portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r882653 [2/3] - in /portals/jetspeed-2/portal/trunk: components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/ components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ components/jetspeed-page-man...
Date Fri, 20 Nov 2009 17:50:20 GMT
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java?rev=882653&r1=882652&r2=882653&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java Fri Nov 20 17:50:11 2009
@@ -27,14 +27,18 @@
 import java.util.List;
 import java.util.Locale;
 
-import org.apache.jetspeed.Jetspeed;
-import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.FolderNotFoundException;
+import org.apache.jetspeed.om.page.DynamicPage;
+import org.apache.jetspeed.om.page.FragmentDefinition;
 import org.apache.jetspeed.om.page.Link;
 import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.PageTemplate;
+import org.apache.jetspeed.om.page.proxy.DynamicPageProxy;
+import org.apache.jetspeed.om.page.proxy.FragmentDefinitionProxy;
 import org.apache.jetspeed.om.page.proxy.LinkProxy;
 import org.apache.jetspeed.om.page.proxy.PageProxy;
+import org.apache.jetspeed.om.page.proxy.PageTemplateProxy;
 import org.apache.jetspeed.om.portlet.GenericMetadata;
 import org.apache.jetspeed.page.PageNotFoundException;
 import org.apache.jetspeed.page.document.DocumentException;
@@ -47,7 +51,6 @@
 import org.apache.jetspeed.page.document.proxy.NodeSetImpl;
 import org.apache.jetspeed.portalsite.view.SiteView;
 import org.apache.jetspeed.portalsite.view.SiteViewSearchPath;
-import org.apache.jetspeed.request.RequestContext;
 
 /**
  * This class proxies PSML Folder instances to create a logical view
@@ -63,8 +66,12 @@
      */
     protected static final Method GET_ALL_METHOD = reflectMethod(Folder.class, "getAll", null);
     protected static final Method GET_DEFAULT_PAGE_METHOD = reflectMethod(Folder.class, "getDefaultPage", null);
+    protected static final Method GET_DYNAMIC_PAGES_METHOD = reflectMethod(Folder.class, "getDynamicPages", null);
+    protected static final Method GET_DYNAMIC_PAGE_METHOD = reflectMethod(Folder.class, "getDynamicPage", new Class[]{String.class});
     protected static final Method GET_FOLDERS_METHOD = reflectMethod(Folder.class, "getFolders", null);
     protected static final Method GET_FOLDER_METHOD = reflectMethod(Folder.class, "getFolder", new Class[]{String.class});
+    protected static final Method GET_FRAGMENT_DEFINITIONS_METHOD = reflectMethod(Folder.class, "getFragmentDefinitions", null);
+    protected static final Method GET_FRAGMENT_DEFINITION_METHOD = reflectMethod(Folder.class, "getFragmentDefinition", new Class[]{String.class});
     protected static final Method GET_LINKS_METHOD = reflectMethod(Folder.class, "getLinks", null);
     protected static final Method GET_LINK_METHOD = reflectMethod(Folder.class, "getLink", new Class[]{String.class});
     protected static final Method GET_MENU_DEFINITIONS_METHOD = reflectMethod(Folder.class, "getMenuDefinitions", null);
@@ -73,6 +80,8 @@
     protected static final Method GET_PAGES_METHOD = reflectMethod(Folder.class, "getPages", null);
     protected static final Method GET_PAGE_METHOD = reflectMethod(Folder.class, "getPage", new Class[]{String.class});
     protected static final Method GET_PAGE_SECURITY_METHOD = reflectMethod(Folder.class, "getPageSecurity", null);
+    protected static final Method GET_PAGE_TEMPLATES_METHOD = reflectMethod(Folder.class, "getPageTemplates", null);
+    protected static final Method GET_PAGE_TEMPLATE_METHOD = reflectMethod(Folder.class, "getPageTemplate", new Class[]{String.class});
     protected static final Method GET_SHORT_TITLE_LOCALE_METHOD = reflectMethod(Folder.class, "getShortTitle", new Class[]{Locale.class});
     protected static final Method GET_SHORT_TITLE_METHOD = reflectMethod(Folder.class, "getShortTitle", null);
     protected static final Method GET_TITLE_LOCALE_METHOD = reflectMethod(Folder.class, "getTitle", new Class[]{Locale.class});
@@ -89,6 +98,11 @@
     private Folder titledFolder;
 
     /**
+     * forceReservedVisible - flag used to suppress child reserved/hidden folder visibility checks
+     */
+    private boolean forceReservedVisible;
+
+    /**
      * children - aggregated proxy sub-folder, page, and link nodes
      */
     private NodeSet children;
@@ -119,6 +133,36 @@
     private boolean pagesAggregated;
 
     /**
+     * pageTemplates - aggregated proxy page template nodes
+     */
+    private NodeSet pageTemplates;
+
+    /**
+     * pageTemplatesAggregated - boolean flag to indicate page templates aggregated
+     */
+    private boolean pageTemplatesAggregated;
+
+    /**
+     * dynamicPages - aggregated proxy dynamic page nodes
+     */
+    private NodeSet dynamicPages;
+
+    /**
+     * dynamicPagesAggregated - boolean flag to indicate dynamic pages aggregated
+     */
+    private boolean dynamicPagesAggregated;
+
+    /**
+     * fragmentDefinitions - aggregated proxy fragment definition nodes
+     */
+    private NodeSet fragmentDefinitions;
+
+    /**
+     * fragmentDefinitionsAggregated - boolean flag to indicate fragment definitions aggregated
+     */
+    private boolean fragmentDefinitionsAggregated;
+
+    /**
      * links - aggregated proxy link nodes
      */
     private NodeSet links;
@@ -164,10 +208,11 @@
      *                    with the proxy delegate
      * @param parentFolder view parent proxy folder
      * @param folder proxy delegate
+     * @param forceReservedVisible suppress reserved/hidden folder visibility checks
      */
-    public static Folder newInstance(SiteView view, String locatorName, Folder parentFolder, Folder folder)
+    public static Folder newInstance(SiteView view, String locatorName, Folder parentFolder, Folder folder, boolean forceReservedVisible)
     {
-        return (Folder)Proxy.newProxyInstance(folder.getClass().getClassLoader(), new Class[]{Folder.class}, new FolderProxy(view, locatorName, parentFolder, folder));
+        return (Folder)Proxy.newProxyInstance(folder.getClass().getClassLoader(), new Class[]{Folder.class}, new FolderProxy(view, locatorName, parentFolder, folder, forceReservedVisible));
     }
 
     /**
@@ -178,12 +223,14 @@
      *                    with the proxy delegate
      * @param parentFolder view parent proxy folder
      * @param folder proxy delegate
+     * @param forceReservedVisible suppress reserved/hidden folder visibility checks
      */
-    private FolderProxy(SiteView view, String locatorName, Folder parentFolder, Folder folder)
+    private FolderProxy(SiteView view, String locatorName, Folder parentFolder, Folder folder, boolean forceReservedVisible)
     {
         super(view, locatorName, parentFolder, folder.getName(), folder.isHidden());
         this.defaultFolder = selectDefaultFromAggregateFolders(folder);
         this.titledFolder = selectTitledFromAggregateFolders(this.defaultFolder);
+        this.forceReservedVisible = forceReservedVisible;
     }
     
     /**
@@ -207,6 +254,14 @@
         {
             return getDefaultPage(proxy);
         }
+        else if (m.equals(GET_DYNAMIC_PAGES_METHOD))
+        {
+            return getDynamicPages(proxy);
+        }
+        else if (m.equals(GET_DYNAMIC_PAGE_METHOD))
+        {
+            return getDynamicPage(proxy, (String)args[0]);
+        }
         else if (m.equals(GET_FOLDERS_METHOD))
         {
             return getFolders(proxy);
@@ -215,6 +270,14 @@
         {
             return getFolder(proxy, (String)args[0]);
         }
+        else if (m.equals(GET_FRAGMENT_DEFINITIONS_METHOD))
+        {
+            return getFragmentDefinitions(proxy);
+        }
+        else if (m.equals(GET_FRAGMENT_DEFINITION_METHOD))
+        {
+            return getFragmentDefinition(proxy, (String)args[0]);
+        }
         else if (m.equals(GET_LINKS_METHOD))
         {
             return getLinks(proxy);
@@ -243,6 +306,14 @@
         {
             return getPage(proxy, (String)args[0]);
         }
+        else if (m.equals(GET_PAGE_TEMPLATES_METHOD))
+        {
+            return getPageTemplates(proxy);
+        }
+        else if (m.equals(GET_PAGE_TEMPLATE_METHOD))
+        {
+            return getPageTemplate(proxy, (String)args[0]);
+        }
         else if (m.equals(GET_SHORT_TITLE_LOCALE_METHOD))
         {
             return getShortTitle((Locale)args[0]);
@@ -495,6 +566,147 @@
     }
 
     /**
+     * getDynamicPages - proxy implementation of Folder.getDynamicPages()
+     *
+     * @param proxy this folder proxy
+     * @return list containing all dynamic pages in folder
+     * @throws NodeException
+     */
+    public NodeSet getDynamicPages(Object proxy) throws NodeException
+    {
+        // latently subset dynamic pages by type from aggregated children
+        if (!dynamicPagesAggregated)
+        {
+            NodeSet allChildren = getAll(proxy);
+            if (allChildren != null)
+            {
+                dynamicPages = allChildren.subset(DynamicPage.DOCUMENT_TYPE);
+            }
+            dynamicPagesAggregated = true;
+        }
+        return dynamicPages;
+    }
+    
+    /**
+     * getDynamicPage - proxy implementation of Folder.getDynamicPage()
+     *
+     * @param proxy this folder proxy
+     * @param name dynamic page name including extension
+     * @return dynamic page
+     * @throws PageNotFoundException
+     * @throws NodeException
+     */
+    public DynamicPage getDynamicPage(Object proxy, String name) throws PageNotFoundException, NodeException
+    {
+        // search for dynamic page by name or absolute path from
+        // aggregated dynamic pages
+        NodeSet allDynamicPages = getDynamicPages(proxy);
+        if (allDynamicPages != null)
+        {
+            DynamicPage dynamicPage = (DynamicPage)allDynamicPages.get(name);
+            if (dynamicPage != null)
+            {
+                return dynamicPage;
+            }
+        }
+        throw new PageNotFoundException("DynamicPage " + name + " not found at " + getPath());
+    }
+
+    /**
+     * getPageTemplates - proxy implementation of Folder.getPageTemplates()
+     *
+     * @param proxy this folder proxy
+     * @return list containing all page templates in folder
+     * @throws NodeException
+     */
+    public NodeSet getPageTemplates(Object proxy) throws NodeException
+    {
+        // latently subset page templates by type from aggregated children
+        if (!pageTemplatesAggregated)
+        {
+            NodeSet allChildren = getAll(proxy);
+            if (allChildren != null)
+            {
+                pageTemplates = allChildren.subset(PageTemplate.DOCUMENT_TYPE);
+            }
+            pageTemplatesAggregated = true;
+        }
+        return pageTemplates;
+    }
+    
+    /**
+     * getPageTemplate - proxy implementation of Folder.getPageTemplate()
+     *
+     * @param proxy this folder proxy
+     * @param name page template name including extension
+     * @return page template
+     * @throws PageNotFoundException
+     * @throws NodeException
+     */
+    public PageTemplate getPageTemplate(Object proxy, String name) throws PageNotFoundException, NodeException
+    {
+        // search for page template by name or absolute path from
+        // aggregated page templates
+        NodeSet allPageTemplates = getPageTemplates(proxy);
+        if (allPageTemplates != null)
+        {
+            PageTemplate pageTemplate = (PageTemplate)allPageTemplates.get(name);
+            if (pageTemplate != null)
+            {
+                return pageTemplate;
+            }
+        }
+        throw new PageNotFoundException("PageTemplate " + name + " not found at " + getPath());
+    }
+
+    /**
+     * getFragmentDefinitions - proxy implementation of Folder.getFragmentDefinitions()
+     *
+     * @param proxy this folder proxy
+     * @return list containing all fragment definitions in folder
+     * @throws NodeException
+     */
+    public NodeSet getFragmentDefinitions(Object proxy) throws NodeException
+    {
+        // latently subset fragment definition by type from aggregated children
+        if (!fragmentDefinitionsAggregated)
+        {
+            NodeSet allChildren = getAll(proxy);
+            if (allChildren != null)
+            {
+                fragmentDefinitions = allChildren.subset(FragmentDefinition.DOCUMENT_TYPE);
+            }
+            fragmentDefinitionsAggregated = true;
+        }
+        return fragmentDefinitions;
+    }
+    
+    /**
+     * getFragmentDefinition - proxy implementation of Folder.getFragmentDefinition()
+     *
+     * @param proxy this folder proxy
+     * @param name fragment definition name including extension
+     * @return fragment definition
+     * @throws PageNotFoundException
+     * @throws NodeException
+     */
+    public FragmentDefinition getFragmentDefinition(Object proxy, String name) throws PageNotFoundException, NodeException
+    {
+        // search for fragment definition by name or absolute path from
+        // aggregated fragment definitions
+        NodeSet allFragmentDefinitions = getFragmentDefinitions(proxy);
+        if (allFragmentDefinitions != null)
+        {
+            FragmentDefinition fragmentDefinition = (FragmentDefinition)allFragmentDefinitions.get(name);
+            if (fragmentDefinition != null)
+            {
+                return fragmentDefinition;
+            }
+        }
+        throw new PageNotFoundException("FragmentDefinition " + name + " not found at " + getPath());
+    }
+
+    /**
      * getMetadata - proxy implementation of Folder.getMetadata()
      *
      * @return metadata
@@ -675,7 +887,7 @@
                 // get menu definitions from inheritance folders and
                 // merge into aggregate menu definition locators
                 Folder folder = (Folder)foldersIter.next();
-                mergeMenuDefinitionLocators(folder.getMenuDefinitions(), folder);
+                mergeMenuDefinitionLocators(folder.getMenuDefinitions(), folder, false);
             }
         }
         catch (FolderNotFoundException fnfe)
@@ -877,24 +1089,13 @@
                     Node child = (Node)childrenIter.next();
                     String childName = child.getName();
 
-                    // filter profiling property folders; they are
-                    // accessed only via SiteView search path
-                    // aggregation that directly utilizes the
-                    // current view page manager
-                    boolean visible = (!(child instanceof Folder) || (!childName.startsWith(Folder.RESERVED_SUBSITE_FOLDER_PREFIX) &&
-                                                       !childName.startsWith(Folder.RESERVED_FOLDER_PREFIX)));
-                    RequestContext rc = Jetspeed.getCurrentRequestContext();
-                    boolean configureMode = false;
-                    if (rc != null)
-                    {
-                        if (rc.getPipeline().getName().equals(PortalReservedParameters.CONFIG_PIPELINE_NAME) ||
-                            rc.getPipeline().getName().equals(PortalReservedParameters.DESKTOP_CONFIG_PIPELINE_NAME))    
-                        {
-                            configureMode = true;
-                        }
-                    }
-                    
-                    if (visible || configureMode)
+                    // filter profiling property folders unless forced; they are
+                    // normally accessed only via SiteView search path aggregation
+                    // that directly utilizes the current view page manager
+                    boolean visible = (forceReservedVisible || (!(child instanceof Folder) ||
+                                                                (!childName.startsWith(Folder.RESERVED_SUBSITE_FOLDER_PREFIX) &&
+                                                                 !childName.startsWith(Folder.RESERVED_FOLDER_PREFIX))));
+                    if (visible)
                     {
                         // test child name uniqueness
                         boolean childUnique = true ;
@@ -909,12 +1110,24 @@
                         {
                             if (child instanceof Folder)
                             {
-                                allChildren.add(FolderProxy.newInstance(getView(), locatorName, (Folder)proxy, (Folder)child));
+                                allChildren.add(FolderProxy.newInstance(getView(), locatorName, (Folder)proxy, (Folder)child, forceReservedVisible));
                             }
                             else if (child instanceof Page)
                             {
                                 allChildren.add(PageProxy.newInstance(getView(), locatorName, (Folder)proxy, (Page)child));
                             }
+                            else if (child instanceof PageTemplate)
+                            {
+                                allChildren.add(PageTemplateProxy.newInstance(getView(), locatorName, (Folder)proxy, (PageTemplate)child));
+                            }
+                            else if (child instanceof DynamicPage)
+                            {
+                                allChildren.add(DynamicPageProxy.newInstance(getView(), locatorName, (Folder)proxy, (DynamicPage)child));
+                            }
+                            else if (child instanceof FragmentDefinition)
+                            {
+                                allChildren.add(FragmentDefinitionProxy.newInstance(getView(), locatorName, (Folder)proxy, (FragmentDefinition)child));
+                            }
                             else if (child instanceof Link)
                             {
                                 allChildren.add(LinkProxy.newInstance(getView(), locatorName, (Folder)proxy, (Link)child));

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageProxy.java?rev=882653&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageProxy.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageProxy.java Fri Nov 20 17:50:11 2009
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.om.page.proxy;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.folder.proxy.FolderProxy;
+import org.apache.jetspeed.om.page.DynamicPage;
+import org.apache.jetspeed.page.document.proxy.NodeProxy;
+import org.apache.jetspeed.portalsite.view.SiteView;
+
+/**
+ * This class proxies PSML DynamicPage instances to create a logical
+ * view of site content using the Dynamic Proxy pattern.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+public class DynamicPageProxy extends NodeProxy implements InvocationHandler
+{
+    /**
+     * *_METHOD - DynamicPage method constants
+     */
+    protected static final Method GET_MENU_DEFINITIONS_METHOD = reflectMethod(DynamicPage.class, "getMenuDefinitions", null);
+
+    /**
+     * dynamicPage - proxy delegate dynamic page instance
+     */
+    private DynamicPage dynamicPage;
+
+    /**
+     * newInstance - creates a new proxy instance that implements the DynamicPage interface
+     *
+     * @param view site view owner of this proxy
+     * @param locatorName name of profile locator associated
+     *                    with the proxy delegate
+     * @param parentFolder view parent proxy folder
+     * @param dynamicPage proxy delegate
+     */
+    public static DynamicPage newInstance(SiteView view, String locatorName, Folder parentFolder, DynamicPage dynamicPage)
+    {
+        return (DynamicPage)Proxy.newProxyInstance(dynamicPage.getClass().getClassLoader(), new Class[]{DynamicPage.class}, new DynamicPageProxy(view, locatorName, parentFolder, dynamicPage));
+    }
+
+    /**
+     * DynamicPageProxy - private constructor used by newInstance()
+     *
+     * @param view site view owner of this proxy
+     * @param locatorName name of profile locator associated
+     *                    with the proxy delegate
+     * @param parentFolder view parent proxy folder
+     * @param dynamicPage proxy delegate
+     */
+    private DynamicPageProxy(SiteView view, String locatorName, Folder parentFolder, DynamicPage dynamicPage)
+    {
+        super(view, locatorName, parentFolder, dynamicPage.getName(), dynamicPage.isHidden());
+        this.dynamicPage = dynamicPage;
+    }
+    
+    /**
+     * invoke - method invocation dispatch for this proxy, (defaults to
+     *          invocation of delegate unless method is implemented in this
+     *          proxy handler or should be hidden/stubbed)
+     *
+     * @param proxy instance invoked against
+     * @param method DynamicPage interface method invoked
+     * @param args method arguments
+     * @throws Throwable
+     */
+    public Object invoke(Object proxy, Method m, Object [] args) throws Throwable
+    {
+        // proxy implementation method dispatch
+        if (m.equals(GET_MENU_DEFINITIONS_METHOD))
+        {
+            return getMenuDefinitions();
+        }
+        else if (m.equals(GET_PARENT_METHOD))
+        {
+            return getParent();
+        }
+        else if (m.equals(GET_PATH_METHOD))
+        {
+            return getPath();
+        }
+        else if (m.equals(GET_URL_METHOD))
+        {
+            return getUrl();
+        }
+        else if (m.equals(EQUALS_METHOD))
+        {
+            return new Boolean(equals(args[0]));
+        }
+        else if (m.equals(HASH_CODE_METHOD))
+        {
+            return new Integer(hashCode());
+        }
+        else if (m.equals(IS_HIDDEN_METHOD))
+        {
+            return new Boolean(isHidden());
+        }
+        else if (m.equals(TO_STRING_METHOD))
+        {
+            return toString();
+        }
+    
+        // proxy suppression of not implemented or mutable methods
+        if (m.getName().startsWith("set"))
+        {
+            throw new RuntimeException("DynamicPage instance is immutable from proxy.");
+        }
+
+        try
+        {
+            // attempt to invoke method on delegate DynamicPage instance
+            return m.invoke(dynamicPage, args);
+        }
+        catch (InvocationTargetException ite)
+        {
+            throw ite.getTargetException();
+        }
+    }
+
+    /**
+     * getDynamicPage - get proxy delegate dynamic page instance
+     *
+     * @return delegate dynamic page
+     */
+    public DynamicPage getDynamicPage()
+    {
+        return dynamicPage;
+    }
+
+    /**
+     * aggregateMenuDefinitionLocators - aggregate all menu definition locators
+     *                                   in site view for this folder or page
+     */
+    protected void aggregateMenuDefinitionLocators()
+    {
+        // merge page and parent folder menu definition locators
+        // by name, (most specific page definitions are merged first
+        // since they override any folder definitions); note parent
+        // folder menu definitions include standard menu definition
+        // locator defaults
+        mergeMenuDefinitionLocators(dynamicPage.getMenuDefinitions(), dynamicPage, true);
+        FolderProxy parentFolderProxy = FolderProxy.getFolderProxy(getParent());
+        mergeMenuDefinitionLocators(parentFolderProxy.getMenuDefinitionLocators());
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionProxy.java?rev=882653&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionProxy.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionProxy.java Fri Nov 20 17:50:11 2009
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.om.page.proxy;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.FragmentDefinition;
+import org.apache.jetspeed.page.document.proxy.NodeProxy;
+import org.apache.jetspeed.portalsite.view.SiteView;
+
+/**
+ * This class proxies PSML FragmentDefinition instances to create
+ * a logical view of site content using the Dynamic Proxy pattern.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+public class FragmentDefinitionProxy extends NodeProxy implements InvocationHandler
+{
+    /**
+     * fragmentDefinition - proxy delegate fragment definition instance
+     */
+    private FragmentDefinition fragmentDefinition;
+
+    /**
+     * newInstance - creates a new proxy instance that implements the FragmentDefinition interface
+     *
+     * @param view site view owner of this proxy
+     * @param locatorName name of profile locator associated
+     *                    with the proxy delegate
+     * @param parentFolder view parent proxy folder
+     * @param fragmentDefinition proxy delegate
+     */
+    public static FragmentDefinition newInstance(SiteView view, String locatorName, Folder parentFolder, FragmentDefinition fragmentDefinition)
+    {
+        return (FragmentDefinition)Proxy.newProxyInstance(fragmentDefinition.getClass().getClassLoader(), new Class[]{FragmentDefinition.class}, new FragmentDefinitionProxy(view, locatorName, parentFolder, fragmentDefinition));
+    }
+
+    /**
+     * FragmentDefinitionProxy - private constructor used by newInstance()
+     *
+     * @param view site view owner of this proxy
+     * @param locatorName name of profile locator associated
+     *                    with the proxy delegate
+     * @param parentFolder view parent proxy folder
+     * @param fragmentDefinition proxy delegate
+     */
+    private FragmentDefinitionProxy(SiteView view, String locatorName, Folder parentFolder, FragmentDefinition fragmentDefinition)
+    {
+        super(view, locatorName, parentFolder, fragmentDefinition.getName(), false);
+        this.fragmentDefinition = fragmentDefinition;
+    }
+    
+    /**
+     * invoke - method invocation dispatch for this proxy, (defaults to
+     *          invocation of delegate unless method is implemented in this
+     *          proxy handler or should be hidden/stubbed)
+     *
+     * @param proxy instance invoked against
+     * @param method FragmentDefinition interface method invoked
+     * @param args method arguments
+     * @throws Throwable
+     */
+    public Object invoke(Object proxy, Method m, Object [] args) throws Throwable
+    {
+        if (m.equals(GET_PARENT_METHOD))
+        {
+            return getParent();
+        }
+        else if (m.equals(GET_PATH_METHOD))
+        {
+            return getPath();
+        }
+        else if (m.equals(GET_URL_METHOD))
+        {
+            return getUrl();
+        }
+        else if (m.equals(EQUALS_METHOD))
+        {
+            return new Boolean(equals(args[0]));
+        }
+        else if (m.equals(HASH_CODE_METHOD))
+        {
+            return new Integer(hashCode());
+        }
+        else if (m.equals(IS_HIDDEN_METHOD))
+        {
+            return new Boolean(isHidden());
+        }
+        else if (m.equals(TO_STRING_METHOD))
+        {
+            return toString();
+        }
+    
+        // proxy suppression of not implemented or mutable methods
+        if (m.getName().startsWith("set"))
+        {
+            throw new RuntimeException("FragmentDefinition instance is immutable from proxy.");
+        }
+
+        try
+        {
+            // attempt to invoke method on delegate FragmentDefinition instance
+            return m.invoke(fragmentDefinition, args);
+        }
+        catch (InvocationTargetException ite)
+        {
+            throw ite.getTargetException();
+        }
+    }
+
+    /**
+     * getFragmentDefinition - get proxy delegate fragment definition instance
+     *
+     * @return delegate fragment definition
+     */
+    public FragmentDefinition getFragmentDefinition()
+    {
+        return fragmentDefinition;
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java?rev=882653&r1=882652&r2=882653&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java Fri Nov 20 17:50:11 2009
@@ -159,7 +159,7 @@
         // since they override any folder definitions); note parent
         // folder menu definitions include standard menu definition
         // locator defaults
-        mergeMenuDefinitionLocators(page.getMenuDefinitions(), page);
+        mergeMenuDefinitionLocators(page.getMenuDefinitions(), page, true);
         FolderProxy parentFolderProxy = FolderProxy.getFolderProxy(getParent());
         mergeMenuDefinitionLocators(parentFolderProxy.getMenuDefinitionLocators());
     }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateProxy.java?rev=882653&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateProxy.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateProxy.java Fri Nov 20 17:50:11 2009
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.om.page.proxy;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.PageTemplate;
+import org.apache.jetspeed.page.document.proxy.NodeProxy;
+import org.apache.jetspeed.portalsite.view.SiteView;
+
+/**
+ * This class proxies PSML PageTemplate instances to create a logical
+ * view of site content using the Dynamic Proxy pattern.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+public class PageTemplateProxy extends NodeProxy implements InvocationHandler
+{
+    /**
+     * *_METHOD - PageTemplate method constants
+     */
+    protected static final Method GET_MENU_DEFINITIONS_METHOD = reflectMethod(PageTemplate.class, "getMenuDefinitions", null);
+
+    /**
+     * pageTemplate - proxy delegate page template instance
+     */
+    private PageTemplate pageTemplate;
+
+    /**
+     * newInstance - creates a new proxy instance that implements the Page interface
+     *
+     * @param view site view owner of this proxy
+     * @param locatorName name of profile locator associated
+     *                    with the proxy delegate
+     * @param parentFolder view parent proxy folder
+     * @param pageTemplate proxy delegate
+     */
+    public static PageTemplate newInstance(SiteView view, String locatorName, Folder parentFolder, PageTemplate pageTemplate)
+    {
+        return (PageTemplate)Proxy.newProxyInstance(pageTemplate.getClass().getClassLoader(), new Class[]{PageTemplate.class}, new PageTemplateProxy(view, locatorName, parentFolder, pageTemplate));
+    }
+
+    /**
+     * PageTemplateProxy - private constructor used by newInstance()
+     *
+     * @param view site view owner of this proxy
+     * @param locatorName name of profile locator associated
+     *                    with the proxy delegate
+     * @param parentFolder view parent proxy folder
+     * @param pageTemplate proxy delegate
+     */
+    private PageTemplateProxy(SiteView view, String locatorName, Folder parentFolder, PageTemplate pageTemplate)
+    {
+        super(view, locatorName, parentFolder, pageTemplate.getName(), false);
+        this.pageTemplate = pageTemplate;
+    }
+    
+    /**
+     * invoke - method invocation dispatch for this proxy, (defaults to
+     *          invocation of delegate unless method is implemented in this
+     *          proxy handler or should be hidden/stubbed)
+     *
+     * @param proxy instance invoked against
+     * @param method PageTemplate interface method invoked
+     * @param args method arguments
+     * @throws Throwable
+     */
+    public Object invoke(Object proxy, Method m, Object [] args) throws Throwable
+    {
+        // proxy implementation method dispatch
+        if (m.equals(GET_MENU_DEFINITIONS_METHOD))
+        {
+            return getMenuDefinitions();
+        }
+        else if (m.equals(GET_PARENT_METHOD))
+        {
+            return getParent();
+        }
+        else if (m.equals(GET_PATH_METHOD))
+        {
+            return getPath();
+        }
+        else if (m.equals(GET_URL_METHOD))
+        {
+            return getUrl();
+        }
+        else if (m.equals(EQUALS_METHOD))
+        {
+            return new Boolean(equals(args[0]));
+        }
+        else if (m.equals(HASH_CODE_METHOD))
+        {
+            return new Integer(hashCode());
+        }
+        else if (m.equals(IS_HIDDEN_METHOD))
+        {
+            return new Boolean(isHidden());
+        }
+        else if (m.equals(TO_STRING_METHOD))
+        {
+            return toString();
+        }
+    
+        // proxy suppression of not implemented or mutable methods
+        if (m.getName().startsWith("set"))
+        {
+            throw new RuntimeException("PageTemplate instance is immutable from proxy.");
+        }
+
+        try
+        {
+            // attempt to invoke method on delegate PageTemplate instance
+            return m.invoke(pageTemplate, args);
+        }
+        catch (InvocationTargetException ite)
+        {
+            throw ite.getTargetException();
+        }
+    }
+
+    /**
+     * getPageTemplate - get proxy delegate page template instance
+     *
+     * @return delegate page template
+     */
+    public PageTemplate getPageTemplate()
+    {
+        return pageTemplate;
+    }
+
+    /**
+     * aggregateMenuDefinitionLocators - aggregate all menu definition locators
+     *                                   in site view for this folder or page
+     */
+    protected void aggregateMenuDefinitionLocators()
+    {
+        // merge only page template menu definition locators by name
+        mergeMenuDefinitionLocators(pageTemplate.getMenuDefinitions(), pageTemplate, false);
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java?rev=882653&r1=882652&r2=882653&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java Fri Nov 20 17:50:11 2009
@@ -270,8 +270,9 @@
      *
      * @param definitions list of menu definitions to merge
      * @param node page or folder node that defines menu definitions
+     * @param override menu definition flag
      */
-    protected void mergeMenuDefinitionLocators(List definitions, Node node)
+    protected void mergeMenuDefinitionLocators(List definitions, Node node, boolean override)
     {
         // merge definitions into aggregated menu definition
         // locators if defined
@@ -293,7 +294,11 @@
                         {
                             menuDefinitionLocators = Collections.synchronizedList(new ArrayList(definitions.size() * 2));
                         }
-                        menuDefinitionLocators.add(new SiteViewMenuDefinitionLocator(definition, node));
+                        menuDefinitionLocators.add(new SiteViewMenuDefinitionLocator(definition, node, override));
+                    }
+                    else if (override)
+                    {
+                        throw new RuntimeException("Override menu definitions must be merged/added before others!");
                     }
                 }
             }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java?rev=882653&r1=882652&r2=882653&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java Fri Nov 20 17:50:11 2009
@@ -26,7 +26,10 @@
 import java.util.Collections;
 
 import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.FragmentDefinition;
+import org.apache.jetspeed.om.page.FragmentReference;
 import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.PageTemplate;
 import org.apache.jetspeed.page.document.Node;
 import org.apache.jetspeed.page.document.NodeException;
 import org.apache.jetspeed.page.document.NodeNotFoundException;
@@ -69,11 +72,36 @@
     private boolean useHistory;
 
     /**
-     * page - cached request profiled page proxy
+     * forceReservedVisible - force reserved/hidden folders visible in site view
+     */
+    private boolean forceReservedVisible;
+
+    /**
+     * requestPage - cached request profiled page proxy
      */
     private Page requestPage;
 
     /**
+     * requestPageTemplate - cached request page template proxy
+     */
+    private PageTemplate requestPageTemplate;
+
+    /**
+     * requestPageTemplateCached - cached flag for request page template proxy
+     */
+    private boolean requestPageTemplateCached;
+
+    /**
+     * requestFragmentDefinitions - cached request request fragment definition proxies map
+     */
+    private Map requestFragmentDefinitions;
+
+    /**
+     * requestFragmentDefinitionsCached - cached flag for request fragment definition proxies map
+     */
+    private boolean requestFragmentDefinitionsCached;
+
+    /**
      * siblingPages - cached node set of visible sibling page proxies
      */
     private NodeSet siblingPages;
@@ -128,14 +156,32 @@
      *                        if locators do not select a page or access is forbidden
      * @param useHistory flag indicating whether to use visited page
      *                   history to select default page per site folder
+     * @param forceReservedVisible force reserved/hidden folders visible in site view
      */
     public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators,
-                                        boolean requestFallback, boolean useHistory)
+                                        boolean requestFallback, boolean useHistory, boolean forceReservedVisible)
     {
         this.sessionContext = sessionContext;
         this.requestProfileLocators = requestProfileLocators;
         this.requestFallback = requestFallback;
         this.useHistory = useHistory;
+        this.forceReservedVisible = forceReservedVisible;
+    }
+
+    /**
+     * PortalSiteRequestContextImpl - constructor
+     *
+     * @param sessionContext session context
+     * @param requestProfileLocators request profile locators
+     * @param requestFallback flag specifying whether to fallback to root folder
+     *                        if locators do not select a page or access is forbidden
+     * @param useHistory flag indicating whether to use visited page
+     *                   history to select default page per site folder
+     */
+    public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators,
+                                        boolean requestFallback, boolean useHistory)
+    {
+        this(sessionContext, requestProfileLocators, requestFallback, useHistory, false);
     }
 
     /**
@@ -149,7 +195,7 @@
     public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators,
                                         boolean requestFallback)
     {
-        this(sessionContext, requestProfileLocators, requestFallback, true);
+        this(sessionContext, requestProfileLocators, requestFallback, true, false);
     }
 
     /**
@@ -160,7 +206,7 @@
      */
     public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators)
     {
-        this(sessionContext, requestProfileLocators, true, true);
+        this(sessionContext, requestProfileLocators, true, true, false);
     }
 
     /**
@@ -197,6 +243,53 @@
     }
 
     /**
+     * getManagedPageTemplate - get request profiled concrete page 
+     *                          template instance as managed by the
+     *                          page manager
+     *  
+     * @return page template
+     * @throws NodeNotFoundException if page not found
+     * @throws SecurityException if page view access not granted
+     */
+    public PageTemplate getManagedPageTemplate() throws NodeNotFoundException
+    {
+        return sessionContext.getManagedPageTemplate(getPageTemplate());            
+    }
+
+    /**
+     * getManagedFragmentDefinitions - get map of request profiled concrete
+     *                                 fragment definition instances as
+     *                                 managed by the page manager
+     *  
+     * @return map of fragment definitions by id
+     * @throws NodeNotFoundException if page not found
+     * @throws SecurityException if page view access not granted
+     */
+    public Map getManagedFragmentDefinitions() throws NodeNotFoundException
+    {
+        // convert map of proxies to map of managed fragment definitions
+        Map fragmentDefinitions = getFragmentDefinitions();
+        if (fragmentDefinitions != null)
+        {
+            Map managedFragmentDefinitions = new HashMap(4);
+            Iterator fragmentDefinitionsIter = fragmentDefinitions.entrySet().iterator();
+            while (fragmentDefinitionsIter.hasNext())
+            {
+                Map.Entry fragmentDefinitionEntry = (Map.Entry)fragmentDefinitionsIter.next();
+                String id = (String)fragmentDefinitionEntry.getKey();
+                FragmentDefinition fragmentDefinition = (FragmentDefinition)fragmentDefinitionEntry.getValue();
+                FragmentDefinition managedFragmentDefinition = sessionContext.getManagedFragmentDefinition(fragmentDefinition);
+                if (managedFragmentDefinition != null)
+                {
+                    managedFragmentDefinitions.put(id, managedFragmentDefinition);
+                }
+            }
+            return managedFragmentDefinitions;
+        }
+        return null;
+    }
+
+    /**
      * getPage - get request profiled page proxy
      *  
      * @return page proxy
@@ -210,12 +303,165 @@
         // cached in this context
         if (requestPage == null)
         {
-            requestPage = sessionContext.selectRequestPage(requestProfileLocators, requestFallback, useHistory);            
+            requestPage = sessionContext.selectRequestPage(requestProfileLocators, requestFallback, useHistory, forceReservedVisible);            
         }
         return requestPage;
     }
 
     /**
+     * getPageTemplate - get page template proxy for request profiled page
+     *  
+     * @return page template proxy if found or null
+     * @throws NodeNotFoundException if page not found
+     * @throws SecurityException if page view access not granted
+     */
+    public PageTemplate getPageTemplate() throws NodeNotFoundException
+    {
+        if (!requestPageTemplateCached)
+        {
+            // get requested page
+            Page page = getPage();
+            if (page != null)
+            {
+                // scan through site looking for first page template
+                // up the folder hierarchy from the requested page
+                try
+                {
+                    Folder folder = (Folder)page.getParent();
+                    while ((folder != null) && (requestPageTemplate == null))
+                    {
+                        NodeSet pageTemplates = folder.getPageTemplates();
+                        if ((pageTemplates != null) && !pageTemplates.isEmpty())
+                        {
+                            // return first page template found
+                            requestPageTemplate = (PageTemplate)pageTemplates.iterator().next();
+                        }
+                        else
+                        {
+                            // continue scan
+                            folder = (Folder)folder.getParent();
+                        }
+                    }
+                }
+                catch (NodeException ne)
+                {
+                }
+            }
+            requestPageTemplateCached = true;
+        }
+        return requestPageTemplate;
+    }
+
+    /**
+     * getFragmentDefinitions - get fragment definition proxy map for request
+     *                          profiled page and page template
+     *  
+     * @return map of fragment definition proxies by fragment id
+     * @throws NodeNotFoundException if page or fragment definition not found
+     * @throws SecurityException if page view access not granted
+     */
+    public Map getFragmentDefinitions() throws NodeNotFoundException
+    {
+        if (!requestFragmentDefinitionsCached)
+        {
+            // get requested page and optional page template
+            Page page = getPage();
+            PageTemplate pageTemplate = getPageTemplate();
+            if (page != null)
+            {
+                // merge fragment reference ids from requested page and page template
+                Set refIds = new HashSet(4);
+                List requestPageFragmentReferences = page.getFragmentsByInterface(FragmentReference.class);
+                mergeFragmentDefinitionRefIds(requestPageFragmentReferences, refIds);
+                List requestPageTemplateFragmentReferences = ((pageTemplate != null) ? pageTemplate.getFragmentsByInterface(FragmentReference.class) : null);
+                mergeFragmentDefinitionRefIds(requestPageTemplateFragmentReferences, refIds);
+                
+                // scan through site looking for each first matching fragment
+                // definition by reference/definition id up the folder hierarchy
+                // from the requested page
+                Iterator refIdsIter = refIds.iterator();
+                while (refIdsIter.hasNext())
+                {
+                    String refId = (String)refIdsIter.next();
+                    FragmentDefinition requestFragmentDefinition = null;
+                    try
+                    {
+                        // scan for fragment definition
+                        Folder folder = (Folder)page.getParent();
+                        while ((folder != null) && (requestFragmentDefinition == null))
+                        {
+                            NodeSet fragmentDefinitions = folder.getFragmentDefinitions();
+                            if ((fragmentDefinitions != null) && !fragmentDefinitions.isEmpty())
+                            {
+                                // find fragment definition by matching reference/definition id
+                                Iterator fragmentDefinitionsIter = fragmentDefinitions.iterator();
+                                while (fragmentDefinitionsIter.hasNext() && (requestFragmentDefinition == null))
+                                {
+                                    FragmentDefinition fragmentDefinition = (FragmentDefinition)fragmentDefinitionsIter.next();
+                                    if (fragmentDefinition.getDefId().equals(refId))
+                                    {
+                                        requestFragmentDefinition = fragmentDefinition;
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                // continue scan
+                                folder = (Folder)folder.getParent();
+                            }
+                        }
+                        
+                        // match fragment definition
+                        if (requestFragmentDefinition != null)
+                        {
+                            if (requestFragmentDefinitions == null)
+                            {
+                                requestFragmentDefinitions = Collections.synchronizedMap(new HashMap(4));
+                            }
+                            requestFragmentDefinitions.put(refId, requestFragmentDefinition);
+                        }
+                        else
+                        {
+                            throw new NodeNotFoundException("Fragment definition for "+refId+" not found.");                        
+                        }
+                    }
+                    catch (NodeException ne)
+                    {
+                        NodeNotFoundException nnfe = new NodeNotFoundException("Fragment definition for "+refId+" not found.");
+                        nnfe.initCause(ne);
+                        throw nnfe;
+                    }
+                }
+            }
+            requestFragmentDefinitionsCached = true;
+        }
+        return requestFragmentDefinitions;
+    }
+    
+    /**
+     * mergeFragmentDefinitionRefIds - utility method to merge reference ids
+     * 
+     * @param fragmentReferences list of fragment references
+     * @param refIds merged set of unique reference ids
+     */
+    private void mergeFragmentDefinitionRefIds(List fragmentReferences, Set refIds)
+    {
+        // merge list of fragment reference reference ids 
+        if ((fragmentReferences != null) && !fragmentReferences.isEmpty())
+        {
+            Iterator fragmentReferencesIter = fragmentReferences.iterator();
+            while (fragmentReferencesIter.hasNext())
+            {
+                FragmentReference fragmentReference = (FragmentReference)fragmentReferencesIter.next();
+                if (fragmentReference.getRefId() != null)
+                {
+                    refIds.add(fragmentReference.getRefId());
+                }
+            }
+        }        
+    }
+
+    /**
      * getFolder - get folder proxy relative to request profiled page
      *  
      * @return page folder proxy
@@ -341,7 +587,7 @@
         // cached in this context
         if (requestRootFolder == null)
         {
-            requestRootFolder = sessionContext.getRequestRootFolder(requestProfileLocators);
+            requestRootFolder = sessionContext.getRequestRootFolder(requestProfileLocators, forceReservedVisible);
         }
         return requestRootFolder;
     }
@@ -393,7 +639,8 @@
 
     /**
      * getCustomMenuNames - get set of custom menu names available as
-     *                      defined for the request profiled page and folder
+     *                      defined for the request profiled page, page
+     *                      template, and folders
      *  
      * @return menu names set
      * @throws NodeNotFoundException if page not found
@@ -401,30 +648,25 @@
      */
     public Set getCustomMenuNames() throws NodeNotFoundException
     {
-        // access page to force request page resolution
+        // access page and page templates to force request
+        // page resolution
         Page page = getPage();
+        PageTemplate pageTemplate = getPageTemplate();
 
         // return available menu definition names from
-        // current request page if not previously cached
-        // in this context
+        // current request page and page template if not
+        // previously cached in this context
         Set standardMenuNames = sessionContext.getStandardMenuNames();
         if ((page != null) && (standardMenuNames != null) && (pageMenuDefinitionNames == null))
         {
-            List locators = sessionContext.getMenuDefinitionLocators(page);
-            if (locators != null)
+            List pageLocators = sessionContext.getMenuDefinitionLocators(page);
+            List pageTemplateLocators = ((pageTemplate != null) ? sessionContext.getMenuDefinitionLocators(pageTemplate) : null);
+            if ((pageLocators != null) || (pageTemplateLocators != null))
             {
                 // get custom definition names
-                pageMenuDefinitionNames = Collections.synchronizedSet(new HashSet(locators.size()));
-                Iterator locatorsIter = locators.iterator();
-                while (locatorsIter.hasNext())
-                {
-                    // get definition name; filter standard menu names
-                    String definitionName = ((SiteViewMenuDefinitionLocator)locatorsIter.next()).getName();
-                    if (!standardMenuNames.contains(definitionName))
-                    {
-                        pageMenuDefinitionNames.add(definitionName);
-                    }
-                }
+                pageMenuDefinitionNames = Collections.synchronizedSet(new HashSet(8));
+                mergeMenuDefinitionLocatorNames(pageLocators, standardMenuNames, pageMenuDefinitionNames);
+                mergeMenuDefinitionLocatorNames(pageTemplateLocators, standardMenuNames, pageMenuDefinitionNames);
             }
             else
             {
@@ -433,6 +675,30 @@
         }
         return pageMenuDefinitionNames;
     }
+    
+    /**
+     * mergeMenuDefinitionLocatorNames - merge menu locator names
+     * 
+     * @param locators menu definition locators
+     * @param excludeNames excluded names set
+     * @param names merged names set
+     */
+    private void mergeMenuDefinitionLocatorNames(List locators, Set excludeNames, Set names)
+    {
+        // merge menu definition locator names
+        if (locators != null)
+        {
+            Iterator locatorsIter = locators.iterator();
+            while (locatorsIter.hasNext())
+            {
+                String definitionName = ((SiteViewMenuDefinitionLocator)locatorsIter.next()).getName();
+                if (!excludeNames.contains(definitionName))
+                {
+                    names.add(definitionName);
+                }
+            }
+        }        
+    }
 
     /**
      * getMenu - get instantiated menu available for the request
@@ -464,12 +730,23 @@
      */
     public Menu getMenu(String name, Set names) throws NodeNotFoundException
     {
-        // access page to force request page resolution
+        // access page and page template to force request
+        // page resolution
         Page page = getPage();
+        PageTemplate pageTemplate = getPageTemplate();
         if ((page != null) && (name != null))
         {
-            // get menu definition locator
+            // get menu definition locator from page or page template
             SiteViewMenuDefinitionLocator locator = sessionContext.getMenuDefinitionLocator(page, name);
+            if ((pageTemplate != null) && ((locator == null) || !locator.isOverride()))
+            {
+                SiteViewMenuDefinitionLocator pageTemplateLocator = sessionContext.getMenuDefinitionLocator(pageTemplate, name);
+                if (pageTemplateLocator != null)
+                {
+                    locator = pageTemplateLocator;
+                }
+            }
+            // get menu implementation for menu definition locator
             if (locator != null)
             {
                 // lookup and return cached relative/request menus

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java?rev=882653&r1=882652&r2=882653&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java Fri Nov 20 17:50:11 2009
@@ -31,10 +31,11 @@
 import javax.servlet.http.HttpSessionBindingListener;
 import javax.servlet.http.HttpSessionEvent;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.DynamicPage;
+import org.apache.jetspeed.om.page.FragmentDefinition;
 import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.PageTemplate;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.PageManagerEventListener;
 import org.apache.jetspeed.page.document.Node;
@@ -50,6 +51,9 @@
 import org.apache.jetspeed.security.JSSubject;
 import org.apache.jetspeed.security.User;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * This class encapsulates managed session state for and
  * interface to the portal-site component and subscribes
@@ -90,6 +94,11 @@
     private transient Map profileLocators;
 
     /**
+     * forceReservedVisible - force reserved/hidden folders visible in site view
+     */
+    private transient boolean forceReservedVisible;
+
+    /**
      * userPrincipal - session user principal
      */
     private transient String userPrincipal;
@@ -123,12 +132,6 @@
     private transient boolean stale;
 
     /**
-     * store which pipeline we are serving
-     * 
-     */
-    private transient String pipeline = "";
-    
-    /**
      * locatorsLastUpdateCheck - time stamp of last locators update check.
      */
     private transient long locatorsLastUpdateCheck;
@@ -141,7 +144,6 @@
     public PortalSiteSessionContextImpl(PageManager pageManager)
     {
         this.pageManager = pageManager;
-        this.pipeline = "";
     }
 
     /**
@@ -152,7 +154,7 @@
      */
     public PortalSiteRequestContext newRequestContext(Map requestProfileLocators)
     {
-        return new PortalSiteRequestContextImpl(this, requestProfileLocators, true, true);
+        return new PortalSiteRequestContextImpl(this, requestProfileLocators, true, true, false);
     }
 
     /**
@@ -165,7 +167,7 @@
      */
     public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, boolean requestFallback)
     {
-        return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestFallback, true);
+        return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestFallback, true, false);
     }
 
     /**
@@ -180,7 +182,23 @@
      */
     public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, boolean requestFallback, boolean useHistory)
     {
-        return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestFallback, useHistory);
+        return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestFallback, useHistory, false);
+    }
+
+    /**
+     * newRequestContext - create a new request context instance
+     *
+     * @param requestProfileLocators request profile locators
+     * @param requestFallback flag specifying whether to fallback to root folder
+     *                        if locators do not select a page or access is forbidden
+     * @param useHistory flag indicating whether to use visited page
+     *                   history to select default page per site folder
+     * @param forceReservedVisible force reserved/hidden folders visible in site view
+     * @return new request context instance
+     */
+    public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, boolean requestFallback, boolean useHistory, boolean forceReservedVisible)
+    {
+        return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestFallback, useHistory, forceReservedVisible);
     }
 
     /**
@@ -191,14 +209,15 @@
      *                        if locators do not select a page or access is forbidden
      * @param useHistory flag indicating whether to use visited page
      *                   history to select default page per site folder
+     * @param forceReservedVisible force reserved/hidden folders visible 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, boolean requestFallback, boolean useHistory) throws NodeNotFoundException
+    public Page selectRequestPage(Map requestProfileLocators, boolean requestFallback, boolean useHistory, boolean forceReservedVisible) throws NodeNotFoundException
     {
         // validate and update session profile locators if modified
-        if (updateSessionProfileLocators(requestProfileLocators))
+        if (updateSessionProfileLocators(requestProfileLocators, forceReservedVisible))
         {
             // extract page request path from the locators
             String requestPath = Folder.PATH_SEPARATOR;
@@ -664,14 +683,15 @@
      * getRequestRootFolder - select root folder proxy for given profile locators
      *
      * @param requestProfileLocators map of profile locators for request
+     * @param requestForceReservedVisible force reserved/hidden folders visible 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
+    public Folder getRequestRootFolder(Map requestProfileLocators, boolean requestForceReservedVisible) throws NodeNotFoundException
     {
         // validate and update session profile locators if modified
-        if (updateSessionProfileLocators(requestProfileLocators))
+        if (updateSessionProfileLocators(requestProfileLocators, requestForceReservedVisible))
         {
             // valid site view required from session profile locators
             SiteView view = getSiteView();
@@ -691,9 +711,10 @@
      *                                session profile locators
      *
      * @param requestProfileLocators map of profile locators for request
+     * @param requestForceReservedVisible force reserved/hidden folders visible for request
      * @return profile locators validation flag
      */
-    private boolean updateSessionProfileLocators(Map requestProfileLocators)
+    private boolean updateSessionProfileLocators(Map requestProfileLocators, boolean requestForceReservedVisible)
     {
         // request profile locators are required
         if ((requestProfileLocators != null) && !requestProfileLocators.isEmpty())
@@ -727,6 +748,7 @@
             // this session context
             boolean userUpdate = false;
             boolean locatorsUpdate = false;
+            boolean forceReservedVisibleUpdate = false;
             boolean updated = false;
             synchronized (this)
             {
@@ -734,7 +756,8 @@
                               ((userPrincipal != null) && !userPrincipal.equals(currentUserPrincipal)));
                 locatorsUpdate = ((profileLocators == null) ||
                                   !locatorsEquals(profileLocators, requestProfileLocators));
-                if (stale || userUpdate || locatorsUpdate)
+                forceReservedVisibleUpdate = (forceReservedVisible != requestForceReservedVisible);
+                if (stale || userUpdate || locatorsUpdate || forceReservedVisibleUpdate)
                 {
                     // reset cached session profile locators, view,
                     // folder page history, menu definition locators,
@@ -758,6 +781,10 @@
                     {
                         debug.append("/locators");
                     }
+                    if (forceReservedVisibleUpdate)
+                    {
+                        debug.append("/force reserved visible");
+                    }
                     if (stale)
                     {
                         debug.append("/stale");
@@ -766,6 +793,18 @@
                 else if (locatorsUpdate)
                 {
                     debug.append("Updated locators");
+                    if (forceReservedVisibleUpdate)
+                    {
+                        debug.append("/force reserved visible");
+                    }
+                    if (stale)
+                    {
+                        debug.append("/stale");
+                    }
+                }
+                else if (forceReservedVisibleUpdate)
+                {
+                    debug.append("Updated force reserved visible");
                     if (stale)
                     {
                         debug.append("/stale");
@@ -863,7 +902,7 @@
                 // may arrive during construction of the site view which
                 // might then result in synchronized deadlock with page
                 // manager or page manager cache internals
-                view = new SiteView(pageManager, profileLocators);
+                view = new SiteView(pageManager, profileLocators, forceReservedVisible);
 
                 // update site view if not already made available by another
                 // request thread
@@ -928,11 +967,7 @@
     {
         // return standard menu names defined for site view
         SiteView view = getSiteView();
-        if (view != null)
-        {
-            return view.getStandardMenuNames();
-        }
-        return null;
+        return ((view != null) ? view.getStandardMenuNames() : null);            
     }
 
     /**
@@ -946,11 +981,7 @@
     {
         // return menu definition locators for node in site view
         SiteView view = getSiteView();
-        if (view != null)
-        {
-            return view.getMenuDefinitionLocators(node);
-        }
-        return null;
+        return ((view != null) ? view.getMenuDefinitionLocators(node) : null);            
     }
 
     /**
@@ -965,11 +996,7 @@
     {
         // return named menu definition locator for node in site view
         SiteView view = getSiteView();
-        if (view != null)
-        {
-            return view.getMenuDefinitionLocator(node, name);
-        }
-        return null;
+        return ((view != null) ? view.getMenuDefinitionLocator(node, name) : null);            
     }
 
     /**
@@ -982,11 +1009,49 @@
     {
         // return managed page in site view
         SiteView view = getSiteView();
-        if (view != null)
-        {
-            return view.getManagedPage(page);            
-        }
-        return null;
+        return ((view != null) ? view.getManagedPage(page) : null);            
+    }
+
+    /**
+     * getManagedPageTemplate - get concrete page template instance from page
+     *                          template proxy
+     *  
+     * @param pageTemplate page template proxy
+     * @return managed page template
+     */
+    public PageTemplate getManagedPageTemplate(PageTemplate pageTemplate)
+    {
+        // return managed page template in site view
+        SiteView view = getSiteView();
+        return ((view != null) ? view.getManagedPageTemplate(pageTemplate) : null);            
+    }
+
+    /**
+     * getManagedDynamicPage - get concrete dynamic page instance from dynamic
+     *                         page proxy
+     *  
+     * @param dynamicPage dynamic page proxy
+     * @return managed dynamic page
+     */
+    public DynamicPage getManagedDynamicPage(DynamicPage dynamicPage)
+    {
+        // return managed dynamic page in site view
+        SiteView view = getSiteView();
+        return ((view != null) ? view.getManagedDynamicPage(dynamicPage) : null);            
+    }
+
+    /**
+     * getManagedFragmentDefinition - get concrete dynamic page instance from
+     *                                fragment definition proxy
+     *  
+     * @param fragmentDefinition fragment definition proxy
+     * @return managed fragment definition
+     */
+    public FragmentDefinition getManagedFragmentDefinition(FragmentDefinition fragmentDefinition)
+    {
+        // return managed fragment definition in site view
+        SiteView view = getSiteView();
+        return ((view != null) ? view.getManagedFragmentDefinition(fragmentDefinition) : null);            
     }
 
     /**
@@ -1314,14 +1379,4 @@
 		}
 		return folderPageHistory;
 	}
-    
-    public void setPipeline(String pipeline)
-    {
-        this.pipeline = pipeline;
-    }
-    
-    public String getPipeline()
-    {
-        return this.pipeline;
-    }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteView.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteView.java?rev=882653&r1=882652&r2=882653&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteView.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteView.java Fri Nov 20 17:50:11 2009
@@ -26,8 +26,15 @@
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.FolderNotFoundException;
 import org.apache.jetspeed.om.folder.proxy.FolderProxy;
+import org.apache.jetspeed.om.page.DynamicPage;
+import org.apache.jetspeed.om.page.FragmentDefinition;
+import org.apache.jetspeed.om.page.Link;
 import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.PageTemplate;
+import org.apache.jetspeed.om.page.proxy.DynamicPageProxy;
+import org.apache.jetspeed.om.page.proxy.FragmentDefinitionProxy;
 import org.apache.jetspeed.om.page.proxy.PageProxy;
+import org.apache.jetspeed.om.page.proxy.PageTemplateProxy;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.document.Node;
 import org.apache.jetspeed.page.document.NodeException;
@@ -111,6 +118,11 @@
      * searchPathsString - search paths as string
      */
     private String searchPathsString;
+    
+    /**
+     * forceReservedVisible - force visibility of hidden/reserved folders
+     */
+    private boolean forceReservedVisible;
 
     /**
      * rootFolderProxy - root folder proxy instance
@@ -123,8 +135,9 @@
      * @param pageManager PageManager component instance
      * @param searchPaths list of search paths in string or search path
      *                    object form
+     * @param forceReservedVisible force visibility of hidden/reserved folders
      */
-    public SiteView(PageManager pageManager, List searchPaths)
+    public SiteView(PageManager pageManager, List searchPaths, boolean forceReservedVisible)
     {
         this.pageManager = pageManager;
         if ((searchPaths != null) && !searchPaths.isEmpty())
@@ -197,6 +210,7 @@
             this.searchPaths.add(new SiteViewSearchPath(ProfileLocator.PAGE_LOCATOR, Folder.PATH_SEPARATOR));
             this.searchPathsString = Folder.PATH_SEPARATOR;
         }
+        this.forceReservedVisible = forceReservedVisible;
     }
 
     /**
@@ -204,10 +218,11 @@
      *
      * @param pageManager PageManager component instance
      * @param searchPaths array of search paths
+     * @param forceReservedVisible force visibility of hidden/reserved folders
      */
-    public SiteView(PageManager pageManager, String [] searchPaths)
+    public SiteView(PageManager pageManager, String [] searchPaths, boolean forceReservedVisible)
     {
-        this(pageManager, makeSearchPathList(searchPaths));
+        this(pageManager, makeSearchPathList(searchPaths), forceReservedVisible);
     }
 
     /**
@@ -235,10 +250,11 @@
      *
      * @param pageManager PageManager component instance
      * @param searchPaths string of comma separated search paths
+     * @param forceReservedVisible force visibility of hidden/reserved folders
      */
-    public SiteView(PageManager pageManager, String searchPaths)
+    public SiteView(PageManager pageManager, String searchPaths, boolean forceReservedVisible)
     {
-        this(pageManager, makeSearchPathList(searchPaths));
+        this(pageManager, makeSearchPathList(searchPaths), forceReservedVisible);
     }
 
     /**
@@ -257,10 +273,11 @@
      *
      * @param pageManager PageManager component instance
      * @param locator profile locator search specification
+     * @param forceReservedVisible force visibility of hidden/reserved folders
      */
-    public SiteView(PageManager pageManager, ProfileLocator locator)
+    public SiteView(PageManager pageManager, ProfileLocator locator, boolean forceReservedVisible)
     {
-        this(pageManager, makeSearchPathList(locator));
+        this(pageManager, makeSearchPathList(locator), forceReservedVisible);
     }
     
     /**
@@ -284,10 +301,11 @@
      *
      * @param pageManager PageManager component instance
      * @param locators map of named profile locator search specifications
+     * @param forceReservedVisible force visibility of hidden/reserved folders
      */
-    public SiteView(PageManager pageManager, Map locators)
+    public SiteView(PageManager pageManager, Map locators, boolean forceReservedVisible)
     {
-        this(pageManager, makeSearchPathList(locators));
+        this(pageManager, makeSearchPathList(locators), forceReservedVisible);
     }
     
     /**
@@ -576,7 +594,7 @@
      */
     public SiteView(PageManager pageManager)
     {
-        this(pageManager, (List)null);
+        this(pageManager, (List)null, false);
     }
 
     /**
@@ -634,7 +652,7 @@
                 // get concrete root folder from page manager
                 // and construct proxy
                 Folder rootFolder = pageManager.getFolder(path);
-                rootFolderProxy = FolderProxy.newInstance(this, locatorName, null, rootFolder);
+                rootFolderProxy = FolderProxy.newInstance(this, locatorName, null, rootFolder, forceReservedVisible);
             }
             catch (NodeException ne)
             {
@@ -758,7 +776,8 @@
                     if (children != null)
                     {
                         Node node = children.get(currentPath);
-                        if ((node != null) && (!onlyVisible || !node.isHidden() || (node == currentPage)) &&
+                        if (((node instanceof Folder) | (node instanceof Page) | (node instanceof Link)) &&
+                            (!onlyVisible || !node.isHidden() || (node == currentPage)) &&
                             (!onlyViewable || isProxyViewable(node, onlyVisible)))
                         {
                             return node;
@@ -977,7 +996,7 @@
                         {
                             // copy children matching remaining path pattern as
                             // page, folder, or link proxies if viewable/visible or
-                            // visibilty not required
+                            // visibility not required
                             children = children.inclusiveSubset(pathPattern);
                             if ((children != null) && !children.isEmpty())
                             {
@@ -986,7 +1005,8 @@
                                 while (childrenIter.hasNext())
                                 {
                                     Node child = (Node)childrenIter.next(); 
-                                    if ((!onlyVisible || !child.isHidden() || (child == currentPage)) &&
+                                    if (((child instanceof Folder) | (child instanceof Page) | (child instanceof Link)) &&
+                                        (!onlyVisible || !child.isHidden() || (child == currentPage)) &&
                                         (!onlyViewable || isProxyViewable(child, onlyVisible)))
                                     {
                                         if (proxies == null)
@@ -1003,9 +1023,10 @@
                         {
                             // access remaining path as page, folder, or link
                             // node proxy; return null if not found or not
-                            // viewable and visiblity is required
+                            // viewable and visibility is required
                             Node child = children.get(currentRegexpPath);
-                            if ((child != null) && (!onlyVisible || !child.isHidden() || (child == currentPage)) &&
+                            if (((child instanceof Folder) | (child instanceof Page) | (child instanceof Link)) &&
+                                (!onlyVisible || !child.isHidden() || (child == currentPage)) &&
                                 (!onlyViewable || isProxyViewable(child, onlyVisible)))
                             {
                                 List proxies = new ArrayList(1);
@@ -1235,10 +1256,59 @@
         // access page proxy from specified page and
         // return associated delegate managed page
         PageProxy pageProxy = (PageProxy)NodeProxy.getNodeProxy(page);
-        if (pageProxy != null)
-        {
-            return pageProxy.getPage();
-        }
-        return null;
+        return ((pageProxy != null) ? pageProxy.getPage() : null);
+    }
+
+    /**
+     * getManagedPageTemplate - get concrete page template instance from
+     *                          page template proxy; implemented here to
+     *                          hide view proxy manipulation from more
+     *                          general portal site implementation
+     *  
+     * @param pageTemplate page template proxy
+     * @return managed page template
+     */
+    public PageTemplate getManagedPageTemplate(PageTemplate pageTemplate)
+    {
+        // access page template proxy from specified page template
+        // and return associated delegate managed page template
+        PageTemplateProxy pageTemplateProxy = (PageTemplateProxy)NodeProxy.getNodeProxy(pageTemplate);
+        return ((pageTemplateProxy != null) ? pageTemplateProxy.getPageTemplate() : null);
+    }
+
+    /**
+     * getManagedDynamicPage - get concrete dynamic page instance from
+     *                         dynamic page proxy; implemented here to
+     *                         hide view proxy manipulation from more
+     *                         general portal site implementation
+     *  
+     * @param dynamicPage dynamic page proxy
+     * @return managed dynamic page
+     */
+    public DynamicPage getManagedDynamicPage(DynamicPage dynamicPage)
+    {
+        // access dynamic page proxy from specified dynamic page
+        // and return associated delegate managed dynamic page
+        DynamicPageProxy dynamicPageProxy = (DynamicPageProxy)NodeProxy.getNodeProxy(dynamicPage);
+        return ((dynamicPageProxy != null) ? dynamicPageProxy.getDynamicPage() : null);
+    }
+
+    /**
+     * getManagedFragmentDefinition - get concrete fragment definition
+     *                                instance from fragment definition
+     *                                proxy; implemented here to hide
+     *                                view proxy manipulation from more
+     *                                general portal site implementation
+     *  
+     * @param fragmentDefinition fragment definition proxy
+     * @return managed dynamic page
+     */
+    public FragmentDefinition getManagedFragmentDefinition(FragmentDefinition fragmentDefinition)
+    {
+        // access fragment definition proxy from specified fragment
+        // definition and return associated delegate managed
+        // fragment definition
+        FragmentDefinitionProxy fragmentDefinitionProxy = (FragmentDefinitionProxy)NodeProxy.getNodeProxy(fragmentDefinition);
+        return ((fragmentDefinitionProxy != null) ? fragmentDefinitionProxy.getFragmentDefinition() : null);
     }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewMenuDefinitionLocator.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewMenuDefinitionLocator.java?rev=882653&r1=882652&r2=882653&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewMenuDefinitionLocator.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewMenuDefinitionLocator.java Fri Nov 20 17:50:11 2009
@@ -42,15 +42,22 @@
     private MenuDefinition menuDefinition;
 
     /**
+     * override - override menu definition flag
+     */
+    private boolean override;
+
+    /**
      * SiteViewMenuDefinitionLocator - custom menu definition constructor
      *
      * @param menuDefinition custom menu definition
      * @param definingNode defining page or folder
+     * @param 
      */
-    public SiteViewMenuDefinitionLocator(MenuDefinition menuDefinition, Node definingNode)
+    public SiteViewMenuDefinitionLocator(MenuDefinition menuDefinition, Node definingNode, boolean override)
     {
         this.menuDefinition = menuDefinition;
         this.locator = definingNode.getPath() + "|" + menuDefinition.getName();
+        this.override = override;
     }
 
     /**
@@ -117,4 +124,14 @@
     {
         return menuDefinition.getName();
     }
+
+    /**
+     * isOverride - return override menu definition flag
+     *
+     * @return override menu definition flag
+     */
+    public boolean isOverride()
+    {
+        return override;
+    }
 }



---------------------------------------------------------------------
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