use of org.opencastproject.util.XmlNamespaceContext in project opencast by opencast.
the class SchedulerServiceImplTest method generateExtendedEvent.
protected static DublinCoreCatalog generateExtendedEvent(Opt<String> eventId, String flavorType) {
DublinCoreCatalog dc = DublinCores.mkStandard();
final Map<String, String> prefixToUri = new HashMap<>();
prefixToUri.put("", "http://test.com/video/opencast");
prefixToUri.put("extended", "http://test.com/video/metadata");
dc.addBindings(new XmlNamespaceContext(prefixToUri));
dc.setRootTag(new EName("http://test.com/video/opencast", "extended"));
dc.setFlavor(new MediaPackageElementFlavor(flavorType, "episode"));
dc.set(PROPERTY_IDENTIFIER, eventId.getOr("1"));
dc.set(PROPERTY_EXTENT, "demo");
return dc;
}
use of org.opencastproject.util.XmlNamespaceContext in project opencast by opencast.
the class CatalogUIAdapterConfiguration method loadXmlNSContext.
/**
* Load the XML namespace bindings from the configuration and build the XML namespace context.
*/
private void loadXmlNSContext() {
final Enumeration<String> keys = configProperties.keys();
final Map<String, String> prefixToUri = new HashMap<String, String>();
while (keys.hasMoreElements()) {
final String key = keys.nextElement();
if (key.startsWith(XML_BINDING_KEY_PREFIX)) {
// First, we need to get the name of the binding
final String nsBindingName = getXmlBindingNameFromConfigKey(key);
// Once we have the name, we're able to retrieve the URI as well as the prefix
final String nsUri = (String) configProperties.get(XML_BINDING_KEY_PREFIX + nsBindingName + XML_BINDING_URI_SUFFIX);
final String nsPrefix = (String) configProperties.get(XML_BINDING_KEY_PREFIX + nsBindingName + XML_BINDING_PREFIX_SUFFIX);
// Check if URI and the prefix have valid values
if (isBlank(nsUri))
throw new ConfigurationException(format("No URI for namespace binding '%s' found", nsBindingName));
if (nsPrefix == null)
throw new ConfigurationException(format("No prefix for namespace binding '%s' found", nsBindingName));
// Add prefix & URI to the intermediate map
prefixToUri.put(nsPrefix, nsUri);
}
}
xmlNSContext = new XmlNamespaceContext(prefixToUri);
}
Aggregations