You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by vk...@apache.org on 2009/05/22 12:39:48 UTC

svn commit: r777460 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site: ./ Model/

Author: vkumar
Date: Fri May 22 10:39:47 2009
New Revision: 777460

URL: http://svn.apache.org/viewvc?rev=777460&view=rev
Log:
Adding Serializable bean for Jetspeed Menu objects to fix SerializableException exception
http://issues.apache.org/jira/browse/JS2-1017

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/ExcludesDefinitionBean.java   (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/IncludesDefinitionBean.java   (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/JetspeedMenuDefinition.java   (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/OptionsDefinitionBean.java   (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/SeparatorDefinitionBean.java   (with props)
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/JetspeedDocument.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/MenuTreeNode.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/JetspeedDocument.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/JetspeedDocument.java?rev=777460&r1=777459&r2=777460&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/JetspeedDocument.java (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/JetspeedDocument.java Fri May 22 10:39:47 2009
@@ -57,6 +57,7 @@
     private String path;
     private List<JetspeedDocumentMetaData> metaData;
     private List<String> documentOrder;
+    private String type;
 
     public JetspeedDocument()
     {
@@ -64,6 +65,7 @@
     }
     public JetspeedDocument(Folder folder)
     {
+        this.type = PortalSiteManager.FOLDER_NODE_TYPE;
         this.path = folder.getPath();
         this.name = folder.getName();
         this.title = folder.getTitle();
@@ -74,11 +76,12 @@
         this.portletDecorator = folder.getDefaultDecorator(Fragment.PORTLET); 
         loadMetaData(folder.getMetadata());
         loadSecurityData(folder.getSecurityConstraints());
-        this.documentOrder = folder.getDocumentOrder();
+        loadDocumentOrder(folder.getDocumentOrder());
     }
 
     public JetspeedDocument(Page page)
     {
+        this.type = PortalSiteManager.PAGE_NODE_TYPE;
         this.path = page.getPath();
         this.name = page.getName();
         this.title = page.getTitle();
@@ -93,6 +96,7 @@
 
     public JetspeedDocument(Link link)
     {
+        this.type = PortalSiteManager.LINK_NODE_TYPE;
         this.path = link.getPath();
         this.name = link.getName();
         this.title = link.getTitle();
@@ -329,6 +333,21 @@
     {
         return path;
     }
+            
+    /**
+     * @return the type
+     */
+    public String getType()
+    {
+        return type;
+    }
+    /**
+     * @param type the type to set
+     */
+    public void setType(String type)
+    {
+        this.type = type;
+    }
     private void loadSecurityData(SecurityConstraints constraints)
     {
         this.securityConstraints = new ArrayList();
@@ -353,6 +372,15 @@
         }
     }
     
+    private void loadDocumentOrder(List documentOrder)
+    {
+        this.documentOrder = new ArrayList<String>();
+        for(int index=0;index<documentOrder.size();index++)
+        {
+            this.documentOrder.add(documentOrder.get(index).toString());
+        }
+    }
+    
     protected String getEscapedName(String pageName)
     {
         if(pageName== null)

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/MenuTreeNode.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/MenuTreeNode.java?rev=777460&r1=777459&r2=777460&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/MenuTreeNode.java (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/MenuTreeNode.java Fri May 22 10:39:47 2009
@@ -17,8 +17,14 @@
 package org.apache.jetspeed.portlets.site;
 
 import java.io.Serializable;
+import java.util.List;
 
+import org.apache.jetspeed.om.folder.FolderNotFoundException;
+import org.apache.jetspeed.om.folder.InvalidFolderException;
 import org.apache.jetspeed.om.folder.MenuDefinition;
+import org.apache.jetspeed.page.PageNotFoundException;
+import org.apache.jetspeed.page.document.NodeException;
+import org.apache.jetspeed.portlets.JetspeedServiceLocator;
 
 /**
  * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
@@ -26,19 +32,26 @@
  */
 public class MenuTreeNode implements Serializable
 {
-
     private static final long serialVersionUID = 1L;
-    private MenuDefinition definition = null;
+    private String path;
     private String name;
-    public MenuTreeNode(MenuDefinition definition)
+    private String type;
+    private JetspeedServiceLocator locator;
+
+    public MenuTreeNode(String name, JetspeedServiceLocator locator)
     {
-        this.definition = definition;
+        this.name = name;
+        this.locator = locator;
     }
-    public MenuTreeNode(String name)
+
+    public MenuTreeNode(String name, String path, String type, JetspeedServiceLocator locator)
     {
         this.name = name;
+        this.locator = locator;
+        this.type = type;
+        this.path = path;
     }
-    
+
     /**
      * @return the name
      */
@@ -46,15 +59,76 @@
     {
         return name;
     }
+
     @Override
     public String toString()
     {
-        return definition!=null?definition.getName():name!=null?name:super.toString();
+        return name != null ? name : super.toString();
     }
-    
+
     public MenuDefinition getDefinition()
     {
-        return this.definition;
+        MenuDefinition definition = null;
+        boolean found = true;
+        try
+        {
+            if (type.equals(PortalSiteManager.FOLDER_NODE_TYPE))
+            {
+                return getMenu(locator.getPageManager().getFolder(path).getMenuDefinitions());
+            }
+            else if (type.equals(PortalSiteManager.PAGE_NODE_TYPE))
+            {
+                return getMenu(locator.getPageManager().getPage(path).getMenuDefinitions());
+            }
+        }
+        catch (PageNotFoundException e)
+        {
+            found = false;
+        }
+        catch (FolderNotFoundException e)
+        {
+            found = false;
+        }
+        catch (InvalidFolderException e)
+        {
+            found = false;
+        }
+        catch (NodeException e)
+        {
+            found = false;
+        }
+        catch (Exception e)
+        {
+            found = false;
+        }
+        if (!found)
+        {
+            if (type.equals(PortalSiteManager.PAGE_NODE_TYPE))
+            {
+                definition = locator.getPageManager().newPageMenuDefinition();
+            }
+            else if (type.equals(PortalSiteManager.FOLDER_NODE_TYPE))
+            {
+                definition = locator.getPageManager().newFolderMenuDefinition();
+            }
+        }
+        return definition;
+    }
+
+    private MenuDefinition getMenu(List menuDefinitions)
+    {
+        for (int index = 0; index < menuDefinitions.size(); index++)
+        {
+            MenuDefinition definition = (MenuDefinition) menuDefinitions.get(index);
+            if (definition.getName().equals(name))
+            {
+                return definition;
+            }
+        }
+        if (type.equals(PortalSiteManager.PAGE_NODE_TYPE))
+        {
+            return locator.getPageManager().newPageMenuDefinition();
+        }
+        return locator.getPageManager().newFolderMenuDefinition();
     }
-    
 }

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/ExcludesDefinitionBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/ExcludesDefinitionBean.java?rev=777460&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/ExcludesDefinitionBean.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/ExcludesDefinitionBean.java Fri May 22 10:39:47 2009
@@ -0,0 +1,60 @@
+/*
+ * 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.portlets.site.Model;
+
+import java.io.Serializable;
+
+import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
+
+/**
+ * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
+ * @version $Id$
+ */
+public class ExcludesDefinitionBean implements Serializable
+{
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 5901585697492383657L;
+    private String name;
+    
+    public ExcludesDefinitionBean()
+    {
+    }
+    
+    public ExcludesDefinitionBean(MenuExcludeDefinition definition)
+    {
+        this.name = definition.getName();
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+    
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/ExcludesDefinitionBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/IncludesDefinitionBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/IncludesDefinitionBean.java?rev=777460&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/IncludesDefinitionBean.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/IncludesDefinitionBean.java Fri May 22 10:39:47 2009
@@ -0,0 +1,74 @@
+/*
+ * 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.portlets.site.Model;
+
+import java.io.Serializable;
+
+import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
+
+/**
+ * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
+ * @version $Id$
+ */
+public class IncludesDefinitionBean implements Serializable
+{
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -7091578820268065886L;
+    private String name;
+    private boolean nest;
+    
+    public IncludesDefinitionBean()
+    {
+        
+    }
+    public IncludesDefinitionBean(MenuIncludeDefinition definition)
+    {
+        this.name = definition.getName();
+        this.nest = definition.isNest();
+    }
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+    /**
+     * @return the nest
+     */
+    public boolean isNest()
+    {
+        return nest;
+    }
+    /**
+     * @param nest the nest to set
+     */
+    public void setNest(boolean nest)
+    {
+        this.nest = nest;
+    }
+    
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/IncludesDefinitionBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/JetspeedMenuDefinition.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/JetspeedMenuDefinition.java?rev=777460&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/JetspeedMenuDefinition.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/JetspeedMenuDefinition.java Fri May 22 10:39:47 2009
@@ -0,0 +1,227 @@
+/*
+ * 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.portlets.site.Model;
+
+import java.io.Serializable;
+
+import org.apache.jetspeed.om.folder.MenuDefinition;
+
+/**
+ * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
+ * @version $Id$
+ */
+public class JetspeedMenuDefinition implements Serializable
+{
+    private String name;
+    private String options;
+    private int depth;
+    private boolean paths;
+    private boolean regexp;
+    private String profile;
+    private String order;
+    private String skin;
+    private String title;
+    private String shortTitle;
+
+    public JetspeedMenuDefinition()
+    {        
+    }
+    
+    public JetspeedMenuDefinition(MenuDefinition definition)
+    {
+        this.name = definition.getName();
+        this.options = definition.getOptions();
+        this.depth = definition.getDepth();
+        this.paths = definition.isPaths();
+        this.regexp = definition.isRegexp();
+        this.skin = definition.getSkin();
+        this.profile = definition.getProfile();
+        this.order = definition.getOrder();
+        this.title = definition.getTitle();
+        this.shortTitle = definition.getShortTitle();
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * @param name
+     *            the name to set
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * @return the options
+     */
+    public String getOptions()
+    {
+        return options;
+    }
+
+    /**
+     * @param options
+     *            the options to set
+     */
+    public void setOptions(String options)
+    {
+        this.options = options;
+    }
+
+    /**
+     * @return the depth
+     */
+    public int getDepth()
+    {
+        return depth;
+    }
+
+    /**
+     * @param depth
+     *            the depth to set
+     */
+    public void setDepth(int depth)
+    {
+        this.depth = depth;
+    }
+
+    /**
+     * @return the paths
+     */
+    public boolean isPaths()
+    {
+        return paths;
+    }
+
+    /**
+     * @param paths
+     *            the paths to set
+     */
+    public void setPaths(boolean paths)
+    {
+        this.paths = paths;
+    }
+
+    /**
+     * @return the regexp
+     */
+    public boolean isRegexp()
+    {
+        return regexp;
+    }
+
+    /**
+     * @param regexp
+     *            the regexp to set
+     */
+    public void setRegexp(boolean regexp)
+    {
+        this.regexp = regexp;
+    }
+
+    /**
+     * @return the profile
+     */
+    public String getProfile()
+    {
+        return profile;
+    }
+
+    /**
+     * @param profile
+     *            the profile to set
+     */
+    public void setProfile(String profile)
+    {
+        this.profile = profile;
+    }
+
+    /**
+     * @return the order
+     */
+    public String getOrder()
+    {
+        return order;
+    }
+
+    /**
+     * @param order
+     *            the order to set
+     */
+    public void setOrder(String order)
+    {
+        this.order = order;
+    }
+
+    /**
+     * @return the skin
+     */
+    public String getSkin()
+    {
+        return skin;
+    }
+
+    /**
+     * @param skin
+     *            the skin to set
+     */
+    public void setSkin(String skin)
+    {
+        this.skin = skin;
+    }
+
+    /**
+     * @return the title
+     */
+    public String getTitle()
+    {
+        return title;
+    }
+
+    /**
+     * @param title
+     *            the title to set
+     */
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+    /**
+     * @return the shortTitle
+     */
+    public String getShortTitle()
+    {
+        return shortTitle;
+    }
+
+    /**
+     * @param shortTitle
+     *            the shortTitle to set
+     */
+    public void setShortTitle(String shortTitle)
+    {
+        this.shortTitle = shortTitle;
+    }
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/JetspeedMenuDefinition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/OptionsDefinitionBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/OptionsDefinitionBean.java?rev=777460&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/OptionsDefinitionBean.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/OptionsDefinitionBean.java Fri May 22 10:39:47 2009
@@ -0,0 +1,171 @@
+/*
+ * 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.portlets.site.Model;
+
+import java.io.Serializable;
+
+import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
+
+/**
+ * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
+ * @version $Id$
+ */
+public class OptionsDefinitionBean implements Serializable
+{
+    private String options;
+    private int depth;
+    private boolean paths;
+    private boolean regexp;
+    private String profile;
+    private String order;
+    private String skin;
+
+    public OptionsDefinitionBean()
+    {
+        
+    }
+    public OptionsDefinitionBean(MenuOptionsDefinition definition)
+    {
+        this.options = definition.getOptions();
+        this.depth = definition.getDepth();
+        this.paths = definition.isPaths();
+        this.regexp = definition.isRegexp();
+        this.skin = definition.getSkin();
+        this.profile = definition.getProfile();
+        this.order = definition.getOrder();
+
+    }
+
+    /**
+     * @return the options
+     */
+    public String getOptions()
+    {
+        return options;
+    }
+
+    /**
+     * @param options
+     *            the options to set
+     */
+    public void setOptions(String options)
+    {
+        this.options = options;
+    }
+
+    /**
+     * @return the depth
+     */
+    public int getDepth()
+    {
+        return depth;
+    }
+
+    /**
+     * @param depth
+     *            the depth to set
+     */
+    public void setDepth(int depth)
+    {
+        this.depth = depth;
+    }
+
+    /**
+     * @return the paths
+     */
+    public boolean isPaths()
+    {
+        return paths;
+    }
+
+    /**
+     * @param paths
+     *            the paths to set
+     */
+    public void setPaths(boolean paths)
+    {
+        this.paths = paths;
+    }
+
+    /**
+     * @return the regexp
+     */
+    public boolean isRegexp()
+    {
+        return regexp;
+    }
+
+    /**
+     * @param regexp
+     *            the regexp to set
+     */
+    public void setRegexp(boolean regexp)
+    {
+        this.regexp = regexp;
+    }
+
+    /**
+     * @return the profile
+     */
+    public String getProfile()
+    {
+        return profile;
+    }
+
+    /**
+     * @param profile
+     *            the profile to set
+     */
+    public void setProfile(String profile)
+    {
+        this.profile = profile;
+    }
+
+    /**
+     * @return the order
+     */
+    public String getOrder()
+    {
+        return order;
+    }
+
+    /**
+     * @param order
+     *            the order to set
+     */
+    public void setOrder(String order)
+    {
+        this.order = order;
+    }
+
+    /**
+     * @return the skin
+     */
+    public String getSkin()
+    {
+        return skin;
+    }
+
+    /**
+     * @param skin
+     *            the skin to set
+     */
+    public void setSkin(String skin)
+    {
+        this.skin = skin;
+    }
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/OptionsDefinitionBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/SeparatorDefinitionBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/SeparatorDefinitionBean.java?rev=777460&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/SeparatorDefinitionBean.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/SeparatorDefinitionBean.java Fri May 22 10:39:47 2009
@@ -0,0 +1,70 @@
+/*
+ * 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.portlets.site.Model;
+
+import java.io.Serializable;
+
+import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
+
+/**
+ * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
+ * @version $Id$
+ */
+public class SeparatorDefinitionBean implements Serializable
+{
+    private String text;
+    private String title;
+    
+    public SeparatorDefinitionBean()
+    {
+        
+    }
+    public SeparatorDefinitionBean(MenuSeparatorDefinition separatorDefinition)
+    {
+        this.text = separatorDefinition.getText();
+        this.title = separatorDefinition.getTitle();
+    }
+    /**
+     * @return the text
+     */
+    public String getText()
+    {
+        return text;
+    }
+    /**
+     * @param text the text to set
+     */
+    public void setText(String text)
+    {
+        this.text = text;
+    }
+    /**
+     * @return the title
+     */
+    public String getTitle()
+    {
+        return title;
+    }
+    /**
+     * @param title the title to set
+     */
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+    
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/Model/SeparatorDefinitionBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java?rev=777460&r1=777459&r2=777460&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java Fri May 22 10:39:47 2009
@@ -36,7 +36,6 @@
 import java.util.zip.ZipFile;
 
 import javax.portlet.PortletRequest;
-import javax.portlet.RenderRequest;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeModel;
@@ -70,6 +69,11 @@
 import org.apache.jetspeed.page.document.UnsupportedDocumentTypeException;
 import org.apache.jetspeed.portalsite.MenuElement;
 import org.apache.jetspeed.portlets.AdminPortletWebPage;
+import org.apache.jetspeed.portlets.site.Model.ExcludesDefinitionBean;
+import org.apache.jetspeed.portlets.site.Model.IncludesDefinitionBean;
+import org.apache.jetspeed.portlets.site.Model.JetspeedMenuDefinition;
+import org.apache.jetspeed.portlets.site.Model.OptionsDefinitionBean;
+import org.apache.jetspeed.portlets.site.Model.SeparatorDefinitionBean;
 import org.apache.jetspeed.portlets.site.SiteTreeNode.FileType;
 import org.apache.jetspeed.portlets.wicket.AbstractAdminWebApplication;
 import org.apache.jetspeed.portlets.wicket.component.DynamicResourceLink;
@@ -173,10 +177,11 @@
 
     private final static String EXCLUDES = "excludes";
 
-    private final static String FOLDER_NODE_TYPE = "folder";
-
-    private final static String PAGE_NODE_TYPE = "page";
+    public final static String FOLDER_NODE_TYPE = "folder";
 
+    public final static String PAGE_NODE_TYPE = "page";
+    
+    public final static String LINK_NODE_TYPE = "link";
     List<ITab> menuTabs = new ArrayList<ITab>();
 
     private List menuOptions = new ArrayList();
@@ -812,12 +817,12 @@
 
         private static final long serialVersionUID = -3223669376958653554L;
 
-        private MenuOptionsDefinition optionsDefinition;
+        private OptionsDefinitionBean  optionsDefinition;
 
         /**
          * @return the optionsDefinition
          */
-        public MenuOptionsDefinition getOptionsDefinition()
+        public OptionsDefinitionBean getOptionsDefinition()
         {
             return optionsDefinition;
         }
@@ -826,19 +831,16 @@
          * @param optionsDefinition
          *            the optionsDefinition to set
          */
-        public void setOptionsDefinition(MenuOptionsDefinition optionsDefinition)
+        public void setOptionsDefinition(OptionsDefinitionBean optionsDefinition)
         {
             this.optionsDefinition = optionsDefinition;
         }
 
-        public OptionsWindow(String id, MenuDefinition definition,
-                MenuOptionsDefinition options, final WebMarkupContainer markUp)
+        public OptionsWindow(String id, MenuOptionsDefinition options, final WebMarkupContainer markUp)
         {
             super(id);
-            this.optionsDefinition = (MenuOptionsDefinition) copyMenuElement(
-                    getNodeType(), options);
-            final MenuOptionsDefinition optionDef = options;
-            final MenuDefinition def = definition;
+            final String name = options.getOptions();
+            this.optionsDefinition = new OptionsDefinitionBean(options);
             final Form menuform = new Form("menuForm");
             menuform.add(new TextField("optionsField", new PropertyModel(this,
                     "optionsDefinition.options")));
@@ -866,7 +868,7 @@
 
                 protected void onSubmit(AjaxRequestTarget target, Form menuform)
                 {
-                    menuActions(SAVE_ACTION, def, optionDef,
+                    menuActions(SAVE_ACTION,  name,
                             getOptionsDefinition());
                     ((ModalWindow) OptionsWindow.this.getParent())
                             .close(target);
@@ -880,14 +882,14 @@
     protected class MenuWindow extends WindowPanel
     {
 
-        private MenuDefinition menuDef;
+        private JetspeedMenuDefinition menuDef;
 
-        public MenuDefinition getMenuDef()
+        public JetspeedMenuDefinition getMenuDef()
         {
             return menuDef;
         }
 
-        public void setMenuDef(MenuDefinition menuDef)
+        public void setMenuDef(JetspeedMenuDefinition menuDef)
         {
             this.menuDef = menuDef;
         }
@@ -896,8 +898,7 @@
                 final AjaxTabbedPanel tabPanel)
         {
             super(id);
-            this.menuDef = (MenuDefinition) copyMenuElement(getNodeType(),
-                    definition);
+            this.menuDef = new JetspeedMenuDefinition(definition);
             final FeedbackPanel feedback = new FeedbackPanel("feedback");
             feedback.setOutputMarkupId(true);
             add(feedback);
@@ -944,11 +945,11 @@
                 @Override
                 protected void onSubmit(AjaxRequestTarget target, Form<?> form)
                 {
-                    menuActions(SAVE_ACTION, definition, getMenuDef());
+                    menuActions(SAVE_ACTION, definition.getName(), getMenuDef());
                     DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) menuTreeRoot
                             .getRoot();
                     DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(
-                            new MenuTreeNode(getMenuDef()));
+                            new MenuTreeNode(getMenuDef().getName(),document.getPath(),document.getType(),getServiceLocator()));
                     rootNode.insert(childNode, rootNode.getChildCount());
                     menuTree.getTreeState().expandNode(rootNode);
                     menuTree.getTreeState().selectNode(childNode, true);
@@ -975,12 +976,12 @@
 
         private static final long serialVersionUID = -3223669376958653554L;
 
-        private MenuIncludeDefinition includes;
+        private IncludesDefinitionBean includes;
 
         /**
          * @return the includes
          */
-        public MenuIncludeDefinition getIncludes()
+        public IncludesDefinitionBean getIncludes()
         {
             return includes;
         }
@@ -989,19 +990,17 @@
          * @param includes
          *            the includes to set
          */
-        public void setIncludes(MenuIncludeDefinition includes)
+        public void setIncludes(IncludesDefinitionBean includes)
         {
             this.includes = includes;
         }
 
-        public IncludesWindow(String id, MenuDefinition definition,
-                MenuIncludeDefinition includes, final WebMarkupContainer markUp)
+        public IncludesWindow(String id,MenuIncludeDefinition includes, final WebMarkupContainer markUp)
         {
             super(id);
-            this.includes = (MenuIncludeDefinition) copyMenuElement(
-                    getNodeType(), includes);
+            final String includesName = includes.getName(); 
+            this.includes = new IncludesDefinitionBean(includes);
             final MenuIncludeDefinition oldDef = includes;
-            final MenuDefinition menuDef = definition;
             final Form menuform = new Form("menuForm");
             menuform.add(new TextField("nameField", new PropertyModel(this,
                     "includes.name")));
@@ -1015,7 +1014,7 @@
                 @Override
                 protected void onSubmit(AjaxRequestTarget target, Form<?> form)
                 {
-                    menuActions(SAVE_ACTION, menuDef, oldDef, getIncludes());
+                    menuActions(SAVE_ACTION, includesName, getIncludes());
                     ((ModalWindow) IncludesWindow.this.getParent())
                             .close(target);
                     target.addComponent(markUp);
@@ -1030,12 +1029,12 @@
 
         private static final long serialVersionUID = -3223669376958653554L;
 
-        private MenuExcludeDefinition excludes;
+        private ExcludesDefinitionBean excludes;
 
         /**
          * @return the excludes
          */
-        public MenuExcludeDefinition getExcludes()
+        public ExcludesDefinitionBean getExcludes()
         {
             return excludes;
         }
@@ -1044,20 +1043,16 @@
          * @param excludes
          *            the excludes to set
          */
-        public void setExcludes(MenuExcludeDefinition excludes)
+        public void setExcludes(ExcludesDefinitionBean excludes)
         {
             this.excludes = excludes;
         }
-
-        public ExcludesWindow(String id, MenuDefinition definition,
-                MenuExcludeDefinition excludes, final WebMarkupContainer markUp)
+        
+        public ExcludesWindow(String id,MenuExcludeDefinition excludes, final WebMarkupContainer markUp)
         {
             super(id);
-            this.excludes = (MenuExcludeDefinition) copyMenuElement(
-                    getNodeType(), excludes);
-            ;
-            final MenuExcludeDefinition oldDef = excludes;
-            final MenuDefinition menuDef = definition;
+            final String excludeName = excludes.getName();
+            this.excludes = new ExcludesDefinitionBean(excludes);
             final Form menuform = new Form("menuForm");
             menuform.add(new Label("namelabel",new ResourceModel("common.name")));
             menuform.add(new TextField("nameField", new PropertyModel(this,
@@ -1068,7 +1063,7 @@
                 @Override
                 protected void onSubmit(AjaxRequestTarget target, Form<?> form)
                 {
-                    menuActions(SAVE_ACTION, menuDef, oldDef, getExcludes());
+                    menuActions(SAVE_ACTION,excludeName,getExcludes());
                     ((ModalWindow) ExcludesWindow.this.getParent())
                             .close(target);
                     target.addComponent(markUp);
@@ -1083,12 +1078,12 @@
 
         private static final long serialVersionUID = -3223669376958653554L;
 
-        private MenuSeparatorDefinition separator;
+        private  SeparatorDefinitionBean separator;
 
         /**
          * @return the constraintName
          */
-        public MenuSeparatorDefinition getSeparator()
+        public SeparatorDefinitionBean getSeparator()
         {
             return separator;
         }
@@ -1097,19 +1092,17 @@
          * @param constraintName
          *            the constraintName to set
          */
-        public void setSeparator(MenuSeparatorDefinition constraintName)
+        public void setSeparator(SeparatorDefinitionBean constraintName)
         {
             this.separator = constraintName;
         }
 
-        public SeparatorWindow(String id, final MenuDefinition definition,
-                MenuSeparatorDefinition separator,
+        public SeparatorWindow(String id, MenuSeparatorDefinition separator,
                 final WebMarkupContainer markUp)
         {
             super(id);
-            this.separator = (MenuSeparatorDefinition) copyMenuElement(
-                    getNodeType(), separator);
-            final MenuSeparatorDefinition sepDef = separator;
+            this.separator = new SeparatorDefinitionBean(separator);
+            final String textName = separator.getText();
             Form separatorForm = new Form("separatorDataForm");
             separatorForm.add(new TextField("separatorText", new PropertyModel(
                     this, "separator.text")));
@@ -1123,7 +1116,7 @@
                 @Override
                 protected void onSubmit(AjaxRequestTarget target, Form form)
                 {
-                    menuActions(SAVE_ACTION, definition, sepDef, getSeparator());
+                    menuActions(SAVE_ACTION,textName, getSeparator());
                     ((ModalWindow) SeparatorWindow.this.getParent())
                             .close(target);
                     target.addComponent(markUp);
@@ -1508,8 +1501,6 @@
     protected class MenuTabPanel extends BasePanel
     {
 
-        public MenuDefinition definition = null;
-
         public DefaultTreeModel getMenuTreeRoot()
         {
             return menuTreeRoot;
@@ -1520,7 +1511,7 @@
             super(id, document);
             ITab tab = null;
             DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("root");
-            rootNode.add(new DefaultMutableTreeNode(new MenuTreeNode("Menus")));
+            rootNode.add(new DefaultMutableTreeNode(new MenuTreeNode("Menus",null)));
             final ModalWindow metaDataModalWindow;
             add(metaDataModalWindow = new ModalWindow("modalwindow"));
             // Adding menu tree node
@@ -1538,12 +1529,15 @@
                 {
                     MenuTreeNode menuNode = (MenuTreeNode) ((DefaultMutableTreeNode) node)
                             .getUserObject();
-                    if (menuNode.getName() == null)
+                    if (menuNode.getName() != null)                        
                     {
-                        setMenuDefinition(menuNode.getDefinition());
-                        controlMenuTabs(true);
-                        menusTab.setSelectedTab(0);
-                        target.addComponent(menusTab);
+                        if (!menuNode.getName().equalsIgnoreCase("Menus"))
+                        {
+                            setMenuDefinition(menuNode.getDefinition());
+                            controlMenuTabs(true);
+                            menusTab.setSelectedTab(0);
+                            target.addComponent(menusTab);
+                        }
                     }
                 }
             };
@@ -1588,11 +1582,11 @@
                 @Override
                 protected void onSubmit(AjaxRequestTarget target, Form<?> form)
                 {
-                    menuActions(REMOVE_ACTION, getMenuDefinition(), null);
+                    menuActions(REMOVE_ACTION, getMenuDefinition().getName(), new JetspeedMenuDefinition());
                     DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) menuTreeRoot
                             .getRoot();
                     DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(
-                            new MenuTreeNode(getMenuDefinition()));
+                            new MenuTreeNode(getMenuDefinition().getName(),getServiceLocator()));
                     rootNode.remove(childNode);
                     menuTree.getTreeState().expandNode(rootNode);
                     menuTree.updateTree(target);
@@ -1614,17 +1608,13 @@
 
     protected class MenuInfoPanel extends MenuBasePanel
     {
-
-        private MenuDefinition menuDef;
-
-        MenuDefinition oldDef = null;
-
-        public MenuDefinition getMenuDef()
+        private JetspeedMenuDefinition menuDef; 
+        public JetspeedMenuDefinition getMenuDef()
         {
             return menuDef;
         }
 
-        public void setMenuDef(MenuDefinition menuDef)
+        public void setMenuDef(JetspeedMenuDefinition menuDef)
         {
             this.menuDef = menuDef;
         }
@@ -1633,9 +1623,9 @@
                 MenuDefinition definition)
         {
             super(id, document, definition);
-            oldDef = (MenuDefinition) copyMenuElement(getNodeType(), definition);
-            this.menuDef = (MenuDefinition) copyMenuElement(getNodeType(),
-                    definition);
+            final String menuDefinitionName = definition.getName();
+            setMenuDef(new JetspeedMenuDefinition((MenuDefinition) copyMenuElement(getNodeType(),
+                    definition)));
             final WebMarkupContainer ajaxPanel = new WebMarkupContainer(
                     "ajaxPanel");
             final FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
@@ -1674,9 +1664,7 @@
                 @Override
                 protected void onSubmit(AjaxRequestTarget target, Form<?> form)
                 {
-                    menuActions(SAVE_ACTION, oldDef, getMenuDef());
-                    oldDef = (MenuDefinition) copyMenuElement(getNodeType(),
-                            getMenuDef());
+                    menuActions(SAVE_ACTION, menuDefinitionName,getMenuDef());
                     target.addComponent(ajaxPanel);
                 }
 
@@ -1703,8 +1691,6 @@
             super(id, document, definition);
             final ModalWindow metaDataModalWindow;
             getMenuElements(definition, MenuElement.SEPARATOR_ELEMENT_TYPE);
-            final MenuDefinition def = (MenuDefinition) copyMenuElement(
-                    getNodeType(), definition);
             add(metaDataModalWindow = new ModalWindow("modalwindow"));
             final WebMarkupContainer ajaxPanel = new WebMarkupContainer(
                     "basePanel");
@@ -1728,8 +1714,7 @@
                         public void onClick(AjaxRequestTarget target)
                         {
                             metaDataModalWindow.setContent(new SeparatorWindow(
-                                    metaDataModalWindow.getContentId(), def,
-                                    separator, ajaxPanel));
+                                    metaDataModalWindow.getContentId(),separator, ajaxPanel));
                             metaDataModalWindow.show(target);
                         }
                     };
@@ -1741,7 +1726,7 @@
                         @Override
                         public void onClick(AjaxRequestTarget target)
                         {
-                            menuActions(REMOVE_ACTION, def, separator, null);
+                            menuActions(REMOVE_ACTION, separator.getText() ,new SeparatorDefinitionBean());
                             target.addComponent(ajaxPanel);
                         }                        
                     };
@@ -1770,8 +1755,7 @@
                                 .newPageMenuSeparatorDefinition();
                     }
                     metaDataModalWindow.setContent(new SeparatorWindow(
-                            metaDataModalWindow.getContentId(), def,
-                            separatorDefinition, ajaxPanel));
+                            metaDataModalWindow.getContentId(), separatorDefinition, ajaxPanel));
                     metaDataModalWindow.show(target);
                 }
             });
@@ -1788,8 +1772,6 @@
             super(id, document, definition);
             getMenuElements(definition, EXCLUDES);
             final ModalWindow metaDataModalWindow;
-            final MenuDefinition def = (MenuDefinition) copyMenuElement(
-                    getNodeType(), definition);
             add(metaDataModalWindow = new ModalWindow("modalwindow"));
             final WebMarkupContainer ajaxPanel = new WebMarkupContainer(
                     "basePanel");
@@ -1811,8 +1793,7 @@
                         public void onClick(AjaxRequestTarget target)
                         {
                             metaDataModalWindow.setContent(new ExcludesWindow(
-                                    metaDataModalWindow.getContentId(), def,
-                                    option, ajaxPanel));
+                                    metaDataModalWindow.getContentId(),option, ajaxPanel));
                             metaDataModalWindow.show(target);
                         }
                     };
@@ -1823,7 +1804,7 @@
                         @Override
                         public void onClick(AjaxRequestTarget target)
                         {
-                            menuActions(REMOVE_ACTION, def, option, null);
+                            menuActions(REMOVE_ACTION,option.getName(), new ExcludesDefinitionBean());
                             target.addComponent(ajaxPanel);
                         }
                     };
@@ -1853,8 +1834,7 @@
                                 .newPageMenuExcludeDefinition();
                     }
                     metaDataModalWindow.setContent(new ExcludesWindow(
-                            metaDataModalWindow.getContentId(), def,
-                            excludeDefinition, ajaxPanel));
+                            metaDataModalWindow.getContentId(),excludeDefinition, ajaxPanel));
                     metaDataModalWindow.show(target);
                 }
             });
@@ -1872,8 +1852,6 @@
             getMenuElements(definition, INCLUDES);
             final ModalWindow metaDataModalWindow;
             add(metaDataModalWindow = new ModalWindow("modalwindow"));
-            final MenuDefinition def = (MenuDefinition) copyMenuElement(
-                    getNodeType(), definition);
             final WebMarkupContainer ajaxPanel = new WebMarkupContainer(
                     "basePanel");
             ajaxPanel.setOutputMarkupId(true);
@@ -1897,8 +1875,7 @@
                         public void onClick(AjaxRequestTarget target)
                         {
                             metaDataModalWindow.setContent(new IncludesWindow(
-                                    metaDataModalWindow.getContentId(), def,
-                                    option, ajaxPanel));
+                                    metaDataModalWindow.getContentId(),option, ajaxPanel));
                             metaDataModalWindow.show(target);
                         }
                     };
@@ -1910,7 +1887,7 @@
                         @Override
                         public void onClick(AjaxRequestTarget target)
                         {
-                            menuActions(REMOVE_ACTION, def, option, null);
+                            menuActions(REMOVE_ACTION,option.getName(),new IncludesDefinitionBean());
                             target.addComponent(ajaxPanel);
                         }
                     };
@@ -1938,7 +1915,7 @@
                                 .newPageMenuIncludeDefinition();
                     }
                     metaDataModalWindow.setContent(new IncludesWindow(
-                            metaDataModalWindow.getContentId(), def,
+                            metaDataModalWindow.getContentId(),
                             includeDefinition, ajaxPanel));
                     metaDataModalWindow.show(target);
                 }
@@ -1954,10 +1931,8 @@
                 MenuDefinition definition)
         {
             super(id, document, definition);
-            getMenuElements(definition, MenuElement.OPTION_ELEMENT_TYPE);
+            getMenuElements(getMenuDefinition(), MenuElement.OPTION_ELEMENT_TYPE);
             final ModalWindow metaDataModalWindow;
-            final MenuDefinition def = (MenuDefinition) copyMenuElement(
-                    getNodeType(), definition);
             add(metaDataModalWindow = new ModalWindow("modalwindow"));
             final WebMarkupContainer ajaxPanel = new WebMarkupContainer(
                     "basePanel");
@@ -1983,8 +1958,7 @@
                         public void onClick(AjaxRequestTarget target)
                         {
                             metaDataModalWindow.setContent(new OptionsWindow(
-                                    metaDataModalWindow.getContentId(), def,
-                                    option, ajaxPanel));
+                                    metaDataModalWindow.getContentId(),option, ajaxPanel));
                             metaDataModalWindow.show(target);
                             target.addComponent(ajaxPanel);
                         }
@@ -1995,7 +1969,7 @@
                         @Override
                         public void onClick(AjaxRequestTarget target)
                         {
-                            menuActions(REMOVE_ACTION, def, option, null);
+                            menuActions(REMOVE_ACTION,option.getOptions(), new OptionsDefinitionBean());
                             target.addComponent(ajaxPanel);
                         }
                     }.add(new JavascriptEventConfirmation("onclick",
@@ -2019,7 +1993,7 @@
                                 .newPageMenuOptionsDefinition();
                     }
                     metaDataModalWindow.setContent(new OptionsWindow(
-                            metaDataModalWindow.getContentId(), def,
+                            metaDataModalWindow.getContentId(),
                             optionDefinition, ajaxPanel));
                     metaDataModalWindow.show(target);
                 }
@@ -3757,7 +3731,7 @@
             }
             if (treeNode == null)
             {
-                treeNode = new DefaultMutableTreeNode(new MenuTreeNode("Menus"));
+                treeNode = new DefaultMutableTreeNode(new MenuTreeNode("Menus",null));
             }
         }
         return treeNode;
@@ -3850,7 +3824,7 @@
         while (menuItreator.hasNext())
         {
             definitaion = (MenuDefinition) menuItreator.next();
-            menu = new DefaultMutableTreeNode(new MenuTreeNode(definitaion));
+            menu = new DefaultMutableTreeNode(new MenuTreeNode(definitaion.getName(),document.getPath(),document.getType(),getServiceLocator()));
             menuNode.add(menu);
         }
     }
@@ -4034,22 +4008,24 @@
      */
     protected MenuDefinition getMenuDefinition()
     {
-        return this.menuDefinition;
-    }
-
+        return (MenuDefinition)getPortletRequest().getPortletSession().getAttribute("menuDefinition");
+    }    
     /**
      * @param menuDefinition
      *            the menuDefinition to set
      */
     protected void setMenuDefinition(MenuDefinition menuDefinition)
     {
-        this.menuDefinition = menuDefinition;
+            
+        getPortletRequest().getPortletSession().setAttribute("menuDefinition", menuDefinition);
     }
 
-    protected void menuActions(String action, MenuDefinition definition,
-            MenuOptionsDefinition oldElement, MenuOptionsDefinition newElement)
+    protected void menuActions(String action, String options,OptionsDefinitionBean element)
     {
         SiteTreeNode node = getUserSelectedNode();
+        MenuDefinition definition = getMenuDefinition();
+        MenuOptionsDefinition oldElement = getOptionsDefinition(options);
+        MenuOptionsDefinition newElement = getOptionsDefinition(element); 
         if (node.getDocType() == FileType.Folder)
         {
             Folder folder = getJetspeedFolder(node.getNodePath());
@@ -4091,12 +4067,15 @@
         getMenuElements(definition, MenuElement.OPTION_ELEMENT_TYPE);
     }
 
-    protected void menuActions(String action, MenuDefinition oldElement,
-            MenuDefinition newElement)
+    protected void menuActions(String action,String name, JetspeedMenuDefinition element)
     {
+        MenuDefinition oldElement = getDefinition(name);        
         SiteTreeNode node = getUserSelectedNode();
+        MenuDefinition newElement = getMenuDefinition(document.getType(),element);
+        newElement.getMenuElements().addAll(oldElement.getMenuElements());
         if (node.getDocType() == FileType.Folder)
         {
+            
             Folder folder = getJetspeedFolder(node.getNodePath());
             List menuList = folder.getMenuDefinitions();
             if (action.equals(SAVE_ACTION))
@@ -4133,11 +4112,12 @@
         setMenuDefinition(newElement);
     }
 
-    protected void menuActions(String action, MenuDefinition definition,
-            MenuSeparatorDefinition oldElement,
-            MenuSeparatorDefinition newElement)
+    protected void menuActions(String action,String name,SeparatorDefinitionBean element)
     {
         SiteTreeNode node = getUserSelectedNode();
+        MenuDefinition definition = getMenuDefinition();
+        MenuSeparatorDefinition oldElement = getSeparatorDefinition(element.getText());
+        MenuSeparatorDefinition newElement = getSeparatorDefinition(element); 
         if (node.getDocType() == FileType.Folder)
         {
             Folder folder = getJetspeedFolder(node.getNodePath());
@@ -4179,10 +4159,12 @@
         getMenuElements(definition, MenuElement.SEPARATOR_ELEMENT_TYPE);
     }
 
-    protected void menuActions(String action, MenuDefinition definition,
-            MenuIncludeDefinition oldElement, MenuIncludeDefinition newElement)
+    protected void menuActions(String action,String name,IncludesDefinitionBean element)
     {
         SiteTreeNode node = getUserSelectedNode();
+        MenuDefinition definition = getMenuDefinition();
+        MenuIncludeDefinition oldElement = getIncludesDefinition(name);
+        MenuIncludeDefinition newElement = getIncludesDefinition(element); 
         if (node.getDocType() == FileType.Folder)
         {
             Folder folder = getJetspeedFolder(node.getNodePath());
@@ -4224,10 +4206,12 @@
         getMenuElements(definition, INCLUDES);
     }
 
-    protected void menuActions(String action, MenuDefinition definition,
-            MenuExcludeDefinition oldElement, MenuExcludeDefinition newElement)
+    protected void menuActions(String action,String name,ExcludesDefinitionBean element)
     {
         SiteTreeNode node = getUserSelectedNode();
+        MenuDefinition definition = getMenuDefinition();
+        MenuExcludeDefinition oldElement = getExcludeDefinition(name);
+        MenuExcludeDefinition newElement = getExcludesDefinition(element);
         if (node.getDocType() == FileType.Folder)
         {
             Folder folder = getJetspeedFolder(node.getNodePath());
@@ -4549,4 +4533,220 @@
     {
         return menuTabs;
     }
-}
+    
+    private MenuOptionsDefinition getOptionsDefinition(String options)
+    {
+        List elements = getMenuDefinition().getMenuElements();
+        for(int index=0;index<elements.size();index++)
+        {
+            Object element = elements.get(index);
+            if(element instanceof MenuOptionsDefinition)
+            {
+                if(((MenuOptionsDefinition)element).getOptions().equals(options))
+                {
+                    return (MenuOptionsDefinition)element;
+                }
+            }
+        }
+        return null;
+    }
+    
+    private MenuSeparatorDefinition getSeparatorDefinition(String options)
+    {
+        List elements = getMenuDefinition().getMenuElements();
+        for(int index=0;index<elements.size();index++)
+        {
+            Object element = elements.get(index);
+            if(element instanceof MenuSeparatorDefinition)
+            {
+                if(((MenuSeparatorDefinition)element).getText().equals(options))
+                {
+                    return (MenuSeparatorDefinition)element;
+                }
+            }
+        }
+        return null;
+    }
+    
+    private MenuExcludeDefinition getExcludeDefinition(String options)
+    {
+        List elements = getMenuDefinition().getMenuElements();
+        for(int index=0;index<elements.size();index++)
+        {
+            Object element = elements.get(index);
+            if(element instanceof MenuExcludeDefinition)
+            {
+                if(((MenuExcludeDefinition)element).getName().equals(options))
+                {
+                    return (MenuExcludeDefinition)element;
+                }
+            }
+        }
+        return null;
+    }
+    
+    private MenuIncludeDefinition getIncludesDefinition(String options)
+    {
+        List elements = getMenuDefinition().getMenuElements();
+        for(int index=0;index<elements.size();index++)
+        {
+            Object element = elements.get(index);
+            if(element instanceof MenuIncludeDefinition)
+            {
+                if(((MenuIncludeDefinition)element).getName().equals(options))
+                {
+                    return (MenuIncludeDefinition)element;
+                }
+            }
+        }
+        return null;
+    }
+    
+    public MenuDefinition getDefinition(String name)
+    {
+        MenuDefinition definition = null;
+        boolean found = true;
+        try
+        {
+            if (document.getType().equals(PortalSiteManager.FOLDER_NODE_TYPE))
+            {
+                return getMenu(getServiceLocator().getPageManager().getFolder(document.getPath()).getMenuDefinitions(),name);
+            }
+            else if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
+            {
+                return getMenu(getServiceLocator().getPageManager().getPage(document.getPath()).getMenuDefinitions(),name);
+            }
+        }
+        catch (PageNotFoundException e)
+        {
+            found = false;
+        }
+        catch (FolderNotFoundException e)
+        {
+            found = false;
+        }
+        catch (InvalidFolderException e)
+        {
+            found = false;
+        }
+        catch (NodeException e)
+        {
+            found = false;
+        }
+        catch (Exception e)
+        {
+            found = false;
+        }
+        if (!found)
+        {
+            if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
+            {
+                definition = getServiceLocator().getPageManager().newPageMenuDefinition();
+            }
+            else if (document.getType().equals(PortalSiteManager.FOLDER_NODE_TYPE))
+            {
+                definition = getServiceLocator().getPageManager().newFolderMenuDefinition();
+            }
+        }
+        return definition;
+    }
+
+    private MenuDefinition getMenu(List menuDefinitions,String name)
+    {
+        for (int index = 0; index < menuDefinitions.size(); index++)
+        {
+            MenuDefinition definition = (MenuDefinition) menuDefinitions.get(index);
+            if (definition.getName().equals(name))
+            {
+                return definition;
+            }
+        }
+        if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
+        {
+            return getServiceLocator().getPageManager().newPageMenuDefinition();
+        }
+        return getServiceLocator().getPageManager().newFolderMenuDefinition();
+    }
+    
+    private MenuDefinition getMenuDefinition(String type,JetspeedMenuDefinition menuDefinition)
+    {        
+        MenuDefinition definition = null;
+        if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
+        {
+            definition =  getServiceLocator().getPageManager().newPageMenuDefinition();
+        }else{
+            definition = getServiceLocator().getPageManager().newFolderMenuDefinition();    
+        }
+        definition.setDepth(menuDefinition.getDepth());
+        definition.setName(menuDefinition.getName());
+        definition.setOptions(menuDefinition.getOptions());
+        definition.setOrder(menuDefinition.getOrder());
+        definition.setPaths(menuDefinition.isPaths());
+        definition.setRegexp(menuDefinition.isRegexp());
+        definition.setTitle(menuDefinition.getTitle());
+        definition.setShortTitle(menuDefinition.getShortTitle());
+        definition.setSkin(menuDefinition.getSkin());
+        definition.setProfile(menuDefinition.getProfile());        
+        return definition;
+    }
+    
+    private MenuSeparatorDefinition getSeparatorDefinition(SeparatorDefinitionBean separator)
+    {        
+        MenuSeparatorDefinition definition = null;
+        if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
+        {
+            definition =  getServiceLocator().getPageManager().newPageMenuSeparatorDefinition();
+        }else{
+            definition = getServiceLocator().getPageManager().newFolderMenuSeparatorDefinition();    
+        }
+        definition.setText(separator.getText());
+        definition.setTitle(separator.getTitle());
+        return definition;
+    }
+    
+    private MenuExcludeDefinition getExcludesDefinition(ExcludesDefinitionBean excludes)
+    {        
+        MenuExcludeDefinition definition = null;
+        if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
+        {
+            definition =  getServiceLocator().getPageManager().newPageMenuExcludeDefinition();
+        }else{
+            definition = getServiceLocator().getPageManager().newFolderMenuExcludeDefinition();    
+        }
+        definition.setName(excludes.getName());
+        return definition;
+    }
+    
+    private MenuIncludeDefinition getIncludesDefinition(IncludesDefinitionBean includes)
+    {        
+        MenuIncludeDefinition  definition = null;
+        if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
+        {
+            definition =  getServiceLocator().getPageManager().newPageMenuIncludeDefinition();
+        }else{
+            definition = getServiceLocator().getPageManager().newFolderMenuIncludeDefinition();    
+        }
+        definition.setName(includes.getName());
+        definition.setNest(includes.isNest());
+        return definition;
+    }
+    
+    private MenuOptionsDefinition getOptionsDefinition(OptionsDefinitionBean options)
+    {        
+        MenuOptionsDefinition definition = null;
+        if (document.getType().equals(PortalSiteManager.PAGE_NODE_TYPE))
+        {
+            definition =  getServiceLocator().getPageManager().newPageMenuOptionsDefinition();
+        }else{
+            definition = getServiceLocator().getPageManager().newFolderMenuOptionsDefinition();    
+        }
+        definition.setDepth(options.getDepth());
+        definition.setOptions(options.getOptions());
+        definition.setOrder(options.getOrder());
+        definition.setPaths(options.isPaths());
+        definition.setRegexp(options.isRegexp());
+        definition.setSkin(options.getSkin());
+        definition.setProfile(options.getProfile());          
+        return definition;
+    }
+}   



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