Search in sources :

Example 1 with GPCatalogConnectorStore

use of org.geosdi.geoplatform.connector.GPCatalogConnectorStore in project geo-platform by geosdi.

the class CSWGetRecordsEsriTest method testFullRecordEsri.

@Ignore(value = "Serve id Down")
@Test(expected = Exception.class)
public void testFullRecordEsri() throws Exception {
    URL url = new URL("http://www.geoportale.isprambiente.it/geoportale" + "/csw/discovery");
    GPCatalogConnectorStore serverConnector = GPCSWConnectorBuilder.newConnector().withServerUrl(url).build();
    CatalogFinderBean finderBean = new CatalogFinderBean();
    finderBean.setTextInfo(new TextInfo() {

        private static final long serialVersionUID = 1L;

        {
            super.setText("scuole");
            super.setSearchTitle(Boolean.TRUE);
            super.setSearchSubjects(Boolean.FALSE);
            super.setSearchAbstract(Boolean.FALSE);
        }
    });
    CatalogGetRecordsRequest<GetRecordsResponseType> request = serverConnector.createGetRecordsRequest();
    request.setTypeName(TypeName.RECORD_V202);
    request.setOutputSchema(OutputSchema.CSW_V202);
    request.setElementSetName(ElementSetType.FULL.value());
    request.setResultType(ResultType.RESULTS.value());
    request.setConstraintLanguage(ConstraintLanguage.FILTER);
    request.setConstraintLanguageVersion(ConstraintLanguageVersion.V110);
    request.setCatalogFinder(finderBean);
    request.setStartPosition(BigInteger.ONE);
    request.setMaxRecords(BigInteger.valueOf(25));
    logger.debug("\n\n#####################RESPONSE AS STRING : {}\n\n", request.getResponseAsString());
    GetRecordsResponseType response = request.getResponse();
    SearchResultsType result = response.getSearchResults();
    List<JAXBElement<? extends AbstractRecordType>> records = result.getAbstractRecord();
    logger.debug("\n*** Record list size: {} ***", records.size());
    processFirstResult((RecordType) records.get(1).getValue());
}
Also used : GPCatalogConnectorStore(org.geosdi.geoplatform.connector.GPCatalogConnectorStore) CatalogFinderBean(org.geosdi.geoplatform.gui.responce.CatalogFinderBean) TextInfo(org.geosdi.geoplatform.gui.responce.TextInfo) JAXBElement(javax.xml.bind.JAXBElement) URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with GPCatalogConnectorStore

use of org.geosdi.geoplatform.connector.GPCatalogConnectorStore in project geo-platform by geosdi.

the class CSWServiceDelegate method createGetRecordsRequest.

private CatalogGetRecordsRequest<GetRecordsResponseType> createGetRecordsRequest(String serverUrl) throws Exception {
    GPCatalogConnectorStore serverConnector = null;
    try {
        URL url = new URL(serverUrl);
        GPCSWConnectorBuilder builder = GPCSWConnectorBuilder.newConnector().withServerUrl(url).withProxyConfiguration(cswProxyConfiguration);
        if (serverUrl.contains("snipc.protezionecivile.it")) {
            GPSecurityConnector securityConnector = new BasicPreemptiveSecurityConnector(snipcProvider.getSnipcUsername(), snipcProvider.getSnipcPassword());
            builder.withClientSecurity(securityConnector);
        }
        serverConnector = builder.build();
    } catch (MalformedURLException ex) {
        logger.error("### MalformedURLException: {}", ex.getMessage());
        throw new IllegalParameterFault("Malformed URL");
    }
    CatalogGetRecordsRequest<GetRecordsResponseType> request = serverConnector.createGetRecordsRequest();
    return request;
}
Also used : GPCatalogConnectorStore(org.geosdi.geoplatform.connector.GPCatalogConnectorStore) MalformedURLException(java.net.MalformedURLException) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPSecurityConnector(org.geosdi.geoplatform.connector.server.security.GPSecurityConnector) GPCSWConnectorBuilder(org.geosdi.geoplatform.connector.GPCSWConnectorBuilder) BasicPreemptiveSecurityConnector(org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector) URL(java.net.URL)

Example 3 with GPCatalogConnectorStore

use of org.geosdi.geoplatform.connector.GPCatalogConnectorStore in project geo-platform by geosdi.

the class GPCSWConnectorFactory method create.

/**
 * @param key
 * @return {@link GPCatalogConnectorStore}
 * @throws Exception
 */
@Override
public GPCatalogConnectorStore create(GPPoolConnectorKey key) throws Exception {
    checkNotNull(key, "The GPPoolConnectorKey must not be null");
    GPCatalogVersion v = GPCatalogVersion.fromString(key.getVersion());
    GPCatalogConnectorStore cswConnector = key.getProxyConfiguration() != null ? new GPCatalogConnectorStore(key.getServerUrl(), key.getPooledConnectorConfig(), key.getSecurityConnector(), key.getProxyConfiguration(), v) : new GPCatalogConnectorStore(key.getServerUrl(), key.getPooledConnectorConfig(), key.getSecurityConnector(), v);
    return cswConnector;
}
Also used : GPCatalogConnectorStore(org.geosdi.geoplatform.connector.GPCatalogConnectorStore) GPCatalogVersion(org.geosdi.geoplatform.connector.GPCatalogVersion)

Example 4 with GPCatalogConnectorStore

use of org.geosdi.geoplatform.connector.GPCatalogConnectorStore in project geo-platform by geosdi.

the class CSWGetRecordsEsriTest method testFullRecordGeoSDI.

@Test
public void testFullRecordGeoSDI() throws Exception {
    URL url = new URL("http://catalog.geosdi.org:80/geonetwork/srv/eng/csw");
    GPCatalogConnectorStore serverConnector = GPCSWConnectorBuilder.newConnector().withServerUrl(url).build();
    CatalogGetRecordsRequest<GetRecordsResponseType> request = serverConnector.createGetRecordsRequest();
    request.setTypeName(TypeName.METADATA);
    request.setOutputSchema(OutputSchema.CSW_V202);
    request.setElementSetName(ElementSetType.FULL.toString());
    request.setResultType(ResultType.RESULTS.toString());
    request.setStartPosition(BigInteger.ONE);
    request.setMaxRecords(BigInteger.valueOf(25));
    logger.debug("\n\n#####################RESPONSE AS STRING : {}\n\n", request.getResponseAsString());
    GetRecordsResponseType response = request.getResponse();
    SearchResultsType result = response.getSearchResults();
    List<JAXBElement<? extends AbstractRecordType>> metadata = result.getAbstractRecord();
    Assert.assertEquals("The Result not contains 25 elements", 25, metadata.size());
    processFirstResult((RecordType) metadata.get(0).getValue());
}
Also used : GPCatalogConnectorStore(org.geosdi.geoplatform.connector.GPCatalogConnectorStore) JAXBElement(javax.xml.bind.JAXBElement) URL(java.net.URL) Test(org.junit.Test)

Example 5 with GPCatalogConnectorStore

use of org.geosdi.geoplatform.connector.GPCatalogConnectorStore in project geo-platform by geosdi.

the class CSWServiceDelegate method getRecordById.

@Override
public String getRecordById(Long serverID, String identifier) throws Exception {
    logger.trace("\n*** GetRecordById ***\n");
    GeoPlatformServer server = this.getCSWServerByID(serverID);
    GPCatalogConnectorStore serverConnector = this.createServerConnector(server.getServerUrl());
    OutputSchema outputSchema = this.gpCSWOutputSchemaFinder.retrieveBestOutputSchemaForRequest(serverConnector, GET_RECORD_BY_ID.toString());
    CatalogGetRecordByIdRequest<GetRecordByIdResponseType> request = serverConnector.createGetRecordByIdRequest();
    request.setId(identifier);
    request.setElementSetType(ElementSetType.FULL.value());
    request.setOutputSchema(outputSchema);
    String response = this.createGetRecordByIdResponseAsString(request);
    String responseXSL = this.insertStylesheet(response);
    return responseXSL;
}
Also used : GPCatalogConnectorStore(org.geosdi.geoplatform.connector.GPCatalogConnectorStore) OutputSchema(org.geosdi.geoplatform.xml.csw.OutputSchema) GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer)

Aggregations

GPCatalogConnectorStore (org.geosdi.geoplatform.connector.GPCatalogConnectorStore)7 URL (java.net.URL)4 MalformedURLException (java.net.MalformedURLException)2 JAXBElement (javax.xml.bind.JAXBElement)2 GPCSWConnectorBuilder (org.geosdi.geoplatform.connector.GPCSWConnectorBuilder)2 BasicPreemptiveSecurityConnector (org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector)2 GPSecurityConnector (org.geosdi.geoplatform.connector.server.security.GPSecurityConnector)2 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)2 Test (org.junit.Test)2 GPCatalogVersion (org.geosdi.geoplatform.connector.GPCatalogVersion)1 GPPoolConnectorKey (org.geosdi.geoplatform.connector.api.pool.GPPoolConnectorKey)1 GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)1 CatalogFinderBean (org.geosdi.geoplatform.gui.responce.CatalogFinderBean)1 TextInfo (org.geosdi.geoplatform.gui.responce.TextInfo)1 OutputSchema (org.geosdi.geoplatform.xml.csw.OutputSchema)1 Ignore (org.junit.Ignore)1