use of org.geotoolkit.wps.xml.v200.ProcessSummary in project geotoolkit by Geomatys.
the class WPSProcessingRegistry method getDescriptor.
@Override
public ProcessDescriptor getDescriptor(final String name) throws NoSuchIdentifierException {
checkDescriptors(false);
Object desc = descriptors.get(name);
// if the process has been added after the registry start.
if (desc == null && dynamicLoading) {
try {
desc = checkDescriptor(name);
} catch (Exception ex) {
LOGGER.log(Level.WARNING, ex.getMessage());
throw new NoSuchIdentifierException("No process descriptor for name :" + name, name);
}
}
if (desc instanceof ProcessDescriptor) {
return (ProcessDescriptor) desc;
}
final ProcessDescriptor pd;
if (desc == null) {
throw new NoSuchIdentifierException("No process descriptor for name :" + name, name);
} else if (desc instanceof ProcessOffering) {
try {
pd = WPS2ProcessDescriptor.create(this, (ProcessOffering) desc);
} catch (IOException ex) {
throw new UncheckedIOException(ex);
} catch (JAXBException | UnsupportedParameterException ex) {
throw new RuntimeException(ex);
}
} else if (desc instanceof ProcessSummary) {
try {
pd = toProcessDescriptor(((ProcessSummary) desc).getIdentifier().getValue());
} catch (UnsupportedParameterException ex) {
throw new RuntimeException(ex.getMessage(), ex);
} catch (Throwable ex) {
throw new RuntimeException(ex.getMessage(), ex);
}
} else
throw new UnsupportedOperationException("Cannot work with " + desc.getClass());
descriptors.put(pd.getIdentifier().getCode(), pd);
return pd;
}
use of org.geotoolkit.wps.xml.v200.ProcessSummary 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);
}
}
}
Aggregations