use of ddf.catalog.source.IngestException in project ddf by codice.
the class CreateOperations method doRemoteCreate.
private CreateResponse doRemoteCreate(CreateRequest createRequest) {
HashSet<ProcessingDetails> exceptions = new HashSet<>();
Map<String, Serializable> properties = new HashMap<>();
List<CatalogStore> stores = opsCatStoreSupport.getCatalogStoresForRequest(createRequest, exceptions);
for (CatalogStore store : stores) {
try {
if (!store.isAvailable()) {
exceptions.add(new ProcessingDetailsImpl(store.getId(), null, "CatalogStore is not available"));
} else {
CreateResponse response = store.create(createRequest);
properties.put(store.getId(), new ArrayList<>(response.getCreatedMetacards()));
}
} catch (IngestException e) {
INGEST_LOGGER.error("Error creating metacards for CatalogStore {}", store.getId(), e);
exceptions.add(new ProcessingDetailsImpl(store.getId(), e));
}
}
return new CreateResponseImpl(createRequest, properties, createRequest.getMetacards(), exceptions);
}
use of ddf.catalog.source.IngestException in project ddf by codice.
the class CatalogFrameworkImplTest method testProviderUnavailableCreate.
// End testing CatalogFramework
// Test negative use-cases (expected errors)
/**
* Tests that the framework properly throws a catalog exception when the local provider is not
* available for create.
*
* @throws SourceUnavailableException
*/
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableCreate() throws SourceUnavailableException {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), false, null);
CatalogFramework framework = createDummyCatalogFramework(provider, storageProvider, eventAdmin, false);
List<Metacard> metacards = new ArrayList<Metacard>();
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
metacards.add(newCard);
CreateRequest create = new CreateRequestImpl(metacards);
// expected to throw exception due to catalog provider being unavailable
try {
framework.create(create);
} catch (IngestException e) {
fail();
}
}
use of ddf.catalog.source.IngestException in project ddf by codice.
the class MetacardApplication method patchMetacards.
protected UpdateResponse patchMetacards(List<MetacardChanges> metacardChanges) throws SourceUnavailableException, IngestException, FederationException, UnsupportedQueryException {
Set<String> changedIds = metacardChanges.stream().flatMap(mc -> mc.getIds().stream()).collect(Collectors.toSet());
Map<String, Result> results = util.getMetacards(changedIds, "*");
for (MetacardChanges changeset : metacardChanges) {
for (AttributeChange attributeChange : changeset.getAttributes()) {
for (String id : changeset.getIds()) {
List<String> values = attributeChange.getValues();
Metacard result = results.get(id).getMetacard();
Function<Serializable, Serializable> mapFunc = Function.identity();
if (isChangeTypeDate(attributeChange, result)) {
mapFunc = mapFunc.andThen(util::parseDate);
}
result.setAttribute(new AttributeImpl(attributeChange.getAttribute(), values.stream().filter(Objects::nonNull).map(mapFunc).collect(Collectors.toList())));
}
}
}
List<Metacard> changedMetacards = results.values().stream().map(Result::getMetacard).collect(Collectors.toList());
return catalogFramework.update(new UpdateRequestImpl(changedMetacards.stream().map(Metacard::getId).collect(Collectors.toList()).toArray(new String[0]), changedMetacards));
}
use of ddf.catalog.source.IngestException in project ddf by codice.
the class ExceptionsTest method testIngestException.
@Test
public void testIngestException() {
IngestException ie = new IngestException();
assertNotNull(ie);
ie = new IngestException(msg);
assertEquals(ie.getMessage(), msg);
ie = new IngestException(testCause);
assertEquals(ie.getCause(), testCause);
ie = new IngestException(msg, testCause);
assertEquals(ie.getMessage(), msg);
assertEquals(ie.getCause(), testCause);
}
use of ddf.catalog.source.IngestException in project ddf by codice.
the class SolrCatalogProvider method deleteListOfMetacards.
private void deleteListOfMetacards(List<Metacard> deletedMetacards, List<? extends Serializable> identifiers, String attributeName) throws IngestException {
String fieldName = attributeName + SchemaFields.TEXT_SUFFIX;
SolrDocumentList docs = getSolrDocumentList(identifiers, fieldName);
createListOfDeletedMetacards(deletedMetacards, docs);
try {
// the assumption is if something was deleted, it should be gone
// right away, such as expired data, etc.
// so we force the commit
client.deleteByIds(fieldName, identifiers, true);
} catch (SolrServerException | IOException e) {
LOGGER.info("Failed to delete metacards by ID(s).", e);
throw new IngestException(COULD_NOT_COMPLETE_DELETE_REQUEST_MESSAGE);
}
}
Aggregations