List of usage examples for org.w3c.dom Element hasAttribute
public boolean hasAttribute(String name);
true
when an attribute with a given name is specified on this element or has a default value, false
otherwise. From source file:net.sourceforge.pmd.RuleSetFactory.java
/** * Determine if the specified rule element will represent a Rule with the * given name.//from w w w.j av a 2 s.c o m * * @param ruleElement The rule element. * @param ruleName The Rule name. * * @return {@code true} if the Rule would have the given name, {@code false} otherwise. */ private boolean isRuleName(Element ruleElement, String ruleName) { if (ruleElement.hasAttribute("name")) { return ruleElement.getAttribute("name").equals(ruleName); } else if (ruleElement.hasAttribute("ref")) { RuleSetReferenceId ruleSetReferenceId = RuleSetReferenceId.parse(ruleElement.getAttribute("ref")) .get(0); return ruleSetReferenceId.getRuleName() != null && ruleSetReferenceId.getRuleName().equals(ruleName); } else { return false; } }
From source file:no.sesat.search.mode.config.CommandConfig.java
public SearchConfiguration readSearchConfiguration(final Element element, final SearchConfiguration inherit, Context context) {/*from w w w. j a va 2 s. c o m*/ if (null != inherit) { fieldFilters.putAll(inherit.getFieldFilterMap()); } if (null != inherit) { resultFields.putAll(inherit.getResultFieldMap()); } ModesSearchConfigurationDeserializer.readSearchConfiguration(this, element, inherit); if (element.hasAttribute("field-filters")) { if (element.getAttribute("field-filters").length() == 0) { clearFieldFilters(); } } return this; }
From source file:no.sesat.search.query.analyser.AnalysisRuleFactory.java
private Predicate readPredicate(final Element element, final Map<String, Predicate> predicateMap, final Map<String, Predicate> inheritedPredicates) { Predicate result = null;/* w w w . j ava 2 s.c om*/ final boolean hasId = element.hasAttribute("id"); final boolean hasContent = element.hasChildNodes(); if (hasId && !hasContent) { // it's an already defined predicate final String id = element.getAttribute("id"); result = findPredicate(id, predicateMap, inheritedPredicates); } else { // we must create it final NodeList operators = element.getChildNodes(); for (int i = 0; i < operators.getLength(); ++i) { final Node operator = operators.item(i); if (operator != null && operator instanceof Element) { result = createPredicate((Element) operator, predicateMap, inheritedPredicates); break; } } if (hasId) { // its got an ID so we must remember it. final String id = element.getAttribute("id"); predicateMap.put(id, result); LOG.debug(DEBUG_CREATED_PREDICATE + id + " " + result); } } return result; }
From source file:org.alfresco.repo.template.XSLTProcessor.java
/** * Adds a script element to the xsl which makes static methods on this object available to the xsl tempalte. * /*from ww w . j a v a 2s . c o m*/ * @param xslTemplate * the xsl template */ protected List<String> addScripts(final XSLTemplateModel xsltModel, final Document xslTemplate) { final Map<QName, List<Map.Entry<QName, Object>>> methods = new HashMap<QName, List<Map.Entry<QName, Object>>>(); for (final Map.Entry<QName, Object> entry : xsltModel.entrySet()) { if (entry.getValue() instanceof TemplateProcessorMethod) { final String prefix = QName.splitPrefixedQName(entry.getKey().toPrefixString())[0]; final QName qn = QName.createQName(entry.getKey().getNamespaceURI(), prefix); if (!methods.containsKey(qn)) { methods.put(qn, new LinkedList<Map.Entry<QName, Object>>()); } methods.get(qn).add(entry); } } final Element docEl = xslTemplate.getDocumentElement(); final String XALAN_NS = Constants.S_BUILTIN_EXTENSIONS_URL; final String XALAN_NS_PREFIX = "xalan"; docEl.setAttribute("xmlns:" + XALAN_NS_PREFIX, XALAN_NS); final Set<String> excludePrefixes = new HashSet<String>(); if (docEl.hasAttribute("exclude-result-prefixes")) { excludePrefixes.addAll(Arrays.asList(docEl.getAttribute("exclude-result-prefixes").split(" "))); } excludePrefixes.add(XALAN_NS_PREFIX); final List<String> result = new LinkedList<String>(); for (QName ns : methods.keySet()) { final String prefix = ns.getLocalName(); docEl.setAttribute("xmlns:" + prefix, ns.getNamespaceURI()); excludePrefixes.add(prefix); final Element compEl = xslTemplate.createElementNS(XALAN_NS, XALAN_NS_PREFIX + ":component"); compEl.setAttribute("prefix", prefix); docEl.appendChild(compEl); String functionNames = null; final Element scriptEl = xslTemplate.createElementNS(XALAN_NS, XALAN_NS_PREFIX + ":script"); scriptEl.setAttribute("lang", "javascript"); final StringBuilder js = new StringBuilder("var _xsltp_invoke = java.lang.Class.forName('" + XSLTProcessorMethodInvoker.class.getName() + "').newInstance();\n" + "function _xsltp_to_java_array(js_array) {\n" + "var java_array = java.lang.reflect.Array.newInstance(java.lang.Object, js_array.length);\n" + "for (var i = 0; i < js_array.length; i++) { java_array[i] = js_array[i]; }\n" + "return java_array; }\n"); for (final Map.Entry<QName, Object> entry : methods.get(ns)) { if (functionNames == null) { functionNames = entry.getKey().getLocalName(); } else { functionNames += " " + entry.getKey().getLocalName(); } final String id = entry.getKey().getLocalName() + entry.getValue().hashCode(); js.append("function " + entry.getKey().getLocalName() + "() { return _xsltp_invoke.invokeMethod('" + id + "', _xsltp_to_java_array(arguments)); }\n"); XSLTProcessorMethodInvoker.addMethod(id, (TemplateProcessorMethod) entry.getValue()); result.add(id); } log.debug("generated JavaScript bindings:\n" + js); scriptEl.appendChild(xslTemplate.createTextNode(js.toString())); compEl.setAttribute("functions", functionNames); compEl.appendChild(scriptEl); } docEl.setAttribute("exclude-result-prefixes", StringUtils.join(excludePrefixes.toArray(new String[excludePrefixes.size()]), " ")); return result; }
From source file:org.alfresco.web.forms.xforms.Schema2XForms.java
@SuppressWarnings("unchecked") public static void rebuildInstance(final Node prototypeNode, final Node oldInstanceNode, final Node newInstanceNode, final HashMap<String, String> schemaNamespaces) { final JXPathContext prototypeContext = JXPathContext.newContext(prototypeNode); prototypeContext.registerNamespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI); final JXPathContext instanceContext = JXPathContext.newContext(oldInstanceNode); instanceContext.registerNamespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI); for (final String prefix : schemaNamespaces.keySet()) { prototypeContext.registerNamespace(prefix, schemaNamespaces.get(prefix)); instanceContext.registerNamespace(prefix, schemaNamespaces.get(prefix)); }/*from www.j ava 2 s . co m*/ // Evaluate non-recursive XPaths for all prototype elements at this level final Iterator<Pointer> it = prototypeContext.iteratePointers("*"); while (it.hasNext()) { final Pointer p = it.next(); Element proto = (Element) p.getNode(); String path = p.asPath(); // check if this is a prototype element with the attribute set boolean isPrototype = proto.hasAttributeNS(NamespaceService.ALFRESCO_URI, "prototype") && proto.getAttributeNS(NamespaceService.ALFRESCO_URI, "prototype").equals("true"); // We shouldn't locate a repeatable child with a fixed path if (isPrototype) { path = path.replaceAll("\\[(\\d+)\\]", "[position() >= $1]"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("[rebuildInstance] evaluating prototyped nodes " + path); } } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("[rebuildInstance] evaluating child node with positional path " + path); } } Document newInstanceDocument = newInstanceNode.getOwnerDocument(); // Locate the corresponding nodes in the instance document List<Node> l = (List<Node>) instanceContext.selectNodes(path); // If the prototype node isn't a prototype element, copy it in as a missing node, complete with all its children. We won't need to recurse on this node if (l.isEmpty()) { if (!isPrototype) { LOGGER.debug("[rebuildInstance] copying in missing node " + proto.getNodeName() + " to " + XMLUtil.buildXPath(newInstanceNode, newInstanceDocument.getDocumentElement())); // Clone the prototype node and all its children Element clone = (Element) proto.cloneNode(true); newInstanceNode.appendChild(clone); if (oldInstanceNode instanceof Document) { // add XMLSchema instance NS addNamespace(clone, NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX, NamespaceConstants.XMLSCHEMA_INSTANCE_NS); } } } else { // Otherwise, append the matches from the old instance document in order for (Node old : l) { Element oldEl = (Element) old; // Copy the old instance element rather than cloning it, so we don't copy over attributes Element clone = null; String nSUri = oldEl.getNamespaceURI(); if (nSUri == null) { clone = newInstanceDocument.createElement(oldEl.getTagName()); } else { clone = newInstanceDocument.createElementNS(nSUri, oldEl.getTagName()); } newInstanceNode.appendChild(clone); if (oldInstanceNode instanceof Document) { // add XMLSchema instance NS addNamespace(clone, NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX, NamespaceConstants.XMLSCHEMA_INSTANCE_NS); } // Copy over child text if this is not a complex type boolean isEmpty = true; for (Node n = old.getFirstChild(); n != null; n = n.getNextSibling()) { if (n instanceof Text) { clone.appendChild(newInstanceDocument.importNode(n, false)); isEmpty = false; } else if (n instanceof Element) { break; } } // Populate the nil attribute. It may be true or false if (proto.hasAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS, "nil")) { clone.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS, NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX + ":nil", String.valueOf(isEmpty)); } // Copy over attributes present in the prototype NamedNodeMap attributes = proto.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Attr attribute = (Attr) attributes.item(i); String localName = attribute.getLocalName(); if (localName == null) { String name = attribute.getName(); if (oldEl.hasAttribute(name)) { clone.setAttributeNode( (Attr) newInstanceDocument.importNode(oldEl.getAttributeNode(name), false)); } else { LOGGER.debug("[rebuildInstance] copying in missing attribute " + attribute.getNodeName() + " to " + XMLUtil.buildXPath(clone, newInstanceDocument.getDocumentElement())); clone.setAttributeNode((Attr) attribute.cloneNode(false)); } } else { String namespace = attribute.getNamespaceURI(); if (!((!isEmpty && (namespace.equals(NamespaceConstants.XMLSCHEMA_INSTANCE_NS) && localName.equals("nil")) || (namespace.equals(NamespaceService.ALFRESCO_URI) && localName.equals("prototype"))))) { if (oldEl.hasAttributeNS(namespace, localName)) { clone.setAttributeNodeNS((Attr) newInstanceDocument .importNode(oldEl.getAttributeNodeNS(namespace, localName), false)); } else { LOGGER.debug("[rebuildInstance] copying in missing attribute " + attribute.getNodeName() + " to " + XMLUtil.buildXPath(clone, newInstanceDocument.getDocumentElement())); clone.setAttributeNodeNS((Attr) attribute.cloneNode(false)); } } } } // recurse on children rebuildInstance(proto, oldEl, clone, schemaNamespaces); } } // Now add in a new copy of the prototype if (isPrototype) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("[rebuildInstance] appending " + proto.getNodeName() + " to " + XMLUtil.buildXPath(newInstanceNode, newInstanceDocument.getDocumentElement())); } newInstanceNode.appendChild(proto.cloneNode(true)); } } }
From source file:org.alfresco.web.forms.xforms.XFormsBean.java
private static void rewriteInlineURIs(final Document schemaDocument, final String cwdAvmPath) { final NodeList nl = XMLUtil.combine( schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "include"), schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "import")); if (LOGGER.isDebugEnabled()) LOGGER.debug("rewriting " + nl.getLength() + " includes"); for (int i = 0; i < nl.getLength(); i++) { final Element includeEl = (Element) nl.item(i); if (includeEl.hasAttribute("schemaLocation")) { String uri = includeEl.getAttribute("schemaLocation"); String finalURI = null; if (uri == null || uri.startsWith("http://") || uri.startsWith("https://")) { if (LOGGER.isDebugEnabled()) LOGGER.debug("not rewriting " + uri); continue; }/* w ww . j av a2 s. co m*/ if (uri.startsWith("webscript://")) { // It's a web script include / import final FacesContext facesContext = FacesContext.getCurrentInstance(); final ExternalContext externalContext = facesContext.getExternalContext(); final HttpServletRequest request = (HttpServletRequest) externalContext.getRequest(); final String baseURI = (request.getScheme() + "://" + request.getServerName() + ':' + request.getServerPort() + request.getContextPath() + "/wcservice"); String rewrittenURI = uri; if (uri.contains("${storeid}")) { final String storeId = AVMUtil.getStoreName(cwdAvmPath); rewrittenURI = uri.replace("${storeid}", storeId); } else if (uri.contains("{storeid}")) { final String storeId = AVMUtil.getStoreName(cwdAvmPath); rewrittenURI = uri.replace("{storeid}", storeId); } else { if (LOGGER.isDebugEnabled()) LOGGER.debug("no store id specified in webscript URI " + uri); } if (uri.contains("${ticket}")) { AuthenticationService authenticationService = Repository.getServiceRegistry(facesContext) .getAuthenticationService(); final String ticket = authenticationService.getCurrentTicket(); rewrittenURI = rewrittenURI.replace("${ticket}", ticket); } else if (uri.contains("{ticket}")) { AuthenticationService authenticationService = Repository.getServiceRegistry(facesContext) .getAuthenticationService(); final String ticket = authenticationService.getCurrentTicket(); rewrittenURI = rewrittenURI.replace("{ticket}", ticket); } else { if (LOGGER.isDebugEnabled()) LOGGER.debug("no ticket specified in webscript URI " + uri); } rewrittenURI = rewrittenURI.replaceAll("%26", "&"); finalURI = baseURI + rewrittenURI.replace("webscript://", "/"); if (LOGGER.isDebugEnabled()) LOGGER.debug("Final URI " + finalURI); } else { // It's a web project asset include / import final String baseURI = (uri.charAt(0) == '/' ? AVMUtil.getPreviewURI(AVMUtil.getStoreName(cwdAvmPath)) : AVMUtil.getPreviewURI(cwdAvmPath)); finalURI = baseURI + uri; } if (LOGGER.isDebugEnabled()) LOGGER.debug("rewriting " + uri + " as " + finalURI); includeEl.setAttribute("schemaLocation", finalURI); } } }
From source file:org.alfresco.web.forms.XSLTRenderingEngine.java
/** * Adds a script element to the xsl which makes static methods on this * object available to the xsl tempalte. * * @param xslTemplate the xsl template//w w w . jav a 2 s .c o m */ protected List<String> addScripts(final Map<QName, Object> model, final Document xslTemplate) { final Map<QName, List<Map.Entry<QName, Object>>> methods = new HashMap<QName, List<Map.Entry<QName, Object>>>(); for (final Map.Entry<QName, Object> entry : model.entrySet()) { if (entry.getValue() instanceof TemplateProcessorMethod) { final String prefix = QName.splitPrefixedQName(entry.getKey().toPrefixString())[0]; final QName qn = QName.createQName(entry.getKey().getNamespaceURI(), prefix); if (!methods.containsKey(qn)) { methods.put(qn, new LinkedList()); } methods.get(qn).add(entry); } } final Element docEl = xslTemplate.getDocumentElement(); final String XALAN_NS = Constants.S_BUILTIN_EXTENSIONS_URL; final String XALAN_NS_PREFIX = "xalan"; docEl.setAttribute("xmlns:" + XALAN_NS_PREFIX, XALAN_NS); final Set<String> excludePrefixes = new HashSet<String>(); if (docEl.hasAttribute("exclude-result-prefixes")) { excludePrefixes.addAll(Arrays.asList(docEl.getAttribute("exclude-result-prefixes").split(" "))); } excludePrefixes.add(XALAN_NS_PREFIX); final List<String> result = new LinkedList<String>(); for (QName ns : methods.keySet()) { final String prefix = ns.getLocalName(); docEl.setAttribute("xmlns:" + prefix, ns.getNamespaceURI()); excludePrefixes.add(prefix); final Element compEl = xslTemplate.createElementNS(XALAN_NS, XALAN_NS_PREFIX + ":component"); compEl.setAttribute("prefix", prefix); docEl.appendChild(compEl); String functionNames = null; final Element scriptEl = xslTemplate.createElementNS(XALAN_NS, XALAN_NS_PREFIX + ":script"); scriptEl.setAttribute("lang", "javascript"); final StringBuilder js = new StringBuilder("var _xsltp_invoke = java.lang.Class.forName('" + ProcessorMethodInvoker.class.getName() + "').newInstance();\n" + "function _xsltp_to_java_array(js_array) {\n" + "var java_array = java.lang.reflect.Array.newInstance(java.lang.Object, js_array.length);\n" + "for (var i = 0; i < js_array.length; i++) { java_array[i] = js_array[i]; }\n" + "return java_array; }\n"); for (final Map.Entry<QName, Object> entry : methods.get(ns)) { if (functionNames == null) { functionNames = entry.getKey().getLocalName(); } else { functionNames += " " + entry.getKey().getLocalName(); } final String id = entry.getKey().getLocalName() + entry.getValue().hashCode(); js.append("function " + entry.getKey().getLocalName() + "() { return _xsltp_invoke.invokeMethod('" + id + "', _xsltp_to_java_array(arguments)); }\n"); ProcessorMethodInvoker.PROCESSOR_METHODS.put(id, (TemplateProcessorMethod) entry.getValue()); result.add(id); } LOGGER.debug("generated JavaScript bindings:\n" + js); scriptEl.appendChild(xslTemplate.createTextNode(js.toString())); compEl.setAttribute("functions", functionNames); compEl.appendChild(scriptEl); } docEl.setAttribute("exclude-result-prefixes", StringUtils.join(excludePrefixes.toArray(new String[excludePrefixes.size()]), " ")); return result; }
From source file:org.apache.activemq.cli.test.ArtemisTest.java
@Test public void testWebConfig() throws Exception { setupAuth();// w w w .jav a2 s .co m Run.setEmbedded(true); //instance1: default using http File instance1 = new File(temporaryFolder.getRoot(), "instance1"); Artemis.main("create", instance1.getAbsolutePath(), "--silent", "--no-fsync", "--no-autotune"); File bootstrapFile = new File(new File(instance1, "etc"), "bootstrap.xml"); assertTrue(bootstrapFile.exists()); Document config = parseXml(bootstrapFile); Element webElem = (Element) config.getElementsByTagName("web").item(0); String bindAttr = webElem.getAttribute("bind"); String bindStr = "http://localhost:" + Create.HTTP_PORT; assertEquals(bindAttr, bindStr); //no any of those assertFalse(webElem.hasAttribute("keyStorePath")); assertFalse(webElem.hasAttribute("keyStorePassword")); assertFalse(webElem.hasAttribute("clientAuth")); assertFalse(webElem.hasAttribute("trustStorePath")); assertFalse(webElem.hasAttribute("trustStorePassword")); //instance2: https File instance2 = new File(temporaryFolder.getRoot(), "instance2"); Artemis.main("create", instance2.getAbsolutePath(), "--silent", "--ssl-key", "etc/keystore", "--ssl-key-password", "password1", "--no-fsync", "--no-autotune"); bootstrapFile = new File(new File(instance2, "etc"), "bootstrap.xml"); assertTrue(bootstrapFile.exists()); config = parseXml(bootstrapFile); webElem = (Element) config.getElementsByTagName("web").item(0); bindAttr = webElem.getAttribute("bind"); bindStr = "https://localhost:" + Create.HTTP_PORT; assertEquals(bindAttr, bindStr); String keyStr = webElem.getAttribute("keyStorePath"); assertEquals("etc/keystore", keyStr); String keyPass = webElem.getAttribute("keyStorePassword"); assertEquals("password1", keyPass); assertFalse(webElem.hasAttribute("clientAuth")); assertFalse(webElem.hasAttribute("trustStorePath")); assertFalse(webElem.hasAttribute("trustStorePassword")); //instance3: https with clientAuth File instance3 = new File(temporaryFolder.getRoot(), "instance3"); Artemis.main("create", instance3.getAbsolutePath(), "--silent", "--ssl-key", "etc/keystore", "--ssl-key-password", "password1", "--use-client-auth", "--ssl-trust", "etc/truststore", "--ssl-trust-password", "password2", "--no-fsync", "--no-autotune"); bootstrapFile = new File(new File(instance3, "etc"), "bootstrap.xml"); assertTrue(bootstrapFile.exists()); byte[] contents = Files.readAllBytes(bootstrapFile.toPath()); String cfgText = new String(contents); System.out.println("confg: " + cfgText); config = parseXml(bootstrapFile); webElem = (Element) config.getElementsByTagName("web").item(0); bindAttr = webElem.getAttribute("bind"); bindStr = "https://localhost:" + Create.HTTP_PORT; assertEquals(bindAttr, bindStr); keyStr = webElem.getAttribute("keyStorePath"); assertEquals("etc/keystore", keyStr); keyPass = webElem.getAttribute("keyStorePassword"); assertEquals("password1", keyPass); String clientAuthAttr = webElem.getAttribute("clientAuth"); assertEquals("true", clientAuthAttr); String trustPathAttr = webElem.getAttribute("trustStorePath"); assertEquals("etc/truststore", trustPathAttr); String trustPass = webElem.getAttribute("trustStorePassword"); assertEquals("password2", trustPass); }
From source file:org.apache.ignite.cache.store.cassandra.persistence.PersistenceSettings.java
/** * Constructs persistence settings from corresponding XML element. * * @param el xml element containing persistence settings configuration. *///from w w w. ja v a 2s . c o m @SuppressWarnings("unchecked") public PersistenceSettings(Element el) { if (el == null) throw new IllegalArgumentException( "DOM element representing key/value persistence object can't be null"); if (!el.hasAttribute(STRATEGY_ATTR)) { throw new IllegalArgumentException("DOM element representing key/value persistence object should have '" + STRATEGY_ATTR + "' attribute"); } try { stgy = PersistenceStrategy.valueOf(el.getAttribute(STRATEGY_ATTR).trim().toUpperCase()); } catch (IllegalArgumentException ignored) { throw new IllegalArgumentException( "Incorrect persistence strategy specified: " + el.getAttribute(STRATEGY_ATTR)); } if (!el.hasAttribute(CLASS_ATTR) && PersistenceStrategy.BLOB != stgy) { throw new IllegalArgumentException("DOM element representing key/value persistence object should have '" + CLASS_ATTR + "' attribute or have BLOB persistence strategy"); } try { javaCls = el.hasAttribute(CLASS_ATTR) ? getClassInstance(el.getAttribute(CLASS_ATTR).trim()) : null; } catch (Throwable e) { throw new IllegalArgumentException("Incorrect java class specified '" + el.getAttribute(CLASS_ATTR) + "' " + "for Cassandra persistence", e); } if (PersistenceStrategy.BLOB != stgy && (ByteBuffer.class.equals(javaCls) || byte[].class.equals(javaCls))) { throw new IllegalArgumentException("Java class '" + el.getAttribute(CLASS_ATTR) + "' " + "specified could only be persisted using BLOB persistence strategy"); } if (PersistenceStrategy.PRIMITIVE == stgy && PropertyMappingHelper.getCassandraType(javaCls) == null) { throw new IllegalArgumentException("Current implementation doesn't support persisting '" + javaCls.getName() + "' object using PRIMITIVE strategy"); } if (PersistenceStrategy.POJO == stgy) { if (javaCls == null) throw new IllegalStateException( "Object java class should be specified for POJO persistence strategy"); try { javaCls.getConstructor(); } catch (Throwable e) { throw new IllegalArgumentException("Java class '" + javaCls.getName() + "' couldn't be used as POJO " + "cause it doesn't have no arguments constructor", e); } } if (el.hasAttribute(COLUMN_ATTR)) { if (PersistenceStrategy.BLOB != stgy && PersistenceStrategy.PRIMITIVE != stgy) { throw new IllegalArgumentException( "Incorrect configuration of Cassandra key/value persistence settings, " + "'" + COLUMN_ATTR + "' attribute is only applicable for PRIMITIVE or BLOB strategy"); } col = el.getAttribute(COLUMN_ATTR).trim(); } if (el.hasAttribute(SERIALIZER_ATTR)) { if (PersistenceStrategy.BLOB != stgy && PersistenceStrategy.POJO != stgy) { throw new IllegalArgumentException( "Incorrect configuration of Cassandra key/value persistence settings, " + "'" + SERIALIZER_ATTR + "' attribute is only applicable for BLOB and POJO strategies"); } Object obj = newObjectInstance(el.getAttribute(SERIALIZER_ATTR).trim()); if (!(obj instanceof Serializer)) { throw new IllegalArgumentException( "Incorrect configuration of Cassandra key/value persistence settings, " + "serializer class '" + el.getAttribute(SERIALIZER_ATTR) + "' doesn't implement '" + Serializer.class.getName() + "' interface"); } serializer = (Serializer) obj; } if ((PersistenceStrategy.BLOB == stgy || PersistenceStrategy.PRIMITIVE == stgy) && col == null) col = defaultColumnName(); }
From source file:org.apache.ode.utils.wsdl.WsdlUtils.java
/** * ODE extends the wsdl spec by allowing definition of the HTTP verb at the operation level. * <br/> If you do so, an {@link UnknownExtensibilityElement} will be added to the list of extensibility elements of the {@link javax.wsdl.BindingOperation}. * <br/> This method looks up for such an element and return the value of the verb attribute if the underlying {@link org.w3c.dom.Element} is {@literal <binding xmlns="http://schemas.xmlsoap.org/wsdl/http/"/>} * or null./*from w ww . jav a2 s.com*/ * * @param bindingOperation */ public static String getOperationVerb(BindingOperation bindingOperation) { final Collection<UnknownExtensibilityElement> unknownExtElements = CollectionsX .filter(bindingOperation.getExtensibilityElements(), UnknownExtensibilityElement.class); for (UnknownExtensibilityElement extensibilityElement : unknownExtElements) { final Element e = extensibilityElement.getElement(); if (Namespaces.ODE_HTTP_EXTENSION_NS.equalsIgnoreCase(e.getNamespaceURI()) && "binding".equals(extensibilityElement.getElement().getLocalName()) && e.hasAttribute("verb")) { return e.getAttribute("verb"); } } return null; }