Search in sources :

Example 26 with AttributeImpl

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

the class MetacardValidityFilterPluginTest method getErrorsMetacard.

private MetacardImpl getErrorsMetacard() {
    MetacardImpl returnMetacard = new MetacardImpl();
    returnMetacard.setAttribute(new AttributeImpl(Validation.VALIDATION_ERRORS, Collections.singletonList("sample-validator")));
    return returnMetacard;
}
Also used : AttributeImpl(ddf.catalog.data.impl.AttributeImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 27 with AttributeImpl

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

the class RegistryMetacardHandler method prepareMetacard.

/**
     * This is the method that converts an internal registry metacard with tag REGISTRY_TAG_INTERNAL
     * into a visible registry metacard with a tag of REGISTRY_TAG. Also removes other transient
     * metacard attributes that only internal entries have.
     *
     * @param metacard The internal registry metacard
     * @param id       The metacard id of the visible registry metacard. Can be null
     */
private void prepareMetacard(Metacard metacard, String id) {
    List<Serializable> tags = new ArrayList<>();
    tags.addAll(metacard.getTags());
    tags.remove(RegistryConstants.REGISTRY_TAG_INTERNAL);
    tags.add(RegistryConstants.REGISTRY_TAG);
    metacard.setAttribute(new AttributeImpl(Metacard.TAGS, tags));
    metacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_METACARD_ID, (Serializable) null));
    metacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_REGISTRY_ID, (Serializable) null));
    metacard.setAttribute(new AttributeImpl(Metacard.ID, id));
}
Also used : Serializable(java.io.Serializable) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList)

Example 28 with AttributeImpl

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

the class IdentityNodeInitializationTest method initWithPreviousPrimaryEntry.

@Test
public void initWithPreviousPrimaryEntry() throws Exception {
    testMetacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_ID, "registryId"));
    testMetacard.setAttribute(new AttributeImpl(Metacard.TITLE, TEST_SITE_NAME));
    when(federationAdminService.getLocalRegistryIdentityMetacard()).thenReturn(Optional.of(testMetacard));
    identityNodeInitialization.init();
    verify(federationAdminService, never()).addRegistryEntry(any(Metacard.class));
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Test(org.junit.Test)

Example 29 with AttributeImpl

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

the class IdentityNodeInitializationTest method initWithPreviousEntryWithNameChange.

@Test
public void initWithPreviousEntryWithNameChange() throws Exception {
    System.setProperty(SystemInfo.SITE_NAME, CHANGED_TEST_SITE_NAME);
    RegistryPackageType registryPackageType = buildRegistryPackageType();
    testMetacard.setAttribute(new AttributeImpl(Metacard.METADATA, metacardMarshaller.getRegistryPackageAsXml(registryPackageType)));
    testMetacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_ID, "registryId"));
    testMetacard.setAttribute(new AttributeImpl(Metacard.TITLE, TEST_SITE_NAME));
    when(federationAdminService.getLocalRegistryIdentityMetacard()).thenReturn(Optional.of(testMetacard));
    ArgumentCaptor<Metacard> updatedMetacard = ArgumentCaptor.forClass(Metacard.class);
    doNothing().when(federationAdminService).updateRegistryEntry(updatedMetacard.capture());
    identityNodeInitialization.init();
    assertThat(updatedMetacard.getValue().getTitle(), is(CHANGED_TEST_SITE_NAME));
    verify(federationAdminService, times(1)).updateRegistryEntry(any(Metacard.class));
    verify(federationAdminService, never()).addRegistryEntry(any(Metacard.class));
}
Also used : Metacard(ddf.catalog.data.Metacard) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Test(org.junit.Test)

Example 30 with AttributeImpl

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

the class IdentificationPlugin method updateTags.

private void updateTags(Metacard metacard) {
    if (RegistryUtility.hasAttribute(metacard, RegistryObjectMetacardType.REMOTE_REGISTRY_ID) && !RegistryUtility.isLocalNode(metacard) && !RegistryUtility.isInternalRegistryMetacard(metacard)) {
        List<Serializable> tags = new ArrayList<>();
        tags.addAll(metacard.getTags());
        tags.remove(RegistryConstants.REGISTRY_TAG);
        tags.add(RegistryConstants.REGISTRY_TAG_INTERNAL);
        metacard.setAttribute(new AttributeImpl(Metacard.TAGS, tags));
    }
}
Also used : Serializable(java.io.Serializable) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList)

Aggregations

AttributeImpl (ddf.catalog.data.impl.AttributeImpl)181 Metacard (ddf.catalog.data.Metacard)109 Test (org.junit.Test)75 ArrayList (java.util.ArrayList)56 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)49 Serializable (java.io.Serializable)30 Date (java.util.Date)30 Attribute (ddf.catalog.data.Attribute)29 List (java.util.List)23 HashMap (java.util.HashMap)20 IOException (java.io.IOException)18 InputStream (java.io.InputStream)17 Result (ddf.catalog.data.Result)15 HashSet (java.util.HashSet)15 PolicyResponse (ddf.catalog.plugin.PolicyResponse)14 ResultImpl (ddf.catalog.data.impl.ResultImpl)11 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)11 Set (java.util.Set)11 ContentItem (ddf.catalog.content.data.ContentItem)10 QueryResponse (ddf.catalog.operation.QueryResponse)10