Search in sources :

Example 1 with UserDTO

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;
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) UserDTO(org.geosdi.geoplatform.response.UserDTO) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 2 with UserDTO

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());
}
Also used : SearchRequest(org.geosdi.geoplatform.request.SearchRequest) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) GPUser(org.geosdi.geoplatform.core.model.GPUser) UserDTOResponse(org.geosdi.geoplatform.response.UserDTOResponse) UserDTO(org.geosdi.geoplatform.response.UserDTO) Test(org.junit.Test)

Example 3 with UserDTO

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;
}
Also used : GPUser(org.geosdi.geoplatform.core.model.GPUser) UserDTO(org.geosdi.geoplatform.response.UserDTO) ArrayList(java.util.ArrayList)

Example 4 with UserDTO

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());
}
Also used : PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) SearchRequest(org.geosdi.geoplatform.request.SearchRequest) GPUser(org.geosdi.geoplatform.core.model.GPUser) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) UserDTO(org.geosdi.geoplatform.response.UserDTO) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) ArrayList(java.util.ArrayList) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) GPUserManageDetail(org.geosdi.geoplatform.gui.client.model.GPUserManageDetail) IGPUserManageDetail(org.geosdi.geoplatform.gui.global.security.IGPUserManageDetail)

Example 5 with UserDTO

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());
}
Also used : SearchRequest(org.geosdi.geoplatform.request.SearchRequest) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) GPUser(org.geosdi.geoplatform.core.model.GPUser) UserDTOResponse(org.geosdi.geoplatform.response.UserDTOResponse) UserDTO(org.geosdi.geoplatform.response.UserDTO) Test(org.junit.Test)

Aggregations

UserDTO (org.geosdi.geoplatform.response.UserDTO)7 GPUser (org.geosdi.geoplatform.core.model.GPUser)4 Test (org.junit.Test)4 PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)3 SearchRequest (org.geosdi.geoplatform.request.SearchRequest)3 ArrayList (java.util.ArrayList)2 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)2 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)2 ApplicationDTO (org.geosdi.geoplatform.response.ApplicationDTO)2 ShortAccountDTO (org.geosdi.geoplatform.response.ShortAccountDTO)2 UserDTOResponse (org.geosdi.geoplatform.response.UserDTOResponse)2 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)1 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)1 GPUserManageDetail (org.geosdi.geoplatform.gui.client.model.GPUserManageDetail)1 IGPUserManageDetail (org.geosdi.geoplatform.gui.global.security.IGPUserManageDetail)1