Author: julien_viet
Date: 2009-12-17 18:27:05 -0500 (Thu, 17 Dec 2009)
New Revision: 1053
Removed:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/AbstractPOMTask.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
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/POMSessionManager.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutionDecorator.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutor.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/DashboardTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageNavigationTask.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/PortletPreferencesTask.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/config/tasks/SearchTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestGadget.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestPortletPreferences.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestWSRP.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
Log:
simplify the task oriented pattern in the mop data storage
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -22,6 +22,7 @@
import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.portal.application.PortletPreferences;
import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.Dashboard;
import org.exoplatform.portal.pom.data.ModelChange;
@@ -98,7 +99,7 @@
public <S> String getId(ApplicationState<S> state) throws Exception;
- public <S> S load(ApplicationState<S> state) throws Exception;
+ public <S> S load(ApplicationState<S> state, ApplicationType<S>
type) throws Exception;
public <S> ApplicationState<S> save(ApplicationState<S> state, S
preferences) throws Exception;
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -22,6 +22,7 @@
import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.portal.application.PortletPreferences;
import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.Dashboard;
import org.exoplatform.portal.pom.data.ModelChange;
@@ -76,9 +77,9 @@
delegate.remove(page.build());
}
- public <S> S load(ApplicationState<S> state) throws Exception
+ public <S> S load(ApplicationState<S> state, ApplicationType<S>
type) throws Exception
{
- return delegate.load(state);
+ return delegate.load(state, type);
}
public void create(Page page) throws Exception
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/AbstractPOMTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/AbstractPOMTask.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/AbstractPOMTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -1,29 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.pom.config;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public abstract class AbstractPOMTask implements POMTask
-{
-
-}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -34,11 +34,11 @@
/** . */
private static final String[] padding = {" ", " ", "
", " "};
- public void execute(POMSession session, POMTask task) throws Exception
+ public <V> V execute(POMSession session, POMTask<V> task) throws
Exception
{
String s = task.toString();
long t0 = System.currentTimeMillis();
- session.execute(task);
+ V v = session.execute(task);
long t1 = System.currentTimeMillis();
String t = "" + (t1 - t0);
if (t.length() < 4)
@@ -50,5 +50,6 @@
{
log.debug("Executed in " + t + " " + s + "");
}
+ return v;
}
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -19,7 +19,6 @@
package org.exoplatform.portal.pom.config;
-import org.exoplatform.commons.chromattic.ChromatticManager;
import org.exoplatform.commons.utils.IOUtil;
import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.container.configuration.ConfigurationManager;
@@ -27,6 +26,7 @@
import org.exoplatform.portal.config.Query;
import org.exoplatform.portal.config.model.Application;
import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.CloneApplicationState;
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.ModelObject;
@@ -48,8 +48,6 @@
import org.exoplatform.portal.pom.data.PageKey;
import org.exoplatform.portal.pom.data.PortalData;
import org.exoplatform.portal.pom.data.PortalKey;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
import org.jibx.runtime.BindingDirectory;
import org.jibx.runtime.IBindingFactory;
import org.jibx.runtime.IUnmarshallingContext;
@@ -72,27 +70,15 @@
/** . */
private ConfigurationManager confManager_;
- /** . */
- private final Log log = ExoLogger.getLogger(getClass());
-
- /** . */
- private final ChromatticManager manager;
-
- public POMDataStorage(POMSessionManager pomMgr, ConfigurationManager confManager,
ChromatticManager manager)
+ public POMDataStorage(POMSessionManager pomMgr, ConfigurationManager confManager)
{
this.pomMgr = pomMgr;
this.confManager_ = confManager;
- this.manager = manager;
}
- public POMSessionManager getPOMSessionManager()
- {
- return pomMgr;
- }
-
public PortalData getPortalConfig(PortalKey key) throws Exception
{
- return pomMgr.execute(new PortalConfigTask.Load(key)).getConfig();
+ return pomMgr.execute(new PortalConfigTask.Load(key));
}
public void create(PortalData config) throws Exception
@@ -112,12 +98,12 @@
public PageData getPage(PageKey key) throws Exception
{
- return pomMgr.execute(new PageTask.Load(key)).getPage();
+ return pomMgr.execute(new PageTask.Load(key));
}
public PageData clonePage(PageKey key, PageKey cloneKey) throws Exception
{
- return pomMgr.execute(new PageTask.Clone(key, cloneKey, true)).getPage();
+ return pomMgr.execute(new PageTask.Clone(key, cloneKey, true));
}
public void remove(PageData page) throws Exception
@@ -132,12 +118,14 @@
public List<ModelChange> save(PageData page) throws Exception
{
- return pomMgr.execute(new PageTask.Save(page)).getChanges();
+ PageTask.Save task = new PageTask.Save(page);
+ pomMgr.execute(task);
+ return task.getChanges();
}
public NavigationData getPageNavigation(NavigationKey key) throws Exception
{
- return pomMgr.execute(new PageNavigationTask.Load(key)).getPageNavigation();
+ return pomMgr.execute(new PageNavigationTask.Load(key));
}
public void save(NavigationData navigation) throws Exception
@@ -171,12 +159,12 @@
else if (state instanceof PersistentApplicationState)
{
PersistentApplicationState pstate = (PersistentApplicationState)state;
- contentId = pomMgr.execute(new
PreferencesTask.GetContentId<S>(pstate.getStorageId())).getContentId();
+ contentId = pomMgr.execute(new
PreferencesTask.GetContentId<S>(pstate.getStorageId()));
}
else if (state instanceof CloneApplicationState)
{
CloneApplicationState cstate = (CloneApplicationState)state;
- contentId = pomMgr.execute(new
PreferencesTask.GetContentId<S>(cstate.getStorageId())).getContentId();
+ contentId = pomMgr.execute(new
PreferencesTask.GetContentId<S>(cstate.getStorageId()));
}
else
{
@@ -187,8 +175,9 @@
return contentId;
}
- public <S> S load(ApplicationState<S> state) throws Exception
+ public <S> S load(ApplicationState<S> state, ApplicationType<S>
type) throws Exception
{
+ Class<S> clazz = type.getContentType().getStateClass();
if (state instanceof TransientApplicationState)
{
TransientApplicationState<S> transientState =
(TransientApplicationState<S>)state;
@@ -197,16 +186,13 @@
}
else if (state instanceof CloneApplicationState)
{
- PreferencesTask.Load<S> load = new
PreferencesTask.Load<S>(((CloneApplicationState<S>)state).getStorageId());
- pomMgr.execute(load);
- return load.getState();
+ PreferencesTask.Load<S> load = new
PreferencesTask.Load<S>(((CloneApplicationState<S>)state).getStorageId(),
clazz);
+ return pomMgr.execute(load);
}
else
{
- PreferencesTask.Load<S> load =
- new
PreferencesTask.Load<S>(((PersistentApplicationState<S>)state).getStorageId());
- pomMgr.execute(load);
- return load.getState();
+ PreferencesTask.Load<S> load = new
PreferencesTask.Load<S>(((PersistentApplicationState<S>)state).getStorageId(),
clazz);
+ return pomMgr.execute(load);
}
}
@@ -236,7 +222,7 @@
public PortletPreferences getPortletPreferences(String windowID) throws Exception
{
- return pomMgr.execute(new PortletPreferencesTask.Load(windowID)).getPreferences();
+ return pomMgr.execute(new PortletPreferencesTask.Load(windowID));
}
public <T> LazyPageList<T> find(Query<T> q) throws Exception
@@ -249,24 +235,23 @@
Class<T> type = q.getClassType();
if (PageData.class.equals(type))
{
- return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindPage((Query<PageData>)q)).getResult();
+ return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindPage((Query<PageData>)q));
}
else if (NavigationData.class.equals(type))
{
- return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindNavigation((Query<NavigationData>)q)).getResult();
+ return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindNavigation((Query<NavigationData>)q));
}
else if (PortletPreferences.class.equals(type))
{
- return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindPortletPreferences((Query<PortletPreferences>)q))
- .getResult();
+ return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindPortletPreferences((Query<PortletPreferences>)q));
}
else if (PortalData.class.equals(type))
{
- return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindSite((Query<PortalData>)q)).getResult();
+ return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindSite((Query<PortalData>)q));
}
else if (PortalKey.class.equals(type) &&
"portal".equals(q.getOwnerType()))
{
- return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindSiteKey((Query<PortalKey>)q)).getResult();
+ return (LazyPageList<T>)pomMgr.execute(new
SearchTask.FindSiteKey((Query<PortalKey>)q));
}
else
{
@@ -289,13 +274,13 @@
}
else if (obj instanceof Application)
{
- ((Application)obj).setStorageName(UUID.randomUUID().toString());
+ obj.setStorageName(UUID.randomUUID().toString());
}
}
public DashboardData loadDashboard(String dashboardId) throws Exception
{
- return pomMgr.execute(new DashboardTask.Load(dashboardId)).getDashboard();
+ return pomMgr.execute(new DashboardTask.Load(dashboardId));
}
public void saveDashboard(DashboardData dashboard) throws Exception
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 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -358,7 +358,7 @@
}
};
- public void execute(POMTask task) throws Exception
+ public <V> V execute(POMTask<V> task) throws Exception
{
if (isInTask)
{
@@ -370,8 +370,9 @@
try
{
isInTask = true;
- task.run(this);
+ V v = task.run(this);
needRollback = false;
+ return v;
}
finally
{
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -130,16 +130,14 @@
*
* @param task the task to execute
* @throws Exception any exception thrown by the task
+ * @return the value
*/
- public <T extends POMTask> T execute(T task) throws Exception
+ public <V> V execute(POMTask<V> task) throws Exception
{
POMSession session = getSession();
//
- executor.execute(session, task);
-
- //
- return task;
+ return executor.execute(session, task);
}
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMTask.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -23,9 +23,9 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public interface POMTask
+public interface POMTask<V>
{
- void run(POMSession session) throws Exception;
+ V run(POMSession session) throws Exception;
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutionDecorator.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutionDecorator.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutionDecorator.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -33,9 +33,9 @@
this.next = next;
}
- public void execute(POMSession session, POMTask task) throws Exception
+ public <V> V execute(POMSession session, POMTask<V> task) throws
Exception
{
- next.execute(session, task);
+ return next.execute(session, task);
}
public <E extends TaskExecutor> E getDecorator(Class<E> decoratorClass)
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutor.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutor.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutor.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -25,6 +25,6 @@
public interface TaskExecutor
{
- void execute(POMSession session, POMTask task) throws Exception;
+ <V> V execute(POMSession session, POMTask<V> task) throws Exception;
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -26,17 +26,13 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public interface CacheableDataTask<K extends Serializable, V> extends POMTask
+public interface CacheableDataTask<K extends Serializable, V> extends
POMTask<V>
{
+ Class<V> getValueType();
+
DataAccessMode getAccessMode();
K getKey();
- V getValue();
-
- void setValue(V value);
-
- Class<V> getValueType();
-
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -41,56 +41,52 @@
super(next);
}
- public void execute(POMSession session, POMTask task) throws Exception
+ public <V> V execute(POMSession session, POMTask<V> task) throws
Exception
{
if (task instanceof CacheableDataTask)
{
- CacheableDataTask<?, ?> loadTask = (CacheableDataTask<?,?>)task;
+ CacheableDataTask<?, V> loadTask = (CacheableDataTask<?, V>)task;
switch (loadTask.getAccessMode())
{
case READ:
- read(session, loadTask);
- break;
+ return read(session, loadTask);
case CREATE:
- create(session, loadTask);
- break;
+ return create(session, loadTask);
case WRITE:
- write(session, loadTask);
- break;
+ return write(session, loadTask);
case DESTROY:
- remove(session, loadTask);
- break;
+ return remove(session, loadTask);
default:
throw new UnsupportedOperationException();
}
}
else
{
- super.execute(session, task);
+ return super.execute(session, task);
}
}
- private <K extends Serializable, V> void remove(POMSession session,
CacheableDataTask<K, V> task) throws Exception
+ private <K extends Serializable, V> V remove(POMSession session,
CacheableDataTask<K, V> task) throws Exception
{
K key = task.getKey();
session.scheduleForEviction(key);
- super.execute(session, task);
+ return super.execute(session, task);
}
- private <K extends Serializable, V> void write(POMSession session,
CacheableDataTask<K, V> task) throws Exception
+ private <K extends Serializable, V> V write(POMSession session,
CacheableDataTask<K, V> task) throws Exception
{
K key = task.getKey();
session.scheduleForEviction(key);
- super.execute(session, task);
+ return super.execute(session, task);
}
- private <K extends Serializable, V> void create(POMSession session,
CacheableDataTask<K, V> task) throws Exception
+ private <K extends Serializable, V> V create(POMSession session,
CacheableDataTask<K, V> task) throws Exception
{
// Nothing to do for now
- super.execute(session, task);
+ return super.execute(session, task);
}
- private <K extends Serializable, V> void read(POMSession session,
CacheableDataTask<K, V> task) throws Exception
+ private <K extends Serializable, V> V read(POMSession session,
CacheableDataTask<K, V> task) throws Exception
{
if (!session.isModified())
{
@@ -109,26 +105,28 @@
//
if (v != null)
{
- task.setValue(v);
+ return v;
}
else
{
readCount.incrementAndGet();
//
- super.execute(session, task);
+ v = super.execute(session, task);
//
- v = task.getValue();
if (v != null)
{
session.putInCache(key, v);
}
+
+ //
+ return v;
}
}
else
{
- super.execute(session, task);
+ return super.execute(session, task);
}
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/DashboardTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/DashboardTask.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/DashboardTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -19,9 +19,9 @@
package org.exoplatform.portal.pom.config.tasks;
+import org.exoplatform.portal.pom.config.POMTask;
import org.exoplatform.portal.pom.data.DashboardData;
import org.exoplatform.portal.pom.data.Mapper;
-import org.exoplatform.portal.pom.config.AbstractPOMTask;
import org.exoplatform.portal.pom.config.POMSession;
import org.gatein.mop.api.workspace.ObjectType;
import org.gatein.mop.api.workspace.ui.UIContainer;
@@ -30,37 +30,32 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class DashboardTask extends AbstractPOMTask
+public abstract class DashboardTask
{
- public static class Load extends DashboardTask
+ public static class Load implements POMTask<DashboardData>
{
/** . */
protected final String storageId;
- /** . */
- protected DashboardData dashboard;
-
public Load(String storageId)
{
this.storageId = storageId;
}
- public void run(POMSession session) throws Exception
+ public DashboardData run(POMSession session) throws Exception
{
UIContainer container = session.findObjectById(ObjectType.CONTAINER,
storageId);
//
if (container != null)
{
- dashboard = new Mapper(session).loadDashboard(container);
+ return new Mapper(session).loadDashboard(container);
}
- }
- public DashboardData getDashboard()
- {
- return dashboard;
+ //
+ return null;
}
@Override
@@ -70,7 +65,7 @@
}
}
- public static class Save extends DashboardTask
+ public static class Save implements POMTask<Void>
{
/** The dashboard object. */
@@ -89,7 +84,7 @@
this.dashboard = dashboard;
}
- public void run(POMSession session) throws Exception
+ public Void run(POMSession session) throws Exception
{
String id = dashboard.getStorageId();
if (id == null)
@@ -109,6 +104,9 @@
//
mapper.saveDashboard(dashboard, container);
+
+ //
+ return null;
}
@Override
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageNavigationTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageNavigationTask.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageNavigationTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -23,7 +23,6 @@
import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
import org.exoplatform.portal.pom.data.Mapper;
-import org.exoplatform.portal.pom.config.AbstractPOMTask;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.data.NavigationData;
import org.exoplatform.portal.pom.data.NavigationKey;
@@ -36,7 +35,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class PageNavigationTask extends AbstractPOMTask
+public abstract class PageNavigationTask
{
/** . */
@@ -54,19 +53,11 @@
public static class Load extends PageNavigationTask implements
CacheableDataTask<NavigationKey, NavigationData>
{
- /** . */
- private NavigationData pageNav;
-
public Load(NavigationKey key)
{
super(key);
}
- public NavigationData getPageNavigation()
- {
- return pageNav;
- }
-
public DataAccessMode getAccessMode()
{
return DataAccessMode.READ;
@@ -77,22 +68,12 @@
return key;
}
- public NavigationData getValue()
- {
- return pageNav;
- }
-
- public void setValue(NavigationData value)
- {
- this.pageNav = value;
- }
-
public Class<NavigationData> getValueType()
{
return NavigationData.class;
}
- public void run(POMSession session) throws Exception
+ public NavigationData run(POMSession session) throws Exception
{
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(siteType, key.getId());
@@ -102,7 +83,7 @@
Navigation defaultNav = nav.getChild("default");
if (defaultNav != null)
{
- pageNav = new Mapper(session).load(defaultNav);
+ return new Mapper(session).load(defaultNav);
}
}
else
@@ -110,6 +91,9 @@
System.out.println("Cannot load page navigation as the corresponding
portal " + key.getId()
+ " with type " + siteType + " does not exist");
}
+
+ //
+ return null;
}
@Override
@@ -119,7 +103,7 @@
}
}
- public static class Save extends PageNavigationTask implements
CacheableDataTask<NavigationKey, NavigationData>
+ public static class Save extends PageNavigationTask implements
CacheableDataTask<NavigationKey, Void>
{
/** . */
@@ -137,32 +121,22 @@
this.overwrite = overwrite;
}
- public DataAccessMode getAccessMode()
+ public Class<Void> getValueType()
{
- return pageNav.getStorageId() != null ? DataAccessMode.WRITE :
DataAccessMode.CREATE;
+ return Void.class;
}
- public void setValue(NavigationData value)
+ public DataAccessMode getAccessMode()
{
- throw new UnsupportedOperationException();
+ return pageNav.getStorageId() != null ? DataAccessMode.WRITE :
DataAccessMode.CREATE;
}
- public Class<NavigationData> getValueType()
- {
- return NavigationData.class;
- }
-
- public NavigationData getValue()
- {
- return pageNav;
- }
-
public NavigationKey getKey()
{
return key;
}
- public void run(POMSession session) throws Exception
+ public Void run(POMSession session) throws Exception
{
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(siteType, key.getId());
@@ -184,6 +158,9 @@
//
new Mapper(session).save(pageNav, defaultNav);
+
+ //
+ return null;
}
@Override
@@ -193,7 +170,7 @@
}
}
- public static class Remove extends PageNavigationTask implements
CacheableDataTask<NavigationKey, NavigationData>
+ public static class Remove extends PageNavigationTask implements
CacheableDataTask<NavigationKey, Void>
{
public Remove(NavigationData pageNav)
@@ -206,27 +183,17 @@
return DataAccessMode.DESTROY;
}
- public void setValue(NavigationData value)
+ public Class<Void> getValueType()
{
- throw new UnsupportedOperationException();
+ return Void.class;
}
- public Class<NavigationData> getValueType()
- {
- return NavigationData.class;
- }
-
- public NavigationData getValue()
- {
- return null;
- }
-
public NavigationKey getKey()
{
return key;
}
- public void run(POMSession session) throws Exception
+ public Void run(POMSession session) throws Exception
{
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(siteType, key.getId());
@@ -245,6 +212,9 @@
{
defaultNav.destroy();
}
+
+ //
+ return null;
}
@Override
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 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -19,13 +19,13 @@
package org.exoplatform.portal.pom.config.tasks;
+import org.exoplatform.portal.pom.config.POMTask;
import org.exoplatform.portal.pom.config.cache.DataAccessMode;
import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
import org.exoplatform.portal.pom.data.Mapper;
import org.exoplatform.portal.pom.data.ModelChange;
import org.exoplatform.portal.pom.data.PageData;
-import org.exoplatform.portal.pom.config.AbstractPOMTask;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.data.PageKey;
import org.gatein.mop.api.Attributes;
@@ -45,7 +45,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class PageTask extends AbstractPOMTask
+public abstract class PageTask
{
/** . */
@@ -72,7 +72,7 @@
this.siteType = Mapper.parseSiteType(ownerType);
}
- public static class Clone extends PageTask
+ public static class Clone extends PageTask implements POMTask<PageData>
{
/** . */
@@ -88,9 +88,6 @@
private final String cloneName;
/** . */
- private PageData page;
-
- /** . */
private boolean deep;
public Clone(PageKey key, PageKey cloneKey, boolean deep)
@@ -105,7 +102,7 @@
this.cloneSiteType = Mapper.parseSiteType(cloneOwnerType);
}
- public void run(POMSession session) throws Exception
+ public PageData run(POMSession session) throws Exception
{
Workspace workspace = session.getWorkspace();
@@ -163,7 +160,7 @@
copy(srcPage, dstPage, srcPage.getRootComponent(), dstPage.getRootComponent());
//
- this.page = new Mapper(session).load(dstPage);
+ return new Mapper(session).load(dstPage);
}
private void copy(org.gatein.mop.api.workspace.Page srcPage,
org.gatein.mop.api.workspace.Page dstPage,
@@ -232,11 +229,6 @@
}
}
- public PageData getPage()
- {
- return page;
- }
-
@Override
public String toString()
{
@@ -245,7 +237,7 @@
}
}
- public static class Remove extends PageTask implements CacheableDataTask<PageKey,
PageData>
+ public static class Remove extends PageTask implements CacheableDataTask<PageKey,
Void>
{
public Remove(PageData page)
@@ -258,27 +250,17 @@
return DataAccessMode.DESTROY;
}
- public void setValue(PageData value)
+ public Class<Void> getValueType()
{
- throw new UnsupportedOperationException();
+ return Void.class;
}
- public Class<PageData> getValueType()
- {
- return PageData.class;
- }
-
- public PageData getValue()
- {
- return null;
- }
-
public PageKey getKey()
{
return key;
}
- public void run(POMSession session)
+ public Void run(POMSession session)
{
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(siteType, ownerId);
@@ -299,6 +281,9 @@
}
page.destroy();
}
+
+ //
+ return null;
}
@Override
@@ -308,7 +293,7 @@
}
}
- public static class Save extends PageTask implements CacheableDataTask<PageKey,
PageData>
+ public static class Save extends PageTask implements CacheableDataTask<PageKey,
Void>
{
/** . */
@@ -330,27 +315,17 @@
return page.getStorageId() != null ? DataAccessMode.WRITE :
DataAccessMode.CREATE;
}
- public void setValue(PageData value)
+ public Class<Void> getValueType()
{
- throw new UnsupportedOperationException();
+ return Void.class;
}
- public Class<PageData> getValueType()
- {
- return PageData.class;
- }
-
- public PageData getValue()
- {
- return page;
- }
-
public PageKey getKey()
{
return key;
}
- public void run(POMSession session) throws Exception
+ public Void run(POMSession session) throws Exception
{
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(siteType, ownerId);
@@ -363,6 +338,9 @@
//
Mapper mapper = new Mapper(session);
changes = mapper.save(this.page, site, name);
+
+ //
+ return null;
}
public List<ModelChange> getChanges()
@@ -380,19 +358,11 @@
public static class Load extends PageTask implements CacheableDataTask<PageKey,
PageData>
{
- /** . */
- private PageData page;
-
public Load(PageKey key)
{
super(key);
}
- public PageData getPage()
- {
- return page;
- }
-
public DataAccessMode getAccessMode()
{
return DataAccessMode.READ;
@@ -408,18 +378,8 @@
return PageData.class;
}
- public void setValue(PageData value)
+ public PageData run(POMSession session)
{
- page = value;
- }
-
- public PageData getValue()
- {
- return page;
- }
-
- public void run(POMSession session)
- {
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(siteType, ownerId);
if (site != null)
@@ -429,9 +389,12 @@
org.gatein.mop.api.workspace.Page page = pages.getChild(name);
if (page != null)
{
- this.page = new Mapper(session).load(page);
+ return new Mapper(session).load(page);
}
}
+
+ //
+ return null;
}
@Override
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 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -24,7 +24,6 @@
import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
import org.exoplatform.portal.pom.data.Mapper;
import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.config.AbstractPOMTask;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.data.PortalKey;
import org.gatein.mop.api.workspace.ObjectType;
@@ -36,7 +35,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class PortalConfigTask extends AbstractPOMTask
+public abstract class PortalConfigTask
{
/** . */
@@ -51,7 +50,7 @@
this.type = Mapper.parseSiteType(key.getType());
}
- public static class Remove extends PortalConfigTask implements
CacheableDataTask<PortalKey, PortalData>
+ public static class Remove extends PortalConfigTask implements
CacheableDataTask<PortalKey, Void>
{
public Remove(PortalKey key)
@@ -64,9 +63,9 @@
return DataAccessMode.DESTROY;
}
- public Class<PortalData> getValueType()
+ public Class<Void> getValueType()
{
- return PortalData.class;
+ return Void.class;
}
public PortalKey getKey()
@@ -74,18 +73,8 @@
return key;
}
- public void setValue(PortalData value)
+ public Void run(POMSession session)
{
- throw new UnsupportedOperationException();
- }
-
- public PortalData getValue()
- {
- return null;
- }
-
- public void run(POMSession session)
- {
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(type, key.getId());
if (site == null)
@@ -96,6 +85,7 @@
{
site.destroy();
}
+ return null;
}
@Override
@@ -105,7 +95,7 @@
}
}
- public static class Save extends PortalConfigTask implements
CacheableDataTask<PortalKey, PortalData>
+ public static class Save extends PortalConfigTask implements
CacheableDataTask<PortalKey, Void>
{
/** . */
@@ -128,27 +118,17 @@
return overwrite ? DataAccessMode.WRITE : DataAccessMode.CREATE;
}
- public void setValue(PortalData value)
+ public Class<Void> getValueType()
{
- throw new UnsupportedOperationException();
+ return Void.class;
}
- public Class<PortalData> getValueType()
- {
- return PortalData.class;
- }
-
- public PortalData getValue()
- {
- return config;
- }
-
public PortalKey getKey()
{
return key;
}
- public void run(POMSession session) throws Exception
+ public Void run(POMSession session) throws Exception
{
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(type, key.getId());
@@ -179,6 +159,9 @@
}
}
new Mapper(session).save(config, site);
+
+ //
+ return null;
}
@Override
@@ -209,34 +192,22 @@
return key;
}
- public void setValue(PortalData value)
- {
- config = value;
- }
-
public Class<PortalData> getValueType()
{
return PortalData.class;
}
- public PortalData getValue()
+ public PortalData run(POMSession session)
{
- return config;
- }
-
- public PortalData getConfig()
- {
- return config;
- }
-
- public void run(POMSession session)
- {
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(type, key.getId());
if (site != null)
{
- this.config = new Mapper(session).load(site);
+ return new Mapper(session).load(site);
}
+
+ //
+ return null;
}
@Override
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortletPreferencesTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortletPreferencesTask.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortletPreferencesTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -21,8 +21,8 @@
import org.exoplatform.portal.application.PortletPreferences;
import org.exoplatform.portal.application.Preference;
+import org.exoplatform.portal.pom.config.POMTask;
import org.exoplatform.portal.pom.data.Mapper;
-import org.exoplatform.portal.pom.config.AbstractPOMTask;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.portal.pom.spi.portlet.PortletBuilder;
@@ -39,7 +39,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class PortletPreferencesTask extends AbstractPOMTask
+public abstract class PortletPreferencesTask
{
/*
@@ -92,7 +92,7 @@
this.windowId = windowId;
}
- public static class Save extends PortletPreferencesTask
+ public static class Save extends PortletPreferencesTask implements
POMTask<Void>
{
/** . */
@@ -106,8 +106,13 @@
this.prefs = prefs;
}
- public void run(POMSession session) throws Exception
+ public Class<Void> getValueType()
{
+ return Void.class;
+ }
+
+ public Void run(POMSession session) throws Exception
+ {
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(siteType, ownerId);
@@ -172,26 +177,26 @@
{
session.addPortletPreferences(prefs);
}
+
+ //
+ return null;
}
}
- public static class Load extends PortletPreferencesTask
+ public static class Load extends PortletPreferencesTask implements
POMTask<PortletPreferences>
{
- /** . */
- private PortletPreferences prefs;
-
public Load(String windowId)
{
super(windowId);
}
- public PortletPreferences getPreferences()
+ public Class<PortletPreferences> getValueType()
{
- return prefs;
+ return PortletPreferences.class;
}
- public void run(POMSession session) throws Exception
+ public PortletPreferences run(POMSession session) throws Exception
{
Workspace workspace = session.getWorkspace();
Site site = workspace.getSite(siteType, ownerId);
@@ -245,10 +250,13 @@
PortletPreferences prefs = new PortletPreferences();
prefs.setWindowId(windowId);
prefs.setPreferences(list);
- this.prefs = prefs;
+ return prefs;
}
}
}
+
+ //
+ return null;
}
}
}
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 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -19,8 +19,8 @@
package org.exoplatform.portal.pom.config.tasks;
-import org.exoplatform.portal.pom.config.AbstractPOMTask;
import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMTask;
import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
import org.exoplatform.portal.pom.config.cache.DataAccessMode;
import org.gatein.mop.api.content.Customization;
@@ -29,50 +29,43 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class PreferencesTask<S> extends AbstractPOMTask
+public abstract class PreferencesTask<S>
{
/** . */
private static final Object NULL_PREFS = new Object();
- public static class GetContentId<S> extends PreferencesTask<S>
+ public static class GetContentId<S> extends PreferencesTask<S> implements
POMTask<String>
{
/** . */
private final String storageId;
- /** . */
- private String contentId;
-
public GetContentId(String storageId)
{
this.storageId = storageId;
}
- public void run(POMSession session) throws Exception
+ public String run(POMSession session) throws Exception
{
Customization<S> customization =
(Customization<S>)session.findCustomizationById(storageId);
- contentId = customization.getContentId();
+ return customization.getContentId();
}
-
- public String getContentId()
- {
- return contentId;
- }
}
- public static class Load<S> extends PreferencesTask<S> implements
CacheableDataTask<String, Object>
+ public static class Load<S> extends PreferencesTask<S> implements
CacheableDataTask<String, S>
{
/** . */
private final String storageId;
/** . */
- private S prefs;
+ private final Class<S> valueType;
- public Load(String storageId)
+ public Load(String storageId, Class<S> valueType)
{
this.storageId = storageId;
+ this.valueType = valueType;
}
public DataAccessMode getAccessMode()
@@ -80,40 +73,23 @@
return DataAccessMode.READ;
}
- public void setValue(Object value)
+ public Class<S> getValueType()
{
- if (value != NULL_PREFS)
- {
- prefs = (S)value;
- }
+ return valueType;
}
- public Class<Object> getValueType()
- {
- return Object.class;
- }
-
- public Object getValue()
- {
- return prefs == null ? NULL_PREFS : prefs;
- }
-
public String getKey()
{
return storageId;
}
- public void run(POMSession session) throws Exception
+ public S run(POMSession session) throws Exception
{
Customization<S> customization =
(Customization<S>)session.findCustomizationById(storageId);
- prefs = customization.getVirtualState();
+ S prefs = customization.getVirtualState();
+ return prefs == null ? (S)NULL_PREFS : prefs;
}
- public S getState()
- {
- return prefs;
- }
-
@Override
public String toString()
{
@@ -121,7 +97,7 @@
}
}
- public static class Save<S> extends PreferencesTask<S> implements
CacheableDataTask<String, Object>
+ public static class Save<S> extends PreferencesTask<S> implements
CacheableDataTask<String, Void>
{
/** . */
@@ -141,27 +117,17 @@
return DataAccessMode.WRITE;
}
- public void setValue(Object value)
+ public Class<Void> getValueType()
{
- throw new UnsupportedOperationException();
+ return Void.class;
}
- public Class<Object> getValueType()
- {
- return Object.class;
- }
-
- public Object getValue()
- {
- return prefs == null ? NULL_PREFS : prefs ;
- }
-
public String getKey()
{
return storageId;
}
- public void run(POMSession session) throws Exception
+ public Void run(POMSession session) throws Exception
{
Customization<S> customization =
(Customization<S>)session.findCustomizationById(storageId);
@@ -174,6 +140,9 @@
{
customization.setState(null);
}
+
+ //
+ return null;
}
@Override
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -23,12 +23,12 @@
import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.portal.application.PortletPreferences;
import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.pom.config.POMTask;
import org.exoplatform.portal.pom.data.Mapper;
import org.exoplatform.portal.pom.data.NavigationData;
import org.exoplatform.portal.pom.data.PageData;
import org.exoplatform.portal.pom.data.PortalData;
import org.exoplatform.portal.pom.data.PortalKey;
-import org.exoplatform.portal.pom.config.AbstractPOMTask;
import org.exoplatform.portal.pom.config.POMSession;
import org.gatein.mop.api.workspace.Navigation;
import org.gatein.mop.api.workspace.ObjectType;
@@ -45,25 +45,17 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class SearchTask<T> extends AbstractPOMTask
+public abstract class SearchTask<T> implements
POMTask<LazyPageList<T>>
{
/** . */
protected final Query<T> q;
- /** . */
- protected LazyPageList<T> result;
-
public SearchTask(Query<T> query)
{
this.q = query;
}
- public LazyPageList<T> getResult()
- {
- return result;
- }
-
public abstract static class FindSiteObject<W extends WorkspaceObject, T>
extends SearchTask<T>
{
@@ -72,7 +64,7 @@
super(query);
}
- public void run(final POMSession session) throws Exception
+ public LazyPageList<T> run(final POMSession session) throws Exception
{
Iterator<W> ite;
try
@@ -119,7 +111,8 @@
}
};
- result = new LazyPageList<T>(la, 10);
+ //
+ return new LazyPageList<T>(la, 10);
}
protected abstract Iterator<W> findW(POMSession session, ObjectType<?
extends Site> siteType, String ownerId,
@@ -189,11 +182,11 @@
super(portletPreferencesQuery);
}
- public void run(final POMSession session) throws Exception
+ public LazyPageList<PortletPreferences> run(final POMSession session) throws
Exception
{
// We return empty on purpose at it is used when preferences are deleted by the
UserPortalConfigService
// and the prefs are deleted transitively when an entity is removed
- result = new LazyPageList<PortletPreferences>(new
ListAccess<PortletPreferences>()
+ return new LazyPageList<PortletPreferences>(new
ListAccess<PortletPreferences>()
{
public PortletPreferences[] load(int index, int length) throws Exception,
IllegalArgumentException
{
@@ -216,7 +209,7 @@
super(siteQuery);
}
- public void run(final POMSession session) throws Exception
+ public LazyPageList<PortalData> run(final POMSession session) throws
Exception
{
Workspace workspace = session.getWorkspace();
String ownerType = q.getOwnerType();
@@ -242,7 +235,7 @@
return portals.size();
}
};
- result = new LazyPageList<PortalData>(la, 10);
+ return new LazyPageList<PortalData>(la, 10);
}
}
@@ -254,7 +247,7 @@
super(siteQuery);
}
- public void run(final POMSession session) throws Exception
+ public LazyPageList<PortalKey> run(final POMSession session) throws
Exception
{
Workspace workspace = session.getWorkspace();
final Collection<? extends Site> portals =
workspace.getSites(ObjectType.PORTAL_SITE);
@@ -277,7 +270,7 @@
return portals.size();
}
};
- result = new LazyPageList<PortalKey>(la, 10);
+ return new LazyPageList<PortalKey>(la, 10);
}
}
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -23,6 +23,7 @@
import org.exoplatform.portal.application.PortletPreferences;
import org.exoplatform.portal.config.Query;
import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.pom.data.ModelChange;
import org.exoplatform.portal.pom.data.PageData;
@@ -91,7 +92,7 @@
public <S> String getId(ApplicationState<S> state) throws Exception;
- public <S> S load(ApplicationState<S> state) throws Exception;
+ public <S> S load(ApplicationState<S> state, ApplicationType<S>
type) throws Exception;
public <S> ApplicationState<S> save(ApplicationState<S> state, S
preferences) throws Exception;
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 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -463,7 +463,7 @@
assertEquals("web/BannerPortlet", storage_.getId(banner1.getState()));
// Check state
- Portlet pagePrefs = storage_.load(instanceId);
+ Portlet pagePrefs = storage_.load(instanceId, ApplicationType.PORTLET);
assertEquals(new PortletBuilder().add("template",
"par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl")
.build(), pagePrefs);
@@ -488,7 +488,7 @@
storage_.save(sitePrefs);
// Check that page prefs have not changed
- pagePrefs = storage_.load(instanceId);
+ pagePrefs = storage_.load(instanceId, ApplicationType.PORTLET);
assertEquals(new PortletBuilder().add("template",
"par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl")
.build(), pagePrefs);
@@ -497,7 +497,7 @@
storage_.save(instanceId, pagePrefs);
// Check that page prefs have changed
- pagePrefs = storage_.load(instanceId);
+ pagePrefs = storage_.load(instanceId, ApplicationType.PORTLET);
assertEquals(new PortletBuilder().add("template",
"foo").build(), pagePrefs);
// Check that site prefs have not changed
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestGadget.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestGadget.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestGadget.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -21,6 +21,7 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.TransientApplicationState;
import org.exoplatform.portal.pom.config.POMSession;
@@ -77,7 +78,7 @@
container = storage_.getPage("portal::test::gadget_page");
gadgetApplication = (Application<Gadget>)container.getChildren().get(0);
- gadget = storage_.load(gadgetApplication.getState());
+ gadget = storage_.load(gadgetApplication.getState(), ApplicationType.GADGET);
assertNotNull(gadget);
assertEquals("user_pref", gadget.getUserPref());
}
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestPortletPreferences.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestPortletPreferences.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestPortletPreferences.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -21,13 +21,13 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PersistentApplicationState;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.config.POMSessionManager;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.portal.pom.spi.portlet.PortletBuilder;
-import org.exoplatform.test.BasicTestCase;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -74,7 +74,7 @@
PersistentApplicationState<Portlet> state =
(PersistentApplicationState)app.getState();
//
- Portlet prefs = storage_.load(state);
+ Portlet prefs = storage_.load(state, ApplicationType.PORTLET);
assertEquals(new PortletBuilder().add("template",
"par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl")
.build(), prefs);
@@ -83,7 +83,7 @@
storage_.save(state, prefs);
//
- prefs = storage_.load(state);
+ prefs = storage_.load(state, ApplicationType.PORTLET);
assertNotNull(prefs);
assertEquals(new PortletBuilder().add("template",
"someanothervalue").build(), prefs);
}
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -54,7 +54,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.CountDownLatch;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -666,7 +665,7 @@
//
Application<Portlet> app =
(Application<Portlet>)clone.getChildren().get(0);
- Portlet prefs2 = storage_.load(app.getState());
+ Portlet prefs2 = storage_.load(app.getState(), ApplicationType.PORTLET);
assertEquals(new PortletBuilder().add("template",
"par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl").build(), prefs2);
@@ -676,7 +675,7 @@
storage_.save(prefs);
//
- prefs2 = storage_.load(app.getState());
+ prefs2 = storage_.load(app.getState(), ApplicationType.PORTLET);
assertEquals(new PortletBuilder().add("template",
"par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl").build(), prefs2);
}
@@ -704,7 +703,7 @@
assertEquals("dashboard/DashboardPortlet",
storage_.getId(app.getState()));
// assertEquals("portal", app.getInstanceState().getOwnerType());
// assertEquals("test", app.getInstanceState().getOwnerId());
- Portlet prefs2 = storage_.load(app.getState());
+ Portlet prefs2 = storage_.load(app.getState(), ApplicationType.PORTLET);
assertNull(prefs2);
}
}.execute(null);
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestWSRP.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestWSRP.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestWSRP.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -21,12 +21,12 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.TransientApplicationState;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.config.POMSessionManager;
import org.exoplatform.portal.pom.spi.wsrp.WSRP;
-import org.exoplatform.test.BasicTestCase;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -80,7 +80,7 @@
container = storage_.getPage(pageId);
wsrpApplication = (Application<WSRP>)container.getChildren().get(0);
- wsrp = storage_.load(wsrpApplication.getState());
+ wsrp = storage_.load(wsrpApplication.getState(), ApplicationType.WSRP_PORTLET);
assertNotNull(wsrp);
assertEquals(id, wsrp.getPortletId());
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -87,7 +87,7 @@
ApplicationState<Portlet> applicationState) throws Exception
{
DataStorage dataStorage =
(DataStorage)container.getComponentInstanceOfType(DataStorage.class);
- Portlet preferences = dataStorage.load(applicationState);
+ Portlet preferences = dataStorage.load(applicationState,
ApplicationType.PORTLET);
PortletContext producerOfferedPortletContext =
getProducerOfferedPortletContext(applicationId);
ExoPortletState map = new
ExoPortletState(producerOfferedPortletContext.getId());
if (preferences != null)
@@ -148,7 +148,7 @@
else
{
DataStorage dataStorage =
(DataStorage)container.getComponentInstanceOfType(DataStorage.class);
- Portlet pref = dataStorage.load(applicationState);
+ Portlet pref = dataStorage.load(applicationState, ApplicationType.PORTLET);
if (pref == null)
pref = new Portlet();
return pref;
@@ -219,7 +219,7 @@
ApplicationState<WSRP> state) throws Exception
{
DataStorage dataStorage =
(DataStorage)container.getComponentInstanceOfType(DataStorage.class);
- WSRP wsrp = dataStorage.load(state);
+ WSRP wsrp = dataStorage.load(state, ApplicationType.WSRP_PORTLET);
if (wsrp == null)
{
wsrp = new WSRP();
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2009-12-17
17:06:31 UTC (rev 1052)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2009-12-17
23:27:05 UTC (rev 1053)
@@ -24,8 +24,8 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.Properties;
-import org.exoplatform.portal.webui.container.UIContainer;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.application.gadget.GadgetApplication;
@@ -355,7 +355,7 @@
public String getUserPref() throws Exception
{
DataStorage service = getApplicationComponent(DataStorage.class);
- org.exoplatform.portal.pom.spi.gadget.Gadget pp = service.load(state);
+ org.exoplatform.portal.pom.spi.gadget.Gadget pp = service.load(state,
ApplicationType.GADGET);
return pp != null ? pp.getUserPref() : null;
}