portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r209305 [7/10] - in /portals/jetspeed-2/branches/MENUS_BRANCH: components/locator/src/java/org/apache/jetspeed/profiler/impl/ components/page-manager/ components/page-manager/src/java/META-INF/ components/page-manager/src/java/org/apache/je...
Date Tue, 05 Jul 2005 18:58:14 GMT
Added: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java?rev=209305&view=auto
==============================================================================
--- portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java (added)
+++ portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java Tue Jul  5 11:58:05 2005
@@ -0,0 +1,737 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portalsite.impl;
+
+import java.security.AccessController;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.Node;
+import org.apache.jetspeed.page.document.NodeException;
+import org.apache.jetspeed.page.document.NodeNotFoundException;
+import org.apache.jetspeed.page.document.NodeSet;
+import org.apache.jetspeed.portalsite.Menu;
+import org.apache.jetspeed.portalsite.PortalSiteRequestContext;
+import org.apache.jetspeed.portalsite.PortalSiteSessionContext;
+import org.apache.jetspeed.portalsite.view.SiteView;
+import org.apache.jetspeed.portalsite.view.SiteViewMenuDefinitionLocator;
+import org.apache.jetspeed.profiler.ProfileLocator;
+import org.apache.jetspeed.profiler.ProfileLocatorProperty;
+import org.apache.jetspeed.security.UserPrincipal;
+
+/**
+ * This class encapsulates managed session state for and
+ * interface to the portal-site component.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class PortalSiteSessionContextImpl implements PortalSiteSessionContext
+{
+    /**
+     * log - logging instance
+     */
+    private final static Log log = LogFactory.getLog(PortalSiteSessionContextImpl.class);
+
+    /**
+     * pageManager - PageManager component
+     */
+    private PageManager pageManager;
+
+    /**
+     * profileLocators - map of session profile locators by locator names
+     */
+    private Map profileLocators;
+
+    /**
+     * userPrincipal - session user principal
+     */
+    private String userPrincipal;
+
+    /**
+     * siteView - session site view
+     */
+    private SiteView siteView;
+
+    /**
+     * folderPageHistory - map of last page visited by folder 
+     */
+    private Map folderPageHistory;
+
+    /**
+     * menuDefinitionLocatorCache - cached menu definition locators for
+     *                              absolute menus valid for session
+     */
+    private Map menuDefinitionLocatorCache;
+
+    /**
+     * PortalSiteSessionContextImpl - constructor
+     *
+     * @param pageManager PageManager component instance
+     */
+    public PortalSiteSessionContextImpl(PageManager pageManager)
+    {
+        this.pageManager = pageManager;
+        this.folderPageHistory = new HashMap();
+    }
+
+    /**
+     * newRequestContext - create a new request context instance
+     *
+     * @param requestProfileLocators request profile locators
+     * @return new request context instance
+     */
+    public PortalSiteRequestContext newRequestContext(Map requestProfileLocators)
+    {
+        // TODO - potentially cache N request contexts and reuse
+        return new PortalSiteRequestContextImpl(this, requestProfileLocators);
+    }
+
+    /**
+     * selectRequestPage - select page proxy for request given profile locators
+     *
+     * @param requestProfileLocators map of profile locators for request
+     * @return selected page proxy for request
+     * @throws NodeNotFoundException if not found
+     * @throws SecurityException if view access not granted
+     */
+    public Page selectRequestPage(Map requestProfileLocators) throws NodeNotFoundException
+    {
+        // validate and update session profile locators if modified
+        if (updateSessionProfileLocators(requestProfileLocators))
+        {
+            // extract page request path from the locators
+            String requestPath = Folder.PATH_SEPARATOR;
+            ProfileLocator locator = (ProfileLocator)requestProfileLocators.get(ProfileLocator.PAGE_LOCATOR);
+            if (locator == null)
+            {
+                // 'page' locator unavailable, use first locator since
+                // all locators should have identical request paths
+                locator = (ProfileLocator)requestProfileLocators.values().iterator().next();
+            }
+            requestPath = locator.getRequestPath();
+            
+            // attempt to select request page or folder using
+            // profile locators and site view
+            Page requestPage = null;
+            try
+            {
+                return selectRequestPage(requestPath);
+            }
+            catch (NodeNotFoundException nnfe)
+            {
+                if (requestPath.equals(Folder.PATH_SEPARATOR))
+                {
+                    throw nnfe;
+                }
+            }
+            catch (SecurityException se)
+            {
+                if (requestPath.equals(Folder.PATH_SEPARATOR))
+                {
+                    throw se;
+                }
+            }
+            
+            // if no matched page or folder, fallback to request of
+            // default page in root folder in page locator
+            return selectRequestPage(Folder.PATH_SEPARATOR);
+        }
+
+        // no request page available
+        throw new NodeNotFoundException("No request page available in site view.");
+    }
+
+    /**
+     * selectRequestPage - select page proxy for request for specified
+     *                     path given profile locators and site view
+     *                     associated with this context
+     *
+     * @param requestPath request path
+     * @return selected page proxy for request
+     * @throws NodeNotFoundException if not found
+     * @throws SecurityException if view access not granted
+     */
+    private Page selectRequestPage(String requestPath) throws NodeNotFoundException
+    {
+        // save access exceptions
+        SecurityException accessException = null;
+
+        // valid SiteView required from session profile locators
+        SiteView view = getSiteView();
+        if (view != null)
+        {
+            // default request to root folder if not specified
+            if (requestPath == null)
+            {
+                requestPath = Folder.PATH_SEPARATOR;
+            }
+            
+            // log page request
+            if (log.isDebugEnabled())
+            {
+                log.debug("Request page: request path=" + requestPath);
+            }
+
+            // lookup request path in view for visible page or folder nodes
+            Node requestNode = null;
+            try
+            {
+                // try page or folder request url
+                requestNode = view.getNodeProxy(requestPath, null, true);
+            }
+            catch (NodeNotFoundException nnfe)
+            {
+                // if request path ends with default page, strip from
+                // request url to retry for folder default
+                if (requestPath.endsWith(Folder.PATH_SEPARATOR + Folder.FALLBACK_DEFAULT_PAGE))
+                {
+                    // retry folder request url
+                    requestPath = requestPath.substring(0, requestPath.length() - Folder.FALLBACK_DEFAULT_PAGE.length());
+                    requestNode = view.getNodeProxy(requestPath, null, true);
+                }
+                else
+                {
+                    // rethrow original exception
+                    throw nnfe;
+                }
+            }
+            
+            // invoke default page logic to determine folder page
+            if (requestNode instanceof Folder)
+            {
+                Folder requestFolder = (Folder)requestNode;
+                
+                // only request folders with pages can be
+                // selected by request; otherwise, fall back to
+                // parent folders assuming that immediate parents
+                // will have the most appropriate default page
+                NodeSet requestFolderPages = null;
+                try
+                {
+                    requestFolderPages = requestFolder.getPages();
+                    while (((requestFolderPages == null) || requestFolderPages.isEmpty()) && (requestFolder.getParent() != null))
+                    {
+                        requestFolder = (Folder)requestFolder.getParent();
+                        requestFolderPages = requestFolder.getPages();
+                    }
+                }
+                catch (NodeException ne)
+                {
+                    requestFolderPages = null;
+                }
+                catch (SecurityException se)
+                {
+                    requestFolderPages = null;
+                    accessException = se;
+                }
+                if ((requestFolderPages != null) && !requestFolderPages.isEmpty())
+                {
+                    // attempt to lookup last visited page by folder proxy
+                    // path, (proxies are hashed by their path), contains
+                    // test must be performed since identical paths may
+                    // occur in multiple site views
+                    Page requestPage = (Page)folderPageHistory.get(requestFolder);
+                    if ((requestPage != null) && requestFolderPages.contains(requestPage))
+                    {
+                        // log selected request page
+                        if (log.isDebugEnabled())
+                        {
+                            log.debug("Selected folder historical page: path=" + view.getManagedPage(requestPage).getPath());
+                        }
+                        return requestPage;
+                    }
+                    
+                    // get default page for folder proxy if more than one
+                    // page is available to choose from
+                    if (requestFolderPages.size() > 1)
+                    {
+                        String defaultPageName = requestFolder.getDefaultPage(false);
+                        if (defaultPageName != null)
+                        {
+                            try
+                            {
+                                // save last visited page for folder proxy
+                                // path, (proxies are hashed by their path),
+                                // and return default page
+                                requestPage = requestFolder.getPage(defaultPageName);
+                                folderPageHistory.put(requestFolder, requestPage);
+
+                                // log selected request page
+                                if (log.isDebugEnabled())
+                                {
+                                    log.debug("Selected folder default page: path=" + view.getManagedPage(requestPage).getPath());
+                                }
+                                return requestPage;
+                            }
+                            catch (NodeException ne)
+                            {
+                            }
+                            catch (SecurityException se)
+                            {
+                                accessException = se;
+                            }
+                        }
+                    }
+                    
+                    // default page not available, select first
+                    // page proxy in request folder; save last
+                    // visited page for folder proxy path,
+                    // (proxies are hashed by their path), and
+                    // return default page
+                    requestPage = (Page)requestFolderPages.iterator().next();
+                    folderPageHistory.put(requestFolder, requestPage);
+
+                    // log selected request page
+                    if (log.isDebugEnabled())
+                    {
+                        log.debug("Selected first folder page, path=" + view.getManagedPage(requestPage).getPath());
+                    }
+                    return requestPage;
+                }
+            }
+            else if (requestNode instanceof Page)
+            {
+                Page requestPage = (Page)requestNode;
+                
+                // save last visited page for folder proxy
+                // path, (proxies are hashed by their path),
+                // and return matched page
+                Folder requestFolder = (Folder)requestPage.getParent();
+                folderPageHistory.put(requestFolder, requestPage);
+
+                // log selected request page
+                if (log.isDebugEnabled())
+                {
+                    log.debug("Selected page, path=" + view.getManagedPage(requestPage).getPath());
+                }
+                return requestPage;
+            }
+        }
+            
+        // no page matched or accessible
+        if (accessException != null)
+        {
+            throw accessException;
+        }
+        throw new NodeNotFoundException("No page matched " + requestPath + " request in site view.");
+    }
+    
+    /**
+     * getRequestRootFolder - select root folder proxy for given profile locators
+     *
+     * @param requestProfileLocators map of profile locators for request
+     * @return root folder proxy for request
+     * @throws NodeNotFoundException if not found
+     * @throws SecurityException if view access not granted
+     */
+    public Folder getRequestRootFolder(Map requestProfileLocators) throws NodeNotFoundException
+    {
+        // validate and update session profile locators if modified
+        if (updateSessionProfileLocators(requestProfileLocators))
+        {
+            // valid site view required from session profile locators
+            SiteView view = getSiteView();
+            if (view != null)
+            {
+                // return root folder proxy from session site view
+                return view.getRootFolderProxy();
+            }
+        }
+
+        // no root folder available
+        throw new NodeNotFoundException("No root folder available in site view.");
+    }
+
+    /**
+     * updateSessionProfileLocators - detect modification of and update cached
+     *                                session profile locators
+     *
+     * @param requestProfileLocators map of profile locators for request
+     * @return profile locators validation flag
+     */
+    private boolean updateSessionProfileLocators(Map requestProfileLocators)
+    {
+        // request profile locators are required
+        if ((requestProfileLocators != null) && !requestProfileLocators.isEmpty())
+        {
+            // get current user principal; ignore derivative
+            // changes in role and group principals
+            String currentUserPrincipal = null;
+            Subject subject = Subject.getSubject(AccessController.getContext());
+            if (subject != null)
+            {
+                Iterator principals = subject.getPrincipals().iterator();
+                while (principals.hasNext())
+                {
+                    Principal principal = (Principal) principals.next();
+                    if (principal instanceof UserPrincipal)
+                    {
+                        if (currentUserPrincipal == null)
+                        {
+                            currentUserPrincipal = principal.getName();
+                        }
+                        else
+                        {
+                            currentUserPrincipal += "|" + principal.getName();
+                        }
+                    }
+                }
+            }
+
+            // detect modification of user principal or
+            // profile locators for session
+            if (((userPrincipal == null) && (currentUserPrincipal != null)) ||
+                ((userPrincipal != null) && !userPrincipal.equals(currentUserPrincipal)) ||
+                (profileLocators == null) ||
+                !locatorsEquals(profileLocators, requestProfileLocators))
+            {
+                // reset cached session profile locators, view,
+                // folder page history, and menu definition locators
+                profileLocators = requestProfileLocators;
+                userPrincipal = currentUserPrincipal;
+                siteView = null;
+                folderPageHistory.clear();
+                if (menuDefinitionLocatorCache != null)
+                {
+                    menuDefinitionLocatorCache.clear();
+                }
+
+                // log session context setup and update
+                if (log.isDebugEnabled())
+                {
+                    StringBuffer debug = new StringBuffer();
+                    debug.append("Updated context: user=" + userPrincipal + ", profileLocators=(");
+                    if (profileLocators != null)
+                    {
+                        boolean firstEntry = true;
+                        Iterator entriesIter = profileLocators.entrySet().iterator();
+                        if (entriesIter.hasNext())
+                        {
+                            Map.Entry entry = (Map.Entry)entriesIter.next();
+                            String locatorName = (String)entry.getKey();
+                            ProfileLocator locator = (ProfileLocator)entry.getValue();
+                            if (!firstEntry)
+                            {
+                                debug.append(",");
+                            }
+                            else
+                            {
+                                firstEntry = false;
+                            }
+                            debug.append(locatorName);
+                            debug.append("=");
+                            debug.append(locator.toString());
+                        }
+                    }
+                    else
+                    {
+                        debug.append("null");
+                    }
+                    debug.append(")");
+                    log.debug(debug);
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * getSiteView - lookup and/or create site view for
+     *               profile locators of this context
+     *
+     * @return site view instance
+     */
+    public SiteView getSiteView()
+    {
+        if ((siteView == null) && (pageManager != null) && (profileLocators != null))
+        {
+            // create new site view
+            siteView = new SiteView(pageManager, profileLocators);
+
+            // log site view creation
+            if (log.isDebugEnabled())
+            {
+                log.debug("Created site view: search paths=" + siteView.getSearchPathsString());
+            }
+        }
+        return siteView;
+    }
+
+    /**
+     * getPageManager - return PageManager component instance
+     *
+     * @return PageManager instance
+     */
+    public PageManager getPageManager()
+    {
+        return pageManager;
+    }
+
+    /**
+     * getProfileLocators - get session profile locators
+     */
+    public Map getProfileLocators()
+    {
+        return profileLocators;
+    }
+
+    /**
+     * getStandardMenuNames - get set of available standard menu names
+     *  
+     * @return menu names set
+     */
+    public Set getStandardMenuNames()
+    {
+        // return standard menu names defined for site view
+        SiteView view = getSiteView();
+        if (view != null)
+        {
+            return view.getStandardMenuNames();
+        }
+        return null;
+    }
+
+    /**
+     * getMenuDefinitionLocators - get list of node proxy menu definition
+     *                             locators from site view
+     *
+     * @param node site view node proxy
+     * @return definition locator list
+     */
+    public List getMenuDefinitionLocators(Node node)
+    {
+        // return menu definition locators for node in site view
+        SiteView view = getSiteView();
+        if (view != null)
+        {
+            return view.getMenuDefinitionLocators(node);
+        }
+        return null;
+    }
+
+    /**
+     * getMenuDefinitionLocator - get named node proxy menu definition
+     *                            locator from site view
+     *
+     * @param node site view node proxy
+     * @param name menu definition name
+     * @return menu definition locator
+     */
+    public SiteViewMenuDefinitionLocator getMenuDefinitionLocator(Node node, String name)
+    {
+        // return named menu definition locator for node in site view
+        SiteView view = getSiteView();
+        if (view != null)
+        {
+            return view.getMenuDefinitionLocator(node, name);
+        }
+        return null;
+    }
+
+    /**
+     * getManagedPage - get concrete page instance from page proxy
+     *  
+     * @param page page proxy
+     * @return managed page
+     */
+    public Page getManagedPage(Page page)
+    {
+        // return managed page in site view
+        SiteView view = getSiteView();
+        if (view != null)
+        {
+            return view.getManagedPage(page);            
+        }
+        return null;
+    }
+
+    /**
+     * getMenuDefinitionLocatorCache - get menu definition locators cache
+     *                                 for absolute menus
+     *
+     * @return menu definition locators cache
+     */
+    public Map getMenuDefinitionLocatorCache()
+    {
+        return menuDefinitionLocatorCache;
+    }
+
+    /**
+     * setMenuDefinitionLocatorCache - set menu definition locators cache
+     *                                 for absolute menus
+     *
+     * @return menu definition locators cache
+     */
+    public void setMenuDefinitionLocatorCache(Map cache)
+    {
+        menuDefinitionLocatorCache = cache;
+    }
+
+    /**
+     * locatorsEquals - test profile locator maps for equivalence
+     *                  ignoring request specifics
+     *
+     * @param locators0 request profile locator map
+     * @param locators1 request profile locator map
+     * @return boolean flag indicating equivalence
+     */
+    private static boolean locatorsEquals(Map locators0, Map locators1)
+    {
+        // trivial comparison
+        if (locators0 == locators1)
+        {
+            return true;
+        }
+
+        // compare locator map sizes
+        if (locators0.size() != locators1.size())
+        {
+            return false;
+        }
+
+        // compare locator map entries
+        Iterator entriesIter = locators0.entrySet().iterator();
+        if (entriesIter.hasNext())
+        {
+            Map.Entry entry = (Map.Entry)entriesIter.next();
+            ProfileLocator locator0 = (ProfileLocator)entry.getValue();
+            ProfileLocator locator1 = (ProfileLocator)locators1.get(entry.getKey());
+            if (locator1 == null)
+            {
+                return false;
+            }
+
+            // compare locators using the most specific,
+            // (i.e. first), locator properties array
+            // returned by the locator iterator
+            ProfileLocatorProperty [] properties0 = (ProfileLocatorProperty [])locator0.iterator().next();
+            ProfileLocatorProperty [] properties1 = (ProfileLocatorProperty [])locator1.iterator().next();
+            if (((properties0 == null) && (properties1 != null)) ||
+                ((properties0 != null) && (properties1 == null)) ||
+                (properties0.length != properties1.length))
+            {
+                return false;
+            }
+
+            // compare control and navigation locator properties
+            if ((properties0 != null) && (properties1 != null))
+            {
+                for (int i = 0, limit = properties0.length; (i < limit); i++)
+                {
+                    // compare names for all properties and control
+                    // and navigation property types and values
+                    if (!properties0[i].getName().equals(properties1[i].getName()) ||
+                        (properties0[i].isControl() && (!properties1[i].isControl() ||
+                                                        !properties0[i].getValue().equals(properties1[i].getValue()))) ||
+                        (properties0[i].isNavigation() && (!properties1[i].isNavigation() ||
+                                                           !properties0[i].getValue().equals(properties1[i].getValue()))))
+                    {
+                        return false;
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * locatorRequestPath - extract request specific path from profile locator
+     *                      using request path from locator
+     *
+     * @param locator request profile locator
+     * @return request path
+     */
+    private static String locatorRequestPath(ProfileLocator locator)
+    {
+        // use request path in locator as default
+        return locatorRequestPath(locator, locator.getRequestPath());
+    }
+
+    /**
+     * locatorRequestPath - extract request specific path from profile locator
+     *
+     * @param locator request profile locator
+     * @param requestPath request path
+     * @return request path
+     */
+    private static String locatorRequestPath(ProfileLocator locator, String requestPath)
+    {
+        // search locator using the most specific,
+        // (i.e. first), locator properties array
+        // returned by the locator iterator and return
+        // first valued property that is not a control
+        // or navigation type
+        ProfileLocatorProperty [] properties = (ProfileLocatorProperty [])locator.iterator().next();
+        for (int i = 0, limit = properties.length; (i < limit); i++)
+        {
+            if (!properties[i].isControl() && !properties[i].isNavigation() && (properties[i].getValue() != null))
+            {
+                // use specified locator path
+                String locatorPath = properties[i].getValue();
+
+                // return specified locatorPath if absolute
+                if (locatorPath.startsWith(Folder.PATH_SEPARATOR))
+                {
+                    return locatorPath;
+                }
+
+                // page names and relative paths are assumed relative to
+                // request path and that any locator paths with no url
+                // separator should have the page extension appended
+                // get default page if page path null
+                if ((locatorPath.indexOf(Folder.PATH_SEPARATOR) == -1) && !locatorPath.endsWith(Page.DOCUMENT_TYPE))
+                {
+                    locatorPath += Page.DOCUMENT_TYPE;
+                }
+            
+                // append locator path to request path, replacing
+                // requested pages and preserving requested folders
+                boolean rootFolderRequest = requestPath.equals(Folder.PATH_SEPARATOR);
+                boolean folderRequest = (!requestPath.endsWith(Page.DOCUMENT_TYPE));
+                int lastSeparatorIndex = requestPath.lastIndexOf(Folder.PATH_SEPARATOR_CHAR);
+                if ((lastSeparatorIndex > 0) && (!folderRequest || requestPath.endsWith(Folder.PATH_SEPARATOR)))
+                {
+                    // append locator to request path base path
+                    return requestPath.substring(0, lastSeparatorIndex) + Folder.PATH_SEPARATOR + locatorPath;
+                }
+                else if (!rootFolderRequest && folderRequest)
+                {
+                    // append locator to request path root folder
+                    return requestPath + Folder.PATH_SEPARATOR + locatorPath;
+                }
+                else
+                {
+                    // use root folder locator
+                    return Folder.PATH_SEPARATOR + locatorPath;
+                }
+            }
+        }
+        return requestPath;
+    }
+}

Propchange: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuDefinition.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuDefinition.java?rev=209305&view=auto
==============================================================================
--- portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuDefinition.java (added)
+++ portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuDefinition.java Tue Jul  5 11:58:05 2005
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portalsite.menu;
+
+import org.apache.jetspeed.om.folder.impl.StandardMenuDefinitionImpl;
+
+/**
+ * This class provides a menu definition for default menus
+ * constructed from folders within menus with depth expansion
+ * specified.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class DefaultMenuDefinition extends StandardMenuDefinitionImpl
+{
+    /**
+     * options - options path specification for menu
+     */
+    private String options;
+
+    /**
+     * depth - inclusion depth for menu
+     */
+    private int depth;
+
+    /**
+     * profile - profile locator for menu and its elements
+     */
+    private String profile;
+
+    /**
+     * DefaultMenuDefinition - constructor
+     */
+    public DefaultMenuDefinition(String options, int depth, String locatorName)
+    {
+        super();
+        this.options = options;
+        this.depth = depth;
+        this.profile = locatorName;
+    }
+
+    /**
+     * getOptions - get comma separated menu options if not specified as elements
+     *
+     * @return option paths specification
+     */
+    public String getOptions()
+    {
+        return options;
+    }
+
+    /**
+     * getDepth - get depth of inclusion for folder menu options
+     *
+     * @return inclusion depth
+     */
+    public int getDepth()
+    {
+        return depth;
+    }
+
+    /**
+     * getProfile - get profile locator used to filter specified options
+     *
+     * @return profile locator name
+     */
+    public String getProfile()
+    {
+        return profile;
+    }
+}

Propchange: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuOptionsDefinition.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuOptionsDefinition.java?rev=209305&view=auto
==============================================================================
--- portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuOptionsDefinition.java (added)
+++ portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuOptionsDefinition.java Tue Jul  5 11:58:05 2005
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portalsite.menu;
+
+import org.apache.jetspeed.om.folder.impl.StandardMenuOptionsDefinitionImpl;
+
+/**
+ * This class provides a menu options definition for options
+ * constructed directly from menu definitions.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class DefaultMenuOptionsDefinition extends StandardMenuOptionsDefinitionImpl
+{
+    /**
+     * options - options path specification for menu
+     */
+    private String options;
+
+    /**
+     * depth - inclusion depth for menu options
+     */
+    private int depth;
+
+    /**
+     * paths - generate ordered paths flag for menu options
+     */
+    private boolean paths;
+
+    /**
+     * regexp - regexp flag for menu options
+     */
+    private boolean regexp;
+
+    /**
+     * profile - profile locator for menu options
+     */
+    private String profile;
+
+    /**
+     * order - comma separated regexp ordering patterns for menu options
+     */
+    private String order;
+
+    /**
+     * DefaultMenuOptionsDefinition - constructor
+     */
+    public DefaultMenuOptionsDefinition(String options, int depth, boolean paths, boolean regexp, String locatorName, String order)
+    {
+        super();
+        this.options = options;
+        this.depth = depth;
+        this.paths = paths;
+        this.regexp = regexp;
+        this.profile = locatorName;
+        this.order = order;
+    }
+
+    /**
+     * getOptions - get comma separated menu options if not specified as elements
+     *
+     * @return option paths specification
+     */
+    public String getOptions()
+    {
+        return options;
+    }
+
+    /**
+     * getDepth - get depth of inclusion for folder menu options
+     *
+     * @return inclusion depth
+     */
+    public int getDepth()
+    {
+        return depth;
+    }
+
+    /**
+     * isPaths - get generate ordered path options
+     *
+     * @return paths options flag
+     */
+    public boolean isPaths()
+    {
+        return paths;
+    }
+    
+    /**
+     * isRegexp - get regexp flag for interpreting options
+     *
+     * @return regexp flag
+     */
+    public boolean isRegexp()
+    {
+        return regexp;
+    }
+
+    /**
+     * getProfile - get profile locator used to filter specified options
+     *
+     * @return profile locator name
+     */
+    public String getProfile()
+    {
+        return profile;
+    }
+
+    /**
+     * getOrder - get comma separated regexp ordering patterns
+     *
+     * @return ordering patterns list
+     */
+    public String getOrder()
+    {
+        return order;
+    }
+}

Propchange: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/DefaultMenuOptionsDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java?rev=209305&view=auto
==============================================================================
--- portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java (added)
+++ portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java Tue Jul  5 11:58:05 2005
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portalsite.menu;
+
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.folder.impl.StandardMenuDefinitionImpl;
+import org.apache.jetspeed.portalsite.view.SiteView;
+
+/**
+ * This class provides a menu definition for the standard
+ * back menu.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class StandardBackMenuDefinition extends StandardMenuDefinitionImpl
+{
+    /**
+     * StandardBackMenuDefinition - constructor
+     */
+    public StandardBackMenuDefinition()
+    {
+        super();
+    }
+
+    /**
+     * getName - get menu name
+     *
+     * @return menu name
+     */
+    public String getName()
+    {
+        return SiteView.STANDARD_BACK_MENU_NAME;
+    }
+
+    /**
+     * getOptions - get comma separated menu options if not specified as elements
+     *
+     * @return option paths specification
+     */
+    public String getOptions()
+    {
+        return ".." + Folder.PATH_SEPARATOR;
+    }
+}

Propchange: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardNavigationsMenuDefinition.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardNavigationsMenuDefinition.java?rev=209305&view=auto
==============================================================================
--- portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardNavigationsMenuDefinition.java (added)
+++ portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardNavigationsMenuDefinition.java Tue Jul  5 11:58:05 2005
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portalsite.menu;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.folder.impl.StandardMenuDefinitionImpl;
+import org.apache.jetspeed.om.folder.impl.StandardMenuIncludeDefinitionImpl;
+import org.apache.jetspeed.om.folder.impl.StandardMenuOptionsDefinitionImpl;
+import org.apache.jetspeed.om.folder.impl.StandardMenuSeparatorDefinitionImpl;
+import org.apache.jetspeed.om.page.Link;
+import org.apache.jetspeed.portalsite.view.SiteView;
+
+/**
+ * This class provides a menu definition for the standard
+ * navigations menu.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class StandardNavigationsMenuDefinition extends StandardMenuDefinitionImpl
+{
+    /**
+     * menuElements - ordered polymorphic list of menu option, nested
+     *                menu, separator, include, and exclude definitions
+     */
+    private List menuElements;
+
+    /**
+     * StandardNavigationsMenuDefinition - constructor
+     */
+    public StandardNavigationsMenuDefinition()
+    {
+        super();
+    }
+
+    /**
+     * getName - get menu name
+     *
+     * @return menu name
+     */
+    public String getName()
+    {
+        return SiteView.STANDARD_NAVIGATIONS_MENU_NAME;
+    }
+
+    /**
+     * getMenuElements - get ordered list of menu options,
+     *                   nested menus, separators, included
+     *                   menu, and excluded menu elements
+     *
+     * @return element list
+     */
+    public List getMenuElements()
+    {
+        // instantiate menu elements if necessary
+        if (menuElements == null)
+        {
+            menuElements = new ArrayList(4);
+            menuElements.add(new StandardMenuSeparatorDefinitionImpl()
+                {
+                    /**
+                     * getText - get default text for separator
+                     *
+                     * @return text
+                     */
+                    public String getText()
+                    {
+                        return "Folders";
+                    }
+                });
+            menuElements.add(new StandardMenuOptionsDefinitionImpl()
+                {
+                    /**
+                     * getOptions - get comma separated menu options
+                     *
+                     * @return option paths specification
+                     */
+                    public String getOptions()
+                    {
+                        return "." + Folder.PATH_SEPARATOR + "*" + Folder.PATH_SEPARATOR;
+                    }
+
+                    /**
+                     * isRegexp - get regexp flag for interpreting option
+                     *
+                     * @return regexp flag
+                     */
+                    public boolean isRegexp()
+                    {
+                        return true;
+                    }
+                });
+            menuElements.add(new StandardMenuIncludeDefinitionImpl()
+                {
+                    /**
+                     * getName - get menu name to nest or with options to include
+                     *
+                     * @return menu name
+                     */
+                    public String getName()
+                    {
+                        return SiteView.CUSTOM_PAGE_NAVIGATIONS_MENU_NAME;
+                    }
+                });
+            menuElements.add(new StandardMenuSeparatorDefinitionImpl()
+                {
+                    /**
+                     * getText - get default text for separator
+                     *
+                     * @return text
+                     */
+                    public String getText()
+                    {
+                        return "Additional Links";
+                    }
+                });
+            menuElements.add(new StandardMenuOptionsDefinitionImpl()
+                {
+                    /**
+                     * getOptions - get comma separated menu options
+                     *
+                     * @return option paths specification
+                     */
+                    public String getOptions()
+                    {
+                        return "*" + Link.DOCUMENT_TYPE;
+                    }
+
+                    /**
+                     * isRegexp - get regexp flag for interpreting option
+                     *
+                     * @return regexp flag
+                     */
+                    public boolean isRegexp()
+                    {
+                        return true;
+                    }
+                });
+        }
+        return menuElements;
+    }
+
+    /**
+     * getSkin - get skin name for menu element
+     *
+     * @return skin name
+     */
+    public String getSkin()
+    {
+        return "left-navigations";
+    }
+}

Propchange: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardNavigationsMenuDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardPagesMenuDefinition.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardPagesMenuDefinition.java?rev=209305&view=auto
==============================================================================
--- portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardPagesMenuDefinition.java (added)
+++ portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardPagesMenuDefinition.java Tue Jul  5 11:58:05 2005
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portalsite.menu;
+
+import org.apache.jetspeed.om.folder.impl.StandardMenuDefinitionImpl;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.portalsite.view.SiteView;
+
+/**
+ * This class provides a menu definition for the standard
+ * pages menu.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class StandardPagesMenuDefinition extends StandardMenuDefinitionImpl
+{
+    /**
+     * StandardPagesMenuDefinition - constructor
+     */
+    public StandardPagesMenuDefinition()
+    {
+        super();
+    }
+
+    /**
+     * getName - get menu name
+     *
+     * @return menu name
+     */
+    public String getName()
+    {
+        return SiteView.STANDARD_PAGES_MENU_NAME;
+    }
+
+    /**
+     * getOptions - get comma separated menu options if not specified as elements
+     *
+     * @return option paths specification
+     */
+    public String getOptions()
+    {
+        return "*" + Page.DOCUMENT_TYPE;
+    }
+
+    /**
+     * isRegexp - get regexp flag for interpreting specified option
+     *
+     * @return regexp flag
+     */
+    public boolean isRegexp()
+    {
+        return true;
+    }
+
+    /**
+     * getSkin - get skin name for menu element
+     *
+     * @return skin name
+     */
+    public String getSkin()
+    {
+        return "tabs";
+    }
+}

Propchange: portals/jetspeed-2/branches/MENUS_BRANCH/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardPagesMenuDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message