use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.
the class ServiceBindingWebConverter method convert.
/**
* This method creates a Map<String, Object> representation of the ServiceBindingType provided.
* The following keys will be added to the map (Taken from EbrimConstants):
* <p>
* ACCESS_URI = "accessUri";
* SERVICE = "service";
* TARGET_BINDING = "targetBinding";
* SPECIFICATION_LINK_KEY = "SpecificationLink";
* <p>
* This will also try to parse RegistryObjectType values to the map.
* <p>
* Uses:
* SpecificationLinkWebConverter
*
* @param binding the ServiceBindingType to be converted into a map, null returns empty Map
* @return Map<String, Object> representation of the ServiceBindingType provided
*/
public Map<String, Object> convert(ServiceBindingType binding) {
Map<String, Object> bindingMap = new HashMap<>();
if (binding == null) {
return bindingMap;
}
webMapHelper.putAllIfNotEmpty(bindingMap, super.convertRegistryObject(binding));
webMapHelper.putIfNotEmpty(bindingMap, ACCESS_URI, binding.getAccessURI());
webMapHelper.putIfNotEmpty(bindingMap, SERVICE, binding.getService());
if (binding.isSetSpecificationLink()) {
List<Map<String, Object>> specificationLinks = new ArrayList<>();
SpecificationLinkWebConverter specificationLinkConverter = new SpecificationLinkWebConverter();
for (SpecificationLinkType specificationLink : binding.getSpecificationLink()) {
Map<String, Object> specificationLinkMap = specificationLinkConverter.convert(specificationLink);
if (MapUtils.isNotEmpty(specificationLinkMap)) {
specificationLinks.add(specificationLinkMap);
}
}
webMapHelper.putIfNotEmpty(bindingMap, SPECIFICATION_LINK_KEY, specificationLinks);
}
webMapHelper.putIfNotEmpty(bindingMap, TARGET_BINDING, binding.getTargetBinding());
return bindingMap;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.
the class RegistryPackageTypeHelperTest method getRegistryObjectFromResource.
private static RegistryObjectType getRegistryObjectFromResource(String path) throws ParserException {
RegistryObjectType rot = null;
JAXBElement<RegistryObjectType> jaxbRegistryObject = parser.unmarshal(configurator, JAXBElement.class, SlotTypeHelperTest.class.getResourceAsStream(path));
if (jaxbRegistryObject != null) {
rot = jaxbRegistryObject.getValue();
}
return rot;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.
the class SlotTypeHelperTest method getNameSlotMapDuplicateSlotNamesAllowed.
@Test
public void getNameSlotMapDuplicateSlotNamesAllowed() throws Exception {
RegistryObjectType rot = getRegistryObjectFromResource("/registry-package-slots-only-with-dup.xml");
List<SlotType1> slots = rot.getSlot();
String duplicateSlotCase = "serviceType";
int expectedSize = 1;
int expectedServiceTypeSize = 2;
Map<String, List<SlotType1>> slotMap = stHelper.getNameSlotMapDuplicateSlotNamesAllowed(slots);
for (SlotType1 slot : slots) {
String slotName = slot.getName();
// duplicate slotCase
if (duplicateSlotCase.equals(slotName)) {
continue;
}
assertThat(slotMap, hasKey(slotName));
assertThat(slotMap.get(slotName), hasSize(expectedSize));
SlotType1 mappedSlot = slotMap.get(slotName).get(0);
assertThat(mappedSlot, is(equalTo(slot)));
}
// ServiceType slot is repeated in the test xml
// Testing that both slots(SOAP & REST) are stored
List<SlotType1> serviceTypes = slotMap.get(duplicateSlotCase);
assertThat(serviceTypes, notNullValue());
assertThat(serviceTypes, hasSize(expectedServiceTypeSize));
for (SlotType1 serviceTypeSlot : serviceTypes) {
String value = stHelper.getStringValues(serviceTypeSlot).get(0);
assertThat(value, anyOf(equalTo("SOAP"), equalTo("REST")));
}
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.
the class ServiceWebConverter method convert.
/**
* This method creates a Map<String, Object> representation of the ServiceType provided.
* The following keys will be added to the map (Taken from EbrimConstants):
* <p>
* SERVICE_BINDING_KEY = "ServiceBinding";
* <p>
* This will also try to parse RegistryObjectType values to the map.
* <p>
* Uses:
* ServiceBindingWebConverter
*
* @param service the ServiceType to be converted into a map, null returns empty Map
* @return Map<String, Object> representation of the ServiceType provided
*/
public Map<String, Object> convert(ServiceType service) {
Map<String, Object> serviceMap = new HashMap<>();
if (service == null) {
return serviceMap;
}
webMapHelper.putAllIfNotEmpty(serviceMap, super.convertRegistryObject(service));
if (service.isSetServiceBinding()) {
List<Map<String, Object>> bindings = new ArrayList<>();
ServiceBindingWebConverter bindingConverter = new ServiceBindingWebConverter();
for (ServiceBindingType binding : service.getServiceBinding()) {
Map<String, Object> bindingMap = bindingConverter.convert(binding);
if (MapUtils.isNotEmpty(bindingMap)) {
bindings.add(bindingMap);
}
}
webMapHelper.putIfNotEmpty(serviceMap, SERVICE_BINDING_KEY, bindings);
}
return serviceMap;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.
the class IdentificationPluginTest method testIdsAlreadySet.
//test both ids are already set
@Test
public void testIdsAlreadySet() throws Exception {
//unmarshal metacard.metadata and confirm only local ext id are set to metacard.getId()
String xml = convert("/registry-both-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.getId(), is(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN));
assertThat(singleExtId.getValue(), is("registryPresetOriginValue"));
}
}
}
Aggregations