Search in sources :

Example 16 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class IdentificationPluginTest method testOtherExtIds.

//test ext IDs are not set to other items
@Test
public void testOtherExtIds() throws Exception {
    //unmarshal metacard.metadata and confirm both origin and local ext id are set to metacard.getId()
    String xml = convert("/registry-extra-extid.xml");
    sampleData.setAttribute(Metacard.METADATA, xml);
    CreateRequest result = identificationPlugin.process(new CreateRequestImpl(sampleData));
    Metacard testMetacard = result.getMetacards().get(0);
    String metadata = testMetacard.getMetadata();
    InputStream inputStream = new ByteArrayInputStream(metadata.getBytes(Charsets.UTF_8));
    JAXBElement<RegistryObjectType> registryObjectTypeJAXBElement = parser.unmarshal(configurator, JAXBElement.class, inputStream);
    RegistryObjectType registryObjectType = registryObjectTypeJAXBElement.getValue();
    List<ExternalIdentifierType> extIdList = registryObjectType.getExternalIdentifier();
    for (ExternalIdentifierType singleExtId : extIdList) {
        if (singleExtId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_LOCAL)) {
            assertThat(singleExtId.getValue(), is(testMetacard.getId()));
        } else if (singleExtId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN)) {
            assertThat(singleExtId.getValue(), is(testMetacard.getId()));
        }
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) ByteArrayInputStream(java.io.ByteArrayInputStream) CreateRequest(ddf.catalog.operation.CreateRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) Test(org.junit.Test)

Example 17 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class RegistryTransformer method unmarshal.

private Metacard unmarshal(InputStream xmlStream) throws ParserException, RegistryConversionException {
    MetacardImpl metacard = null;
    JAXBElement<RegistryObjectType> registryObjectTypeJAXBElement = parser.unmarshal(configurator, JAXBElement.class, xmlStream);
    if (registryObjectTypeJAXBElement != null) {
        RegistryObjectType registryObjectType = registryObjectTypeJAXBElement.getValue();
        if (registryObjectType != null) {
            metacard = (MetacardImpl) RegistryPackageConverter.getRegistryObjectMetacard(registryObjectType, registryMetacardType);
        }
    }
    return metacard;
}
Also used : RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 18 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class RegistryTransformerTest method testJaxbElementNullValue.

@Test(expected = CatalogTransformerException.class)
public void testJaxbElementNullValue() throws Exception {
    JAXBElement<RegistryObjectType> mockRegistryObjectType = Mockito.mock(JAXBElement.class);
    when((mockRegistryObjectType).getValue()).thenReturn(null);
    Parser mockParser = Mockito.mock(Parser.class);
    when((mockParser).unmarshal(any(ParserConfigurator.class), any(Class.class), any(InputStream.class))).thenReturn(mockRegistryObjectType);
    registryTransformer.setParser(mockParser);
    convert("/csw-basic-info.xml");
}
Also used : ParserConfigurator(org.codice.ddf.parser.ParserConfigurator) InputStream(java.io.InputStream) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) XmlParser(org.codice.ddf.parser.xml.XmlParser) Parser(org.codice.ddf.parser.Parser) Test(org.junit.Test)

Example 19 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class FederationAdmin method updateDateFields.

private void updateDateFields(RegistryPackageType rpt) {
    ExtrinsicObjectType nodeInfo = null;
    for (JAXBElement identifiable : rpt.getRegistryObjectList().getIdentifiable()) {
        RegistryObjectType registryObject = (RegistryObjectType) identifiable.getValue();
        if (registryObject instanceof ExtrinsicObjectType && RegistryConstants.REGISTRY_NODE_OBJECT_TYPE.equals(registryObject.getObjectType())) {
            nodeInfo = (ExtrinsicObjectType) registryObject;
            break;
        }
    }
    if (nodeInfo != null) {
        boolean liveDateFound = false;
        boolean lastUpdatedFound = false;
        OffsetDateTime now = OffsetDateTime.now(ZoneId.of(ZoneOffset.UTC.toString()));
        String rightNow = now.toString();
        for (SlotType1 slot : nodeInfo.getSlot()) {
            if (slot.getName().equals(RegistryConstants.XML_LIVE_DATE_NAME)) {
                liveDateFound = true;
            } else if (slot.getName().equals(RegistryConstants.XML_LAST_UPDATED_NAME)) {
                ValueListType valueList = EbrimConstants.RIM_FACTORY.createValueListType();
                valueList.getValue().add(rightNow);
                slot.setValueList(EbrimConstants.RIM_FACTORY.createValueList(valueList));
                lastUpdatedFound = true;
            }
        }
        if (!liveDateFound) {
            SlotType1 liveDate = slotHelper.create(RegistryConstants.XML_LIVE_DATE_NAME, rightNow, DATE_TIME);
            nodeInfo.getSlot().add(liveDate);
        }
        if (!lastUpdatedFound) {
            SlotType1 lastUpdated = slotHelper.create(RegistryConstants.XML_LAST_UPDATED_NAME, rightNow, DATE_TIME);
            nodeInfo.getSlot().add(lastUpdated);
        }
    }
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) OffsetDateTime(java.time.OffsetDateTime) ValueListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ValueListType) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) JAXBElement(javax.xml.bind.JAXBElement) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 20 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class SlotTypeHelperTest method testGetNameSlotMap.

@Test
public void testGetNameSlotMap() throws Exception {
    RegistryObjectType rot = getRegistryObjectFromResource("/registry-package-slots-only-with-dup.xml");
    List<SlotType1> slots = rot.getSlot();
    String specialSlotCase = "serviceType";
    String expectedServiceType = "SOAP";
    Map<String, SlotType1> slotMap = stHelper.getNameSlotMap(slots);
    for (SlotType1 slot : slots) {
        String slotName = slot.getName();
        // Skip special case which will be tested below
        if (specialSlotCase.equals(slotName)) {
            continue;
        }
        assertThat(slotMap, hasKey(slotName));
        SlotType1 mappedSlot = slotMap.get(slotName);
        assertThat(mappedSlot, is(equalTo(slot)));
    }
    // ServiceType slot is repeated in the test xml
    // Testing that the second one (SOAP)is stored
    SlotType1 serviceType = slotMap.get(specialSlotCase);
    assertThat(serviceType, notNullValue());
    String value = stHelper.getStringValues(serviceType).get(0);
    assertThat(value, is(equalTo(expectedServiceType)));
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) Test(org.junit.Test)

Aggregations

RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)16 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 Map (java.util.Map)6 Test (org.junit.Test)6 InputStream (java.io.InputStream)5 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ExternalIdentifierType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)4 OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)4 PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)4 ServiceType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType)4 SlotType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1)4 Metacard (ddf.catalog.data.Metacard)3 CreateRequest (ddf.catalog.operation.CreateRequest)3 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)3 JAXBElement (javax.xml.bind.JAXBElement)3 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)3 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)2