@Override public ProjectRoleActor createRoleActor(Long id, Long projectRoleId, Long projectId, String type, String parameter) throws RoleActorDoesNotExistException { Map<String, ProjectRoleActorModuleDescriptor> implementations = getImplementationsMap(); ProjectRoleActorModuleDescriptor roleActorModuleDescriptor = getRoleActorModuleDescriptor(type, implementations); if (roleActorModuleDescriptor == null) { throw new IllegalArgumentException("Type " + type + " is not a registered RoleActor implementation"); } //We are not wrapping this in SafePluginPointAccess because there is no easy way to propagate checked exception correctly. RoleActorFactory roleActorFactory = roleActorModuleDescriptor.getModule(); return roleActorFactory.createRoleActor(id, projectRoleId, projectId, type, parameter); }
private boolean roleActorsToRemoveContainsRoleActorFromProjectRole(RoleActor roleActorFromProjectRole, String actorType, ApplicationUser currentUser, Collection<String> actors, ProjectRole projectRole, Project project) { // We want to keep track of the amount of times we run into an existing role actor that contains the current // user within the users Set that the actor represents if (roleActorFromProjectRole.getType().equals(actorType) && roleActorFromProjectRole.contains(currentUser)) { for (String actorKey : actors) { // Create a roleActor object from the actorName and type so we can compare the equality of the // actor to be removed with the roleActorFromProjectRole RoleActor roleActorToRemove; try { roleActorToRemove = roleActorFactory.createRoleActor(null, projectRole.getId(), project.getId(), actorType, actorKey); } catch (RoleActorDoesNotExistException e) { throw new IllegalArgumentException("Unexpected error: the role actor '" + actorKey + "' of type '" + actorType + "' does not exist."); } // If the role to be removed is the same as the role we are looking at then we keep a count of // it since this is a role that is being removed and the role includes the current user. if (roleActorToRemove.equals(roleActorFromProjectRole)) { return true; } } } return false; }
final ProjectRoleActor actor = roleActorFactory.createRoleActor(actorGV.getLong(FIELD_ID), projectRoleId, projectId, actorGV.getString(ROLE_ACTOR_TYPE), actorGV.getString(ROLE_ACTOR_PARAMETER));
projectRoleActor = roleActorFactory.createRoleActor(null, projectRoleId, projectId, actorType, actorKey);