Search in sources :

Example 16 with Capabilities

use of org.geotoolkit.sos.xml.v100.Capabilities in project geotoolkit by Geomatys.

the class WebProcessingClient method getServiceCapabilities.

/**
 * @param refresh if set to true, the cached capabilities document will be renewed.
 *
 * @return WPSCapabilitiesType : WPS server capabilities
 */
public Capabilities getServiceCapabilities(boolean refresh) throws CapabilitiesException {
    if (capabilities != null && !refresh) {
        return capabilities;
    }
    final GetCapabilitiesRequest capaReq = createGetCapabilities();
    capaReq.setTimeout(TIMEOUT_CAPS);
    try (final InputStream is = capaReq.getResponseStream()) {
        final Unmarshaller unmarshaller = WPSMarshallerPool.getInstance().acquireUnmarshaller();
        Object obj = unmarshaller.unmarshal(is);
        if (obj instanceof JAXBElement) {
            obj = ((JAXBElement) obj).getValue();
        }
        if (obj instanceof ExceptionResponse) {
            final Exception er = ((ExceptionResponse) obj).toException();
            throw new CapabilitiesException(er.getMessage(), er);
        } else if (obj instanceof Capabilities) {
            capabilities = (Capabilities) obj;
        } else {
            throw new CapabilitiesException("Unexpected jaxb mapping for capabilities: " + (obj == null ? "null" : obj.getClass()));
        }
        WPSMarshallerPool.getInstance().recycle(unmarshaller);
    } catch (Exception ex) {
        capabilities = null;
        throw new CapabilitiesException(ex.getMessage(), ex);
    }
    if (capabilities == null) {
        throw new CapabilitiesException("A problem occured while getting Service capabilities.");
    }
    return capabilities;
}
Also used : ExceptionResponse(org.geotoolkit.ows.xml.ExceptionResponse) GetCapabilities(org.geotoolkit.wps.xml.v200.GetCapabilities) Capabilities(org.geotoolkit.wps.xml.v200.Capabilities) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller) CapabilitiesException(org.geotoolkit.client.CapabilitiesException) CapabilitiesException(org.geotoolkit.client.CapabilitiesException)

Example 17 with Capabilities

use of org.geotoolkit.sos.xml.v100.Capabilities in project geotoolkit by Geomatys.

the class WPSProcessingRegistry method checkDescriptors.

/**
 * @param loadDescription force loading all descriptor
 */
private synchronized void checkDescriptors(boolean loadDescription) {
    if (descriptors != null && !loadDescription)
        return;
    if (descriptors == null)
        descriptors = new ConcurrentHashMap<>();
    final Capabilities capabilities;
    try {
        capabilities = client.getServiceCapabilities();
    } catch (CapabilitiesException ex) {
        // it should not happen since we called a getCapabilities at registry creation
        throw new RuntimeException(ex);
    }
    final Contents contents = capabilities.getContents();
    if (contents == null) {
        return;
    }
    final List<ProcessSummary> processBrief = contents.getProcessSummary();
    if (loadDescription) {
        final ExecutorService exec = Executors.newFixedThreadPool(8);
        for (final ProcessSummary processBriefType : processBrief) {
            final String processId = processBriefType.getIdentifier().getValue();
            if (descriptors.get(processId) instanceof ProcessDescriptor)
                continue;
            exec.submit(new Runnable() {

                @Override
                public void run() {
                    try {
                        final ProcessDescriptor processDesc = toProcessDescriptor(processId);
                        descriptors.put(processDesc.getIdentifier().getCode(), processDesc);
                    } catch (Throwable ex) {
                        LOGGER.log(Level.WARNING, ex.getMessage(), ex);
                    }
                }
            });
        }
        exec.shutdown();
        try {
            // TODO: better timeout management
            exec.awaitTermination(10, TimeUnit.MINUTES);
        } catch (InterruptedException ex) {
            LOGGER.log(Level.WARNING, ex.getMessage(), ex);
        }
    } else {
        for (final ProcessSummary processBriefType : processBrief) {
            descriptors.put(processBriefType.getIdentifier().getValue(), processBriefType);
        }
    }
}
Also used : ProcessSummary(org.geotoolkit.wps.xml.v200.ProcessSummary) Contents(org.geotoolkit.wps.xml.v200.Contents) Capabilities(org.geotoolkit.wps.xml.v200.Capabilities) ExecutorService(java.util.concurrent.ExecutorService) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CapabilitiesException(org.geotoolkit.client.CapabilitiesException)

Example 18 with Capabilities

use of org.geotoolkit.sos.xml.v100.Capabilities in project geotoolkit by Geomatys.

the class WebMapTileClient method components.

@Override
public synchronized Collection<WMTSResource> components() throws DataStoreException {
    List<WMTSResource> resources = this.resources;
    if (resources == null) {
        resources = new ArrayList<>();
        final Capabilities capa = getServiceCapabilities();
        if (capa == null) {
            throw new DataStoreException("Could not get Capabilities.");
        }
        resources = createOrUpdateResources(null, capa);
        this.resources = resources;
    }
    return Collections.unmodifiableList(resources);
}
Also used : DataStoreException(org.apache.sis.storage.DataStoreException) Capabilities(org.geotoolkit.wmts.xml.v100.Capabilities)

Example 19 with Capabilities

use of org.geotoolkit.sos.xml.v100.Capabilities in project geotoolkit by Geomatys.

the class WebMapTileClientTest method testUpdateSequence.

/**
 * Test update sequence updates child resources.
 */
@Test
public void testUpdateSequence() throws MalformedURLException, JAXBException, DataStoreException, FactoryException {
    Capabilities capa1 = WMTSBindingUtilities.unmarshall(WebMapTileClientTest.class.getResource("/org/geotoolkit/wmts/UpdateSequence1.xml"), WMTSVersion.v100);
    Capabilities capa2 = WMTSBindingUtilities.unmarshall(WebMapTileClientTest.class.getResource("/org/geotoolkit/wmts/UpdateSequence2.xml"), WMTSVersion.v100);
    final WebMapTileClient wmts = new WebMapTileClient(new URL("http://localhost:8080/wmts"), null, WMTSVersion.v100, capa1, true);
    final GridCoverageResource resource = (GridCoverageResource) wmts.findResource("PROFONDEUR_RGB_pyramid");
    final AtomicBoolean updated = new AtomicBoolean(false);
    resource.addListener(StoreEvent.class, new StoreListener<StoreEvent>() {

        @Override
        public void eventOccured(StoreEvent event) {
            updated.set(true);
        }
    });
    Assert.assertEquals(CommonCRS.WGS84.normalizedGeographic(), resource.getGridGeometry().getCoordinateReferenceSystem());
    Assert.assertEquals(false, updated.get());
    wmts.checkForUpdates(capa2);
    Assert.assertEquals(true, updated.get());
    Assert.assertEquals(CommonCRS.NAD83.normalizedGeographic(), resource.getGridGeometry().getCoordinateReferenceSystem());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Capabilities(org.geotoolkit.wmts.xml.v100.Capabilities) GridCoverageResource(org.apache.sis.storage.GridCoverageResource) URL(java.net.URL) StoreEvent(org.apache.sis.storage.event.StoreEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 Unmarshaller (javax.xml.bind.Unmarshaller)7 Capabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities)7 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 ByteBuf (io.netty.buffer.ByteBuf)3 URL (java.net.URL)3 JAXBElement (javax.xml.bind.JAXBElement)3 Capabilities (org.geotoolkit.csw.xml.v202.Capabilities)3 Capabilities (org.geotoolkit.wmts.xml.v100.Capabilities)3 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)2 MarshallerPool (org.apache.sis.xml.MarshallerPool)2 CapabilitiesException (org.geotoolkit.client.CapabilitiesException)2 TimePositionType (org.geotoolkit.gml.xml.v311.TimePositionType)2 DocumentType (org.geotoolkit.inspire.xml.DocumentType)2 InspireCapabilitiesType (org.geotoolkit.inspire.xml.InspireCapabilitiesType)2 LanguagesType (org.geotoolkit.inspire.xml.LanguagesType)2 MultiLingualCapabilities (org.geotoolkit.inspire.xml.MultiLingualCapabilities)2 TranslatedCapabilitiesType (org.geotoolkit.inspire.xml.TranslatedCapabilitiesType)2 OperationsMetadata (org.geotoolkit.ows.xml.v100.OperationsMetadata)2