@Override public void deleteCustomUserInfoDefinition(final long customUserInfoDefinitionId) throws SIdentityException { this.deleteCustomUserInfoDefinition(getCustomUserInfoDefinition(customUserInfoDefinitionId)); }
@Override public void deleteCustomUserInfoValue(final long customUserInfoValueId) throws SIdentityException { this.deleteCustomUserInfoValue(getCustomUserInfoValue(customUserInfoValueId)); }
@Override public void deleteGroup(final long groupId) throws SGroupNotFoundException, SGroupDeletionException { final SGroup group = getGroup(groupId); this.deleteGroup(group); }
@Override public void deleteRole(final long roleId) throws SRoleNotFoundException, SRoleDeletionException { final SRole role = getRole(roleId); this.deleteRole(role); }
EntityUpdateDescriptor professionalDataUpdateDescriptor, EntityUpdateDescriptor iconUpdater) throws SIdentityException { SUser sUser = getUser(userId); if (iconUpdater.getFields().containsKey("content")) { try { updateIcon(userUpdateDescriptor, iconUpdater, sUser); } catch (SBonitaReadException | SRecorderException e) { throw new SIdentityException(e); updateUser(sUser, userUpdateDescriptor); SContactInfo persoContactInfo = getUserContactInfo(userId, true); if (persoContactInfo == null) { persoContactInfo = BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(userId, true).done(); createUserContactInfo(persoContactInfo); updateUserContactInfo(persoContactInfo, personalDataUpdateDescriptor); SContactInfo professContactInfo = getUserContactInfo(userId, false); if (professContactInfo == null) { professContactInfo = BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(userId, false).done(); createUserContactInfo(professContactInfo); updateUserContactInfo(professContactInfo, professionalDataUpdateDescriptor);
@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 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 deleteUser(final long userId) throws SUserDeletionException { SUser user; try { user = getUser(userId); if (user.getIconId() != null) { deleteIcon(user.getIconId()); } deleteUser(user); } catch (final SUserNotFoundException e) { // ignored, let's switch to the next one } catch (SRecorderException | SBonitaReadException e) { throw new SUserDeletionException(e); } }
@Override public void createRole(final SRole role, String iconFilename, byte[] iconContent) throws SIdentityException { final String methodName = "createRole"; final SRoleLogBuilder logBuilder = getRoleLog(ActionType.CREATED, "Adding a new role with name " + role.getName()); try { if (iconFilename != null && iconContent != null) { SIcon icon = createIcon(iconFilename, iconContent); (((SRoleImpl) role)).setIconId(icon.getId()); } recorder.recordInsert(new InsertRecord(role), ROLE); log(role.getId(), SQueriableLog.STATUS_OK, logBuilder, methodName); } catch (final SRecorderException e) { log(role.getId(), SQueriableLog.STATUS_FAIL, logBuilder, methodName); throw new SIdentityException("Can't add role " + role, e); } }
@Override public SUser createUser(SUser sUser, SContactInfo personalContactInfo, SContactInfo proContactInfo, String iconFilename, byte[] iconContent) throws SUserCreationException { if (iconFilename != null && iconContent != null) { try { SIcon icon = createIcon(iconFilename, iconContent); ((SUserImpl) sUser).setIconId(icon.getId()); } catch (SRecorderException e) { throw new SUserCreationException(e); } } SUser user = createUser(sUser); if (personalContactInfo != null) { createUserContactInfo(BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(personalContactInfo).setUserId(user.getId()).done()); } if (proContactInfo != null) { createUserContactInfo(BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(proContactInfo).setUserId(user.getId()).done()); } return user; }
@Override public List<Long> deleteChildrenGroup(final long groupId) throws SGroupDeletionException, SGroupNotFoundException { final ArrayList<Long> deletedGroups = new ArrayList<>(); try { List<SGroup> childrenGroup; final int nbGroup = 20; while (!(childrenGroup = getGroupChildren(groupId, 0, nbGroup)).isEmpty()) { for (final SGroup sGroup : childrenGroup) { deletedGroups.addAll(deleteChildrenGroup(sGroup.getId())); deletedGroups.add(sGroup.getId()); deleteGroup(sGroup); } } } catch (final SGroupNotFoundException e) { throw e; } catch (final SIdentityException e) { throw new SGroupDeletionException(e); } return deletedGroups; }
@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 deleteUserMembership(final long id) throws SMembershipDeletionException { try { final SUserMembership userMembership = getLightUserMembership(id); deleteLightUserMembership(userMembership); } catch (final SIdentityException e) { throw new SMembershipDeletionException("Can't delete membership with id " + id, e); } }
private void replaceIcon(EntityUpdateDescriptor updateDescriptor, byte[] content, String filename, SHavingIcon element) throws SRecorderException, SBonitaReadException { SIcon newIcon = createIcon(filename, content); updateDescriptor.addField("iconId", newIcon.getId()); Long previousIconId = element.getIconId(); if (previousIconId != null) { deleteIcon(previousIconId); } }
@Override @Deprecated public SUser createUserWithoutEncryptingPassword(final SUser user) throws SUserCreationException { final String methodName = "createUserWithoutEncryptingPassword"; final SUser hashedUser = BuilderFactory.get(SUserBuilderFactory.class).createNewInstance(user).done(); return createUser(user, methodName, hashedUser); }
private void removeIcon(EntityUpdateDescriptor updateDescriptor, SHavingIcon element) throws SBonitaReadException, SRecorderException { Long previousIconId = element.getIconId(); if (previousIconId != null) { deleteIcon(previousIconId); updateDescriptor.addField("iconId", null); } }
EntityUpdateDescriptor professionalDataUpdateDescriptor, EntityUpdateDescriptor iconUpdater) throws SIdentityException { SUser sUser = getUser(userId); if (iconUpdater.getFields().containsKey("content")) { try { updateIcon(userUpdateDescriptor, iconUpdater, sUser); } catch (SBonitaReadException | SRecorderException e) { throw new SIdentityException(e); updateUser(sUser, userUpdateDescriptor); SContactInfo persoContactInfo = getUserContactInfo(userId, true); if (persoContactInfo == null) { persoContactInfo = BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(userId, true).done(); createUserContactInfo(persoContactInfo); updateUserContactInfo(persoContactInfo, personalDataUpdateDescriptor); SContactInfo professContactInfo = getUserContactInfo(userId, false); if (professContactInfo == null) { professContactInfo = BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(userId, false).done(); createUserContactInfo(professContactInfo); updateUserContactInfo(professContactInfo, professionalDataUpdateDescriptor);
@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 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 deleteUser(final long userId) throws SUserDeletionException { SUser user; try { user = getUser(userId); if (user.getIconId() != null) { deleteIcon(user.getIconId()); } deleteUser(user); } catch (final SUserNotFoundException e) { // ignored, let's switch to the next one } catch (SRecorderException | SBonitaReadException e) { throw new SUserDeletionException(e); } }