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.resource.SVNResourceBeanDefinitionParser.java
/** * Gets the value of the {@value #PROXY_USERNAME_ATTRIB_NAME} attribute. * // w ww .ja va 2 s .c o m * @param configElement resource configuration element * * @return value of the attribute * * @throws BeanCreationException thrown if the attribute is present but contains an empty string */ protected String getProxyUsername(Element configElement) throws BeanCreationException { if (configElement.hasAttributeNS(null, PROXY_USERNAME_ATTRIB_NAME)) { String username = DatatypeHelper .safeTrimOrNullString(configElement.getAttributeNS(null, PROXY_USERNAME_ATTRIB_NAME)); if (username == null) { log.error("SVN resource definition attribute '" + PROXY_USERNAME_ATTRIB_NAME + "' may not be an empty string"); throw new BeanCreationException("SVN resource definition attribute '" + PROXY_USERNAME_ATTRIB_NAME + "' may not be an empty string"); } return username; } return null; }
From source file:edu.internet2.middleware.shibboleth.common.config.resource.SVNResourceBeanDefinitionParser.java
/** * Gets the value of the {@value #PROXY_PASSWORD_ATTRIB_NAME} attribute. * /* w w w. j av a2s . com*/ * @param configElement resource configuration element * * @return value of the attribute * * @throws BeanCreationException thrown if the attribute is present but contains an empty string */ protected String getProxyPassword(Element configElement) throws BeanCreationException { if (configElement.hasAttributeNS(null, PROXY_PASSWORD_ATTRIB_NAME)) { String password = DatatypeHelper .safeTrimOrNullString(configElement.getAttributeNS(null, PROXY_PASSWORD_ATTRIB_NAME)); if (password == null) { log.error("SVN resource definition attribute '" + PROXY_PASSWORD_ATTRIB_NAME + "' may not be an empty string"); throw new BeanCreationException("SVN resource definition attribute '" + PROXY_PASSWORD_ATTRIB_NAME + "' may not be an empty string"); } return password; } return null; }
From source file:edu.internet2.middleware.shibboleth.common.config.resource.SVNResourceBeanDefinitionParser.java
/** * Gets the value of the {@value #USERNAME_ATTRIB_NAME} attribute. * //from www .ja va 2s . c o m * @param configElement resource configuration element * * @return value of the attribute * * @throws BeanCreationException thrown if the attribute is present but contains an empty string */ protected String getUsername(Element configElement) throws BeanCreationException { if (configElement.hasAttributeNS(null, USERNAME_ATTRIB_NAME)) { String username = DatatypeHelper .safeTrimOrNullString(configElement.getAttributeNS(null, USERNAME_ATTRIB_NAME)); if (username == null) { log.error("SVN resource definition attribute '" + USERNAME_ATTRIB_NAME + "' may not be an empty string"); throw new BeanCreationException("SVN resource definition attribute '" + USERNAME_ATTRIB_NAME + "' may not be an empty string"); } return username; } return null; }
From source file:edu.internet2.middleware.shibboleth.common.config.resource.SVNResourceBeanDefinitionParser.java
/** * Gets the value of the {@value #PROXY_HOST_ATTRIB_NAME} attribute. * //www. j a v a2s . c om * @param configElement resource configuration element * * @return value of the attribute * * @throws BeanCreationException thrown if the attribute is present but contains an empty string */ protected String getProxyHost(Element configElement) throws BeanCreationException { if (configElement.hasAttributeNS(null, PROXY_HOST_ATTRIB_NAME)) { String host = DatatypeHelper .safeTrimOrNullString(configElement.getAttributeNS(null, PROXY_HOST_ATTRIB_NAME)); if (host == null) { log.error("SVN resource definition attribute '" + PROXY_HOST_ATTRIB_NAME + "' may not be an empty string"); throw new BeanCreationException("SVN resource definition attribute '" + PROXY_HOST_ATTRIB_NAME + "' may not be an empty string"); } return host; } return null; }
From source file:edu.internet2.middleware.shibboleth.common.config.resource.SVNResourceBeanDefinitionParser.java
/** * Gets the value of the {@value #REVISION_ATTRIB_NAME} attribute. * //from w w w.ja va 2 s . c o m * @param configElement resource configuration element * * @return value of the attribute * * @throws BeanCreationException thrown if the attribute is missing or contains an invalid number */ protected long getRevision(Element configElement) throws BeanCreationException { if (!configElement.hasAttributeNS(null, REVISION_ATTRIB_NAME)) { return -1; } else { try { return Long.parseLong(DatatypeHelper .safeTrimOrNullString(configElement.getAttributeNS(null, WORKING_COPY_DIR_ATTRIB_NAME))); } catch (NumberFormatException e) { log.error("SVN resource definition attribute '" + REVISION_ATTRIB_NAME + "' contains an invalid number"); throw new BeanCreationException("SVN resource definition attribute '" + REVISION_ATTRIB_NAME + "' contains an invalid number"); } } }
From source file:edu.internet2.middleware.shibboleth.common.config.resource.SVNResourceBeanDefinitionParser.java
/** * Gets the value of the {@value #REPOSITORY_URL_ATTRIB_NAME} attribute. * //from www . j a v a 2 s .c om * @param configElement resource configuration element * * @return value of the attribute * * @throws BeanCreationException thrown if the attribute is missing or contains an invalid SVN URL */ protected SVNURL getRespositoryUrl(Element configElement) throws BeanCreationException { if (!configElement.hasAttributeNS(null, REPOSITORY_URL_ATTRIB_NAME)) { log.error("SVN resource definition missing required '" + REPOSITORY_URL_ATTRIB_NAME + "' attribute"); throw new BeanCreationException( "SVN resource definition missing required '" + REPOSITORY_URL_ATTRIB_NAME + "' attribute"); } String repositoryUrl = DatatypeHelper .safeTrimOrNullString(configElement.getAttributeNS(null, REPOSITORY_URL_ATTRIB_NAME)); try { return SVNURL.parseURIDecoded(repositoryUrl); } catch (SVNException e) { log.error("SVN remote repository URL " + repositoryUrl + " is not valid", e); throw new BeanCreationException("SVN remote repository URL " + repositoryUrl + " is not valid", e); } }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.LdapDataConnectorBeanDefinitionParser.java
/** * Processes the cache configuration directives. * /*from ww w . j a v a 2 s.c o m*/ * @param pluginId ID of the plugin * @param pluginConfig configuration element for the plugin * @param pluginBuilder builder for the plugin */ protected void processCacheConfig(String pluginId, Element pluginConfig, BeanDefinitionBuilder pluginBuilder) { boolean cacheResults = false; String cacheManagerId = "shibboleth.CacheManager"; long cacheElementTtl = 4 * 60 * 60 * 1000; int maximumCachedElements = 500; List<Element> cacheConfigs = XMLHelper.getChildElementsByTagNameNS(pluginConfig, DataConnectorNamespaceHandler.NAMESPACE, "ResultCache"); if (cacheConfigs != null && !cacheConfigs.isEmpty()) { Element cacheConfig = cacheConfigs.get(0); cacheResults = true; if (cacheConfig.hasAttributeNS(null, "cacheManagerRef")) { cacheManagerId = DatatypeHelper.safeTrim(cacheConfig.getAttributeNS(null, "cacheManagerRef")); } if (cacheConfig.hasAttributeNS(null, "elementTimeToLive")) { cacheElementTtl = SpringConfigurationUtils.parseDurationToMillis( "elementTimeToLive on data connector " + pluginId, cacheConfig.getAttributeNS(null, "elementTimeToLive"), 0); } if (cacheConfig.hasAttributeNS(null, "maximumCachedElements")) { maximumCachedElements = Integer.parseInt( DatatypeHelper.safeTrim(cacheConfig.getAttributeNS(null, "maximumCachedElements"))); } } if (pluginConfig.hasAttributeNS(null, "cacheResults")) { log.warn( "Data connection {}: use of 'cacheResults' attribute is deprecated. Use <ResultCache> instead.", pluginId); cacheResults = XMLHelper .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "cacheResults")); } if (cacheResults) { log.debug("Data connector {} is caching results: {}", pluginId, cacheResults); pluginBuilder.addPropertyReference("cacheManager", cacheManagerId); log.debug("Data connector {} cache element time to live: {}ms", pluginId, cacheElementTtl); pluginBuilder.addPropertyValue("cacheElementTimeToLive", cacheElementTtl); log.debug("Data connector {} maximum number of caches elements: {}", pluginId, maximumCachedElements); pluginBuilder.addPropertyValue("maximumCachedElements", maximumCachedElements); } }
From source file:edu.internet2.middleware.shibboleth.common.config.resource.SVNResourceBeanDefinitionParser.java
/** * Gets the value of the {@value #RESOURCE_FILE_ATTRIB_NAME} attribute. * //from ww w . ja v a2 s . co m * @param configElement resource configuration element * * @return value of the attribute * * @throws BeanCreationException thrown if the attribute is missing or contains an empty string */ protected String getResourceFile(Element configElement) throws BeanCreationException { if (!configElement.hasAttributeNS(null, RESOURCE_FILE_ATTRIB_NAME)) { log.error("SVN resource definition missing required '" + RESOURCE_FILE_ATTRIB_NAME + "' attribute"); throw new BeanCreationException( "SVN resource definition missing required '" + RESOURCE_FILE_ATTRIB_NAME + "' attribute"); } String filename = DatatypeHelper .safeTrimOrNullString(configElement.getAttributeNS(null, RESOURCE_FILE_ATTRIB_NAME)); if (filename == null) { log.error("SVN resource definition attribute '" + RESOURCE_FILE_ATTRIB_NAME + "' may not be an empty string"); throw new BeanCreationException("SVN resource definition attribute '" + RESOURCE_FILE_ATTRIB_NAME + "' may not be an empty string"); } return filename; }
From source file:edu.internet2.middleware.shibboleth.common.config.resource.SVNResourceBeanDefinitionParser.java
/** * Gets the value of the {@value #PROXY_PORT_ATTRIB_NAME} attribute. * /*from w w w . j a va 2s . c o m*/ * @param configElement resource configuration element * * @return value of the attribute, or {@value #DEFAULT_PROXY_PORT} if the attribute is not defined * * @throws BeanCreationException thrown if the attribute is present but contains an empty string */ protected int getProxyPort(Element configElement) throws BeanCreationException { if (!configElement.hasAttributeNS(null, PROXY_PORT_ATTRIB_NAME)) { return DEFAULT_PROXY_PORT; } String port = DatatypeHelper .safeTrimOrNullString(configElement.getAttributeNS(null, PROXY_PORT_ATTRIB_NAME)); if (port == null) { log.error("SVN resource definition attribute '" + PROXY_PORT_ATTRIB_NAME + "' may not be an empty string"); throw new BeanCreationException("SVN resource definition attribute '" + PROXY_PORT_ATTRIB_NAME + "' may not be an empty string"); } try { return Integer.parseInt(port); } catch (NumberFormatException e) { log.error("SVN resource definition attribute '" + PROXY_PORT_ATTRIB_NAME + "' contains an invalid number"); throw new BeanCreationException("SVN resource definition attribute '" + PROXY_PORT_ATTRIB_NAME + "' contains an invalid number"); } }
From source file:edu.internet2.middleware.shibboleth.common.config.resource.SVNResourceBeanDefinitionParser.java
/** * Gets the value of the {@value #REPOSITORY_URL_ATTRIB_NAME} attribute. * /*from w w w . ja v a2s .c o m*/ * @param configElement resource configuration element * * @return value of the attribute * * @throws BeanCreationException thrown if the attribute is missing or contains an invalid directory path */ protected File getWorkingCopyDirectory(Element configElement) throws BeanCreationException { if (!configElement.hasAttributeNS(null, WORKING_COPY_DIR_ATTRIB_NAME)) { log.error("SVN resource definition missing required '" + WORKING_COPY_DIR_ATTRIB_NAME + "' attribute"); throw new BeanCreationException( "SVN resource definition missing required '" + WORKING_COPY_DIR_ATTRIB_NAME + "' attribute"); } File directory = new File(DatatypeHelper .safeTrimOrNullString(configElement.getAttributeNS(null, WORKING_COPY_DIR_ATTRIB_NAME))); if (directory == null) { log.error("SVN working copy directory may not be null"); throw new BeanCreationException("SVN working copy directory may not be null"); } if (!directory.exists()) { boolean created = directory.mkdirs(); if (!created) { log.error("SVN working copy direction " + directory.getAbsolutePath() + " does not exist and could not be created"); throw new BeanCreationException("SVN working copy direction " + directory.getAbsolutePath() + " does not exist and could not be created"); } } if (!directory.isDirectory()) { log.error("SVN working copy location " + directory.getAbsolutePath() + " is not a directory"); throw new BeanCreationException( "SVN working copy location " + directory.getAbsolutePath() + " is not a directory"); } if (!directory.canRead()) { log.error("SVN working copy directory " + directory.getAbsolutePath() + " can not be read by this process"); throw new BeanCreationException("SVN working copy directory " + directory.getAbsolutePath() + " can not be read by this process"); } if (!directory.canWrite()) { log.error("SVN working copy directory " + directory.getAbsolutePath() + " can not be written to by this process"); throw new BeanCreationException("SVN working copy directory " + directory.getAbsolutePath() + " can not be written to by this process"); } return directory; }