List of usage examples for javax.xml.namespace QName getLocalPart
public String getLocalPart()
Get the local part of this QName
.
From source file:eu.esdihumboldt.hale.io.wfs.ui.KVPUtil.java
/** * Add typename and namespace parameters for a WFS request to the given URI * builder./*from ww w. j a v a 2 s . c o m*/ * * @param builder the builder for the WFS request URI * @param selected the type names to include * @param version the targeted WFS version */ public static void addTypeNameParameter(URIBuilder builder, Iterable<QName> selected, WFSVersion version) { // namespaces mapped to prefixes Map<String, String> namespaces = new HashMap<>(); // type names with updated prefix Set<QName> typeNames = new HashSet<>(); for (QName type : selected) { String prefix; if (type.getNamespaceURI() != null && !type.getNamespaceURI().isEmpty()) { prefix = namespaces.get(type.getNamespaceURI()); if (prefix == null) { // no mapping yet for namespace String candidate = type.getPrefix(); prefix = addPrefix(candidate, type.getNamespaceURI(), namespaces); } } else { // default namespace prefix = XMLConstants.DEFAULT_NS_PREFIX; } // add updated type typeNames.add(new QName(type.getNamespaceURI(), type.getLocalPart(), prefix)); } final String paramNamespaces; final String paramTypenames; final String prefixNamespaceDelim; switch (version) { case V1_1_0: paramNamespaces = "NAMESPACE"; paramTypenames = "TYPENAME"; prefixNamespaceDelim = "="; break; case V2_0_0: case V2_0_2: /* * XXX below are the values as defined in the WFS 2 specification. * There have been problems with some GeoServer instances if used in * that manner. */ paramNamespaces = "NAMESPACES"; paramTypenames = "TYPENAMES"; prefixNamespaceDelim = ","; break; default: // fall-back to WFS 1.1 paramNamespaces = "NAMESPACE"; paramTypenames = "TYPENAME"; prefixNamespaceDelim = "="; } // add namespace prefix definitions if (!namespaces.isEmpty()) { builder.addParameter(paramNamespaces, Joiner.on(',') .join(Maps.transformEntries(namespaces, new EntryTransformer<String, String, String>() { @Override public String transformEntry(String namespace, String prefix) { StringBuilder sb = new StringBuilder(); sb.append("xmlns("); sb.append(prefix); sb.append(prefixNamespaceDelim); sb.append(namespace); sb.append(")"); return sb.toString(); } }).values())); } // add type names if (!typeNames.isEmpty()) { builder.addParameter(paramTypenames, Joiner.on(',').join(Iterables.transform(typeNames, new Function<QName, String>() { @Override public String apply(QName typeName) { String prefix = typeName.getPrefix(); if (prefix == null || prefix.isEmpty()) { return typeName.getLocalPart(); } return prefix + ":" + typeName.getLocalPart(); } }))); } }
From source file:edu.internet2.middleware.openid.message.encoding.EncodingUtils.java
/** * Build an appropriate namespaced parameter name for a {@link QName}. * /*from w w w .ja va 2s. co m*/ * @param qname QName to convert into parameter name * @param namespaces map of registered namespaces * @return namespaced parameter name */ public static String encodeParameterName(QName qname, NamespaceMap namespaces) { String parameter; String namespaceAlias = namespaces.getAlias(qname.getNamespaceURI()); if (qname instanceof NamespaceQName) { // parameter name is for a namespace declaration parameter = "ns"; if (namespaceAlias != XMLConstants.DEFAULT_NS_PREFIX) { parameter += "." + namespaceAlias; } } else { // otherwise, parameter name is for a message parameter parameter = qname.getLocalPart(); if (namespaceAlias != XMLConstants.DEFAULT_NS_PREFIX) { parameter = namespaceAlias + "." + parameter; } } return parameter; }
From source file:com.evolveum.midpoint.web.component.wizard.resource.SynchronizationStep.java
private static String getTypeDisplayName(@NotNull QName name) { return StringUtils.removeEnd(name.getLocalPart(), "Type"); }
From source file:com.evolveum.midpoint.schema.constants.ObjectTypes.java
public static ObjectTypes getObjectTypeFromTypeQName(QName typeQName) { if (typeQName == null) { return null; }//from w ww . j a v a 2 s .co m // HACK WARNING! FIXME // UGLY HORRIBLE TERRIBLE AWFUL HACK FOLLOWS // The JAXB fails to correctly process QNames in default namespace (no prefix) // e.g it will not understand this: type="RoleType", even if defatult namespace // is set, it will parse it as null namespace. // Therefore substitute null namespace with common namespace if (typeQName.getNamespaceURI() == null || typeQName.getNamespaceURI().isEmpty()) { typeQName = new QName(SchemaConstants.NS_C, typeQName.getLocalPart()); } // END OF UGLY HACK for (ObjectTypes type : values()) { if (QNameUtil.match(type.getTypeQName(), typeQName)) { return type; } } throw new IllegalArgumentException("Unsupported object type qname " + typeQName); }
From source file:com.evolveum.midpoint.web.component.prism.ContainerValueWrapper.java
static String getDisplayNameFromItem(Item item) { Validate.notNull(item, "Item must not be null."); String displayName = item.getDisplayName(); if (StringUtils.isEmpty(displayName)) { QName name = item.getElementName(); if (name != null) { displayName = name.getLocalPart(); } else {/*from w w w . j a va2 s. co m*/ displayName = item.getDefinition().getTypeName().getLocalPart(); } } return displayName; }
From source file:org.eclipse.winery.repository.client.WineryRepositoryClient.java
private static WebResource getTopologyTemplateWebResource(WebResource base, QName serviceTemplate) { String nsEncoded = Util.DoubleURLencode(serviceTemplate.getNamespaceURI()); String idEncoded = Util.DoubleURLencode(serviceTemplate.getLocalPart()); WebResource res = base.path("servicetemplates").path(nsEncoded).path(idEncoded).path("topologytemplate"); return res;//from w ww .j av a 2 s .com }
From source file:com.evolveum.midpoint.test.util.MidPointAsserts.java
public static void assertAssigned(PrismObject<? extends FocusType> focus, String targetOid, QName refType, QName relation) {/*from w w w . ja v a2s . c o m*/ FocusType focusType = focus.asObjectable(); for (AssignmentType assignmentType : focusType.getAssignment()) { ObjectReferenceType targetRef = assignmentType.getTargetRef(); if (targetRef != null) { if (refType.equals(targetRef.getType())) { if (targetOid.equals(targetRef.getOid()) && MiscSchemaUtil.compareRelation(targetRef.getRelation(), relation)) { return; } } } } AssertJUnit.fail(focus + " does not have assigned " + refType.getLocalPart() + " " + targetOid + ", relation " + relation); }
From source file:com.evolveum.midpoint.schema.util.ShadowUtil.java
public static ResourceAttributeContainer getAttributesContainer(PrismContainerValue<?> cval, QName containerName) { PrismContainer attributesContainer = cval.findContainer(containerName); if (attributesContainer == null) { return null; }/*w w w . j a v a 2s.c o m*/ if (attributesContainer instanceof ResourceAttributeContainer) { return (ResourceAttributeContainer) attributesContainer; } else { throw new SystemException("Expected that <" + containerName.getLocalPart() + "> will be ResourceAttributeContainer but it is " + attributesContainer.getClass()); } }
From source file:com.evolveum.midpoint.model.impl.validator.ResourceValidatorImpl.java
public static String prettyPrintUsingStandardPrefix(QName name) { if (name == null) { return null; }//w w w .ja va2s . co m String ns = name.getNamespaceURI(); if (SchemaConstants.NS_C.equals(ns)) { return "c:" + name.getLocalPart(); } else if (MidPointConstants.NS_RI.equals(ns)) { return "ri:" + name.getLocalPart(); } else if (SchemaConstantsGenerated.NS_ICF_SCHEMA.equals(ns)) { return "icfs:" + name.getLocalPart(); } else if (SchemaConstantsGenerated.NS_ICF_SCHEMA.equals(ns)) { return "icfs:" + name.getLocalPart(); } else { return null; } }
From source file:org.eclipse.winery.repository.Utils.java
public static Set<QName> cleanQNameSet(Set<QName> set) { Set<QName> newSet = new HashSet<QName>(); for (QName setItem : set) { if (setItem != null && !setItem.getLocalPart().equals("null")) { newSet.add(setItem);/*from w w w .j av a 2 s. c om*/ } } return newSet; }