public void delete(Username currentUser, Role role, LocalizedOperationResult result) { update(currentUser, role, result, new RoleConfigDeleteCommand(goConfigService, role, authorizationExtension, currentUser, result)); if (result.isSuccessful()) { result.setMessage(LocalizedMessage.resourceDeleteSuccessful(getTagName(role.getClass()).toLowerCase(), role.getName())); } }
protected void update(Username currentUser, Role role, LocalizedOperationResult result, EntityConfigUpdateCommand<Role> command) { try { goConfigService.updateConfig(command, currentUser); } catch (Exception e) { if (e instanceof GoConfigInvalidException) { result.unprocessableEntity(entityConfigValidationFailed(getTagName(role.getClass()), role.getName(), ((GoConfigInvalidException) e).getAllErrorMessages())); } else { if (!result.hasMessage()) { LOGGER.error(e.getMessage(), e); result.internalServerError(saveFailedWithReason("An error occurred while saving the role config. Please check the logs for more information.")); } } } }
public void bulkUpdate(GoCDRolesBulkUpdateRequest bulkUpdateRequest, Username currentUser, HttpLocalizedOperationResult result) { RolesConfigBulkUpdateCommand command = new RolesConfigBulkUpdateCommand(bulkUpdateRequest, currentUser, goConfigService, result); try { goConfigService.updateConfig(command, currentUser); } catch (Exception e) { if (e instanceof GoConfigInvalidException) { result.unprocessableEntity(entityConfigValidationFailed(getTagName(RolesConfig.class), bulkUpdateRequest.getRolesToUpdateAsString(), ((GoConfigInvalidException) e).getAllErrorMessages())); } else { if (!result.hasMessage()) { LOGGER.error(e.getMessage(), e); result.internalServerError(saveFailedWithReason("An error occurred while saving the role config. Please check the logs for more information.")); } } } }