portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smi...@apache.org
Subject svn commit: r477887 - in /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed: decoration/DecorationValve.java layout/ajax-xml/getactions.vm layout/ajax-xml/psml.vm layout/impl/GetPortletActionsAction.java
Date Tue, 21 Nov 2006 21:09:22 GMT
Author: smilek
Date: Tue Nov 21 13:09:19 2006
New Revision: 477887

URL: http://svn.apache.org/viewvc?view=rev&rev=477887
Log:
add supported page actions to getpage and getactions ajaxapi responses

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getactions.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/GetPortletActionsAction.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java?view=diff&rev=477887&r1=477886&r2=477887
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
Tue Nov 21 13:09:19 2006
@@ -122,10 +122,10 @@
 
         PageActionAccess pageActionAccess = (PageActionAccess)requestContext.getAttribute(PortalReservedParameters.PAGE_EDIT_ACCESS_ATTRIBUTE);
         
-        if ( fragments == null )
+        if ( fragments == null || fragments.size() == 0 )
         {
             ContentFragment rootFragment = page.getRootContentFragment();
-            initDepthFragments(requestContext, theme, rootFragment, pageActionAccess, isAjaxRequest);
+            initDepthFragments(requestContext, theme, rootFragment, pageActionAccess, isAjaxRequest,
fragments);
         }
         else
         {
@@ -185,19 +185,19 @@
      * @throws PortletEntityNotStoredException 
      * @throws FailedToRetrievePortletWindow 
      */
-    protected void initActionsForFragment(
-                        RequestContext requestContext, 
-                        ContentFragment fragment, 
-                        PageActionAccess pageActionAccess, 
-                        Decoration decoration,
-                        boolean isAjaxRequest) throws FailedToRetrievePortletWindow, PortletEntityNotStoredException
+    protected boolean initActionsForFragment(RequestContext requestContext, 
+                                             ContentFragment fragment, 
+                                             PageActionAccess pageActionAccess, 
+                                             Decoration decoration,
+                                             boolean isAjaxRequest) throws FailedToRetrievePortletWindow,
PortletEntityNotStoredException
     {
+        boolean fragmentSupportsActions = false;
         PortletWindow window = windowAccessor.getPortletWindow(fragment); 
         PortletDefinitionComposite portlet = (PortletDefinitionComposite) window.getPortletEntity().getPortletDefinition();
         
         if (null == portlet)
         {
-            return; // allow nothing
+            return fragmentSupportsActions; // allow nothing
         }
 
         List actions = Collections.EMPTY_LIST;
@@ -208,10 +208,12 @@
         
         if ( fragment.equals(requestContext.getPage().getRootFragment()) )
         {
+            fragmentSupportsActions = true;
             actions = getPageModes(requestContext, window, content, currentMode, currentState,
pageActionAccess, decoration, isAjaxRequest);
         }
         else if ( !Fragment.LAYOUT.equals(fragment.getType()) )
         {
+            fragmentSupportsActions = true;
             String fragmentId = fragment.getId();
             PortletApplication pa = (PortletApplication)window.getPortletEntity().getPortletDefinition().getPortletApplicationDefinition();
 
@@ -291,6 +293,8 @@
         }
         
         decoration.setActions( actions );
+        
+        return fragmentSupportsActions;
     }
     
     /**
@@ -308,8 +312,8 @@
      * @throws PortletEntityNotStoredException 
      */
     protected List getPageModes(RequestContext requestContext, PortletWindow window, ContentTypeSet
content, 
-                    PortletMode mode, WindowState state, PageActionAccess pageActionAccess,
Decoration decoration,
-                    boolean isAjaxRequest)
+                                PortletMode mode, WindowState state, PageActionAccess pageActionAccess,
Decoration decoration,
+                                boolean isAjaxRequest)
     {
         List pageModes = new ArrayList();
         
@@ -385,7 +389,8 @@
                                       Theme theme, 
                                       ContentFragment fragment, 
                                       PageActionAccess pageActionAccess,
-                                      boolean isAjaxRequest)
+                                      boolean isAjaxRequest,
+                                      List collectFragments )
     {
         final List contentFragments = fragment.getContentFragments();
         
@@ -395,29 +400,37 @@
             while(itr.hasNext())
             {
                 ContentFragment aFragment = (ContentFragment) itr.next();
-                initDepthFragments(requestContext, theme, aFragment, pageActionAccess, isAjaxRequest);
+                initDepthFragments(requestContext, theme, aFragment, pageActionAccess, isAjaxRequest,
collectFragments);
             }
         }
         
-        initFragment(requestContext, theme, fragment, pageActionAccess, isAjaxRequest);
+        if ( initFragment(requestContext, theme, fragment, pageActionAccess, isAjaxRequest)
)
+        {
+            if ( collectFragments != null )
+            {
+                collectFragments.add( fragment );
+            }
+        }
     }
 
-    protected void initFragment(RequestContext requestContext, 
-                                Theme theme, 
-                                ContentFragment fragment, 
-                                PageActionAccess pageActionAccess,
-                                boolean isAjaxRequest)
+    protected boolean initFragment(RequestContext requestContext, 
+                                   Theme theme, 
+                                   ContentFragment fragment, 
+                                   PageActionAccess pageActionAccess,
+                                   boolean isAjaxRequest)
     {
+        boolean fragmentSupportsActions = false;
         try
         {
             Decoration decoration = theme.getDecoration(fragment);
             fragment.setDecoration(decoration);
-            initActionsForFragment(requestContext, fragment, pageActionAccess, decoration,
isAjaxRequest);
+            fragmentSupportsActions = initActionsForFragment(requestContext, fragment, pageActionAccess,
decoration, isAjaxRequest);
         }
         catch (Exception e)
         {
             log.warn("Unable to initalize actions for fragment "+fragment.getId(), e);
         }
+        return fragmentSupportsActions;
     }
 
     

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getactions.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getactions.vm?view=diff&rev=477887&r1=477886&r2=477887
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getactions.vm
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/getactions.vm
Tue Nov 21 13:09:19 2006
@@ -2,8 +2,15 @@
     <status>$status</status>
     <action>$action</action>
     
+    #if ( $page )
+    <page>
+#foreach ($action in $page.decoration.actions)
+        <action id="${action.ActionName}" type="${action.ActionType}" name="${action.Name}"
url="${action.Action}"/>    
+#end
+    </page>
+    #end
     <portlets>
-#foreach ($portlet in $fragments)
+#foreach ($portlet in $portlets)
     <portlet id="$portlet.getId()">
 #foreach ($action in $portlet.decoration.actions)
         <action id="${action.ActionName}" type="${action.ActionType}" name="${action.Name}"
url="${action.Action}"/>    

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=477887&r1=477886&r2=477887
==============================================================================
--- 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 Nov 21 13:09:19 2006
@@ -49,6 +49,9 @@
 #foreach ($meta in $page.Metadata.Fields)
 	<metadata name="$meta.Name" xml:lang="$meta.Locale.Language">$meta.Value</metadata>
 #end
+#foreach ($action in $page.getRootContentFragment().decoration.actions)
+     <action id="${action.ActionName}" type="${action.ActionType}" name="${action.Name}"
url="${action.Action}"/>    
+#end
 
 #if ($fragments == "true")    
   #traverseFragments($page.RootFragment)

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPortletActionsAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPortletActionsAction.java?view=diff&rev=477887&r1=477886&r2=477887
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPortletActionsAction.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPortletActionsAction.java
Tue Nov 21 13:09:19 2006
@@ -93,46 +93,52 @@
         return runAction(requestContext, resultMap, false);
     }
     
-    public boolean runAction(RequestContext requestContext, Map resultMap, boolean batch)
+    public boolean runAction( RequestContext requestContext, Map resultMap, boolean batch
)
     {
         boolean success = true;
         String status = "success";
         try
         {
-            resultMap.put(ACTION, action);
-            // Get the necessary parameters off of the request
-            String[] portletIds = requestContext.getRequest().getParameterValues( PORTLETID
);
-            if (portletIds == null) 
-            { 
-                throw new Exception("no portlet id was provided"); 
-            }
+            resultMap.put( ACTION, action );
             
             ContentPage page = requestContext.getPage();
             
-            ArrayList portletFragments = new ArrayList();
-            for ( int i = 0 ; i < portletIds.length ; i++ )
+            // Get the necessary parameters off of the request
+            ArrayList getActionsForFragments = new ArrayList();
+            String[] portletIds = requestContext.getRequest().getParameterValues( PORTLETID
);
+            if ( portletIds != null && portletIds.length > 0 ) 
             {
-                String portletId = portletIds[ i ];
-                ContentFragment fragment = (ContentFragment)page.getFragmentById( portletId
);
-                if ( fragment == null )
+                for ( int i = 0 ; i < portletIds.length ; i++ )
                 {
-                    throw new Exception("fragment not found for specified portlet id: " +
portletId); 
+                    String portletId = portletIds[ i ];
+                    ContentFragment fragment = (ContentFragment)page.getFragmentById( portletId
);
+                    if ( fragment == null )
+                    {
+                        throw new Exception("fragment not found for specified portlet id:
" + portletId); 
+                    }
+                    getActionsForFragments.add( fragment );
                 }
-                portletFragments.add( fragment );
+                getActionsForFragments.add( page.getRootContentFragment() );
             }
 
             // Run the Decoration valve to get actions
-            decorationValve.initFragments( requestContext, true, portletFragments );
+            decorationValve.initFragments( requestContext, true, getActionsForFragments );
+            
+            if ( getActionsForFragments.size() > 0 )
+            {
+                Fragment rootFragment = (Fragment)getActionsForFragments.remove( getActionsForFragments.size()-1
);
+                resultMap.put( PAGE, rootFragment );
+            }
             
-            resultMap.put(FRAGMENTS, portletFragments);
+            resultMap.put( PORTLETS, getActionsForFragments );
             
-            resultMap.put(STATUS, status);
+            resultMap.put( STATUS, status );
         } 
         catch (Exception e)
         {
             // Log the exception
-            log.error("exception while moving a portlet", e);
-            resultMap.put(REASON, e.toString());
+            log.error( "exception while getting actions for a fragment", e );
+            resultMap.put( REASON, e.toString() );
             // Return a failure indicator
             success = false;
         }



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