Search in sources :

Example 6 with ContentTypeImpl

use of ddf.catalog.data.impl.ContentTypeImpl in project ddf by codice.

the class ContentTypeFilterDelegate method propertyIsEqualTo.

// PropertyIsEqualTo
@Override
public List<ContentType> propertyIsEqualTo(String propertyName, String literal, boolean isCaseSensitive) {
    List<ContentType> types = null;
    verifyInputData(propertyName, literal);
    if (propertyName.equalsIgnoreCase(Metacard.CONTENT_TYPE)) {
        ContentType type = new ContentTypeImpl(literal, "");
        types = new ArrayList<ContentType>();
        types.add(type);
    } else {
        types = Collections.<ContentType>emptyList();
    }
    return types;
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) ContentType(ddf.catalog.data.ContentType)

Example 7 with ContentTypeImpl

use of ddf.catalog.data.impl.ContentTypeImpl in project ddf by codice.

the class TestCswSourceBase method generateContentType.

protected Set<ContentType> generateContentType(List<String> names) {
    Set<ContentType> contentTypes = new HashSet<>();
    for (String name : names) {
        ContentType ct = new ContentTypeImpl(name, "");
        contentTypes.add(ct);
    }
    return contentTypes;
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) ContentType(ddf.catalog.data.ContentType) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet)

Example 8 with ContentTypeImpl

use of ddf.catalog.data.impl.ContentTypeImpl in project ddf by codice.

the class WfsSource method getContentTypes.

@Override
public Set<ContentType> getContentTypes() {
    Set<QName> typeNames = featureTypeFilters.keySet();
    Set<ContentType> contentTypes = new HashSet<ContentType>();
    for (QName featureName : typeNames) {
        contentTypes.add(new ContentTypeImpl(featureName.getLocalPart(), getVersion()));
    }
    return contentTypes;
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) ContentType(ddf.catalog.data.ContentType) QName(javax.xml.namespace.QName) HashSet(java.util.HashSet)

Example 9 with ContentTypeImpl

use of ddf.catalog.data.impl.ContentTypeImpl in project ddf by codice.

the class SourcePollerRunnerTest method createContentTypes.

private Set<ContentType> createContentTypes() {
    Set<ContentType> types = new HashSet<ContentType>();
    types.add(new ContentTypeImpl("Type1", "v1.1"));
    types.add(new ContentTypeImpl("Type2", "v1.2"));
    return types;
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) ContentType(ddf.catalog.data.ContentType) HashSet(java.util.HashSet)

Example 10 with ContentTypeImpl

use of ddf.catalog.data.impl.ContentTypeImpl in project ddf by codice.

the class TestRestEndpoint method testGetDocumentSourcesSuccess.

/**
     * Tests getting source information
     *
     * @throws Exception
     */
@Test
public void testGetDocumentSourcesSuccess() throws Exception {
    final String localSourceId = "local";
    final String fed1SourceId = "fed1";
    final String fed2SourceId = "fed2";
    final String version = "4.0";
    final String jsonMimeTypeString = "application/json";
    Set<ContentType> contentTypes = new HashSet<ContentType>();
    contentTypes.add(new ContentTypeImpl("ct1", "v1"));
    contentTypes.add(new ContentTypeImpl("ct2", "v2"));
    contentTypes.add(new ContentTypeImpl("ct3", null));
    JSONArray contentTypesInJSON = new JSONArray();
    for (ContentType ct : contentTypes) {
        JSONObject ob = new JSONObject();
        ob.put("name", ct.getName());
        ob.put("version", ct.getVersion() != null ? ct.getVersion() : "");
        contentTypesInJSON.add(ob);
    }
    Set<SourceDescriptor> sourceDescriptors = new HashSet<SourceDescriptor>();
    SourceDescriptorImpl localDescriptor = new SourceDescriptorImpl(localSourceId, contentTypes);
    localDescriptor.setVersion(version);
    localDescriptor.setAvailable(true);
    SourceDescriptorImpl fed1Descriptor = new SourceDescriptorImpl(fed1SourceId, contentTypes);
    fed1Descriptor.setVersion(version);
    fed1Descriptor.setAvailable(true);
    SourceDescriptorImpl fed2Descriptor = new SourceDescriptorImpl(fed2SourceId, null);
    fed2Descriptor.setAvailable(true);
    sourceDescriptors.add(localDescriptor);
    sourceDescriptors.add(fed1Descriptor);
    sourceDescriptors.add(fed2Descriptor);
    SourceInfoResponse sourceInfoResponse = new SourceInfoResponseImpl(null, null, sourceDescriptors);
    CatalogFramework framework = mock(CatalogFramework.class);
    when(framework.getSourceInfo(isA(SourceInfoRequestEnterprise.class))).thenReturn(sourceInfoResponse);
    RESTEndpoint restEndpoint = new RESTEndpoint(framework);
    Response response = restEndpoint.getDocument(null, null);
    assertEquals(OK, response.getStatus());
    assertEquals(jsonMimeTypeString, response.getMetadata().get("Content-Type").get(0));
    String responseMessage = IOUtils.toString((ByteArrayInputStream) response.getEntity());
    JSONArray srcList = (JSONArray) new JSONParser().parse(responseMessage);
    assertEquals(3, srcList.size());
    for (Object o : srcList) {
        JSONObject src = (JSONObject) o;
        assertEquals(true, src.get("available"));
        String id = (String) src.get("id");
        if (id.equals(localSourceId)) {
            assertThat((Iterable<Object>) src.get("contentTypes"), hasItems(contentTypesInJSON.toArray()));
            assertEquals(contentTypes.size(), ((JSONArray) src.get("contentTypes")).size());
            assertEquals(version, src.get("version"));
        } else if (id.equals(fed1SourceId)) {
            assertThat((Iterable<Object>) src.get("contentTypes"), hasItems(contentTypesInJSON.toArray()));
            assertEquals(contentTypes.size(), ((JSONArray) src.get("contentTypes")).size());
            assertEquals(version, src.get("version"));
        } else if (id.equals(fed2SourceId)) {
            assertEquals(0, ((JSONArray) src.get("contentTypes")).size());
            assertEquals("", src.get("version"));
        } else {
            fail("Invalid ID returned");
        }
    }
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) SourceDescriptor(ddf.catalog.source.SourceDescriptor) ContentType(ddf.catalog.data.ContentType) SourceDescriptorImpl(ddf.catalog.source.impl.SourceDescriptorImpl) JSONArray(net.minidev.json.JSONArray) Matchers.anyString(org.mockito.Matchers.anyString) SourceInfoRequestEnterprise(ddf.catalog.operation.impl.SourceInfoRequestEnterprise) QueryResponse(ddf.catalog.operation.QueryResponse) Response(javax.ws.rs.core.Response) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) JSONObject(net.minidev.json.JSONObject) CatalogFramework(ddf.catalog.CatalogFramework) SourceInfoResponseImpl(ddf.catalog.operation.impl.SourceInfoResponseImpl) JSONParser(net.minidev.json.parser.JSONParser) JSONObject(net.minidev.json.JSONObject) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ContentTypeImpl (ddf.catalog.data.impl.ContentTypeImpl)13 ContentType (ddf.catalog.data.ContentType)12 Metacard (ddf.catalog.data.Metacard)6 HashSet (java.util.HashSet)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)2 Matchers.anyString (org.mockito.Matchers.anyString)2 CatalogFramework (ddf.catalog.CatalogFramework)1 Result (ddf.catalog.data.Result)1 QueryResponse (ddf.catalog.operation.QueryResponse)1 SourceInfoResponse (ddf.catalog.operation.SourceInfoResponse)1 SourceInfoRequestEnterprise (ddf.catalog.operation.impl.SourceInfoRequestEnterprise)1 SourceInfoResponseImpl (ddf.catalog.operation.impl.SourceInfoResponseImpl)1 SourceDescriptor (ddf.catalog.source.SourceDescriptor)1 SourceDescriptorImpl (ddf.catalog.source.impl.SourceDescriptorImpl)1 IOException (java.io.IOException)1 URI (java.net.URI)1 List (java.util.List)1 Map (java.util.Map)1