Search in sources :

Example 1 with ContentTypeEvaluationCriteriaImpl

use of ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl in project ddf by codice.

the class ContentTypePredicate method matches.

public boolean matches(Event properties) {
    LOGGER.debug("ENTERING: matches");
    boolean status = false;
    Map<String, Object> contextualMap = (Map<String, Object>) properties.getProperty(PubSubConstants.HEADER_CONTEXTUAL_KEY);
    String operation = (String) properties.getProperty(PubSubConstants.HEADER_OPERATION_KEY);
    LOGGER.debug("operation = {}", operation);
    if (contextualMap != null) {
        String metadata = (String) contextualMap.get("METADATA");
        // cannot apply any geospatial filtering - just send the event on to the subscriber
        if (PubSubConstants.DELETE.equals(operation) && PubSubConstants.METADATA_DELETED.equals(metadata)) {
            LOGGER.debug("Detected a DELETE operation where metadata is just the word 'deleted', so send event on to subscriber");
            LOGGER.debug("EXITING: matches");
            return true;
        }
    }
    Object inputContentType = properties.getProperty(PubSubConstants.HEADER_CONTENT_TYPE_KEY);
    LOGGER.debug("input obtained from event properties: ", inputContentType);
    if (inputContentType != null) {
        ContentTypeEvaluationCriteriaImpl ctec = new ContentTypeEvaluationCriteriaImpl(this, inputContentType.toString());
        status = ContentTypeEvaluator.evaluate(ctec);
    }
    LOGGER.debug("EXITING: matches");
    return status;
}
Also used : ContentTypeEvaluationCriteriaImpl(ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl) Map(java.util.Map)

Example 2 with ContentTypeEvaluationCriteriaImpl

use of ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl in project ddf by codice.

the class PredicateTest method testContentTypeEvaluatorTypeAndVersionMatch.

@Test
public void testContentTypeEvaluatorTypeAndVersionMatch() throws Exception {
    LOGGER.debug("**************************  START: testContentTypeEvaluator_TypeAndVersion_Match()  ***********************");
    // Match on "nitf, v20"
    ContentTypePredicate predicate = new ContentTypePredicate("nitf", "v20");
    String inputContentType = "nitf,v20";
    ContentTypeEvaluationCriteriaImpl ctec = new ContentTypeEvaluationCriteriaImpl(predicate, inputContentType);
    boolean status = ContentTypeEvaluator.evaluate(ctec);
    assertTrue(status);
    LOGGER.debug("**************************  END: testContentTypeEvaluator_TypeAndVersion_Match()  ***********************");
}
Also used : ContentTypeEvaluationCriteriaImpl(ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl) ContentTypePredicate(ddf.catalog.pubsub.predicate.ContentTypePredicate) Test(org.junit.Test)

Example 3 with ContentTypeEvaluationCriteriaImpl

use of ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl in project ddf by codice.

the class PredicateTest method testContentTypeEvaluatorOnlyTypeNoMatch.

@Test
public void testContentTypeEvaluatorOnlyTypeNoMatch() throws Exception {
    LOGGER.debug("**************************  START: testContentTypeEvaluator_OnlyType_NoMatch()  ***********************");
    // Match on "nitf", all versions
    ContentTypePredicate predicate = new ContentTypePredicate("nitf", null);
    String inputContentType = "video,v20";
    ContentTypeEvaluationCriteriaImpl ctec = new ContentTypeEvaluationCriteriaImpl(predicate, inputContentType);
    boolean status = ContentTypeEvaluator.evaluate(ctec);
    assertFalse(status);
    LOGGER.debug("**************************  END: testContentTypeEvaluator_OnlyType_NoMatch()  ***********************");
}
Also used : ContentTypeEvaluationCriteriaImpl(ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl) ContentTypePredicate(ddf.catalog.pubsub.predicate.ContentTypePredicate) Test(org.junit.Test)

Example 4 with ContentTypeEvaluationCriteriaImpl

use of ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl in project ddf by codice.

the class PredicateTest method testContentTypeEvaluatorTypeAndVersionVersionMismatch.

@Test
public void testContentTypeEvaluatorTypeAndVersionVersionMismatch() throws Exception {
    LOGGER.debug("**************************  START: testContentTypeEvaluator_TypeAndVersion_VersionMismatch()  ***********************");
    // Match on "nitf, v20"
    ContentTypePredicate predicate = new ContentTypePredicate("nitf", "v20");
    String inputContentType = "nitf,v20_Army";
    ContentTypeEvaluationCriteriaImpl ctec = new ContentTypeEvaluationCriteriaImpl(predicate, inputContentType);
    boolean status = ContentTypeEvaluator.evaluate(ctec);
    assertFalse(status);
    LOGGER.debug("**************************  END: testContentTypeEvaluator_TypeAndVersion_VersionMismatch()  ***********************");
}
Also used : ContentTypeEvaluationCriteriaImpl(ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl) ContentTypePredicate(ddf.catalog.pubsub.predicate.ContentTypePredicate) Test(org.junit.Test)

Example 5 with ContentTypeEvaluationCriteriaImpl

use of ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl in project ddf by codice.

the class PredicateTest method testContentTypeEvaluatorOnlyTypeMatch.

@Test
public void testContentTypeEvaluatorOnlyTypeMatch() throws Exception {
    LOGGER.debug("**************************  START: testContentTypeEvaluator_OnlyType_Match()  ***********************");
    // Match on "nitf", all versions
    ContentTypePredicate predicate = new ContentTypePredicate("nitf", null);
    String inputContentType = "nitf,v20";
    ContentTypeEvaluationCriteriaImpl ctec = new ContentTypeEvaluationCriteriaImpl(predicate, inputContentType);
    boolean status = ContentTypeEvaluator.evaluate(ctec);
    assertTrue(status);
    LOGGER.debug("**************************  END: testContentTypeEvaluator_OnlyType_Match()  ***********************");
}
Also used : ContentTypeEvaluationCriteriaImpl(ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl) ContentTypePredicate(ddf.catalog.pubsub.predicate.ContentTypePredicate) Test(org.junit.Test)

Aggregations

ContentTypeEvaluationCriteriaImpl (ddf.catalog.pubsub.criteria.contenttype.ContentTypeEvaluationCriteriaImpl)6 ContentTypePredicate (ddf.catalog.pubsub.predicate.ContentTypePredicate)5 Test (org.junit.Test)5 Map (java.util.Map)1