Search in sources :

Example 1 with UserDto

use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.

the class RoleController method getRoleReferences.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{roleCode}/userreferences", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getRoleReferences(@PathVariable String roleCode, RestListRequest requestList) {
    logger.debug("loading user references for role {}", roleCode);
    PagedMetadata<UserDto> result = this.getRoleService().getRoleReferences(roleCode, requestList);
    return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) UserDto(org.entando.entando.aps.system.services.user.model.UserDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with UserDto

use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.

the class UserController method updateUserPassword.

@RestAccessControl(permission = Permission.MANAGE_USERS)
@RequestMapping(value = "/{username}/password", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateUserPassword(@PathVariable String username, @Valid @RequestBody UserPasswordRequest passwordRequest, BindingResult bindingResult) {
    logger.debug("changing pasword for user {} with request {}", username, passwordRequest);
    // field validations
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    this.getUserValidator().validateBody(username, passwordRequest.getUsername(), bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    this.getUserValidator().validatePasswords(passwordRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    UserDto user = this.getUserService().updateUserPassword(passwordRequest);
    return new ResponseEntity<>(new RestResponse(user), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) UserDto(org.entando.entando.aps.system.services.user.model.UserDto) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with UserDto

use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.

the class UserController method addUser.

@RestAccessControl(permission = Permission.MANAGE_USERS)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addUser(@Valid @RequestBody UserRequest userRequest, BindingResult bindingResult) throws ApsSystemException {
    logger.debug("adding user with request {}", userRequest);
    // field validations
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    UserDto dto = this.getUserService().addUser(userRequest);
    return new ResponseEntity<>(new RestResponse(dto), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) UserDto(org.entando.entando.aps.system.services.user.model.UserDto) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with UserDto

use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.

the class UserController method updateUser.

@RestAccessControl(permission = Permission.MANAGE_USERS)
@RequestMapping(value = "/{username}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateUser(@PathVariable String username, @Valid @RequestBody UserRequest userRequest, BindingResult bindingResult) {
    logger.debug("updating user {} with request {}", username, userRequest);
    // field validations
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    this.getUserValidator().validateBody(username, userRequest.getUsername(), bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    this.getUserValidator().validatePassword(username, userRequest.getPassword(), bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    UserDto user = this.getUserService().updateUser(userRequest);
    return new ResponseEntity<>(new RestResponse(user), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) UserDto(org.entando.entando.aps.system.services.user.model.UserDto) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with UserDto

use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.

the class UserController method getUser.

@RestAccessControl(permission = Permission.MANAGE_USERS)
@RequestMapping(value = "/{username}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getUser(@PathVariable String username) {
    logger.debug("getting user {} details", username);
    UserDto user = this.getUserService().getUser(username);
    return new ResponseEntity<>(new RestResponse(user), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) UserDto(org.entando.entando.aps.system.services.user.model.UserDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

UserDto (org.entando.entando.aps.system.services.user.model.UserDto)13 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)6 RestResponse (org.entando.entando.web.common.model.RestResponse)6 ResponseEntity (org.springframework.http.ResponseEntity)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)4 ArrayList (java.util.ArrayList)4 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)3 User (com.agiletec.aps.system.services.user.User)3 RestServerError (org.entando.entando.aps.system.exception.RestServerError)3 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)3 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)3 UserDetails (com.agiletec.aps.system.services.user.UserDetails)2 Date (java.util.Date)2 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)2 RestListRequest (org.entando.entando.web.common.model.RestListRequest)2 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)1 IAuthorizationManager (com.agiletec.aps.system.services.authorization.IAuthorizationManager)1 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)1 Role (com.agiletec.aps.system.services.role.Role)1