use of org.geosdi.geoplatform.response.UserDTO in project geo-platform by geosdi.
the class UserService method updateOwnUser.
@Override
public Long updateOwnUser(IGPUserManageDetail userDetail, String currentPlainPassword, String newPlainPassword, HttpServletRequest httpServletRequest) throws GeoPlatformException {
this.getCheckLoggedUser(httpServletRequest);
logger.debug("\nOWN User to update:\n{}", userDetail);
Long userID = null;
try {
UserDTO userDTO = new UserDTO();
userDTO.setId(userDetail.getId());
userDTO.setName(userDetail.getName());
userDTO.setEmailAddress(userDetail.getEmail());
userID = geoPlatformServiceClient.updateOwnUser(userDTO, currentPlainPassword, newPlainPassword);
sessionUtility.storeLoggedAccount(this.dtoUserConverter.convertToGPUser(userDetail), httpServletRequest);
} catch (IllegalParameterFault ipf) {
throw new GeoPlatformException(ipf.getMessage());
} catch (ResourceNotFoundFault rnnf) {
throw new GeoPlatformException(rnnf.getMessage());
}
return userID;
}
use of org.geosdi.geoplatform.response.UserDTO in project geo-platform by geosdi.
the class RSAccountTest method testRetrieveUserRest.
@Test
public void testRetrieveUserRest() throws ResourceNotFoundFault {
// Number of Account Like
long numAccountsLike = gpWSClient.getAccountsCount(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS));
Assert.assertEquals("Number of Account Like", 1L, numAccountsLike);
// Get User from Id
// Get UserDTO from Id
UserDTOResponse userDTOResponse = gpWSClient.getShortUser(idUserTest);
UserDTO userDTOFromWS = userDTOResponse.getUserDTO();
Assert.assertNotNull(userDTOFromWS);
Assert.assertEquals("Error found UserDTO from Id", idUserTest, userDTOFromWS.getId().longValue());
// Get GPUser from Id
GPUser userFromWS = gpWSClient.getUserDetail(idUserTest);
Assert.assertNotNull(userFromWS);
Assert.assertEquals("Error found GPUser from Id", idUserTest, userFromWS.getId().longValue());
// Get User from Username
// Get UserDTO from Username
userDTOFromWS = gpWSClient.getShortUserByUsername(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS)).getUserDTO();
Assert.assertNotNull(userDTOFromWS);
Assert.assertEquals("Error found UserDTO from Username", idUserTest, userDTOFromWS.getId().longValue());
// Get GPUser from Username
userFromWS = gpWSClient.getUserDetailByUsername(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS));
Assert.assertNotNull(userFromWS);
Assert.assertEquals("Error found GPUser from Username", idUserTest, userFromWS.getId().longValue());
}
use of org.geosdi.geoplatform.response.UserDTO in project geo-platform by geosdi.
the class AccountDTOFactory method buildUserDTOList.
public static List<UserDTO> buildUserDTOList(List<GPUser> users) {
checkNotNull(users, "The List of Accounts must not be null.");
List<UserDTO> usersDTO = new ArrayList<>(users.size());
for (GPUser gpUser : users) {
usersDTO.add((UserDTO) buildAccountDTO(gpUser));
}
return usersDTO;
}
use of org.geosdi.geoplatform.response.UserDTO in project geo-platform by geosdi.
the class UserService method searchUsers.
@Override
public PagingLoadResult<GPUserManageDetail> searchUsers(PagingLoadConfig config, String searchText, String organization, HttpServletRequest httpServletRequest) {
GPUser user = this.getCheckLoggedUser(httpServletRequest);
SearchRequest srq = new SearchRequest(searchText);
Long usersCount = this.geoPlatformServiceClient.getUsersCount(organization, srq);
int start = config.getOffset();
int page = start == 0 ? start : start / config.getLimit();
PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
List<UserDTO> userList = null;
try {
userList = this.geoPlatformServiceClient.searchUsers(user.getId(), psr).getSearchUsers();
if (userList == null) {
throw new GeoPlatformException("There are no results");
}
} catch (ResourceNotFoundFault rnnf) {
// TODO Better message
throw new GeoPlatformException(rnnf.getMessage());
}
List<GPUserManageDetail> searchUsers = new ArrayList<GPUserManageDetail>();
for (UserDTO userDTO : userList) {
GPUserManageDetail userDetail = this.dtoUserConverter.convertToGPUserManageDetail(userDTO);
searchUsers.add(userDetail);
}
return new BasePagingLoadResult<GPUserManageDetail>(searchUsers, config.getOffset(), usersCount.intValue());
}
use of org.geosdi.geoplatform.response.UserDTO in project geo-platform by geosdi.
the class WSAccountTest method testRetrieveUser.
@Test
public void testRetrieveUser() throws ResourceNotFoundFault {
// Number of Account Like
long numAccountsLike = gpWSClient.getAccountsCount(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS));
assertEquals("Number of Account Like", 1L, numAccountsLike);
// Get User from Id
// Get UserDTO from Id
UserDTOResponse userDTOResponse = gpWSClient.getShortUser(idUserTest);
UserDTO userDTOFromWS = userDTOResponse.getUserDTO();
assertNotNull(userDTOFromWS);
assertEquals("Error found UserDTO from Id", idUserTest, userDTOFromWS.getId().longValue());
// Get GPUser from Id
GPUser userFromWS = gpWSClient.getUserDetail(idUserTest);
assertNotNull(userFromWS);
assertEquals("Error found GPUser from Id", idUserTest, userFromWS.getId().longValue());
// Get User from Username
// Get UserDTO from Username
userDTOFromWS = gpWSClient.getShortUserByUsername(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS)).getUserDTO();
assertNotNull(userDTOFromWS);
assertEquals("Error found UserDTO from Username", idUserTest, userDTOFromWS.getId().longValue());
// Get GPUser from Username
userFromWS = gpWSClient.getUserDetailByUsername(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS));
assertNotNull(userFromWS);
assertEquals("Error found GPUser from Username", idUserTest, userFromWS.getId().longValue());
}
Aggregations