Search in sources :

Example 46 with IngestException

use of ddf.catalog.source.IngestException in project ddf by codice.

the class ExceptionsTest method testIngestException.

@Test
public void testIngestException() {
    IngestException ie = new IngestException();
    assertNotNull(ie);
    ie = new IngestException(msg);
    assertEquals(ie.getMessage(), msg);
    ie = new IngestException(testCause);
    assertEquals(ie.getCause(), testCause);
    ie = new IngestException(msg, testCause);
    assertEquals(ie.getMessage(), msg);
    assertEquals(ie.getCause(), testCause);
}
Also used : IngestException(ddf.catalog.source.IngestException) Test(org.junit.Test)

Example 47 with IngestException

use of ddf.catalog.source.IngestException in project ddf by codice.

the class SolrCatalogProvider method deleteListOfMetacards.

private void deleteListOfMetacards(List<Metacard> deletedMetacards, List<? extends Serializable> identifiers, String attributeName) throws IngestException {
    String fieldName = attributeName + SchemaFields.TEXT_SUFFIX;
    SolrDocumentList docs = getSolrDocumentList(identifiers, fieldName);
    createListOfDeletedMetacards(deletedMetacards, docs);
    try {
        // the assumption is if something was deleted, it should be gone
        // right away, such as expired data, etc.
        // so we force the commit
        client.deleteByIds(fieldName, identifiers, true);
    } catch (SolrServerException | IOException e) {
        LOGGER.info("Failed to delete metacards by ID(s).", e);
        throw new IngestException(COULD_NOT_COMPLETE_DELETE_REQUEST_MESSAGE);
    }
}
Also used : SolrServerException(org.apache.solr.client.solrj.SolrServerException) IngestException(ddf.catalog.source.IngestException) SolrDocumentList(org.apache.solr.common.SolrDocumentList) IOException(java.io.IOException)

Example 48 with IngestException

use of ddf.catalog.source.IngestException in project ddf by codice.

the class SolrCatalogProvider method getSolrDocumentList.

private SolrDocumentList getSolrDocumentList(List<? extends Serializable> identifierPaged, String fieldName) throws IngestException {
    SolrQuery query = new SolrQuery(client.getIdentifierQuery(fieldName, identifierPaged));
    query.setRows(identifierPaged.size());
    QueryResponse solrResponse;
    try {
        solrResponse = solr.query(query, METHOD.POST);
    } catch (SolrServerException | IOException e) {
        LOGGER.info("Failed to get list of Solr documents for delete.", e);
        throw new IngestException(COULD_NOT_COMPLETE_DELETE_REQUEST_MESSAGE);
    }
    return solrResponse.getResults();
}
Also used : QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IngestException(ddf.catalog.source.IngestException) IOException(java.io.IOException) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Example 49 with IngestException

use of ddf.catalog.source.IngestException 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());
        }
    }
    // delete items from cache
    try {
        getCacheProxy().removeById(exportedItems.stream().map(ExportItem::getId).collect(Collectors.toList()).toArray(new String[exportedItems.size()]));
    } catch (Exception e) {
        LOGGER.warn("Could not delete all exported items from cache (Results will eventually expire)", e);
    }
    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) URISyntaxException(java.net.URISyntaxException) ParseException(java.text.ParseException) ResourceNotFoundException(ddf.catalog.resource.ResourceNotFoundException) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) ZipException(net.lingala.zip4j.exception.ZipException) StorageException(ddf.catalog.content.StorageException) CatalogCommandRuntimeException(org.codice.ddf.commands.util.CatalogCommandRuntimeException) CQLException(org.geotools.filter.text.cql2.CQLException) IngestException(ddf.catalog.source.IngestException) IOException(java.io.IOException) ResourceNotSupportedException(ddf.catalog.resource.ResourceNotSupportedException)

Example 50 with IngestException

use of ddf.catalog.source.IngestException in project ddf by codice.

the class IngestCommand method addFileToQueue.

private void addFileToQueue(ArrayBlockingQueue<Metacard> metacardQueue, long start, File file) {
    if (file.isHidden()) {
        fileCount.incrementAndGet();
        ignoreCount.incrementAndGet();
        return;
    }
    String extension = "." + FilenameUtils.getExtension(file.getName());
    if (ignoreList != null && (ignoreList.contains(extension) || ignoreList.contains(file.getName()))) {
        ignoreCount.incrementAndGet();
        printProgressAndFlush(start, fileCount.get(), ingestCount.get() + ignoreCount.get());
        return;
    }
    Metacard result = null;
    try {
        result = readMetacard(file);
    } catch (IngestException e) {
        logIngestException(e, file);
        if (failedIngestDirectory != null) {
            moveToFailedIngestDirectory(file);
        }
        printErrorMessage(String.format("Failed to ingest file [%s].", file.getAbsolutePath()));
        INGEST_LOGGER.warn("Failed to ingest file [{}].", file.getAbsolutePath());
    }
    if (result != null) {
        putMetacardOnQueue(metacardQueue, result);
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) IngestException(ddf.catalog.source.IngestException)

Aggregations

IngestException (ddf.catalog.source.IngestException)56 Metacard (ddf.catalog.data.Metacard)33 ArrayList (java.util.ArrayList)32 HashMap (java.util.HashMap)21 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)20 CreateResponse (ddf.catalog.operation.CreateResponse)19 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)17 IOException (java.io.IOException)17 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)15 Test (org.junit.Test)15 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)13 InternalIngestException (ddf.catalog.source.InternalIngestException)13 QueryResponse (ddf.catalog.operation.QueryResponse)11 Serializable (java.io.Serializable)11 List (java.util.List)11 Map (java.util.Map)11 FederationException (ddf.catalog.federation.FederationException)10 CreateRequest (ddf.catalog.operation.CreateRequest)10 DeleteResponse (ddf.catalog.operation.DeleteResponse)10 QueryImpl (ddf.catalog.operation.impl.QueryImpl)10