提交 da27cf14 编写于 作者: O o2null

Merge branch 'develop' into 'fix/group_as_read'

# Conflicts:
#   o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/ActionAssignCreate.java
......@@ -167,18 +167,31 @@ public class ActionPersistPublishByWorkFlow extends BaseAction {
}
if (check) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
if ( StringUtils.isNotEmpty( wi.getCreatorIdentity() )) {
wi.setCreatorPerson( userManagerService.getPersonNameWithIdentity( wi.getCreatorIdentity() ) );
wi.setCreatorUnitName( userManagerService.getUnitNameByIdentity( wi.getCreatorIdentity() ) );
wi.setCreatorTopUnitName( userManagerService.getTopUnitNameByIdentity( wi.getCreatorIdentity() ) );
} else {
if ("xadmin".equalsIgnoreCase( effectivePerson.getDistinguishedName()) ) {
try {
if (StringUtils.isEmpty( wi.getCreatorIdentity() )) {
if( "cipher".equalsIgnoreCase( effectivePerson.getDistinguishedName() )) {
wi.setCreatorIdentity("cipher");
wi.setCreatorPerson("cipher");
wi.setCreatorUnitName("cipher");
wi.setCreatorTopUnitName("cipher");
}else if ("xadmin".equalsIgnoreCase(effectivePerson.getDistinguishedName())) {
wi.setCreatorIdentity("xadmin");
wi.setCreatorPerson("xadmin");
wi.setCreatorUnitName("xadmin");
wi.setCreatorTopUnitName("xadmin");
} else {
}else {
//尝试一下根据当前用户获取用户的第一个身份
wi.setCreatorIdentity(userManagerService.getMajorIdentityWithPerson( effectivePerson.getDistinguishedName()) );
}
}
if ( !StringUtils.equals( "cipher", wi.getCreatorIdentity() ) && !StringUtils.equals( "xadmin", wi.getCreatorIdentity() )) {
//说明是指定的发布者,并不使用cipher和xadmin代替
if (StringUtils.isNotEmpty( wi.getCreatorIdentity() )) {
wi.setCreatorPerson( userManagerService.getPersonNameWithIdentity( wi.getCreatorIdentity() ) );
wi.setCreatorUnitName( userManagerService.getUnitNameByIdentity( wi.getCreatorIdentity() ) );
wi.setCreatorTopUnitName( userManagerService.getTopUnitNameByIdentity( wi.getCreatorIdentity() ) );
}else {
Exception exception = new ExceptionPersonHasNoIdentity(wi.getCreatorIdentity());
result.error(exception);
}
......@@ -191,9 +204,6 @@ public class ActionPersistPublishByWorkFlow extends BaseAction {
if (check) {
if ( StringUtils.isEmpty(wi.getTitle())) {
// check = false;
// Exception exception = new ExceptionDocumentTitleEmpty();
// result.error(exception);
wi.setTitle( appInfo.getAppName() + " - " + categoryInfo.getCategoryName() + " - 无标题文档" );
}
}
......@@ -212,6 +222,7 @@ public class ActionPersistPublishByWorkFlow extends BaseAction {
}
}
//从流程管理中复制所有的附件到CMS
if (check) {
if ( wi.getWf_attachmentIds() != null && wi.getWf_attachmentIds().length > 0 ) {
FileInfo fileInfo = null;
......@@ -267,11 +278,12 @@ public class ActionPersistPublishByWorkFlow extends BaseAction {
throw exception;
}
}
if (check) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
logService.log(emc, wi.getCreatorIdentity(),
document.getCategoryAlias() + ":" + document.getTitle(), document.getAppId(),
document.getCategoryId(), document.getId(), "", "DOCUMENT", "发布");
document.getCategoryId(), document.getId(), "", "DOCUMENT", "发布" );
} catch (Throwable th) {
th.printStackTrace();
result.error(th);
......
package com.x.cms.assemble.control.jaxrs.document;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.processplatform.core.entity.content.Attachment;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -216,10 +220,10 @@ public class ActionPersistPublishContent extends BaseAction {
try {
JsonElement docData = XGsonBuilder.instance().toJsonTree(wi.getDocData(), Map.class);
wi.setDocStatus("published");
if( wi.getPublishTime() == null ) {
wi.setPublishTime(new Date());
}
document = documentPersistService.save(wi.copier.copy(wi), docData );
if( wi.getPublishTime() == null ) { wi.setPublishTime(new Date()); }
document = wi.copier.copy(wi);
document.setId( wi.getId() );
document = documentPersistService.save( document, docData );
} catch (Exception e) {
check = false;
Exception exception = new ExceptionDocumentInfoProcess(e, "系统在创建文档信息时发生异常!");
......@@ -228,6 +232,48 @@ public class ActionPersistPublishContent extends BaseAction {
}
}
//从流程管理中复制所有的附件到CMS
if (check) {
if ( wi.getWf_attachmentIds() != null && wi.getWf_attachmentIds().length > 0 ) {
FileInfo fileInfo = null;
Attachment attachment = null;
StorageMapping mapping_attachment = null;
StorageMapping mapping_fileInfo = null;
InputStream input = null;
byte[] attachment_content = null;
for (String attachmentId : wi.getWf_attachmentIds()) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
document = emc.find(document.getId(), Document.class, ExceptionWhen.not_found);
attachment = emc.find(attachmentId, Attachment.class, ExceptionWhen.not_found);
if (attachment != null) {
emc.beginTransaction(FileInfo.class);
emc.beginTransaction(Document.class);
mapping_attachment = ThisApplication.context().storageMappings().get(Attachment.class, attachment.getStorage());
attachment_content = attachment.readContent(mapping_attachment);
mapping_fileInfo = ThisApplication.context().storageMappings().random(FileInfo.class);
fileInfo = concreteFileInfo(effectivePerson.getDistinguishedName(), document, mapping_fileInfo, attachment.getName(), attachment.getSite());
input = new ByteArrayInputStream(attachment_content);
fileInfo.saveContent(mapping_fileInfo, input, attachment.getName());
fileInfo.setName(attachment.getName());
emc.check(document, CheckPersistType.all);
emc.persist(fileInfo, CheckPersistType.all);
emc.commit();
}
} catch (Throwable th) {
th.printStackTrace();
result.error(th);
} finally {
if (input != null) {
input.close();
}
}
}
}
}
if (check) {
try {
Wo wo = new Wo();
......@@ -240,6 +286,7 @@ public class ActionPersistPublishContent extends BaseAction {
throw exception;
}
}
if (check) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
logService.log(emc, wi.getCreatorIdentity(),
......@@ -358,17 +405,51 @@ public class ActionPersistPublishContent extends BaseAction {
logger.error( e, effectivePerson, request, null);
}
}
ApplicationCache.notify(FileInfo.class);
ApplicationCache.notify(Document.class);
return result;
}
private FileInfo concreteFileInfo(String person, Document document, StorageMapping storage, String name, String site) throws Exception {
String fileName = UUID.randomUUID().toString();
String extension = FilenameUtils.getExtension(name);
FileInfo attachment = new FileInfo();
if (StringUtils.isEmpty(extension)) {
throw new Exception("file extension is empty.");
} else {
fileName = fileName + "." + extension;
}
if (name.indexOf("\\") > 0) {
name = StringUtils.substringAfterLast(name, "\\");
}
if (name.indexOf("/") > 0) {
name = StringUtils.substringAfterLast(name, "/");
}
attachment.setCreateTime(new Date());
attachment.setLastUpdateTime(new Date());
attachment.setExtension(extension);
attachment.setName(name);
attachment.setFileName(fileName);
attachment.setStorage(storage.getName());
attachment.setAppId(document.getAppId());
attachment.setCategoryId(document.getCategoryId());
attachment.setDocumentId(document.getId());
attachment.setCreatorUid(person);
attachment.setSite(site);
attachment.setFileHost("");
attachment.setFilePath("");
attachment.setFileType("ATTACHMENT");
return attachment;
}
public static class Wi {
public static List<String> Excludes = new ArrayList<String>(JpaObject.FieldsUnmodify);
public static WrapCopier<Wi, Document> copier = WrapCopierFactory.wi( Wi.class, Document.class, null, null);
private String id = null;
@FieldDescribe( "文档操作者身份." )
private String identity = null;
......@@ -491,9 +572,23 @@ public class ActionPersistPublishContent extends BaseAction {
private List<String> managerList;
private List<String> pictureList;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Boolean getTop() {
return isTop;
}
public void setTop(Boolean top) {
isTop = top;
}
public String getSummary() {
return summary;
}
......
......@@ -3,11 +3,13 @@ package com.x.cms.assemble.control.jaxrs.document;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
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.ApplicationCache;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.tools.ListTools;
import com.x.cms.assemble.control.Business;
......@@ -29,7 +31,10 @@ import com.x.cms.core.entity.AppInfo;
import com.x.cms.core.entity.CategoryInfo;
import com.x.cms.core.entity.Document;
import com.x.cms.core.entity.FileInfo;
import net.sf.ehcache.Ehcache;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
public class BaseAction extends StandardJaxrsAction {
protected Ehcache cache = ApplicationCache.instance().getCache( Document.class);
......@@ -215,7 +220,9 @@ public class BaseAction extends StandardJaxrsAction {
}
return false;
}
// /**
// * 将权限组,组织为一个整体集合
// * @param personName
......
......@@ -11,6 +11,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -21,6 +22,7 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("document/cipher")
@JaxrsDescribe("信息发布信息文档管理(Cipher)")
public class DocumentCipherAction extends StandardJaxrsAction{
private static Logger logger = LoggerFactory.getLogger( DocumentCipherAction.class );
......@@ -30,7 +32,7 @@ public class DocumentCipherAction extends StandardJaxrsAction{
@Path("publish/content")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void publishContent( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, JsonElement jsonElement ) {
public void publishContentByWorkFlow( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, JsonElement jsonElement ) {
EffectivePerson effectivePerson = this.effectivePerson( request );
ActionResult<ActionPersistPublishByWorkFlow.Wo> result = new ActionResult<>();
Boolean check = true;
......
......@@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.AuditLog;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -83,6 +84,9 @@ public class ActionRefreshDocumentPermission extends BaseAction {
}
}
ApplicationCache.notify( Document.class );
return result;
}
......
......@@ -216,10 +216,10 @@ public class ActionPersistPublishContent extends BaseAction {
try {
JsonElement docData = XGsonBuilder.instance().toJsonTree(wi.getDocData(), Map.class);
wi.setDocStatus("published");
if( wi.getPublishTime() == null ) {
wi.setPublishTime(new Date());
}
document = documentPersistService.save(wi.copier.copy(wi), docData );
if( wi.getPublishTime() == null ) { wi.setPublishTime(new Date()); }
document = wi.copier.copy(wi);
document.setId( wi.getId() );
document = documentPersistService.save( document, docData );
} catch (Exception e) {
check = false;
Exception exception = new ExceptionDocumentInfoProcess(e, "系统在创建文档信息时发生异常!");
......@@ -365,10 +365,10 @@ public class ActionPersistPublishContent extends BaseAction {
public static class Wi {
public static List<String> Excludes = new ArrayList<String>(JpaObject.FieldsUnmodify);
public static WrapCopier<Wi, Document> copier = WrapCopierFactory.wi( Wi.class, Document.class, null, null);
private String id = null;
@FieldDescribe( "文档操作者身份." )
private String identity = null;
......@@ -491,9 +491,23 @@ public class ActionPersistPublishContent extends BaseAction {
private List<String> managerList;
private List<String> pictureList;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Boolean getTop() {
return isTop;
}
public void setTop(Boolean top) {
isTop = top;
}
public String getSummary() {
return summary;
}
......
......@@ -16,6 +16,7 @@ public class ProcessingAttributes extends GsonPropertyObject {
public static final String TYPE_RESET = "reset";
public static final String TYPE_RETRACT = "retract";
public static final String TYPE_ROLLBACK = "rollback";
//public static final String TYPE_BEGIN = "begin";
private Integer loop = 1;
@FieldDescribe("强制从arrive开始")
......
......@@ -52,7 +52,7 @@ import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
/**
* 创建处于start状态的work
* 创建处于start状态的work 此方法不需要进入队列运行
*
* @author Rui
*
......@@ -132,6 +132,7 @@ class ActionAssignCreate extends BaseAction {
Processing p = new Processing(processingAttributes);
p.processing(work.getId());
}
wo.setId(work.getId());
result.setData(wo);
return result;
......
......@@ -27,7 +27,6 @@ import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.processplatform.core.entity.element.ActivityType;
@Path("work")
@JaxrsDescribe("工作")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册