Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
164ee345
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,发现更多精彩内容 >>
提交
164ee345
编写于
12月 08, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
流程上传附件控制附件类型和附件大小
上级
e0c47eaf
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
158 addition
and
3 deletion
+158
-3
o2server/configSample/processPlatform.json
o2server/configSample/processPlatform.json
+10
-1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ProcessPlatform.java
.../java/com/x/base/core/project/config/ProcessPlatform.java
+57
-1
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUpdate.java
...tform/assemble/surface/jaxrs/attachment/ActionUpdate.java
+2
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUpdateCallback.java
...semble/surface/jaxrs/attachment/ActionUpdateCallback.java
+2
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadCallback.java
...semble/surface/jaxrs/attachment/ActionUploadCallback.java
+2
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWithWork.java
...semble/surface/jaxrs/attachment/ActionUploadWithWork.java
+3
-1
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWithWorkCompleted.java
...rface/jaxrs/attachment/ActionUploadWithWorkCompleted.java
+3
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/BaseAction.java
...latform/assemble/surface/jaxrs/attachment/BaseAction.java
+45
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ExceptionAttachmentInvalid.java
.../surface/jaxrs/attachment/ExceptionAttachmentInvalid.java
+17
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ExceptionAttachmentInvalidCallback.java
.../jaxrs/attachment/ExceptionAttachmentInvalidCallback.java
+17
-0
未找到文件。
o2server/configSample/processPlatform.json
浏览文件 @
164ee345
...
...
@@ -59,6 +59,14 @@
"###thresholdMinutes"
:
"当工作滞留设定时间后,将尝试触发工作流转,可以自动处理由于人员变动的引起的工作滞留,默认24*60分钟.###"
},
"processingSignalPersistEnable"
:
false
,
"attachmentConfig"
:
{
"fileSize"
:
0.0
,
"fileTypeIncludes"
:
[],
"fileTypeExcludes"
:
[],
"###fileSize"
:
"附件大小限制(单位M,默认不限制).###"
,
"###fileTypeIncludes"
:
"只允许上传的文件后缀###"
,
"###fileTypeExcludes"
:
"不允许上传的文件后缀###"
},
"###maintenanceIdentity"
:
"维护身份,当工作发生意外错误,无法找到对应的处理人情况下,先尝试将工作分配给创建身份,如果创建身份也不可获取,那么分配给指定人员,默认情况下这个值为空.###"
,
"###formVersionCount"
:
"表单历史版本保留数量,0为不保留.###"
,
"###processVersionCount"
:
"流程历史版本保留数量,0为不保留.###"
,
...
...
@@ -96,5 +104,6 @@
"###count"
:
"提醒数量限制.###"
},
"###extensionEvents"
:
"事件扩充.###"
,
"###processingSignalPersistEnable"
:
"是否保存工作处理信号内容,默认false.###"
"###processingSignalPersistEnable"
:
"是否保存工作处理信号内容,默认false.###"
,
"###attachmentConfig"
:
"流程附件上传限制大小或者类型.###"
}
\ No newline at end of file
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ProcessPlatform.java
浏览文件 @
164ee345
...
...
@@ -75,6 +75,7 @@ public class ProcessPlatform extends ConfigObject {
this
.
deleteDraft
=
new
DeleteDraft
();
this
.
passExpired
=
new
PassExpired
();
this
.
processingSignalPersistEnable
=
DEFAULT_PROCESSINGSIGNALPERSISTENABLE
;
this
.
attachmentConfig
=
new
AttachmentConfig
();
}
public
Integer
getExecutorCount
()
{
...
...
@@ -170,6 +171,10 @@ public class ProcessPlatform extends ConfigObject {
@FieldDescribe
(
"是否保存工作处理信号内容,默认false."
)
private
Boolean
processingSignalPersistEnable
;
@FieldDescribe
(
"流程附件上传限制大小或者类型."
)
private
AttachmentConfig
attachmentConfig
;
public
Boolean
getProcessingSignalPersistEnable
()
{
if
(
processingSignalPersistEnable
==
null
)
{
this
.
processingSignalPersistEnable
=
DEFAULT_PROCESSINGSIGNALPERSISTENABLE
;
...
...
@@ -184,6 +189,14 @@ public class ProcessPlatform extends ConfigObject {
return
extensionEvents
;
}
public
AttachmentConfig
getAttachmentConfig
()
{
return
this
.
attachmentConfig
==
null
?
new
AttachmentConfig
()
:
attachmentConfig
;
}
public
void
setAttachmentConfig
(
AttachmentConfig
attachmentConfig
)
{
this
.
attachmentConfig
=
attachmentConfig
;
}
public
Urge
getUrge
()
{
return
this
.
urge
==
null
?
new
Urge
()
:
this
.
urge
;
}
...
...
@@ -593,6 +606,49 @@ public class ProcessPlatform extends ConfigObject {
}
public
static
class
AttachmentConfig
extends
ConfigObject
{
public
static
AttachmentConfig
defaultInstance
()
{
AttachmentConfig
o
=
new
AttachmentConfig
();
return
o
;
}
public
static
final
Integer
DEFAULT_FILE_SIZE
=
0
;
@FieldDescribe
(
"附件大小限制(单位M,默认不限制)."
)
private
Integer
fileSize
=
DEFAULT_FILE_SIZE
;
@FieldDescribe
(
"只允许上传的文件后缀"
)
private
List
<
String
>
fileTypeIncludes
=
new
ArrayList
<>();
@FieldDescribe
(
"不允许上传的文件后缀"
)
private
List
<
String
>
fileTypeExcludes
=
new
ArrayList
<>();
public
Integer
getFileSize
()
{
return
fileSize
;
}
public
void
setFileSize
(
Integer
fileSize
)
{
this
.
fileSize
=
fileSize
;
}
public
List
<
String
>
getFileTypeIncludes
()
{
return
fileTypeIncludes
;
}
public
void
setFileTypeIncludes
(
List
<
String
>
fileTypeIncludes
)
{
this
.
fileTypeIncludes
=
fileTypeIncludes
;
}
public
List
<
String
>
getFileTypeExcludes
()
{
return
fileTypeExcludes
;
}
public
void
setFileTypeExcludes
(
List
<
String
>
fileTypeExcludes
)
{
this
.
fileTypeExcludes
=
fileTypeExcludes
;
}
}
public
static
class
ExtensionEvents
{
@FieldDescribe
(
"工作附件上传."
)
...
...
@@ -841,4 +897,4 @@ public class ProcessPlatform extends ConfigObject {
}
}
\ No newline at end of file
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUpdate.java
浏览文件 @
164ee345
...
...
@@ -72,6 +72,8 @@ class ActionUpdate extends BaseAction {
throw
new
ExceptionAccessDenied
(
effectivePerson
,
attachment
);
}
this
.
verifyConstraint
(
bytes
.
length
,
fileName
,
null
);
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
Attachment
.
class
,
attachment
.
getStorage
());
emc
.
beginTransaction
(
Attachment
.
class
);
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUpdateCallback.java
浏览文件 @
164ee345
...
...
@@ -51,6 +51,8 @@ class ActionUpdateCallback extends BaseAction {
// attachment.getExtension())) {
// throw new ExceptionExtensionNotMatch(fileName, attachment.getExtension());
// }
this
.
verifyConstraint
(
bytes
.
length
,
fileName
,
null
);
/** 统计待办数量判断用户是否可以上传附件 */
WoControl
control
=
business
.
getControl
(
effectivePerson
,
work
,
WoControl
.
class
);
if
(
BooleanUtils
.
isNotTrue
(
control
.
getAllowProcessing
()))
{
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadCallback.java
浏览文件 @
164ee345
...
...
@@ -48,6 +48,8 @@ class ActionUploadCallback extends BaseAction {
// if (StringUtils.isEmpty(fileName)) {
// throw new ExceptionEmptyExtension(fileName);
// }
this
.
verifyConstraint
(
bytes
.
length
,
fileName
,
callback
);
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
random
(
Attachment
.
class
);
Attachment
attachment
=
this
.
concreteAttachment
(
work
,
effectivePerson
,
site
);
attachment
.
saveContent
(
mapping
,
bytes
,
fileName
);
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWithWork.java
浏览文件 @
164ee345
...
...
@@ -62,6 +62,8 @@ class ActionUploadWithWork extends BaseAction {
/* 调整可能的附件名称 */
fileName
=
this
.
adjustFileName
(
business
,
work
.
getJob
(),
fileName
);
this
.
verifyConstraint
(
bytes
.
length
,
fileName
,
null
);
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
random
(
Attachment
.
class
);
Attachment
attachment
=
this
.
concreteAttachment
(
work
,
effectivePerson
,
site
);
attachment
.
saveContent
(
mapping
,
bytes
,
fileName
);
...
...
@@ -73,7 +75,7 @@ class ActionUploadWithWork extends BaseAction {
logger
.
debug
(
"filename:{}, file type:{}, text:{}."
,
attachment
.
getName
(),
attachment
.
getType
(),
attachment
.
getText
());
}
emc
.
beginTransaction
(
Attachment
.
class
);
emc
.
persist
(
attachment
,
CheckPersistType
.
all
);
emc
.
commit
();
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWithWorkCompleted.java
浏览文件 @
164ee345
...
...
@@ -62,6 +62,9 @@ class ActionUploadWithWorkCompleted extends BaseAction {
}
/* 调整可能的附件名称 */
fileName
=
this
.
adjustFileName
(
business
,
workCompleted
.
getJob
(),
fileName
);
this
.
verifyConstraint
(
bytes
.
length
,
fileName
,
null
);
/* 天印扩展 */
if
(
StringUtils
.
isNotEmpty
(
extraParam
))
{
WiExtraParam
wiExtraParam
=
gson
.
fromJson
(
extraParam
,
WiExtraParam
.
class
);
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/BaseAction.java
浏览文件 @
164ee345
...
...
@@ -2,6 +2,7 @@ package com.x.processplatform.assemble.surface.jaxrs.attachment;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.concurrent.CompletableFuture
;
import
javax.persistence.EntityManager
;
...
...
@@ -10,6 +11,10 @@ import javax.persistence.criteria.CriteriaQuery;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
com.x.base.core.project.cache.Cache
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.config.ProcessPlatform
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -243,4 +248,44 @@ abstract class BaseAction extends StandardJaxrsAction {
return
value
;
});
}
/**
* 判断附件是否符合大小、文件类型的约束
* @param size
* @param fileName
* @param callback
* @throws Exception
*/
protected
void
verifyConstraint
(
long
size
,
String
fileName
,
String
callback
)
throws
Exception
{
ProcessPlatform
.
AttachmentConfig
attConfig
=
Config
.
processPlatform
().
getAttachmentConfig
();
if
(
attConfig
.
getFileSize
()!=
null
&&
attConfig
.
getFileSize
()>
0
)
{
size
=
size
/
(
1024
*
1024
);
if
(
size
>
attConfig
.
getFileSize
())
{
if
(
StringUtils
.
isNotEmpty
(
callback
)){
throw
new
ExceptionAttachmentInvalidCallback
(
callback
,
fileName
,
attConfig
.
getFileSize
());
}
else
{
throw
new
ExceptionAttachmentInvalid
(
fileName
,
attConfig
.
getFileSize
());
}
}
}
String
fileType
=
FilenameUtils
.
getExtension
(
fileName
).
toLowerCase
();
if
(
attConfig
.
getFileTypeIncludes
()!=
null
&&
!
attConfig
.
getFileTypeIncludes
().
isEmpty
()){
if
(!
ListTools
.
contains
(
attConfig
.
getFileTypeIncludes
(),
fileType
)){
if
(
StringUtils
.
isNotEmpty
(
callback
)){
throw
new
ExceptionAttachmentInvalidCallback
(
callback
,
fileName
);
}
else
{
throw
new
ExceptionAttachmentInvalid
(
fileName
);
}
}
}
if
(
attConfig
.
getFileTypeExcludes
()!=
null
&&
!
attConfig
.
getFileTypeExcludes
().
isEmpty
()){
if
(
ListTools
.
contains
(
attConfig
.
getFileTypeExcludes
(),
fileType
)){
if
(
StringUtils
.
isNotEmpty
(
callback
)){
throw
new
ExceptionAttachmentInvalidCallback
(
callback
,
fileName
);
}
else
{
throw
new
ExceptionAttachmentInvalid
(
fileName
);
}
}
}
}
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ExceptionAttachmentInvalid.java
0 → 100644
浏览文件 @
164ee345
package
com.x.processplatform.assemble.surface.jaxrs.attachment
;
import
com.x.base.core.project.exception.PromptException
;
class
ExceptionAttachmentInvalid
extends
PromptException
{
private
static
final
long
serialVersionUID
=
3232548525722242208L
;
ExceptionAttachmentInvalid
(
String
fileName
)
{
super
(
"附件:{}, 不符合上传类型."
,
fileName
);
}
ExceptionAttachmentInvalid
(
String
fileName
,
Integer
fileSize
)
{
super
(
"附件:{},附件大小超过限制{}M."
,
fileName
,
fileSize
);
}
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ExceptionAttachmentInvalidCallback.java
0 → 100644
浏览文件 @
164ee345
package
com.x.processplatform.assemble.surface.jaxrs.attachment
;
import
com.x.base.core.project.exception.CallbackPromptException
;
class
ExceptionAttachmentInvalidCallback
extends
CallbackPromptException
{
private
static
final
long
serialVersionUID
=
8275405268546054638L
;
ExceptionAttachmentInvalidCallback
(
String
callbackName
,
String
fileName
)
{
super
(
callbackName
,
"附件:{}, 不符合上传类型."
,
fileName
);
}
ExceptionAttachmentInvalidCallback
(
String
callbackName
,
String
fileName
,
Integer
fileSize
)
{
super
(
callbackName
,
"附件:{},附件大小超过限制{}M."
,
fileName
,
fileSize
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录