Search in sources :

Example 11 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.

the class SourceMetricsImpl method process.

// PostFederatedQuery
@Override
public QueryResponse process(QueryResponse input) throws PluginExecutionException, StopProcessingException {
    LOGGER.trace("ENTERING: process (for PostFederatedQueryPlugin)");
    if (null != input) {
        Set<ProcessingDetails> processingDetails = input.getProcessingDetails();
        List<Result> results = input.getResults();
        // Total Exceptions metric per Source
        Iterator<ProcessingDetails> iterator = processingDetails.iterator();
        while (iterator.hasNext()) {
            ProcessingDetails next = iterator.next();
            if (next != null && next.getException() != null) {
                String sourceId = next.getSourceId();
                updateMetric(sourceId, EXCEPTIONS_SCOPE, 1);
            }
        }
        Map<String, Integer> totalHitsPerSource = new HashMap<String, Integer>();
        for (Result result : results) {
            String sourceId = result.getMetacard().getSourceId();
            if (totalHitsPerSource.containsKey(sourceId)) {
                totalHitsPerSource.put(sourceId, totalHitsPerSource.get(sourceId) + 1);
            } else {
                // First detection of this new source ID in the results list -
                // initialize the Total Query Result Count for this Source
                totalHitsPerSource.put(sourceId, 1);
            }
        }
        // Total Query Results metric per Source
        for (Map.Entry<String, Integer> source : totalHitsPerSource.entrySet()) {
            updateMetric(source.getKey(), QUERIES_TOTAL_RESULTS_SCOPE, source.getValue());
        }
    }
    LOGGER.trace("EXITING: process (for PostFederatedQueryPlugin)");
    return input;
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) Result(ddf.catalog.data.Result)

Example 12 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.

the class SortedQueryMonitor method executePostFederationQueryPluginsWithSourceError.

private void executePostFederationQueryPluginsWithSourceError(QueryRequest queryRequest, String sourceId, Exception e, Set<ProcessingDetails> processingDetails) {
    ProcessingDetails processingDetail = new ProcessingDetailsImpl(sourceId, e);
    SourceResponse sourceResponse = new SourceResponseImpl(queryRequest, new ArrayList<>());
    sourceResponse.getProcessingErrors().add(processingDetail);
    processingDetails.add(processingDetail);
    executePostFederationQueryPlugins(sourceResponse, queryRequest);
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) SourceResponse(ddf.catalog.operation.SourceResponse) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl)

Example 13 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.

the class FederationAdminServiceImpl method stringifyProcessingErrors.

private String stringifyProcessingErrors(Set<ProcessingDetails> details) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    for (ProcessingDetails detail : details) {
        pw.append(detail.getSourceId());
        pw.append(":");
        if (detail.hasException()) {
            detail.getException().printStackTrace(pw);
        }
        pw.append(System.lineSeparator());
    }
    return pw.toString();
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

Example 14 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.

the class AbstractCswStore method update.

@Override
public UpdateResponse update(UpdateRequest updateRequest) throws IngestException {
    Map<String, Serializable> properties = new HashMap<>();
    validateOperation();
    Subject subject = (Subject) updateRequest.getPropertyValue(SecurityConstants.SECURITY_SUBJECT);
    Csw csw = factory.getClientForSubject(subject);
    CswTransactionRequest transactionRequest = getTransactionRequest();
    OperationTransaction opTrans = (OperationTransaction) updateRequest.getPropertyValue(Constants.OPERATION_TRANSACTION_KEY);
    String insertTypeName = schemaTransformerManager.getTransformerIdForSchema(cswSourceConfiguration.getOutputSchema());
    HashSet<ProcessingDetails> errors = new HashSet<>();
    if (insertTypeName == null) {
        insertTypeName = CswConstants.CSW_RECORD;
    }
    ArrayList<Metacard> updatedMetacards = new ArrayList<>(updateRequest.getUpdates().size());
    ArrayList<Filter> updatedMetacardFilters = new ArrayList<>(updateRequest.getUpdates().size());
    for (Map.Entry<Serializable, Metacard> update : updateRequest.getUpdates()) {
        Metacard metacard = update.getValue();
        properties.put(metacard.getId(), metacard);
        updatedMetacardFilters.add(filterBuilder.attribute(updateRequest.getAttributeName()).is().equalTo().text(update.getKey().toString()));
        transactionRequest.getUpdateActions().add(new UpdateAction(metacard, insertTypeName, null));
    }
    try {
        TransactionResponseType response = csw.transaction(transactionRequest);
        if (response.getTransactionSummary().getTotalUpdated().longValue() != updateRequest.getUpdates().size()) {
            errors.add(new ProcessingDetailsImpl(this.getId(), null, "One or more updates failed"));
        }
    } catch (CswException e) {
        throw new IngestException("Csw Transaction Failed.", e);
    }
    try {
        updatedMetacards.addAll(transactionQuery(updatedMetacardFilters, subject));
    } catch (UnsupportedQueryException e) {
        errors.add(new ProcessingDetailsImpl(this.getId(), e, "Failed to retrieve updated metacards"));
    }
    return new UpdateResponseImpl(updateRequest, properties, updatedMetacards, new ArrayList(opTrans.getPreviousStateMetacards()), errors);
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ArrayList(java.util.ArrayList) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) TransactionResponseType(net.opengis.cat.csw.v_2_0_2.TransactionResponseType) OperationTransaction(ddf.catalog.operation.OperationTransaction) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) UpdateResponseImpl(ddf.catalog.operation.impl.UpdateResponseImpl) IngestException(ddf.catalog.source.IngestException) HashSet(java.util.HashSet) UpdateAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) Subject(ddf.security.Subject) Metacard(ddf.catalog.data.Metacard) Filter(org.opengis.filter.Filter) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) Map(java.util.Map) DefaultCswRecordMap(org.codice.ddf.spatial.ogc.csw.catalog.common.converter.DefaultCswRecordMap) HashMap(java.util.HashMap)

Example 15 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.

the class RemoteDeleteOperations method doRemoteDelete.

private DeleteResponse doRemoteDelete(DeleteRequest deleteRequest) {
    HashSet<ProcessingDetails> exceptions = new HashSet<>();
    Map<String, Serializable> properties = new HashMap<>();
    List<CatalogStore> stores = opsCatStoreSupport.getCatalogStoresForRequest(deleteRequest, exceptions);
    List<Metacard> metacards = new ArrayList<>();
    for (CatalogStore store : stores) {
        try {
            if (!store.isAvailable()) {
                exceptions.add(new ProcessingDetailsImpl(store.getId(), null, "CatalogStore is not available"));
            } else {
                // TODO: 4/27/17 Address bug in DDF-2970 for overwriting deleted metacards
                DeleteResponse response = store.delete(deleteRequest);
                properties.put(store.getId(), new ArrayList<>(response.getDeletedMetacards()));
                metacards = response.getDeletedMetacards();
            }
        } catch (IngestException e) {
            INGEST_LOGGER.error("Error deleting metacards for CatalogStore {}", store.getId(), e);
            exceptions.add(new ProcessingDetailsImpl(store.getId(), e));
        }
    }
    return new DeleteResponseImpl(deleteRequest, properties, metacards, exceptions);
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) CatalogStore(ddf.catalog.source.CatalogStore) Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) IngestException(ddf.catalog.source.IngestException) HashSet(java.util.HashSet)

Aggregations

ProcessingDetails (ddf.catalog.operation.ProcessingDetails)15 ProcessingDetailsImpl (ddf.catalog.operation.impl.ProcessingDetailsImpl)8 HashMap (java.util.HashMap)7 IngestException (ddf.catalog.source.IngestException)6 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)6 Serializable (java.io.Serializable)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 Metacard (ddf.catalog.data.Metacard)3 FederationException (ddf.catalog.federation.FederationException)3 SourceResponse (ddf.catalog.operation.SourceResponse)3 CatalogStore (ddf.catalog.source.CatalogStore)3 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)3 Result (ddf.catalog.data.Result)2 QueryResponse (ddf.catalog.operation.QueryResponse)2 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)2 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)2 UpdateResponseImpl (ddf.catalog.operation.impl.UpdateResponseImpl)2 InternalIngestException (ddf.catalog.source.InternalIngestException)2 Subject (ddf.security.Subject)2