use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class MetacardMarshaller method getRegistryPackageAsXml.
/**
* Converts the RegistryPackageType into an xml string
*
* @param registryPackage Registry package to convert
* @return Ebrim xml string
* @throws ParserException
*/
public String getRegistryPackageAsXml(RegistryPackageType registryPackage) throws ParserException {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
JAXBElement<RegistryPackageType> registryObjectTypeJAXBElement = EbrimConstants.RIM_FACTORY.createRegistryPackage(registryPackage);
parser.marshal(marshalConfigurator, registryObjectTypeJAXBElement, outputStream);
return new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new ParserException("Error parsing registry package to ebrim xml", e);
}
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class RegistryReportBuilderTest method testOrganizationReportWithSimplifiedRegistryPackage.
@Test
public void testOrganizationReportWithSimplifiedRegistryPackage() throws Exception {
RegistryPackageType registryPackage = getRegistryPackageFromResource("/csw-simplified-registry-package.xml");
String html = reportHelper.getHtmlFromRegistryPackage(registryPackage, reportHelper.ORGANIZATIONS);
assertOrganizationReportValues(Jsoup.parse(html));
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class IdentityNodeInitialization method createIdentityNode.
private void createIdentityNode() throws FederationAdminException {
String registryPackageId = RegistryConstants.GUID_PREFIX + UUID.randomUUID().toString().replaceAll("-", "");
LOGGER.info("Creating registry identity node: {} {}", SystemInfo.getSiteName(), registryPackageId);
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);
String siteName = SystemInfo.getSiteName();
if (StringUtils.isNotBlank(siteName)) {
extrinsicObject.setName(internationalStringTypeHelper.create(siteName));
} else {
extrinsicObject.setName(internationalStringTypeHelper.create(UNKNOWN_SITE_NAME));
}
String home = SystemBaseUrl.getBaseUrl();
extrinsicObject.setHome(home);
String version = SystemInfo.getVersion();
if (StringUtils.isNotBlank(version)) {
VersionInfoType versionInfo = RIM_FACTORY.createVersionInfoType();
versionInfo.setVersionName(version);
extrinsicObject.setVersionInfo(versionInfo);
}
OffsetDateTime now = OffsetDateTime.now(ZoneId.of(ZoneOffset.UTC.toString()));
String rightNow = now.toString();
SlotType1 lastUpdated = slotTypeHelper.create(RegistryConstants.XML_LAST_UPDATED_NAME, rightNow, DATE_TIME);
extrinsicObject.getSlot().add(lastUpdated);
SlotType1 liveDate = slotTypeHelper.create(RegistryConstants.XML_LIVE_DATE_NAME, rightNow, DATE_TIME);
extrinsicObject.getSlot().add(liveDate);
if (registryPackage.getRegistryObjectList() == null) {
registryPackage.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
}
registryPackage.getRegistryObjectList().getIdentifiable().add(RIM_FACTORY.createIdentifiable(extrinsicObject));
Metacard identityMetacard = getRegistryMetacardFromRegistryPackage(registryPackage);
if (identityMetacard != null) {
identityMetacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE, true));
identityMetacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true));
System.setProperty(RegistryConstants.REGISTRY_ID_PROPERTY, registryPackageId);
federationAdminService.addRegistryEntry(identityMetacard);
}
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class IdentityNodeInitialization method updateIdentityNodeName.
private void updateIdentityNodeName(Metacard metacard) throws FederationAdminException, ParserException {
RegistryPackageType registryPackage = metacardMarshaller.getRegistryPackageFromMetacard(metacard);
String siteName = SystemInfo.getSiteName();
RegistryPackageTypeHelper registryPackageTypeHelper = new RegistryPackageTypeHelper();
registryPackageTypeHelper.getExtrinsicObjects(registryPackage.getRegistryObjectList()).stream().filter(extrinsicObjectType -> extrinsicObjectType.getObjectType().equals(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE)).findFirst().ifPresent(extrinsicObjectType -> extrinsicObjectType.setName(internationalStringTypeHelper.create(siteName)));
Metacard identityMetacard = getRegistryMetacardFromRegistryPackage(registryPackage);
if (identityMetacard != null) {
federationAdminService.updateRegistryEntry(identityMetacard);
}
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class FederationAdminTest method testCreateLocalEntryMissingAttributes.
@Test
public void testCreateLocalEntryMissingAttributes() throws Exception {
String metacardId = "metacardId";
RegistryPackageType registryObject = getRegistryObjectFromResource("/csw-full-registry-package.xml");
Map<String, Object> registryMap = getMapFromRegistryObject(registryObject);
registryMap.remove("id");
registryMap.remove("home");
registryMap.remove("objectType");
Metacard metacard = getTestMetacard();
when(registryTransformer.transform(any(InputStream.class))).thenReturn(metacard);
when(federationAdminService.addRegistryEntry(any(Metacard.class))).thenReturn(metacardId);
federationAdmin.createLocalEntry(registryMap);
ArgumentCaptor<InputStream> captor = ArgumentCaptor.forClass(InputStream.class);
verify(registryTransformer).transform(captor.capture());
String ebrim = IOUtils.toString(captor.getValue());
IOUtils.closeQuietly(captor.getValue());
assertXpathEvaluatesTo(SystemBaseUrl.getBaseUrl(), "/*[local-name() = 'RegistryPackage']/@home", ebrim);
assertXpathEvaluatesTo(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE, "/*[local-name() = 'RegistryPackage']/@objectType", ebrim);
assertXpathExists("/*[local-name() = 'RegistryPackage']/@id", ebrim);
}
Aggregations