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;
}
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));
}
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));
}
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));
}
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));
}
}
Aggregations