use of ddf.catalog.source.FederatedSource in project ddf by codice.
the class CatalogBundle method isFederatedSourceReady.
private boolean isFederatedSourceReady(String id) throws InvalidSyntaxException {
CatalogFramework framework = getService(CatalogFramework.class);
FederatedSource source = serviceManager.getServiceReferences(FederatedSource.class, null).stream().map(serviceManager::getService).filter(src -> id.equals(src.getId())).findFirst().orElse(null);
if (source != null && framework != null) {
SourceInfoRequestEnterprise request = new SourceInfoRequestEnterprise(true);
try {
SourceInfoResponse sources = framework.getSourceInfo(request);
return sources.getSourceInfo().stream().filter(descriptor -> descriptor.getSourceId().equals(source.getId())).map(descriptor -> descriptor.isAvailable() && source.isAvailable()).findFirst().orElse(false);
} catch (SourceUnavailableException ignore) {
}
}
return false;
}
Aggregations