private void deleteProfileMembersOfGroupChildren(final long groupId) throws SIdentityException, SBonitaException { int i = 0; List<SGroup> childrenGroup; do { childrenGroup = identityService.getGroupChildren(groupId, i, BATCH_SIZE); i += BATCH_SIZE; for (final SGroup sGroup : childrenGroup) { deleteProfileMembersOfGroup(sGroup.getId()); } } while (childrenGroup.size() == BATCH_SIZE); }
private void deleteActorMembersOfGroupChildren(final long groupId) throws SIdentityException, SActorMemberNotFoundException, SActorMemberDeletionException, SBonitaReadException { int i = 0; List<SGroup> childrenGroup; do { childrenGroup = identityService.getGroupChildren(groupId, i, BATCH_SIZE); i += BATCH_SIZE; for (final SGroup sGroup : childrenGroup) { deleteActorMembersOfGroup(sGroup.getId()); } } while (childrenGroup.size() == BATCH_SIZE); }
private void deleteActorMembersOfGroupChildren(final long groupId) throws SIdentityException, SActorMemberNotFoundException, SActorMemberDeletionException, SBonitaReadException { int i = 0; List<SGroup> childrenGroup; do { childrenGroup = identityService.getGroupChildren(groupId, i, BATCH_SIZE); i += BATCH_SIZE; for (final SGroup sGroup : childrenGroup) { deleteActorMembersOfGroup(sGroup.getId()); } } while (childrenGroup.size() == BATCH_SIZE); }
private void deleteProfileMembersOfGroupChildren(final long groupId) throws SIdentityException, SBonitaException { int i = 0; List<SGroup> childrenGroup; do { childrenGroup = identityService.getGroupChildren(groupId, i, BATCH_SIZE); i += BATCH_SIZE; for (final SGroup sGroup : childrenGroup) { deleteProfileMembersOfGroup(sGroup.getId()); } } while (childrenGroup.size() == BATCH_SIZE); }
private void checkPathUnicity(long groupId, GroupUpdater updater, IdentityService identityService) throws SGroupNotFoundException, AlreadyExistsException { final Serializable updatedName = updater.getFields().get(GroupField.NAME); SGroup sGroupToBeUpdated = identityService.getGroup(groupId); String name = updatedName != null ? updatedName.toString() : sGroupToBeUpdated.getName(); StringBuilder sb = new StringBuilder(); String parentPath = updater.getFields().get(GroupField.PARENT_PATH) != null ? updater.getFields().get(GroupField.PARENT_PATH).toString() : ""; sb.append(parentPath).append("/").append(name); try { if (updatedName != null) { SGroup group = identityService.getGroupByPath(sb.toString()); if (group.getId() != groupId) { throw new AlreadyExistsException("Group named \"" + name + "\" already exists"); } } } catch (final SGroupNotFoundException e) { } }
private void checkPathUnicity(long groupId, GroupUpdater updater, IdentityService identityService) throws SGroupNotFoundException, AlreadyExistsException { final Serializable updatedName = updater.getFields().get(GroupField.NAME); SGroup sGroupToBeUpdated = identityService.getGroup(groupId); String name = updatedName != null ? updatedName.toString() : sGroupToBeUpdated.getName(); StringBuilder sb = new StringBuilder(); String parentPath = updater.getFields().get(GroupField.PARENT_PATH) != null ? updater.getFields().get(GroupField.PARENT_PATH).toString() : ""; sb.append(parentPath).append("/").append(name); try { if (updatedName != null) { SGroup group = identityService.getGroupByPath(sb.toString()); if (group.getId() != groupId) { throw new AlreadyExistsException("Group named \"" + name + "\" already exists"); } } } catch (final SGroupNotFoundException e) { } }
private Map<String, Long> importGroups(final List<ExportedGroup> groupCreators) throws ImportDuplicateInOrganizationException, SIdentityException { final Map<String, Long> groupPathToIdMap = new HashMap<>(groupCreators.size()); for (final ExportedGroup groupCreator : groupCreators) { SGroup sGroup; try { final String groupPath = getGroupPath(groupCreator); sGroup = identityService.getGroupByPath(groupPath); strategy.foundExistingGroup(sGroup, groupCreator); } catch (final SGroupNotFoundException e) { sGroup = addGroup(groupCreator); } groupPathToIdMap.put(sGroup.getPath(), sGroup.getId()); } return groupPathToIdMap; }
private Map<String, Long> importGroups(final List<ExportedGroup> groupCreators) throws ImportDuplicateInOrganizationException, SIdentityException { final Map<String, Long> groupPathToIdMap = new HashMap<>(groupCreators.size()); for (final ExportedGroup groupCreator : groupCreators) { SGroup sGroup; try { final String groupPath = getGroupPath(groupCreator); sGroup = identityService.getGroupByPath(groupPath); strategy.foundExistingGroup(sGroup, groupCreator); } catch (final SGroupNotFoundException e) { sGroup = addGroup(groupCreator); } groupPathToIdMap.put(sGroup.getPath(), sGroup.getId()); } return groupPathToIdMap; }
@Override public void updateGroup(final SGroup group, final EntityUpdateDescriptor descriptor, EntityUpdateDescriptor iconUpdater) throws SIdentityException { final SGroupLogBuilder logBuilder = getGroupLog(ActionType.UPDATED, "Updating the group"); try { if (iconUpdater != null && iconUpdater.getFields().containsKey("content")) { updateIcon(descriptor, iconUpdater, group); } recorder.recordUpdate(UpdateRecord.buildSetFields(group, descriptor), GROUP); log(group.getId(), SQueriableLog.STATUS_OK, logBuilder, "updateGroup"); } catch (final SRecorderException | SBonitaReadException e) { log(group.getId(), SQueriableLog.STATUS_FAIL, logBuilder, "updateGroup"); throw new SIdentityException("Can't update group " + group, e); } }
@Override public void updateGroup(final SGroup group, final EntityUpdateDescriptor descriptor, EntityUpdateDescriptor iconUpdater) throws SIdentityException { final SGroupLogBuilder logBuilder = getGroupLog(ActionType.UPDATED, "Updating the group"); try { if (iconUpdater != null && iconUpdater.getFields().containsKey("content")) { updateIcon(descriptor, iconUpdater, group); } recorder.recordUpdate(UpdateRecord.buildSetFields(group, descriptor), GROUP); log(group.getId(), SQueriableLog.STATUS_OK, logBuilder, "updateGroup"); } catch (final SRecorderException | SBonitaReadException e) { log(group.getId(), SQueriableLog.STATUS_FAIL, logBuilder, "updateGroup"); throw new SIdentityException("Can't update group " + group, e); } }
@Override public SActorMember addRoleAndGroupToActor(final long actorId, final long roleId, final long groupId) throws SActorNotFoundException, SActorMemberCreationException { try { final SActorMember addActorMember = addOnlyThisRoleAndGroupToActor(actorId, roleId, groupId); int i = 0; List<SGroup> groupChildren; do { groupChildren = identityService.getGroupChildren(groupId, i, BATCH_SIZE); for (final SGroup child : groupChildren) { addRoleAndGroupToActor(actorId, roleId, child.getId()); } i += BATCH_SIZE; } while (groupChildren.size() == BATCH_SIZE); return addActorMember; } catch (final SIdentityException e) { throw new SActorMemberCreationException(e); } }
@Override public void deleteGroup(final SGroup group) throws SGroupDeletionException { final SGroupLogBuilder logBuilder = getGroupLog(ActionType.DELETED, "Deleting group " + group.getName()); try { if (group.getIconId() != null) { deleteIcon(group.getIconId()); } recorder.recordDelete(new DeleteRecord(group), GROUP); log(group.getId(), SQueriableLog.STATUS_OK, logBuilder, "deleteGroup"); } catch (final SRecorderException | SBonitaReadException re) { log(group.getId(), SQueriableLog.STATUS_FAIL, logBuilder, "deleteGroup"); throw new SGroupDeletionException(re); } }
@Override public void deleteGroup(final SGroup group) throws SGroupDeletionException { final SGroupLogBuilder logBuilder = getGroupLog(ActionType.DELETED, "Deleting group " + group.getName()); try { if (group.getIconId() != null) { deleteIcon(group.getIconId()); } recorder.recordDelete(new DeleteRecord(group), GROUP); log(group.getId(), SQueriableLog.STATUS_OK, logBuilder, "deleteGroup"); } catch (final SRecorderException | SBonitaReadException re) { log(group.getId(), SQueriableLog.STATUS_FAIL, logBuilder, "deleteGroup"); throw new SGroupDeletionException(re); } }
private void updateChildren(final SGroup group, final String parentPath, final String idKey, final String parentPathKey, final String groupName) throws SIdentityException { List<SGroup> groupChildren; int i = 0; do { groupChildren = identityService.getGroupChildren(group.getId(), i * BATCH_SIZE, BATCH_SIZE, idKey, OrderByType.ASC); i++; for (final SGroup child : groupChildren) { if (parentPath != null) { updateChildren(child, parentPath + '/' + groupName, idKey, parentPathKey, child.getName()); } else { updateChildren(child, '/' + groupName, idKey, parentPathKey, child.getName()); } } } while (!groupChildren.isEmpty()); final EntityUpdateDescriptor updateDescriptor = new EntityUpdateDescriptor(); updateDescriptor.addField(parentPathKey, parentPath); identityService.updateGroup(group, updateDescriptor, null); }
private void updateChildren(final SGroup group, final String parentPath, final String idKey, final String parentPathKey, final String groupName) throws SIdentityException { List<SGroup> groupChildren; int i = 0; do { groupChildren = identityService.getGroupChildren(group.getId(), i * BATCH_SIZE, BATCH_SIZE, idKey, OrderByType.ASC); i++; for (final SGroup child : groupChildren) { if (parentPath != null) { updateChildren(child, parentPath + '/' + groupName, idKey, parentPathKey, child.getName()); } else { updateChildren(child, '/' + groupName, idKey, parentPathKey, child.getName()); } } } while (!groupChildren.isEmpty()); final EntityUpdateDescriptor updateDescriptor = new EntityUpdateDescriptor(); updateDescriptor.addField(parentPathKey, parentPath); identityService.updateGroup(group, updateDescriptor, null); }
@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); }
@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 Group toGroup(final SGroup sGroup) { final GroupImpl group = new GroupImpl(sGroup.getId(), sGroup.getName()); group.setParentPath(sGroup.getParentPath()); group.setCreatedBy(sGroup.getCreatedBy()); group.setCreationDate(new Date(sGroup.getCreationDate())); group.setDescription(sGroup.getDescription()); group.setDisplayName(sGroup.getDisplayName()); group.setIconId(sGroup.getIconId()); group.setLastUpdate(new Date(sGroup.getLastUpdate())); return group; }
public static Group toGroup(final SGroup sGroup) { final GroupImpl group = new GroupImpl(sGroup.getId(), sGroup.getName()); group.setParentPath(sGroup.getParentPath()); group.setCreatedBy(sGroup.getCreatedBy()); group.setCreationDate(new Date(sGroup.getCreationDate())); group.setDescription(sGroup.getDescription()); group.setDisplayName(sGroup.getDisplayName()); group.setIconId(sGroup.getIconId()); group.setLastUpdate(new Date(sGroup.getLastUpdate())); return group; }
@Override public void createGroup(final SGroup group, String iconFileName, byte[] iconContent) throws SGroupCreationException { final String methodName = "createGroup"; final long objectId = group.getId(); final SGroupLogBuilder logBuilder = getGroupLog(ActionType.CREATED, "Adding a new group with name " + group.getName()); try { if (iconFileName != null && iconContent != null) { SIcon icon = createIcon(iconFileName, iconContent); ((SGroupImpl) group).setIconId(icon.getId()); } final InsertRecord insertRecord = new InsertRecord(group); recorder.recordInsert(insertRecord, GROUP); final int status = SQueriableLog.STATUS_OK; log(insertRecord.getEntity().getId(), status, logBuilder, methodName); } catch (final SRecorderException re) { final int status = SQueriableLog.STATUS_FAIL; log(objectId, status, logBuilder, methodName); throw new SGroupCreationException(re); } }