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()));
}
}
}
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;
}
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");
}
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);
}
}
}
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)));
}
Aggregations