Example usage for org.w3c.dom Element getLocalName

List of usage examples for org.w3c.dom Element getLocalName

Introduction

In this page you can find the example usage for org.w3c.dom Element getLocalName.

Prototype

public String getLocalName();

Source Link

Document

Returns the local part of the qualified name of this node.

Usage

From source file:org.ow2.petals.binding.soap.SoapBootstrapOperations.java

/**
 * Get a SOAP parameter./*w w  w . j  a  v  a  2s. c  o m*/
 * 
 * @param name
 * @param value
 * @param jbi
 */
public String getParam(String name, Jbi jbi) {
    for (Element element : jbi.getComponent().getAny()) {
        if (element.getLocalName().equals(name)) {
            return element.getTextContent();
        }
    }

    return null;
}

From source file:org.owasp.webscarab.plugin.saml.SamlModel.java

public static Element findProtocolSignatureElement(Document document) {
    Element documentElement = document.getDocumentElement();
    NodeList documentChildNodes = documentElement.getChildNodes();
    int documentNodeCount = documentChildNodes.getLength();
    for (int nodeIdx = 0; nodeIdx < documentNodeCount; nodeIdx++) {
        Node node = documentChildNodes.item(nodeIdx);
        if (Node.ELEMENT_NODE == node.getNodeType()) {
            Element element = (Element) node;
            if (false == "http://www.w3.org/2000/09/xmldsig#".equals(element.getNamespaceURI())) {
                continue;
            }//from w  w  w  .j av  a 2 s.co m
            if (false == "Signature".equals(element.getLocalName())) {
                continue;
            }
            return element;
        }
    }
    return null;
}

From source file:org.owasp.webscarab.plugin.saml.SamlModel.java

public static Element findAssertionSignatureElement(Document document) {
    NodeList assertionNodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:assertion",
            "Assertion");
    if (0 == assertionNodeList.getLength()) {
        assertionNodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion",
                "Assertion");
        if (0 == assertionNodeList.getLength()) {
            return null;
        }//from  w  w  w . j a va 2s .  c  o m
    }
    Node assertionNode = assertionNodeList.item(0);
    NodeList assertionChildrenNodeList = assertionNode.getChildNodes();
    int assertionChildrenNodeCount = assertionChildrenNodeList.getLength();
    for (int nodeIdx = 0; nodeIdx < assertionChildrenNodeCount; nodeIdx++) {
        Node node = assertionChildrenNodeList.item(nodeIdx);
        if (Node.ELEMENT_NODE == node.getNodeType()) {
            Element element = (Element) node;
            if (false == "http://www.w3.org/2000/09/xmldsig#".equals(element.getNamespaceURI())) {
                continue;
            }
            if (false == "Signature".equals(element.getLocalName())) {
                continue;
            }
            return element;
        }
    }
    return null;
}

From source file:org.qualipso.interop.semantics.securecomm.asm.inout.MyInOutRouteBuilder.java

public void configure() {

    try {/*w w w .  ja  v  a  2s .  c o  m*/
        File file = new File(propertyFileName);
        FileInputStream fis = new FileInputStream(file);
        availableServicesAsProperties = new Properties();
        availableServicesAsProperties.load(fis);
        fis.close();

        from("jbi:service:urn:qualipso:wp32:secCommNode2:camelinout")
                .to("jbi:service:urn:qualipso:wp32:secCommNode2:secCommNode2beanwssecService?mep=in-out")
                .setHeader("endpointName", constant("jbi:service:urn:qualipso:wp32:secCommNode2:")
                        .append(new Expression<Exchange>() {
                            public Object evaluate(Exchange exchange) {
                                Exchange copyEx = exchange.copy();
                                Message msg = copyEx.getIn();

                                org.w3c.dom.Document doc = (org.w3c.dom.Document) msg
                                        .getBody(org.w3c.dom.Document.class);
                                Element root = doc.getDocumentElement();
                                System.out
                                        .println("MyInOutRouteBuilder elemNAME=[" + root.getLocalName() + "]");

                                NamedNodeMap attrs = root.getAttributes();
                                for (int i = 0; i < attrs.getLength(); i++) {
                                    Node temp = attrs.item(i);

                                    if (temp.getNodeName().equalsIgnoreCase(WS_NAME_ATTRIBUTE)
                                            || temp.getNodeName().equalsIgnoreCase(WS_NAME_ATTRIBUTE2)) {
                                        System.out.println(
                                                "MyInOutRouteBuilder ROUTING =>[" + temp.getNodeValue() + "]");
                                        return availableServicesAsProperties.get(temp.getNodeValue().trim());
                                    }
                                }

                                // assuming we'll have an error page, redirect there 
                                return "errata";
                            }
                        }))
                .recipientList(header("endpointName"));
        //.to("jbi:service:urn:qualipso:wp32:secCommNode2:secCommNode2ServerServiceProvInOut?mep=in-out");

    } catch (Exception ex) {
        //assuming we shall have an error page, redirect to that one.
        System.out.println("CAMEL_EXCEPTION");
        ex.printStackTrace(System.out);
    }
}

From source file:org.socraticgrid.xmlCommon.XmlUtility.java

public static String formatElementForLogging(String elementName, Element element) {
    String elementNamePart = null;
    String elementValuePart = null;

    elementValuePart = serializeElementIgnoreFaults(element);

    if (NullChecker.isNotNullish(elementName)) {
        elementNamePart = elementName;/* ww w.  j  av a 2 s  . com*/
    } else if (element != null) {
        elementNamePart = element.getLocalName();
    } else {
        elementNamePart = "element";
    }

    String message = "{" + elementNamePart + "}=[" + elementValuePart + "]";
    return message;
}

From source file:org.springframework.batch.core.jsr.configuration.xml.JsrBeanDefinitionDocumentReader.java

@Override
protected void preProcessXml(Element root) {
    if (ROOT_JOB_ELEMENT_NAME.equals(root.getLocalName())) {
        initProperties(root);/*  www .  ja va  2s.c  o  m*/
        transformDocument(root);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Transformed XML from preProcessXml: " + elementToString(root));
        }
    }
}

From source file:org.springframework.data.gemfire.config.AbstractRegionParser.java

protected boolean isRegionTemplate(final Element element) {
    String localName = element.getLocalName();
    return (localName != null && localName.endsWith("-template"));
}

From source file:org.springframework.data.gemfire.config.AbstractRegionParser.java

protected void doParseCommonRegionConfiguration(Element element, ParserContext parserContext,
        BeanDefinitionBuilder regionBuilder, BeanDefinitionBuilder regionAttributesBuilder, boolean subRegion) {

    mergeTemplateRegionAttributes(element, parserContext, regionBuilder, regionAttributesBuilder);

    String resolvedCacheRef = ParsingUtils.resolveCacheReference(element.getAttribute("cache-ref"));

    if (!subRegion) {
        regionBuilder.addPropertyReference("cache", resolvedCacheRef);
        ParsingUtils.setPropertyValue(element, regionBuilder, "close");
        ParsingUtils.setPropertyValue(element, regionBuilder, "destroy");
    }/* w  w  w.j  av  a 2 s .  com*/

    ParsingUtils.setPropertyValue(element, regionBuilder, "name");
    ParsingUtils.setPropertyValue(element, regionBuilder, "ignore-if-exists", "lookupEnabled");
    ParsingUtils.setPropertyValue(element, regionBuilder, "data-policy");
    ParsingUtils.setPropertyValue(element, regionBuilder, "persistent");
    ParsingUtils.setPropertyValue(element, regionBuilder, "shortcut");

    if (StringUtils.hasText(element.getAttribute("disk-store-ref"))) {
        ParsingUtils.setPropertyValue(element, regionBuilder, "disk-store-ref", "diskStoreName");
        regionBuilder.addDependsOn(element.getAttribute("disk-store-ref"));
    }

    ParsingUtils.parseOptionalRegionAttributes(parserContext, element, regionAttributesBuilder);
    ParsingUtils.parseSubscription(parserContext, element, regionAttributesBuilder);
    ParsingUtils.parseStatistics(element, regionAttributesBuilder);
    ParsingUtils.parseMembershipAttributes(parserContext, element, regionAttributesBuilder);
    ParsingUtils.parseExpiration(parserContext, element, regionAttributesBuilder);
    ParsingUtils.parseEviction(parserContext, element, regionAttributesBuilder);
    ParsingUtils.parseCompressor(parserContext, element, regionAttributesBuilder);

    String enableGateway = element.getAttribute("enable-gateway");
    String hubId = element.getAttribute("hub-id");

    // Factory will enable gateway if it is not set and hub-id is set.
    if (StringUtils.hasText(enableGateway)) {
        if (GemfireUtils.isGemfireVersion7OrAbove()) {
            log.warn("'enable-gateway' has been deprecated since Gemfire 7.0");
        }
    }

    ParsingUtils.setPropertyValue(element, regionBuilder, "enable-gateway");

    if (StringUtils.hasText(hubId)) {
        if (GemfireUtils.isGemfireVersion7OrAbove()) {
            log.warn("'hub-id' has been deprecated since Gemfire 7.0");
        }
        if (!CollectionUtils.isEmpty(DomUtils.getChildElementsByTagName(element, "gateway-sender"))) {
            parserContext.getReaderContext().error("specifying both 'hub-id' and 'gateway-sender' is invalid",
                    element);
        }
    }

    ParsingUtils.setPropertyValue(element, regionBuilder, "hub-id");

    parseCollectionOfCustomSubElements(element, parserContext, regionBuilder, AsyncEventQueue.class.getName(),
            "async-event-queue", "asyncEventQueues");

    parseCollectionOfCustomSubElements(element, parserContext, regionBuilder, GatewaySender.class.getName(),
            "gateway-sender", "gatewaySenders");

    List<Element> subElements = DomUtils.getChildElements(element);

    for (Element subElement : subElements) {
        if (subElement.getLocalName().equals("cache-listener")) {
            regionBuilder.addPropertyValue("cacheListeners",
                    ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, regionBuilder));
        } else if (subElement.getLocalName().equals("cache-loader")) {
            regionBuilder.addPropertyValue("cacheLoader", ParsingUtils
                    .parseRefOrSingleNestedBeanDeclaration(parserContext, subElement, regionBuilder));
        } else if (subElement.getLocalName().equals("cache-writer")) {
            regionBuilder.addPropertyValue("cacheWriter", ParsingUtils
                    .parseRefOrSingleNestedBeanDeclaration(parserContext, subElement, regionBuilder));
        }
    }

    if (!subRegion) {
        parseSubRegions(element, parserContext, resolvedCacheRef);
    }
}

From source file:org.springframework.data.gemfire.config.AbstractRegionParser.java

private void findSubRegionElements(Element parent, String parentPath,
        Map<String, Element> allSubRegionElements) {
    for (Element element : DomUtils.getChildElements(parent)) {
        if (element.getLocalName().endsWith("region")) {
            String subRegionName = getRegionNameFromElement(element);
            String subRegionPath = buildSubRegionPath(parentPath, subRegionName);
            allSubRegionElements.put(subRegionPath, element);
            findSubRegionElements(element, subRegionPath, allSubRegionElements);
        }/*from www.  ja v  a  2 s  . c  o  m*/
    }
}

From source file:org.springframework.data.gemfire.config.ParsingUtils.java

static Object getBeanReference(ParserContext parserContext, Element element, String refAttributeName) {
    String refAttributeValue = element.getAttribute(refAttributeName);
    Object returnValue = null;/*from w  w  w.j ava2  s . c  om*/

    if (StringUtils.hasText(refAttributeValue)) {
        if (!DomUtils.getChildElements(element).isEmpty()) {
            parserContext.getReaderContext().error(String.format(
                    "Use either the '%1$s' attribute or a nested bean declaration for '%2$s' element, but not both.",
                    refAttributeName, element.getLocalName()), element);
        }

        returnValue = new RuntimeBeanReference(refAttributeValue);
    }

    return returnValue;
}