Search in sources :

Example 16 with RegistryPackageType

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

Example 17 with RegistryPackageType

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

Example 18 with RegistryPackageType

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));
}
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 19 with RegistryPackageType

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");
    }
}
Also used : ParserException(org.codice.ddf.parser.ParserException) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) StopProcessingException(ddf.catalog.plugin.StopProcessingException)

Example 20 with RegistryPackageType

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