Search in sources :

Example 1 with SearchRequest

use of org.geosdi.geoplatform.request.SearchRequest in project geo-platform by geosdi.

the class LayerService method searchProjects.

@Override
public BasePagingLoadResult<GPClientProject> searchProjects(PagingLoadConfig config, String searchText, String imageURL, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    GPAccount account;
    try {
        account = this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    int start = config.getOffset();
    SearchRequest srq = new SearchRequest(searchText);
    try {
        Long projectsCount = this.geoPlatformServiceClient.getAccountProjectsCount(account.getId(), srq);
        if (projectsCount == 0l) {
            throw new GeoPlatformException("There are no results");
        }
        logger.debug("#############################PROJECT_COUNT : {}\n", projectsCount);
        int page = start == 0 ? start : start / config.getLimit();
        PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
        List<ProjectDTO> projectsDTO = this.geoPlatformServiceClient.searchAccountProjects(account.getId(), psr);
        if (projectsDTO == null) {
            throw new GeoPlatformException("There are no results");
        }
        ArrayList<GPClientProject> clientProjects = new ArrayList<GPClientProject>();
        for (ProjectDTO projectDTO : projectsDTO) {
            GPClientProject clientProject = this.dtoLayerConverter.convertToGPCLientProject(projectDTO, imageURL);
            clientProjects.add(clientProject);
        }
        return new BasePagingLoadResult<GPClientProject>(clientProjects, config.getOffset(), projectsCount.intValue());
    } catch (ResourceNotFoundFault ex) {
        ex.printStackTrace();
        throw new GeoPlatformException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GeoPlatformException(ex.getMessage());
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPClientProject(org.geosdi.geoplatform.gui.client.model.projects.GPClientProject) SearchRequest(org.geosdi.geoplatform.request.SearchRequest) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) ArrayList(java.util.ArrayList) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 2 with SearchRequest

use of org.geosdi.geoplatform.request.SearchRequest in project geo-platform by geosdi.

the class GPCatalogFinderService method searchCSWServers.

@Override
public PagingLoadResult<GPCSWServerBeanModel> searchCSWServers(PagingLoadConfig config, String searchText, String organization, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    SearchRequest srq = new SearchRequest(searchText);
    int serversCount = geoPlatformCSWClient.getCSWServersCount(srq, organization);
    ArrayList<GPCSWServerBeanModel> searchServers;
    if (serversCount == 0) {
        logger.info("\n*** No catalog found ***");
        searchServers = new ArrayList<GPCSWServerBeanModel>(0);
    } else {
        int start = config.getOffset();
        int page = start == 0 ? start : start / config.getLimit();
        PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
        List<ServerCSWDTO> serverList = geoPlatformCSWClient.searchCSWServers(psr, organization);
        searchServers = new ArrayList<GPCSWServerBeanModel>(serverList.size());
        for (ServerCSWDTO serverDTO : serverList) {
            searchServers.add(this.convertServerDTO(serverDTO));
        }
    }
    return new BasePagingLoadResult<GPCSWServerBeanModel>(searchServers, config.getOffset(), serversCount);
}
Also used : PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) SearchRequest(org.geosdi.geoplatform.request.SearchRequest) ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) GPCSWServerBeanModel(org.geosdi.geoplatform.gui.model.server.GPCSWServerBeanModel) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult)

Example 3 with SearchRequest

use of org.geosdi.geoplatform.request.SearchRequest in project geo-platform by geosdi.

the class SecurityService method xmppGetDataLogin.

@Override
public XMPPLoginDetails xmppGetDataLogin(String userName, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    XMPPLoginDetails xMPPLoginDetails = null;
    if (userName != null) {
        GPUser user;
        try {
            user = geoPlatformServiceClient.getUserDetailByUsername(new SearchRequest(userName, LikePatternType.CONTENT_EQUALS));
            xMPPLoginDetails = new XMPPLoginDetails();
            xMPPLoginDetails.setUsername(user.getUsername());
            xMPPLoginDetails.setPassword(user.getPassword());
            xMPPLoginDetails.setHostXmppServer(this.hostXmppServer);
        } catch (ResourceNotFoundFault ex) {
            logger.error("SecurityService", "Unable to find user with username: " + userName + " Error: " + ex);
            throw new GeoPlatformException("Unable to find user with username: " + userName);
        }
    }
    return xMPPLoginDetails;
}
Also used : SearchRequest(org.geosdi.geoplatform.request.SearchRequest) XMPPLoginDetails(org.geosdi.geoplatform.gui.client.model.security.XMPPLoginDetails) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 4 with SearchRequest

use of org.geosdi.geoplatform.request.SearchRequest in project geo-platform by geosdi.

the class SecurityService method casLogin.

@Override
public IGPAccountDetail casLogin(HttpServletRequest httpServletRequest) throws GeoPlatformException {
    Assertion casAssertion = (AssertionImpl) httpServletRequest.getSession().getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
    IGPAccountDetail accountDetail = null;
    if (casAssertion != null && casAssertion.getPrincipal() != null && casAssertion.getPrincipal().getName() != null) {
        String casUserName = casAssertion.getPrincipal().getName();
        GPUser user;
        try {
            user = geoPlatformServiceClient.getUserDetailByUsername(new SearchRequest(casUserName, LikePatternType.CONTENT_EQUALS));
            geoPlatformServiceClient.getAccountPermission(user.getId());
            accountDetail = this.executeLoginOnGPAccount(user, geoPlatformServiceClient.getAccountPermission(user.getId()), null, httpServletRequest);
        } catch (ResourceNotFoundFault ex) {
            logger.info("SecurityService", "Unable to find user with username or email: " + casUserName + " Error: " + ex);
            accountDetail = this.createNewCASUser(casUserName, httpServletRequest);
        } catch (SOAPFaultException ex) {
            logger.error("Error on SecurityService: " + ex + " password incorrect");
            throw new GeoPlatformException("Password incorrect");
        }
    }
    return accountDetail;
}
Also used : AssertionImpl(org.jasig.cas.client.validation.AssertionImpl) IGPAccountDetail(org.geosdi.geoplatform.gui.global.security.IGPAccountDetail) SearchRequest(org.geosdi.geoplatform.request.SearchRequest) Assertion(org.jasig.cas.client.validation.Assertion) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 5 with SearchRequest

use of org.geosdi.geoplatform.request.SearchRequest 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)

Aggregations

SearchRequest (org.geosdi.geoplatform.request.SearchRequest)13 PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)8 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)5 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)5 Test (org.junit.Test)5 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)3 GPUser (org.geosdi.geoplatform.core.model.GPUser)3 UserDTO (org.geosdi.geoplatform.response.UserDTO)3 ArrayList (java.util.ArrayList)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 GPMessage (org.geosdi.geoplatform.core.model.GPMessage)2 IGPAccountDetail (org.geosdi.geoplatform.gui.global.security.IGPAccountDetail)2 UserDTOResponse (org.geosdi.geoplatform.response.UserDTOResponse)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Date (java.util.Date)1 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)1 GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)1 GPUserManageDetail (org.geosdi.geoplatform.gui.client.model.GPUserManageDetail)1 GPClientProject (org.geosdi.geoplatform.gui.client.model.projects.GPClientProject)1