use of ddf.catalog.operation.DeleteResponse in project ddf by codice.
the class CatalogFrameworkImplTest method testDeleteWithStores.
// TODO (DDF-2436) -
@Ignore
@Test
public void testDeleteWithStores() throws Exception {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<>(), true, new Date());
Map<String, CatalogStore> storeMap = new HashMap<>();
Map<String, FederatedSource> sourceMap = new HashMap<>();
MockCatalogStore store = new MockCatalogStore("catalogStoreId-1", true);
storeMap.put(store.getId(), store);
sourceMap.put(store.getId(), store);
CatalogFramework framework = createDummyCatalogFramework(provider, storeMap, sourceMap, eventAdmin);
FilterFactory filterFactory = new FilterFactoryImpl();
Filter filter = filterFactory.like(filterFactory.property(Metacard.METADATA), "*", "*", "?", "/", false);
List<Metacard> metacards = new ArrayList<>();
String id = UUID.randomUUID().toString().replaceAll("-", "");
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));
DeleteRequest deleteRequest = new DeleteRequestImpl(Collections.singletonList(id), Metacard.ID, new HashMap<>(), destinations);
DeleteResponse response = framework.delete(deleteRequest);
assertThat(response.getDeletedMetacards().size(), is(1));
QueryResponse queryResponse = framework.query(new QueryRequestImpl(new QueryImpl(filter), true));
assertThat(queryResponse.getResults().size(), is(0));
}
use of ddf.catalog.operation.DeleteResponse in project ddf by codice.
the class RestReplicatorPlugin method process.
@Override
public DeleteResponse process(DeleteResponse input) throws PluginExecutionException {
if (input != null && Requests.isLocal(input.getRequest()) && client != null) {
WebClient updateClient = WebClient.fromClient(client);
updateClient.type(MediaType.APPLICATION_JSON);
if (input.getDeletedMetacards() == null || input.getDeletedMetacards().isEmpty()) {
return input;
}
for (int i = 0; i < input.getDeletedMetacards().size(); i++) {
Metacard metacard = input.getDeletedMetacards().get(i);
if (metacard != null && metacard.getId() != null) {
updateClient.path(metacard.getId());
Response r = updateClient.delete();
LOGGER.debug("RESPONSE: [{}]", ToStringBuilder.reflectionToString(r));
}
}
}
return input;
}
use of ddf.catalog.operation.DeleteResponse in project ddf by codice.
the class RegistryIdPostIngestPluginTest method testProcessDeleteLocal.
@Test
public void testProcessDeleteLocal() throws Exception {
MetacardImpl metacard = getDefaultMetacard();
metacard.setAttribute(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true);
CreateResponse createResponse = new CreateResponseImpl(null, null, Collections.singletonList(metacard));
registryIdPostIngestPlugin.process(createResponse);
assertThat(registryIdPostIngestPlugin.getLocalRegistryIds().size(), equalTo(1));
DeleteResponse deleteResponse = new DeleteResponseImpl(null, null, Collections.singletonList(metacard));
registryIdPostIngestPlugin.process(deleteResponse);
assertThat(registryIdPostIngestPlugin.getLocalRegistryIds().size(), equalTo(0));
}
use of ddf.catalog.operation.DeleteResponse in project ddf by codice.
the class RegistryIdPostIngestPluginTest method testProcessDelete.
@Test
public void testProcessDelete() throws Exception {
CreateResponse createResponse = new CreateResponseImpl(null, null, Collections.singletonList(getDefaultMetacard()));
registryIdPostIngestPlugin.process(createResponse);
DeleteResponse deleteResponse = new DeleteResponseImpl(null, null, Collections.singletonList(getDefaultMetacard()));
registryIdPostIngestPlugin.process(deleteResponse);
assertThat(registryIdPostIngestPlugin.getRegistryIds().size(), equalTo(0));
}
use of ddf.catalog.operation.DeleteResponse in project ddf by codice.
the class RemoteDeleteOperations method performRemoteDelete.
@Nullable
public DeleteResponse performRemoteDelete(DeleteRequest deleteRequest, @Nullable DeleteResponse deleteResponse) {
if (!opsCatStoreSupport.isCatalogStoreRequest(deleteRequest)) {
return deleteResponse;
}
DeleteResponse remoteDeleteResponse = doRemoteDelete(deleteRequest);
if (deleteResponse == null) {
deleteResponse = remoteDeleteResponse;
deleteResponse = injectAttributes(deleteResponse);
} else {
deleteResponse.getProperties().putAll(remoteDeleteResponse.getProperties());
deleteResponse.getProcessingErrors().addAll(remoteDeleteResponse.getProcessingErrors());
}
return deleteResponse;
}
Aggregations