use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class RegistryStoreImpl method setMetacardExtID.
private void setMetacardExtID(Metacard metacard, String newId) throws ParserException {
RegistryPackageType registryPackage = metacardMarshaller.getRegistryPackageFromMetacard(metacard);
List<ExternalIdentifierType> currentExtIdList = registryPackage.getExternalIdentifier();
currentExtIdList.stream().filter(extId -> extId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_LOCAL)).findFirst().ifPresent(extId -> extId.setValue(newId));
metacardMarshaller.setMetacardRegistryPackage(metacard, registryPackage);
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class IdentityNodeInitializationTest method buildRegistryPackageType.
private RegistryPackageType buildRegistryPackageType() {
SlotTypeHelper slotTypeHelper = new SlotTypeHelper();
InternationalStringTypeHelper internationalStringTypeHelper = new InternationalStringTypeHelper();
String registryPackageId = RegistryConstants.GUID_PREFIX + UUID.randomUUID().toString().replaceAll("-", "");
RegistryPackageType registryPackage = RIM_FACTORY.createRegistryPackageType();
registryPackage.setId(registryPackageId);
registryPackage.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);
ExtrinsicObjectType extrinsicObject = RIM_FACTORY.createExtrinsicObjectType();
extrinsicObject.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);
String extrinsicObjectId = RegistryConstants.GUID_PREFIX + UUID.randomUUID().toString().replaceAll("-", "");
extrinsicObject.setId(extrinsicObjectId);
extrinsicObject.setName(internationalStringTypeHelper.create(TEST_SITE_NAME));
String home = SystemBaseUrl.getBaseUrl();
extrinsicObject.setHome(home);
registryPackage.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
registryPackage.getRegistryObjectList().getIdentifiable().add(RIM_FACTORY.createIdentifiable(extrinsicObject));
return registryPackage;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType 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 oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class IdentificationPlugin method updateIdentifiers.
private void updateIdentifiers(Metacard metacard, boolean create) throws StopProcessingException {
boolean extOriginFound = false;
boolean extRegIdFound = false;
String metacardID = metacard.getId();
String registryID = RegistryUtility.getRegistryId(metacard);
String systemRegId = System.getProperty(RegistryConstants.REGISTRY_ID_PROPERTY);
try {
RegistryPackageType registryPackage = metacardMarshaller.getRegistryPackageFromMetacard(metacard);
List<ExternalIdentifierType> extIdList = new ArrayList<>();
//check if external ids are already present
if (registryPackage.isSetExternalIdentifier()) {
List<ExternalIdentifierType> currentExtIdList = registryPackage.getExternalIdentifier();
for (ExternalIdentifierType extId : currentExtIdList) {
extId.setRegistryObject(registryID);
if (extId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_LOCAL)) {
if (isInternal(metacard) && create) {
metacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_METACARD_ID, extId.getValue()));
}
extId.setValue(metacardID);
} else if (extId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN)) {
extOriginFound = true;
} else if (extId.getId().equals(RegistryConstants.REGISTRY_ID_ORIGIN)) {
if (!systemRegId.equals(extId.getValue()) && isInternal(metacard)) {
metacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_REGISTRY_ID, extId.getValue()));
}
extId.setValue(systemRegId);
extRegIdFound = true;
}
extIdList.add(extId);
}
if (!extOriginFound) {
extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN, registryID, RegistryConstants.REGISTRY_METACARD_ID_CLASS, metacardID));
}
if (!extRegIdFound) {
extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_ID_ORIGIN, registryID, RegistryConstants.REGISTRY_ID_CLASS, systemRegId));
}
} else {
extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_MCARD_ID_LOCAL, registryID, RegistryConstants.REGISTRY_METACARD_ID_CLASS, metacardID));
extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN, registryID, RegistryConstants.REGISTRY_METACARD_ID_CLASS, metacardID));
extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_ID_ORIGIN, registryID, RegistryConstants.REGISTRY_ID_CLASS, systemRegId));
}
registryPackage.setExternalIdentifier(extIdList);
metacardMarshaller.setMetacardRegistryPackage(metacard, registryPackage);
} catch (ParserException e) {
throw new StopProcessingException("Unable to access Registry Metadata. Parser exception caught");
}
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class RegistryReportBuilderTest method testFullReportWithSimplifiedRegistryPackage.
@Test
public void testFullReportWithSimplifiedRegistryPackage() throws Exception {
RegistryPackageType registryPackage = getRegistryPackageFromResource("/csw-simplified-registry-package.xml");
String html = reportHelper.getHtmlFromRegistryPackage(registryPackage, reportHelper.REPORT);
assertFullReportValues(Jsoup.parse(html));
}
Aggregations