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.marshaller.ItemPathHolder.java
public ItemPathHolder(List<PathHolderSegment> segments, boolean absolute) { this.segments = new ArrayList<>(); for (PathHolderSegment segment : segments) { if (segment.getQName() != null && StringUtils.isEmpty(segment.getQName().getPrefix())) { QName qname = segment.getQName(); this.segments.add(new PathHolderSegment(new QName(qname.getNamespaceURI(), qname.getLocalPart()))); } else {/*w w w . j ava2 s. com*/ this.segments.add(segment); } } // this.segments = segments; this.absolute = absolute; }
From source file:com.evolveum.midpoint.prism.crypto.ProtectorImpl.java
@Override public <T> void hash(ProtectedData<T> protectedData) throws EncryptionException, SchemaException { if (protectedData.isHashed()) { throw new IllegalArgumentException("Attempt to hash protected data that are already hashed"); }//from ww w . j av a 2s. c om String algorithmUri = getDigestAlgorithm(); QName algorithmQName = QNameUtil.uriToQName(algorithmUri); String algorithmNamespace = algorithmQName.getNamespaceURI(); if (algorithmNamespace == null) { throw new SchemaException("No algorithm namespace"); } HashedDataType hashedDataType; switch (algorithmNamespace) { case PrismConstants.NS_CRYPTO_ALGORITHM_PBKD: if (!protectedData.canSupportType(String.class)) { throw new SchemaException("Non-string proteted data"); } hashedDataType = hashPbkd((ProtectedData<String>) protectedData, algorithmUri, algorithmQName.getLocalPart()); break; default: throw new SchemaException("Unknown namespace " + algorithmNamespace); } protectedData.setHashedData(hashedDataType); protectedData.destroyCleartext(); protectedData.setEncryptedData(null); }
From source file:com.evolveum.midpoint.prism.marshaller.XPathHolder.java
public XPathHolder(List<XPathSegment> segments, boolean absolute) { this.segments = new ArrayList<XPathSegment>(); for (XPathSegment segment : segments) { if (segment.getQName() != null && StringUtils.isEmpty(segment.getQName().getPrefix())) { QName qname = segment.getQName(); this.segments.add(new XPathSegment(new QName(qname.getNamespaceURI(), qname.getLocalPart()))); } else {// w w w . j av a2 s. co m this.segments.add(segment); } } // this.segments = segments; this.absolute = absolute; }
From source file:com.evolveum.midpoint.prism.schema.SchemaToDomProcessor.java
/** * Set attribute in the DOM element to a string value. * @param element element element where to set attribute * @param attr attribute name (QName)/*from ww w . j av a 2 s . c o m*/ * @param attrValue attribute value (String) */ private void setAttribute(Element element, QName attr, String attrValue) { if (attributeQualified) { element.setAttributeNS(attr.getNamespaceURI(), attr.getLocalPart(), attrValue); addToImport(attr.getNamespaceURI()); } else { element.setAttribute(attr.getLocalPart(), attrValue); } }
From source file:com.evolveum.midpoint.prism.schema.SchemaToDomProcessor.java
private Element getOrCreateElement(QName qName, Element parentElement) { NodeList elements = parentElement.getElementsByTagNameNS(qName.getNamespaceURI(), qName.getLocalPart()); if (elements.getLength() == 0) { Element element = createElement(qName); Element refChild = DOMUtil.getFirstChildElement(parentElement); parentElement.insertBefore(element, refChild); return element; }/*from w w w. j a v a 2 s. c o m*/ return (Element) elements.item(0); }
From source file:com.evolveum.midpoint.prism.schema.SchemaToDomProcessor.java
/** * Create XML element with the correct namespace prefix and namespace definition. * @param qname element QName//from ww w . jav a2s .c o m * @return created DOM element */ public Element createElement(QName qname) { QName qnameWithPrefix = namespacePrefixMapper.setQNamePrefix(qname); addToImport(qname.getNamespaceURI()); if (rootXsdElement != null) { return DOMUtil.createElement(document, qnameWithPrefix, rootXsdElement, rootXsdElement); } else { // This is needed otherwise the root element itself could not be created return DOMUtil.createElement(document, qnameWithPrefix); } }
From source file:com.evolveum.midpoint.prism.marshaller.ItemPathHolder.java
public String toCanonicalPath(Class objectType, PrismContext prismContext) { StringBuilder sb = new StringBuilder("\\"); boolean first = true; PrismObjectDefinition objDef = null; if (objectType != null) { objDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(objectType); }//from w w w . j a v a 2 s . co m ItemDefinition def = null; for (PathHolderSegment seg : segments) { if (seg.isIdValueFilter()) { //for now, we don't want to save concrete id, just the path continue; } else { QName qname = seg.getQName(); if (!first) { sb.append("\\"); if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) { if (def instanceof PrismContainerDefinition) { PrismContainerDefinition containerDef = (PrismContainerDefinition) def; def = containerDef.findItemDefinition(qname); } if (def != null) { qname = def.getName(); } } } else { if (StringUtils.isBlank(qname.getNamespaceURI()) && objDef != null) { def = objDef.findItemDefinition(qname); if (def != null) { qname = def.getName(); } } first = false; } sb.append(QNameUtil.qNameToUri(qname)); } } return sb.toString(); }
From source file:com.evolveum.midpoint.prism.schema.SchemaToDomProcessor.java
/** * Adds XSD element definition created from the PrismReferenceDefinition. * TODO: need to finish/* w w w . ja va 2 s. co m*/ */ private void addReferenceDefinition(PrismReferenceDefinition definition, Element parent) { Element property = createElement(new QName(W3C_XML_SCHEMA_NS_URI, "element")); // Add to document first, so following methods will be able to resolve namespaces parent.appendChild(property); String attrNamespace = definition.getName().getNamespaceURI(); if (attrNamespace != null && attrNamespace.equals(getNamespace())) { setAttribute(property, "name", definition.getName().getLocalPart()); setQNameAttribute(property, "type", definition.getTypeName()); } else { setQNameAttribute(property, "ref", definition.getName()); } if (definition.getCompositeObjectElementName() == null) { setMultiplicityAttribute(property, "minOccurs", 0); } setMultiplicityAttribute(property, "maxOccurs", definition.getMaxOccurs()); // Add annotations Element annotation = createElement(new QName(W3C_XML_SCHEMA_NS_URI, "annotation")); property.appendChild(annotation); Element appinfo = createElement(new QName(W3C_XML_SCHEMA_NS_URI, "appinfo")); annotation.appendChild(appinfo); addAnnotation(A_OBJECT_REFERENCE, appinfo); if (definition.getTargetTypeName() != null) { addAnnotation(A_OBJECT_REFERENCE_TARGET_TYPE, definition.getTargetTypeName(), appinfo); } if (definition.getCompositeObjectElementName() == null) { return; } property = createElement(new QName(W3C_XML_SCHEMA_NS_URI, "element")); // Add to document first, so following methods will be able to resolve namespaces parent.appendChild(property); QName elementName = definition.getCompositeObjectElementName(); attrNamespace = elementName.getNamespaceURI(); if (attrNamespace != null && attrNamespace.equals(getNamespace())) { setAttribute(property, "name", elementName.getLocalPart()); setQNameAttribute(property, "type", definition.getTargetTypeName()); } else { setQNameAttribute(property, "ref", elementName); } setMultiplicityAttribute(property, "minOccurs", 0); setMultiplicityAttribute(property, "maxOccurs", definition.getMaxOccurs()); // Add annotations annotation = createElement(new QName(W3C_XML_SCHEMA_NS_URI, "annotation")); property.appendChild(annotation); appinfo = createElement(new QName(W3C_XML_SCHEMA_NS_URI, "appinfo")); annotation.appendChild(appinfo); addAnnotation(A_OBJECT_REFERENCE, definition.getName(), appinfo); if (definition.isComposite()) { addAnnotation(A_COMPOSITE, definition.isComposite(), appinfo); } SchemaDefinitionFactory definitionFactory = getDefinitionFactory(); definitionFactory.addExtraReferenceAnnotations(definition, appinfo, this); }
From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java
public <T> Class<T> getCompileTimeClass(QName xsdType) { SchemaDescription desc = getSchemaRegistry().findSchemaDescriptionByNamespace(xsdType.getNamespaceURI()); if (desc == null) { return null; }//from ww w . jav a 2s.c om Map<QName, Class<?>> map = desc.getXsdTypeTocompileTimeClassMap(); if (map == null) { return null; } return (Class<T>) map.get(xsdType); }
From source file:com.legstar.proxy.invoke.jaxws.WebServiceInvoker.java
/** * Try to extract something meaningful from a SOAP Fault. * /*from w w w.j av a 2 s . c o m*/ * @param e the SOAP Fault exception * @return a fault description */ @SuppressWarnings("rawtypes") public String getFaultReasonText(final SOAPFaultException e) { if (_log.isDebugEnabled()) { SOAPFault fault = e.getFault(); if (fault != null) { QName code = fault.getFaultCodeAsQName(); String string = fault.getFaultString(); String actor = fault.getFaultActor(); _log.debug("SOAP fault contains: "); _log.debug(" Fault code = " + code.toString()); _log.debug(" Local name = " + code.getLocalPart()); _log.debug(" Namespace prefix = " + code.getPrefix() + ", bound to " + code.getNamespaceURI()); _log.debug(" Fault string = " + string); if (actor != null) { _log.debug(" Fault actor = " + actor); } Detail detail = fault.getDetail(); if (detail != null) { Iterator entries = detail.getDetailEntries(); while (entries.hasNext()) { DetailEntry newEntry = (DetailEntry) entries.next(); String value = newEntry.getValue(); _log.debug(" Detail entry = " + value); } } } else { _log.debug(e); } } SOAPFault fault = e.getFault(); if (fault != null) { StringBuffer faultMessage = new StringBuffer(e.getFault().getFaultString()); Detail detail = fault.getDetail(); if (detail != null) { Iterator entries = detail.getDetailEntries(); while (entries.hasNext()) { DetailEntry newEntry = (DetailEntry) entries.next(); faultMessage.append(" [" + newEntry.getValue() + "]"); } } return faultMessage.toString(); } else { return e.getMessage(); } }