List of usage examples for javax.xml.namespace QName getNamespaceURI
public String getNamespaceURI()
Get the Namespace URI of this QName
.
From source file:com.evolveum.midpoint.prism.PrismContainerDefinition.java
public <ID extends ItemDefinition> ID findNamedItemDefinition(QName firstName, ItemPath rest, Class<ID> clazz) { // we need to be compatible with older versions..soo if the path does // not contains qnames with namespaces defined (but the prefix was // specified) match definition according to the local name if (StringUtils.isEmpty(firstName.getNamespaceURI())) { for (ItemDefinition def : getDefinitions()) { if (QNameUtil.match(firstName, def.getName())) { return (ID) def.findItemDefinition(rest, clazz); }//from w w w . j ava 2 s .c o m } } for (ItemDefinition def : getDefinitions()) { if (firstName.equals(def.getName())) { return (ID) def.findItemDefinition(rest, clazz); } } if (isRuntimeSchema()) { return findRuntimeItemDefinition(firstName, rest, clazz); } return null; }
From source file:com.evolveum.midpoint.util.DOMUtil.java
public static void validateNonEmptyQName(QName qname, String shortDescription, boolean allowEmptyNamespace) { if (qname == null) { throw new IllegalArgumentException("null" + shortDescription); }//ww w . j av a2 s .c o m // This is hard to enforce. There are situations where unmarshalling // object reference types as ObjectReferenceType, not as prism references. // (E.g. when dealing with reference variables in mappigns/expressions.) // In these cases we need to qualify types after the unmarshalling is complete. if (!allowEmptyNamespace && StringUtils.isEmpty(qname.getNamespaceURI())) { throw new IllegalArgumentException("Missing namespace" + shortDescription); } if (StringUtils.isEmpty(qname.getLocalPart())) { throw new IllegalArgumentException("Missing local part" + shortDescription); } }
From source file:eu.playproject.platform.service.bootstrap.DSBTopicManager.java
@Override public Subscription subscribe(String producer, QName topic, String subscriber) throws BootstrapFault { Subscription subscription = null;/*from w ww . j a v a 2 s . c om*/ logger.info("Subscribe to topic '" + topic + "' on producer '" + producer + "' for subscriber '" + subscriber + "'"); HTTPProducerClient client = new HTTPProducerClient(producer); try { String id = client.subscribe(topic, subscriber); logger.info("Subscribed to topic " + topic + " and ID is " + id); subscription = new Subscription(); subscription.setDate(System.currentTimeMillis()); subscription.setId(id); subscription.setProvider(producer); subscription.setSubscriber(subscriber); Topic t = new Topic(); t.setName(topic.getLocalPart()); t.setNs(topic.getNamespaceURI()); t.setPrefix(topic.getPrefix()); subscription.setTopic(t); this.subscriptionRegistry.addSubscription(subscription); } catch (NotificationException e) { logger.log(Level.SEVERE, "Problem while subscribing", e); throw new BootstrapFault(e); } catch (GovernanceExeption e) { logger.log(Level.WARNING, "Problem while saving subscription", e); //throw new BootstrapFault(e); } return subscription; }
From source file:com._4dconcept.springframework.data.marklogic.core.MarklogicTemplate.java
private XName buildVariableName(QName name) { return new XName(name.getNamespaceURI(), name.getLocalPart()); }
From source file:com.evolveum.midpoint.prism.marshaller.ItemPathHolder.java
public ItemPathHolder(ItemPath itemPath, boolean forceExplicitNamespaceDeclarations) { if (itemPath.getNamespaceMap() != null) { this.explicitNamespaceDeclarations.putAll(itemPath.getNamespaceMap()); }/* w ww .java 2s .c o m*/ this.segments = new ArrayList<>(); for (ItemPathSegment segment : itemPath.getSegments()) { PathHolderSegment xsegment; if (segment instanceof NameItemPathSegment) { boolean variable = segment.isVariable(); QName name = ((NameItemPathSegment) segment).getName(); xsegment = new PathHolderSegment(name, variable); if (forceExplicitNamespaceDeclarations && StringUtils.isNotEmpty(name.getPrefix())) { this.explicitNamespaceDeclarations.put(name.getPrefix(), name.getNamespaceURI()); } } else if (segment instanceof IdItemPathSegment) { xsegment = new PathHolderSegment(idToString(((IdItemPathSegment) segment).getId())); } else if (segment instanceof ObjectReferencePathSegment) { xsegment = new PathHolderSegment(PrismConstants.T_OBJECT_REFERENCE, false); } else if (segment instanceof ParentPathSegment) { xsegment = new PathHolderSegment(PrismConstants.T_PARENT, false); } else if (segment instanceof IdentifierPathSegment) { xsegment = new PathHolderSegment(PrismConstants.T_ID, false); } else { throw new IllegalStateException("Unknown segment: " + segment); } this.segments.add(xsegment); } this.absolute = false; }
From source file:com.evolveum.midpoint.prism.lex.json.AbstractJsonLexicalProcessor.java
private String determineNewCurrentNamespace(MapXNode map, JsonSerializationContext ctx) { Map<String, Integer> counts = new HashMap<>(); for (QName childName : map.keySet()) { String childNs = childName.getNamespaceURI(); if (StringUtils.isEmpty(childNs)) { continue; }/*from www . j a v a 2 s .c om*/ if (childNs.equals(ctx.currentNamespace)) { return ctx.currentNamespace; // found existing => continue with it } increaseCounter(counts, childNs); } if (map.getElementName() != null && QNameUtil.hasNamespace(map.getElementName())) { increaseCounter(counts, map.getElementName().getNamespaceURI()); } // otherwise, take the URI that occurs the most in the map Entry<String, Integer> max = null; for (Entry<String, Integer> count : counts.entrySet()) { if (max == null || count.getValue() > max.getValue()) { max = count; } } return max != null ? max.getKey() : null; }
From source file:com.evolveum.midpoint.prism.lex.json.AbstractJsonLexicalProcessor.java
private String createKeyUri(Entry<QName, XNode> entry, JsonSerializationContext ctx) { QName key = entry.getKey(); if (namespaceMatch(ctx.currentNamespace, key.getNamespaceURI())) { return key.getLocalPart(); } else if (StringUtils.isNotEmpty(ctx.currentNamespace) && !isAttribute(entry.getValue())) { return QNameUtil.qNameToUri(key, true); // items with no namespace should be written as such (starting with '#') } else {//from www. j a va 2 s.c o m return QNameUtil.qNameToUri(key, false); // items with no namespace can be written in plain } }
From source file:com.evolveum.midpoint.prism.lex.json.AbstractJsonLexicalProcessor.java
private String createElementNameUri(QName elementName, JsonSerializationContext ctx) { if (namespaceMatch(ctx.currentNamespace, elementName.getNamespaceURI())) { return elementName.getLocalPart(); } else {/* w ww .ja va 2 s .c o m*/ return QNameUtil.qNameToUri(elementName, StringUtils.isNotEmpty(ctx.currentNamespace)); } }
From source file:com.evolveum.midpoint.web.component.input.QNameEditorPanel.java
public QNameEditorPanel(String id, IModel<ItemPathType> model, String localPartTooltipKey, String namespaceTooltipKey, boolean markLocalPartAsRequired, boolean markNamespaceAsRequired) { super(id, model); this.itemPathModel = model; localpartModel = new IModel<String>() { @Override//from ww w . ja va2s .co m public String getObject() { QName qName = itemPathToQName(); return qName != null ? qName.getLocalPart() : null; } @Override public void setObject(String object) { if (object == null) { itemPathModel.setObject(null); } else { itemPathModel.setObject( new ItemPathType(new ItemPath(new QName(namespaceModel.getObject(), object)))); } } @Override public void detach() { } }; namespaceModel = new IModel<String>() { @Override public String getObject() { QName qName = itemPathToQName(); return qName != null ? qName.getNamespaceURI() : null; } @Override public void setObject(String object) { if (StringUtils.isBlank(localpartModel.getObject())) { itemPathModel.setObject(null); } else { itemPathModel.setObject( new ItemPathType(new ItemPath(new QName(object, localpartModel.getObject())))); } } @Override public void detach() { } }; initLayout(localPartTooltipKey, namespaceTooltipKey, markLocalPartAsRequired, markNamespaceAsRequired); }
From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java
public <T> Element marshalObjectToDom(T jaxbObject, QName elementQName, Document doc) throws JAXBException { if (doc == null) { doc = DOMUtil.getDocument();//from www. j a v a2 s . co m } JAXBElement<T> jaxbElement = new JAXBElement<T>(elementQName, (Class<T>) jaxbObject.getClass(), jaxbObject); Element element = doc.createElementNS(elementQName.getNamespaceURI(), elementQName.getLocalPart()); marshalElementToDom(jaxbElement, element); return (Element) element.getFirstChild(); }