List of usage examples for org.w3c.dom Element hasAttributeNS
public boolean hasAttributeNS(String namespaceURI, String localName) throws DOMException;
true
when an attribute with a given local name and namespace URI is specified on this element or has a default value, false
otherwise. From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.attributeDefinition.MappedAttributeDefinitionBeanDefinitionParser.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); List<ValueMap> valueMaps = processValueMaps(pluginId, pluginConfigChildren, pluginBuilder); pluginBuilder.addPropertyValue("valueMaps", valueMaps); if (pluginConfigChildren.containsKey(DEFAULT_VALUE_ELEMENT_NAME)) { Element defaultValueElem = pluginConfigChildren.get(DEFAULT_VALUE_ELEMENT_NAME).get(0); String defaultValue = DatatypeHelper.safeTrimOrNullString(defaultValueElem.getTextContent()); pluginBuilder.addPropertyValue("defaultValue", defaultValue); if (log.isDebugEnabled()) { log.debug("Attribute definition {} default value: {}", pluginId, defaultValue); }//from w w w. j a va 2 s . c om boolean passThru = false; if (defaultValueElem.hasAttributeNS(null, "passThru")) { passThru = XMLHelper .getAttributeValueAsBoolean(defaultValueElem.getAttributeNodeNS(null, "passThru")); } pluginBuilder.addPropertyValue("passThru", passThru); if (log.isDebugEnabled()) { log.debug("Attribute definition {} uses default value pass thru: {}", pluginId, passThru); } } }
From source file:edu.internet2.middleware.psp.spring.LdapSpmlTargetBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element configElement, ParserContext parserContext, BeanDefinitionBuilder builder) { super.doParse(configElement, parserContext, builder); String ldapPoolId = configElement.getAttributeNS(null, "ldapPoolId"); LOG.debug("Setting ldapPoolId to '{}'", ldapPoolId); builder.addPropertyValue("ldapPoolId", ldapPoolId); String ldapPoolIdSource = configElement.getAttributeNS(null, "ldapPoolIdSource"); LOG.debug("Setting ldapPoolIdSource to '{}'", ldapPoolIdSource); builder.addPropertyValue("ldapPoolIdSource", ldapPoolIdSource); if (configElement.hasAttributeNS(null, "logLdif")) { Attr attr = configElement.getAttributeNodeNS(null, "logLdif"); LOG.debug("Setting logLdif to '{}'", XMLHelper.getAttributeValueAsBoolean(attr)); builder.addPropertyValue("logLdif", XMLHelper.getAttributeValueAsBoolean(attr)); }/*from w w w . jav a2 s. com*/ }
From source file:edu.mayo.cts2.framework.core.xml.PatchedCastorMarshaller.java
protected Object unmarshalDomSource(DOMSource domSource) throws XmlMappingException { Node node = domSource.getNode(); if (node != null && node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; Node parent = node.getParentNode(); while (parent != null) { NamedNodeMap atts = parent.getAttributes(); if (atts != null) { for (int i = 0, j = atts.getLength(); i < j; i++) { Attr att = (Attr) atts.item(i); if (XMLNS_NS.equals(att.getNamespaceURI())) { String name = att.getName(); String value = att.getValue(); if (!element.hasAttributeNS(XMLNS_NS, name)) { element.setAttributeNS(XMLNS_NS, name, value); }//from w w w . j av a 2s . c o m } } } parent = parent.getParentNode(); } } return super.unmarshalDomSource(domSource); }
From source file:edu.internet2.middleware.shibboleth.common.config.metadata.EntityRoleFilterBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { ArrayList<QName> retainedRoles = new ArrayList<QName>(); List<Element> retainedRoleElems = XMLHelper.getChildElementsByTagNameNS(element, MetadataNamespaceHandler.NAMESPACE, "RetainedRole"); if (retainedRoleElems != null) { for (Element retainedRoleElem : retainedRoleElems) { retainedRoles.add(XMLHelper.getElementContentAsQName(retainedRoleElem)); }/* www. j av a2s. c o m*/ } builder.addConstructorArgValue(retainedRoles); if (element.hasAttributeNS(null, "removeRolelessEntityDescriptors")) { builder.addPropertyValue("removeRolelessEntityDescriptors", XMLHelper.getAttributeValueAsBoolean( element.getAttributeNodeNS(null, "removeRolelessEntityDescriptors"))); } else { builder.addPropertyValue("removeRolelessEntityDescriptors", true); } if (element.hasAttributeNS(null, "removeEmptyEntitiesDescriptors")) { builder.addPropertyValue("removeEmptyEntitiesDescriptors", XMLHelper.getAttributeValueAsBoolean( element.getAttributeNodeNS(null, "removeEmptyEntitiesDescriptors"))); } else { builder.addPropertyValue("removeEmptyEntitiesDescriptors", true); } }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.RDBMSDataConnectorBeanDefinitionParser.java
/** * Processes the Column descriptor configuration elements. * /* w ww .j av a 2 s . co m*/ * @param pluginId ID of this data connector * @param pluginConfigChildren configuration elements * @param pluginBuilder the bean definition parser * * @return result set column descriptors */ protected List<RDBMSColumnDescriptor> processColumnDescriptors(String pluginId, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder) { List<RDBMSColumnDescriptor> columnDescriptors = new ArrayList<RDBMSColumnDescriptor>(); QName columnElementName = new QName(DataConnectorNamespaceHandler.NAMESPACE, "Column"); RDBMSColumnDescriptor columnDescriptor; String columnName; String attributeId; String dataType; if (pluginConfigChildren.containsKey(columnElementName)) { for (Element columnElem : pluginConfigChildren.get(columnElementName)) { columnName = columnElem.getAttributeNS(null, "columnName"); attributeId = columnElem.getAttributeNS(null, "attributeID"); if (columnElem.hasAttributeNS(null, "type")) { dataType = columnElem.getAttributeNS(null, "type"); } else { dataType = DATA_TYPES.String.toString(); } columnDescriptor = new RDBMSColumnDescriptor(columnName, attributeId, DATA_TYPES.valueOf(dataType)); columnDescriptors.add(columnDescriptor); } log.debug("Data connector {} column descriptors: {}", pluginId, columnDescriptors); } return columnDescriptors; }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.LdapDataConnectorBeanDefinitionParser.java
/** * Process the LDAP result handling configuration for the LDAP data connector. * /* w w w . j ava 2 s.co m*/ * @param pluginId ID of the LDAP plugin * @param pluginConfig LDAP plugin configuration element * @param pluginConfigChildren child elements of the plugin * @param pluginBuilder plugin builder * @param parserContext current parsing context */ protected void processResultHandlingConfig(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) { int searchTimeLimit = 3000; if (pluginConfig.hasAttributeNS(null, "searchTimeLimit")) { searchTimeLimit = (int) SpringConfigurationUtils.parseDurationToMillis( "'searchTimeLimit' on data connector " + pluginId, pluginConfig.getAttributeNS(null, "searchTimeLimit"), 0); } log.debug("Data connector {} search timeout: {}ms", pluginId, searchTimeLimit); pluginBuilder.addPropertyValue("searchTimeLimit", searchTimeLimit); int maxResultSize = 1; if (pluginConfig.hasAttributeNS(null, "maxResultSize")) { maxResultSize = Integer.parseInt(pluginConfig.getAttributeNS(null, "maxResultSize")); } log.debug("Data connector {} max search result size: {}", pluginId, maxResultSize); pluginBuilder.addPropertyValue("maxResultSize", maxResultSize); boolean mergeResults = false; if (pluginConfig.hasAttributeNS(null, "mergeResults")) { mergeResults = XMLHelper .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "mergeResults")); } log.debug("Data connector {} merge results: {}", pluginId, mergeResults); pluginBuilder.addPropertyValue("mergeResults", mergeResults); boolean noResultsIsError = false; if (pluginConfig.hasAttributeNS(null, "noResultIsError")) { noResultsIsError = XMLHelper .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "noResultIsError")); } log.debug("Data connector {} no results is error: {}", pluginId, noResultsIsError); pluginBuilder.addPropertyValue("noResultsIsError", noResultsIsError); boolean lowercaseAttributeNames = false; if (pluginConfig.hasAttributeNS(null, "lowercaseAttributeNames")) { lowercaseAttributeNames = XMLHelper .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "lowercaseAttributeNames")); } log.debug("Data connector {} will lower case attribute IDs: {}", pluginId, lowercaseAttributeNames); pluginBuilder.addPropertyValue("lowercaseAttributeNames", lowercaseAttributeNames); }
From source file:com.wfreitas.camelsoap.SoapClient.java
/** * Expand the message to accommodate data collections. * <p/>// w w w .jav a2 s . co m * It basically just clones the message where appropriate. * * @param element The element to be processed. * @param params The message params. Uses the message params to * decide whether or not cloning is required. */ private void expandMessage(Element element, Map params) { // If this element is not a cloned element, check does it need to be cloned... if (!element.hasAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, IS_CLONE_ATTRIB)) { String ognl = OGNLUtils.getOGNLExpression(element); Element clonePoint = getClonePoint(element); if (clonePoint != null) { int collectionSize; collectionSize = calculateCollectionSize(ognl, params); if (collectionSize == -1) { // It's a collection, but has no entries that match the OGNL expression for this element... if (clonePoint == element) { // If the clonePoint is the element itself, we remove it... we're done with it... clonePoint.getParentNode().removeChild(clonePoint); } else { // If the clonePoint is not the element itself (it's a child element), leave it // and check it again when we get to it... resetClonePoint(clonePoint); } } else if (collectionSize == 0) { // It's a collection, but has no entries, remove it... clonePoint.getParentNode().removeChild(clonePoint); } else if (collectionSize == 1) { // It's a collection, but no need to clone coz we // already have an entry for it... clonePoint.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + OGNLUtils.OGNL_ATTRIB, ognl + "[0]"); } else { // It's a collection and we need to do some cloning if (clonePoint != null) { // We already have one, so decrement by one... cloneCollectionTemplateElement(clonePoint, (collectionSize - 1), ognl); } else { LOGGER.warn("Collection/array template element <" + element.getLocalName() + "> would appear to be invalid. It doesn't contain any child elements."); } } } } // Now do the same for the child elements... List<Node> children = DOMUtil.copyNodeList(element.getChildNodes()); for (Node node : children) { if (node.getNodeType() == Node.ELEMENT_NODE) { expandMessage((Element) node, params); } } }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.StoredIDDataConnectorBeanDefinitionParser.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); processConnectionManagement(pluginId, pluginConfig, pluginConfigChildren, pluginBuilder, parserContext); long queryTimeout = 5 * 1000; if (pluginConfig.hasAttributeNS(null, "queryTimeout")) { queryTimeout = SpringConfigurationUtils.parseDurationToMillis( "queryTimeout on relational database connector " + pluginId, pluginConfig.getAttributeNS(null, "queryTimeout"), 0); }//from ww w . j a v a2s . c o m log.debug("Data connector {} SQL query timeout: {}ms", queryTimeout); pluginBuilder.addPropertyValue("queryTimeout", queryTimeout); String generatedAttributeId = "storedId"; if (pluginConfig.hasAttributeNS(null, "generatedAttributeID")) { generatedAttributeId = DatatypeHelper .safeTrimOrNullString(pluginConfig.getAttributeNS(null, "generatedAttributeID")); } pluginBuilder.addPropertyValue("generatedAttribute", generatedAttributeId); log.debug("Data connector {} generated attribute ID: {}", pluginId, generatedAttributeId); String sourceAttribute = DatatypeHelper .safeTrimOrNullString(pluginConfig.getAttributeNS(null, "sourceAttributeID")); log.debug("Data connector {} source attribute ID: {}", pluginId, sourceAttribute); pluginBuilder.addPropertyValue("sourceAttribute", sourceAttribute); String salt = DatatypeHelper.safeTrimOrNullString(pluginConfig.getAttributeNS(null, "salt")); log.debug("Data connector {} salt: {}", pluginId, salt); pluginBuilder.addPropertyValue("salt", salt.getBytes()); }
From source file:edu.washington.shibboleth.attribute.resolver.spring.dc.rws.RwsDataConnectorParser.java
/** * Parse attribute requirements/*www . j av a2 s . c om*/ * * @param elements DOM elements of type <code>Attribute</code> * * @return the attributes */ protected List<RwsAttribute> parseAttributes(List<Element> elements) { if (elements == null || elements.size() == 0) { return null; } List<RwsAttribute> rwsAttributes = new Vector<RwsAttribute>(); for (Element ele : elements) { RwsAttribute rwsAttribute = new RwsAttribute(); rwsAttribute.name = StringSupport.trimOrNull(ele.getAttributeNS(null, "name")); log.debug("parseattribute: " + rwsAttribute.name); System.out.println("parseattribute: " + rwsAttribute.name); rwsAttribute.xPath = StringSupport.trimOrNull(ele.getAttributeNS(null, "xPath")); rwsAttribute.maxResultSize = 1; if (ele.hasAttributeNS(null, "maxResultSize")) { rwsAttribute.maxResultSize = Integer.parseInt(ele.getAttributeNS(null, "maxResultSize")); } boolean noResultsIsError = false; if (ele.hasAttributeNS(null, "noResultIsError")) { rwsAttribute.noResultIsError = AttributeSupport .getAttributeValueAsBoolean(ele.getAttributeNodeNS(null, "noResultIsError")); } rwsAttributes.add(rwsAttribute); } return rwsAttributes; }
From source file:de.betterform.xml.xforms.CustomElementFactory.java
/** * Returns true if the given DOM Element matches a configured custom * element.// w ww .j a v a2s .co m * * @param element * The DOM Element to investigate. * @return Whether the element matches a custom element or not. * * @throws XFormsException * In case of MustUnderstand Module failure. */ public boolean isCustomElement(Element element) throws XFormsException { if (this.noCustomElements) { //no custom elements configured return false; } //key to search the Map for a custom element String key = getKeyForElement(element); if (ELEMENTS.containsKey(key)) { //a match was found return true; } //if the element is not recognized but it has a //mustUnderstand attribute, throw an exception to //signal error according to the spec if (element.hasAttributeNS(NamespaceConstants.XFORMS_NS, MUST_UNDERSTAND_ATTRIBUTE)) { String elementId = element.getPrefix() + ":" + element.getLocalName(); throw new XFormsException("MustUnderstand Module failure at element " + elementId); } //no matching configuration was found return false; }