Search in sources :

Example 16 with DeleteResponse

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));
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) FilterFactory(org.opengis.filter.FilterFactory) CatalogStore(ddf.catalog.source.CatalogStore) QueryImpl(ddf.catalog.operation.impl.QueryImpl) CatalogFramework(ddf.catalog.CatalogFramework) HashSet(java.util.HashSet) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) Date(java.util.Date) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) FederatedSource(ddf.catalog.source.FederatedSource) Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) Filter(org.opengis.filter.Filter) QueryResponse(ddf.catalog.operation.QueryResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) DeleteRequest(ddf.catalog.operation.DeleteRequest) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with DeleteResponse

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;
}
Also used : DeleteResponse(ddf.catalog.operation.DeleteResponse) Response(javax.ws.rs.core.Response) CreateResponse(ddf.catalog.operation.CreateResponse) UpdateResponse(ddf.catalog.operation.UpdateResponse) Metacard(ddf.catalog.data.Metacard) WebClient(org.apache.cxf.jaxrs.client.WebClient)

Example 18 with DeleteResponse

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));
}
Also used : DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) CreateResponse(ddf.catalog.operation.CreateResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Test(org.junit.Test)

Example 19 with DeleteResponse

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));
}
Also used : DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) CreateResponse(ddf.catalog.operation.CreateResponse) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Test(org.junit.Test)

Example 20 with DeleteResponse

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;
}
Also used : DeleteResponse(ddf.catalog.operation.DeleteResponse) Nullable(com.sun.istack.Nullable)

Aggregations

DeleteResponse (ddf.catalog.operation.DeleteResponse)54 Test (org.junit.Test)37 Metacard (ddf.catalog.data.Metacard)23 DeleteRequest (ddf.catalog.operation.DeleteRequest)23 ArrayList (java.util.ArrayList)19 DeleteRequestImpl (ddf.catalog.operation.impl.DeleteRequestImpl)18 HashMap (java.util.HashMap)17 Serializable (java.io.Serializable)15 DeleteResponseImpl (ddf.catalog.operation.impl.DeleteResponseImpl)14 CreateResponse (ddf.catalog.operation.CreateResponse)13 List (java.util.List)11 QueryResponse (ddf.catalog.operation.QueryResponse)9 QueryRequest (ddf.catalog.operation.QueryRequest)8 IngestException (ddf.catalog.source.IngestException)8 Result (ddf.catalog.data.Result)7 UpdateResponse (ddf.catalog.operation.UpdateResponse)7 QueryImpl (ddf.catalog.operation.impl.QueryImpl)7 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)7 CatalogFramework (ddf.catalog.CatalogFramework)6 Update (ddf.catalog.operation.Update)6