use of org.entando.entando.aps.system.services.entity.model.EntityDto in project entando-core by entando.
the class ProfileController method addUserProfile.
@RestAccessControl(permission = Permission.MANAGE_USER_PROFILES)
@RequestMapping(value = "/userProfiles", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<EntityDto>> addUserProfile(@Valid @RequestBody EntityDto bodyRequest, BindingResult bindingResult) {
logger.debug("Add new user profile -> {}", bodyRequest);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
this.getProfileValidator().validate(bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
EntityDto response = this.getUserProfileService().addUserProfile(bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
return new ResponseEntity<>(new SimpleRestResponse<>(response), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.entity.model.EntityDto in project entando-core by entando.
the class ProfileController method updateUserProfile.
@RestAccessControl(permission = Permission.MANAGE_USER_PROFILES)
@RequestMapping(value = "/userProfiles/{username}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<EntityDto>> updateUserProfile(@PathVariable String username, @Valid @RequestBody EntityDto bodyRequest, BindingResult bindingResult) {
logger.debug("Update user profile -> {}", bodyRequest);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
this.getProfileValidator().validateBodyName(username, bodyRequest, bindingResult);
EntityDto response = this.getUserProfileService().updateUserProfile(bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
return new ResponseEntity<>(new SimpleRestResponse<>(response), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.entity.model.EntityDto in project entando-core by entando.
the class ProfileController method getUserProfile.
@RestAccessControl(permission = Permission.MANAGE_USER_PROFILES)
@RequestMapping(value = "/userProfiles/{username}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<EntityDto>> getUserProfile(@PathVariable String username) throws JsonProcessingException {
logger.debug("Requested profile -> {}", username);
EntityDto dto;
if (!this.getProfileValidator().existProfile(username)) {
if (userExists(username)) {
// if the user exists but the profile doesn't, creates an empty profile
IUserProfile userProfile = createNewEmptyUserProfile(username);
dto = new EntityDto(userProfile);
} else {
throw new ResourceNotFoundException(EntityValidator.ERRCODE_ENTITY_DOES_NOT_EXIST, "Profile", username);
}
} else {
dto = this.getUserProfileService().getUserProfile(username);
}
logger.debug("Main Response -> {}", dto);
return new ResponseEntity<>(new SimpleRestResponse<>(dto), HttpStatus.OK);
}
Aggregations