List of usage examples for org.w3c.dom Element getAttributeNS
public String getAttributeNS(String namespaceURI, String localName) throws DOMException;
From source file:com.evolveum.midpoint.util.DOMUtil.java
public static String getAttribute(Element element, QName attrQname) { String attr = element.getAttributeNS(attrQname.getNamespaceURI(), attrQname.getLocalPart()); if (StringUtils.isEmpty(attr)) { // also try without the namespace attr = element.getAttribute(attrQname.getLocalPart()); }//from www . j a v a2s. c o m return attr; }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.principalConnector.StoredIDPrincipalConnectorBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) { super.doParse(pluginId, pluginConfig, pluginConfigChildren, pluginBuilder, parserContext); pluginBuilder.addPropertyReference("idProducer", DatatypeHelper.safeTrimOrNullString(pluginConfig.getAttributeNS(null, "storedIdDataConnectorRef"))); boolean noResultsIsError = false; if (pluginConfig.hasAttributeNS(null, "noResultIsError")) { noResultsIsError = XMLHelper/* www.j av a2 s. co m*/ .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "noResultIsError")); } pluginBuilder.addPropertyValue("noResultIsError", noResultsIsError); }
From source file:com.evolveum.midpoint.util.DOMUtil.java
public static QName getQNameAttribute(Element element, QName attributeName) { String attrContent = element.getAttributeNS(attributeName.getNamespaceURI(), attributeName.getLocalPart()); if (StringUtils.isBlank(attrContent)) { return null; }//from w ww. java 2 s. c o m return resolveQName(element, attrContent); }
From source file:info.joseluismartin.gtc.WmsCache.java
/** * {@inheritDoc}// w w w . j a va2s. c o m * @throws IOException */ @Override public InputStream parseResponse(InputStream serverStream, String remoteUri, String localUri) throws IOException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(remoteUri); UriComponents remoteComponents = builder.build(); String localUrl = localUri + "/" + getPath(); InputStream is = serverStream; MultiValueMap<String, String> params = remoteComponents.getQueryParams(); if (GET_CAPABILITIES.equals(params.getFirst(REQUEST))) { String response = IOUtils.toString(serverStream); Document doc = XMLUtils.newDocument(response); if (log.isDebugEnabled()) XMLUtils.prettyDocumentToString(doc); // Fix GetMapUrl Element getMapElement = (Element) doc.getElementsByTagName(GET_MAP).item(0); if (getMapElement != null) { if (log.isDebugEnabled()) { log.debug("Found GetMapUrl: " + this.getMapUrl); } NodeList nl = getMapElement.getElementsByTagName(ONLINE_RESOURCE_ELEMENT); if (nl.getLength() > 0) { Element resource = (Element) nl.item(0); if (resource.hasAttributeNS(XLINK_NS, HREF_ATTRIBUTE)) { this.getMapUrl = resource.getAttributeNS(XLINK_NS, HREF_ATTRIBUTE).replace("?", ""); resource.setAttributeNS(XLINK_NS, HREF_ATTRIBUTE, localUrl); } } } // Fix GetFeatureInfoUrl Element getFeatureElement = (Element) doc.getElementsByTagName(GET_FEATURE_INFO).item(0); if (getFeatureElement != null) { if (log.isDebugEnabled()) { log.debug("Found GetFeatureInfoUrl: " + this.getFeatureInfoUrl); } NodeList nl = getFeatureElement.getElementsByTagName(ONLINE_RESOURCE_ELEMENT); if (nl.getLength() > 0) { Element resource = (Element) nl.item(0); if (resource.hasAttributeNS(XLINK_NS, HREF_ATTRIBUTE)) { this.getFeatureInfoUrl = resource.getAttributeNS(XLINK_NS, HREF_ATTRIBUTE).replace("?", ""); resource.setAttributeNS(XLINK_NS, HREF_ATTRIBUTE, localUrl); } } } response = XMLUtils.documentToString(doc); response = response.replaceAll(getServerUrl(), localUrl); // response = "<?xml version='1.0' encoding='UTF-8'>" + response; is = IOUtils.toInputStream(response); } return is; }
From source file:edu.internet2.middleware.shibboleth.idp.config.profile.saml2.SAML2ECPProfileHandlerBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element config, BeanDefinitionBuilder builder) { super.doParse(config, builder); // see that the handler gets initialized builder.setInitMethodName("initialize"); if (config.hasAttributeNS(null, "authnContextClassRef")) { builder.addPropertyValue("authnContextClassRef", DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "authnContextClassRef"))); } else {/*from w ww . java 2 s. c o m*/ builder.addPropertyValue("authnContextClassRef", AuthnContext.PPT_AUTHN_CTX); } }
From source file:de.betterform.xml.dom.DOMUtil.java
/** * equivalent to the XPath expression './/tnuri:tagName[@anuri:attrName='attrValue']' *//*from ww w. j a v a 2 s .c o m*/ public static Element getElementByAttributeValueNS(Node start, String tnuri, String tagName, String anuri, String attrName, String attrValue) { NodeList nl = ((Element) start).getElementsByTagNameNS(tnuri, tagName); if (nl != null) { int l = nl.getLength(); if (l == 0) { return null; } Element e = null; String compareValue = null; for (int i = 0; i < l; i++) { e = (Element) nl.item(i); if (e.getNodeType() == Node.ELEMENT_NODE) { compareValue = e.getAttributeNS(anuri, attrName); if (compareValue.equals(attrValue)) { return e; } } } } return null; }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.attributeDefinition.PrescopedAttributeDefinitionBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) { super.doParse(pluginId, pluginConfig, pluginConfigChildren, pluginBuilder, parserContext); String scopeDelimiter = "@"; if (pluginConfig.hasAttributeNS(null, "scopeDelimiter")) { scopeDelimiter = pluginConfig.getAttributeNS(null, "scopeDelimiter"); }/*ww w . j a v a2s .co m*/ log.debug("Setting scope delimiter of attribute definition {} to: {}", pluginId, scopeDelimiter); pluginBuilder.addPropertyValue("scopeDelimiter", scopeDelimiter); }
From source file:de.fhg.iais.cortex.services.ingest.worker.BinaryResolutionWorker.java
private CortexModel replaceLocalUrisInEDM(CortexModel model, String itemId) { if ((model == null) || (model.getAny().size() < 1)) { return model; }/*from w ww. j av a2 s . c om*/ Element rdf = model.getAny().get(0); if (rdf != null) { //replace in edm model Element aggregation = (Element) rdf .getElementsByTagNameNS(GlobalConstants.ORE_NAMESPACE_URI, "Aggregation").item(0); if (aggregation != null) { Element thumbnail = (Element) aggregation .getElementsByTagNameNS(GlobalConstants.EDM_NAMESPACE_URI, "object").item(0); if (thumbnail != null) { if (thumbnail.getAttributeNS(GlobalConstants.RDF_NAMESPACE_URI, Parser.RESOURCE) != null) { Attr attr = thumbnail.getAttributeNodeNS(GlobalConstants.RDF_NAMESPACE_URI, Parser.RESOURCE); String href = attr.getValue(); String value = amendRelativeUris(itemId, href); attr.setNodeValue(value); } } } else { throw new DbcException( "Ingest failed: " + itemId + " has no ore:Aggregation. Please check your Mappings."); } } return model; }
From source file:edu.internet2.middleware.shibboleth.common.config.metadata.HTTPMetadataProviderBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element config, ParserContext parserContext, BeanDefinitionBuilder builder) { String providerId = getProviderId(config); super.doParse(config, parserContext, builder); String metadataURL = DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "metadataURL")); URL metadataURI = null;//w ww . j a v a 2 s .c om try { metadataURI = new URL(metadataURL); } catch (MalformedURLException e) { throw new BeanCreationException("metadataURL attribute for metadata provider " + providerId + " must be present and must contain a valid URL"); } HttpClient httpClient = buildHttpClient(config, providerId, metadataURI); builder.addConstructorArgValue(httpClient); log.debug("Metadata provider '{}' metadata URL: {}", providerId, metadataURL); builder.addConstructorArgValue(metadataURL); }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.ComputedIDDataConnectorBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) { super.doParse(pluginId, pluginConfig, pluginConfigChildren, pluginBuilder, parserContext); if (pluginConfig.hasAttributeNS(null, "generatedAttributeID")) { pluginBuilder.addPropertyValue("generatedAttribute", pluginConfig.getAttributeNS(null, "generatedAttributeID")); } else {/*from w ww . j a va 2 s . c o m*/ pluginBuilder.addPropertyValue("generatedAttribute", "computedId"); } pluginBuilder.addPropertyValue("sourceAttribute", pluginConfig.getAttributeNS(null, "sourceAttributeID")); pluginBuilder.addPropertyValue("salt", pluginConfig.getAttributeNS(null, "salt").getBytes()); }