use of ddf.catalog.source.FederatedSource in project ddf by codice.
the class ResourceOperations method getOptionsFromFederatedSource.
/**
* Get the supported options from the {@link ResourceReader} that matches the scheme in the
* specified {@link Metacard}'s URI. Only look in the specified source for the {@link Metacard}.
*
* @param metacard the {@link Metacard} to get the supported options for
* @param sourceId the ID of the federated source to look for the {@link Metacard}
* @return the {@link Set} of supported options for the metacard
* @throws ResourceNotFoundException if the {@link ddf.catalog.source.Source} cannot be found for the source ID
*/
@Deprecated
private Set<String> getOptionsFromFederatedSource(Metacard metacard, String sourceId) throws ResourceNotFoundException {
LOGGER.trace("ENTERING: getOptionsFromFederatedSource");
FederatedSource source = frameworkProperties.getFederatedSources().get(sourceId);
if (source != null) {
LOGGER.trace("EXITING: getOptionsFromFederatedSource");
return source.getOptions(metacard);
} else {
String message = "Unable to find source corresponding to given site name: " + sourceId;
LOGGER.trace("EXITING: getOptionsFromFederatedSource");
throw new ResourceNotFoundException(message);
}
}
use of ddf.catalog.source.FederatedSource in project ddf by codice.
the class TestFanout method startCswSource.
private void startCswSource() throws Exception {
getServiceManager().waitForHttpEndpoint(CSW_PATH + "?_wadl");
getServiceManager().createManagedService(CSW_FEDERATED_SOURCE_FACTORY_PID, getCswSourceProperties(CSW_SOURCE_ID, CSW_PATH.getUrl(), getServiceManager()));
long timeout = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(10);
boolean available = false;
FederatedSource source = null;
while (!available) {
if (source == null) {
source = getServiceManager().getServiceReferences(FederatedSource.class, null).stream().map(getServiceManager()::getService).filter(src -> CSW_SOURCE_ID.equals(src.getId())).findFirst().orElse(null);
} else {
available = source.isAvailable();
}
if (System.currentTimeMillis() > timeout) {
fail("CSW source failed to initialize in time.");
}
Thread.sleep(1000);
}
}
use of ddf.catalog.source.FederatedSource in project ddf by codice.
the class CatalogFrameworkImplTest method testUpdateWithStores.
// TODO (DDF-2436) -
@Ignore
@Test
public void testUpdateWithStores() throws Exception {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<>(), true, new Date());
List<CatalogStore> storeList = new ArrayList<>();
List<FederatedSource> sourceList = new ArrayList<>();
MockCatalogStore store = new MockCatalogStore("catalogStoreId-1", true);
storeList.add(store);
sourceList.add(store);
CatalogFramework framework = createDummyCatalogFramework(provider, storeList, sourceList, eventAdmin);
FilterFactory filterFactory = new FilterFactoryImpl();
Filter filter = filterFactory.like(filterFactory.property(Metacard.METADATA), "*", "*", "?", "/", false);
List<Metacard> metacards = new ArrayList<>();
String id = UUID.randomUUID().toString();
MetacardImpl newCard = new MetacardImpl();
newCard.setId(id);
newCard.setAttribute("myKey", "myValue1");
metacards.add(newCard);
Map<String, Serializable> reqProps = new HashMap<>();
HashSet<String> destinations = new HashSet<>();
destinations.add("mockMemoryProvider");
destinations.add("catalogStoreId-1");
framework.create(new CreateRequestImpl(metacards, reqProps, destinations));
MetacardImpl updateCard = new MetacardImpl();
updateCard.setId(id);
updateCard.setAttribute("myKey", "myValue2");
List<Entry<Serializable, Metacard>> updates = new ArrayList<>();
updates.add(new SimpleEntry<>(id, updateCard));
destinations.remove("mockMemoryProvider");
framework.update(new UpdateRequestImpl(updates, Metacard.ID, new HashMap<>(), destinations));
assertThat(provider.hasReceivedUpdateByIdentifier(), is(false));
assertThat(store.hasReceivedUpdateByIdentifier(), is(true));
QueryResponse storeResponse = framework.query(new QueryRequestImpl(new QueryImpl(filter), destinations));
assertThat(storeResponse.getResults().size(), is(1));
assertThat(storeResponse.getResults().get(0).getMetacard().getAttribute("myKey").getValue(), equalTo("myValue2"));
destinations.clear();
QueryResponse providerResponse = framework.query(new QueryRequestImpl(new QueryImpl(filter), destinations));
assertThat(providerResponse.getResults().size(), is(1));
assertThat(providerResponse.getResults().get(0).getMetacard().getAttribute("myKey").getValue(), equalTo("myValue1"));
}
use of ddf.catalog.source.FederatedSource in project ddf by codice.
the class CatalogFrameworkImplTest method createDefaultFederatedSourceList.
private List<FederatedSource> createDefaultFederatedSourceList(boolean isAvailable) {
FederatedSource siteA = new MockSource("A", "Site A", "v1.0", "DDF", null, isAvailable, new Date());
FederatedSource siteB = new MockSource("B", "Site B", "v1.0", "DDF", null, isAvailable, new Date());
FederatedSource siteC = new MockSource("C", "Site C", "v1.0", "DDF", null, isAvailable, new Date());
ArrayList<FederatedSource> federatedSources = new ArrayList<FederatedSource>();
federatedSources.add(siteC);
federatedSources.add(siteB);
federatedSources.add(siteA);
return federatedSources;
}
use of ddf.catalog.source.FederatedSource in project ddf by codice.
the class CatalogFrameworkImplTest method createDummyCatalogFramework.
private CatalogFramework createDummyCatalogFramework(CatalogProvider provider, List<CatalogStore> stores, List<FederatedSource> sources, MockEventProcessor eventAdmin) {
FederationStrategy federationStrategy = new FederationStrategy() {
@Override
public QueryResponse federate(List<Source> sources, QueryRequest query) throws FederationException {
List<Result> results = new ArrayList<>();
for (Source source : sources) {
try {
SourceResponse response = source.query(query);
results.addAll(response.getResults());
} catch (UnsupportedQueryException e) {
}
}
return new QueryResponseImpl(query, results, results.size());
}
};
ArrayList<PostIngestPlugin> postIngestPlugins = new ArrayList<>();
postIngestPlugins.add(eventAdmin);
FrameworkProperties frameworkProperties = new FrameworkProperties();
frameworkProperties.setCatalogProviders(Collections.singletonList(provider));
frameworkProperties.setStorageProviders(Collections.singletonList(storageProvider));
frameworkProperties.setCatalogStores(stores);
frameworkProperties.setPreIngest(new ArrayList<>());
frameworkProperties.setPostIngest(postIngestPlugins);
frameworkProperties.setPreQuery(new ArrayList<>());
frameworkProperties.setPostQuery(new ArrayList<>());
frameworkProperties.setPolicyPlugins(new ArrayList<>());
frameworkProperties.setAccessPlugins(new ArrayList<>());
frameworkProperties.setFederatedSources(sources);
frameworkProperties.setConnectedSources(new ArrayList<>());
frameworkProperties.setFederationStrategy(federationStrategy);
frameworkProperties.setQueryResponsePostProcessor(new QueryResponsePostProcessor(null, null));
frameworkProperties.setFilterBuilder(new GeotoolsFilterBuilder());
frameworkProperties.setDefaultAttributeValueRegistry(defaultAttributeValueRegistry);
return createFramework(frameworkProperties);
}
Aggregations