use of ddf.catalog.operation.UpdateResponse in project ddf by codice.
the class SolrProviderTest method testUpdatePartial.
/**
* Tests if a partial update is handled appropriately.
*
* @throws IngestException
* @throws UnsupportedQueryException
*/
@Test
public void testUpdatePartial() throws IngestException, UnsupportedQueryException {
deleteAllIn(provider);
MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
CreateResponse createResponse = create(metacard);
String id = createResponse.getCreatedMetacards().get(0).getId();
metacard.setContentTypeName("newContentType");
String[] ids = { id, "no_such_record" };
UpdateResponse response = update(ids, Arrays.asList((Metacard) metacard, metacard));
assertEquals(1, response.getUpdatedMetacards().size());
}
use of ddf.catalog.operation.UpdateResponse in project ddf by codice.
the class UpdateOperations method performLocalUpdate.
private UpdateResponse performLocalUpdate(UpdateRequest updateRequest) throws IngestException, SourceUnavailableException {
if (!Requests.isLocal(updateRequest)) {
return null;
}
UpdateResponse updateResponse = sourceOperations.getCatalog().update(updateRequest);
updateResponse = historian.version(updateResponse);
return updateResponse;
}
use of ddf.catalog.operation.UpdateResponse in project ddf by codice.
the class UpdateOperations method performRemoteUpdate.
private UpdateResponse performRemoteUpdate(UpdateRequest updateRequest, UpdateResponse updateResponse) {
if (opsCatStoreSupport.isCatalogStoreRequest(updateRequest)) {
UpdateResponse remoteUpdateResponse = doRemoteUpdate(updateRequest);
if (updateResponse == null) {
updateResponse = remoteUpdateResponse;
} else {
updateResponse.getProperties().putAll(remoteUpdateResponse.getProperties());
updateResponse.getProcessingErrors().addAll(remoteUpdateResponse.getProcessingErrors());
}
}
return updateResponse;
}
use of ddf.catalog.operation.UpdateResponse in project ddf by codice.
the class UpdateOperations method update.
//
// Delegate methods
//
public UpdateResponse update(UpdateRequest updateRequest) throws IngestException, SourceUnavailableException {
UpdateResponse updateResponse = doUpdate(updateRequest);
updateResponse = doPostIngest(updateResponse);
return updateResponse;
}
use of ddf.catalog.operation.UpdateResponse in project ddf by codice.
the class FrameworkProducer method update.
/**
* Updates metacard(s) in the catalog using the Catalog Framework.
*
* @param exchange
* The {@link org.apache.camel.Exchange} can contain a
* {@link org.apache.camel.Message} with a body of type {@link java.util.List} of
* Metacard or a single Metacard.
* @throws ddf.catalog.source.SourceUnavailableException
* @throws ddf.catalog.source.IngestException
* @throws ddf.camel.component.catalog.framework.FrameworkProducerException
*/
private void update(final Exchange exchange) throws SourceUnavailableException, IngestException, FrameworkProducerException {
UpdateResponse updateResponse = null;
// read in data from exchange
final List<Metacard> metacardsToBeUpdated = readBodyDataAsMetacards(exchange);
// process data if valid
if (!validateList(metacardsToBeUpdated, Metacard.class)) {
processCatalogResponse(updateResponse, exchange);
throw new FrameworkProducerException("Validation of Metacard list failed");
}
LOGGER.debug("Validation of Metacard list passed...");
final String[] metacardIds = new String[metacardsToBeUpdated.size()];
for (int i = 0; i < metacardsToBeUpdated.size(); i++) {
metacardIds[i] = metacardsToBeUpdated.get(i).getId();
}
final UpdateRequest updateRequest = new UpdateRequestImpl(metacardIds, metacardsToBeUpdated);
final int expectedNumberOfUpdatedMetacards = metacardsToBeUpdated.size();
if (expectedNumberOfUpdatedMetacards < 1) {
LOGGER.debug("Empty list of Metacards...nothing to process");
processCatalogResponse(updateResponse, exchange);
return;
}
LOGGER.debug("Making UPDATE call to Catalog Framework...");
updateResponse = catalogFramework.update(updateRequest);
if (updateResponse == null) {
LOGGER.debug("UpdateResponse is null from catalog framework");
processCatalogResponse(updateResponse, exchange);
return;
}
final List<Update> updatedMetacards = updateResponse.getUpdatedMetacards();
if (updatedMetacards == null) {
LOGGER.debug("UpdateResponse returned null metacards list");
processCatalogResponse(updateResponse, exchange);
return;
}
final int numberOfUpdatedMetacards = updatedMetacards.size();
if (numberOfUpdatedMetacards != expectedNumberOfUpdatedMetacards) {
LOGGER.debug("Expected {} metacards updated but only {} were successfully updated", expectedNumberOfUpdatedMetacards, numberOfUpdatedMetacards);
processCatalogResponse(updateResponse, exchange);
return;
}
LOGGER.debug("Updated {} metacards", numberOfUpdatedMetacards);
processCatalogResponse(updateResponse, exchange);
}
Aggregations