@Override public boolean isUserAllowed(Content content, UserDetails currentUser) { try { if (!super.isUserAllowed(content, currentUser)) { return false; } boolean allowedType = false; List<SmallContentType> allowedContentTypes = this.getAllowedContentTypes(currentUser); for (int i = 0; i < allowedContentTypes.size(); i++) { SmallContentType smallContentType = allowedContentTypes.get(i); if (smallContentType.getCode().equals(content.getTypeCode())) { allowedType = true; break; } } if (!allowedType) { return false; } String status = content.getStatus(); if (status != null && !status.equals(Content.STATUS_NEW) && !status.equals(Content.STATUS_DRAFT)) { if (status.equals(Content.STATUS_READY) || status.equals(Content.STATUS_PUBLIC)) { boolean isSupervisor = this.getAuthorizationManager().isAuthOnPermission(currentUser, Permission.SUPERVISOR); if (!isSupervisor) { return false; } } else { List<Step> steps = this.getWorkflowManager().getSteps(content.getTypeCode()); boolean auth = false; for (int i = 0; i < steps.size(); i++) { Step step = steps.get(i); if (step.getCode().equals(status)) { if (step.getRole() != null || this.checkRole(step.getRole(), currentUser)) { auth = true; break; } } } if (!auth) { return false; } } } } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "isUserAllowed"); throw new RuntimeException("Error checking user authority", t); } return true; }
@Override public List<SelectItem> getAvalaibleStatus(UserDetails user, String contentTypeCode) { List<SelectItem> items = new ArrayList<SelectItem>(); String roleName = this.getWorkflowManager().getRole(contentTypeCode); if (!this.checkRole(roleName, user)) { return items; } Workflow workflow = this.getWorkflowManager().getWorkflow(contentTypeCode); items.add(new SelectItem(Content.STATUS_DRAFT, "name.contentStatus." + Content.STATUS_DRAFT)); if (null != workflow) { Iterator<Step> stepsIter = workflow.getSteps().iterator(); while (stepsIter.hasNext()) { Step step = stepsIter.next(); if (this.checkRole(step.getRole(), user)) { items.add(new SelectItem(step.getCode(), step.getDescr())); } } } if (this.getAuthorizationManager().isAuthOnPermission(user, Permission.SUPERVISOR)) { items.add(new SelectItem(Content.STATUS_READY, "name.contentStatus." + Content.STATUS_READY)); } return items; }