Package com.volantis.xml.pipeline.sax

Examples of com.volantis.xml.pipeline.sax.XMLPipelineContext


    // javadoc inherited
    public void setPipeline(XMLPipeline pipeline) {
        super.setPipeline(pipeline);

        // get hold of the pipeline context
        XMLPipelineContext context = getPipelineContext();

        // get hold of the pipeline configuration
        XMLPipelineConfiguration pipelineConfiguration =
                context.getPipelineConfiguration();

        configuration = (WSDriverConfiguration)pipelineConfiguration.
                retrieveConfiguration(WSDriverConfiguration.class);

        if (configuration == null) {
            // cannot get hold of the configuration. As this is fatal
            // deliver a fatal error down the pipeline
            XMLPipelineException error = new XMLPipelineException(
                    "Could not retrieve the Web Service configuration",
                    context.getCurrentLocator());

            try {
                pipeline.getPipelineProcess().fatalError(error);
            } catch (SAXException e) {
                // cannot continue so throw a runtime exception
View Full Code Here


        EnvironmentContext environmentContext =
                ContextInternals.getEnvironmentContext(mcsContext);

        // The getXMLReader() call above will set up the pipelineContext in
        // the environmentContext.  See MarlinSAXHelper.setPipelineContext()
        XMLPipelineContext pipelineContext =
                environmentContext.getPipelineContext();

        // Set the Base URI in the pipeline's context
        URL baseURI = this.getServletContext().getResource("/");
        if (logger.isDebugEnabled()) {
            logger.debug("Setting Base URI " + baseURI.toExternalForm());
        }
        pipelineContext.pushBaseURI(baseURI.toExternalForm());

        reader.parse(new InputSource(msgStream));
    }
View Full Code Here

    // javadoc inherited from interface
    public void stopProcess() throws SAXException {
        // Each request has a single operation and a single message. Both
        // of these should have been set as properties in the pipeline context
        // by the time we get here.
        XMLPipelineContext context = getPipelineContext();
        if (!context.inErrorRecoveryMode()) {
            Locator locator = context.getCurrentLocator();

            Operation operation =
                    (Operation)context.getProperty(Operation.class);
            if (operation == null) {
                String errorMessage =
                        "Could not find the operation for this request";
                fatalError(new XMLPipelineException(errorMessage, locator));
            }

            Message message = (Message)context.getProperty(Message.class);
            if (message == null) {
                String errorMessage =
                        "Could not find the message for this request";
                fatalError(new XMLPipelineException(errorMessage, locator));
            }
View Full Code Here

    private void forwardMessageAsXML(Message message)
            throws SAXException, IOException {

        XMLProcess consumer = getNextProcess();

        XMLPipelineContext context = getPipelineContext();

        String partNamespace = (String)
                context.getProperty(PART_NAMESPACE_URI_KEY);
        String partPrefix = (String)context.getProperty(PART_PREFIX_KEY);

        String responseNamespace = configuration.getResponseNamespaceURI();
        String responsePrefix = configuration.getResponseDefaultPrefixURI();

        NamespacePrefixTracker namespaceManager =
                context.getNamespacePrefixTracker();
        namespaceManager.startPrefixMapping(responsePrefix,
                                            responseNamespace);

        consumer.startPrefixMapping(responsePrefix, responseNamespace);
View Full Code Here

            if (catalog != null) {
                WSDLEntry entry = catalog.retrieveWSDLEntry(wsdlURI);

                if (entry != null) {
                    XMLPipelineContext context = getPipelineContext();
                    wsdlInputSource = entry.provideAlternativeInputSource(
                            context, manager);
                }
            }
        }
View Full Code Here

    // Javadoc inherited.
    public void doAction(DynamicProcess dynamicProcess)
            throws SAXException {

        XMLPipelineContext context = dynamicProcess.getPipelineContext();
        if (!context.inErrorRecoveryMode()) {
            model.endTemplate();
        }

        // Remove the process.
        dynamicProcess.removeProcess(process);

        if (!context.inErrorRecoveryMode()) {
            Object popped = context.popObject();
            if (popped != model) {
                XMLPipelineException error = new XMLPipelineException(
                        "Expected to remove object " + model +
                        "from the pipeline, but actually removed " + popped,
                        context.getCurrentLocator());
                // send the error down the pipeline
                dynamicProcess.fatalError(error);
            }
        }
    }
View Full Code Here

    // Javadoc inherited.
    public Object startElement(
            DynamicProcess dynamicProcess, ExpandedName element,
            Attributes attributes) throws SAXException {

        XMLPipelineContext pipelineContext =
                dynamicProcess.getPipelineContext();

        // Get the model for containing template for bindings that reference
        // values in containing templates, may be null.
        TemplateModel containing = (TemplateModel) pipelineContext.findObject(
                TemplateModel.class);

        // Create the template process and add it to the pipeline.
        TemplateProcess process = new TemplateProcess(containing);
        dynamicProcess.addProcess(process);

        // Push the template model onto the stack so it can be picked up by
        // nested elements.
        TemplateModel model = process;
        pipelineContext.pushObject(model, false);

        // Start the template.
        model.startTemplate();

        // The presence or absence of the href attribute determines the gross
View Full Code Here

        }

        // Get the current state, create an element specific wrapper and push
        // it as the new state. The newly created state inherits the current
        // selidname from the containing state.
        XMLPipelineContext pipelineContext = getPipelineContext();
        State containingState = peekState();
        State state = diSelectElement.createState(containingState, attributes);
        states.push(state);
        int index;

        // The attributes used on output if they have changed. This is created
        // only when it is needed.
        AttributesImpl output = null;

        // Check to see whether the current state knows whether or not to
        // process the body of the element. This supports the
        // select / when / otherwise elements.
        if (!state.canProcessBody()) {
            // The current state indicates that the element and its body should
            // not be processed so ignore this element and all its children.
            pipelineContext.getFlowControlManager().exitCurrentElement();

            // Remember that the body was not processed.
            state.setProcessBody(false);

            // Don't forward the event on.
            return;
        }

        // Determine whether this event can be forwarded to the next process,
        // this is element specific.
        boolean forwardEvent = diSelectElement.getForwardEvent();

        // Check to see whether the element supports an expr attribute and if
        // so whether it is an element specific attribute, of the global
        // diselect one.
        String exprAttributeURI = diSelectElement.getExprAttributeURI();
        if (exprAttributeURI != null) {

            // Check to see whether there is an expr attribute, use the index
            // as we may need to remove the attribute.
            index = attributes.getIndex(exprAttributeURI, "expr");
            if (index != -1) {
                String value = attributes.getValue(index);
                try {
                    Expression expression = parser.parse(value);

                    // obtain the ExpressionContext from the PipelineContext
                    // the ExpressionContext is needed in order to evaluate the
                    // expression parsed
                    ExpressionContext expressionContext =
                            pipelineContext.getExpressionContext();

                    // Evaluate the expression and cast to a boolean.
                    boolean result = PipelineExpressionHelper.fnBoolean(
                            expression.evaluate(
                                    expressionContext).getSequence())
                            .asJavaBoolean();

                    if (!result) {
                        // The expression evaluated to false so ignore this
                        // element and all its children.
                        pipelineContext.getFlowControlManager()
                                .exitCurrentElement();

                        // Remember that the body was not processed.
                        state.setProcessBody(false);

                        // Don't forward the event on.
                        return;
                    }

                    // Only update the attributes if the event is being
                    // forwarded, otherwise it is a waste of time.
                    if (forwardEvent) {
                        // The element is included but we need to remove the
                        // sel:expr attribute.
                        if (output == null) {
                            output = new AttributesImpl(attributes);

                            // Use the output attributes as the input to ensure
                            // that indeces match.
                            attributes = output;
                        }
                        output.removeAttribute(index);
                    }

                } catch (ExpressionException e) {
                    // something went wrong when evaluating the xpath.
                    // Send an error down the pipeline
                    Locator locator = pipelineContext.getCurrentLocator();
                    XMLPipelineException se = new XMLPipelineException(
                            "Could not evaluate the expression " +
                                    value,
                            locator,
                            e);

                    fatalError(se);
                }
            }
        }

        // Remember that the body of the element is to be processed, this will
        // ensure that the matching end element event is forwarded if
        // necessary, and if relevant ensure that the select / when / otherwise
        // combination works correctly.
        state.setProcessBody(true);

        // Get the current name of the attribute that will be used to replace
        // the diselect:selid attribute.
        ExpandedName selidName = state.getSelidName();

        // Check to see whether the element supports a selidname attribute and
        // if so whether it is an element specific attribute, of the global
        // diselect one.
        String selidNameAttributeURI =
                diSelectElement.getSelidNameAttributeURI();
        if (selidNameAttributeURI != null) {

            // Check to see whether there is a selidname attribute, use the
            // index as we may need to remove the attribute.
            index = attributes.getIndex(selidNameAttributeURI, "selidname");
            if (index != -1) {
                String value = attributes.getValue(index);

                // Only update the attributes if the event is being
                // forwarded, otherwise it is a waste of time.
                if (forwardEvent) {
                    // Remove the attribute.
                    if (output == null) {
                        output = new AttributesImpl(attributes);

                        // Use the output attributes as the input to ensure that
                        // indeces match.
                        attributes = output;
                    }
                    output.removeAttribute(index);
                }

                // Resolve the value to an ExpandedName, update the value for
                // the current element and store it away just in case it is
                // needed for descendant elements.
                QName qname = new ImmutableQName(value);
                selidName = pipelineContext.getNamespacePrefixTracker()
                        .resolveQName(qname, null);
                state.setSelidName(selidName);
            }
        }

        // Only elements outside the diselect namespace support the
        // diselect:selid attribute.
        if (diSelectElement.canHaveSelidAttribute()) {
            // Now check for sel:selid attribute.
            index = attributes.getIndex(Constants.DISELECT_NAMESPACE, "selid");
            if (index != -1) {

                String idURI = selidName.getNamespaceURI();
                String idLocalName = selidName.getLocalName();
                String idQName;

                // Construct the selid attribute's qname, this is dependent on
                // the namespace of the selidName and the namespace prefix
                // mappings in scope.
                if (idURI.equals("")) {
                    // The attribute has no namespace so the qname is the same
                    // as the local name.
                    idQName = idLocalName;
                } else {
                    String prefix = null;

                    // Find the first non empty prefix associated with the specified
                    // array. A non-empty prefix is required
                    String[] prefixes =
                            pipelineContext.getNamespacePrefixTracker()
                                    .getNamespacePrefixes(idURI);
                    for (String p : prefixes) {
                        if (!p.equals("")) {
                            prefix = p;
                            break;
View Full Code Here

    // Javadoc inherited.
    public void doAction(DynamicProcess dynamicProcess) throws SAXException {

        TValue value = model.getParameterBlock().query(parameter);

        XMLPipelineContext pipelineContext = dynamicProcess.getPipelineContext();

        ExpressionContext context = pipelineContext.getExpressionContext();

        // The given name could be a prefixed name, so go through these
        // hoops to ensure that we register the variable against the
        // correct namespace (the namespace for no prefix is "no namespace"
        // according to http://www.w3.org/TR/xpath20/#id-variables - this
View Full Code Here

        cup.setPipeline(pipeline);

        cup.setNextProcess(process);
        cup.startProcess();

        XMLPipelineContext context = pipeline.getPipelineContext();
        Locator playLocator = player.getLocator();
        context.pushLocator(playLocator);
        manager = context.getFlowControlManager();
        try {
            player.setContentHandler(cup);
            player.setFlowController(this);
            player.play();
        } catch (SAXException x) {
            // Catching, logging and re-throwing because this exception may get lost
            // in case of IllegalStateException thrown inside finally
            logger.error(x);
            throw x;
        } finally {
            manager = null;

            Locator poppedLocator = (Locator) context.popLocator();
            if (poppedLocator != playLocator) {
                if (logger.isDebugEnabled()) {
                    String pushed = (null != playLocator) ? playLocator.getPublicId() : "null";
                    String popped = (null != poppedLocator) ? poppedLocator.getPublicId() : "null";
                    logger.debug("Popped locator does not match pushed locator." +
View Full Code Here

TOP

Related Classes of com.volantis.xml.pipeline.sax.XMLPipelineContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.