Search in sources :

Example 66 with UpdateResponse

use of ddf.catalog.operation.UpdateResponse in project ddf by codice.

the class CatalogBackupPluginTest method getUpdateResponse.

private UpdateResponse getUpdateResponse(List<String> oldMetacardIds) {
    List<Update> updatedMetacards = new ArrayList<>(oldMetacardIds.size());
    int i = 0;
    for (String oldMetacardId : oldMetacardIds) {
        Metacard oldMetacard = getMetacard(oldMetacardId, BASE_OLD_TITLE + i);
        Metacard newMetacard = getMetacard(oldMetacardId, BASE_NEW_TITLE + i);
        // Create UpdateResponse
        Update mockUpdate = mock(Update.class);
        when(mockUpdate.getOldMetacard()).thenReturn(oldMetacard);
        when(mockUpdate.getNewMetacard()).thenReturn(newMetacard);
        updatedMetacards.add(mockUpdate);
        i++;
    }
    UpdateRequest request = mock(UpdateRequest.class);
    UpdateResponse mockUpdateResponse = mock(UpdateResponse.class);
    when(mockUpdateResponse.getUpdatedMetacards()).thenReturn(updatedMetacards);
    when(mockUpdateResponse.getRequest()).thenReturn(request);
    return mockUpdateResponse;
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse) Metacard(ddf.catalog.data.Metacard) UpdateRequest(ddf.catalog.operation.UpdateRequest) ArrayList(java.util.ArrayList) Update(ddf.catalog.operation.Update)

Example 67 with UpdateResponse

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;
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse)

Example 68 with 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;
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse)

Example 69 with 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;
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse)

Example 70 with UpdateResponse

use of ddf.catalog.operation.UpdateResponse in project ddf by codice.

the class CatalogMetricsTest method catalogUpdateExceptionMetric.

@Test
public void catalogUpdateExceptionMetric() throws Exception {
    Iterable<Tag> updateExceptionTags = Tags.of("type", IngestException.class.getName(), "source", "source3");
    UpdateRequest request = mock(UpdateRequest.class);
    UpdateResponse response = mock(UpdateResponse.class);
    mockCatalogResponseExceptions(request, response, new ProcessingDetailsImpl("source3", new IngestException()));
    catalogMetrics.process(response);
    assertThat(meterRegistry.counter("ddf.catalog.update.exceptions", updateExceptionTags).count(), is(1.0));
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse) UpdateRequest(ddf.catalog.operation.UpdateRequest) IngestException(ddf.catalog.source.IngestException) Tag(io.micrometer.core.instrument.Tag) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Test(org.junit.Test)

Aggregations

UpdateResponse (ddf.catalog.operation.UpdateResponse)79 Test (org.junit.Test)56 Metacard (ddf.catalog.data.Metacard)47 Update (ddf.catalog.operation.Update)32 UpdateRequest (ddf.catalog.operation.UpdateRequest)31 ArrayList (java.util.ArrayList)31 Serializable (java.io.Serializable)27 HashMap (java.util.HashMap)26 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)20 CreateResponse (ddf.catalog.operation.CreateResponse)19 List (java.util.List)18 UpdateStorageRequest (ddf.catalog.content.operation.UpdateStorageRequest)15 Result (ddf.catalog.data.Result)14 Map (java.util.Map)14 UpdateResponseImpl (ddf.catalog.operation.impl.UpdateResponseImpl)13 IngestException (ddf.catalog.source.IngestException)13 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)12 DeletedMetacard (ddf.catalog.core.versioning.DeletedMetacard)11 DeleteResponse (ddf.catalog.operation.DeleteResponse)11 QueryImpl (ddf.catalog.operation.impl.QueryImpl)11