Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
90a16c98
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
90a16c98
编写于
11月 05, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cms增加根据id列表查询doc数据接口
上级
e6267412
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
253 addition
and
116 deletion
+253
-116
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/CmsJaxrsFilter.java
...java/com/x/cms/assemble/control/jaxrs/CmsJaxrsFilter.java
+2
-2
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListDocumentData.java
...e/control/jaxrs/document/ActionQueryListDocumentData.java
+142
-0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryPermissionReadDocument.java
...rol/jaxrs/document/ActionQueryPermissionReadDocument.java
+10
-114
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/BaseAction.java
...com/x/cms/assemble/control/jaxrs/document/BaseAction.java
+80
-0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/DocumentAction.java
...x/cms/assemble/control/jaxrs/document/DocumentAction.java
+19
-0
未找到文件。
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/CmsJaxrsFilter.java
浏览文件 @
90a16c98
package
com.x.cms.assemble.control.jaxrs
;
import
com.x.base.core.project.jaxrs.ManagerUserJaxrsFilter
;
import
com.x.base.core.project.jaxrs.
Cipher
ManagerUserJaxrsFilter
;
import
javax.servlet.annotation.WebFilter
;
...
...
@@ -40,6 +40,6 @@ import javax.servlet.annotation.WebFilter;
"/jaxrs/commend/*"
,
"/servlet/*"
},
asyncSupported
=
true
)
public
class
CmsJaxrsFilter
extends
ManagerUserJaxrsFilter
{
public
class
CmsJaxrsFilter
extends
Cipher
ManagerUserJaxrsFilter
{
}
\ No newline at end of file
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListDocumentData.java
0 → 100644
浏览文件 @
90a16c98
package
com.x.cms.assemble.control.jaxrs.document
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.cache.Cache
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.cms.assemble.control.Business
;
import
com.x.cms.core.entity.Document
;
import
com.x.cms.core.entity.content.Data
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
public
class
ActionQueryListDocumentData
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionQueryListDocumentData
.
class
);
protected
ActionResult
<
List
<
Wo
>>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
Business
business
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
}
List
<
Wo
>
wos
=
new
ArrayList
<>();
if
(
wi
.
getDocIds
()!=
null
)
{
List
<
String
>
unitNames
=
userManagerService
.
listUnitNamesWithPerson
(
effectivePerson
.
getDistinguishedName
());
List
<
String
>
groupNames
=
userManagerService
.
listGroupNamesByPerson
(
effectivePerson
.
getDistinguishedName
());
for
(
String
id
:
wi
.
getDocIds
()){
Cache
.
CacheKey
cacheKey
=
new
Cache
.
CacheKey
(
this
.
getClass
(),
id
,
effectivePerson
.
getDistinguishedName
());
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
wos
.
add
((
Wo
)
optional
.
get
());
}
else
{
Wo
wo
=
getDocumentQueryResult
(
business
,
id
,
effectivePerson
,
unitNames
,
groupNames
);
if
(
wo
!=
null
)
{
wos
.
add
(
wo
);
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wo
);
}
}
}
}
result
.
setData
(
wos
);
return
result
;
}
/**
* 获取需要返回的文档信息对象
* @param id
* @param effectivePerson
* @return
*/
private
Wo
getDocumentQueryResult
(
Business
business
,
String
id
,
EffectivePerson
effectivePerson
,
List
<
String
>
unitNames
,
List
<
String
>
groupNames
)
throws
Exception
{
Wo
wo
=
new
Wo
();
Document
document
=
documentQueryService
.
view
(
id
,
effectivePerson
);
if
(
document
!=
null
){
if
(
this
.
hasReadPermission
(
business
,
document
,
unitNames
,
groupNames
,
effectivePerson
,
null
))
{
WoDocument
woOutDocument
=
WoDocument
.
copier
.
copy
(
document
);
wo
.
setDocId
(
id
);
wo
.
setDocument
(
woOutDocument
);
if
(
woOutDocument
!=
null
)
{
wo
.
setData
(
documentQueryService
.
getDocumentData
(
document
));
}
}
else
{
return
null
;
}
}
return
wo
;
}
public
static
class
Wo
extends
GsonPropertyObject
{
@FieldDescribe
(
"文档ID."
)
private
String
docId
;
@FieldDescribe
(
"作为输出的CMS文档数据对象."
)
private
WoDocument
document
;
@FieldDescribe
(
"文档所有数据信息."
)
private
Data
data
;
public
String
getDocId
()
{
return
docId
;
}
public
void
setDocId
(
String
docId
)
{
this
.
docId
=
docId
;
}
public
WoDocument
getDocument
()
{
return
document
;
}
public
void
setDocument
(
WoDocument
document
)
{
this
.
document
=
document
;
}
public
Data
getData
()
{
return
data
;
}
public
void
setData
(
Data
data
)
{
this
.
data
=
data
;
}
}
public
static
class
WoDocument
extends
Document
{
private
static
final
long
serialVersionUID
=
-
5076990764713538973L
;
public
static
List
<
String
>
Excludes
=
new
ArrayList
<
String
>();
public
static
WrapCopier
<
Document
,
WoDocument
>
copier
=
WrapCopierFactory
.
wo
(
Document
.
class
,
WoDocument
.
class
,
null
,
JpaObject
.
FieldsInvisible
);
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"文档id"
)
private
List
<
String
>
docIds
=
new
ArrayList
<>();
public
List
<
String
>
getDocIds
()
{
return
docIds
;
}
public
void
setDocIds
(
List
<
String
>
docIds
)
{
this
.
docIds
=
docIds
;
}
}
}
\ No newline at end of file
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryPermissionReadDocument.java
浏览文件 @
90a16c98
package
com.x.cms.assemble.control.jaxrs.document
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WrapBoolean
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.organization.Person
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.cms.core.entity.AppInfo
;
import
com.x.cms.core.entity.CategoryInfo
;
import
com.x.cms.assemble.control.Business
;
import
com.x.cms.core.entity.Document
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.List
;
public
class
ActionQueryPermissionReadDocument
extends
BaseAction
{
...
...
@@ -19,6 +16,10 @@ public class ActionQueryPermissionReadDocument extends BaseAction {
protected
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
id
,
String
queryPerson
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Business
business
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
}
Wo
wo
=
new
Wo
();
wo
.
setValue
(
false
);
result
.
setData
(
wo
);
...
...
@@ -26,115 +27,10 @@ public class ActionQueryPermissionReadDocument extends BaseAction {
if
(
document
==
null
){
return
result
;
}
//匿名用户是否可读
if
(
effectivePerson
.
isAnonymous
()){
AppInfo
appInfo
=
appInfoServiceAdv
.
get
(
document
.
getAppId
()
);
CategoryInfo
categoryInfo
=
categoryInfoServiceAdv
.
get
(
document
.
getCategoryId
());
if
(
appInfo
!=
null
&&
categoryInfo
!=
null
){
boolean
flag
=
true
;
//检查这个文档所在的栏目和分类是否都是全员可见
if
(
(
ListTools
.
isNotEmpty
(
document
.
getReadPersonList
()
)
&&
!
document
.
getReadPersonList
().
contains
(
"所有人"
)
)
||
ListTools
.
isNotEmpty
(
document
.
getReadUnitList
()
)
||
ListTools
.
isNotEmpty
(
document
.
getReadGroupList
()
)
)
{
flag
=
false
;
}
//检查这个文档所在的栏目和分类是否都是全员可见
if
(
!
appInfo
.
getAllPeopleView
()
)
{
//栏目不可见
flag
=
false
;
}
//检查这个文档所在的栏目和分类是否都是全员可见
if
(
!
categoryInfo
.
getAllPeopleView
()
)
{
//分类不可见
flag
=
false
;
}
wo
.
setValue
(
flag
);
return
result
;
}
}
else
{
String
personName
=
effectivePerson
.
getDistinguishedName
();
if
(
effectivePerson
.
isManager
()){
if
(
StringUtils
.
isNotEmpty
(
queryPerson
)){
Person
person
=
userManagerService
.
getPerson
(
queryPerson
);
if
(
person
!=
null
){
personName
=
person
.
getDistinguishedName
();
}
else
{
return
result
;
}
}
else
{
wo
.
setValue
(
true
);
return
result
;
}
}
List
<
String
>
unitNames
=
userManagerService
.
listUnitNamesWithPerson
(
personName
);
List
<
String
>
groupNames
=
userManagerService
.
listGroupNamesByPerson
(
personName
);
//是否是读者
if
(
ListTools
.
contains
(
document
.
getReadPersonList
(),
getShortTargetFlag
(
personName
))
||
ListTools
.
contains
(
document
.
getReadPersonList
(),
"所有人"
)){
wo
.
setValue
(
true
);
return
result
;
}
for
(
String
unitName
:
unitNames
){
if
(
ListTools
.
contains
(
document
.
getReadUnitList
(),
getShortTargetFlag
(
unitName
))){
wo
.
setValue
(
true
);
return
result
;
}
}
for
(
String
groupName
:
groupNames
){
if
(
ListTools
.
contains
(
document
.
getReadGroupList
(),
getShortTargetFlag
(
groupName
))){
wo
.
setValue
(
true
);
return
result
;
}
}
//是否是作者
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorPersonList
()
))
{
if
(
document
.
getAuthorPersonList
().
contains
(
personName
)
)
{
wo
.
setValue
(
true
);
return
result
;
}
}
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorUnitList
()
))
{
if
(
ListTools
.
containsAny
(
unitNames
,
document
.
getAuthorUnitList
()))
{
wo
.
setValue
(
true
);
return
result
;
}
}
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorGroupList
()
))
{
if
(
ListTools
.
containsAny
(
groupNames
,
document
.
getAuthorGroupList
()))
{
wo
.
setValue
(
true
);
return
result
;
}
}
//是否是分类的管理者
CategoryInfo
categoryInfo
=
categoryInfoServiceAdv
.
get
(
document
.
getCategoryId
());
if
(
categoryInfoServiceAdv
.
isCategoryInfoManager
(
categoryInfo
,
personName
,
unitNames
,
groupNames
))
{
wo
.
setValue
(
true
);
return
result
;
}
//是否是栏目的管理者
AppInfo
appInfo
=
appInfoServiceAdv
.
get
(
document
.
getAppId
()
);
if
(
appInfoServiceAdv
.
isAppInfoManager
(
appInfo
,
personName
,
unitNames
,
groupNames
))
{
wo
.
setValue
(
true
);
return
result
;
}
}
return
result
;
}
wo
.
setValue
(
this
.
hasReadPermission
(
business
,
document
,
null
,
null
,
effectivePerson
,
queryPerson
));
private
String
getShortTargetFlag
(
String
distinguishedName
)
{
String
target
=
null
;
if
(
StringUtils
.
isNotEmpty
(
distinguishedName
)
){
String
[]
array
=
distinguishedName
.
split
(
"@"
);
StringBuffer
sb
=
new
StringBuffer
();
if
(
array
.
length
==
3
){
target
=
sb
.
append
(
array
[
1
]).
append
(
"@"
).
append
(
array
[
2
]).
toString
();
}
else
if
(
array
.
length
==
2
){
//2段
target
=
sb
.
append
(
array
[
0
]).
append
(
"@"
).
append
(
array
[
1
]).
toString
();
}
else
{
target
=
array
[
0
];
}
}
return
target
;
return
result
;
}
public
static
class
Wo
extends
WrapBoolean
{
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/BaseAction.java
浏览文件 @
90a16c98
...
...
@@ -6,9 +6,12 @@ import com.x.base.core.container.EntityManagerContainer;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.annotation.CheckPersistType
;
import
com.x.base.core.project.cache.Cache
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.StandardJaxrsAction
;
import
com.x.base.core.project.organization.Person
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.cms.assemble.control.Business
;
import
com.x.cms.assemble.control.ThisApplication
;
import
com.x.cms.assemble.control.service.AppInfoServiceAdv
;
import
com.x.cms.assemble.control.service.CategoryInfoServiceAdv
;
import
com.x.cms.assemble.control.service.DocCommendPersistService
;
...
...
@@ -23,6 +26,7 @@ import com.x.cms.assemble.control.service.QueryViewService;
import
com.x.cms.assemble.control.service.UserManagerService
;
import
com.x.cms.core.entity.*
;
import
com.x.query.core.entity.Item
;
import
org.apache.commons.lang3.StringUtils
;
public
class
BaseAction
extends
StandardJaxrsAction
{
...
...
@@ -208,6 +212,82 @@ public class BaseAction extends StandardJaxrsAction {
return
false
;
}
protected
boolean
hasReadPermission
(
Business
business
,
Document
document
,
List
<
String
>
unitNames
,
List
<
String
>
groupNames
,
EffectivePerson
effectivePerson
,
String
queryPerson
)
throws
Exception
{
String
personName
=
effectivePerson
.
getDistinguishedName
();
if
(
effectivePerson
.
isManager
()){
if
(
StringUtils
.
isNotEmpty
(
queryPerson
)){
Person
person
=
userManagerService
.
getPerson
(
queryPerson
);
if
(
person
!=
null
){
personName
=
person
.
getDistinguishedName
();
}
else
{
return
false
;
}
}
else
{
return
true
;
}
}
//是否是读者
if
(
ListTools
.
contains
(
document
.
getReadPersonList
(),
getShortTargetFlag
(
personName
))
||
ListTools
.
contains
(
document
.
getReadPersonList
(),
"所有人"
)){
return
true
;
}
if
(
unitNames
==
null
){
unitNames
=
userManagerService
.
listUnitNamesWithPerson
(
personName
);
}
for
(
String
unitName
:
unitNames
){
if
(
ListTools
.
contains
(
document
.
getReadUnitList
(),
getShortTargetFlag
(
unitName
))){
return
true
;
}
}
if
(
groupNames
==
null
){
groupNames
=
userManagerService
.
listGroupNamesByPerson
(
personName
);
}
for
(
String
groupName
:
groupNames
){
if
(
ListTools
.
contains
(
document
.
getReadGroupList
(),
getShortTargetFlag
(
groupName
))){
return
true
;
}
}
//是否是作者
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorPersonList
()
))
{
if
(
document
.
getAuthorPersonList
().
contains
(
personName
)
)
{
return
true
;
}
}
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorUnitList
()
))
{
if
(
ListTools
.
containsAny
(
unitNames
,
document
.
getAuthorUnitList
()))
{
return
true
;
}
}
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorGroupList
()
))
{
if
(
ListTools
.
containsAny
(
groupNames
,
document
.
getAuthorGroupList
()))
{
return
true
;
}
}
if
(
business
.
isHasPlatformRole
(
personName
,
ThisApplication
.
ROLE_CMSManager
)){
return
true
;
}
return
false
;
}
protected
String
getShortTargetFlag
(
String
distinguishedName
)
{
String
target
=
null
;
if
(
StringUtils
.
isNotEmpty
(
distinguishedName
)
){
String
[]
array
=
distinguishedName
.
split
(
"@"
);
StringBuffer
sb
=
new
StringBuffer
();
if
(
array
.
length
==
3
){
target
=
sb
.
append
(
array
[
1
]).
append
(
"@"
).
append
(
array
[
2
]).
toString
();
}
else
if
(
array
.
length
==
2
){
//2段
target
=
sb
.
append
(
array
[
0
]).
append
(
"@"
).
append
(
array
[
1
]).
toString
();
}
else
{
target
=
array
[
0
];
}
}
return
target
;
}
// /**
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/DocumentAction.java
浏览文件 @
90a16c98
...
...
@@ -676,4 +676,23 @@ public class DocumentAction extends StandardJaxrsAction{
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"列示文档数据."
,
action
=
ActionQueryListDocumentData
.
class
)
@POST
@Path
(
"list/document/data"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
query_listDocumentData
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
JsonElement
jsonElement
)
{
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
ActionResult
<
List
<
ActionQueryListDocumentData
.
Wo
>>
result
=
new
ActionResult
<>();
try
{
result
=
((
ActionQueryListDocumentData
)
proxy
.
getProxy
(
ActionQueryListDocumentData
.
class
)).
execute
(
request
,
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
result
.
error
(
e
);
logger
.
error
(
e
,
effectivePerson
,
request
,
jsonElement
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录