提交 6e65ec9a 编写于 作者: O o2null

Merge branch 'feature/cms发布文档允许上传其他cms文档的附件' into 'wrdp'

[内容管理]发布文档允许上传其他cms文档的附件

See merge request o2oa/o2oa!3005
......@@ -283,6 +283,42 @@ public class ActionPersistPublishContent extends BaseAction {
}
}
//从CMS其他文档中复制所有的附件到CMS
if (check) {
if ( wi.getCms_attachmentIds() != null && wi.getCms_attachmentIds().length > 0 ) {
FileInfo fileInfo = null;
FileInfo copyFileInfo = null;
StorageMapping mapping_attachment = null;
StorageMapping mapping_fileInfo = null;
byte[] attachment_content = null;
for (String attachmentId : wi.getCms_attachmentIds()) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
document = emc.find(document.getId(), Document.class, ExceptionWhen.not_found);
copyFileInfo = emc.find(attachmentId, FileInfo.class, ExceptionWhen.not_found);
if (copyFileInfo != null) {
emc.beginTransaction(FileInfo.class);
emc.beginTransaction(Document.class);
mapping_attachment = ThisApplication.context().storageMappings().get(FileInfo.class, copyFileInfo.getStorage());
attachment_content = copyFileInfo.readContent(mapping_attachment);
mapping_fileInfo = ThisApplication.context().storageMappings().random(FileInfo.class);
fileInfo = concreteFileInfo(effectivePerson.getDistinguishedName(), document, mapping_fileInfo, copyFileInfo.getName(), copyFileInfo.getSite());
fileInfo.saveContent(mapping_fileInfo, attachment_content, copyFileInfo.getName());
fileInfo.setName(copyFileInfo.getName());
emc.check(document, CheckPersistType.all);
emc.persist(fileInfo, CheckPersistType.all);
emc.commit();
}
} catch (Throwable th) {
th.printStackTrace();
result.error(th);
}
}
}
}
if (check) {
try {
Wo wo = new Wo();
......@@ -474,6 +510,9 @@ public class ActionPersistPublishContent extends BaseAction {
@FieldDescribe( "启动流程的附件列表." )
private String[] wf_attachmentIds = null;
@FieldDescribe( "内容管理其他文档的附件列表,非必填" )
private String[] cms_attachmentIds = null;
@FieldDescribe( "文档数据JSON对象." )
private Map<?, ?> docData = null;
......@@ -1033,6 +1072,13 @@ public class ActionPersistPublishContent extends BaseAction {
this.authorList = authorList;
}
public String[] getCms_attachmentIds() {
return cms_attachmentIds;
}
public void setCms_attachmentIds(String[] cms_attachmentIds) {
this.cms_attachmentIds = cms_attachmentIds;
}
}
public static class Wo extends WoId {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册