public static Role toRole(final SRole sRole) { final RoleImpl role = new RoleImpl(sRole.getId(), sRole.getName()); role.setDisplayName(sRole.getDisplayName()); role.setDescription(sRole.getDescription()); role.setIconId(sRole.getIconId()); role.setCreatedBy(sRole.getCreatedBy()); role.setCreationDate(new Date(sRole.getCreationDate())); role.setLastUpdate(new Date(sRole.getLastUpdate())); return role; }
private static ExportedRole toExportedRole(final SRole sRole) { final ExportedRole role = new ExportedRole(sRole.getName()); role.setDisplayName(sRole.getDisplayName()); role.setDescription(sRole.getDescription()); return role; }
@Override public void deleteRole(final SRole role) throws SRoleDeletionException { final String methodName = "deleteRole"; final SRoleLogBuilder logBuilder = getRoleLog(ActionType.DELETED, "Deleting role with name " + role.getName()); try { if (role.getIconId() != null) { deleteIcon(role.getIconId()); } recorder.recordDelete(new DeleteRecord(role), ROLE); log(role.getId(), SQueriableLog.STATUS_OK, logBuilder, methodName); } catch (final SRecorderException | SBonitaReadException re) { log(role.getId(), SQueriableLog.STATUS_FAIL, logBuilder, methodName); throw new SRoleDeletionException(re); } }
private Map<String, Long> importRoles(final List<ExportedRole> roleCreators) throws ImportDuplicateInOrganizationException, SIdentityException { final Map<String, Long> roleNameToIdMap = new HashMap<>(roleCreators.size()); for (final ExportedRole roleCreator : roleCreators) { SRole sRole; try { sRole = identityService.getRoleByName(roleCreator.getName()); strategy.foundExistingRole(sRole, roleCreator); } catch (final SRoleNotFoundException e) { sRole = addRole(roleCreator); } roleNameToIdMap.put(sRole.getName(), sRole.getId()); } return roleNameToIdMap; }
@Override public void foundExistingRole(final SRole existingRole, final ExportedRole newRole) throws ImportDuplicateInOrganizationException { throw new ImportDuplicateInOrganizationException("There's already a role with the name : " + existingRole.getName()); }
@Override public void execute() throws SBonitaException { // FIXME: if RDBMS has foreign keys, getUser, getRole, getGroup can be ommitted: final SUser user = identityService.getUser(userId); final SRole role = identityService.getRole(roleId); final SGroup group = identityService.getGroup(groupId); userMembership = BuilderFactory.get(SUserMembershipBuilderFactory.class).createNewInstance(user.getId(), group.getId(), role.getId()).setAssignedBy(assignedBy) .setAssignedDate(System.currentTimeMillis()).done(); identityService.createUserMembership(userMembership); }
private Map<String, Long> importRoles(final List<ExportedRole> roleCreators) throws ImportDuplicateInOrganizationException, SIdentityException { final Map<String, Long> roleNameToIdMap = new HashMap<>(roleCreators.size()); for (final ExportedRole roleCreator : roleCreators) { SRole sRole; try { sRole = identityService.getRoleByName(roleCreator.getName()); strategy.foundExistingRole(sRole, roleCreator); } catch (final SRoleNotFoundException e) { sRole = addRole(roleCreator); } roleNameToIdMap.put(sRole.getName(), sRole.getId()); } return roleNameToIdMap; }
@Override public void foundExistingRole(final SRole existingRole, final ExportedRole newRole) throws ImportDuplicateInOrganizationException { throw new ImportDuplicateInOrganizationException("There's already a role with the name : " + existingRole.getName()); }
private static ExportedRole toExportedRole(final SRole sRole) { final ExportedRole role = new ExportedRole(sRole.getName()); role.setDisplayName(sRole.getDisplayName()); role.setDescription(sRole.getDescription()); return role; }
@Override public void deleteRole(final SRole role) throws SRoleDeletionException { final String methodName = "deleteRole"; final SRoleLogBuilder logBuilder = getRoleLog(ActionType.DELETED, "Deleting role with name " + role.getName()); try { if (role.getIconId() != null) { deleteIcon(role.getIconId()); } recorder.recordDelete(new DeleteRecord(role), ROLE); log(role.getId(), SQueriableLog.STATUS_OK, logBuilder, methodName); } catch (final SRecorderException | SBonitaReadException re) { log(role.getId(), SQueriableLog.STATUS_FAIL, logBuilder, methodName); throw new SRoleDeletionException(re); } }
@Override public void execute() throws SBonitaException { // FIXME: if RDBMS has foreign keys, getUser, getRole, getGroup can be ommitted: final SUser user = identityService.getUser(userId); final SRole role = identityService.getRole(roleId); final SGroup group = identityService.getGroup(groupId); userMembership = BuilderFactory.get(SUserMembershipBuilderFactory.class).createNewInstance(user.getId(), group.getId(), role.getId()).setAssignedBy(assignedBy) .setAssignedDate(System.currentTimeMillis()).done(); identityService.createUserMembership(userMembership); }
public static Role toRole(final SRole sRole) { final RoleImpl role = new RoleImpl(sRole.getId(), sRole.getName()); role.setDisplayName(sRole.getDisplayName()); role.setDescription(sRole.getDescription()); role.setIconId(sRole.getIconId()); role.setCreatedBy(sRole.getCreatedBy()); role.setCreationDate(new Date(sRole.getCreationDate())); role.setLastUpdate(new Date(sRole.getLastUpdate())); return role; }
@Override public SRole updateRole(final SRole role, final EntityUpdateDescriptor descriptor, EntityUpdateDescriptor iconUpdater) throws SIdentityException { final String methodName = "updateRole"; final SRoleLogBuilder logBuilder = getRoleLog(ActionType.UPDATED, "Updating the role with name " + role.getName()); try { if (iconUpdater != null && iconUpdater.getFields().containsKey("content")) { updateIcon(descriptor, iconUpdater, role); } recorder.recordUpdate(UpdateRecord.buildSetFields(role, descriptor), ROLE); log(role.getId(), SQueriableLog.STATUS_FAIL, logBuilder, methodName); } catch (final SRecorderException | SBonitaReadException e) { log(role.getId(), SQueriableLog.STATUS_FAIL, logBuilder, methodName); throw new SIdentityException("Can't update role " + role, e); } return role; }
private void addRoleToProfile() throws SRoleNotFoundException, SProfileMemberCreationException { final SRole role = identityService.getRole(roleId); if (role != null) { sProfileMember = profileService.addRoleToProfile(profileId, roleId, role.getName()); } }
protected EntityUpdateDescriptor getRoleDescriptor(final SRole existingRole, final ExportedRole exportedRole) { final SRoleUpdateBuilder roleUpdateBuilder = BuilderFactory.get(SRoleUpdateBuilderFactory.class).createNewInstance(); final String name = exportedRole.getName(); if (name != null && !name.equals(existingRole.getName())) { roleUpdateBuilder.updateName(name); } final String description = exportedRole.getDescription(); if (description != null && !description.equals(existingRole.getDescription())) { roleUpdateBuilder.updateDescription(description); } final String displayName = exportedRole.getDisplayName(); if (displayName != null && !displayName.equals(existingRole.getDisplayName())) { roleUpdateBuilder.updateDisplayName(displayName); } return roleUpdateBuilder.done(); }
for (final String roleName : roleNames) { final SRole role = identityService.getRoleByName(roleName); checkAlreadyExistingRoleMapping(actorId, role.getId()); actorMappingService.addRoleToActor(actorId, role.getId()); final SGroup group = identityService.getGroupByPath(membership.getGroup()); final SRole role = identityService.getRoleByName(membership.getRole()); checkAlreadyExistingMembershipMapping(actorId, group.getId(), role.getId()); actorMappingService.addRoleAndGroupToActor(actorId, role.getId(), group.getId());
@Override public SRole updateRole(final SRole role, final EntityUpdateDescriptor descriptor, EntityUpdateDescriptor iconUpdater) throws SIdentityException { final String methodName = "updateRole"; final SRoleLogBuilder logBuilder = getRoleLog(ActionType.UPDATED, "Updating the role with name " + role.getName()); try { if (iconUpdater != null && iconUpdater.getFields().containsKey("content")) { updateIcon(descriptor, iconUpdater, role); } recorder.recordUpdate(UpdateRecord.buildSetFields(role, descriptor), ROLE); log(role.getId(), SQueriableLog.STATUS_FAIL, logBuilder, methodName); } catch (final SRecorderException | SBonitaReadException e) { log(role.getId(), SQueriableLog.STATUS_FAIL, logBuilder, methodName); throw new SIdentityException("Can't update role " + role, e); } return role; }
private void addRoleToProfile() throws SRoleNotFoundException, SProfileMemberCreationException { final SRole role = identityService.getRole(roleId); if (role != null) { sProfileMember = profileService.addRoleToProfile(profileId, roleId, role.getName()); } }
protected EntityUpdateDescriptor getRoleDescriptor(final SRole existingRole, final ExportedRole exportedRole) { final SRoleUpdateBuilder roleUpdateBuilder = BuilderFactory.get(SRoleUpdateBuilderFactory.class).createNewInstance(); final String name = exportedRole.getName(); if (name != null && !name.equals(existingRole.getName())) { roleUpdateBuilder.updateName(name); } final String description = exportedRole.getDescription(); if (description != null && !description.equals(existingRole.getDescription())) { roleUpdateBuilder.updateDescription(description); } final String displayName = exportedRole.getDisplayName(); if (displayName != null && !displayName.equals(existingRole.getDisplayName())) { roleUpdateBuilder.updateDisplayName(displayName); } return roleUpdateBuilder.done(); }
for (final String roleName : roleNames) { final SRole role = identityService.getRoleByName(roleName); checkAlreadyExistingRoleMapping(actorId, role.getId()); actorMappingService.addRoleToActor(actorId, role.getId()); final SGroup group = identityService.getGroupByPath(membership.getGroup()); final SRole role = identityService.getRoleByName(membership.getRole()); checkAlreadyExistingMembershipMapping(actorId, group.getId(), role.getId()); actorMappingService.addRoleAndGroupToActor(actorId, role.getId(), group.getId());