use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.
the class UserService method getUsers.
@Override
public PagedMetadata<UserDto> getUsers(RestListRequest requestList) {
try {
// transforms the filters by overriding the key specified in the request with the correct one known by the dto
List<FieldSearchFilter> filters = new ArrayList<FieldSearchFilter>(requestList.buildFieldSearchFilters());
filters.stream().filter(i -> ((i.getKey() != null) && (UserDto.getEntityFieldName(i.getKey()) != null))).forEach(i -> i.setKey(UserDto.getEntityFieldName(i.getKey())));
List<UserDetails> users = null;
if (filters.size() > 0) {
String text = (String) filters.get(0).getValue();
users = this.getUserManager().searchUsers(text);
} else {
users = this.getUserManager().getUsers();
}
List<UserDto> dtoList = dtoBuilder.convert(users);
SearcherDaoPaginatedResult<UserDetails> result = new SearcherDaoPaginatedResult<>(users.size(), users);
PagedMetadata<UserDto> pagedMetadata = new PagedMetadata<>(requestList, result);
pagedMetadata.setBody(dtoList);
return pagedMetadata;
} catch (Throwable t) {
logger.error("error in search groups", t);
throw new RestServerError("error in search groups", t);
}
}
use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.
the class UserControllerUnitTest method mockUser.
private UserDto mockUser() {
User user1 = new User();
user1.setUsername("user");
user1.setDisabled(false);
user1.setLastAccess(new Date());
user1.setLastPasswordChange(new Date());
user1.setMaxMonthsSinceLastAccess(2);
user1.setMaxMonthsSinceLastPasswordChange(1);
String password;
try {
password = this.getEncrypter().encrypt("password");
} catch (ApsSystemException ex) {
password = "plain_password";
}
user1.setPassword(password);
return new UserDto(user1);
}
use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.
the class UserController method getUsers.
@RestAccessControl(permission = Permission.MANAGE_USERS)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getUsers(RestListRequest requestList) {
logger.debug("getting users details with request {}", requestList);
PagedMetadata<UserDto> result = this.getUserService().getUsers(requestList);
return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.
the class RoleService method getRoleReferences.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public PagedMetadata<UserDto> getRoleReferences(String roleCode, RestListRequest restRequest) {
Role role = this.getRoleManager().getRole(roleCode);
if (null == role) {
logger.warn("no role found with code {}", roleCode);
throw new RestRourceNotFoundException(RoleValidator.ERRCODE_ROLE_NOT_FOUND, "role", roleCode);
}
List<UserDto> dtoList = this.getAuthorizationService().getRoleUtilizer(roleCode);
List<UserDto> subList = restRequest.getSublist(dtoList);
SearcherDaoPaginatedResult<UserDto> pagedResult = new SearcherDaoPaginatedResult(dtoList.size(), subList);
PagedMetadata<UserDto> pagedMetadata = new PagedMetadata<>(restRequest, pagedResult);
pagedMetadata.setBody(subList);
return pagedMetadata;
}
use of org.entando.entando.aps.system.services.user.model.UserDto in project entando-core by entando.
the class RoleService method validateRoleForDelete.
protected BeanPropertyBindingResult validateRoleForDelete(Role role) {
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(role, "role");
List<UserDto> users = this.getAuthorizationService().getRoleUtilizer(role.getName());
if (!users.isEmpty()) {
errors.reject(RoleValidator.ERRCODE_ROLE_REFERENCES, new String[] { role.getName() }, "role.cannot.delete.references");
}
return errors;
}
Aggregations