@Override public IdentityAPI getIdentityAPI() { return new IdentityAPIImpl(); }
@Override public long getNumberOfCustomInfoDefinitions() { return createCustomUserInfoDefinitionAPI().count(); }
@Override public Role createRole(final String roleName) throws AlreadyExistsException, CreationException { return createRole(new RoleCreator(roleName)); }
@Override public Group updateGroup(final long groupId, final GroupUpdater updater) throws GroupNotFoundException, UpdateException, AlreadyExistsException { if (updater == null || updater.getFields().isEmpty()) { throw new UpdateException("The update descriptor does not contain field updates"); } final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final IdentityService identityService = tenantAccessor.getIdentityService(); try { checkPathUnicity(groupId, updater, identityService); final EntityUpdateDescriptor changeDescriptor = getGroupUpdateDescriptor(updater, tenantAccessor.getTechnicalLoggerService()); return ModelConvertor.toGroup(new UpdateGroup(groupId, changeDescriptor, identityService, getIconUpdater(updater)).update()); } catch (final SGroupNotFoundException e) { throw new GroupNotFoundException(e); } catch (final SIdentityException sbe) { throw new UpdateException(sbe); } }
@Override public SearchResult<CustomUserInfoValue> searchCustomUserInfoValues(final SearchOptions options) { try { return createCustomUserInfoValueAPI().search(getTenantAccessor().getSearchEntitiesDescriptor().getSearchCustomUserInfoValueDescriptor(), options); } catch (final SBonitaException e) { throw new RetrieveException(e); } }
@Override public User createUser(final String userName, final String password) throws AlreadyExistsException, CreationException { final UserCreator creator = new UserCreator(userName, password); creator.setEnabled(true); return createUser(creator); }
@Override public List<CustomUserInfo> getCustomUserInfo(final long userId, final int startIndex, final int maxResult) { try { return createCustomUserInfoAPI().list(userId, startIndex, maxResult); } catch (final SBonitaException e) { throw new RetrieveException(e); } }
@Override public Group createGroup(final String name, final String parentPath) throws CreationException { final GroupCreator groupCreator = new GroupCreator(name); groupCreator.setParentPath(parentPath); return createGroup(groupCreator); }
@Override public CustomUserInfoValue setCustomUserInfoValue(final long definitionId, final long userId, final String value) throws UpdateException { try { return ModelConvertor.convert(createCustomUserInfoValueAPI().set(definitionId, userId, value)); } catch (final SBonitaException e) { throw new UpdateException(e); } }
@Override public Map<Long, Group> getGroups(final List<Long> groupIds) { final Map<Long, Group> groups = new HashMap<>(); for (final Long groupId : groupIds) { try { final Group group = getGroup(groupId); groups.put(groupId, group); } catch (final GroupNotFoundException e) { // if the group does not exist; skip the group } } return groups; }
@Override public Group updateGroup(final long groupId, final GroupUpdater updater) throws GroupNotFoundException, UpdateException, AlreadyExistsException { if (updater == null || updater.getFields().isEmpty()) { throw new UpdateException("The update descriptor does not contain field updates"); } final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final IdentityService identityService = tenantAccessor.getIdentityService(); try { checkPathUnicity(groupId, updater, identityService); final EntityUpdateDescriptor changeDescriptor = getGroupUpdateDescriptor(updater, tenantAccessor.getTechnicalLoggerService()); return ModelConvertor.toGroup(new UpdateGroup(groupId, changeDescriptor, identityService, getIconUpdater(updater)).update()); } catch (final SGroupNotFoundException e) { throw new GroupNotFoundException(e); } catch (final SIdentityException sbe) { throw new UpdateException(sbe); } }
@Override public SearchResult<CustomUserInfoValue> searchCustomUserInfoValues(final SearchOptions options) { try { return createCustomUserInfoValueAPI().search(getTenantAccessor().getSearchEntitiesDescriptor().getSearchCustomUserInfoValueDescriptor(), options); } catch (final SBonitaException e) { throw new RetrieveException(e); } }
@Override public User createUser(final String userName, final String password) throws AlreadyExistsException, CreationException { final UserCreator creator = new UserCreator(userName, password); creator.setEnabled(true); return createUser(creator); }
@Override public List<CustomUserInfo> getCustomUserInfo(final long userId, final int startIndex, final int maxResult) { try { return createCustomUserInfoAPI().list(userId, startIndex, maxResult); } catch (final SBonitaException e) { throw new RetrieveException(e); } }
@Override public Group createGroup(final String name, final String parentPath) throws CreationException { final GroupCreator groupCreator = new GroupCreator(name); groupCreator.setParentPath(parentPath); return createGroup(groupCreator); }
@Override public CustomUserInfoValue setCustomUserInfoValue(final long definitionId, final long userId, final String value) throws UpdateException { try { return ModelConvertor.convert(createCustomUserInfoValueAPI().set(definitionId, userId, value)); } catch (final SBonitaException e) { throw new UpdateException(e); } }
@Override public Map<Long, Group> getGroups(final List<Long> groupIds) { final Map<Long, Group> groups = new HashMap<>(); for (final Long groupId : groupIds) { try { final Group group = getGroup(groupId); groups.put(groupId, group); } catch (final GroupNotFoundException e) { // if the group does not exist; skip the group } } return groups; }
@Override public List<CustomUserInfoDefinition> getCustomUserInfoDefinitions(final int startIndex, final int maxResult) throws RetrieveException { return createCustomUserInfoDefinitionAPI().list(startIndex, maxResult); }
@Override public User createUser(final String userName, final String password, final String firstName, final String lastName) throws AlreadyExistsException, CreationException { final UserCreator creator = new UserCreator(userName, password); creator.setFirstName(firstName).setLastName(lastName); creator.setEnabled(true); return createUser(creator); }
@Override public IdentityAPI getIdentityAPI() { return new IdentityAPIImpl(); }