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 void addGroupToProfile() throws SGroupNotFoundException, SProfileMemberCreationException { final SGroup group = identityService.getGroup(groupId); if (group != null) { sProfileMember = profileService.addGroupToProfile(profileId, groupId, group.getName(), group.getParentPath()); } }
private void addGroupToProfile() throws SGroupNotFoundException, SProfileMemberCreationException { final SGroup group = identityService.getGroup(groupId); if (group != null) { sProfileMember = profileService.addGroupToProfile(profileId, groupId, group.getName(), group.getParentPath()); } }
public SGroup update() throws SIdentityException { SGroup sGroup = identityService.getGroup(groupId); final SGroupBuilderFactory sGroupBuilderFactory = BuilderFactory.get(SGroupBuilderFactory.class); // if the parent path changes it's also necessary to change the children's parent path final String parentPathKey = sGroupBuilderFactory.getParentPathKey(); final String nameKey = sGroupBuilderFactory.getNameKey(); final Map<String, Object> fields = changeDescriptor.getFields(); if (fields.containsKey(parentPathKey) || fields.containsKey(nameKey)) { final String parentPath = fields.containsKey(parentPathKey) ? (String) fields.get(parentPathKey) : sGroup.getParentPath(); final String groupName = fields.containsKey(nameKey) ? (String) fields.get(nameKey) : sGroup.getName(); updateChildren(sGroup, parentPath, sGroupBuilderFactory.getIdKey(), parentPathKey, groupName); } identityService.updateGroup(sGroup, changeDescriptor, iconUpdater); return sGroup; }
public SGroup update() throws SIdentityException { SGroup sGroup = identityService.getGroup(groupId); final SGroupBuilderFactory sGroupBuilderFactory = BuilderFactory.get(SGroupBuilderFactory.class); // if the parent path changes it's also necessary to change the children's parent path final String parentPathKey = sGroupBuilderFactory.getParentPathKey(); final String nameKey = sGroupBuilderFactory.getNameKey(); final Map<String, Object> fields = changeDescriptor.getFields(); if (fields.containsKey(parentPathKey) || fields.containsKey(nameKey)) { final String parentPath = fields.containsKey(parentPathKey) ? (String) fields.get(parentPathKey) : sGroup.getParentPath(); final String groupName = fields.containsKey(nameKey) ? (String) fields.get(nameKey) : sGroup.getName(); updateChildren(sGroup, parentPath, sGroupBuilderFactory.getIdKey(), parentPathKey, groupName); } identityService.updateGroup(sGroup, changeDescriptor, iconUpdater); return sGroup; }
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); }
private void addRoleAndGroupToProfile() throws SGroupNotFoundException, SRoleNotFoundException, SProfileMemberCreationException { final SGroup group = identityService.getGroup(groupId); final SRole role = identityService.getRole(roleId); if (group != null && role != null) { sProfileMember = profileService .addRoleAndGroupToProfile(profileId, roleId, groupId, role.getName(), group.getName(), group.getParentPath()); } }
private void addRoleAndGroupToProfile() throws SGroupNotFoundException, SRoleNotFoundException, SProfileMemberCreationException { final SGroup group = identityService.getGroup(groupId); final SRole role = identityService.getRole(roleId); if (group != null && role != null) { sProfileMember = profileService .addRoleAndGroupToProfile(profileId, roleId, groupId, role.getName(), group.getName(), group.getParentPath()); } }
protected EntityUpdateDescriptor getGroupDescriptor(final SGroup existingGroup, final ExportedGroup exportedGroup) { final SGroupUpdateBuilder groupUpdateBuilder = BuilderFactory.get(SGroupUpdateBuilderFactory.class).createNewInstance(); final String name = exportedGroup.getName(); if (name != null && !name.equals(existingGroup.getName())) { groupUpdateBuilder.updateName(name); } final String parentPath = exportedGroup.getParentPath(); if (parentPath != null && !parentPath.equals(existingGroup.getParentPath())) { groupUpdateBuilder.updateName(parentPath); } final String description = exportedGroup.getDescription(); if (description != null && !description.equals(existingGroup.getDescription())) { groupUpdateBuilder.updateDescription(description); } final String displayName = exportedGroup.getDisplayName(); if (displayName != null && !displayName.equals(existingGroup.getDisplayName())) { groupUpdateBuilder.updateDisplayName(displayName); } return groupUpdateBuilder.done(); }
protected EntityUpdateDescriptor getGroupDescriptor(final SGroup existingGroup, final ExportedGroup exportedGroup) { final SGroupUpdateBuilder groupUpdateBuilder = BuilderFactory.get(SGroupUpdateBuilderFactory.class).createNewInstance(); final String name = exportedGroup.getName(); if (name != null && !name.equals(existingGroup.getName())) { groupUpdateBuilder.updateName(name); } final String parentPath = exportedGroup.getParentPath(); if (parentPath != null && !parentPath.equals(existingGroup.getParentPath())) { groupUpdateBuilder.updateName(parentPath); } final String description = exportedGroup.getDescription(); if (description != null && !description.equals(existingGroup.getDescription())) { groupUpdateBuilder.updateDescription(description); } final String displayName = exportedGroup.getDisplayName(); if (displayName != null && !displayName.equals(existingGroup.getDisplayName())) { groupUpdateBuilder.updateDisplayName(displayName); } return groupUpdateBuilder.done(); }
private static ExportedGroup toExportedGroup(final SGroup sGroup) { final ExportedGroup group = new ExportedGroup(); group.setName(sGroup.getName()); group.setParentPath(sGroup.getParentPath()); group.setDescription(sGroup.getDescription()); group.setDisplayName(sGroup.getDisplayName()); return group; }
private static ExportedGroup toExportedGroup(final SGroup sGroup) { final ExportedGroup group = new ExportedGroup(); group.setName(sGroup.getName()); group.setParentPath(sGroup.getParentPath()); group.setDescription(sGroup.getDescription()); group.setDisplayName(sGroup.getDisplayName()); 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; }
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 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); } }
@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); } }
@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); } }