Author: trong.tran
Date: 2010-01-18 21:21:38 -0500 (Mon, 18 Jan 2010)
New Revision: 1352
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NoSuchDateException.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/StorageException.java
Removed:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/DataMissingException.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/bean/UIDataFeed.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIRepeater.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java
Log:
GTNPORTAL-273 Improve the code and add unit test for Data Storage services
Deleted:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/DataMissingException.java
===================================================================
---
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/DataMissingException.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/DataMissingException.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -1,52 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2009, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.exoplatform.commons.utils;
-
-public class DataMissingException extends RuntimeException
-{
-
- public DataMissingException()
- {
- // TODO Auto-generated constructor stub
- }
-
- public DataMissingException(String message)
- {
- super(message);
- // TODO Auto-generated constructor stub
- }
-
- public DataMissingException(Throwable cause)
- {
- super(cause);
- // TODO Auto-generated constructor stub
- }
-
- public DataMissingException(String message, Throwable cause)
- {
- super(message, cause);
- // TODO Auto-generated constructor stub
- }
-
-}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NoSuchDateException.java
(from rev 1347,
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/DataMissingException.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NoSuchDateException.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NoSuchDateException.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.exoplatform.portal.config;
+
+
+public class NoSuchDateException extends StorageException
+{
+ public NoSuchDateException()
+ {
+ }
+
+ public NoSuchDateException(String message)
+ {
+ super(message);
+ }
+
+ public NoSuchDateException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+}
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/StorageException.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/StorageException.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/StorageException.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -0,0 +1,22 @@
+package org.exoplatform.portal.config;
+
+/**
+ * @author <a href="mailto:trong.tran@exoplatform.com">Trong
Tran</a>
+ * @version $Revision$
+ */
+public class StorageException extends RuntimeException
+{
+ public StorageException()
+ {
+ }
+
+ public StorageException(String message)
+ {
+ super(message);
+ }
+
+ public StorageException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -24,8 +24,8 @@
import org.exoplatform.commons.chromattic.SessionContext;
import org.exoplatform.commons.chromattic.SynchronizationListener;
import org.exoplatform.commons.chromattic.SynchronizationStatus;
-import org.exoplatform.commons.utils.DataMissingException;
import org.exoplatform.portal.application.PortletPreferences;
+import org.exoplatform.portal.config.NoSuchDateException;
import org.exoplatform.portal.pom.data.Mapper;
import org.gatein.mop.api.Model;
import org.gatein.mop.api.content.Customization;
@@ -203,7 +203,7 @@
{
Customization<?> customization = getModel().findCustomizationById(id);
if (customization == null) {
- throw new DataMissingException("Can not find " + id);
+ throw new NoSuchDateException("Can not find " + id);
}
return customization;
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageTask.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageTask.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -19,7 +19,7 @@
package org.exoplatform.portal.pom.config.tasks;
-import org.exoplatform.commons.utils.DataMissingException;
+import org.exoplatform.portal.config.NoSuchDateException;
import org.exoplatform.portal.pom.config.POMTask;
import org.exoplatform.portal.pom.config.cache.DataAccessMode;
import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
@@ -112,7 +112,7 @@
Site srcSite = workspace.getSite(siteType, ownerId);
if (srcSite == null)
{
- throw new DataMissingException("Could not clone page " + name +
"from non existing site of type "
+ throw new NoSuchDateException("Could not clone page " + name +
"from non existing site of type "
+ ownerType + " with id " + ownerId);
}
else
@@ -125,7 +125,7 @@
//
if (srcPage == null)
{
- throw new DataMissingException("Could not clone non existing page "
+ name + " from site of type "
+ throw new NoSuchDateException("Could not clone non existing page "
+ name + " from site of type "
+ ownerType + " with id " + ownerId);
}
@@ -267,7 +267,7 @@
Site site = workspace.getSite(siteType, ownerId);
if (site == null)
{
- throw new DataMissingException("Could not remove page " + name +
"of non existing site of type "
+ throw new NoSuchDateException("Could not remove page " + name +
"of non existing site of type "
+ ownerType + " with id " + ownerId);
}
else
@@ -277,7 +277,7 @@
org.gatein.mop.api.workspace.Page page = pages.getChild(name);
if (page == null)
{
- throw new DataMissingException("Could not remove non existing page
" + name + " of site of type "
+ throw new NoSuchDateException("Could not remove non existing page
" + name + " of site of type "
+ ownerType + " with id " + ownerId);
}
page.destroy();
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -19,8 +19,8 @@
package org.exoplatform.portal.pom.config.tasks;
-import org.exoplatform.commons.utils.DataMissingException;
import org.exoplatform.portal.application.PortletPreferences;
+import org.exoplatform.portal.config.NoSuchDateException;
import org.exoplatform.portal.pom.config.cache.DataAccessMode;
import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
import org.exoplatform.portal.pom.data.Mapper;
@@ -80,7 +80,7 @@
Site site = workspace.getSite(type, key.getId());
if (site == null)
{
- throw new DataMissingException("Could not remove non existing portal
" + key.getId());
+ throw new NoSuchDateException("Could not remove non existing portal
" + key.getId());
}
else
{
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -19,7 +19,7 @@
package org.exoplatform.portal.pom.config.tasks;
-import org.exoplatform.commons.utils.DataMissingException;
+import org.exoplatform.portal.config.NoSuchDateException;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.config.POMTask;
import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
@@ -50,7 +50,7 @@
{
Customization<S> customization =
(Customization<S>)session.findCustomizationById(storageId);
if (customization == null) {
- throw new DataMissingException("Can not find " + storageId);
+ throw new NoSuchDateException("Can not find " + storageId);
}
return customization.getContentId();
}
@@ -136,7 +136,7 @@
Customization<S> customization =
(Customization<S>)session.findCustomizationById(storageId);
if (customization == null) {
- throw new DataMissingException("Can not find " + storageId);
+ throw new NoSuchDateException("Can not find " + storageId);
}
if (prefs != null)
{
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -19,7 +19,7 @@
package org.exoplatform.portal.pom.data;
-import org.exoplatform.commons.utils.DataMissingException;
+import org.exoplatform.portal.config.NoSuchDateException;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.model.ApplicationState;
import org.exoplatform.portal.config.model.ApplicationType;
@@ -398,7 +398,7 @@
private List<ComponentData> loadChildren(UIContainer src)
{
- if (src == null) throw new DataMissingException("Can not load
children");
+ if (src == null) throw new NoSuchDateException("Can not load children");
ArrayList<ComponentData> children = new
ArrayList<ComponentData>(src.size());
for (UIComponent component : src)
{
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -53,9 +53,6 @@
{
/** . */
- private final String testPortal = "testPortal";
-
- /** . */
private final String testPage = "portal::classic::testPage";
/** . */
@@ -128,10 +125,19 @@
PortalConfig portal = storage_.getPortalConfig("portal",
"test");
assertNotNull(portal);
- //
storage_.remove(portal);
- portal = storage_.getPortalConfig(testPortal);
- assertNull(portal);
+ assertNull(storage_.getPortalConfig("portal", "test"));
+
+ try
+ {
+ //Trying to remove non existing a portal config
+ storage_.remove(portal);
+ fail("was expecting a NoSuchDataException");
+ }
+ catch (NoSuchDateException e)
+ {
+
+ }
}
public void testCreatePage() throws Exception
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/bean/UIDataFeed.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/bean/UIDataFeed.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/bean/UIDataFeed.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -19,8 +19,8 @@
package org.exoplatform.webui.bean;
-import org.exoplatform.commons.utils.DataMissingException;
import org.exoplatform.commons.utils.PageList;
+import org.exoplatform.portal.config.NoSuchDateException;
/**
* Created by The eXo Platform SAS Author : liem.nguyen ncliam(a)gmail.com Jun 26,
@@ -33,10 +33,10 @@
/***
* Load data of next page. Throws DataMissingException when page's data is cannot
load
- * @throws DataMissingException
+ * @throws NoSuchDateException
* @throws Exception
*/
- public void feedNext() throws DataMissingException, Exception;
+ public void feedNext() throws NoSuchDateException, Exception;
public boolean hasNext();
}
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIRepeater.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIRepeater.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIRepeater.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -19,8 +19,8 @@
package org.exoplatform.webui.core;
-import org.exoplatform.commons.utils.DataMissingException;
import org.exoplatform.commons.utils.PageList;
+import org.exoplatform.portal.config.NoSuchDateException;
import org.exoplatform.util.ReflectionUtil;
import org.exoplatform.webui.bean.UIDataFeed;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -106,7 +106,7 @@
return method.invoke(bean, ReflectionUtil.EMPTY_ARGS);
}
- public void feedNext() throws DataMissingException, Exception
+ public void feedNext() throws NoSuchDateException, Exception
{
int page = datasource.getCurrentPage();
page++;
@@ -126,7 +126,7 @@
catch (Throwable e)
{
datasource.getPage(page--);
- throw new DataMissingException(e);
+ throw new NoSuchDateException(e);
}
}
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java 2010-01-18
14:04:19 UTC (rev 1351)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java 2010-01-19
02:21:38 UTC (rev 1352)
@@ -19,8 +19,8 @@
package org.exoplatform.webui.core;
-import org.exoplatform.commons.utils.DataMissingException;
import org.exoplatform.commons.utils.PageList;
+import org.exoplatform.portal.config.NoSuchDateException;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.bean.UIDataFeed;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -80,7 +80,7 @@
{
dataFeed.feedNext();
}
- catch (DataMissingException e)
+ catch (NoSuchDateException e)
{
// Update parent of virtual list to refresh
event.getRequestContext().addUIComponentToUpdateByAjax(virtualList.getParent());