Author: trong.tran
Date: 2010-11-29 05:42:50 -0500 (Mon, 29 Nov 2010)
New Revision: 5345
Modified:
exo/portal/branches/standalone/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java
exo/portal/branches/standalone/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
exo/portal/branches/standalone/web/portal/src/main/webapp/WEB-INF/web.xml
exo/portal/branches/standalone/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/StandaloneAppRequestHandler.java
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIStandaloneAppContainer.java
Log:
Clean up code
Add unit test
Change a method signature in DataStorage
Modified:
exo/portal/branches/standalone/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java
===================================================================
---
exo/portal/branches/standalone/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java 2010-11-29
10:05:54 UTC (rev 5344)
+++
exo/portal/branches/standalone/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java 2010-11-29
10:42:50 UTC (rev 5345)
@@ -20,8 +20,6 @@
package org.exoplatform.dashboard.webui.component;
import org.exoplatform.portal.webui.application.UIGadget;
-import org.exoplatform.portal.webui.page.UIPage;
-import org.exoplatform.portal.webui.page.UIPageBody;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.web.application.ApplicationMessage;
@@ -35,8 +33,6 @@
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
-import javax.portlet.WindowState;
-
@ComponentConfigs({@ComponentConfig(template =
"classpath:groovy/dashboard/webui/component/UIDashboard.gtmpl", events = {
@EventConfig(listeners = UIDashboardContainer.MoveGadgetActionListener.class),
@EventConfig(listeners = UIDashboardContainer.AddNewGadgetActionListener.class),
Modified:
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
===================================================================
---
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java 2010-11-29
10:05:54 UTC (rev 5344)
+++
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java 2010-11-29
10:42:50 UTC (rev 5345)
@@ -19,10 +19,6 @@
package org.exoplatform.portal.config;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.portal.application.PortletPreferences;
@@ -36,6 +32,9 @@
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.pom.data.ModelChange;
+import java.util.Comparator;
+import java.util.List;
+
/**
* Created by The eXo Platform SAS
* Apr 19, 2007
@@ -147,14 +146,15 @@
*/
public List<String> getAllPortalNames() throws Exception;
+ //TODO Ideally we should define and return a site metadata object which contains a
site's information.
/**
- * Returns info on site holding workspace object specified by applicationStorageId
+ * Returns a String array that contains two elements. The first one is the site type
and the second one is site name. <br/>
*
* @param applicationStorageId
* @return
* @throws Exception
*/
- public Map<String, String> getSiteInfo(String applicationStorageId) throws
Exception;
+ public String[] getSiteInfo(String applicationStorageId) throws Exception;
public <S> Application<S> getApplicationModel(String applicationStorageId)
throws Exception;
}
\ No newline at end of file
Modified:
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
===================================================================
---
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2010-11-29
10:05:54 UTC (rev 5344)
+++
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2010-11-29
10:42:50 UTC (rev 5345)
@@ -18,14 +18,6 @@
*/
package org.exoplatform.portal.config;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.portal.application.PortletPreferences;
@@ -51,6 +43,13 @@
import org.exoplatform.portal.pom.data.PortalKey;
import org.exoplatform.services.listener.ListenerService;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
@@ -348,7 +347,7 @@
delegate.saveDashboard(dashboard.build());
}
- public Map<String, String> getSiteInfo(String applicationStorageId)
+ public String[] getSiteInfo(String applicationStorageId)
throws Exception {
// TODO Auto-generated method stub
return delegate.getSiteInfo(applicationStorageId);
Modified:
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
===================================================================
---
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java 2010-11-29
10:05:54 UTC (rev 5344)
+++
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java 2010-11-29
10:42:50 UTC (rev 5345)
@@ -19,13 +19,6 @@
package org.exoplatform.portal.pom.config;
-import java.io.ByteArrayInputStream;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
import org.exoplatform.commons.utils.IOUtil;
import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.container.configuration.ConfigurationManager;
@@ -39,6 +32,7 @@
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.PersistentApplicationState;
+import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.TransientApplicationState;
import org.exoplatform.portal.pom.config.tasks.DashboardTask;
import org.exoplatform.portal.pom.config.tasks.PageNavigationTask;
@@ -67,6 +61,13 @@
import org.jibx.runtime.IBindingFactory;
import org.jibx.runtime.impl.UnmarshallingContext;
+import java.io.ByteArrayInputStream;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
@@ -323,8 +324,7 @@
});
}
- @Override
- public Map<String, String> getSiteInfo(String workspaceObjectId)
+ public String[] getSiteInfo(String workspaceObjectId)
throws Exception {
POMSession session = pomMgr.getSession();
@@ -336,25 +336,25 @@
Site site = ((UIComponent)workspaceObject).getPage().getSite();
ObjectType<? extends Site> siteType = site.getObjectType();
- Map<String, String> returnedMap = new HashMap<String, String>();
+ String[] siteInfo = new String[2];
//Put the siteType on returned map
if(siteType == ObjectType.PORTAL_SITE)
{
- returnedMap.put("siteType", "portal");
+ siteInfo[0] = PortalConfig.PORTAL_TYPE;
}
else if(siteType == ObjectType.GROUP_SITE)
{
- returnedMap.put("siteType", "group");
+ siteInfo[0] = PortalConfig.GROUP_TYPE;
}else if(siteType == ObjectType.USER_SITE)
{
- returnedMap.put("siteType", "user");
+ siteInfo[0] = PortalConfig.USER_TYPE;
}
//Put the siteOwner on returned map
- returnedMap.put("siteOwner", site.getName());
+ siteInfo[1] = site.getName();
- return returnedMap;
+ return siteInfo;
}
throw new Exception("The provided ID is not associated with an
application");
Modified:
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java
===================================================================
---
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java 2010-11-29
10:05:54 UTC (rev 5344)
+++
exo/portal/branches/standalone/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java 2010-11-29
10:42:50 UTC (rev 5345)
@@ -108,7 +108,7 @@
public void save() throws Exception;
- public Map<String, String> getSiteInfo(String workspaceObjectId) throws
Exception;
+ public String[] getSiteInfo(String workspaceObjectId) throws Exception;
public <S> ApplicationData<S> getApplicationData(String
applicationStorageId) throws Exception;
Modified:
exo/portal/branches/standalone/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
---
exo/portal/branches/standalone/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-11-29
10:05:54 UTC (rev 5344)
+++
exo/portal/branches/standalone/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-11-29
10:42:50 UTC (rev 5345)
@@ -887,4 +887,43 @@
portletApp.setState(state);
return portletApp;
}
+
+ public void testGettingGadgetInDashboard() throws Exception
+ {
+ Page page = new Page();
+ page.setPageId("user::john::foo");
+ Application<Portlet> app = Application.createPortletApplication();
+ app.setState(new
TransientApplicationState<Portlet>("dashboard/DashboardPortlet"));
+ page.getChildren().add(app);
+ storage_.save(page);
+ page = storage_.getPage("user::john::foo");
+ String id = page.getChildren().get(0).getStorageId();
+
+ // Load the dashboard itself
+ Dashboard dashboard = storage_.loadDashboard(id);
+
+ // Put a gadget in one container
+ Container row0 = (Container)dashboard.getChildren().get(0);
+ Application<Gadget> gadgetApp = Application.createGadgetApplication();
+ gadgetApp.setState(new TransientApplicationState<Gadget>("foo"));
+ row0.getChildren().add(gadgetApp);
+
+ // Save the dashboard
+ storage_.saveDashboard(dashboard);
+
+ // Load again the persisted version
+ dashboard = storage_.loadDashboard(id);
+
+ row0 = (Container)dashboard.getChildren().get(0);
+ Application<Gadget> gadget =
(Application<Gadget>)row0.getChildren().get(0);
+ String storageId = gadget.getStorageId();
+
+ // Now get the gadget by StorageId
+ Application<Object> applicationModel =
storage_.getApplicationModel(storageId);
+ assertEquals(gadget.getId(), applicationModel.getId());
+
+ String[] siteInfo = storage_.getSiteInfo(storageId);
+ assertEquals(PortalConfig.USER_TYPE, siteInfo[0]);
+ assertEquals("john", siteInfo[1]);
+ }
}
Modified: exo/portal/branches/standalone/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- exo/portal/branches/standalone/web/portal/src/main/webapp/WEB-INF/web.xml 2010-11-29
10:05:54 UTC (rev 5344)
+++ exo/portal/branches/standalone/web/portal/src/main/webapp/WEB-INF/web.xml 2010-11-29
10:42:50 UTC (rev 5345)
@@ -287,7 +287,7 @@
</servlet-mapping>
<servlet-mapping>
<servlet-name>portal</servlet-name>
- <url-pattern>/StandaloneApplication/*</url-pattern>
+ <url-pattern>/standalone/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
@@ -303,6 +303,7 @@
<web-resource-collection>
<web-resource-name>user authentication</web-resource-name>
<url-pattern>/private/*</url-pattern>
+ <url-pattern>/standalone/*</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
</web-resource-collection>
@@ -327,20 +328,6 @@
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>user authentication</web-resource-name>
- <url-pattern>/StandaloneApplication/*</url-pattern>
- <http-method>POST</http-method>
- <http-method>GET</http-method>
- </web-resource-collection>
- <auth-constraint>
- <role-name>users</role-name>
- </auth-constraint>
- <user-data-constraint>
- <transport-guarantee>NONE</transport-guarantee>
- </user-data-constraint>
- </security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>gatein-domain</realm-name>
Modified:
exo/portal/branches/standalone/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl
===================================================================
---
exo/portal/branches/standalone/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl 2010-11-29
10:05:54 UTC (rev 5344)
+++
exo/portal/branches/standalone/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl 2010-11-29
10:42:50 UTC (rev 5345)
@@ -40,7 +40,7 @@
def serverName = portletRequest.getServerName();
def port = portletRequest.getServerPort();
def standaloneURL = scheme + "://" + serverName + ":" + port +
rcontext.getPortalContextPath();
- standaloneURL += "/StandaloneApplication/" + uicomponent.getStorageId();
+ standaloneURL += "/standalone/" + uicomponent.getStorageId();
def portletResponse = rcontext.getResponse();
standaloneURL = portletResponse.encodeURL(standaloneURL);
Modified:
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/StandaloneAppRequestHandler.java
===================================================================
---
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/StandaloneAppRequestHandler.java 2010-11-29
10:05:54 UTC (rev 5344)
+++
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/StandaloneAppRequestHandler.java 2010-11-29
10:42:50 UTC (rev 5345)
@@ -28,7 +28,7 @@
public class StandaloneAppRequestHandler extends PortalRequestHandler
{
- private String[] PATHS = {"/StandaloneApplication"};
+ private String[] PATHS = {"/standalone"};
public String[] getPath()
{
Modified:
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIStandaloneAppContainer.java
===================================================================
---
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIStandaloneAppContainer.java 2010-11-29
10:05:54 UTC (rev 5344)
+++
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIStandaloneAppContainer.java 2010-11-29
10:42:50 UTC (rev 5345)
@@ -69,7 +69,7 @@
}
DataStorage ds = getApplicationComponent(DataStorage.class);
- Map<String, String> siteInfo;
+ String[] siteInfo;
try
{
siteInfo = ds.getSiteInfo(storageId);
@@ -84,8 +84,8 @@
String siteOwner = null;
if (siteInfo != null)
{
- siteType = siteInfo.get("siteType");
- siteOwner = siteInfo.get("siteOwner");
+ siteType = siteInfo[0];
+ siteOwner = siteInfo[1];
}
ConversationState currentState = ConversationState.getCurrent();
if (PortalConfig.USER_TYPE.equals(siteType) &&
currentState.getIdentity().getUserId().equals(siteOwner))