@Override public Role createRole(final RoleCreator creator) throws AlreadyExistsException, CreationException { if (creator == null) { throw new CreationException("Unable to create a role with a null RoleCreator object"); } if (creator.getFields().get(org.bonitasoft.engine.identity.RoleCreator.RoleField.NAME) == null) { throw new CreationException("Unable to create a role with a null name"); } final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final IdentityService identityService = tenantAccessor.getIdentityService(); if (creator.getFields().containsKey(RoleCreator.RoleField.ICON_NAME) || creator.getFields().containsKey(RoleCreator.RoleField.ICON_PATH)) { tenantAccessor.getTechnicalLoggerService().log(IdentityAPIImpl.class, TechnicalLogSeverity.WARNING, "setIconName and setIconPath are deprecated, use setIcon instead"); } final SRole sRole = ModelConvertor.constructSRole(creator); try { getRoleByName(sRole.getName()); throw new AlreadyExistsException("A role named \"" + sRole.getName() + "\" already exists"); } catch (final RoleNotFoundException ignored) { // Ok, role can now be created. } try { identityService.createRole(sRole, (String) creator.getFields().get(RoleCreator.RoleField.ICON_FILENAME), (byte[]) creator.getFields().get(RoleCreator.RoleField.ICON_CONTENT)); return ModelConvertor.toRole(sRole); } catch (final SIdentityException e) { throw new CreationException("Role create exception!", e); } }
@Override public Role createRole(final RoleCreator creator) throws AlreadyExistsException, CreationException { if (creator == null) { throw new CreationException("Unable to create a role with a null RoleCreator object"); } if (creator.getFields().get(org.bonitasoft.engine.identity.RoleCreator.RoleField.NAME) == null) { throw new CreationException("Unable to create a role with a null name"); } final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final IdentityService identityService = tenantAccessor.getIdentityService(); if (creator.getFields().containsKey(RoleCreator.RoleField.ICON_NAME) || creator.getFields().containsKey(RoleCreator.RoleField.ICON_PATH)) { tenantAccessor.getTechnicalLoggerService().log(IdentityAPIImpl.class, TechnicalLogSeverity.WARNING, "setIconName and setIconPath are deprecated, use setIcon instead"); } final SRole sRole = ModelConvertor.constructSRole(creator); try { getRoleByName(sRole.getName()); throw new AlreadyExistsException("A role named \"" + sRole.getName() + "\" already exists"); } catch (final RoleNotFoundException ignored) { // Ok, role can now be created. } try { identityService.createRole(sRole, (String) creator.getFields().get(RoleCreator.RoleField.ICON_FILENAME), (byte[]) creator.getFields().get(RoleCreator.RoleField.ICON_CONTENT)); return ModelConvertor.toRole(sRole); } catch (final SIdentityException e) { throw new CreationException("Role create exception!", e); } }