Package org.apache.cocoon.sunshine.context

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


        }
        try {
            String profileID = "global";
            String sunletID = this.request.getParameter(SunSpot.REQ_PARAMETER_SUNLET);

            SessionContext context = this.getContext(true);

            Map configuration = this.getConfiguration();

            DocumentFragment sunletsFragment = (DocumentFragment)context.getAttribute(ATTRIBUTE_ADMIN_SUNLETS);
            String command = this.request.getParameter(SunSpot.REQ_PARAMETER_ADMIN_SUNLETS);
            if (command != null && sunletsFragment != null) {
                try {
                    this.getSunShineComponent().startWritingTransaction(context);
                    // save : save sunlets base
                    // new  : new sunlet
                    // delete : use id to delete sunlet
                    // change : change the sunlet
                    //        cache : cleans the cache
                    if (command.equals("delete") == true && sunletID != null) {
                        Node sunlet = XMLUtil.getSingleNode(sunletsFragment, "sunlets-profile/sunlets/sunlet[@id='"+sunletID+"']");
                        if (sunlet != null) {
                            sunlet.getParentNode().removeChild(sunlet);
                        }
                    } else if (command.equals("change") == true && sunletID != null) {
                        Node sunlet = XMLUtil.getSingleNode(sunletsFragment, "sunlets-profile/sunlets/sunlet[@id='"+sunletID+"']");
                        if (sunlet != null) {
                            // now get the information
                            String value;

                            value = this.request.getParameter("sunspotadmin_title");
                            if (value != null) XMLUtil.setValueOfNode(XMLUtil.getSingleNode(sunlet, "title"), value);

                            value = this.request.getParameter("sunspotadmin_mand");
                            if (value != null) XMLUtil.setValueOfNode(XMLUtil.getSingleNode(sunlet, "configuration/mandatory"), value);

                            value = this.request.getParameter("sunspotadmin_sizable");
                            if (value != null) XMLUtil.setValueOfNode(XMLUtil.getSingleNode(sunlet, "configuration/sizable"), value);

                            value = this.request.getParameter("sunspotadmin_active");
                            if (value != null) XMLUtil.setValueOfNode(XMLUtil.getSingleNode(sunlet, "configuration/active"), value);

                            value = this.request.getParameter("sunspotadmin_handsize");
                            if (value != null) XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/handlesSizable"), value);

                            value = this.request.getParameter("sunspotadmin_handpar");
                            if (value != null) XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/handlesParameters"), value);

                            value = this.request.getParameter("sunspotadmin_timeout");
                            if (value != null) XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/timeout"), value);

                            value = this.request.getParameter("sunspotadmin_customizable");
                            if (value != null) XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/customizable"), value);

                            value = this.request.getParameter("sunspotadmin_persistent");
                            if (value != null) XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/persistent"), value);

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

                            // transformations
                            value = this.request.getParameter("sunspotadmin_newxsl");
                            if (value != null) {
                                Element tNode = (Element)XMLUtil.selectSingleNode(sunlet, "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();
                            int pos;
                            Element sNode;
                            String key;
                            while (keys.hasMoreElements() == true) {
                                key = (String)keys.nextElement();
                                if (key.startsWith("sunspotadmin_xsl_") == true) {
                                    value = key.substring(key.lastIndexOf('_')+ 1);
                                    sNode = (Element)XMLUtil.getSingleNode(sunlet, "transformation/stylesheet[position()="+value+"]");
                                    if (sNode != null) {
                                        String xslName = this.request.getParameter(key);
                                        if (xslName.equals("true") == true) xslName = "**STYLESHEET**";
                                        XMLUtil.setValueOfNode(sNode, xslName);
                                    }
                                } else if (key.startsWith("sunspotadmin_delxsl_") == true) {
                                    value = key.substring(key.lastIndexOf('_')+ 1);
                                    sNode = (Element)XMLUtil.getSingleNode(sunlet, "transformation/stylesheet[position()="+value+"]");
                                    if (sNode != null) {
                                        sNode.setAttributeNS(null, "delete", "true");
                                    }
                                }
                            }
                            NodeList delete = XMLUtil.selectNodeList(sunlet, "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 sunlet id!
                        int index = 0;
                        boolean found = false;
                        Element sunlet;
                        Element subNode;

                        while (found == false) {
                            sunletID = "S"+index;
                            sunlet = (Element)XMLUtil.getSingleNode(sunletsFragment, "sunlets-profile/sunlets/sunlet[@id='"+sunletID+"']");
                            if (sunlet == null) {
                                found = true;
                            } else {
                                index++;
                            }
                        }
                        sunlet = sunletsFragment.getOwnerDocument().createElementNS(null, "sunlet");
                        sunlet.setAttributeNS(null, "id", sunletID);
                        subNode = sunlet.getOwnerDocument().createElementNS(null, "resource");
                        sunlet.appendChild(subNode);
                        subNode.setAttributeNS(null, "uri", "uri_in_sitemap");

                        String title = this.request.getParameter("sunspotadmin_title");
                        if (title == null || title.trim().length() == 0) title = "**NEW SUNLET**";
                        XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/mandatory"), "false");
                        XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/sizable"), "true");
                        XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/active"), "false");
                        XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/handlesParameters"), "true");
                        XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "configuration/handlesSizable"), "false");
                        XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "title"), title);
                        XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "status/visible"), "true");
                        XMLUtil.setValueOfNode(XMLUtil.selectSingleNode(sunlet, "status/size"), "max");
                        XMLUtil.getSingleNode(sunletsFragment, "sunlets-profile/sunlets").appendChild(sunlet);
                    } else if (command.equals("save") == true) {

                        SourceParameters pars = new SourceParameters();
                        pars.setSingleParameterValue("profile", "sunlet-base");
                        pars.setSingleParameterValue("application", (String)this.request.getAttribute(org.apache.cocoon.sunshine.sunrise.Constants.REQUEST_ATTRIBUTE_APPLICATION_NAME));
                        pars.setSingleParameterValue("handler", (String)this.request.getAttribute(org.apache.cocoon.sunshine.sunrise.Constants.REQUEST_ATTRIBUTE_HANDLER_NAME));

                        Resource saveResource = (Resource)configuration.get(Constants.CONF_SUNLETBASE_SAVE_RESOURCE);

                        if (saveResource == null) {
                            throw new ProcessingException("sunSpot: No save resource defined for type sunlet-base.");
                        } else {

                            this.getResourceConnector().saveXML(saveResource.getResourceType(),null,
                                 saveResource.getResourceIdentifier(),pars,
                                 sunletsFragment);

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

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

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

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

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

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

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

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

                DocumentFragment rolesDF = this.getSunRise().getRoles();
                Node             roles   = null;
                if (rolesDF != null) roles = XMLUtil.getSingleNode(rolesDF, "roles");
                IncludeXMLConsumer.includeNode(roles, consumer, consumer);

                String role = this.request.getParameter(SunSpot.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");
                    DocumentFragment userDF = this.getSunRise().getUsers(role, null);
                    Node             users = null;
                    if (userDF != null) users = XMLUtil.getSingleNode(userDF, "users");
                    IncludeXMLConsumer.includeNode(users, consumer, consumer);
                    this.sendEndElementEvent(consumer, "roleusers");
                }
            }

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

            if (state.equals(Constants.STATE_ROLE) == true) {
                String role = this.request.getParameter(SunSpot.REQ_PARAMETER_ROLE);
                if (role == null) {
                    role = (String)context.getAttribute(ATTRIBUTE_ADMIN_ROLE);
                }
                context.setAttribute(ATTRIBUTE_ADMIN_ROLE, role);
                if (role != null) {
                    consumer.startElement("", Constants.ELEMENT_ROLE, Constants.ELEMENT_ROLE, attr);
                    consumer.characters(role.toCharArray(), 0, role.length());
                    consumer.endElement("", Constants.ELEMENT_ROLE, Constants.ELEMENT_ROLE);
                    profileID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_ROLE, role, null, true);
                    Map profile = this.retrieveProfile(profileID);
                    if (profile == null) {
                        this.createProfile(context, SunSpot.BUILDTYPE_VALUE_ROLE, role, null, true);
                        profile = this.retrieveProfile(profileID);
                    }
                    this.showPortal(consumer, true, context, profile, profileID);
                }
            }
            if (state.equals(Constants.STATE_USER) == true) {
                String role = this.request.getParameter(SunSpot.REQ_PARAMETER_ROLE);
                String id   = this.request.getParameter(SunSpot.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("", Constants.ELEMENT_ROLE, Constants.ELEMENT_ROLE, attr);
                    consumer.characters(role.toCharArray(), 0, role.length());
                    consumer.endElement("", Constants.ELEMENT_ROLE, Constants.ELEMENT_ROLE);
                    consumer.startElement("", Constants.ELEMENT_ID, Constants.ELEMENT_ID, attr);
                    consumer.characters(id.toCharArray(), 0, id.length());
                    consumer.endElement("", Constants.ELEMENT_ID, Constants.ELEMENT_ID);

                    profileID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_ID, role, id, true);
                    Map profile = this.retrieveProfile(profileID);
                    if (profile == null) {
                        this.createProfile(context, SunSpot.BUILDTYPE_VALUE_ID, role, id, true);
                        profile = this.retrieveProfile(profileID);
                    }
                    this.showPortal(consumer, true, context, profile, profileID);
                }
            }
            // one sunlet
            if (state.equals(Constants.STATE_SUNLET) == true) {
                if (sunletsFragment != null && sunletID != null) {
                    Node sunlet = XMLUtil.getSingleNode(sunletsFragment, "sunlets-profile/sunlets/sunlet[@id='"+sunletID+"']");
                    if (sunlet != null) {
                        IncludeXMLConsumer.includeNode(sunlet, consumer, consumer);
                    }
                } else {
                    state = Constants.STATE_SUNLETS;
                }
            }
            if (state.equals(Constants.STATE_SUNLETS) == true) {
                consumer.startElement("", Constants.ELEMENT_SUNLETS, Constants.ELEMENT_SUNLETS, attr);

                // load the base sunlets profile
                if (sunletsFragment == null) {
                    SourceParameters pars = new SourceParameters();
                    pars.setSingleParameterValue("application", (String)this.request.getAttribute(org.apache.cocoon.sunshine.sunrise.Constants.REQUEST_ATTRIBUTE_APPLICATION_NAME));
                    Resource res = (Resource)configuration.get(Constants.CONF_SUNLETBASE_RESOURCE);
                    if (res == null) {
                        throw new ProcessingException("No configuration for sunSpot-sunlet base profile found.");
                    }
                    sunletsFragment = this.loadXML(res.getResourceType(), null,
                                                   res.getResourceIdentifier(), pars,
                                                   "Error during loading of sunLet base.");
                    context.setAttribute(ATTRIBUTE_ADMIN_SUNLETS, sunletsFragment);
                }
                IncludeXMLConsumer.includeNode(XMLUtil.selectSingleNode(sunletsFragment,
                                   "sunlets-profile"), consumer, consumer);
                consumer.endElement("", Constants.ELEMENT_SUNLETS, Constants.ELEMENT_SUNLETS);
            }
View Full Code Here


    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(SunSpot.ATTRIBUTE_PORTAL_ROLE) != null) {
            profileID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_ID,
                  (String)context.getAttribute(SunSpot.ATTRIBUTE_PORTAL_ROLE),
                  (String)context.getAttribute(SunSpot.ATTRIBUTE_PORTAL_ID), false);
            storedProfile = this.retrieveProfile(profileID);
        }

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

        // 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(SunSpot.ATTRIBUTE_PORTAL_ROLE) != null) {
            profileID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_ID,
                  (String)context.getAttribute(SunSpot.ATTRIBUTE_PORTAL_ROLE),
                  (String)context.getAttribute(SunSpot.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, SunSpot.BUILDTYPE_VALUE_ID, null, null, adminProfile);
            // get the profileID
            profileID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_ID,
                    (String)context.getAttribute(SunSpot.ATTRIBUTE_PORTAL_ROLE),
                    (String)context.getAttribute(SunSpot.ATTRIBUTE_PORTAL_ID), adminProfile);
            storedProfile = this.retrieveProfile(profileID);
            if (storedProfile == null) {
                throw new ProcessingException("sunSpot: No portal profile found.");
            }
            if (this.getLogger().isDebugEnabled() == true) {
View Full Code Here

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

            SessionContext context = this.getContext(true);
            try {
                this.getSunShineComponent().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 sunSpot found.");
                }

                // is the ID profile cached?
                if (type.equals(SunSpot.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(SunSpot.BUILDTYPE_VALUE_ID) == true) {
                        doID = true;
                        previousID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_ROLE, role, null, adminProfile);
                        theProfile = this.getCachedProfile(previousID, config);
                        if (theProfile == null) {
                            doRole = true;
                            previousID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_GLOBAL, null, null, adminProfile);
                            theProfile = this.getCachedProfile(previousID, config);
                            if (theProfile == null) {
                                doGlobal = true;
                                previousID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_BASIC, null, null, adminProfile);
                                theProfile = this.getCachedProfile(previousID, config);
                            }
                        }
                    } else if (type.equals(SunSpot.BUILDTYPE_VALUE_ROLE) == true) {
                        theProfile = this.getCachedProfile(profileID, config);
                        if (theProfile == null) {
                            doRole = true;
                            previousID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_GLOBAL, null, null, adminProfile);
                            theProfile = this.getCachedProfile(previousID, config);
                            if (theProfile == null) {
                                doGlobal = true;
                                previousID = this.getProfileID(SunSpot.BUILDTYPE_VALUE_BASIC, null, null, adminProfile);
                                theProfile = this.getCachedProfile(previousID, config);
                            }
                        }
                    } else if (type.equals(SunSpot.BUILDTYPE_VALUE_GLOBAL) == true) {
                        theProfile = this.getCachedProfile(profileID, config);
                        if (theProfile == null) {
                            doGlobal = true;
                            previousID = this.getProfileID(SunSpot.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(Constants.PROFILE_PROFILE, profile);
                        this.cacheProfile(this.getProfileID(SunSpot.BUILDTYPE_VALUE_BASIC, null, null, adminProfile), theProfile, config);
                    } else {
                        profile = (DocumentFragment)theProfile.get(Constants.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(SunSpot.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(SunSpot.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(SunSpot.BUILDTYPE_VALUE_ID) == true) {
                        this.buildUserStatusProfile(profileRoot, config, role, id, adminProfile);
                    }

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

                        theProfile.put(Constants.PROFILE_PORTAL_LAYOUTS,
                               this.buildPortalLayouts(context, profile));
                        theProfile.put(Constants.PROFILE_SUNLET_LAYOUTS,
                               this.buildSunletLayouts(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(SunSpot.BUILDTYPE_VALUE_ID) == true) {
                        DocumentFragment profile = (DocumentFragment)theProfile.get(Constants.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(SunSpot.BUILDTYPE_VALUE_ID) == true
                    && adminProfile == false) {
                    context.setAttribute(SunSpot.ATTRIBUTE_PORTAL_ROLE, role);
                    context.setAttribute(SunSpot.ATTRIBUTE_PORTAL_ID, id);
                }
            } finally {
                this.getSunShineComponent().stopWritingTransaction(context);
            }// end synchronized
        } catch (javax.xml.transform.TransformerException local) {
View Full Code Here

        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

        // synchronized
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN checkAuthentication sunlet="+sunletID);
        }
        boolean result = false;
        SessionContext context = this.getContext(false);
        if (context != null
            && (String)context.getAttribute(SunSpot.ATTRIBUTE_PORTAL_ROLE) != null) {

            try {
                this.getSunShineComponent().startReadingTransaction(context);
                Map theProfile = this.retrieveProfile(this.getProfileID(SunSpot.BUILDTYPE_VALUE_ID,
                     (String)context.getAttribute(SunSpot.ATTRIBUTE_PORTAL_ROLE),
                     (String)context.getAttribute(SunSpot.ATTRIBUTE_PORTAL_ID), false));

                if (theProfile != null) {
                    if (sunletID == null || sunletID.trim().length() == 0) {
                        result = true;
                    } else {
View Full Code Here

        // synchronized via context
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN logout handler=" + logoutHandlerName +
                                   ", mode="+mode);
        }
        SessionContext context = this.getSunRiseSessionContext(false);

        if (context != null && logoutHandlerName != null) {

            // cached?
            if (context.getAttribute("SUNRISE_ISAUTHENTICATED:" + logoutHandlerName) != null) {
                context.setAttribute("SUNRISE_ISAUTHENTICATED:" + logoutHandlerName, null);
            }
            // remove context
            context.removeXML(logoutHandlerName);
            // FIXME (CZ): The sessionContextImpl should not be null, but
            //             it is sometimes. Why?
            SessionContextImpl sessionContextImpl = (SessionContextImpl)
                        this.getSunShineComponent().getContext(Constants.SESSION_CONTEXT_NAME);
            if (sessionContextImpl != null) {
                sessionContextImpl.cleanParametersCache(logoutHandlerName);
            } else if (this.getLogger().isWarnEnabled()) {
                this.getLogger().warn("AuthenticationManager:logout() - sessionContextImpl is null");
            }
            Handler logoutHandler = (Handler)this.getHandler(logoutHandlerName);

            // reset application load status
            logoutHandler.setApplicationsLoaded(context, false);
            Iterator apps = logoutHandler.getApplications().values().iterator();
            ApplicationHandler current;
            while (apps.hasNext() == true) {
                current = (ApplicationHandler)apps.next();
                current.setIsLoaded(context, false);
            }

            final List handlerContexts = logoutHandler.getHandlerContexts();
            final Iterator iter = handlerContexts.iterator();
            while ( iter.hasNext() ) {
                final SessionContext deleteContext = (SessionContext) iter.next();
                this.getSunShineComponent().deleteContext( deleteContext.getName() );
            }
            logoutHandler.clearHandlerContexts();
        }

        if ( mode != null && mode.equalsIgnoreCase("terminateSession") ) {
View Full Code Here

        // synchronized
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN createHandlerContext name="+name);
        }

        SessionContext context = null;

        if (this.handler != null) {

            final Session session = this.getSunShineComponent().getSession(false);
            synchronized(session) {
View Full Code Here

        // synchronized
        if (this.handler == null) {
            return new SourceParameters();
        }
        if (path == null) {
            SessionContext context = this.getSunRiseSessionContext(false);
            SourceParameters pars = (SourceParameters)context.getAttribute("cachedparameters_" + this.handler.getName());
            if (pars == null) {
                 pars = this.createParameters(null, this.handlerName, path, this.applicationName);
                 context.setAttribute("cachedparameters_" + this.handler.getName(), pars);
            }
            return pars;
        }
        return this.createParameters(null, this.handlerName, path, this.applicationName);
    }
View Full Code Here

    throws ProcessingException {
        if (this.handler == null) {
            // this is only a fallback
            return EMPTY_MAP;
        }
        SessionContext context = this.getSunRiseSessionContext(false);
        Map map = (Map)context.getAttribute("cachedmap_" + this.handler.getName());
        if (map == null) {
            map = new HashMap();
            Parameters pars = this.createParameters(null).getFirstParameters();
            String[] names = pars.getNames();
            if (names != null) {
                String key;
                String value;
                for(int i=0;i<names.length;i++) {
                    key = names[i];
                    value = pars.getParameter(key, null);
                    if (value != null) map.put(key, value);
                }
            }
            context.setAttribute("cachedmap_" + this.handler.getName(), map);
        }
        return map;
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.sunshine.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.