portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r482816 - in /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed: ajax/ layout/ajax-xml/ layout/impl/
Date Tue, 05 Dec 2006 22:53:14 GMT
Author: taylor
Date: Tue Dec  5 14:53:13 2006
New Revision: 482816

URL: http://svn.apache.org/viewvc?view=rev&rev=482816
Log:
https://issues.apache.org/jira/browse/JS2-306
New implementation of Site Manager portlet

Added:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolderlist.vm
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseGetResourceAction.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseSiteUpdateAction.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderListAction.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateFolderAction.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateLinkAction.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdatePageAction.java
Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/error.vm
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolder.vm
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getlink.vm
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderAction.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetLinkAction.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/SecurityConstraintsAction.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java Tue Dec  5 14:53:13 2006
@@ -167,7 +167,18 @@
             RequestContext requestContext, boolean actionSuccessFlag)
     {
         // Response will always be text/xml
-        requestContext.getResponse().setContentType(CONTENT_TYPE);
+        String format = requestContext.getRequestParameter("format");
+        if (format == null)
+        {
+            requestContext.getResponse().setContentType(CONTENT_TYPE);
+        }
+        else
+        {
+            if (format.equals("json"))
+            {
+                requestContext.getResponse().setContentType("text/json");
+            }
+        }
 
         try
         {

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/error.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/error.vm?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/error.vm (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/error.vm Tue Dec  5 14:53:13 2006
@@ -1,6 +1,6 @@
 <js>
-    <status>$status</status>
-    <action>$action</action>
-	<reason>$reason</reason>
-    <id>$id</id>
+    <status>$!status</status>
+    <action>$!action</action>
+	    <reason>$!reason</reason>
+    <id>$!id</id>
 </js>

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolder.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolder.vm?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolder.vm (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolder.vm Tue Dec  5 14:53:13 2006
@@ -1,17 +1,40 @@
 <js>
     <status>$!status</status>
     <action>$!action</action>    
-    <folder>
-      <path>$!folder.Path</path>
+    <folder hidden="$!folder.isHidden()">
+    <defaults
+       layout-decorator='$!folder.getDefaultDecorator("layout")'
+       portlet-decorator='$!folder.getDefaultDecorator("portlet")'
+       theme='$!folder.Skin'
+     />    
       <name>$!folder.Name</name>
+      <path>$!folder.Path</path>      
       <url>$!folder.Url</url>
       <hidden>$!folder.isHidden()</hidden>
       <reserved>$!folder.isReserved()</reserved>
 		      <title>$!folder.Title</title>
-		      <shortTitle>$!folder.ShortTitle</shortTitle>		      
-		      <pageDecorator>$!folder.getDefaultDecorator("layout")</pageDecorator>
-		      <portletDecorator>$!folder.getDefaultDecorator("portlet")</portletDecorator>		      
-		      <defaultPage>$!folder.DefaultPage</defaultPage>
-		      <desktopTheme>$!folder.Skin</desktopTheme>
+		      <short-title>$!folder.ShortTitle</short-title>		      		      
+      <default-page>$!folder.DefaultPage</default-page>
+#foreach ($meta in $folder.Metadata.Fields)
+	<metadata name="$meta.Name" xml:lang="$meta.Locale.toString()">$!meta.Value</metadata>
+#end		      
+#if ($securityRefs)
+#foreach ($sec in $securityRefs)
+      	<security-ref>$sec</security-ref>
+#end
+#end
+#if ($securityOwner)
+      <security-owner>$securityOwner</security-owner>
+#end
+#if ($securityDefs)
+#foreach ($sec in $securityDefs)
+      	<security-def id="$velocityCount">
+      	   <permissions>$!sec.Permissions</permissions>
+      	   <roles>$!sec.Roles</roles>
+      	   <groups>$!sec.Groups</groups>
+      	   <users>$!sec.Users</users>      	   
+      	</security-def>
+#end  
+#end
     </folder>    
 </js>

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolderlist.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolderlist.vm?view=auto&rev=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolderlist.vm (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getfolderlist.vm Tue Dec  5 14:53:13 2006
@@ -0,0 +1,18 @@
+[
+#set ($fcount = 0)
+#foreach($f in $folders)    
+#if($fcount > 0),#end{isFolder: true, object: "Folder", widgetId: "$f.Path", title: "$f.Name", childIconSrc: "/j2-admin/images/folder.gif"}
+#set ($fcount = $fcount + 1)
+#end        
+#foreach($p in $pages)    
+#if($fcount > 0),#end{isFolder: false, object: "Page", widgetId: "$p.Path", title: "$p.Name", childIconSrc: "/j2-admin/images/page.gif"}
+#set ($fcount = $fcount + 1)
+#end        
+#foreach($l in $links)    
+#if($fcount > 0),#end{isFolder: false, object: "Link", widgetId: "$l.Path", title: "$l.Name", childIconSrc: "/j2-admin/images/link.gif"}
+#set ($fcount = $fcount + 1)
+#end        
+]
+
+ 
+ 
\ No newline at end of file

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getlink.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getlink.vm?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getlink.vm (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getlink.vm Tue Dec  5 14:53:13 2006
@@ -1,9 +1,34 @@
 <js>
     <status>$status</status>
     <action>$action</action>    
-    <link>
-      <path>$link.Path</path>
-		      <title>$link.Title</title>
-		      <shortTitle>$link.ShortTitle</shortTitle>		      
+    <link hidden="$!link.isHidden()">
+      <name>$!link.Name</name>
+      <path>$!link.Path</path>
+		      <title>$!link.Title</title>
+		      <short-title>$!link.ShortTitle</short-title>		      
+		      <url>$!link.Url</url>
+		      <target>$!link.Target</target>
+      <version>$!link.Version</version>
+#foreach ($meta in $link.Metadata.Fields)
+	      <metadata name="$meta.Name" xml:lang="$meta.Locale.toString()">$!meta.Value</metadata>
+#end
+#if ($securityRefs)
+#foreach ($sec in $securityRefs)
+      	<security-ref>$sec</security-ref>
+#end
+#end
+#if ($securityOwner)
+      <security-owner>$securityOwner</security-owner>
+#end
+#if ($securityDefs)
+#foreach ($sec in $securityDefs)
+      	<security-def id="$velocityCount">
+      	   <permissions>$!sec.Permissions</permissions>
+      	   <roles>$!sec.Roles</roles>
+      	   <groups>$!sec.Groups</groups>
+      	   <users>$!sec.Users</users>      	   
+      	</security-def>
+#end  
+#end
     </link>    
 </js>

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm Tue Dec  5 14:53:13 2006
@@ -26,8 +26,8 @@
 	#foreach ($action in $f.decoration.actions)
      <action id="${action.ActionName}" type="${action.ActionType}" name="${action.Name}" url="${action.Action}"/>    
 	#end
-	<mode>$f.decoration.getCurrentModeAction()</mode>
-	<state>$f.decoration.getCurrentStateAction()</state>
+	<mode>$!f.decoration.getCurrentModeAction()</mode>
+	<state>$!f.decoration.getCurrentStateAction()</state>
 	#if($portletIcons.get($f.Id))
     <icon>$portletIcons.get($f.Id)</icon>
     #end
@@ -41,16 +41,16 @@
     
 <page hidden='$page.Hidden'>
   <defaults
-     layout-decorator='$page.getDefaultDecorator("layout")'
-     portlet-decorator='$page.getDefaultDecorator("portlet")'
+     layout-decorator='$!page.getDefaultDecorator("layout")'
+     portlet-decorator='$!page.getDefaultDecorator("portlet")'
+     theme='$!page.Skin'     
   />
   <name>$page.Name</name>
   <path>$page.Path</path>
-  <title>$esc.xml($page.Title)</title>
-  <short-title>$esc.xml($page.ShortTitle)</short-title>
-  
+  <title>$esc.xml($!page.Title)</title>
+  <short-title>$esc.xml($!page.ShortTitle)</short-title>
 #foreach ($meta in $page.Metadata.Fields)
-	<metadata name="$meta.Name" xml:lang="$meta.Locale.Language">$meta.Value</metadata>
+	<metadata name="$meta.Name" xml:lang="$meta.Locale.toString()">$!meta.Value</metadata>
 #end
 #foreach ($action in $page.getRootContentFragment().decoration.actions)
      <action id="${action.ActionName}" type="${action.ActionType}" name="${action.Name}" url="${action.Action}"/>    
@@ -59,7 +59,24 @@
 #if ($fragments == "true")    
   #traverseFragments($page.RootFragment)
 #end
-  
+#if ($securityRefs)
+#foreach ($sec in $securityRefs)
+      	<security-ref>$sec</security-ref>
+#end
+#end
+#if ($securityOwner)
+      <security-owner>$securityOwner</security-owner>
+#end
+#if ($securityDefs)
+#foreach ($sec in $securityDefs)
+      	<security-def id="$velocityCount">
+      	   <permissions>$!sec.Permissions</permissions>
+      	   <roles>$!sec.Roles</roles>
+      	   <groups>$!sec.Groups</groups>
+      	   <users>$!sec.Users</users>      	   
+      	</security-def>
+#end  
+#end
 </page>    
 
 </js>

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseGetResourceAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseGetResourceAction.java?view=auto&rev=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseGetResourceAction.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseGetResourceAction.java Tue Dec  5 14:53:13 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.layout.impl;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.ajax.AjaxAction;
+import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.om.common.SecuredResource;
+import org.apache.jetspeed.page.PageManager;
+
+/**
+ * Abstract Get Resource aaction for folders, pages and links
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public abstract class BaseGetResourceAction
+    extends BasePortletAction 
+    implements AjaxAction, AjaxBuilder, Constants 
+{
+    protected Log log = LogFactory.getLog(BaseSiteUpdateAction.class);    
+    
+    public BaseGetResourceAction(String template, 
+            String errorTemplate, 
+            PageManager pageManager)
+    {
+        super(template, errorTemplate, pageManager);
+    }
+    
+    public BaseGetResourceAction(String template, 
+                             String errorTemplate, 
+                             PortletActionSecurityBehavior securityBehavior)
+    {
+        super(template, errorTemplate, securityBehavior);
+    }
+
+    public BaseGetResourceAction(String template, 
+                             String errorTemplate, 
+                             PageManager pageManager,
+                             PortletActionSecurityBehavior securityBehavior)
+    {
+        super(template, errorTemplate, pageManager, securityBehavior);        
+    }
+
+    protected void putSecurityInformation(Map resultMap, SecuredResource resource)
+    {
+        if (resource.getSecurityConstraints() != null)
+        {
+            resultMap.put(SECURITY_REFS, resource.getSecurityConstraints().getSecurityConstraintsRefs());
+            resultMap.put(SECURITY_DEFS, resource.getSecurityConstraints().getSecurityConstraints());
+            resultMap.put(SECURITY_OWNER, resource.getSecurityConstraints().getOwner());
+        }
+    }
+}

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java Tue Dec  5 14:53:13 2006
@@ -55,6 +55,16 @@
     }
 
     public BasePortletAction(String template, 
+            String errorTemplate, 
+            PageManager pageManager)
+    {
+        this.template = template;
+        this.errorTemplate = errorTemplate;
+        this.pageManager = pageManager;
+        this.securityBehavior = null;
+    }
+    
+    public BasePortletAction(String template, 
                              String errorTemplate, 
                              PageManager pageManager,
                              PortletActionSecurityBehavior securityBehavior)

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseSiteUpdateAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseSiteUpdateAction.java?view=auto&rev=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseSiteUpdateAction.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseSiteUpdateAction.java Tue Dec  5 14:53:13 2006
@@ -0,0 +1,323 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.layout.impl;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.ajax.AJAXException;
+import org.apache.jetspeed.ajax.AjaxAction;
+import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.om.common.LocalizedField;
+import org.apache.jetspeed.om.common.SecurityConstraints;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.Node;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Abstract Site update action for folders, pages and links
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public abstract class BaseSiteUpdateAction
+    extends BasePortletAction
+    implements AjaxAction, AjaxBuilder, Constants 
+{
+    protected Log log = LogFactory.getLog(BaseSiteUpdateAction.class);    
+    
+    public BaseSiteUpdateAction(String template, 
+            String errorTemplate, 
+            PageManager pageManager)
+    {
+        super(template, errorTemplate, pageManager);
+    }
+    
+    public BaseSiteUpdateAction(String template, 
+                             String errorTemplate, 
+                             PortletActionSecurityBehavior securityBehavior)
+    {
+        super(template, errorTemplate, securityBehavior);
+    }
+
+    public BaseSiteUpdateAction(String template, 
+                             String errorTemplate, 
+                             PageManager pageManager,
+                             PortletActionSecurityBehavior securityBehavior)
+    {
+        super(template, errorTemplate, pageManager, securityBehavior);        
+    }
+
+    protected abstract int updateInformation(RequestContext requestContext, Map resultMap, Node node, String path)
+    throws AJAXException;
+    
+    protected int insertMetadata(RequestContext requestContext, Map resultMap, Node node)
+    throws AJAXException
+    {
+        String name = getActionParameter(requestContext, "name");
+        String language = getActionParameter(requestContext, "lang");
+        String value = getActionParameter(requestContext, "value");
+        if (isBlank(name) || isBlank(language))
+            throw new AJAXException("Invalid Metadata: name, language invalid data.");
+        Locale locale = new Locale(language);
+        node.getMetadata().addField(locale, name, value);        
+        return 1;
+    }
+
+    protected int updateMetadata(RequestContext requestContext, Map resultMap, Node node)
+    throws AJAXException
+    {
+        String name = getActionParameter(requestContext, "name");
+        String language = getActionParameter(requestContext, "lang");
+        String value = getActionParameter(requestContext, "value");
+        String oldName = getActionParameter(requestContext, "oldname");
+        String oldLanguage = getActionParameter(requestContext, "oldlang");
+
+        if (isBlank(name) || isBlank(language) || isBlank(oldName) || isBlank(oldLanguage))
+            throw new AJAXException("Invalid Metadata: name, language invalid data.");
+                
+        Collection cfields = node.getMetadata().getFields(oldName);
+        if (cfields == null || cfields.size() == 0)
+        {
+            return insertMetadata(requestContext, resultMap, node);            
+        }
+        boolean found = false;
+        Iterator fields = cfields.iterator();
+        while (fields.hasNext())
+        {
+            LocalizedField field  = (LocalizedField)fields.next();
+            if (areFieldsSame(field.getName(), oldName) &&
+                areFieldsSame(field.getLocale().toString(), oldLanguage))
+            {
+                field.setName(name);
+                field.setLocale(new Locale(language));
+                field.setValue(value);
+                found = true;
+                break;
+            }
+        }
+        if (!found)
+            return insertMetadata(requestContext, resultMap, node);
+        return 1;
+    }
+    
+    protected int removeMetadata(RequestContext requestContext, Map resultMap, Node node)
+    throws AJAXException
+    {
+        String name = getActionParameter(requestContext, "name");
+        String language = getActionParameter(requestContext, "lang");
+        if (isBlank(name) || isBlank(language))
+            throw new AJAXException("Invalid Metadata: name, language invalid data.");
+        Collection cfields = node.getMetadata().getFields(name);
+        Collection allFields = node.getMetadata().getFields();
+        if (cfields == null || cfields.size() == 0)
+        {
+            return 0;            
+        }
+        boolean found = false;        
+        Iterator fields = cfields.iterator();
+        while (fields.hasNext())
+        {
+            LocalizedField field  = (LocalizedField)fields.next();
+            if (areFieldsSame(field.getName(), name) &&
+                areFieldsSame(field.getLocale().toString(), language))
+            {
+                cfields.remove(field);
+                if (allFields.remove(field))
+                {
+                    node.getMetadata().setFields(allFields);
+                }
+                found = true;
+                break;
+            }
+        }    
+        
+        return (found) ? 1 : 0;
+    }
+
+    protected int insertSecurityReference(RequestContext requestContext, Map resultMap, Node node)
+    throws AJAXException
+    {
+        String name = getActionParameter(requestContext, "name");
+        String kind = getActionParameter(requestContext, "kind");
+        if (isBlank(name) || isBlank(kind))
+            throw new AJAXException("Invalid Security Ref: name invalid data.");
+        if (node.getSecurityConstraints() == null)
+        {
+            SecurityConstraints cons = node.newSecurityConstraints();
+            node.setSecurityConstraints(cons);             
+        }
+        if (kind.equals("Owner"))
+        {
+            node.getSecurityConstraints().setOwner(name);
+        }
+        else
+        {
+            List refs = node.getSecurityConstraints().getSecurityConstraintsRefs();
+            if (refs.contains(name))
+                return 0; // do nothing
+            refs.add(name);
+        }
+        return 1;        
+    }
+
+    protected int updateSecurityReference(RequestContext requestContext, Map resultMap, Node node)
+    throws AJAXException
+    {
+        String name = getActionParameter(requestContext, "name");
+        String oldName = getActionParameter(requestContext, "oldname");
+        String kind = getActionParameter(requestContext, "kind");
+        if (isBlank(name) || isBlank(oldName) || isBlank(kind))
+            throw new AJAXException("Invalid Security Ref: name invalid data.");
+        if (node.getSecurityConstraints() == null)
+        {
+            SecurityConstraints cons = node.newSecurityConstraints();
+            node.setSecurityConstraints(cons);             
+        }                
+        List refs = node.getSecurityConstraints().getSecurityConstraintsRefs();        
+        if (refs == null || refs.size() == 0)
+        {
+            return insertSecurityReference(requestContext, resultMap, node);            
+        }
+        boolean found = false;
+        if (kind.equals("Owner"))
+        {
+            node.getSecurityConstraints().setOwner(name);
+            found = true;
+        }
+        else
+        {            
+            for (int ix = 0; ix < refs.size(); ix++)
+            {
+                String ref = (String)refs.get(ix);  
+                if (areFieldsSame(ref, oldName))
+                {
+                    refs.set(ix, name);
+                    found = true;
+                    break;
+                }
+            }
+        }
+        if (!found)
+            return insertSecurityReference(requestContext, resultMap, node);
+        return 1;
+    }
+    
+    protected int removeSecurityReference(RequestContext requestContext, Map resultMap, Node node)
+    throws AJAXException
+    {
+        String name = getActionParameter(requestContext, "name");
+        String kind = getActionParameter(requestContext, "kind");
+        if (isBlank(name) || isBlank(kind))
+            throw new AJAXException("Invalid Security Ref: name invalid data.");
+        if (node.getSecurityConstraints() == null)
+        {
+            return 0;
+        }
+        if (kind.equals("Owner"))
+        {
+            node.getSecurityConstraints().setOwner(null);
+        }
+        else
+        {
+            List refs = node.getSecurityConstraints().getSecurityConstraintsRefs();
+            if (!refs.contains(name))
+                return 0; // nothing to do
+            refs.remove(name);
+        }
+        return 1;
+    }
+
+    protected int removeSecurityDef(RequestContext requestContext, Map resultMap, Node node)
+    throws AJAXException
+    {
+        String id = getActionParameter(requestContext, "id");
+        if (isBlank(id))
+            throw new AJAXException("Invalid Security Ref: id invalid data.");
+        if (node.getSecurityConstraints() == null)
+        {
+            return 0;
+        }
+        List defs = node.getSecurityConstraints().getSecurityConstraints();
+        if (defs == null || defs.size() == 0)
+        {
+            return 0;
+        }
+        if (id.length() == 1)
+            return 0;
+        id = id.substring(1);
+        int index = Integer.parseInt(id) - 1;
+        if (index < 0)
+        {
+            return 0;
+        }
+        defs.remove(index);
+        return 1;
+    }
+    
+    protected boolean isBlank(String field)
+    {
+        if (field == null || field.trim().length() == 0)
+            return true;
+        return false;
+    }
+    protected boolean isFieldModified(String paramValue, String prevValue)
+    {
+        if (paramValue == null)
+        {
+            if (prevValue == null)
+                return false;
+            else
+                return true;
+        }
+        else
+        {
+            if (prevValue == null)
+                return true;
+            if (prevValue.equals(paramValue))
+                return false;
+            else
+                return true;
+        }
+    }
+    protected boolean areFieldsSame(String f1, String f2)
+    {
+        return !isFieldModified(f1, f2);
+    }
+    protected boolean isBooleanModified(String paramValue, boolean prevValue)
+    {
+        if (paramValue == null)
+        {
+            if (prevValue == false)
+                return false;
+            else
+                return true;
+        }
+        else
+        {
+            if (prevValue == false)
+                return true;
+            else
+                return false;
+        }
+    }        
+}

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java Tue Dec  5 14:53:13 2006
@@ -77,6 +77,10 @@
     public static final String FRAGMENTS = "fragments";
     public static final String TYPE = "type";
     public static final String FORMAT = "format";
+    public static final String METADATA = "metadata";
+    public static final String SECURITY_REFS = "securityRefs";
+    public static final String SECURITY_DEFS = "securityDefs";
+    public static final String SECURITY_OWNER = "securityOwner";
     
 	// Move types
 	public static final int ABS = 1;

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderAction.java?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderAction.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderAction.java Tue Dec  5 14:53:13 2006
@@ -23,6 +23,7 @@
 import org.apache.jetspeed.ajax.AjaxAction;
 import org.apache.jetspeed.ajax.AjaxBuilder;
 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.om.common.SecuredResource;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.request.RequestContext;
@@ -37,7 +38,7 @@
  * @version $Id: $
  */
 public class GetFolderAction 
-    extends BasePortletAction 
+    extends BaseGetResourceAction 
     implements AjaxAction, AjaxBuilder, Constants
 {
     protected Log log = LogFactory.getLog(GetFolderAction.class);
@@ -66,6 +67,7 @@
             Folder folder = retrieveFolder(requestContext);            
             resultMap.put(STATUS, status);
             resultMap.put(FOLDER, folder);
+            putSecurityInformation(resultMap, folder);
         } 
         catch (Exception e)
         {

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderListAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderListAction.java?view=auto&rev=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderListAction.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetFolderListAction.java Tue Dec  5 14:53:13 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.layout.impl;
+
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.ajax.AjaxAction;
+import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Get the immediate contents of a folder in JSON format 
+ *
+ * AJAX Parameters: 
+ *    folder: full path to the folder 
+ *    
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class GetFolderListAction 
+    extends BaseGetResourceAction 
+    implements AjaxAction, AjaxBuilder, Constants
+{
+    protected Log log = LogFactory.getLog(GetThemesAction.class);
+    
+    public GetFolderListAction(String template, 
+            String errorTemplate,
+            PageManager pageManager,
+            PortletActionSecurityBehavior securityBehavior)
+    {
+        super(template, errorTemplate, pageManager, securityBehavior);        
+    }
+
+    public boolean run(RequestContext requestContext, Map resultMap)
+    {
+        boolean success = true;
+        String status = "success";
+        try
+        {
+            resultMap.put(ACTION, "getfolderlist");
+            if (false == checkAccess(requestContext, JetspeedActions.VIEW))
+            {
+                    success = false;
+                    resultMap.put(REASON, "Insufficient access to get folderlist");
+                    return success;
+            }                     
+            String data = getActionParameter(requestContext, "data");
+            StringTokenizer tokenizer = new StringTokenizer(data, "[{:\"");
+            String folderName = null;            
+            while (tokenizer.hasMoreTokens())
+            {
+                String token = tokenizer.nextToken();
+                if (token.equals("widgetId"))
+                {
+                    folderName = tokenizer.nextToken();
+                    break;
+                }
+            }
+            String format = getActionParameter(requestContext, FORMAT);
+            if (format == null)
+                format = "json";
+            if (folderName == null)
+            {
+                success = false;
+                resultMap.put(REASON, "Folder name not found.");
+                return success;                
+            }
+            resultMap.put(FORMAT, format);
+            Folder folder = pageManager.getFolder(folderName);
+            resultMap.put(FOLDER, folder);
+            resultMap.put("folders", folder.getFolders().iterator());
+            resultMap.put("pages", folder.getPages().iterator());
+            resultMap.put("links", folder.getLinks().iterator());
+            resultMap.put(STATUS, status);            
+        } 
+        catch (Exception e)
+        {
+            // Log the exception
+            log.error("exception while getting theme info", e);
+            // Return a failure indicator
+            success = false;
+        }
+
+        return success;
+    }
+    
+    
+}

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetLinkAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetLinkAction.java?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetLinkAction.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetLinkAction.java Tue Dec  5 14:53:13 2006
@@ -38,7 +38,7 @@
  * @version $Id: $
  */
 public class GetLinkAction 
-    extends BasePortletAction 
+    extends BaseGetResourceAction 
     implements AjaxAction, AjaxBuilder, Constants
 {
     protected Log log = LogFactory.getLog(GetLinkAction.class);
@@ -65,14 +65,16 @@
                     return success;
             }                                    
             Link link = retrieveLink(requestContext);            
-            resultMap.put(STATUS, status);
+            resultMap.put(STATUS, status);            
             resultMap.put(LINK, link);
+            // resultMap.put(METADATA, link.getMetadata().getFields());
+            putSecurityInformation(resultMap, link);            
         } 
         catch (Exception e)
         {
             // Log the exception
             log.error("exception while getting link info", e);
-
+            resultMap.put(REASON, e.getMessage());
             // Return a failure indicator
             success = false;
         }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java Tue Dec  5 14:53:13 2006
@@ -47,7 +47,7 @@
  * @version $Id: $
  */
 public class GetPageAction 
-    extends BasePortletAction 
+    extends BaseGetResourceAction 
     implements AjaxAction, AjaxBuilder, Constants
 {
     protected Log log = LogFactory.getLog(GetPageAction.class);
@@ -93,6 +93,7 @@
             }
             resultMap.put(STATUS, status);
             resultMap.put(PAGE, page);
+            putSecurityInformation(resultMap, page);                        
             String fragments = getActionParameter(requestContext, FRAGMENTS);
             if (fragments == null)
             {

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/SecurityConstraintsAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/SecurityConstraintsAction.java?view=diff&rev=482816&r1=482815&r2=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/SecurityConstraintsAction.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/SecurityConstraintsAction.java Tue Dec  5 14:53:13 2006
@@ -53,14 +53,12 @@
     implements AjaxAction, AjaxBuilder, Constants
 {
     protected Log log = LogFactory.getLog(SecurityConstraintsAction.class);
-    protected PageManager pm = null;
 
     public SecurityConstraintsAction(String template, 
                                      String errorTemplate, 
                                      PageManager pm)
     {
-        super(template, errorTemplate, null); 
-        this.pm = pm;
+        super(template, errorTemplate, pm); 
     }
     
     public boolean run(RequestContext requestContext, Map resultMap)
@@ -128,7 +126,7 @@
         
         try
         {
-            PageSecurity pageSecurity = pm.getPageSecurity();        
+            PageSecurity pageSecurity = pageManager.getPageSecurity();        
             SecurityConstraintsDef def = pageSecurity.getSecurityConstraintsDef(name);
             if (def == null)
             {
@@ -137,7 +135,7 @@
             List defs = pageSecurity.getSecurityConstraintsDefs();
             defs.remove(def);
             pageSecurity.setSecurityConstraintsDefs(defs);
-            pm.updatePageSecurity(pageSecurity);
+            pageManager.updatePageSecurity(pageSecurity);
         }
         catch (Exception e)
         {
@@ -161,13 +159,12 @@
             Document document = saxBuilder.build(reader);
             Element root = document.getRootElement();
             String name = root.getAttribute("name").getValue();
-            System.out.println("name = " + name);
-            PageSecurity pageSecurity = pm.getPageSecurity();
+            PageSecurity pageSecurity = pageManager.getPageSecurity();
             SecurityConstraintsDef def = pageSecurity.getSecurityConstraintsDef(name);
             int defsSize = 0;
             if (def == null)
             {
-                def = pm.newSecurityConstraintsDef();
+                def = pageManager.newSecurityConstraintsDef();
                 def.setName(name);
                 added = true;
             }
@@ -210,7 +207,7 @@
                 for (int ix = min; ix < xmlSize; ix++)
                 {
                     Element xmlConstraint = (Element)xmlConstraints.get(ix);
-                    SecurityConstraint constraint =  pm.newPageSecuritySecurityConstraint();                    
+                    SecurityConstraint constraint =  pageManager.newPageSecuritySecurityConstraint();                    
                     updateConstraintValues(xmlConstraint, constraint);
                     constraints.add(constraint);                    
                     count++;
@@ -221,7 +218,7 @@
                 pageSecurity.getSecurityConstraintsDefs().add(def);
                 pageSecurity.setSecurityConstraintsDefs(pageSecurity.getSecurityConstraintsDefs());
             }
-            pm.updatePageSecurity(pageSecurity);
+            pageManager.updatePageSecurity(pageSecurity);
         }
         catch (Exception e)
         {
@@ -270,7 +267,7 @@
         
         try
         {
-            PageSecurity pageSecurity = pm.getPageSecurity();        
+            PageSecurity pageSecurity = pageManager.getPageSecurity();        
             List globals = pageSecurity.getGlobalSecurityConstraintsRefs();
             if (!globals.contains(name))
             {
@@ -278,7 +275,7 @@
             }
             globals.remove(name);
             pageSecurity.setGlobalSecurityConstraintsRefs(globals);
-            pm.updatePageSecurity(pageSecurity);
+            pageManager.updatePageSecurity(pageSecurity);
             count++;
         }
         catch (Exception e)
@@ -299,7 +296,7 @@
         
         try
         {
-            PageSecurity pageSecurity = pm.getPageSecurity();        
+            PageSecurity pageSecurity = pageManager.getPageSecurity();        
             List globals = pageSecurity.getGlobalSecurityConstraintsRefs();
             if (pageSecurity.getSecurityConstraintsDef(name) == null)
             {
@@ -312,7 +309,7 @@
             }
             globals.add(name);
             pageSecurity.setGlobalSecurityConstraintsRefs(globals);
-            pm.updatePageSecurity(pageSecurity);
+            pageManager.updatePageSecurity(pageSecurity);
             count++;
         }
         catch (Exception e)

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateFolderAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateFolderAction.java?view=auto&rev=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateFolderAction.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateFolderAction.java Tue Dec  5 14:53:13 2006
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.layout.impl;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.ajax.AJAXException;
+import org.apache.jetspeed.ajax.AjaxAction;
+import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.Node;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Update Folder action -- updates various parts of the PSML folder
+ * 
+ * AJAX Parameters: 
+ *    action = updatefolder
+ *    General methods:
+ *    method = add | remove 
+ *    Info methods:
+ *    | info 
+ *    Meta methods:
+ *    | add-meta | update-meta | remove-meta
+ *    Security methods:
+ *    | add-secref | remove-secref
+ *    
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: $
+ */
+public class UpdateFolderAction 
+    extends BaseSiteUpdateAction 
+    implements AjaxAction, AjaxBuilder, Constants
+{
+    protected Log log = LogFactory.getLog(UpdateFolderAction.class);
+
+    public UpdateFolderAction(String template, 
+                            String errorTemplate, 
+                            PageManager pm)
+    {
+        super(template, errorTemplate, pm); 
+    }
+    
+    public boolean run(RequestContext requestContext, Map resultMap)
+            throws AJAXException
+    {
+        boolean success = true;
+        String status = "success";
+        try
+        {
+            resultMap.put(ACTION, "updatefolder");
+            // Get the necessary parameters off of the request
+            String method = getActionParameter(requestContext, "method");
+            if (method == null) 
+            { 
+                throw new RuntimeException("Method not provided"); 
+            }            
+            resultMap.put("method", method);
+            if (false == checkAccess(requestContext, JetspeedActions.EDIT))
+            {
+                success = false;
+                resultMap.put(REASON, "Insufficient access to administer portal permissions");                
+                return success;
+            }           
+            int count = 0;
+            String path = getActionParameter(requestContext, "path");
+            if (path == null)
+                throw new AJAXException("Missing 'path' parameter");             
+            Folder folder = null; 
+            if (!method.equals("add"))
+            {
+                folder = pageManager.getFolder(path);
+            }       
+            else
+            {
+                if (pageManager.folderExists(path))
+                {
+                    success = false;
+                    resultMap.put(REASON, "Can't create: Folder already exists: " + path);                
+                    return success;                
+                }
+            }            
+            if (method.equals("info"))
+            {
+                count = updateInformation(requestContext, resultMap, folder, path);
+            }
+            else if (method.equals("add-meta"))
+            {
+                count = insertMetadata(requestContext, resultMap, folder);
+            }
+            else if ( method.equals("update-meta"))
+            {
+                count = updateMetadata(requestContext, resultMap, folder);
+            }
+            else if (method.equals("remove-meta"))
+            {
+                count = removeMetadata(requestContext, resultMap, folder);
+            }
+            else if (method.equals("update-secref"))
+            {
+                count = updateSecurityReference(requestContext, resultMap, folder);
+            }            
+            else if (method.equals("add-secref"))
+            {
+                count = insertSecurityReference(requestContext, resultMap, folder);
+            }
+            else if (method.equals("remove-secref"))
+            {
+                count = removeSecurityReference(requestContext, resultMap, folder);
+            }
+            else if (method.equals("remove-secdef"))
+            {
+                count = removeSecurityDef(requestContext, resultMap, folder);
+            }                        
+            else if (method.equals("add"))
+            {
+                folder = pageManager.newFolder(path);
+                folder.setTitle(getActionParameter(requestContext, "title"));
+                String s = getActionParameter(requestContext, "short-title");
+                if (!isBlank(s))
+                    folder.setShortTitle(s);
+                count++;                
+            }
+            else if (method.equals("remove"))
+            {
+                pageManager.removeFolder(folder);
+            }                        
+            else
+            {
+                success = false;
+                resultMap.put(REASON, "Unsupported Site Update method: " + method);                
+                return success;                
+            }
+            if (count > 0)
+            {
+                pageManager.updateFolder(folder);                
+            }
+            resultMap.put("count", Integer.toString(count));
+            resultMap.put(STATUS, status);
+        } 
+        catch (Exception e)
+        {
+            log.error("exception administering Site update", e);
+            resultMap.put(REASON, e.toString());
+            success = false;
+        }
+        return success;
+    }
+    
+    protected int updateInformation(RequestContext requestContext, Map resultMap, Node node, String path)
+    throws AJAXException    
+    {
+        int count = 0;
+        try
+        {
+            Folder folder = (Folder)node;            
+            String title = getActionParameter(requestContext, "title");
+            if (isFieldModified(title, folder.getTitle()))
+                folder.setTitle(title);
+            String shortTitle = getActionParameter(requestContext, "short-title");
+            if (isFieldModified(shortTitle, folder.getShortTitle()))
+                folder.setShortTitle(shortTitle);
+            String layoutDecorator = getActionParameter(requestContext, "layout-decorator");
+            if (isFieldModified(layoutDecorator, folder.getDefaultDecorator(Fragment.LAYOUT)))
+            {
+                if (isBlank(layoutDecorator))
+                    layoutDecorator = null;                 
+                folder.setDefaultDecorator(layoutDecorator, Fragment.LAYOUT);
+            }
+            String portletDecorator = getActionParameter(requestContext, "portlet-decorator");
+            if (isFieldModified(portletDecorator, folder.getDefaultDecorator(Fragment.PORTLET)))
+            {
+                if (isBlank(portletDecorator))
+                    portletDecorator = null;                 
+                folder.setDefaultDecorator(portletDecorator, Fragment.PORTLET);
+            }
+            String defaultPage = getActionParameter(requestContext, "default-page");
+            if (isFieldModified(defaultPage, folder.getDefaultPage()))
+                folder.setDefaultPage(defaultPage);                        
+            String hidden = getActionParameter(requestContext, "hidden");
+            if (isBooleanModified(hidden, folder.isHidden()))
+                folder.setHidden(!folder.isHidden());                                    
+            count++;
+        }
+        catch (Exception e)
+        {
+            throw new AJAXException(e);
+        }        
+        return count;
+    }
+    
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateLinkAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateLinkAction.java?view=auto&rev=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateLinkAction.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdateLinkAction.java Tue Dec  5 14:53:13 2006
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.layout.impl;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.ajax.AJAXException;
+import org.apache.jetspeed.ajax.AjaxAction;
+import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.Link;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.Node;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Update Link action -- updates various parts of the PSML link
+ * 
+ * AJAX Parameters: 
+ *    action = updatelink
+ *    General methods:
+ *    method = add | remove 
+ *    Info methods:
+ *    | info 
+ *    Meta methods:
+ *    | add-meta | update-meta | remove-meta
+ *    Security methods:
+ *    | add-secref | remove-secref
+ *    
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: $
+ */
+public class UpdateLinkAction 
+    extends BaseSiteUpdateAction 
+    implements AjaxAction, AjaxBuilder, Constants
+{
+    protected Log log = LogFactory.getLog(UpdateLinkAction.class);
+
+    public UpdateLinkAction(String template, 
+                            String errorTemplate, 
+                            PageManager pm)
+    {
+        super(template, errorTemplate, pm); 
+    }
+    
+    public boolean run(RequestContext requestContext, Map resultMap)
+            throws AJAXException
+    {
+        boolean success = true;
+        String status = "success";
+        try
+        {
+            resultMap.put(ACTION, "updatelink");
+            // Get the necessary parameters off of the request
+            String method = getActionParameter(requestContext, "method");
+            if (method == null) 
+            { 
+                throw new RuntimeException("Method not provided"); 
+            }            
+            resultMap.put("method", method);
+            if (false == checkAccess(requestContext, JetspeedActions.EDIT))
+            {
+                success = false;
+                resultMap.put(REASON, "Insufficient access to administer portal permissions");                
+                return success;
+            }           
+            int count = 0;
+            String path = getActionParameter(requestContext, "path");
+            if (path == null)
+                throw new AJAXException("Missing 'path' parameter");             
+            Link link = null; 
+            if (!method.equals("add"))
+            {
+                link = pageManager.getLink(path);                
+            }                        
+            else
+            {
+                if (pageManager.linkExists(path))
+                {
+                    success = false;
+                    resultMap.put(REASON, "Can't create: Link already exists: " + path);                
+                    return success;                
+                }
+            }
+            if (method.equals("info"))
+            {
+                count = updateInformation(requestContext, resultMap, link, path);
+            }
+            else if (method.equals("update-meta"))
+            {
+                count = updateMetadata(requestContext, resultMap, link);
+            }
+            else if (method.equals("add-meta"))
+            {
+                count = insertMetadata(requestContext, resultMap, link);
+            }
+            else if (method.equals("remove-meta"))
+            {
+                count = removeMetadata(requestContext, resultMap, link);
+            }
+            else if (method.equals("add-secref"))
+            {
+                count = insertSecurityReference(requestContext, resultMap, link);
+            }
+            else if (method.equals("update-secref"))
+            {
+                count = updateSecurityReference(requestContext, resultMap, link);
+            }                        
+            else if (method.equals("remove-secref"))
+            {
+                count = removeSecurityReference(requestContext, resultMap, link);
+            }
+            else if (method.equals("remove-secdef"))
+            {
+                count = removeSecurityDef(requestContext, resultMap, link);
+            }                        
+            else if (method.equals("add"))
+            {
+                link = pageManager.newLink(path);
+                link.setTitle(getActionParameter(requestContext, "title"));
+                String s = getActionParameter(requestContext, "short-title");
+                if (!isBlank(s))
+                    link.setShortTitle(s);
+                link.setUrl(getActionParameter(requestContext, "url"));
+                count++;
+            }
+            else if (method.equals("remove"))
+            {
+                pageManager.removeLink(link);
+            }                        
+            else
+            {
+                success = false;
+                resultMap.put(REASON, "Unsupported Site Update method: " + method);                
+                return success;                
+            }
+            if (count > 0)
+            {
+                pageManager.updateLink(link);                
+            }            
+            resultMap.put("count", Integer.toString(count));
+            resultMap.put(STATUS, status);
+        } 
+        catch (Exception e)
+        {
+            log.error("exception administering Site update", e);
+            resultMap.put(REASON, e.toString());
+            success = false;
+        }
+        return success;
+    }
+    
+    protected int updateInformation(RequestContext requestContext, Map resultMap, Node node, String path)
+    throws AJAXException    
+    {
+        int count = 0;
+        try
+        {
+            Link link = (Link)node;            
+            String title = getActionParameter(requestContext, "title");
+            if (isFieldModified(title, link.getTitle()))
+                link.setTitle(title);
+            String shortTitle = getActionParameter(requestContext, "short-title");
+            if (isFieldModified(shortTitle, link.getShortTitle()))
+                link.setShortTitle(shortTitle);
+            String url = getActionParameter(requestContext, "url");
+            if (isFieldModified(url, link.getUrl()))
+                link.setUrl(url);
+            String target = getActionParameter(requestContext, "target");
+            if (isFieldModified(target, link.getTarget()))
+                link.setTarget(target);                        
+            String hidden = getActionParameter(requestContext, "hidden");
+            if (isBooleanModified(hidden, link.isHidden()))
+                link.setHidden(!link.isHidden());                                    
+            count++;
+        }
+        catch (Exception e)
+        {
+            throw new AJAXException(e);
+        }        
+        return count;
+    }
+    
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdatePageAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdatePageAction.java?view=auto&rev=482816
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdatePageAction.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/UpdatePageAction.java Tue Dec  5 14:53:13 2006
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.layout.impl;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.ajax.AJAXException;
+import org.apache.jetspeed.ajax.AjaxAction;
+import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.Node;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Update Page action -- updates various parts of the PSML page
+ * 
+ * AJAX Parameters: 
+ *    action = updatepage
+ *    General methods:
+ *    method = add | remove 
+ *    Info methods:
+ *    | info 
+ *    Meta methods:
+ *    | add-meta | update-meta | remove-meta
+ *    Security methods:
+ *    | add-secref | remove-secref
+ *    
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: $
+ */
+public class UpdatePageAction 
+    extends BaseSiteUpdateAction 
+    implements AjaxAction, AjaxBuilder, Constants
+{
+    protected Log log = LogFactory.getLog(UpdatePageAction.class);
+
+    public UpdatePageAction(String template, 
+                            String errorTemplate, 
+                            PageManager pm)
+    {
+        super(template, errorTemplate, pm); 
+    }
+    
+    public boolean run(RequestContext requestContext, Map resultMap)
+            throws AJAXException
+    {
+        boolean success = true;
+        String status = "success";
+        try
+        {
+            resultMap.put(ACTION, "updatepage");
+            // Get the necessary parameters off of the request
+            String method = getActionParameter(requestContext, "method");
+            if (method == null) 
+            { 
+                throw new RuntimeException("Method not provided"); 
+            }            
+            resultMap.put("method", method);
+            if (false == checkAccess(requestContext, JetspeedActions.EDIT))
+            {
+                success = false;
+                resultMap.put(REASON, "Insufficient access to administer portal permissions");                
+                return success;
+            }           
+            int count = 0;
+            String path = getActionParameter(requestContext, "path");
+            if (path == null)
+                throw new AJAXException("Missing 'path' parameter");
+            Page page = null; 
+            if (!method.equals("add"))
+            {
+                page = pageManager.getPage(path);
+            }
+            else
+            {
+                if (pageManager.pageExists(path))
+                {
+                    success = false;
+                    resultMap.put(REASON, "Can't create: Page already exists: " + path);                
+                    return success;                
+                }
+            }                
+            if (method.equals("info"))
+            {
+                count = updateInformation(requestContext, resultMap, page, path);
+            }
+            else if (method.equals("add-meta"))
+            {
+                count = insertMetadata(requestContext, resultMap, page);
+            }
+            else if (method.equals("update-meta"))
+            {
+                count = updateMetadata(requestContext, resultMap, page);
+            }
+            else if (method.equals("remove-meta"))
+            {
+                count = removeMetadata(requestContext, resultMap, page);
+            }
+            else if (method.equals("add-secref"))
+            {
+                count = insertSecurityReference(requestContext, resultMap, page);
+            }
+            else if (method.equals("update-secref"))
+            {
+                count = updateSecurityReference(requestContext, resultMap, page);
+            }                        
+            else if (method.equals("remove-secref"))
+            {
+                count = removeSecurityReference(requestContext, resultMap, page);
+            }
+            else if (method.equals("remove-secdef"))
+            {
+                count = removeSecurityDef(requestContext, resultMap, page);
+            }            
+            else if (method.equals("add"))
+            {
+                page = pageManager.newPage(path);
+                page.setTitle(getActionParameter(requestContext, "title"));
+                String s = getActionParameter(requestContext, "short-title");
+                if (!isBlank(s))
+                    page.setShortTitle(s);                
+                page.getRootFragment().setName(getActionParameter(requestContext, "defaultLayout"));
+                count++;                
+            }
+            else if (method.equals("remove"))
+            {
+                pageManager.removePage(page);
+            }            
+            else
+            {
+                success = false;
+                resultMap.put(REASON, "Unsupported Site Update method: " + method);                
+                return success;                
+            }
+            if (count > 0)
+            {
+                pageManager.updatePage(page);                
+            }                        
+            resultMap.put("count", Integer.toString(count));
+            resultMap.put(STATUS, status);
+        } 
+        catch (Exception e)
+        {
+            log.error("exception administering Site update", e);
+            resultMap.put(REASON, e.toString());
+            success = false;
+        }
+        return success;
+    }
+    
+    protected int updateInformation(RequestContext requestContext, Map resultMap, Node node, String path)
+    throws AJAXException    
+    {
+        int count = 0;
+        try
+        {
+            Page page = (Page)node;            
+            String title = getActionParameter(requestContext, "title");
+            if (isFieldModified(title, page.getTitle()))
+                page.setTitle(title);
+            String shortTitle = getActionParameter(requestContext, "short-title");
+            if (isFieldModified(shortTitle, page.getShortTitle()))
+                page.setShortTitle(shortTitle);
+            String layoutDecorator = getActionParameter(requestContext, "layout-decorator");
+            if (isFieldModified(layoutDecorator, page.getDefaultDecorator(Fragment.LAYOUT)))
+            {
+                if (isBlank(layoutDecorator))
+                    layoutDecorator = null; 
+                page.setDefaultDecorator(layoutDecorator, Fragment.LAYOUT);
+            }
+            String portletDecorator = getActionParameter(requestContext, "portlet-decorator");
+            if (isFieldModified(portletDecorator, page.getDefaultDecorator(Fragment.PORTLET)))
+            {
+                if (isBlank(portletDecorator))
+                    portletDecorator = null;                 
+                page.setDefaultDecorator(portletDecorator, Fragment.PORTLET);
+            }
+            String theme = getActionParameter(requestContext, "theme");
+            if (isFieldModified(theme, page.getSkin()))
+            {
+                if (isBlank(theme))
+                    theme = null;                 
+                page.setSkin(theme);
+            }
+            String hidden = getActionParameter(requestContext, "hidden");
+            if (isBooleanModified(hidden, page.isHidden()))
+                page.setHidden(!page.isHidden());                                    
+            count++;
+        }
+        catch (Exception e)
+        {
+            throw new AJAXException(e);
+        }        
+        return count;
+    }
+    
+}



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