portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r891885 - in /portals/jetspeed-2/portal/trunk: applications/jetspeed/src/main/webapp/jetui/engine/portal.js components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
Date Thu, 17 Dec 2009 20:44:20 GMT
Author: woonsan
Date: Thu Dec 17 20:44:20 2009
New Revision: 891885

URL: http://svn.apache.org/viewvc?rev=891885&view=rev
Log:
JS2-1084: Replacing old ajax api during portlet window moving by new rest api.

Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js?rev=891885&r1=891884&r2=891885&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
Thu Dec 17 20:44:20 2009
@@ -211,16 +211,6 @@
         }
     });
 	
-    var onMoveComplete = function(id, o, args) { 
-    	var id = id; // Transaction ID. 
-    	var data = o.responseText; // Response data.
-    	//Y.log("move result = " + data);
-    	var dataIn = Y.DataType.XML.parse(data),
-    		schema = {  resultListLocator: "status", resultFields: [{key:"status"}] },
-    		dataOut = Y.DataSchema.XML.apply(schema, dataIn);
-    	var widgetId = args[0];
-    };     
-    
     Y.DD.DDM.on('drag:end', function(e) {
         var drag = e.target;
         if (drag.target) {
@@ -241,16 +231,16 @@
         persistMove(drag.get('node'), e);
     });
     
-
-	 
-
+    var onMoveComplete = function(id, o, args) { 
+        var id = id; // Transaction ID. 
+        var data = o.responseText; // Response data.
+        Y.log("move result = " + data);
+        var windowId = args.complete[0];
+    };     
+    
     var persistMove = function(drag, e) {
-    	var uri = document.location.href;
-    	if (uri.indexOf("/portal") > -1)
-    		uri = uri.replace("/portal", "/ajaxapi");
-    	else
-    		uri = uri.replace("/ui", "/ajaxapi");
-    	var windowId =  drag.getAttribute('id');
+        var portal = JETUI_YUI.getPortalInstance();
+        var windowId =  drag.getAttribute('id');
         if (drag.data.get("toolbar") == false) {
         	var oldColumn = drag.data.get('column');
         	var oldRow = drag.data.get('row');        	
@@ -262,15 +252,27 @@
         		drag.data.set('column', parentColumn);
         	}
         	reallocateColumn(parentColumn);
-        	var uri = uri + "?action=moveabs&id=" + windowId + "&col=" + drag.data.get('column')
+ "&row=" + drag.data.get('row');
-            Y.on('io:complete', onMoveComplete, this, [windowId]); 
-            var request = Y.io(uri);         	            
+            var uri = portal.portalContextPath + "/services/pagelayout/fragment/" + windowId
+ "/pos/?_type=json";
+            uri += "&col=" + drag.data.get('column') + "&row=" + drag.data.get('row');
+            var config = {
+                    on: { complete: onMoveComplete },
+                    method: "PUT",
+                    headers: { "X-Portal-Path" : portal.portalPagePath },
+                    arguments: { complete: [ windowId ] }
+                };
+            var request = Y.io(uri, config);
         }    	
         else
         {
-        	var uri = uri + "?action=move&id=" + windowId + "&x=" + e.target.region.top
+ "&y=" + e.target.region.left;
-            Y.on('io:complete', onMoveComplete, this, [windowId]); 
-            var request = Y.io(uri);         	            
+            var uri = portal.portalContextPath + "/services/pagelayout/fragment/" + windowId
+ "/pos/?_type=json";
+            uri += "&x=" + e.target.region.top + "&y=" + e.target.region.left;
+            var config = {
+                    on: { complete: onMoveComplete },
+                    method: "PUT",
+                    headers: { "X-Portal-Path" : portal.portalPagePath },
+                    arguments: { complete: [ windowId ] }
+                };
+            var request = Y.io(uri, config);
         }
     };
 

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java?rev=891885&r1=891884&r2=891885&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
Thu Dec 17 20:44:20 2009
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.services.rest;
 
 import java.util.Comparator;
+import java.util.Iterator;
 import java.util.List;
 import java.util.SortedSet;
 import java.util.TreeSet;
@@ -346,9 +347,9 @@
                             pageLayoutComponent.updateRowColumn(contentFragment, destRow,
destColumn);
                             pageLayoutComponent.updateRowColumn(destFragment, row, column);
                         }
+                        
+                        break;
                     }
-                    
-                    break;
                 }
             }
             else if ("down".equals(direction))
@@ -361,9 +362,17 @@
                     {
                         SortedSet<ContentFragment> tailSet = set.tailSet(contentFragment);
                         
-                        if (!tailSet.isEmpty())
+                        if (tailSet.size() > 1)
                         {
-                            ContentFragment destFragment = tailSet.first();
+                            Iterator<ContentFragment> it = tailSet.iterator();
+                            ContentFragment tempFragment = it.next();
+                            
+                            if (!tempFragment.getId().equals(contentFragment.getId()))
+                            {
+                                throw new IllegalStateException("Tail set of the column fragment
set must start with the content fragment itself.");
+                            }
+                            
+                            ContentFragment destFragment = it.next();
                             int row = contentFragment.getLayoutRow();
                             int column = contentFragment.getLayoutColumn();
                             int destRow = destFragment.getLayoutRow();
@@ -371,9 +380,9 @@
                             pageLayoutComponent.updateRowColumn(contentFragment, destRow,
destColumn);
                             pageLayoutComponent.updateRowColumn(destFragment, row, column);
                         }
+                        
+                        break;
                     }
-                    
-                    break;
                 }
             }
             else
@@ -385,14 +394,67 @@
         {
             int row = NumberUtils.toInt(rowParam, -1);
             int col = NumberUtils.toInt(colParam, -1);
-
-            try
-            {
-                pageLayoutComponent.updateRowColumn(contentFragment, row, col);
-            }
-            catch (Exception e)
+            
+            if (row != -1 && col != -1 && (contentFragment.getLayoutRow()
!= row || contentFragment.getLayoutColumn() != col))
             {
-                throw new WebApplicationException(e);
+                try
+                {
+                    ContentFragment layoutFragment = null;
+                    
+                    if (!StringUtils.isBlank(layoutFragmentId))
+                    {
+                        layoutFragment = contentPage.getFragmentByFragmentId(layoutFragmentId);
+                        
+                        if (layoutFragment == null)
+                        {
+                            throw new WebApplicationException(new IllegalArgumentException("Layout
fragment not found with the specified id: " + layoutFragmentId));
+                        }
+                    }
+                    else
+                    {
+                        layoutFragment = getParentFragment(pageLayoutComponent.getUnlockedRootFragment(contentPage),
fragmentId);
+                        
+                        if (layoutFragment == null)
+                        {
+                            throw new WebApplicationException(new IllegalArgumentException("Layout
fragment not found for the fragment: " + fragmentId));
+                        }
+                    }
+                    
+                    int layoutColumnCount = getColumnCountOfLayoutFragment(layoutFragment);
+                    
+                    SortedSet<ContentFragment> [] fragmentSetArray = getSortedChildFragmentSetArray(layoutFragment,
layoutColumnCount);
+                    
+                    if (fragmentSetArray.length > col)
+                    {
+                        SortedSet<ContentFragment> set = fragmentSetArray[col];
+                        
+                        if (row >= set.size())
+                        {
+                            row = set.size();
+                        }
+                        
+                        pageLayoutComponent.updateRowColumn(contentFragment, row, col);
+                        
+                        SortedSet<ContentFragment> tailSet = set.tailSet(contentFragment);
+                        
+                        for (ContentFragment f : tailSet)
+                        {
+                            if (!f.getId().equals(contentFragment.getId()))
+                            {
+                                ++row;
+                                
+                                if (row != f.getLayoutRow())
+                                {
+                                    pageLayoutComponent.updateRowColumn(f, row, col);
+                                }
+                            }
+                        }
+                    }
+                }
+                catch (Exception e)
+                {
+                    throw new WebApplicationException(e);
+                }
             }
         }
         else



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