提交 49668e47 编写于 作者: O o2sword

流程和应用管理角色权限判断

上级 5edb89bc
......@@ -13,6 +13,7 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.assemble.designer.Business;
import com.x.processplatform.assemble.designer.MessageFactory;
import com.x.processplatform.core.entity.element.Application;
......@@ -36,6 +37,7 @@ class ActionCreate extends BaseAction {
application.setCreatorPerson(effectivePerson.getDistinguishedName());
application.setLastUpdatePerson(effectivePerson.getDistinguishedName());
application.setLastUpdateTime(new Date());
application.setControllerList(ListTools.add(application.getControllerList(), true, true, effectivePerson.getDistinguishedName()));
emc.persist(application, CheckPersistType.all);
emc.commit();
CacheManager.notify(Application.class);
......@@ -60,4 +62,4 @@ class ActionCreate extends BaseAction {
}
}
\ No newline at end of file
}
......@@ -85,8 +85,7 @@ public class ProcessFactory extends ElementFactory {
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Process> root = cq.from(Process.class);
Predicate p = cb.conjunction();
if (effectivePerson.isNotManager() && (!this.business().organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager))) {
if (!this.business().canManageApplication(effectivePerson, application)) {
p = cb.and(cb.isEmpty(root.get(Process_.startableIdentityList)),
cb.isEmpty(root.get(Process_.startableUnitList)),
cb.isEmpty(root.get(Process_.startableGroupList)));
......@@ -110,9 +109,7 @@ public class ProcessFactory extends ElementFactory {
/* 获取用户可启动的流程,如果applicationId 为空则取到所有可启动流程 */
public boolean startable(EffectivePerson effectivePerson, List<String> identities, List<String> units,
List<String> groups, Process process) throws Exception {
if (effectivePerson.isManager()
|| (BooleanUtils.isTrue(this.business().organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager)))) {
if (this.business().canManageApplication(effectivePerson, null)) {
return true;
}
if (ListTools.isEmpty(process.getStartableIdentityList())
......@@ -137,13 +134,15 @@ public class ProcessFactory extends ElementFactory {
return false;
}
public List<String> listControlableProcess(EffectivePerson effectivePerson, Application application)
public List<String> listControllableProcess(EffectivePerson effectivePerson, Application application)
throws Exception {
List<String> ids = this.listWithApplication(application);
boolean isManager = this.business().canManageApplication(effectivePerson, application);
List<String> list = new ArrayList<>();
for (String str : ids) {
Process o = this.pick(str);
if ((null != o) && (effectivePerson.isPerson(o.getControllerList()))) {
boolean flag = (!BooleanUtils.isFalse(o.getEditionEnable())) && (isManager || effectivePerson.isPerson(o.getControllerList()));
if (flag) {
list.add(str);
}
}
......
package com.x.processplatform.assemble.surface.jaxrs.application;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.core.entity.element.Application;
import com.x.processplatform.core.express.assemble.surface.jaxrs.application.ActionGetIconWo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Optional;
class ActionIsManager extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionIsManager.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
LOGGER.debug("execute:{}, flag:{}.", effectivePerson::getDistinguishedName, () -> flag);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Application application = business.application().pick(flag);
if (null == application) {
throw new ExceptionEntityNotExist(flag);
}
wo.setValue(business.canManageApplication(effectivePerson, application));
}
result.setData(wo);
return result;
}
@Schema(name="com.x.processplatform.assemble.surface.jaxrs.application.ActionIsManager$Wo")
public static class Wo extends WrapBoolean {
}
}
......@@ -162,4 +162,25 @@ public class ApplicationAction extends StandardJaxrsAction {
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
@Operation(summary = "校验当前用户是否是指定应用的管理员.", operationId = OPERATIONID_PREFIX + "isManager", responses = {
@ApiResponse(content = {
@Content(schema = @Schema(implementation = ActionIsManager.Wo.class)) }) })
@JaxrsMethodDescribe(value = "校验当前用户是否是指定应用的管理员.", action = ActionIsManager.class)
@GET
@Path("{flag}/is/manager")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void isManager(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("应用标识") @PathParam("flag") String flag) {
ActionResult<ActionIsManager.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionIsManager().execute(effectivePerson, flag);
} catch (Exception e) {
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
package com.x.processplatform.assemble.surface.jaxrs.process;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapStringList;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.core.entity.element.Application;
import io.swagger.v3.oas.annotations.media.Schema;
class ActionListControllableWithApplication extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionListControllableWithApplication.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String applicationFlag) throws Exception {
LOGGER.debug("execute:{}, applicationFlag:{}.", effectivePerson::getDistinguishedName, () -> applicationFlag);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
Wo wo = new Wo();
Application application = business.application().pick(applicationFlag);
if (null == application) {
throw new ExceptionEntityNotExist(applicationFlag, Application.class);
}
wo.setValueList(business.process().listControllableProcess(effectivePerson, application));
result.setData(wo);
return result;
}
}
@Schema(name = "com.x.processplatform.assemble.surface.jaxrs.process.ActionListControllableWithApplication$Wo")
public static class Wo extends WrapStringList {
}
}
......@@ -235,4 +235,26 @@ public class ProcessAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
@Operation(summary = "根据指定应用标识获取可管理的流程.", operationId = OPERATIONID_PREFIX
+ "listControllableWithApplication", responses = { @ApiResponse(content = {
@Content(schema = @Schema(implementation = ActionListControllableWithApplication.Wo.class)) }) })
@JaxrsMethodDescribe(value = "根据指定应用标识获取可管理的流程.", action = ActionListControllableWithApplication.class)
@GET
@Path("list/controllable/application/{applicationFlag}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listControllableWithApplication(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("应用标识") @PathParam("applicationFlag") String applicationFlag) {
ActionResult<ActionListControllableWithApplication.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListControllableWithApplication().execute(effectivePerson, applicationFlag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
......@@ -25,7 +25,7 @@ import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.element.Application;
class ActionManageListNext extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionManageListNext.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id, Integer count, String applicationFlag)
......@@ -47,7 +47,7 @@ class ActionManageListNext extends BaseAction {
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, equalsTerms, null,
null, null, null, null, null, null, true, DESC);
} else {
List<String> ids = business.process().listControlableProcess(effectivePerson, application);
List<String> ids = business.process().listControllableProcess(effectivePerson, application);
if (ListTools.isNotEmpty(ids)) {
InTerms inTerms = new InTerms();
inTerms.put("process", ids);
......
......@@ -23,7 +23,7 @@ import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.element.Application;
class ActionManageListPrev extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionManageListPrev.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id, Integer count, String applicationFlag)
......@@ -45,7 +45,7 @@ class ActionManageListPrev extends BaseAction {
result = this.standardListPrev(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, equalsTerms, null, null, null, null,
null, null, null, true, DESC);
} else {
List<String> ids = business.process().listControlableProcess(effectivePerson, application);
List<String> ids = business.process().listControllableProcess(effectivePerson, application);
if (ListTools.isNotEmpty(ids)) {
InTerms inTerms = new InTerms();
inTerms.put("process", ids);
......
......@@ -42,7 +42,7 @@ class ActionManageListNext extends BaseAction {
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, equalsTerms, null, null, null, null,
null, null, null, true, DESC);
} else {
List<String> ids = business.process().listControlableProcess(effectivePerson, application);
List<String> ids = business.process().listControllableProcess(effectivePerson, application);
if (ListTools.isNotEmpty(ids)) {
InTerms inTerms = new InTerms();
inTerms.put("process", ids);
......
......@@ -42,7 +42,7 @@ class ActionManageListPrev extends BaseAction {
result = this.standardListPrev(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, equalsTerms, null, null, null, null,
null, null, null, true, DESC);
} else {
List<String> ids = business.process().listControlableProcess(effectivePerson, application);
List<String> ids = business.process().listControllableProcess(effectivePerson, application);
if (ListTools.isNotEmpty(ids)) {
InTerms inTerms = new InTerms();
inTerms.put("process", ids);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册