Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
65a0b9fa
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,发现更多精彩内容 >>
提交
65a0b9fa
编写于
11月 25, 2022
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复附件下载权限校验
上级
64ad2063
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
192 addition
and
166 deletion
+192
-166
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/Business.java
...ol/src/main/java/com/x/cms/assemble/control/Business.java
+29
-0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/ReviewFactory.java
...ava/com/x/cms/assemble/control/factory/ReviewFactory.java
+36
-25
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryViewDocument.java
...emble/control/jaxrs/document/ActionQueryViewDocument.java
+17
-28
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/fileinfo/ActionFileDownload.java
...s/assemble/control/jaxrs/fileinfo/ActionFileDownload.java
+30
-15
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/fileinfo/ActionFileDownloadStream.java
...mble/control/jaxrs/fileinfo/ActionFileDownloadStream.java
+32
-18
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/fileinfo/ActionGet.java
.../com/x/cms/assemble/control/jaxrs/fileinfo/ActionGet.java
+12
-13
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/UserManagerService.java
...om/x/cms/assemble/control/service/UserManagerService.java
+36
-67
未找到文件。
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/Business.java
浏览文件 @
65a0b9fa
...
...
@@ -7,6 +7,7 @@ import java.util.Set;
import
com.x.cms.core.entity.CategoryInfo
;
import
com.x.cms.core.entity.Document
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.container.EntityManagerContainer
;
...
...
@@ -499,6 +500,34 @@ public class Business {
return
publishFlag
;
}
/**
* 是否是文档的读者
* @param person
* @return
* @throws Exception
*/
public
boolean
isDocumentReader
(
EffectivePerson
person
,
Document
document
)
throws
Exception
{
if
(
isManager
(
person
))
{
return
true
;
}
String
documentType
=
"数据"
;
if
(
documentType
.
equals
(
document
.
getDocumentType
())){
return
true
;
}
if
(
BooleanUtils
.
isTrue
(
document
.
getIsAllRead
())){
return
true
;
}
Long
count
=
this
.
reviewFactory
().
countByDocumentAndPerson
(
document
.
getId
(),
person
.
getDistinguishedName
());
if
(
count
>
0
){
return
true
;
}
count
=
this
.
reviewFactory
().
countByDocumentAndPerson
(
document
.
getId
(),
"*"
);
if
(
count
>
0
){
return
true
;
}
return
false
;
}
/**
* TODO (uncomplete)判断用户是否有权限进行:[表单模板管理]操作
*
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/ReviewFactory.java
浏览文件 @
65a0b9fa
...
...
@@ -26,7 +26,7 @@ import com.x.cms.core.express.tools.filter.QueryFilter;
* 文档权限控制信息服务类
*/
public
class
ReviewFactory
extends
AbstractFactory
{
public
ReviewFactory
(
Business
business
)
throws
Exception
{
super
(
business
);
}
...
...
@@ -34,7 +34,18 @@ public class ReviewFactory extends AbstractFactory {
public
Review
get
(
String
id
)
throws
Exception
{
return
this
.
entityManagerContainer
().
find
(
id
,
Review
.
class
,
ExceptionWhen
.
none
);
}
public
Long
countByDocumentAndPerson
(
String
docId
,
String
person
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Review
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
Review
>
root
=
cq
.
from
(
Review
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Review_
.
docId
),
docId
);
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
Review_
.
permissionObj
),
person
));
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
);
return
em
.
createQuery
(
cq
).
getSingleResult
();
}
public
List
<
String
>
listByAppId
(
String
appId
,
Integer
maxCount
)
throws
Exception
{
if
(
maxCount
==
null
)
{
maxCount
=
1000
;
...
...
@@ -47,7 +58,7 @@ public class ReviewFactory extends AbstractFactory {
cq
.
select
(
root
.
get
(
Review_
.
id
)
).
where
(
p
);
return
em
.
createQuery
(
cq
).
setMaxResults
(
maxCount
).
getResultList
();
}
public
List
<
String
>
listByCategoryId
(
String
categoryId
,
Integer
maxCount
)
throws
Exception
{
if
(
maxCount
==
null
)
{
maxCount
=
1000
;
...
...
@@ -60,7 +71,7 @@ public class ReviewFactory extends AbstractFactory {
cq
.
select
(
root
.
get
(
Review_
.
id
)).
where
(
p
);
return
em
.
createQuery
(
cq
).
setMaxResults
(
maxCount
).
getResultList
();
}
public
List
<
String
>
listByDocument
(
String
docId
,
Integer
maxCount
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Review
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
...
...
@@ -69,8 +80,8 @@ public class ReviewFactory extends AbstractFactory {
Predicate
p
=
cb
.
equal
(
root
.
get
(
Review_
.
docId
),
docId
);
cq
.
select
(
root
.
get
(
Review_
.
id
)).
where
(
p
);
return
em
.
createQuery
(
cq
).
setMaxResults
(
maxCount
).
getResultList
();
}
}
public
List
<
String
>
listByDocumentAndPerson
(
String
docId
,
String
person
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
docId
)
)
{
throw
new
Exception
(
"doc id can not be empty!"
);
...
...
@@ -87,7 +98,7 @@ public class ReviewFactory extends AbstractFactory {
cq
.
select
(
root
.
get
(
Review_
.
id
)).
where
(
p
);
return
em
.
createQuery
(
cq
).
getResultList
();
}
public
Long
countByCategoryId
(
String
categoryId
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Review
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
...
...
@@ -97,7 +108,7 @@ public class ReviewFactory extends AbstractFactory {
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
);
return
em
.
createQuery
(
cq
).
getSingleResult
();
}
public
Long
countByDocuemnt
(
String
docId
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Review
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
...
...
@@ -107,7 +118,7 @@ public class ReviewFactory extends AbstractFactory {
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
);
return
em
.
createQuery
(
cq
).
getSingleResult
();
}
public
Long
countByAppId
(
String
appId
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Review
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
...
...
@@ -117,7 +128,7 @@ public class ReviewFactory extends AbstractFactory {
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
);
return
em
.
createQuery
(
cq
).
getSingleResult
();
}
/**
* 根据条件查询符合条件的文档信息数量
* @param personName
...
...
@@ -138,7 +149,7 @@ public class ReviewFactory extends AbstractFactory {
cq
.
select
(
cb
.
count
(
root
)).
where
(
p
);
return
em
.
createQuery
(
cq
).
getSingleResult
();
}
/**
* 根据条件查询符合条件的文档信息ID
* @param maxCount
...
...
@@ -159,7 +170,7 @@ public class ReviewFactory extends AbstractFactory {
p_permission
=
CriteriaBuilderTools
.
predicate_or
(
cb
,
p_permission
,
cb
.
equal
(
root
.
get
(
Review_
.
permissionObj
),
personName
)
);
}
Predicate
p
=
CriteriaBuilderTools
.
composePredicateWithQueryFilter
(
Review_
.
class
,
cb
,
p_permission
,
root
,
queryFilter
);
List
<
Order
>
orders
=
new
ArrayList
<>();
if
(
!
Review
.
isTop_FIELDNAME
.
equals
(
orderField
))
{
Order
isTopOrder
=
CriteriaBuilderTools
.
getOrder
(
cb
,
root
,
Review_
.
class
,
Review
.
isTop_FIELDNAME
,
"desc"
);
...
...
@@ -176,9 +187,9 @@ public class ReviewFactory extends AbstractFactory {
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
setMaxResults
(
maxCount
).
getResultList
();
}
/**
* 根据条件查询符合条件的文档信息ID,根据上一条的sequnce查询指定数量的信息
* @param maxCount
...
...
@@ -209,7 +220,7 @@ public class ReviewFactory extends AbstractFactory {
}
p
=
cb
.
and
(
p
,
p_seq
);
}
List
<
Order
>
orders
=
new
ArrayList
<>();
if
(
!
Document
.
isTop_FIELDNAME
.
equals
(
orderField
))
{
Order
isTopOrder
=
CriteriaBuilderTools
.
getOrder
(
cb
,
root
,
Document_
.
class
,
Document
.
isTop_FIELDNAME
,
"desc"
);
...
...
@@ -217,12 +228,12 @@ public class ReviewFactory extends AbstractFactory {
orders
.
add
(
isTopOrder
);
}
}
Order
orderWithField
=
CriteriaBuilderTools
.
getOrder
(
cb
,
root
,
Review_
.
class
,
orderField
,
orderType
);
if
(
orderWithField
!=
null
){
orders
.
add
(
orderWithField
);
}
if
(
ListTools
.
isNotEmpty
(
orders
))
{
cq
.
orderBy
(
orders
);
}
...
...
@@ -299,27 +310,27 @@ public class ReviewFactory extends AbstractFactory {
p_permission
=
CriteriaBuilderTools
.
predicate_or
(
cb
,
p_permission
,
cb
.
equal
(
root
.
get
(
Review_
.
permissionObj
),
personName
)
);
}
Predicate
p
=
CriteriaBuilderTools
.
composePredicateWithQueryFilter
(
Review_
.
class
,
cb
,
p_permission
,
root
,
queryFilter
);
//排序,添加排序列,默认使用sequence
List
<
Order
>
orders
=
new
ArrayList
<>();
Order
orderWithField
=
CriteriaBuilderTools
.
getOrder
(
cb
,
root
,
Review_
.
class
,
orderField
,
orderType
);
if
(
orderWithField
!=
null
){
orders
.
add
(
orderWithField
);
}
if
(
!
Document
.
isFieldInSequence
(
orderField
))
{
//如果是其他的列,很可能排序值不唯一,所以使用多一列排序列来确定每次查询的顺序
orderWithField
=
CriteriaBuilderTools
.
getOrder
(
cb
,
root
,
Review_
.
class
,
Review
.
id_FIELDNAME
,
orderType
);
if
(
orderWithField
!=
null
){
orders
.
add
(
orderWithField
);
}
}
}
if
(
ListTools
.
isNotEmpty
(
orders
)){
cq
.
orderBy
(
orders
);
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
setMaxResults
(
maxCount
).
getResultList
();
}
public
List
<
String
>
listDocIdsWithConditionInReview
(
String
personName
,
QueryFilter
queryFilter
,
Integer
maxCount
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Review
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
...
...
@@ -331,10 +342,10 @@ public class ReviewFactory extends AbstractFactory {
}
Predicate
p
=
CriteriaBuilderTools
.
composePredicateWithQueryFilter
(
Review_
.
class
,
cb
,
p_permission
,
root
,
queryFilter
);
cq
.
select
(
root
.
get
(
Review_
.
docId
)).
where
(
p
);
return
em
.
createQuery
(
cq
.
where
(
p
)).
setMaxResults
(
maxCount
).
getResultList
();
}
public
List
<
String
>
listDocIdsWithConditionInReview
(
String
personName
,
String
orderField
,
String
orderType
,
QueryFilter
queryFilter
,
Integer
maxCount
)
throws
Exception
{
List
<
String
>
docIds
=
new
ArrayList
<>();
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Review
.
class
);
...
...
@@ -361,4 +372,4 @@ public class ReviewFactory extends AbstractFactory {
}
return
docIds
;
}
}
\ No newline at end of file
}
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryViewDocument.java
浏览文件 @
65a0b9fa
...
...
@@ -121,10 +121,6 @@ public class ActionQueryViewDocument extends BaseAction {
List
<
String
>
groupNames
=
null
;
Boolean
isAnonymous
=
effectivePerson
.
isAnonymous
();
String
personName
=
effectivePerson
.
getDistinguishedName
();
Business
business
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
}
if
(
!
isAnonymous
)
{
try
{
...
...
@@ -301,39 +297,32 @@ public class ActionQueryViewDocument extends BaseAction {
if
(
isManager
||
isAppAdmin
||
isCategoryAdmin
||
isCreator
)
{
isEditor
=
true
;
}
else
{
// 判断当前登录者是不是该文档的可编辑者
try
{
if
(
!
isAnonymous
)
{
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorPersonList
()
))
{
if
(
document
.
getAuthorPersonList
().
contains
(
getShortTargetFlag
(
personName
)
)
)
{
isEditor
=
true
;
}
if
(
!
isAnonymous
)
{
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorPersonList
()
))
{
if
(
document
.
getAuthorPersonList
().
contains
(
getShortTargetFlag
(
personName
)
)
)
{
isEditor
=
true
;
}
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorUnitList
()
))
{
if
(
ListTools
.
containsAny
(
getShortTargetFlag
(
unitNames
),
document
.
getAuthorUnitList
()
))
{
isEditor
=
true
;
}
}
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorUnitList
()
))
{
if
(
ListTools
.
containsAny
(
getShortTargetFlag
(
unitNames
),
document
.
getAuthorUnitList
()))
{
isEditor
=
true
;
}
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorGroupList
()
))
{
if
(
ListTools
.
containsAny
(
getShortTargetFlag
(
groupNames
),
document
.
getAuthorGroupList
()
))
{
isEditor
=
true
;
}
}
if
(
ListTools
.
isNotEmpty
(
document
.
getAuthorGroupList
()
))
{
if
(
ListTools
.
containsAny
(
getShortTargetFlag
(
groupNames
),
document
.
getAuthorGroupList
()))
{
isEditor
=
true
;
}
}
}
catch
(
Exception
e
)
{
check
=
false
;
Exception
exception
=
new
ExceptionDocumentInfoProcess
(
e
,
"判断用户是否可编辑文档时发生异常!user:"
+
personName
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
}
}
if
(!
isEditor
)
{
check
=
this
.
hasReadPermission
(
business
,
document
,
unitNames
,
groupNames
,
effectivePerson
,
null
);
if
(!
check
)
{
throw
new
ExceptionAccessDenied
(
effectivePerson
,
document
);
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
if
(!
business
.
isDocumentReader
(
effectivePerson
,
document
)){
throw
new
ExceptionAccessDenied
(
effectivePerson
,
document
);
}
}
}
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/fileinfo/ActionFileDownload.java
浏览文件 @
65a0b9fa
package
com.x.cms.assemble.control.jaxrs.fileinfo
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.project.annotation.AuditLog
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.config.StorageMapping
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WoFile
;
import
com.x.cms.assemble.control.Business
;
import
com.x.cms.assemble.control.ThisApplication
;
import
com.x.cms.core.entity.Document
;
import
com.x.cms.core.entity.FileInfo
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.servlet.http.HttpServletRequest
;
/**
* 下载附件
* @author sword
*/
public
class
ActionFileDownload
extends
BaseAction
{
@AuditLog
(
operation
=
"下载附件"
)
protected
ActionResult
<
Wo
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
String
id
,
String
fileName
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
FileInfo
attachment
=
fileInfoServiceAdv
.
get
(
id
);
if
(
null
==
attachment
)
{
throw
new
Exception
(
"附件不存在。id:"
+
id
)
;
}
else
{
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
FileInfo
.
class
,
attachment
.
getStorage
());
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
FileInfo
fileInfo
=
emc
.
find
(
id
,
FileInfo
.
class
);
if
(
null
==
fileInfo
)
{
throw
new
ExceptionFileInfoNotExists
(
id
);
}
if
(
StringUtils
.
isBlank
(
fileName
))
{
fileName
=
attachment
.
getName
();
fileName
=
fileInfo
.
getName
();
}
else
{
String
extension
=
FilenameUtils
.
getExtension
(
fileName
);
if
(
StringUtils
.
isEmpty
(
extension
))
{
fileName
=
fileName
+
"."
+
attachment
.
getExtension
();
fileName
=
fileName
+
"."
+
fileInfo
.
getExtension
();
}
}
Wo
wo
=
new
Wo
(
attachment
.
readContent
(
mapping
),
Document
document
=
emc
.
find
(
fileInfo
.
getDocumentId
(),
Document
.
class
);
if
(
null
==
document
)
{
throw
new
ExceptionDocumentNotExists
(
fileInfo
.
getDocumentId
());
}
Business
business
=
new
Business
(
emc
);
if
(!
business
.
isDocumentReader
(
effectivePerson
,
document
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
FileInfo
.
class
,
fileInfo
.
getStorage
());
Wo
wo
=
new
Wo
(
fileInfo
.
readContent
(
mapping
),
this
.
contentType
(
false
,
fileName
),
this
.
contentDisposition
(
false
,
fileName
));
result
.
setData
(
wo
);
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/fileinfo/ActionFileDownloadStream.java
浏览文件 @
65a0b9fa
package
com.x.cms.assemble.control.jaxrs.fileinfo
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.project.annotation.AuditLog
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.config.StorageMapping
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WoFile
;
import
com.x.cms.assemble.control.Business
;
import
com.x.cms.assemble.control.ThisApplication
;
import
com.x.cms.core.entity.Document
;
import
com.x.cms.core.entity.FileInfo
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.servlet.http.HttpServletRequest
;
/**
* 下载附件
* @author sword
*/
public
class
ActionFileDownloadStream
extends
BaseAction
{
@AuditLog
(
operation
=
"下载附件"
)
protected
ActionResult
<
Wo
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
String
id
,
String
fileName
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
FileInfo
attachment
=
fileInfoServiceAdv
.
get
(
id
);
if
(
null
==
attachment
)
{
throw
new
Exception
(
"附件不存在。id:"
+
id
)
;
}
else
{
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
FileInfo
.
class
,
attachment
.
getStorage
());
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
FileInfo
fileInfo
=
emc
.
find
(
id
,
FileInfo
.
class
);
if
(
null
==
fileInfo
)
{
throw
new
ExceptionFileInfoNotExists
(
id
);
}
if
(
StringUtils
.
isBlank
(
fileName
))
{
fileName
=
attachment
.
getName
();
fileName
=
fileInfo
.
getName
();
}
else
{
String
extension
=
FilenameUtils
.
getExtension
(
fileName
);
if
(
StringUtils
.
isEmpty
(
extension
))
{
fileName
=
fileName
+
"."
+
attachment
.
getExtension
();
fileName
=
fileName
+
"."
+
fileInfo
.
getExtension
();
}
}
Wo
wo
=
new
Wo
(
attachment
.
readContent
(
mapping
),
this
.
contentType
(
true
,
fileName
),
this
.
contentDisposition
(
true
,
fileName
));
Document
document
=
emc
.
find
(
fileInfo
.
getDocumentId
(),
Document
.
class
);
if
(
null
==
document
)
{
throw
new
ExceptionDocumentNotExists
(
fileInfo
.
getDocumentId
());
}
Business
business
=
new
Business
(
emc
);
if
(!
business
.
isDocumentReader
(
effectivePerson
,
document
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
FileInfo
.
class
,
fileInfo
.
getStorage
());
Wo
wo
=
new
Wo
(
fileInfo
.
readContent
(
mapping
),
this
.
contentType
(
true
,
fileName
),
this
.
contentDisposition
(
true
,
fileName
));
result
.
setData
(
wo
);
}
return
result
;
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/fileinfo/ActionGet.java
浏览文件 @
65a0b9fa
...
...
@@ -13,8 +13,10 @@ 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.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.cms.assemble.control.Business
;
import
com.x.cms.core.entity.Document
;
import
com.x.cms.core.entity.FileInfo
;
...
...
@@ -23,8 +25,6 @@ public class ActionGet extends BaseAction {
protected
ActionResult
<
Wo
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
String
id
,
String
documentId
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wrap
=
null
;
List
<
String
>
attachmentIds
=
null
;
Cache
.
CacheKey
cacheKey
=
new
Cache
.
CacheKey
(
this
.
getClass
(),
id
);
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
...
...
@@ -33,20 +33,19 @@ public class ActionGet extends BaseAction {
result
.
setData
(
wrap
);
}
else
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
//先查询附件是否该文档里的附件,从属关系是否正常
Document
document
=
emc
.
find
(
documentId
,
Document
.
class
);
if
(
null
==
document
)
{
throw
new
Exception
(
"document{id:"
+
documentId
+
"} not existed."
);
}
attachmentIds
=
fileInfoServiceAdv
.
listIdsWithDocId
(
documentId
);
if
(
attachmentIds
==
null
||
!
attachmentIds
.
contains
(
id
))
{
throw
new
Exception
(
"document{id"
+
documentId
+
"} not contian attachment{id:"
+
id
+
"}."
);
}
FileInfo
fileInfo
=
emc
.
find
(
id
,
FileInfo
.
class
);
if
(
null
==
fileInfo
)
{
throw
new
Exception
(
"需要查询的附件或者文件信息不存在,请联系管理员。ID:"
+
id
);
throw
new
ExceptionFileInfoNotExists
(
id
);
}
Document
document
=
emc
.
find
(
fileInfo
.
getDocumentId
(),
Document
.
class
);
if
(
null
==
document
)
{
throw
new
ExceptionDocumentNotExists
(
fileInfo
.
getDocumentId
());
}
Business
business
=
new
Business
(
emc
);
if
(!
business
.
isDocumentReader
(
effectivePerson
,
document
)){
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
//如果信息存在,则需要向客户端返回信息,先将查询出来的JPA对象COPY到一个普通JAVA对象里,再进行返回
wrap
=
Wo
.
copier
.
copy
(
fileInfo
);
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wrap
);
result
.
setData
(
wrap
);
...
...
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/UserManagerService.java
浏览文件 @
65a0b9fa
package
com.x.cms.assemble.control.service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
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.base.core.project.organization.Identity
;
import
com.x.base.core.project.organization.OrganizationDefinition
;
import
com.x.base.core.project.organization.Person
;
import
com.x.base.core.project.organization.Unit
;
import
com.x.base.core.project.tools.ListTools
;
...
...
@@ -19,6 +14,12 @@ import com.x.cms.assemble.control.Business;
import
com.x.cms.assemble.control.ThisApplication
;
import
com.x.cms.core.entity.AppInfo
;
import
com.x.organization.core.entity.PersistenceProperties
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.regex.Matcher
;
/**
* 组织人员角色相关信息的服务类
...
...
@@ -37,17 +38,14 @@ public class UserManagerService {
* @throws Exception
*/
public
Person
getPerson
(
String
personName
)
throws
Exception
{
Person
person
=
null
;
try
{
Business
business
=
new
Business
(
null
);
if
(
personName
.
split
(
"@"
).
length
==
2
){
personName
=
personName
.
split
(
"@"
)[
0
];
}
person
=
business
.
organization
().
person
().
getObject
(
personName
);
}
catch
(
Exception
e
)
{
throw
e
;
if
(
StringUtils
.
isNotBlank
(
personName
)){
return
null
;
}
Business
business
=
new
Business
(
null
);
if
(
personName
.
split
(
"@"
).
length
==
2
){
personName
=
personName
.
split
(
"@"
)[
0
];
}
return
person
;
return
business
.
organization
().
person
().
getObject
(
personName
)
;
}
/**
...
...
@@ -65,12 +63,10 @@ public class UserManagerService {
Unit
unit
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
unitNames
=
business
.
organization
().
unit
().
listWithPerson
(
personName
);
if
(
ListTools
.
isEmpty
(
unitNames
))
{
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@P"
).
length
==
2
)
{
unitNames
=
business
.
organization
().
unit
().
listWithPerson
(
personName
.
split
(
"@"
)[
0
]
);
}
if
(
StringUtils
.
isNotBlank
(
personName
)
&&
personName
.
split
(
"@"
).
length
==
2
){
personName
=
personName
.
split
(
"@"
)[
0
];
}
unitNames
=
business
.
organization
().
unit
().
listWithPerson
(
personName
);
if
(
ListTools
.
isNotEmpty
(
unitNames
))
{
for
(
String
unitName
:
unitNames
)
{
unit
=
business
.
organization
().
unit
().
getObject
(
unitName
);
...
...
@@ -94,17 +90,8 @@ public class UserManagerService {
* @throws Exception
*/
public
String
getUnitNameByIdentity
(
String
identity
)
throws
Exception
{
Business
business
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
return
business
.
organization
().
unit
().
getWithIdentity
(
identity
);
}
catch
(
NullPointerException
e
)
{
System
.
out
.
println
(
"根据身份获取所属组织名称时发生NullPointerException异常。identity:"
+
identity
);
return
null
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"根据身份获取所属组织名称时发生异常。identity:"
+
identity
);
throw
e
;
}
Business
business
=
new
Business
(
null
);
return
business
.
organization
().
unit
().
getWithIdentity
(
identity
);
}
/**
...
...
@@ -120,16 +107,14 @@ public class UserManagerService {
Business
business
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
// 兼容一下传过来的perosnName有可能是个人,有可能是身份
if
(
StringUtils
.
isNotEmpty
(
personName
)){
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@P"
).
length
==
2
)
{
personName
=
business
.
organization
().
person
().
get
(
personName
.
split
(
"@"
)[
0
]);
}
else
{
personName
=
business
.
organization
().
person
().
get
(
personName
);
if
(!
OrganizationDefinition
.
isPersonDistinguishedName
(
personName
)){
if
(
personName
.
split
(
"@"
).
length
==
2
){
personName
=
personName
.
split
(
"@"
)[
0
];
}
personName
=
business
.
organization
().
person
().
get
(
personName
);
}
identity
=
getMajorIdentityWithPerson
(
personName
);
if
(
identity
!=
null
&&
!
identity
.
isEmpty
(
))
{
if
(
StringUtils
.
isNotBlank
(
identity
))
{
topUnitName
=
business
.
organization
().
unit
().
getWithIdentityWithLevel
(
identity
,
1
);
}
return
topUnitName
;
...
...
@@ -168,8 +153,8 @@ public class UserManagerService {
Business
business
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
if
(
StringUtils
.
isNotEmpty
(
personName
)){
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@
P
"
).
length
==
2
)
{
if
(
!
OrganizationDefinition
.
isPersonDistinguishedName
(
personName
)){
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@"
).
length
==
2
)
{
personName
=
business
.
organization
().
person
().
get
(
personName
.
split
(
"@"
)[
0
]);
}
else
{
personName
=
business
.
organization
().
person
().
get
(
personName
);
...
...
@@ -182,7 +167,7 @@ public class UserManagerService {
}
else
{
for
(
String
identity
:
identities
)
{
Identity
obj
=
business
.
organization
().
identity
().
getObject
(
identity
);
if
(
obj
.
getMajor
(
))
{
if
(
BooleanUtils
.
isTrue
(
obj
.
getMajor
()
))
{
return
identity
;
}
}
...
...
@@ -229,12 +214,8 @@ public class UserManagerService {
Business
business
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
if
(
StringUtils
.
isNotEmpty
(
personName
)){
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@P"
).
length
==
2
)
{
personName
=
business
.
organization
().
person
().
get
(
personName
.
split
(
"@"
)[
0
]);
}
else
{
personName
=
business
.
organization
().
person
().
get
(
personName
);
}
if
(
StringUtils
.
isNotEmpty
(
personName
)
&&
personName
.
split
(
"@"
).
length
==
2
){
personName
=
personName
.
split
(
"@"
)[
0
];
}
unitNames
=
business
.
organization
().
unit
().
listWithPersonSupNested
(
personName
);
return
unitNames
==
null
?
new
ArrayList
<>()
:
unitNames
;
...
...
@@ -259,12 +240,8 @@ public class UserManagerService {
Business
business
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
if
(
StringUtils
.
isNotEmpty
(
personName
)){
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@P"
).
length
==
2
)
{
personName
=
business
.
organization
().
person
().
get
(
personName
.
split
(
"@"
)[
0
]);
}
else
{
personName
=
business
.
organization
().
person
().
get
(
personName
);
}
if
(
StringUtils
.
isNotEmpty
(
personName
)
&&
personName
.
split
(
"@"
).
length
==
2
){
personName
=
personName
.
split
(
"@"
)[
0
];
}
return
business
.
organization
().
identity
().
listWithPerson
(
personName
);
}
catch
(
NullPointerException
e
)
{
...
...
@@ -288,7 +265,7 @@ public class UserManagerService {
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
if
(
StringUtils
.
isNotEmpty
(
personName
)){
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@
P
"
).
length
==
2
)
{
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@"
).
length
==
2
)
{
personName
=
business
.
organization
().
person
().
get
(
personName
.
split
(
"@"
)[
0
]);
}
else
{
personName
=
business
.
organization
().
person
().
get
(
personName
);
...
...
@@ -319,12 +296,8 @@ public class UserManagerService {
List
<
String
>
nameList
=
new
ArrayList
<
String
>();
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
if
(
StringUtils
.
isNotEmpty
(
personName
)){
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@P"
).
length
==
2
)
{
personName
=
business
.
organization
().
person
().
get
(
personName
.
split
(
"@"
)[
0
]);
}
else
{
personName
=
business
.
organization
().
person
().
get
(
personName
);
}
if
(
StringUtils
.
isNotEmpty
(
personName
)
&&
personName
.
split
(
"@"
).
length
==
2
){
personName
=
personName
.
split
(
"@"
)[
0
];
}
groupList
=
business
.
organization
().
group
().
listWithPerson
(
personName
);
if
(
groupList
!=
null
&&
groupList
.
size
()
>
0
)
{
...
...
@@ -357,12 +330,8 @@ public class UserManagerService {
Business
business
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
business
=
new
Business
(
emc
);
if
(
StringUtils
.
isNotEmpty
(
personName
)){
if
(
personName
.
endsWith
(
"@P"
)
&&
personName
.
split
(
"@P"
).
length
==
2
)
{
personName
=
business
.
organization
().
person
().
get
(
personName
.
split
(
"@"
)[
0
]);
}
else
{
personName
=
business
.
organization
().
person
().
get
(
personName
);
}
if
(
StringUtils
.
isNotEmpty
(
personName
)
&&
personName
.
split
(
"@"
).
length
==
2
){
personName
=
personName
.
split
(
"@"
)[
0
];
}
roleList
=
business
.
organization
().
role
().
listWithPerson
(
personName
);
if
(
roleList
!=
null
&&
!
roleList
.
isEmpty
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录