use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class RemoteSolrCatalogProviderTest method testUnconfiguredGetContentTypes.
@Test(expected = IllegalStateException.class)
public void testUnconfiguredGetContentTypes() throws IngestException {
CatalogProvider provider = new MockedRemoteSolrCatalogProvider(null);
provider.getContentTypes();
}
use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class RemoteSolrCatalogProviderTest method testUnconfiguredUpdate.
@Test(expected = IllegalStateException.class)
public void testUnconfiguredUpdate() throws IngestException {
CatalogProvider provider = new MockedRemoteSolrCatalogProvider(null);
provider.update(mock(UpdateRequest.class));
}
use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class CatalogBundle method waitForCatalogProvider.
public CatalogProvider waitForCatalogProvider() throws InterruptedException {
LOGGER.info("Waiting for CatalogProvider to become available.");
serviceManager.printInactiveBundlesInfo();
CatalogProvider provider = null;
CatalogFramework framework = null;
long timeoutLimit = System.currentTimeMillis() + CATALOG_PROVIDER_TIMEOUT;
boolean available = false;
while (!available) {
if (provider == null) {
ServiceReference<CatalogFramework> frameworkRef = serviceManager.getServiceReference(CatalogFramework.class);
ServiceReference<CatalogProvider> providerRef = serviceManager.getServiceReference(CatalogProvider.class);
if (providerRef != null) {
provider = serviceManager.getService(providerRef);
}
if (frameworkRef != null) {
framework = serviceManager.getService(frameworkRef);
}
}
if (framework != null && provider != null) {
SourceInfoRequestLocal sourceInfoRequestEnterprise = new SourceInfoRequestLocal(true);
try {
SourceInfoResponse sources = framework.getSourceInfo(sourceInfoRequestEnterprise);
Set<SourceDescriptor> sourceInfo = sources.getSourceInfo();
for (SourceDescriptor sourceDescriptor : sourceInfo) {
if (sourceDescriptor.getSourceId().equals(provider.getId())) {
available = sourceDescriptor.isAvailable() && provider.isAvailable();
LOGGER.info("CatalogProvider.isAvailable = {}", available);
}
}
} catch (SourceUnavailableException e) {
available = false;
}
}
if (!available) {
if (System.currentTimeMillis() > timeoutLimit) {
LOGGER.info("CatalogProvider.isAvailable = false");
serviceManager.printInactiveBundles();
fail(String.format("Catalog provider timed out after %d minutes.", TimeUnit.MILLISECONDS.toMinutes(CATALOG_PROVIDER_TIMEOUT)));
}
Thread.sleep(1000);
}
}
LOGGER.info("CatalogProvider is available.");
return provider;
}
use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class MigrateCommand method getCatalogProviders.
private List<CatalogProvider> getCatalogProviders() {
ServiceTracker st = new ServiceTracker(bundleContext, CatalogProvider.class.getName(), null);
st.open();
ServiceReference<CatalogProvider>[] serviceRefs = st.getServiceReferences();
Map<ServiceReference<CatalogProvider>, CatalogProvider> map = new TreeMap<>(new ServiceComparator());
if (null != serviceRefs) {
for (ServiceReference<CatalogProvider> serviceReference : serviceRefs) {
map.put(serviceReference, (CatalogProvider) st.getService(serviceReference));
}
}
return new ArrayList<>(map.values());
}
use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class MigrateCommand method promptForProvider.
private CatalogProvider promptForProvider(String whichProvider, String id, List<CatalogProvider> providers) throws IOException {
List<String> providersIdList = providers.stream().map(p -> p.getClass().getSimpleName()).collect(Collectors.toList());
while (true) {
if (StringUtils.isBlank(id) || !providersIdList.contains(id)) {
console.println("Please enter the Source ID of the \"" + whichProvider + "\" Provider:");
} else {
break;
}
id = getInput(whichProvider + " Provider ID: ");
}
final String providerId = id;
final CatalogProvider provider = providers.stream().filter(p -> p.getClass().getSimpleName().equals(providerId)).findFirst().orElse(null);
return provider;
}
Aggregations