Search in sources :

Example 26 with RegistryPackageType

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);
    }
}
Also used : ParserException(org.codice.ddf.parser.ParserException) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 27 with RegistryPackageType

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));
}
Also used : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) Test(org.junit.Test)

Example 28 with RegistryPackageType

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);
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) OffsetDateTime(java.time.OffsetDateTime) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) VersionInfoType(oasis.names.tc.ebxml_regrep.xsd.rim._3.VersionInfoType)

Example 29 with RegistryPackageType

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);
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) RegistryPackageTypeHelper(org.codice.ddf.registry.schemabindings.helper.RegistryPackageTypeHelper)

Example 30 with RegistryPackageType

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);
}
Also used : Metacard(ddf.catalog.data.Metacard) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) InputStream(java.io.InputStream) Test(org.junit.Test)

Aggregations

RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)46 Test (org.junit.Test)26 Metacard (ddf.catalog.data.Metacard)16 InputStream (java.io.InputStream)12 RegistryObjectListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType)11 ArrayList (java.util.ArrayList)9 JAXBElement (javax.xml.bind.JAXBElement)9 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)9 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)7 HashMap (java.util.HashMap)5 IOException (java.io.IOException)4 Map (java.util.Map)4 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)4 OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)4 PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)4 RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)4 ParserConfigurator (org.codice.ddf.parser.ParserConfigurator)4 FederationAdminException (org.codice.ddf.registry.federationadmin.service.internal.FederationAdminException)4 QueryRequest (ddf.catalog.operation.QueryRequest)3 QueryResponse (ddf.catalog.operation.QueryResponse)3