use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class ProfileTypeController method deleteDataType.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{profileTypeCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteDataType(@PathVariable String profileTypeCode) throws ApsSystemException {
logger.debug("Deleting profile type -> {}", profileTypeCode);
this.getUserProfileTypeService().deleteUserProfileType(profileTypeCode);
Map<String, String> result = new HashMap<>();
result.put("code", profileTypeCode);
return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class ProfileTypeController method getUserProfileTypes.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getUserProfileTypes(RestListRequest requestList) throws JsonProcessingException {
this.getProfileTypeValidator().validateRestListRequest(requestList);
PagedMetadata<EntityTypeShortDto> result = this.getUserProfileTypeService().getShortUserProfileTypes(requestList);
logger.debug("Main Response -> {}", result);
this.getProfileTypeValidator().validateRestListResult(requestList, result);
return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class ProfileTypeController method addUserProfileTypes.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> addUserProfileTypes(@Valid @RequestBody ProfileTypeDtoRequest bodyRequest, BindingResult bindingResult) throws JsonProcessingException {
// field validations
this.getProfileTypeValidator().validate(bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
if (this.getProfileTypeValidator().existType(bodyRequest.getCode())) {
bindingResult.reject(DataTypeValidator.ERRCODE_ENTITY_TYPE_ALREADY_EXISTS, new String[] { bodyRequest.getCode() }, "entityType.exists");
}
if (bindingResult.hasErrors()) {
throw new ValidationConflictException(bindingResult);
}
UserProfileTypeDto result = this.getUserProfileTypeService().addUserProfileType(bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
logger.debug("Main Response -> {}", result);
return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class ProfileTypeController method getUserProfileType.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{profileTypeCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getUserProfileType(@PathVariable String profileTypeCode) throws JsonProcessingException {
logger.debug("Requested profile type -> {}", profileTypeCode);
if (!this.getProfileTypeValidator().existType(profileTypeCode)) {
throw new RestRourceNotFoundException(DataTypeValidator.ERRCODE_ENTITY_TYPE_DOES_NOT_EXIST, "Profile Type", profileTypeCode);
}
UserProfileTypeDto dto = this.getUserProfileTypeService().getUserProfileType(profileTypeCode);
logger.debug("Main Response -> {}", dto);
return new ResponseEntity<>(new RestResponse(dto), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class UserSettingsController method updateUserSettings.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateUserSettings(@Valid @RequestBody UserSettingsRequest request, BindingResult bindingResult) {
logger.debug("updatinug user settings");
// params validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
UserSettingsDto settings = this.getUserSettingsService().updateUserSettings(request);
return new ResponseEntity<>(new RestResponse(settings), HttpStatus.OK);
}
Aggregations