Search in sources :

Example 1 with ServerCSWDTO

use of org.geosdi.geoplatform.responce.ServerCSWDTO 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 2 with ServerCSWDTO

use of org.geosdi.geoplatform.responce.ServerCSWDTO in project geo-platform by geosdi.

the class CSWServiceDelegate method saveServerCSW.

/**
 * @see {@link GeoPlatformCSWService#saveServerCSW(String, String, String)},
 * java.lang.String)
 */
@Override
public ServerCSWDTO saveServerCSW(String alias, String serverUrl, String organization) throws IllegalParameterFault {
    serverUrl = this.deleteQueryStringFromURL(serverUrl);
    GeoPlatformServer server = serverDao.findByServerUrl(serverUrl);
    if (server != null) {
        // If there is already a server with the specified URLs
        return new ServerCSWDTO(server);
    }
    GPOrganization org = organizationDao.findByName(organization);
    if (org == null) {
        throw new IllegalParameterFault("CSW Server to save have an organization that does not exist");
    }
    try {
        CatalogCapabilities capabilities = catalogCapabilitiesBean.bindUrl(serverUrl);
        server = new GeoPlatformServer();
        server.setServerType(GPCapabilityType.CSW);
        server.setServerUrl(serverUrl);
        server.setAliasName(alias);
        server.setOrganization(org);
        server.setTitle(capabilities.getServiceIdentification().getTitle());
        server.setAbstractServer(capabilities.getServiceIdentification().getAbstractText());
        server.setName(capabilities.getServiceProvider().getProviderName());
        // TODO assert
        CSWEntityCorrectness.checkCSWServer(server);
        serverDao.persist(server);
    } catch (Exception ex) {
        logger.error("### MalformedURLException: {}", ex.getMessage());
        throw new IllegalParameterFault("Exception : " + ex.getMessage());
    }
    return new ServerCSWDTO(server);
}
Also used : CatalogCapabilities(org.geosdi.geoplatform.connector.api.capabilities.model.csw.CatalogCapabilities) GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 3 with ServerCSWDTO

use of org.geosdi.geoplatform.responce.ServerCSWDTO in project geo-platform by geosdi.

the class CSWCatalogServerTest method testSearchCSWServers.

@Test
public void testSearchCSWServers() {
    // wrt title
    PaginatedSearchRequest request = new PaginatedSearchRequest("test", 10, 0);
    List<ServerCSWDTO> search = cswService.searchCSWServers(request, super.organizationNameTest);
    Assert.assertNotNull(search);
    Assert.assertEquals(1, search.size());
}
Also used : ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) Test(org.junit.Test)

Example 4 with ServerCSWDTO

use of org.geosdi.geoplatform.responce.ServerCSWDTO in project geo-platform by geosdi.

the class CSWCatalogServerTest method testSearchCSWServersMore.

@Test
public void testSearchCSWServersMore() throws Exception {
    // Insert 27 servers (only 25 for matching wrt alias)
    Long[] serverIDs = new Long[27];
    for (int i = 1; i <= 27; i++) {
        GeoPlatformServer server = super.createCSWServer("Mock title " + i, "http://url.mock-" + i, organizationTest);
        if (i >= 3) {
            server.setAliasName("Alias test " + i);
        }
        serverIDs[i - 1] = cswService.insertServerCSW(server);
        Assert.assertNotNull(serverIDs[i - 1]);
    }
    // First page
    // wrt title and alias
    PaginatedSearchRequest request = new PaginatedSearchRequest("test", 10, 0);
    List<ServerCSWDTO> search = cswService.searchCSWServers(request, super.organizationNameTest);
    Assert.assertNotNull(search);
    Assert.assertEquals(10, search.size());
    // Second page
    // wrt title and alias
    request = new PaginatedSearchRequest("test", 10, 1);
    search = cswService.searchCSWServers(request, super.organizationNameTest);
    Assert.assertNotNull(search);
    Assert.assertEquals(10, search.size());
    // Third page
    // wrt title and alias
    request = new PaginatedSearchRequest("test", 10, 2);
    search = cswService.searchCSWServers(request, super.organizationNameTest);
    Assert.assertNotNull(search);
    Assert.assertEquals(6, search.size());
    // Delete the servers
    for (Long serverID : serverIDs) {
        boolean deleted = cswService.deleteServerCSW(serverID);
        Assert.assertTrue(deleted);
    }
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) Test(org.junit.Test)

Example 5 with ServerCSWDTO

use of org.geosdi.geoplatform.responce.ServerCSWDTO in project geo-platform by geosdi.

the class CSWCatalogServerTest method testSecureSaveServerSNIPC.

@Ignore("Require to add the SNIPC certificate into default keystore")
@Test
public void testSecureSaveServerSNIPC() throws Exception {
    // Save the server
    String serverURL = super.snipcProvider.getSnipcUrl();
    ServerCSWDTO serverDTO = cswService.saveServerCSW("SNIPC", serverURL, organizationNameTest);
    Assert.assertNotNull(serverDTO);
    // Retrieve the server
    ServerCSWDTO retrievedServerDTO = cswService.getShortServerCSW(serverURL);
    this.compareServer(serverDTO, retrievedServerDTO);
    // Delete the server
    boolean deleted = cswService.deleteServerCSW(serverDTO.getId());
    Assert.assertTrue(deleted);
}
Also used : ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ServerCSWDTO (org.geosdi.geoplatform.responce.ServerCSWDTO)11 Test (org.junit.Test)7 PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)4 GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)3 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)2 GPCSWServerBeanModel (org.geosdi.geoplatform.gui.model.server.GPCSWServerBeanModel)2 Ignore (org.junit.Ignore)2 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 CatalogCapabilities (org.geosdi.geoplatform.connector.api.capabilities.model.csw.CatalogCapabilities)1 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)1 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)1 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)1 SearchRequest (org.geosdi.geoplatform.request.SearchRequest)1