public boolean isAffected(ModuleAction action) throws NotEmptyException { if (action == null) throw new NotEmptyException("action cannot be empty"); for (ModuleAction item : moduleActions) if (item.equals(action)) return true; return false; }
public void addAction(ModuleAction action) throws AccessNotAllowedException, NotEmptyException { if (action == null) throw new NotEmptyException("action cannot be empty"); if (Tools.hasRight("ADD_ACTION_TO_MODULE")) { action.setModule(this); action.persist(); moduleActions.add(action); } else throw new AccessNotAllowedException("You can't add action to module"); }
public void removeAction(ModuleAction action) throws AccessNotAllowedException, NotEmptyException { if (action == null) throw new NotEmptyException("action cannot be empty"); if (Tools.hasRight("REMOVE_ACTION_FROM_MODULE")) { for (ModuleAction gp : moduleActions) if (gp.equals(action)) { gp.remove(); break; } } else throw new AccessNotAllowedException("You can't remove action from module"); }
@Override public void changeModuleStatus(String moduleId, String ownerId, String entityId, String action) throws InvalidDataException { // valueOf will throw IllegalArgumentException if the value doesn't belong in enum, // however the use of the contains, allows for overwriting getSupportedActions to narrow down // the list of available actions for this particular implementation if (action == null || !getSupportedActions().contains(ModuleAction.valueOf(action.toUpperCase()))) { throw new InvalidDataException("unknown action: " + action); } EntityModuleStatus moduleStatus = null; if (ModuleAction.SUBMIT.toString().equals(action.toUpperCase())) { if (isSubmittable(moduleId, ownerId)) { moduleStatus = EntityModuleStatus.SUBMITTED; } else { throw new InvalidDataException( "Cannot submit the module because it is not in submittable state"); } } moduleManager.updateEntityModuleStatus(ownerId, moduleId, entityId, moduleStatus.toString()); }