List of usage examples for org.w3c.dom Element getLocalName
public String getLocalName();
From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java
/** * basically Delegates to getSingleNodeValue and returns the just the last value. * * @param requestElement request element * @param tagName tag name//from ww w.j a v a2s . c o m * @return last value */ protected String getLastSingleNodeValue(Element requestElement, String tagName) { Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name"); this.authenticate(); String lastValue = null; String node; // get the Element with name = tagName NodeList children = requestElement.getElementsByTagName(tagName).item(0).getChildNodes(); // iterate over the child nodes for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.TEXT_NODE) { node = children.item(i).getNodeValue(); lastValue = node; } } if (lastValue == null || lastValue.isEmpty()) { // throw new IllegalArgumentException( "Could not find request text node" ); } return lastValue; }
From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java
protected String getNodeValue(Element requestElement, String tagName) { Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name"); this.authenticate(); Node node = requestElement.getElementsByTagName(tagName).item(0); return node.getNodeValue(); }
From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java
protected String getOptionalNodeValue(Element requestElement, String tagName) { Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name"); this.authenticate(); Node node = requestElement.getElementsByTagName(tagName).item(0); if (node == null) return null; return node.getNodeValue(); }
From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java
/** * Function that handles the retrieval of xml input. Use this method if there is only one value in the input but * generically, this method can also store multiple input values as well. This will depend on how the xml is parsed * by the client. OLDTODO Still need to test on different types of client requests. * * @param requestElement - xml request in node hierarchy * @param tagName tag name// ww w .j a va2 s .c o m * @return a collection contain one string element */ /* * OLDTODO return value should be single string object. Note that many services will be affected should we make this * change. */ protected Collection<String> getSingleNodeValue(Element requestElement, String tagName) { Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name"); this.authenticate(); Collection<String> value = new HashSet<>(); String node; // get the Element with name = tagName NodeList children = requestElement.getElementsByTagName(tagName).item(0).getChildNodes(); // iterate over the child nodes for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.TEXT_NODE) { node = children.item(i).getNodeValue(); value.add(node); } } if (value.isEmpty()) { // throw new IllegalArgumentException( "Could not find request text node" ); } return value; }