Example usage for org.w3c.dom Node DOCUMENT_NODE

List of usage examples for org.w3c.dom Node DOCUMENT_NODE

Introduction

In this page you can find the example usage for org.w3c.dom Node DOCUMENT_NODE.

Prototype

short DOCUMENT_NODE

To view the source code for org.w3c.dom Node DOCUMENT_NODE.

Click Source Link

Document

The node is a Document.

Usage

From source file:org.energy_home.jemma.ah.internal.configurator.Configuratore.java

private void traverseConfigurationTree(Node node) {
    lastNode = node;/*from   www .  j a v a  2s .c  o  m*/
    int nodeType = node.getNodeType();

    switch (nodeType) {
    case Node.DOCUMENT_NODE:
        traverseConfigurationTree(((Document) node).getDocumentElement());
        break;

    // print element with attributes
    case Node.ELEMENT_NODE:
        NamedNodeMap attrs = node.getAttributes();
        String tag = node.getNodeName();

        if ((tag == "location") && (loadLocations)) {
            String name = attrs.getNamedItem("name").getNodeValue();
            String icon = attrs.getNamedItem("icon").getNodeValue();
            String pid = attrs.getNamedItem("pid").getNodeValue();

            locations.add(new Location(pid, name, icon));

        }
        if ((tag == "category") && (loadCategories)) {
            String name = attrs.getNamedItem("name").getNodeValue();
            String icon = attrs.getNamedItem("icon").getNodeValue();
            String pid = attrs.getNamedItem("pid").getNodeValue();

            categories.add(new Category(pid, name, icon));

        } else if (tag == "rule") {
            try {
                String rule = attrs.getNamedItem("filter").getNodeValue();
                rules.add(rule);
            } catch (Exception e) {
                log.error(e);
            }
        } else if (tag == "connect") {
            try {
                String pid1 = attrs.getNamedItem("pid1").getNodeValue();
                String pid2 = attrs.getNamedItem("pid2").getNodeValue();
                this.connAdmin.createConnection(pid1, pid2);
            } catch (Exception e) {
                log.error(e);
            }
        } else if ((tag == "appliance") && (loadAppliances)) {
            props = new Hashtable();
        } else if ((tag == "configuration")) {
            props = new Hashtable();
        } else if ((tag == "property") && (lastNode != null) && (props != null)) {
            // log.debug("last node is " + lastNode.getNodeName());
            String name = attrs.getNamedItem("name").getNodeValue();
            Object propValue = traversePropertyNode(lastNode);
            if (propValue == null) {
                log.error("null property " + name);
            } else {
                props.put(name, propValue);
            }
        }
        NodeList children = node.getChildNodes();

        if (children != null) {
            int len = children.getLength();
            for (int i = 0; i < len; i++) {
                traverseConfigurationTree(children.item(i));
            }
            if (tag.equals("appliance")) {
                // we traversed all appliances children, its time to
                // instantiate the
                // driver
                try {
                    String appliancePid = (String) props.get(Constants.SERVICE_PID);
                    if (appliancePid == null) {
                        // for backward compatibility
                        appliancePid = (String) props.get(IAppliance.APPLIANCE_PID);
                    }

                    String type = (String) props.get(IAppliance.APPLIANCE_TYPE_PROPERTY);

                    if ((appliancePid != null) && (type != null)) {
                        String locationPid = (String) props.get(IAppliance.APPLIANCE_LOCATION_PID_PROPERTY);
                        String categoryPid = (String) props.get(IAppliance.APPLIANCE_CATEGORY_PID_PROPERTY);
                        createAppliance(appliancePid, props);
                        // }
                    } else {
                        log.error("during reading configuration: unable to retrieve driver pid");
                    }
                } catch (Exception e) {
                    log.debug(e.getMessage());
                }
            } else if (tag.equals("configuration")) {
                // we traversed all appliances children, its time to
                // instantiate the
                // driver
                try {
                    configurationsVector.add(props);
                } catch (Exception e) {
                    log.debug(e.getMessage());
                }
            }
        }
        break;

    case Node.TEXT_NODE:
        break;
    }
}

From source file:org.energy_home.jemma.ah.internal.configurator.Configuratore.java

public void traverseConfigurationTreeOld(Node node) {
    lastNode = node;/*from   w  ww  . j  a  v a 2  s  . co  m*/
    int nodeType = node.getNodeType();

    switch (nodeType) {
    case Node.DOCUMENT_NODE:
        traverseConfigurationTreeOld(((Document) node).getDocumentElement());
        break;

    // print element with attributes
    case Node.ELEMENT_NODE:
        NamedNodeMap attrs = node.getAttributes();
        String tag = node.getNodeName();

        if ((tag == "location") && (loadLocations)) {
            String name = attrs.getNamedItem("name").getNodeValue();
            String icon = attrs.getNamedItem("icon").getNodeValue();
            String pid = attrs.getNamedItem("pid").getNodeValue();

            try {
                this.hacService.addLocation(new Location(pid, name, icon));
            } catch (Throwable e) {
                // this is a duplicate location, skip it by putting a log
                // message
                log.warn("error while adding location found reading configuration file");
            }
        }
        if ((tag == "category") && (loadCategories)) {
            String name = attrs.getNamedItem("name").getNodeValue();
            String icon = attrs.getNamedItem("icon").getNodeValue();
            String pid = attrs.getNamedItem("pid").getNodeValue();

            categories.add(new Category(pid, name, icon));
        } else if (tag == "rule") {
            try {
                String rule = attrs.getNamedItem("filter").getNodeValue();
                rules.add(rule);
                // this.connAdmin.addBindRule(rule);
            } catch (Exception e) {
                log.error(e);
            }
        } else if (tag == "connect") {
            try {
                String pid1 = attrs.getNamedItem("pid1").getNodeValue();
                String pid2 = attrs.getNamedItem("pid2").getNodeValue();
                //this.connAdmin.createConnection(pid1, pid2);
            } catch (Exception e) {
                log.error(e);
            }
        } else if ((tag == "appliance") && (loadAppliances)) {
            props = new Hashtable();
        } else if ((tag == "property") && (lastNode != null) && (props != null)) {
            // log.debug("last node is " + lastNode.getNodeName());
            String name = attrs.getNamedItem("name").getNodeValue();
            Object propValue = traversePropertyNode(lastNode);
            if (propValue == null) {
                log.error("null property " + name);
            } else {
                props.put(name, propValue);
            }
        }
        NodeList children = node.getChildNodes();

        if (children != null) {
            int len = children.getLength();
            for (int i = 0; i < len; i++) {
                traverseConfigurationTreeOld(children.item(i));
            }
            if (tag.equals("appliance")) {
                // we traversed all appliances children, its time to
                // instantiate the
                // driver
                try {
                    String appliancePid = (String) props.get(Constants.SERVICE_PID);
                    if (appliancePid == null) {
                        // for backward compatibility
                        appliancePid = (String) props.get(IAppliance.APPLIANCE_PID);
                    }

                    String type = (String) props.get(IAppliance.APPLIANCE_TYPE_PROPERTY);

                    if ((appliancePid != null) && (type != null)) {
                        String locationPid = (String) props.get(IAppliance.APPLIANCE_LOCATION_PID_PROPERTY);
                        String categoryPid = (String) props.get(IAppliance.APPLIANCE_CATEGORY_PID_PROPERTY);
                        createAppliance(appliancePid, props);
                        // }
                    } else {
                        log.error("during reading configuration: unable to retrieve driver pid");
                    }
                } catch (Exception e) {
                    log.debug(e.getMessage());
                }
            }
        }
        break;

    case Node.TEXT_NODE:
        break;
    }
}

From source file:org.energy_home.jemma.ah.internal.hac.lib.HacService.java

protected void traverseConfigurationTree(Node node) {
    lastNode = node;//  w  ww  .ja v  a2 s .  c om
    int nodeType = node.getNodeType();

    switch (nodeType) {
    case Node.DOCUMENT_NODE:
        traverseConfigurationTree(((Document) node).getDocumentElement());
        break;

    // print element with attributes
    case Node.ELEMENT_NODE:
        NamedNodeMap attrs = node.getAttributes();
        String tag = node.getNodeName();

        if ((tag == "location") && (loadLocations)) {
            String name = attrs.getNamedItem("name").getNodeValue();
            String icon = attrs.getNamedItem("icon").getNodeValue();
            String pid = attrs.getNamedItem("pid").getNodeValue();

            try {
                this.locationsDb.add(new Location(pid, name, icon));
            } catch (HacException e) {
                // this is a duplicate location, skip it by putting a log
                // message
                LOG.warn("error while adding location found reading configuration file", e);
            }
        }
        if (tag == "category") {
            String name = attrs.getNamedItem("name").getNodeValue();
            String icon = attrs.getNamedItem("icon").getNodeValue();
            String pid = attrs.getNamedItem("pid").getNodeValue();

            try {
                categories.add(new Category(pid, name, icon));
            } catch (HacException e) {
                // this is a duplicate location, skip it by putting a log
                // message
                LOG.warn("error while adding location found reading configuration file", e);
            }
        } else if ((tag == "appliance") && (loadAppliances)) {
            /*
             * String name = attrs.getNamedItem("name").getNodeValue();
             * if (log.isDebugEnabled()) log.debug("reading va " + name);
             */
            properties = new Hashtable();
        } else if ((tag == "property") && (lastNode != null) && (properties != null)) {
            // log.debug("last node is " + lastNode.getNodeName());
            String name = attrs.getNamedItem("name").getNodeValue();

            // Node item = attrs.getNamedItem("type");

            // String type = null;
            //
            // if (item != null) {
            // type = item.getNodeValue();
            // }

            Object propValue = traversePropertyNode(lastNode);
            if (propValue == null) {
                LOG.debug("null property " + name);
            } else {
                properties.put(name, propValue);
            }
        }
        NodeList children = node.getChildNodes();

        if (children != null) {
            int len = children.getLength();
            for (int i = 0; i < len; i++) {
                traverseConfigurationTree(children.item(i));
            }
            if (tag.equals("appliance")) {
                // we traversed all appliances children, its time to
                // instantiate the
                // driver
                try {
                    String appliancePid = (String) properties.get(Constants.SERVICE_PID);
                    if (appliancePid == null) {
                        // for backward compatibility
                        appliancePid = (String) properties.get(IAppliance.APPLIANCE_PID);
                    }

                    String type = (String) properties.get(IAppliance.APPLIANCE_TYPE_PROPERTY);

                    if ((appliancePid != null) && (type != null)) {
                        String locationPid = (String) properties
                                .get(IAppliance.APPLIANCE_LOCATION_PID_PROPERTY);
                        String categoryPid = (String) properties
                                .get(IAppliance.APPLIANCE_CATEGORY_PID_PROPERTY);
                        if ((locationPid != null) && (this.locationsDb.getByPid(locationPid) == null)) {
                            LOG.debug("WARNING: device " + servicePid + " specifies an unknown location pid");
                        } else if ((categoryPid != null)
                                && (this.categories.getCategoryByPid(categoryPid) == null)) {
                            LOG.debug("WARNING: device " + servicePid + " specifies an unknown category pid");
                        } else {
                            createConfiguration(type, appliancePid, properties);
                        }
                    } else {
                        LOG.debug("during reading configuration: unable to retrieve driver pid");
                    }
                } catch (Exception e) {
                    LOG.warn(e.getMessage(), e);
                }
            }
        }
        break;

    case Node.TEXT_NODE:
        break;
    }
}

From source file:org.erdc.cobie.shared.spreadsheetml.transformation.cobietab.COBieSpreadSheet.java

License:asdf

public static void nodeToStream(Node node, PrintWriter out) {
    String workSheetName = "";
    boolean canonical = false;
    // is there anything to do?
    if (node == null) {
        return;//from  ww w  .j  a va2s  .  c  o m
    }

    int type = node.getNodeType();
    switch (type) {
    // print document
    case Node.DOCUMENT_NODE: {
        if (!canonical) {
            out.println("<?xml version=\"1.0\"?>");
        }
        // print(((Document)node).getDocumentElement());

        NodeList children = node.getChildNodes();
        for (int iChild = 0; iChild < children.getLength(); iChild++) {
            nodeToStream(children.item(iChild), out);
        }
        out.flush();
        break;
    }

    // print element with attributes
    case Node.ELEMENT_NODE: {
        out.print('<');
        out.print(node.getNodeName());
        Attr attrs[] = sortAttributes(node.getAttributes());
        for (int i = 0; i < attrs.length; i++) {
            Attr attr = attrs[i];
            if (((node.getNodeName().equalsIgnoreCase("Worksheet")
                    || node.getNodeName().equalsIgnoreCase("ss:Worksheet"))
                    && attr.getName().equalsIgnoreCase("Name")) || attr.getName().equalsIgnoreCase("ss:Name")) {
                workSheetName = normalize(attr.getNodeValue());
            }
            out.print(' ');
            out.print(attr.getNodeName());
            out.print("=\"");
            out.print(normalize(attr.getNodeValue()));
            out.print('"');
        }
        out.print('>');
        out.flush();
        NodeList children = node.getChildNodes();
        if (children != null) {
            int len = children.getLength();
            for (int i = 0; i < len; i++) {
                nodeToStream(children.item(i), out);
            }
        }
        break;
    }

    // handle entity reference nodes
    case Node.ENTITY_REFERENCE_NODE: {
        if (canonical) {
            NodeList children = node.getChildNodes();
            if (children != null) {
                int len = children.getLength();
                for (int i = 0; i < len; i++) {
                    nodeToStream(children.item(i), out);
                }
            }
        } else {
            out.print('&');
            out.print(node.getNodeName());
            out.print(';');
        }
        break;
    }

    // print cdata sections
    case Node.CDATA_SECTION_NODE: {
        if (canonical) {
            out.print(normalize(node.getNodeValue()));
        } else {
            out.print("<![CDATA[");
            out.print(node.getNodeValue());
            out.print("]]>");
        }
        break;
    }

    // print text
    case Node.TEXT_NODE: {
        out.print(normalize(node.getNodeValue()));
        break;
    }

    // print processing instruction
    case Node.PROCESSING_INSTRUCTION_NODE: {
        out.print("<?");
        out.print(node.getNodeName());
        String data = node.getNodeValue();
        if ((data != null) && (data.length() > 0)) {
            out.print(' ');
            out.print(data);
        }
        out.print("?>");
        break;
    }

    // print comment
    case Node.COMMENT_NODE: {
        out.print("<!--");
        String data = node.getNodeValue();
        if (data != null) {
            out.print(data);
        }
        out.print("-->");
        break;
    }
    }

    if (type == Node.ELEMENT_NODE) {
        if ((node.getNodeName().equalsIgnoreCase("Worksheet")
                || node.getNodeName().equalsIgnoreCase("ss:Worksheet")) && (workSheetName.length() > 0)) {
            out.print(printCOBieSheetDataValidation(workSheetName));
        }
        out.print("</");
        out.print(node.getNodeName());
        out.print('>');
    }

    out.flush();

}

From source file:org.etudes.component.app.melete.SubSectionUtilImpl.java

public org.w3c.dom.Element getNextSection(org.w3c.dom.Element currItem) throws Exception {
    if (currItem == null) {
        currParent = subSectionW3CDOM.getDocumentElement();
        currLastSection = (org.w3c.dom.Element) currParent.getLastChild();
        return (org.w3c.dom.Element) currParent.getFirstChild();
    }//from w  ww .j  a v  a  2s. c  o m

    if (currItem.hasChildNodes()) {
        currParent = currItem;
        return (org.w3c.dom.Element) currItem.getFirstChild();
    }

    if (currParent == null)
        currParent = currItem.getParentNode();

    if (currItem.equals((org.w3c.dom.Element) currParent.getLastChild())) {
        while (true) {
            if (currParent.getNodeType() == Node.DOCUMENT_NODE)
                return null;
            if (!currParent.equals(currLastSection) && !currItem.equals(currLastSection)) {
                currItem = (org.w3c.dom.Element) currParent.getNextSibling();
                if (currItem == null) {
                    logger.debug("going a level up to fetch sibling");
                    currItem = (org.w3c.dom.Element) currParent;
                    currParent = currItem.getParentNode();
                    continue;
                }
                currParent = currItem.getParentNode();
                return currItem;
            } else
                return null;
        }
    } else
        return (org.w3c.dom.Element) currItem.getNextSibling();
}

From source file:org.exist.http.urlrewrite.XQueryURLRewrite.java

@Override
protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
        throws IOException, ServletException {
    if (rewriteConfig == null) {
        configure();/*from w ww.  jav a2 s  .  c  o m*/
        rewriteConfig = new RewriteConfig(this);
    }

    final long start = System.currentTimeMillis();
    final HttpServletRequest request = servletRequest;
    final HttpServletResponse response = servletResponse;

    if (LOG.isTraceEnabled()) {
        LOG.trace(request.getRequestURI());
    }
    final Descriptor descriptor = Descriptor.getDescriptorSingleton();
    if (descriptor != null && descriptor.requestsFiltered()) {
        final String attr = (String) request.getAttribute("XQueryURLRewrite.forwarded");
        if (attr == null) {
            //                request = new HttpServletRequestWrapper(request, /*formEncoding*/ "utf-8" );
            //logs the request if specified in the descriptor
            descriptor.doLogRequestInReplayLog(request);

            request.setAttribute("XQueryURLRewrite.forwarded", "true");
        }
    }

    Subject user = defaultUser;

    Subject requestUser = HttpAccount.getUserFromServletRequest(request);
    if (requestUser != null) {
        user = requestUser;
    } else {
        // Secondly try basic authentication
        final String auth = request.getHeader("Authorization");
        if (auth != null) {
            requestUser = authenticator.authenticate(request, response);
            if (requestUser != null) {
                user = requestUser;
            }
        }
    }

    try {
        configure();
        //checkCache(user);

        final RequestWrapper modifiedRequest = new RequestWrapper(request);
        final URLRewrite staticRewrite = rewriteConfig.lookup(modifiedRequest);
        if (staticRewrite != null && !staticRewrite.isControllerForward()) {
            modifiedRequest.setPaths(staticRewrite.resolve(modifiedRequest), staticRewrite.getPrefix());

            if (LOG.isTraceEnabled()) {
                LOG.trace("Forwarding to target: " + staticRewrite.getTarget());
            }
            staticRewrite.doRewrite(modifiedRequest, response);
        } else {

            if (LOG.isTraceEnabled()) {
                LOG.trace("Processing request URI: " + request.getRequestURI());
            }
            if (staticRewrite != null) {
                // fix the request URI
                staticRewrite.updateRequest(modifiedRequest);
            }

            // check if the request URI is already in the url cache
            ModelAndView modelView = getFromCache(request.getHeader("Host") + request.getRequestURI(), user);

            if (LOG.isDebugEnabled()) {
                LOG.debug("Checked cache for URI: " + modifiedRequest.getRequestURI() + " original: "
                        + request.getRequestURI());
            }
            // no: create a new model and view configuration
            if (modelView == null) {
                modelView = new ModelAndView();
                // Execute the query
                Sequence result = Sequence.EMPTY_SEQUENCE;
                DBBroker broker = null;
                try {
                    broker = pool.get(user);
                    modifiedRequest.setAttribute(RQ_ATTR_REQUEST_URI, request.getRequestURI());

                    final Properties outputProperties = new Properties();

                    outputProperties.setProperty(OutputKeys.INDENT, "yes");
                    outputProperties.setProperty(OutputKeys.ENCODING, "UTF-8");
                    outputProperties.setProperty(OutputKeys.MEDIA_TYPE, MimeType.XML_TYPE.getName());

                    result = runQuery(broker, modifiedRequest, response, modelView, staticRewrite,
                            outputProperties);

                    logResult(broker, result);

                    if (response.isCommitted()) {
                        return;
                    }

                    // process the query result
                    if (result.getItemCount() == 1) {
                        final Item resource = result.itemAt(0);
                        if (!Type.subTypeOf(resource.getType(), Type.NODE)) {
                            throw new ServletException(
                                    "XQueryURLRewrite: urlrewrite query should return an element!");
                        }
                        Node node = ((NodeValue) resource).getNode();
                        if (node.getNodeType() == Node.DOCUMENT_NODE) {
                            node = ((Document) node).getDocumentElement();
                        }
                        if (node.getNodeType() != Node.ELEMENT_NODE) {
                            //throw new ServletException("Redirect XQuery should return an XML element!");
                            response(broker, response, outputProperties, result);
                            return;
                        }
                        Element elem = (Element) node;
                        if (!(Namespaces.EXIST_NS.equals(elem.getNamespaceURI()))) {
                            response(broker, response, outputProperties, result);
                            return;
                            //                            throw new ServletException("Redirect XQuery should return an element in namespace " + Namespaces.EXIST_NS);
                        }

                        if (Namespaces.EXIST_NS.equals(elem.getNamespaceURI())
                                && "dispatch".equals(elem.getLocalName())) {
                            node = elem.getFirstChild();
                            while (node != null) {
                                if (node.getNodeType() == Node.ELEMENT_NODE
                                        && Namespaces.EXIST_NS.equals(node.getNamespaceURI())) {
                                    final Element action = (Element) node;
                                    if ("view".equals(action.getLocalName())) {
                                        parseViews(modifiedRequest, action, modelView);
                                    } else if ("error-handler".equals(action.getLocalName())) {
                                        parseErrorHandlers(modifiedRequest, action, modelView);
                                    } else if ("cache-control".equals(action.getLocalName())) {
                                        final String option = action.getAttribute("cache");
                                        modelView.setUseCache("yes".equals(option));
                                    } else {
                                        final URLRewrite urw = parseAction(modifiedRequest, action);
                                        if (urw != null) {
                                            modelView.setModel(urw);
                                        }
                                    }
                                }
                                node = node.getNextSibling();
                            }
                            if (modelView.getModel() == null) {
                                modelView.setModel(new PassThrough(config, elem, modifiedRequest));
                            }
                        } else if (Namespaces.EXIST_NS.equals(elem.getNamespaceURI())
                                && "ignore".equals(elem.getLocalName())) {
                            modelView.setModel(new PassThrough(config, elem, modifiedRequest));
                            final NodeList nl = elem.getElementsByTagNameNS(Namespaces.EXIST_NS,
                                    "cache-control");
                            if (nl.getLength() > 0) {
                                elem = (Element) nl.item(0);
                                final String option = elem.getAttribute("cache");
                                modelView.setUseCache("yes".equals(option));
                            }
                        } else {
                            response(broker, response, outputProperties, result);
                            return;
                        }
                    } else if (result.getItemCount() > 1) {
                        response(broker, response, outputProperties, result);
                        return;
                    }

                    if (modelView.useCache()) {
                        LOG.debug("Caching request to " + request.getRequestURI());
                        urlCache.put(modifiedRequest.getHeader("Host") + request.getRequestURI(), modelView);
                    }

                } finally {
                    pool.release(broker);
                }

                // store the original request URI to org.exist.forward.request-uri
                modifiedRequest.setAttribute(RQ_ATTR_REQUEST_URI, request.getRequestURI());
                modifiedRequest.setAttribute(RQ_ATTR_SERVLET_PATH, request.getServletPath());

            }
            if (LOG.isTraceEnabled()) {
                LOG.trace("URLRewrite took " + (System.currentTimeMillis() - start) + "ms.");
            }
            final HttpServletResponse wrappedResponse = new CachingResponseWrapper(response,
                    modelView.hasViews() || modelView.hasErrorHandlers());
            if (modelView.getModel() == null) {
                modelView.setModel(new PassThrough(config, modifiedRequest));
            }

            if (staticRewrite != null) {
                if (modelView.getModel().doResolve()) {
                    staticRewrite.rewriteRequest(modifiedRequest);
                } else {
                    modelView.getModel().setAbsolutePath(modifiedRequest);
                }
            }
            modifiedRequest.allowCaching(!modelView.hasViews());
            doRewrite(modelView.getModel(), modifiedRequest, wrappedResponse);

            int status = ((CachingResponseWrapper) wrappedResponse).getStatus();
            if (status == HttpServletResponse.SC_NOT_MODIFIED) {
                response.flushBuffer();
            } else if (status < 400) {
                if (modelView.hasViews()) {
                    applyViews(modelView, modelView.views, response, modifiedRequest, wrappedResponse);
                } else {
                    ((CachingResponseWrapper) wrappedResponse).flush();
                }
            } else {
                // HTTP response code indicates an error
                if (modelView.hasErrorHandlers()) {
                    final byte[] data = ((CachingResponseWrapper) wrappedResponse).getData();
                    if (data != null) {
                        modifiedRequest.setAttribute(RQ_ATTR_ERROR, new String(data, UTF_8));
                    }
                    applyViews(modelView, modelView.errorHandlers, response, modifiedRequest, wrappedResponse);
                } else {
                    flushError(response, wrappedResponse);
                }
            }
        }
        //            Sequence result;
        //            if ((result = (Sequence) request.getAttribute(RQ_ATTR_RESULT)) != null) {
        //                writeResults(response, broker, result);
        //            }
    } catch (final Throwable e) {
        LOG.error("Error while processing " + servletRequest.getRequestURI() + ": " + e.getMessage(), e);
        throw new ServletException("An error occurred while processing request to "
                + servletRequest.getRequestURI() + ": " + e.getMessage(), e);

    }
}

From source file:org.getobjects.appserver.templates.WOxElemBuilder.java

public WOElement buildNode(Node _node, WOxElemBuilder _builder) {
    if (_node == null)
        return null;

    switch (_node.getNodeType()) {
    case Node.ELEMENT_NODE:
        return this.buildElement((Element) _node, _builder);
    case Node.TEXT_NODE:
        return this.buildText((Text) _node, _builder);
    case Node.CDATA_SECTION_NODE:
        return this.buildCDATASection((CDATASection) _node, _builder);
    case Node.COMMENT_NODE:
        return this.buildComment((Comment) _node, _builder);
    case Node.DOCUMENT_NODE:
        return this.buildDocument((Document) _node, _builder);

    default: {//from   w w  w.ja va  2s.c o  m
        if (this.nextBuilder != null)
            return this.nextBuilder.buildNode(_node, _builder);

        this.log.error("unsupported node type: " + _node);
    }
    }
    return null;
}

From source file:org.infoscoop.util.DocumentBuildFilter.java

public void characters(XMLString arg0, Augmentations arg1) throws XNIException {
    if (cdata) {// ww w  . ja v  a  2s .c o  m
        current.appendChild(doc.createCDATASection(arg0.toString()));
    } else if (entity) {
        // ignore
    } else if (current.getNodeType() != Node.DOCUMENT_NODE) {
        try {
            current.appendChild(doc.createTextNode(arg0.toString()));
        } catch (Exception ex) {
            log.error(current + "," + current.getNodeType());
            throw new RuntimeException(ex);
        }
    }
}

From source file:org.jbpm.bpel.xml.BpelReader.java

public void read(BpelProcessDefinition processDefinition, DOMSource source) {
    // save the document location
    String location = source.getSystemId();
    processDefinition.setLocation(location);

    // prepare a locator of imported documents, relative to the process document location
    ProcessWsdlLocator wsdlLocator = null;
    if (location != null) {
        try {//from   w w  w.ja  va 2 s.c o  m
            wsdlLocator = new ProcessWsdlLocator(new URI(location));
            wsdlLocator.setProblemHandler(problemHandler);
        } catch (URISyntaxException e) {
            problemHandler.add(new Problem(Problem.LEVEL_ERROR, "source system id is invalid"));
        }
    }

    Element processElem;
    Node node = source.getNode();

    switch (node.getNodeType()) {
    case Node.DOCUMENT_NODE:
        processElem = ((Document) node).getDocumentElement();
        break;
    case Node.ELEMENT_NODE:
        processElem = (Element) node;
        break;
    default:
        problemHandler.add(new Problem(Problem.LEVEL_ERROR,
                "source node must be either an element or a document: " + node));
        return;
    }

    // read process definition
    read(processDefinition, processElem, wsdlLocator);
}

From source file:org.jbpm.bpel.xml.util.XmlUtil.java

public static void setObjectValue(Node node, Object value) {
    switch (node.getNodeType()) {
    case Node.ELEMENT_NODE:
        setObjectValue((Element) node, value);
        break;/*from  w ww . j  av  a  2s  .  co m*/
    case Node.DOCUMENT_NODE:
        setObjectValue(((Document) node).getDocumentElement(), value);
        break;
    default:
        // BPEL-243 throw selectionFailure if the source is an EII with xsi:nil=true
        if (value instanceof Element) {
            String nil = ((Element) value).getAttributeNS(BpelConstants.NS_XML_SCHEMA_INSTANCE,
                    BpelConstants.ATTR_NIL);
            if (DatatypeUtil.parseBoolean(nil) == Boolean.TRUE)
                throw new BpelFaultException(BpelConstants.FAULT_SELECTION_FAILURE);
        }
        // replace content
        node.setNodeValue(DatatypeUtil.toString(value));
    }
}