Package org.apache.cocoon.webapps.session.context

Examples of org.apache.cocoon.webapps.session.context.SessionContext


            } else if ( result != null ) {
                // now set the failure information in the temporary context
                ContextManager contextManager = null;
                try {
                    contextManager = (ContextManager) this.manager.lookup( ContextManager.ROLE );
                    SessionContext temp = contextManager.getContext( SessionConstants.TEMPORARY_CONTEXT );
                   
                    final DocumentFragment fragment = result.result.createDocumentFragment();
                    final Node root = result.result.getDocumentElement();
                    root.normalize();
                    Node child;
                    boolean appendedNode = false;
                    while (root.hasChildNodes() ) {
                        child = root.getFirstChild();
                        root.removeChild(child);
                        // Leave out empty text nodes before any other node
                        if (appendedNode
                            || child.getNodeType() != Node.TEXT_NODE
                            || child.getNodeValue().trim().length() > 0) {
                            fragment.appendChild(child);
                            appendedNode = true;
                        }
                    }
                    temp.appendXML("/", fragment);
                } catch ( ServiceException se ) {
                    throw new ProcessingException("Unable to lookup session manager.", se);
                } finally {
                    this.manager.release( contextManager );
                }
View Full Code Here


                                                   String saveURI)
    throws ProcessingException {
        RequestState state = this.getState();
        UserHandler handler = state.getHandler();
       
        SessionContext context = null;

        if ( handler != null ) {
            ContextManager contextManager = null;
            try {
                contextManager = (ContextManager)this.manager.lookup(ContextManager.ROLE);
View Full Code Here

        if ( pos != -1 ) {
            final String contextName = name.substring(0, pos);
            final String path = name.substring(pos);
           
            try {
                SessionContext context = this.contextManager.getContext(contextName);
                if ( context != null ) {
                    DocumentFragment frag = context.getXML(path);
                    return DOMUtil.getValueOfNode(frag);
                }
            } catch (ProcessingException pe) {
                throw new ConfigurationException("Unable to get information from context.", pe);
            }
View Full Code Here

     * Get a reserved context
     */
    private SessionContext getReservedContext(String name)
    throws ProcessingException {
        // synchronized
        SessionContext context = null;
        SessionContextProvider provider = null;
        try {
            provider = (SessionContextProvider)this.contextSelector.select( name );
            synchronized (provider) {
                context = provider.getSessionContext(name);
View Full Code Here

        Session session = this.getSession(true);
        if (session == null) {
            throw new ProcessingException("CreateContext: Session is required");
        }

        SessionContext context;
        synchronized(session) {
            // test for reserved context
            if (this.isReservedContextName(name)) {
                throw new ProcessingException("SessionContext with name " + name + " is reserved and cannot be created manually.");
            }

            if (this.existsContext(name)) {
                context = this.getContext(name);
            } else {
                Map contexts = this.getSessionContexts(session);
                context = new SimpleSessionContext(this.xpathProcessor, this.resolver);
                context.setup(name, loadURI, saveURI);
                contexts.put(name, context);
            }
        }
       
        if (this.getLogger().isDebugEnabled()) {
View Full Code Here

        }
        if (path == null) {
            throw new ProcessingException("SessionManager.getContextFragment: Path is required");
        }

        SessionContext context = this.contextManager.getContext( contextName );

        if (context == null) {
            throw new ProcessingException("SessionManager.getContextFragment: Context '" + contextName + "' not found.");
        }

        DocumentFragment frag;
        frag = context.getXML(path);

        if (this.getLogger().isDebugEnabled() ) {
            this.getLogger().debug("END getContextFragment documentFragment=" + (frag == null ? "null" : XMLUtils.serializeNode(frag, XMLUtils.createPropertiesForXML(false))));
        }
        return frag;
View Full Code Here

        }
        if (path == null) {
            throw new ProcessingException("SessionManager.streamContextFragment: Path is required");
        }

        SessionContext context = this.contextManager.getContext( contextName );

        if (context == null) {
            throw new ProcessingException("SessionManager.streamContextFragment: Context '" + contextName + "' not found.");
        }

        streamed = context.streamXML(path, consumer, consumer);

        if (this.getLogger().isDebugEnabled() ) {
            this.getLogger().debug("END streamContextFragment streamed=" + streamed);
        }
        return streamed;
View Full Code Here

        if (fragment == null) {
            throw new ProcessingException("SessionManager.setContextFragment: Fragment is required");
        }

        // get context
        SessionContext context = this.contextManager.getContext( contextName );

        // check context
        if (context == null) {
            throw new ProcessingException("SessionManager.setContextFragment: Context '" + contextName + "' not found.");
        }

        context.setXML(path, fragment);

        if (this.getLogger().isDebugEnabled() ) {
            this.getLogger().debug("END setContextFragment");
        }
    }
View Full Code Here

        if (fragment == null) {
            throw new ProcessingException("SessionManager.appendContextFragment: Fragment is required");
        }

        // get context
        SessionContext context = this.contextManager.getContext( contextName );

        // check context
        if (context == null) {
            throw new ProcessingException("SessionManager.appendContextFragment: Context '" + contextName + "' not found.");
        }

        context.appendXML(path, fragment);

        if (this.getLogger().isDebugEnabled() ) {
            this.getLogger().debug("END appendContextFragment");
        }
    }
View Full Code Here

        if (fragment == null) {
            throw new ProcessingException("SessionManager.mergeContextFragment: Fragment is required");
        }

        // get context
        SessionContext context = this.contextManager.getContext( contextName );

        // check context
        if (context == null) {
            throw new ProcessingException("SessionManager.mergeContextFragment: Context '" + contextName + "' not found.");
        }

        Node contextNode = context.getSingleNode(path);
        if (contextNode == null) {
            // no merge required
            context.setXML(path, fragment);
        } else {
            this.importNode(contextNode, fragment, false);
            context.setNode(path, contextNode);
        }

        if (this.getLogger().isDebugEnabled()) {
            this.getLogger().debug("END mergeContextFragment");
        }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.webapps.session.context.SessionContext

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.