Search in sources :

Example 16 with StorageException

use of ddf.catalog.content.StorageException in project ddf by codice.

the class DeleteOperations method doDelete.

//
// Private helper methods
//
public DeleteResponse doDelete(DeleteRequest deleteRequest, List<String> fanoutTagBlacklist) throws IngestException, SourceUnavailableException {
    DeleteStorageRequest deleteStorageRequest = null;
    DeleteResponse deleteResponse = null;
    deleteRequest = queryOperations.setFlagsOnRequest(deleteRequest);
    deleteRequest = validateDeleteRequest(deleteRequest);
    deleteRequest = validateLocalSource(deleteRequest);
    try {
        deleteRequest = populateMetacards(deleteRequest, fanoutTagBlacklist);
        deleteRequest = preProcessPreAuthorizationPlugins(deleteRequest);
        deleteStorageRequest = new DeleteStorageRequestImpl(getDeleteMetacards(deleteRequest), deleteRequest.getProperties());
        deleteRequest = processPreDeletePolicyPlugins(deleteRequest);
        deleteRequest = processPreDeleteAccessPlugins(deleteRequest);
        deleteRequest = processPreIngestPlugins(deleteRequest);
        deleteRequest = validateDeleteRequest(deleteRequest);
        // Call the Provider delete method
        LOGGER.debug("Calling catalog.delete() with {} entries.", deleteRequest.getAttributeValues().size());
        deleteResponse = performLocalDelete(deleteRequest, deleteStorageRequest);
        deleteResponse = remoteDeleteOperations.performRemoteDelete(deleteRequest, deleteResponse);
        deleteResponse = postProcessPreAuthorizationPlugins(deleteResponse);
        deleteRequest = populateDeleteRequestPolicyMap(deleteRequest, deleteResponse);
        deleteResponse = processPostDeleteAccessPlugins(deleteResponse);
        // Post results to be available for pubsub
        deleteResponse = validateFixDeleteResponse(deleteResponse, deleteRequest);
    } catch (StopProcessingException see) {
        LOGGER.debug(PRE_INGEST_ERROR + see.getMessage(), see);
        throw new IngestException(PRE_INGEST_ERROR + see.getMessage());
    } catch (RuntimeException re) {
        LOGGER.info("Exception during runtime while performing delete", re);
        throw new InternalIngestException("Exception during runtime while performing delete");
    } finally {
        if (deleteStorageRequest != null) {
            try {
                sourceOperations.getStorage().commit(deleteStorageRequest);
            } catch (StorageException e) {
                LOGGER.info("Unable to remove stored content items.", e);
            }
        }
    }
    deleteResponse = doPostIngest(deleteResponse);
    return deleteResponse;
}
Also used : DeleteStorageRequest(ddf.catalog.content.operation.DeleteStorageRequest) DeleteStorageRequestImpl(ddf.catalog.content.operation.impl.DeleteStorageRequestImpl) DeleteResponse(ddf.catalog.operation.DeleteResponse) InternalIngestException(ddf.catalog.source.InternalIngestException) InternalIngestException(ddf.catalog.source.InternalIngestException) IngestException(ddf.catalog.source.IngestException) StopProcessingException(ddf.catalog.plugin.StopProcessingException) StorageException(ddf.catalog.content.StorageException)

Example 17 with StorageException

use of ddf.catalog.content.StorageException in project ddf by codice.

the class InMemoryStorageProvider method delete.

@Override
public DeleteStorageResponse delete(DeleteStorageRequest deleteRequest) throws StorageException {
    if (deleteRequest == null) {
        throw new StorageException("delete request can't be null");
    }
    List<ContentItem> itemsToDelete = new ArrayList<>();
    for (Metacard metacard : deleteRequest.getMetacards()) {
        List<ContentItem> tmp = storageMap.values().stream().filter(item -> item.getMetacard().getId().equals(metacard.getId())).collect(Collectors.toList());
        if (tmp.isEmpty()) {
            throw new StorageException("can't delete a metacard that isn't stored");
        }
        itemsToDelete.addAll(tmp);
    }
    for (ContentItem item : itemsToDelete) {
        deleteMap.put(item.getUri(), item);
    }
    return new DeleteStorageResponseImpl(deleteRequest, itemsToDelete);
}
Also used : CreateStorageRequest(ddf.catalog.content.operation.CreateStorageRequest) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ReadStorageRequest(ddf.catalog.content.operation.ReadStorageRequest) ArrayList(java.util.ArrayList) StorageRequest(ddf.catalog.content.operation.StorageRequest) CreateStorageResponseImpl(ddf.catalog.content.operation.impl.CreateStorageResponseImpl) StorageException(ddf.catalog.content.StorageException) UpdateStorageRequest(ddf.catalog.content.operation.UpdateStorageRequest) ReadStorageResponseImpl(ddf.catalog.content.operation.impl.ReadStorageResponseImpl) List(java.util.List) ContentItem(ddf.catalog.content.data.ContentItem) CreateStorageResponse(ddf.catalog.content.operation.CreateStorageResponse) DeleteStorageRequest(ddf.catalog.content.operation.DeleteStorageRequest) DeleteStorageResponseImpl(ddf.catalog.content.operation.impl.DeleteStorageResponseImpl) UpdateStorageResponseImpl(ddf.catalog.content.operation.impl.UpdateStorageResponseImpl) Metacard(ddf.catalog.data.Metacard) Map(java.util.Map) StorageProvider(ddf.catalog.content.StorageProvider) DeleteStorageResponse(ddf.catalog.content.operation.DeleteStorageResponse) UpdateStorageResponse(ddf.catalog.content.operation.UpdateStorageResponse) ReadStorageResponse(ddf.catalog.content.operation.ReadStorageResponse) Metacard(ddf.catalog.data.Metacard) ArrayList(java.util.ArrayList) StorageException(ddf.catalog.content.StorageException) ContentItem(ddf.catalog.content.data.ContentItem) DeleteStorageResponseImpl(ddf.catalog.content.operation.impl.DeleteStorageResponseImpl)

Aggregations

StorageException (ddf.catalog.content.StorageException)17 IOException (java.io.IOException)11 ContentItem (ddf.catalog.content.data.ContentItem)9 Path (java.nio.file.Path)9 ArrayList (java.util.ArrayList)8 URISyntaxException (java.net.URISyntaxException)7 Metacard (ddf.catalog.data.Metacard)6 IngestException (ddf.catalog.source.IngestException)6 CreateStorageResponse (ddf.catalog.content.operation.CreateStorageResponse)4 InternalIngestException (ddf.catalog.source.InternalIngestException)4 URI (java.net.URI)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ContentItemImpl (ddf.catalog.content.data.impl.ContentItemImpl)3 DeleteStorageRequest (ddf.catalog.content.operation.DeleteStorageRequest)3 DeleteStorageResponse (ddf.catalog.content.operation.DeleteStorageResponse)3 UpdateStorageResponse (ddf.catalog.content.operation.UpdateStorageResponse)3 DeleteStorageRequestImpl (ddf.catalog.content.operation.impl.DeleteStorageRequestImpl)3 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)3 List (java.util.List)3