Examples of SessionContext


Examples of oasis.names.tc.wsrp.v1.types.SessionContext

        try {
            UserSession userSession = consumerEnvironment.getSessionHandler().getUserSession(portletKey.getProducerId(), user.getUserID());
            PortletDescription portletDescription = producer.getPortletDescription(portletKey.getPortletHandle());
            GroupSession groupSession = userSession.getGroupSession(portletDescription.getGroupID());
            PortletSession portletSession = groupSession.getPortletSession(portletInstanceKey);
            SessionContext sessionContext = portletSession.getSessionContext();
            WSRPPortlet wsrpportlet = consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
            PortletDriver portletDriver = consumerEnvironment.getPortletDriverRegistry().getPortletDriver(wsrpportlet);
   
            if (sessionContext != null) {
                String[] sessions = new String[1];
                sessions[0] = new String (sessionContext.getSessionID());
                portletDriver.releaseSessions(sessions, user.getUserID());
            }
           
            userSession.removeGroupSession(portletDescription.getGroupID());
        } catch (WSRPException e) {
View Full Code Here

Examples of org.apache.aurora.auth.SessionValidator.SessionContext

    IJobKey jobKey = JobKeys.assertValid(IJobKey.build(mutableJobKey));
    checkNotBlank(shardIds);
    requireNonNull(session);

    Response response = Util.emptyResponse();
    SessionContext context;
    try {
      context = sessionValidator.checkAuthenticated(session, ImmutableSet.of(jobKey.getRole()));
    } catch (AuthFailedException e) {
      return addMessage(response, AUTH_FAILED, e);
    }

    try {
      lockManager.validateIfLocked(
          ILockKey.build(LockKey.job(jobKey.newBuilder())),
          Optional.fromNullable(mutableLock).transform(ILock.FROM_BUILDER));
      schedulerCore.restartShards(jobKey, shardIds, context.getIdentity());
      response.setResponseCode(OK);
    } catch (LockException e) {
      addMessage(response, LOCK_ERROR, e);
    } catch (ScheduleException e) {
      addMessage(response, INVALID_REQUEST, e);
View Full Code Here

Examples of org.apache.axis2.context.SessionContext

            msgContext.setConfigurationContext(configurationContext);

            String sessionKey = request.getSession(true).getId();
            if (configurationContext.getAxisConfiguration().isManageTransportSession()) {
                SessionContext sessionContext = sessionManager.getSessionContext(sessionKey);
                msgContext.setSessionContext(sessionContext);
            }

            msgContext.setTransportIn(transportIn);
            msgContext.setTransportOut(transportOut);
View Full Code Here

Examples of org.apache.cocoon.sunshine.context.SessionContext

                }
            }
            consumer.endElement("", "menue", "menue");
        }

        SessionContext context = this.getSunRiseSessionContext(true);

        synchronized (context) {

            String state = this.request.getParameter(SunRise.REQ_PARAMETER_STATE);
            if (state == null) {
                state = (isAdmin == true ? "main" : "seluser");
            }

            if (state.equals("addrole") == true) {
                String role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
                if (role != null && role.trim().length() > 0) {
                    SourceParameters pars = new SourceParameters();
                    // first include all request parameters
                    Enumeration requestParameters = this.request.getParameterNames();
                    String current;
                    while (requestParameters.hasMoreElements() == true) {
                        current = (String)requestParameters.nextElement();
                        pars.setParameter(current, this.request.getParameter(current));
                    }
                    this.addRole(role, pars);
                } else {
                    role = null;
                }
                context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, null);
            }

            if (state.equals("delrole") == true) {
                try {
                    String role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
                    if (role != null) {
                        // first delete user
                        DocumentFragment userDF = this.getUsers(role, null);
                        NodeList         users   = null;
                        if (userDF != null) users = XMLUtil.selectNodeList(userDF, "users/user");
                        if (users != null) {
                            for(int i = 0; i < users.getLength(); i++) {
                                this.deleteUser(role, XMLUtil.getValueOf(users.item(i), "ID"), null);
                            }
                        }
                        this.deleteRole(role, null);
                    }
                    context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, null);
                } catch (javax.xml.transform.TransformerException local) {
                    throw new ProcessingException("TransformerException: " + local, local);
                }
            }


            if (state.equals("chguser") == true) {
                String role;
                String id;
                String user;

                if (isAdmin == false) {
                    SourceParameters pars = this.createParameters(null);
                    id = pars.getParameter("ID", null);
                    role = pars.getParameter("role", null);
                    user = "old";
                } else {
                    role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
                    id   = this.request.getParameter(SunRise.REQ_PARAMETER_ID);
                    user = this.request.getParameter(SunRise.REQ_PARAMETER_USER);
                }

                boolean addingNewUserFailed = false;
                if (role != null && id != null && user != null) {
                    if (user.equals("new") == true) {
                        SourceParameters pars = new SourceParameters();
                        // first include all request parameters
                        Enumeration requestParameters = this.request.getParameterNames();
                        String current;
                        while (requestParameters.hasMoreElements() == true) {
                            current = (String)requestParameters.nextElement();
                            pars.setParameter(current, this.request.getParameter(current));
                        }
                        addingNewUserFailed = !this.addUser(role, id, pars);
                        if (addingNewUserFailed == false) {
                            consumer.startElement("", "addeduser", "addeduser", attr);
                            consumer.characters(id.toCharArray(), 0, id.length());
                            consumer.endElement("", "addeduser", "addeduser");
                        }
                    } else {
                        String delete = this.request.getParameter("sunrisedeluser");
                        if (delete != null && delete.equals("true") == true) {
                            this.deleteUser(role, id, null);
                        } else {
                            SourceParameters pars = new SourceParameters();
                            // first include all request parameters
                            Enumeration requestParameters = this.request.getParameterNames();
                            String current;
                            while (requestParameters.hasMoreElements() == true) {
                                current = (String)requestParameters.nextElement();
                                pars.setParameter(current, this.request.getParameter(current));
                            }
                            this.changeUser(role, id, pars);
                        }
                    }
                    context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, null);
                }
                if (addingNewUserFailed == false) {
                    state = (isAdmin == true ? "adduser" : "seluser");
                } else {
                    state = "erruser";
                }
            }

            if (state.equals("seluser") == true) {
                String role;
                String id;

                if (isAdmin == false) {
                    SourceParameters pars = this.createParameters(null);
                    id = pars.getParameter("ID", null);
                    role = pars.getParameter("role", null);
                } else {
                    role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
                    id   = this.request.getParameter(SunRise.REQ_PARAMETER_ID);
                }
                if (role != null && id != null) {
                    context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, role);

                    // include users
                    DocumentFragment userDF = this.getUsers(role, id);
                    Element          users   = null;
                    try {
                        if (userDF != null) users = (Element)XMLUtil.getSingleNode(userDF, "users/user");
                    } catch (javax.xml.transform.TransformerException local) {
                        throw new ProcessingException("TransformerException: " + local, local);
                    }
                    consumer.startElement("", "uservalues", "uservalues", attr);
                    if (users != null && users.hasChildNodes() == true) {
                        NodeList childs = users.getChildNodes();
                        for(int i = 0; i < childs.getLength(); i++) {
                            if (childs.item(i).getNodeType() == Node.ELEMENT_NODE)
                                IncludeXMLConsumer.includeNode(childs.item(i), consumer, consumer);
                        }
                    }
                    consumer.endElement("", "uservalues", "uservalues");
                }
                consumer.startElement("", "user", "user", attr);
                consumer.characters("old".toCharArray(), 0, 3);
                consumer.endElement("", "user", "user");
                if (isAdmin == false) {
                    consumer.startElement("", "role", "role", attr);
                    consumer.characters(role.toCharArray(), 0, role.length());
                    consumer.endElement("", "role", "role");
               }
            }

            if (state.equals("erruser") == true) {
                String role;
                String id;

                if (isAdmin == false) {
                    SourceParameters pars = this.createParameters(null);
                    id = pars.getParameter("ID", null);
                    role = pars.getParameter("role", null);
                } else {
                    role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
                    id   = this.request.getParameter(SunRise.REQ_PARAMETER_ID);
                }
                if (role != null && id != null) {
                    context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, role);

                    // include users
                    DocumentFragment userDF = this.getUsers(role, id);
                    Element          users   = null;
                    try {
                        if (userDF != null) users = (Element)XMLUtil.getSingleNode(userDF, "users/user");
                    } catch (javax.xml.transform.TransformerException local) {
                        throw new ProcessingException("TransformerException: " + local, local);
                    }
                    consumer.startElement("", "uservalues", "uservalues", attr);
                    if (users != null && users.hasChildNodes() == true) {
                        NodeList childs = users.getChildNodes();
                        for(int i = 0; i < childs.getLength(); i++) {
                            if (childs.item(i).getNodeType() == Node.ELEMENT_NODE)
                                IncludeXMLConsumer.includeNode(childs.item(i), consumer, consumer);
                        }
                    }
                    consumer.endElement("", "uservalues", "uservalues");
                }
                consumer.startElement("", "user", "user", attr);
                consumer.characters("error".toCharArray(), 0, 5);
                consumer.endElement("", "user", "user");
                if (isAdmin == false) {
                    consumer.startElement("", "role", "role", attr);
                    consumer.characters(role.toCharArray(), 0, role.length());
                    consumer.endElement("", "role", "role");
               }
            }

            if (state.equals("adduser") == true) {
                consumer.startElement("", "user", "user", attr);
                consumer.characters("new".toCharArray(), 0, 3);
                consumer.endElement("", "user", "user");
            }

            if (state.equals("selrole") == true) {
                String role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
                context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, role);
                // include users
                DocumentFragment userDF = this.getUsers(role, null);
                Node             users   = null;
                try {
                    if (userDF != null) users = XMLUtil.getSingleNode(userDF, "users");
                } catch (javax.xml.transform.TransformerException local) {
                    throw new ProcessingException("TransformerException: " + local, local);
                }
                IncludeXMLConsumer.includeNode(users, consumer, consumer);
            }

            if (isAdmin == true) {
                // include roles
                DocumentFragment rolesDF = this.getRoles();
                Node             roles   = null;
                try {
                    if (rolesDF != null) roles = XMLUtil.getSingleNode(rolesDF, "roles");
                } catch (javax.xml.transform.TransformerException local) {
                    throw new ProcessingException("TransformerException: " + local, local);
                }
                IncludeXMLConsumer.includeNode(roles, consumer, consumer);

                // include selected role
                String role = (String)context.getAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE);
                if (role != null) {
                    consumer.startElement("", "role", "role", attr);
                    consumer.characters(role.toCharArray(), 0, role.length());
                    consumer.endElement("", "role", "role");
                }
View Full Code Here

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

    throws ProcessingException, IOException, SAXException {
        // synchronized
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN getContext create="+create);
        }
        SessionContext context = null;

        final Session session = this.getSessionManager().getSession(false);
        if (session != null) {
            synchronized(session) {
                String appName = this.getAuthenticationManager().getApplicationName();
View Full Code Here

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

        }
        try {
            String profileID = "global";
            String copletID = this.request.getParameter(PortalManager.REQ_PARAMETER_COPLET);

            SessionContext context = this.getContext(true);

            Map configuration = this.getConfiguration();

            DocumentFragment copletsFragment = (DocumentFragment)context.getAttribute(ATTRIBUTE_ADMIN_COPLETS);
            String command = this.request.getParameter(PortalManager.REQ_PARAMETER_ADMIN_COPLETS);
            if (command != null && copletsFragment != null) {
                try {
                    this.getSessionManager().startWritingTransaction(context);
                    // save : save coplets base
                    // new  : new coplet
                    // delete : use id to delete coplet
                    // change : change the coplet
                    //        cache : cleans the cache
                    if (command.equals("delete") == true && copletID != null) {
                        Node coplet = DOMUtil.getSingleNode(copletsFragment, "coplets-profile/coplets/coplet[@id='"+copletID+"']");
                        if (coplet != null) {
                            coplet.getParentNode().removeChild(coplet);
                        }
                    } else if (command.equals("change") == true && copletID != null) {
                        Node coplet = DOMUtil.getSingleNode(copletsFragment, "coplets-profile/coplets/coplet[@id='"+copletID+"']");
                        if (coplet != null) {
                            // now get the information
                            String value;

                            value = this.request.getParameter("portaladmin_title");
                            if (value != null) DOMUtil.setValueOfNode(DOMUtil.getSingleNode(coplet, "title"), value);

                            value = this.request.getParameter("portaladmin_mand");
                            if (value != null) DOMUtil.setValueOfNode(DOMUtil.getSingleNode(coplet, "configuration/mandatory"), value);

                            value = this.request.getParameter("portaladmin_sizable");
                            if (value != null) DOMUtil.setValueOfNode(DOMUtil.getSingleNode(coplet, "configuration/sizable"), value);

                            value = this.request.getParameter("portaladmin_active");
                            if (value != null) DOMUtil.setValueOfNode(DOMUtil.getSingleNode(coplet, "configuration/active"), value);

                            value = this.request.getParameter("portaladmin_handsize");
                            if (value != null) DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/handlesSizable"), value);

                            value = this.request.getParameter("portaladmin_handpar");
                            if (value != null) DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/handlesParameters"), value);

                            value = this.request.getParameter("portaladmin_timeout");
                            if (value != null) DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/timeout"), value);

                            value = this.request.getParameter("portaladmin_customizable");
                            if (value != null) DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/customizable"), value);

                            value = this.request.getParameter("portaladmin_persistent");
                            if (value != null) DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/persistent"), value);

                            String resource = this.request.getParameter("portaladmin_resource");
                            if (resource != null) {
                                Element resourceNode = (Element)DOMUtil.getSingleNode(coplet, "resource");
                                resourceNode.getParentNode().removeChild(resourceNode);
                                resourceNode = coplet.getOwnerDocument().createElementNS(null, "resource");
                                resourceNode.setAttributeNS(null, "uri", resource);
                                coplet.appendChild(resourceNode);
                            }
                            resource = this.request.getParameter("portaladmin_cust");
                            boolean isCustom = DOMUtil.getValueAsBooleanOf(coplet, "configuration/customizable", false);
                            if (resource != null && isCustom == true) {
                                Element resourceNode = (Element)DOMUtil.getSingleNode(coplet, "customization");
                                if (resourceNode != null) resourceNode.getParentNode().removeChild(resourceNode);
                                resourceNode = coplet.getOwnerDocument().createElementNS(null, "customization");
                                resourceNode.setAttributeNS(null, "uri", resource);
                                coplet.appendChild(resourceNode);
                            }
                            if (isCustom == false) {
                                Element resourceNode = (Element)DOMUtil.getSingleNode(coplet, "customization");
                                if (resourceNode != null) resourceNode.getParentNode().removeChild(resourceNode);
                            }

                            // transformations
                            value = this.request.getParameter("portaladmin_newxsl");
                            if (value != null) {
                                Element tNode = (Element)DOMUtil.selectSingleNode(coplet, "transformation");
                                Element sNode = tNode.getOwnerDocument().createElementNS(null, "stylesheet");
                                tNode.appendChild(sNode);
                                sNode.appendChild(sNode.getOwnerDocument().createTextNode(value));
                            }

                            // now get all transformation stylesheets, mark
                            // all stylesheets which should be deleted with
                            // an attribute delete
                            Enumeration keys = this.request.getParameterNames();
                            Element sNode;
                            String key;
                            while (keys.hasMoreElements() == true) {
                                key = (String)keys.nextElement();
                                if (key.startsWith("portaladmin_xsl_") == true) {
                                    value = key.substring(key.lastIndexOf('_')+ 1);
                                    sNode = (Element)DOMUtil.getSingleNode(coplet, "transformation/stylesheet[position()="+value+"]");
                                    if (sNode != null) {
                                        String xslName = this.request.getParameter(key);
                                        if (xslName.equals("true") == true) xslName = "**STYLESHEET**";
                                        DOMUtil.setValueOfNode(sNode, xslName);
                                    }
                                } else if (key.startsWith("portaladmin_delxsl_") == true) {
                                    value = key.substring(key.lastIndexOf('_')+ 1);
                                    sNode = (Element)DOMUtil.getSingleNode(coplet, "transformation/stylesheet[position()="+value+"]");
                                    if (sNode != null) {
                                        sNode.setAttributeNS(null, "delete", "true");
                                    }
                                }
                            }
                            NodeList delete = DOMUtil.selectNodeList(coplet, "transformation/stylesheet[@delete]");
                            if (delete != null) {
                                for(int i=0; i < delete.getLength(); i++) {
                                    delete.item(i).getParentNode().removeChild(delete.item(i));
                                }
                            }
                        }
                    } else if (command.equals("new") == true) {
                        // first we have to invent a new coplet id!
                        int index = 0;
                        boolean found = false;
                        Element coplet;
                        Element subNode;

                        while (found == false) {
                            copletID = "S"+index;
                            coplet = (Element)DOMUtil.getSingleNode(copletsFragment, "coplets-profile/coplets/coplet[@id='"+copletID+"']");
                            if (coplet == null) {
                                found = true;
                            } else {
                                index++;
                            }
                        }
                        coplet = copletsFragment.getOwnerDocument().createElementNS(null, "coplet");
                        coplet.setAttributeNS(null, "id", copletID);
                        subNode = coplet.getOwnerDocument().createElementNS(null, "resource");
                        coplet.appendChild(subNode);
                        subNode.setAttributeNS(null, "uri", "uri_in_sitemap");

                        String title = this.request.getParameter("portaladmin_title");
                        if (title == null || title.trim().length() == 0) title = "**NEW COPLET**";
                        DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/mandatory"), "false");
                        DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/sizable"), "true");
                        DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/active"), "false");
                        DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/handlesParameters"), "true");
                        DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "configuration/handlesSizable"), "false");
                        DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "title"), title);
                        DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "status/visible"), "true");
                        DOMUtil.setValueOfNode(DOMUtil.selectSingleNode(coplet, "status/size"), "max");
                        DOMUtil.getSingleNode(copletsFragment, "coplets-profile/coplets").appendChild(coplet);
                    } else if (command.equals("save") == true) {

                        SourceParameters pars = new SourceParameters();
                        pars.setSingleParameterValue("profile", "coplet-base");
                        pars.setSingleParameterValue("application", this.getAuthenticationManager().getApplicationName());
                        pars.setSingleParameterValue("handler", this.getAuthenticationManager().getHandlerName());

                        String saveResource = (String)configuration.get(PortalConstants.CONF_COPLETBASE_SAVE_RESOURCE);

                        if (saveResource == null) {
                            throw new ProcessingException("portal: No save resource defined for type coplet-base.");
                        } else {
                           
                            SourceUtil.writeDOM(saveResource,
                                                null,
                                                pars,
                                                copletsFragment,
                                                this.resolver,
                                                "xml");

                            // now the hardest part, clean up the whole cache
                            this.cleanUpCache(null, null, configuration);
                        }
                    }
                } finally {
                    this.getSessionManager().stopWritingTransaction(context);
                }
            }

            // general commands
            if (command != null && command.equals("cleancache") == true) {
                this.cleanUpCache(null, null, configuration);
            }

            String state = this.request.getParameter(PortalManager.REQ_PARAMETER_STATE);
            if (state == null) {
                state = (String)context.getAttribute(ATTRIBUTE_ADMIN_STATE, PortalConstants.STATE_MAIN);
            }

            // now start producing xml:
            AttributesImpl attr = new AttributesImpl();
            consumer.startElement("", PortalConstants.ELEMENT_ADMINCONF, PortalConstants.ELEMENT_ADMINCONF, attr);

            context.setAttribute(ATTRIBUTE_ADMIN_STATE, state);
            consumer.startElement("", PortalConstants.ELEMENT_STATE, PortalConstants.ELEMENT_STATE, attr);
            consumer.characters(state.toCharArray(), 0, state.length());
            consumer.endElement("", PortalConstants.ELEMENT_STATE, PortalConstants.ELEMENT_STATE);

            if (state.equals(PortalConstants.STATE_MAIN) == true) {

                Document rolesDF = this.getRoles();
                Node     roles   = null;
                if (rolesDF != null) roles = DOMUtil.getSingleNode(rolesDF, "roles");
                IncludeXMLConsumer.includeNode(roles, consumer, consumer);
            }

            if (state.equals(PortalConstants.STATE_MAIN_ROLE) == true) {

                Document rolesDF = this.getRoles();
                Node     roles   = null;
                if (rolesDF != null) roles = DOMUtil.getSingleNode(rolesDF, "roles");
                IncludeXMLConsumer.includeNode(roles, consumer, consumer);

                String role = this.request.getParameter(PortalManager.REQ_PARAMETER_ROLE);
                if (role == null) {
                    role = (String)context.getAttribute(ATTRIBUTE_ADMIN_ROLE);
                }
                context.setAttribute(ATTRIBUTE_ADMIN_ROLE, role);
                if (role != null) {
                    this.sendStartElementEvent(consumer, "roleusers");
                    this.sendStartElementEvent(consumer, "name");
                    this.sendTextEvent(consumer, role);
                    this.sendEndElementEvent(consumer, "name");
                    Document userDF = this.getUsers(role, null);
                    Node     users = null;
                    if (userDF != null) users = DOMUtil.getSingleNode(userDF, "users");
                    IncludeXMLConsumer.includeNode(users, consumer, consumer);
                    this.sendEndElementEvent(consumer, "roleusers");
                }
            }

            if (state.equals(PortalConstants.STATE_GLOBAL) == true) {
                profileID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, true);
                Map profile = this.retrieveProfile(profileID);
                if (profile == null) {
                    this.createProfile(context, PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, true);
                    profile = this.retrieveProfile(profileID);
                }
                this.showPortal(consumer, true, context, profile, profileID);
            }

            if (state.equals(PortalConstants.STATE_ROLE) == true) {
                String role = this.request.getParameter(PortalManager.REQ_PARAMETER_ROLE);
                if (role == null) {
                    role = (String)context.getAttribute(ATTRIBUTE_ADMIN_ROLE);
                }
                context.setAttribute(ATTRIBUTE_ADMIN_ROLE, role);
                if (role != null) {
                    consumer.startElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE, attr);
                    consumer.characters(role.toCharArray(), 0, role.length());
                    consumer.endElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE);
                    profileID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ROLE, role, null, true);
                    Map profile = this.retrieveProfile(profileID);
                    if (profile == null) {
                        this.createProfile(context, PortalManager.BUILDTYPE_VALUE_ROLE, role, null, true);
                        profile = this.retrieveProfile(profileID);
                    }
                    this.showPortal(consumer, true, context, profile, profileID);
                }
            }
            if (state.equals(PortalConstants.STATE_USER) == true) {
                String role = this.request.getParameter(PortalManager.REQ_PARAMETER_ROLE);
                String id   = this.request.getParameter(PortalManager.REQ_PARAMETER_ID);
                if (role == null) {
                    role = (String)context.getAttribute(ATTRIBUTE_ADMIN_ROLE);
                }
                if (id == null) {
                    id = (String)context.getAttribute(ATTRIBUTE_ADMIN_ID);
                }
                context.setAttribute(ATTRIBUTE_ADMIN_ID, id);
                context.setAttribute(ATTRIBUTE_ADMIN_ROLE, role);
                if (role != null && id != null) {
                    consumer.startElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE, attr);
                    consumer.characters(role.toCharArray(), 0, role.length());
                    consumer.endElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE);
                    consumer.startElement("", PortalConstants.ELEMENT_ID, PortalConstants.ELEMENT_ID, attr);
                    consumer.characters(id.toCharArray(), 0, id.length());
                    consumer.endElement("", PortalConstants.ELEMENT_ID, PortalConstants.ELEMENT_ID);

                    profileID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ID, role, id, true);
                    Map profile = this.retrieveProfile(profileID);
                    if (profile == null) {
                        this.createProfile(context, PortalManager.BUILDTYPE_VALUE_ID, role, id, true);
                        profile = this.retrieveProfile(profileID);
                    }
                    this.showPortal(consumer, true, context, profile, profileID);
                }
            }
            // one coplet
            if (state.equals(PortalConstants.STATE_COPLET) == true) {
                if (copletsFragment != null && copletID != null) {
                    Node coplet = DOMUtil.getSingleNode(copletsFragment, "coplets-profile/coplets/coplet[@id='"+copletID+"']");
                    if (coplet != null) {
                        IncludeXMLConsumer.includeNode(coplet, consumer, consumer);
                    }
                } else {
                    state = PortalConstants.STATE_COPLETS;
                }
            }
            if (state.equals(PortalConstants.STATE_COPLETS) == true) {
                consumer.startElement("", PortalConstants.ELEMENT_COPLETS, PortalConstants.ELEMENT_COPLETS, attr);

                // load the base coplets profile
                if (copletsFragment == null) {
                    SourceParameters pars = new SourceParameters();
                    pars.setSingleParameterValue("application", this.getAuthenticationManager().getApplicationName());
                    String res = (String)configuration.get(PortalConstants.CONF_COPLETBASE_RESOURCE);
                    if (res == null) {
                        throw new ProcessingException("No configuration for portal-coplet base profile found.");
                    }
                    copletsFragment = SourceUtil.readDOM(res,
                                                         null,
                                                         pars,
                                                         this.resolver);
                    context.setAttribute(ATTRIBUTE_ADMIN_COPLETS, copletsFragment);
                }
                IncludeXMLConsumer.includeNode(DOMUtil.selectSingleNode(copletsFragment,
                                   "coplets-profile"), consumer, consumer);
                consumer.endElement("", PortalConstants.ELEMENT_COPLETS, PortalConstants.ELEMENT_COPLETS);
            }
View Full Code Here

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

    throws SAXException, IOException, ProcessingException {
        // synchronized
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN getStatusProfile");
        }
        SessionContext context = this.getContext(true);
        String profileID = null;
        Map storedProfile = null;
        Element statusProfile = null;

        if (context.getAttribute(PortalManager.ATTRIBUTE_PORTAL_ROLE) != null) {
            profileID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ID,
                  (String)context.getAttribute(PortalManager.ATTRIBUTE_PORTAL_ROLE),
                  (String)context.getAttribute(PortalManager.ATTRIBUTE_PORTAL_ID), false);
            storedProfile = this.retrieveProfile(profileID);
        }

        if (storedProfile != null) {
            DocumentFragment profile = (DocumentFragment)storedProfile.get(PortalConstants.PROFILE_PROFILE);
View Full Code Here

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

        // synchronized
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN showPortal consumer=" + consumer+", configMode="+
                             configMode+", adminProfile="+adminProfile);
        }
        SessionContext context = this.getContext(true);
        String profileID = null;
        Map storedProfile = null;

        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("start portal generation");
        }
        if (context.getAttribute(PortalManager.ATTRIBUTE_PORTAL_ROLE) != null) {
            profileID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ID,
                  (String)context.getAttribute(PortalManager.ATTRIBUTE_PORTAL_ROLE),
                  (String)context.getAttribute(PortalManager.ATTRIBUTE_PORTAL_ID), adminProfile);
            storedProfile = this.retrieveProfile(profileID);
        }
        if (storedProfile == null) {

            if (this.getLogger().isDebugEnabled() == true) {
                this.getLogger().debug("start building profile");
            }
            this.createProfile(context, PortalManager.BUILDTYPE_VALUE_ID, null, null, adminProfile);
            // get the profileID
            profileID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ID,
                    (String)context.getAttribute(PortalManager.ATTRIBUTE_PORTAL_ROLE),
                    (String)context.getAttribute(PortalManager.ATTRIBUTE_PORTAL_ID), adminProfile);
            storedProfile = this.retrieveProfile(profileID);
            if (storedProfile == null) {
                throw new ProcessingException("portal: No portal profile found.");
            }
            if (this.getLogger().isDebugEnabled() == true) {
View Full Code Here

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

                }
            } else {
                throw new ProcessingException("buildProfile: Type unknown: " + type);
            }

            SessionContext context = this.getContext(true);
            try {
                this.getSessionManager().startWritingTransaction(context);

                String profileID = this.getProfileID(type, role, id, adminProfile);
                Map theProfile = null;

                // get the configuration
                Map config = this.getConfiguration();
                if (config == null) {
                    throw new ProcessingException("No configuration for portal found.");
                }

                // is the ID profile cached?
                if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true) {
                    theProfile = this.getCachedProfile(profileID, config);
                }

                if (theProfile == null) {

                    boolean doBase = false;
                    boolean doGlobal = false;
                    boolean doRole = false;
                    boolean doID = false;
                    String previousID;

                    if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true) {
                        doID = true;
                        previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ROLE, role, null, adminProfile);
                        theProfile = this.getCachedProfile(previousID, config);
                        if (theProfile == null) {
                            doRole = true;
                            previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, adminProfile);
                            theProfile = this.getCachedProfile(previousID, config);
                            if (theProfile == null) {
                                doGlobal = true;
                                previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_BASIC, null, null, adminProfile);
                                theProfile = this.getCachedProfile(previousID, config);
                            }
                        }
                    } else if (type.equals(PortalManager.BUILDTYPE_VALUE_ROLE) == true) {
                        theProfile = this.getCachedProfile(profileID, config);
                        if (theProfile == null) {
                            doRole = true;
                            previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, adminProfile);
                            theProfile = this.getCachedProfile(previousID, config);
                            if (theProfile == null) {
                                doGlobal = true;
                                previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_BASIC, null, null, adminProfile);
                                theProfile = this.getCachedProfile(previousID, config);
                            }
                        }
                    } else if (type.equals(PortalManager.BUILDTYPE_VALUE_GLOBAL) == true) {
                        theProfile = this.getCachedProfile(profileID, config);
                        if (theProfile == null) {
                            doGlobal = true;
                            previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_BASIC, null, null, adminProfile);
                            theProfile = this.getCachedProfile(previousID, config);
                        }
                    } else { // basic profile
                        theProfile = this.getCachedProfile(profileID, config);
                    }

                    // build the profile
                    if (theProfile == null) {
                        theProfile = new HashMap(8,2);
                        doBase = true;
                    }

                    Element          profileRoot;
                    DocumentFragment profile;

                    if (doBase == true) {
                        // build the base level
                        profile = this.buildBaseProfile(config, adminProfile);
                        profileRoot = (Element)profile.getFirstChild();
                        theProfile.put(PortalConstants.PROFILE_PROFILE, profile);
                        this.cacheProfile(this.getProfileID(PortalManager.BUILDTYPE_VALUE_BASIC, null, null, adminProfile), theProfile, config);
                    } else {
                        profile = (DocumentFragment)theProfile.get(PortalConstants.PROFILE_PROFILE);
                        profileRoot = (Element)profile.getFirstChild();
                    }

                    // load the global delta if type is global, role or user (but not basic!)
                    if (doGlobal == true) {
                        this.buildGlobalProfile(profileRoot, config, adminProfile);
                        this.cacheProfile(this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, adminProfile), theProfile, config);
                    }

                    // load the role delta if type is role or user
                    if (doRole == true) {
                        this.buildRoleProfile(profileRoot, config, role, adminProfile);
                        this.cacheProfile(this.getProfileID(PortalManager.BUILDTYPE_VALUE_ROLE, role, null, adminProfile), theProfile, config);
                    }

                    // load the user delta if type is user
                    if (doID == true) {
                        this.buildUserProfile(profileRoot, config, role, id, adminProfile);
                    }

                    // load the status profile when type is user
                    if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true) {
                        this.buildUserStatusProfile(profileRoot, config, role, id, adminProfile);
                    }

                    if (type.equals(PortalManager.BUILDTYPE_VALUE_BASIC) == false) {
                        this.buildRunProfile(theProfile, context, profile);

                        theProfile.put(PortalConstants.PROFILE_PORTAL_LAYOUTS,
                               this.buildPortalLayouts(context, profile));
                        theProfile.put(PortalConstants.PROFILE_COPLET_LAYOUTS,
                               this.buildcopleyLayouts(context, profile));

                        this.buildTypeProfile(theProfile, context, profile);
                    }

                    // cache the profile, if user
                    if (doID == true) {
                        this.cacheProfile(profileID, theProfile, config);
                    }
                } else {
                    // load the status profile when type is user
                    if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true) {
                        DocumentFragment profile = (DocumentFragment)theProfile.get(PortalConstants.PROFILE_PROFILE);
                        Element profileRoot = (Element)profile.getFirstChild();
                        this.buildUserStatusProfile(profileRoot, config, role, id, adminProfile);
                    }
                }

                // store the whole profile
                this.storeProfile(profileID, theProfile);

                // now put role and id into the context if type is ID
                if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true
                    && adminProfile == false) {
                    context.setAttribute(PortalManager.ATTRIBUTE_PORTAL_ROLE, role);
                    context.setAttribute(PortalManager.ATTRIBUTE_PORTAL_ID, id);
                }
            } finally {
                this.getSessionManager().stopWritingTransaction(context);
            }// end synchronized
        } catch (javax.xml.transform.TransformerException local) {
View Full Code Here

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

        Map    originalProfile;
        Map    baseProfile;
        String baseType, baseRole, baseID, rootElementName;
        DocumentFragment originalFragment;
        DocumentFragment delta;
        SessionContext context = this.getContext(true);

        originalProfile = this.retrieveProfile(this.getProfileID(type, role, id, adminProfile));
        if (originalProfile == null) {
            throw new ProcessingException("buildProfileDelta: no profile found for " +
                   type + " - " + role + " - " + id + ".");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.