Search in sources :

Example 1 with IdAndUriMetacard

use of org.codice.ddf.commands.catalog.export.IdAndUriMetacard in project ddf by codice.

the class ExportCommand method doDelete.

private void doDelete(List<ExportItem> exportedItems, List<ExportItem> exportedContentItems) {
    Instant start;
    console.println("Starting delete");
    start = Instant.now();
    for (ExportItem exportedContentItem : exportedContentItems) {
        try {
            DeleteStorageRequestImpl deleteRequest = new DeleteStorageRequestImpl(Collections.singletonList(new IdAndUriMetacard(exportedContentItem.getId(), exportedContentItem.getResourceUri())), exportedContentItem.getId(), Collections.emptyMap());
            storageProvider.delete(deleteRequest);
            storageProvider.commit(deleteRequest);
        } catch (StorageException e) {
            printErrorMessage("Could not delete content for metacard: " + exportedContentItem.toString());
        }
    }
    for (ExportItem exported : exportedItems) {
        try {
            catalogProvider.delete(new DeleteRequestImpl(exported.getId()));
        } catch (IngestException e) {
            printErrorMessage("Could not delete metacard: " + exported.toString());
        }
    }
    console.println("Metacards and Content deleted in: " + getFormattedDuration(start));
    console.println("Number of metacards deleted: " + exportedItems.size());
    console.println("Number of content deleted: " + exportedContentItems.size());
}
Also used : DeleteStorageRequestImpl(ddf.catalog.content.operation.impl.DeleteStorageRequestImpl) ExportItem(org.codice.ddf.commands.catalog.export.ExportItem) Instant(java.time.Instant) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) IdAndUriMetacard(org.codice.ddf.commands.catalog.export.IdAndUriMetacard) IngestException(ddf.catalog.source.IngestException) StorageException(ddf.catalog.content.StorageException)

Aggregations

StorageException (ddf.catalog.content.StorageException)1 DeleteStorageRequestImpl (ddf.catalog.content.operation.impl.DeleteStorageRequestImpl)1 DeleteRequestImpl (ddf.catalog.operation.impl.DeleteRequestImpl)1 IngestException (ddf.catalog.source.IngestException)1 Instant (java.time.Instant)1 ExportItem (org.codice.ddf.commands.catalog.export.ExportItem)1 IdAndUriMetacard (org.codice.ddf.commands.catalog.export.IdAndUriMetacard)1