Search in sources :

Example 31 with MetacardTypeImpl

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

the class FilterPluginTest method getNoSecurityAttributeMetacard.

private Metacard getNoSecurityAttributeMetacard() {
    MetacardImpl metacard = new MetacardImpl();
    metacard.setResourceSize("100");
    try {
        metacard.setResourceURI(new URI("http://some.fancy.uri/goes/here"));
    } catch (URISyntaxException e) {
        LOGGER.error("", e);
    }
    //Intentionally do not set the Metacard.SECURITY attribute
    metacard.setContentTypeName("Resource");
    metacard.setTitle("Metacard 1");
    metacard.setContentTypeVersion("1");
    metacard.setType(new MetacardTypeImpl(MetacardType.DEFAULT_METACARD_TYPE_NAME, new HashSet<>()));
    return metacard;
}
Also used : MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet)

Example 32 with MetacardTypeImpl

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

the class FilterPluginTest method getExactRolesMetacard.

private Metacard getExactRolesMetacard() {
    MetacardImpl metacard = new MetacardImpl();
    metacard.setResourceSize("100");
    try {
        metacard.setResourceURI(new URI("http://some.fancy.uri/goes/here"));
    } catch (URISyntaxException e) {
        LOGGER.error("", e);
    }
    metacard.setContentTypeName("Resource");
    metacard.setTitle("Metacard 1");
    metacard.setContentTypeVersion("1");
    metacard.setType(new MetacardTypeImpl(MetacardType.DEFAULT_METACARD_TYPE_NAME, new HashSet<>()));
    HashMap<String, List<String>> security = new HashMap<>();
    security.put("Roles", Arrays.asList("A", "B"));
    metacard.setSecurity(security);
    metacard.setId("exactroles");
    return metacard;
}
Also used : HashMap(java.util.HashMap) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) List(java.util.List) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet)

Example 33 with MetacardTypeImpl

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

the class FilterPluginTest method getMissingRolesMetacard.

private Metacard getMissingRolesMetacard() {
    MetacardImpl metacard = new MetacardImpl();
    metacard.setResourceSize("100");
    try {
        metacard.setResourceURI(new URI("http://some.fancy.uri/goes/here"));
    } catch (URISyntaxException e) {
        LOGGER.error("", e);
    }
    metacard.setContentTypeName("Resource");
    metacard.setTitle("Metacard 1");
    metacard.setContentTypeVersion("1");
    metacard.setType(new MetacardTypeImpl(MetacardType.DEFAULT_METACARD_TYPE_NAME, new HashSet<>()));
    HashMap<String, List<String>> security = new HashMap<>();
    security.put("Roles", Arrays.asList("A"));
    metacard.setSecurity(security);
    return metacard;
}
Also used : HashMap(java.util.HashMap) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) List(java.util.List) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet)

Example 34 with MetacardTypeImpl

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

the class FilterPluginTest method getNoRolesMetacard.

private Metacard getNoRolesMetacard() {
    MetacardImpl metacard = new MetacardImpl();
    metacard.setResourceSize("100");
    try {
        metacard.setResourceURI(new URI("http://some.fancy.uri/goes/here"));
    } catch (URISyntaxException e) {
        LOGGER.error("", e);
    }
    metacard.setContentTypeName("Resource");
    metacard.setTitle("Metacard 1");
    metacard.setContentTypeVersion("1");
    metacard.setType(new MetacardTypeImpl(MetacardType.DEFAULT_METACARD_TYPE_NAME, new HashSet<>()));
    HashMap<String, List<String>> security = new HashMap<>();
    metacard.setSecurity(security);
    return metacard;
}
Also used : HashMap(java.util.HashMap) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) List(java.util.List) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet)

Example 35 with MetacardTypeImpl

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

the class MetacardCreatorTest method testIntAttribute.

@Test
public void testIntAttribute() {
    Set<AttributeDescriptor> extraAttributes = new HashSet<>();
    extraAttributes.add(new AttributeDescriptorImpl(Media.DURATION, false, false, false, false, BasicTypes.INTEGER_TYPE));
    final Metadata metadata = new Metadata();
    String imageLength = "14";
    metadata.add(TIFF.IMAGE_LENGTH, imageLength);
    MetacardTypeImpl extendedMetacardType = new MetacardTypeImpl(BasicTypes.BASIC_METACARD.getName(), BasicTypes.BASIC_METACARD, extraAttributes);
    final String id = "id";
    final String metadataXml = "<xml>test</xml>";
    Metacard metacard = MetacardCreator.createMetacard(metadata, id, metadataXml, extendedMetacardType);
    assertThat(metacard.getMetadata(), is(metadataXml));
    assertThat(metacard.getAttribute(Media.HEIGHT).getValue(), is(Integer.valueOf(imageLength)));
}
Also used : Metacard(ddf.catalog.data.Metacard) Metadata(org.apache.tika.metadata.Metadata) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)40 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)22 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)21 Test (org.junit.Test)21 Metacard (ddf.catalog.data.Metacard)20 HashSet (java.util.HashSet)16 ArrayList (java.util.ArrayList)15 MetacardType (ddf.catalog.data.MetacardType)14 AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)10 URI (java.net.URI)9 HashMap (java.util.HashMap)6 List (java.util.List)6 Metadata (org.apache.tika.metadata.Metadata)6 URISyntaxException (java.net.URISyntaxException)5 SourceResponse (ddf.catalog.operation.SourceResponse)4 QueryImpl (ddf.catalog.operation.impl.QueryImpl)3 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)3 MetacardTypeAdapter (ddf.catalog.transformer.xml.adapter.MetacardTypeAdapter)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ContentItem (ddf.catalog.content.data.ContentItem)2