Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Session


        Form form = (Form) request.getAttribute(id);

        if (form!=null) {
            return form;
        } else {
            Session session = request.getSession(false);

            if (session!=null) {
                form = (Form) session.getAttribute(id);
            }
            return form;
        }
    }
View Full Code Here


    public static void remove(Map sitemapObjectModel, String id) {
        Request request = getRequest(sitemapObjectModel);

        request.removeAttribute(id);

        Session session = request.getSession(false);

        if (session!=null) {
            session.removeAttribute(id);
        }
    }
View Full Code Here

        if (SCOPE_REQUEST.equals(scope)) {
            request.setAttribute(id_, this);
        } else // session scope
        {
            Session session = request.getSession(true);

            session.setAttribute(id_, this);
        }

    }
View Full Code Here

      Request request = ObjectModelHelper.getRequest(objectModel);
      Context context = ObjectModelHelper.getContext(objectModel);
      if(context != null)
        request.setAttribute("Wale",new  TestBean("Wale in the big sea","context"));

      Session session =request.getSession(true);
      session.setAttribute("Mouse",new  TestBean("Liveing in the session","session"));
      objectModel.put("Lion", new TestBean("Lion:walking on the sitemap","sitemap") );
      request.setAttribute("Hamster",new TestBean("Hamster:Wer hat nach mir gefragt","request")  );
      session.setAttribute("Elefant",new  TestBean("Elefant:from Africa","session"));
      request.setAttribute("Elefant",new  TestBean("Elefant:from India","request"));


      return objectModel;
View Full Code Here

        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN getAuthenticationSessionContext create=" + create);
        }
        SessionContext context = null;

        Session session = this.getSessionManager().getSession(create);
        if (session != null) {
            synchronized(session) {
                context = (SessionContext)session.getAttribute(AuthenticationConstants.SESSION_ATTRIBUTE_CONTEXT_NAME);
                if (context == null && create == true) {
                    context = new SimpleSessionContext();
                    context.setup(AuthenticationConstants.SESSION_CONTEXT_NAME, null, null);
                    session.setAttribute(AuthenticationConstants.SESSION_ATTRIBUTE_CONTEXT_NAME, context);
                }
            }
        }

        if (this.getLogger().isDebugEnabled() == true) {
View Full Code Here

        SessionContext context = null;

        if (this.handler != null) {

            final Session session = this.getSessionManager().getSession(false);
            synchronized(session) {

                try {
                    // create new context
                    context = this.getSessionManager().createContext(name, loadURI, saveURI);
View Full Code Here

            Object bean = null;
            if (scope == null) {
                // Search for bean in (1) objectModel, (2) request, (3) session, and (4) context.
                bean = request.getAttribute(name);
                if (bean == null) {
                    Session session = request.getSession(false);
                    if (session != null) {
                        bean = session.getAttribute(name);
                    }
                }
                if (bean == null) {
                    Context context = ObjectModelHelper.getContext(objectModel);
                    if (context != null) {
                        bean = context.getAttribute(name);
                    }
                }
                if (bean == null) {
                    bean = objectModel.get(name);
                }
            } else if (SCOPE_SITEMAP.equals(scope)) {
                bean = objectModel.get(name);
            } else if (SCOPE_REQUEST.equals(scope)) {
                bean = request.getAttribute(name);
            } if (SCOPE_SESSION.equals(scope)) {
                Session session = request.getSession(false);
                if (session != null) {
                    bean = session.getAttribute(name);
                }
            } if (SCOPE_CONTEXT.equals(scope)) {
                Context context = ObjectModelHelper.getContext(objectModel);
                if(context != null){
                    bean=context.getAttribute(name);
View Full Code Here

            if (!source.equals("EMPTY")) {
                // get configuration from external file
                // referenced by "src" attribute of "validate" element

                Configuration conf = null;
                Session session = null;
                try {
                    Source resource = this.resolver.resolveURI(source);
                    SAXConfigurationHandler saxBuilder = new SAXConfigurationHandler();
                    resolver.toSAX(resource, saxBuilder);

                    conf = saxBuilder.getConfiguration();
                    session = this.getSessionManager().getSession(true);
                    session.setAttribute(this.formName, conf);
                   
                    if (validationDoc != null) {
                        //validationDoc contains "validate-set" element
                        validationDoc.normalize();
                        Node validationNode = validationDoc.getFirstChild();
                        while (validationNode.getNodeType() != Node.ELEMENT_NODE) {
                            validationNode = validationNode.getNextSibling();
                            if (validationNode == null) break;
                        }
                        if (validationNode != null &&
                            validationNode.getNodeType() == Node.ELEMENT_NODE &&
                            validationNode.getNodeName().equals(FORM_VALIDATESET_ELEMENT)) {
                            String validationXML = XMLUtils.serializeNodeToXML(validationNode);
                            DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
                            conf = builder.build(new StringBufferInputStream(validationXML));
                            session.setAttribute(this.formName+"validate-set", conf);
                        }
                    }
                   
                } catch (SourceException se) {
                    throw new ProcessingException("Cannot resolve"+source, se);
                } catch (ConfigurationException ce) {
                    throw new ProcessingException("Error building Configuration out of validate-set element", ce);
                }

            } else if (validationDoc != null) {
                //validationDoc contains the validation rules inline
                try {
                    validationDoc.normalize();
                    Node validationNode = validationDoc.getFirstChild();
                    while (validationNode.getNodeType() != Node.ELEMENT_NODE) {
                        validationNode = validationNode.getNextSibling();
                        if (validationNode == null) break;
                    }
                    if (validationNode != null &&
                        validationNode.getNodeType() == Node.ELEMENT_NODE &&
                        validationNode.getNodeName().equals("root")) {

                        String validationXML = XMLUtils.serializeNodeToXML(validationNode);
                        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
                        Configuration conf = null;
                        Session session = null;
                        conf = builder.build(new StringBufferInputStream(validationXML));
                        session = this.getSessionManager().getSession(true);
                        session.setAttribute(this.formName, conf);
                        //the constraint-set to validate is the first and single one
                        session.setAttribute(this.formName+"validate-set", conf.getChildren ("constraint-set")[0]);

                    }
                } catch (ConfigurationException ce) {
                    throw new ProcessingException("Error building Configuration out of validation XML", ce);
                }
View Full Code Here

            st = conn.createStatement ();
            rs = st.executeQuery (query);

            if (rs.next ()) {
                getLogger ().debug ("DBAUTH: authorized successfully");
                Session session = null;

                if (cs) {
                    session = req.getSession (false);
                    if (session != null)
                        session.invalidate ();
                    session = req.getSession (true);
                    if (session == null)
                        return null;
                    getLogger ().debug ("DBAUTH: session created");
                } else {
View Full Code Here

        Request request = ObjectModelHelper.getRequest(objectModel);
        JXPathContext context = (JXPathContext) request.getAttribute(Constants.JXPATH_CONTEXT);
        if (context == null) {
            Context cocoonContext = ObjectModelHelper.getContext(objectModel);
            JXPathContext parentContext = null;
            Session session = request.getSession(false);
            if (session != null) {
                parentContext = getSessionContext(session, cocoonContext);
            } else {
                parentContext = getApplicationContext(cocoonContext);
            }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.environment.Session

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.