diff --git a/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistPublishContent.java b/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistPublishContent.java index ba480e79eedcea000811c2063ca4c8d0760a8856..477c7e5ac5ba863453ac2caee3797cddbc1eb68f 100644 --- a/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistPublishContent.java +++ b/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistPublishContent.java @@ -10,7 +10,9 @@ import java.util.UUID; import javax.servlet.http.HttpServletRequest; import com.x.base.core.project.config.Token; +import com.x.base.core.project.exception.ExceptionAccessDenied; import com.x.base.core.project.tools.DateTools; +import com.x.cms.assemble.control.Business; import com.x.cms.core.entity.enums.DocumentStatus; import com.x.cms.core.entity.query.DocumentNotify; import org.apache.commons.io.FilenameUtils; @@ -52,90 +54,51 @@ public class ActionPersistPublishContent extends BaseAction { protected ActionResult execute( HttpServletRequest request, JsonElement jsonElement, EffectivePerson effectivePerson) throws Exception { ActionResult result = new ActionResult<>(); - List cloudPictures = null; - AppInfo appInfo = null; - CategoryInfo categoryInfo = null; Document document = null; - Form form = null; - Wi wi = null; + Wi wi = this.convertToWrapIn( jsonElement, Wi.class ); Boolean check = true; - try { - wi = this.convertToWrapIn( jsonElement, Wi.class ); - } catch (Exception e ) { - check = false; - Exception exception = new ExceptionDocumentInfoProcess( e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString() ); - result.error( exception ); - logger.error( e, effectivePerson, request, null); + if ( StringUtils.isEmpty( wi.getCategoryId() ) ) { + throw new ExceptionDocumentCategoryIdEmpty(); } - if (check) { - if ( StringUtils.isEmpty(wi.getCategoryId())) { - check = false; - Exception exception = new ExceptionDocumentCategoryIdEmpty(); - result.error(exception); + CategoryInfo categoryInfo; + AppInfo appInfo = null; + + Document oldDocument = documentQueryService.get(wi.getId()); + if(oldDocument != null){ + categoryInfo = categoryInfoServiceAdv.get( oldDocument.getCategoryId() ); + appInfo = appInfoServiceAdv.get(oldDocument.getAppId()); + }else{ + categoryInfo = categoryInfoServiceAdv.get( wi.getCategoryId() ); + if(categoryInfo != null) { + appInfo = appInfoServiceAdv.get(categoryInfo.getAppId()); } } - if (check) { - try { - categoryInfo = categoryInfoServiceAdv.get( wi.getCategoryId() ); - if (categoryInfo == null) { - check = false; - Exception exception = new ExceptionCategoryInfoNotExists(wi.getCategoryId()); - result.error(exception); - } - } catch (Exception e) { - check = false; - Exception exception = new ExceptionDocumentInfoProcess(e,"系统在根据ID查询分类信息时发生异常!ID:" + wi.getCategoryId()); - result.error(exception); - logger.error(e, effectivePerson, request, null); - } + if(categoryInfo == null){ + throw new ExceptionCategoryInfoNotExists(wi.getCategoryId()); + } + if (appInfo == null) { + throw new ExceptionAppInfoNotExists(categoryInfo.getAppId()); } - if (check) { - try { - appInfo = appInfoServiceAdv.get( categoryInfo.getAppId() ); - if (appInfo == null) { - check = false; - Exception exception = new ExceptionAppInfoNotExists(categoryInfo.getAppId()); - result.error(exception); - } - } catch (Exception e) { - check = false; - Exception exception = new ExceptionDocumentInfoProcess(e, "系统在根据ID查询应用栏目信息时发生异常!ID:" + categoryInfo.getAppId()); - result.error(exception); - logger.error(e, effectivePerson, request, null); - } + Business business = new Business(null); + if(!business.isDocumentEditor(effectivePerson, appInfo, categoryInfo, oldDocument)){ + throw new ExceptionAccessDenied(effectivePerson); } // 查询分类设置的编辑表单 - if (check) { - if ( StringUtils.isEmpty(categoryInfo.getFormId())) { - check = false; - Exception exception = new ExceptionCategoryFormIdEmpty(); - result.error(exception); - } + if ( StringUtils.isEmpty(categoryInfo.getFormId() )) { + throw new ExceptionCategoryFormIdEmpty(); } - if (check) { - try { - form = formServiceAdv.get(categoryInfo.getFormId()); - if (form == null) { - check = false; - Exception exception = new ExceptionFormForEditNotExists(categoryInfo.getFormId()); - result.error(exception); - } else { - wi.setForm(form.getId()); - wi.setFormName(form.getName()); - } - } catch (Exception e) { - check = false; - Exception exception = new ExceptionDocumentInfoProcess(e, - "系统在根据ID查询编辑表单时发生异常!ID:" + categoryInfo.getFormId()); - result.error(exception); - logger.error(e, effectivePerson, request, null); - } + Form form = formServiceAdv.get(categoryInfo.getFormId()); + if (form == null) { + throw new ExceptionFormForEditNotExists(categoryInfo.getFormId()); + } else { + wi.setForm(form.getId()); + wi.setFormName(form.getName()); } if (check) { @@ -345,7 +308,9 @@ public class ActionPersistPublishContent extends BaseAction { if ( check && !wi.getSkipPermission() ) { //将读者以及作者信息持久化到数据库中 try { - documentPersistService.refreshDocumentPermission( document.getId(), wi.getReaderList(), wi.getAuthorList() ); + if(oldDocument==null || (wi.getReaderList() != null && wi.getAuthorList() != null)) { + documentPersistService.refreshDocumentPermission(document.getId(), wi.getReaderList(), wi.getAuthorList()); + } } catch (Exception e) { Exception exception = new ExceptionDocumentInfoProcess(e, "系统在核对文档访问管理权限信息时发生异常!"); result.error(exception); diff --git a/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistSaveDocument.java b/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistSaveDocument.java index 288ff8d0468b1b11db6628933533be5b56e48e62..792d446d4d73a06a44829ad097e7c799409d617f 100644 --- a/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistSaveDocument.java +++ b/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistSaveDocument.java @@ -262,7 +262,9 @@ public class ActionPersistSaveDocument extends BaseAction { if (check) { try {//将读者以及作者信息持久化到数据库中 - documentPersistService.refreshDocumentPermission( document.getId(), wi.getReaderList(), wi.getAuthorList() ); + if(oldDocument==null || (wi.getReaderList() != null && wi.getAuthorList() != null)){ + documentPersistService.refreshDocumentPermission( document.getId(), wi.getReaderList(), wi.getAuthorList() ); + } } catch (Exception e) { check = false; Exception exception = new ExceptionDocumentInfoProcess(e, "系统在核对文档访问管理权限信息时发生异常!");