use of org.geotoolkit.sml.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;
}
use of org.geotoolkit.sml.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);
}
}
}
use of org.geotoolkit.sml.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);
}
use of org.geotoolkit.sml.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());
}
Aggregations