[gatein-commits] gatein SVN: r493 - in portal/branches/wsrp-integration: component/common/src/main/java/org/exoplatform/commons/utils and 46 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Nov 4 15:32:34 EST 2009


Author: chris.laprun at jboss.com
Date: 2009-11-04 15:32:31 -0500 (Wed, 04 Nov 2009)
New Revision: 493

Added:
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/BinaryOutput.java
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/BufferingOutputStream.java
   portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestBufferingOutputStream.java
   portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestOutputStreamPrinter.java
   portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestPrinter.java
   portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestSafe.java
   portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestTextEncoder.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/ModelDemarcation.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutor.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataAccessMode.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ApplicationData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyType.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ContainerData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/DashboardData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationKey.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/OwnerKey.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageKey.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalKey.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/BaseScript.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyCompilationException.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyPrinter.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScript.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScriptBuilder.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplate.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplateEngine.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyText.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/LineBreakItem.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/OutputStreamWriterGroovyPrinter.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/Position.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionItem.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionType.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateCompilationException.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateParser.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateRuntimeException.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateSection.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TextItem.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/WriterGroovyPrinter.java
   portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/
   portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateCompiler.java
   portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateParser.java
   portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java
   portal/branches/wsrp-integration/component/scripting/src/test/resources/
   portal/branches/wsrp-integration/component/scripting/src/test/resources/UIPortalApplication.gtmpl
   portal/branches/wsrp-integration/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigParser.java
   portal/branches/wsrp-integration/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptTask.java
Removed:
   portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/OutputStreamPrinterTestCase.java
   portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/PrinterTestCase.java
   portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/SafeTestCase.java
   portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TextEncoderTestCase.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/MappedAttributes.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Mapper.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataAccessMode.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ApplicationData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyType.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ContainerData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/DashboardData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationKey.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/OwnerKey.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageKey.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalData.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalKey.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/resource/config/tasks/JavascriptTask.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/resource/config/xml/JavascriptConfigParser.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/text/SimpleTemplateEngine.java
   portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateCompiler.java
   portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateParser.java
   portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java
   portal/branches/wsrp-integration/component/scripting/src/test/resources/UIPortalApplication.gtmpl
   portal/branches/wsrp-integration/web/eXoResources/src/main/webapp/WEB-INF/conf/script/
   portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/script/
Modified:
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharEncoder.java
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharsetCharEncoder.java
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharsetTextEncoder.java
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/OutputStreamPrinter.java
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Printer.java
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/TableCharEncoder.java
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Text.java
   portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/TextEncoder.java
   portal/branches/wsrp-integration/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java
   portal/branches/wsrp-integration/component/portal/src/main/java/conf/portal/configuration.xml
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/Query.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Application.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Container.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Dashboard.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/ModelChange.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/ModelObject.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageBody.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNodeContainer.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PersistentApplicationState.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Properties.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/SiteBody.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/gadget/GadgetApplication.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/portlet/PortletApplication.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/wsrp/WSRPApplication.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/Utils.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/DashboardTask.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageNavigationTask.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageTask.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortletPreferencesTask.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java
   portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java
   portal/branches/wsrp-integration/component/portal/src/test/java/conf/portal/test-configuration.xml
   portal/branches/wsrp-integration/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/commons/utils/PortalPrinter.java
   portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
   portal/branches/wsrp-integration/packaging/module/src/main/javascript/portal.packaging.module.js
   portal/branches/wsrp-integration/pom.xml
   portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
   portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
   portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/PortalNavigationPortlet_vi.xml
   portal/branches/wsrp-integration/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java
   portal/branches/wsrp-integration/web/eXoResources/src/main/webapp/WEB-INF/gatein-resources.xml
   portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/classes/locale/navigation/group/organization/management/executive-board_en.properties
   portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/portal/group/platform/administrators/navigation.xml
   portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
   portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/gatein-resources.xml
   portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/gatein_resources_1_0.xsd
   portal/branches/wsrp-integration/web/portal/src/main/webapp/groovy/portal/webui/page/UIWizardPageSelectLayoutForm.gtmpl
   portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java
   portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
   portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalSelector.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
   portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
Log:
- Merged trunk changes 463 to 492.

Copied: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/BinaryOutput.java (from rev 480, portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/BinaryOutput.java)
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/BinaryOutput.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/BinaryOutput.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.commons.utils;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public interface BinaryOutput
+{
+
+   Charset getCharset();
+
+   void write(byte b) throws IOException;
+
+   void write(byte[] bytes) throws IOException;
+
+   void write(byte[] b, int off, int len) throws IOException;
+
+}

Copied: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/BufferingOutputStream.java (from rev 480, portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/BufferingOutputStream.java)
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/BufferingOutputStream.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/BufferingOutputStream.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.commons.utils;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * A stream that maintains a buffer and flush it on a delegate output stream when it is
+ * filled. Unlike {@link java.io.BufferedOutputStream} this class is not synchronized. 
+ *
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class BufferingOutputStream extends OutputStream
+{
+
+   /** . */
+   private final OutputStream out;
+
+   /** . */
+   private byte[] buffer;
+
+   /** . */
+   private boolean open;
+
+   /** . */
+   private int offset;
+
+   /** . */
+   private final int size;
+
+   public BufferingOutputStream(OutputStream out, int bufferSize)
+   {
+      if (out == null)
+      {
+         throw new NullPointerException("No null output stream");
+      }
+      if (bufferSize < 1)
+      {
+         throw new IllegalArgumentException("No buffer size under 1");
+      }
+      this.out = out;
+      this.buffer = new byte[bufferSize];
+      this.size = bufferSize;
+      this.open = true;
+   }
+
+   @Override
+   public void write(int b) throws IOException
+   {
+      if (!open)
+      {
+         throw new IOException("closed");
+      }
+      if (offset >= size)
+      {
+         out.write(buffer);
+         offset = 0;
+      }
+      buffer[offset++] = (byte)b;
+   }
+
+   @Override
+   public void write(byte[] b, int off, int len) throws IOException
+   {
+      if (!open)
+      {
+         throw new IOException("closed");
+      }
+
+      //
+      if (offset + len >= size)
+      {
+         // Clear the buffer
+         out.write(buffer, 0, offset);
+         offset = 0;
+
+         // While the data length is greater than the the buffer size
+         // write directly to the wire
+         while (len >= size)
+         {
+            out.write(b, off, size);
+            off += size;
+            len -= size;
+         }
+      }
+
+      //
+      System.arraycopy(b, off, buffer, offset, len);
+      offset += len;
+   }
+
+   @Override
+   public void flush() throws IOException
+   {
+      if (!open)
+      {
+         throw new IOException("closed");
+      }
+
+      //
+      if (offset > 0)
+      {
+         out.write(buffer, 0, offset);
+         offset = 0;
+      }
+
+      //
+      out.flush();
+   }
+
+   @Override
+   public void close() throws IOException
+   {
+      if (!open)
+      {
+         throw new IOException("closed");
+      }
+
+      //
+      if (offset > 0)
+      {
+         out.write(buffer, 0, offset);
+         offset = 0;
+      }
+
+      //
+      open = false;
+      out.close();
+   }
+}

Modified: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharEncoder.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharEncoder.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharEncoder.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,8 @@
 
 package org.exoplatform.commons.utils;
 
+import java.nio.charset.Charset;
+
 /**
  * A char encoder that encodes chars to a suite of bytes. No assumptions must be made about the
  * statefullness nature of an encoder as some encoder may be statefull and some encoder may be stateless.
@@ -36,4 +38,11 @@
     * @return the serie of bytes corresponding to the encoded char
     */
    byte[] encode(char c);
+
+   /**
+    * Returns the charset that will perform the encoding.
+    *
+    * @return the charset for encoding
+    */
+   Charset getCharset();
 }

Modified: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharsetCharEncoder.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharsetCharEncoder.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharsetCharEncoder.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -61,6 +61,11 @@
       this.arrays = new byte[][]{new byte[0], new byte[1], new byte[2], new byte[3], new byte[4], new byte[5]};
    }
 
+   public Charset getCharset()
+   {
+      return charset;
+   }
+
    public byte[] encode(char c)
    {
       /*

Modified: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharsetTextEncoder.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharsetTextEncoder.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/CharsetTextEncoder.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -29,7 +29,7 @@
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
-public class CharsetTextEncoder implements TextEncoder
+public final class CharsetTextEncoder implements TextEncoder
 {
 
    private static final CharsetTextEncoder UTF8 = new CharsetTextEncoder(CharsetCharEncoder.getUTF8());
@@ -52,10 +52,40 @@
       this(new TableCharEncoder(new CharsetCharEncoder(Charset.forName(encoding))));
    }
 
+   public Charset getCharset()
+   {
+      return charEncoder.getCharset();
+   }
+
    public void encode(char c, OutputStream out) throws IOException
    {
-      byte[] bytes = charEncoder.encode(c);
-      out.write(bytes);
+      if (c > -1 && c < 128)
+      {
+         out.write((int)c);
+      }
+      else
+      {
+         byte[] bytes = charEncoder.encode(c);
+         switch (bytes.length)
+         {
+            case 0:
+               throw new AssertionError();
+            case 1:
+               out.write(bytes[0]);
+               break;
+            case 2:
+               out.write(bytes[0]);
+               out.write(bytes[1]);
+               break;
+            case 3:
+               out.write(bytes[0]);
+               out.write(bytes[1]);
+               out.write(bytes[2]);
+               break;
+            default:
+               out.write(bytes);
+         }
+      }
    }
 
    public void encode(char[] chars, int off, int len, OutputStream out) throws IOException
@@ -63,8 +93,7 @@
       for (int i = off; i < len; i++)
       {
          char c = chars[i];
-         byte[] bytes = charEncoder.encode(c);
-         out.write(bytes);
+         encode(c, out);
       }
    }
 
@@ -73,8 +102,7 @@
       for (int i = off; i < len; i++)
       {
          char c = str.charAt(i);
-         byte[] bytes = charEncoder.encode(c);
-         out.write(bytes);
+         encode(c, out);
       }
    }
 }

Modified: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/OutputStreamPrinter.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/OutputStreamPrinter.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/OutputStreamPrinter.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.charset.Charset;
 
 /**
  * <p>An extension of {@link Printer} that encodes the text with a provided encoder and sends the resulting
@@ -42,10 +43,13 @@
  *
  * </p>
  *
+ * <p>The class provides direct write access to the underlying output stream when the client of the stream can provides
+ * bytes directly.</p>
+ *
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
-public class OutputStreamPrinter extends Printer
+public class OutputStreamPrinter extends Printer implements BinaryOutput
 {
 
    private final IOFailureFlow failureFlow;
@@ -58,29 +62,68 @@
 
    private boolean failed;
 
+   private final boolean flushOnClose;
+
    /**
     * Builds an instance with the failureFlow being {@link IOFailureFlow#RETHROW} and
     * a the ignoreOnFailure property set to false.
     *
     * @param encoder the encoder
     * @param out the output
+    * @param flushOnClose flush when stream is closed
     * @throws IllegalArgumentException if any argument is null
     */
+   public OutputStreamPrinter(TextEncoder encoder, OutputStream out, boolean flushOnClose) throws IllegalArgumentException
+   {
+      this(encoder, out, IOFailureFlow.RETHROW, false, flushOnClose, 0);
+   }
+
+   /**
+    * Builds an instance with the failureFlow being {@link IOFailureFlow#RETHROW} and
+    * a the ignoreOnFailure property set to false.
+    *
+    * @param encoder the encoder
+    * @param out the output
+    * @param flushOnClose flush when stream is closed
+    * @param bufferSize the size of the buffer
+    * @throws IllegalArgumentException if any argument is null
+    */
+   public OutputStreamPrinter(TextEncoder encoder, OutputStream out, boolean flushOnClose, int bufferSize) throws IllegalArgumentException
+   {
+      this(encoder, out, IOFailureFlow.RETHROW, false, flushOnClose, bufferSize);
+   }
+
+   /**
+    * Builds an instance with the failureFlow being {@link IOFailureFlow#RETHROW} and
+    * a the ignoreOnFailure property set to false.
+    *
+    * @param encoder the encoder
+    * @param out the output
+    * @throws IllegalArgumentException if any argument is null
+    */
    public OutputStreamPrinter(TextEncoder encoder, OutputStream out) throws IllegalArgumentException
    {
-      this(encoder, out, IOFailureFlow.RETHROW, false);
+      this(encoder, out, IOFailureFlow.RETHROW, false, false, 0);
    }
 
    /**
-    * Builds a new instance.
+    * Builds a new instance with the specified parameters and the delegate output.
     *
     * @param encoder the encoder
     * @param out the output
     * @param failureFlow the control flow failureFlow
     * @param ignoreOnFailure the behavior on failure
+    * @param flushOnClose flush when stream is closed
+    * @param bufferSize the buffer size
     * @throws IllegalArgumentException if any argument is null
     */
-   public OutputStreamPrinter(TextEncoder encoder, OutputStream out, IOFailureFlow failureFlow, boolean ignoreOnFailure)
+   public OutputStreamPrinter(
+      TextEncoder encoder,
+      OutputStream out,
+      IOFailureFlow failureFlow,
+      boolean ignoreOnFailure,
+      boolean flushOnClose,
+      int bufferSize)
       throws IllegalArgumentException
    {
       if (encoder == null)
@@ -95,19 +138,37 @@
       {
          throw new IllegalArgumentException("No null control flow mode accepted");
       }
+      if (bufferSize < 0)
+      {
+         throw new IllegalArgumentException("Invalid negative max buffer size: " + bufferSize);
+      }
+
+      //
+      if (bufferSize > 0)
+      {
+         out = new BufferingOutputStream(out, bufferSize);
+      }
+
+      //
       this.encoder = encoder;
       this.out = out;
       this.failureFlow = failureFlow;
       this.failed = false;
       this.ignoreOnFailure = ignoreOnFailure;
+      this.flushOnClose = flushOnClose;
    }
 
+   public final Charset getCharset()
+   {
+      return encoder.getCharset();
+   }
+
    /**
     * Returns the failure flow.
     *
     * @return the failure flow
     */
-   public IOFailureFlow getFailureFlow()
+   public final IOFailureFlow getFailureFlow()
    {
       return failureFlow;
    }
@@ -117,18 +178,69 @@
     * 
     * @return the ignore on failure property
     */
-   public boolean getIgnoreOnFailure()
+   public final boolean getIgnoreOnFailure()
    {
       return ignoreOnFailure;
    }
 
-   public boolean isFailed()
+   public final boolean isFailed()
    {
       return failed;
    }
 
+   // Bytes access interface
+
+   public final void write(byte b) throws IOException
+   {
+      if (!failed)
+      {
+         try
+         {
+            out.write(b);
+         }
+         catch (IOException e)
+         {
+            handle(e);
+         }
+      }
+   }
+
+   public final void write(byte[] bytes) throws IOException
+   {
+      if (!failed)
+      {
+         try
+         {
+            out.write(bytes);
+         }
+         catch (IOException e)
+         {
+            handle(e);
+         }
+      }
+   }
+
+   public final void write(byte[] b, int off, int len) throws IOException
+   {
+      if (!failed)
+      {
+         try
+         {
+            out.write(b, off, len);
+         }
+         catch (IOException e)
+         {
+            handle(e);
+         }
+      }
+   }
+
+   //
+
    @Override
-   public void write(int c) throws IOException
+   // Note that the parent method has a synchronisation that we want to avoid
+   // for performance reasons
+   public final void write(int c) throws IOException
    {
       if (!failed)
       {
@@ -144,7 +256,7 @@
    }
 
    @Override
-   public void write(char[] cbuf) throws IOException
+   public final void write(char[] cbuf) throws IOException
    {
       if (!failed)
       {
@@ -160,7 +272,7 @@
    }
 
    @Override
-   public void write(String str) throws IOException
+   public final void write(String str) throws IOException
    {
       if (!failed)
       {
@@ -176,7 +288,9 @@
    }
 
    @Override
-   public void write(String str, int off, int len) throws IOException
+   // Note that the parent method has a synchronisation that we want to avoid
+   // for performance reasons
+   public final void write(String str, int off, int len) throws IOException
    {
       if (!failed)
       {
@@ -191,7 +305,7 @@
       }
    }
 
-   public void write(char[] cbuf, int off, int len) throws IOException
+   public final void write(char[] cbuf, int off, int len) throws IOException
    {
       if (!failed)
       {
@@ -206,9 +320,9 @@
       }
    }
 
-   public void flush() throws IOException
+   public final void flush() throws IOException
    {
-      if (!failed)
+      if (!failed && !flushOnClose)
       {
          try
          {
@@ -221,7 +335,7 @@
       }
    }
 
-   public void close() throws IOException
+   public final void close() throws IOException
    {
       try
       {

Modified: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Printer.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Printer.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Printer.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,53 +19,17 @@
 
 package org.exoplatform.commons.utils;
 
-import java.io.IOException;
 import java.io.Writer;
 
 /**
+ * Extend the writer class by providing various method for printing text.
+ *
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
 public abstract class Printer extends Writer
 {
-
    public Printer()
    {
    }
-
-   public void println(Object o)
-   {
-      print(o);
-      println();
-   }
-
-   public void println()
-   {
-      try
-      {
-         write('\n');
-      }
-      catch (IOException ignore)
-      {
-      }
-   }
-
-   public void print(Object o)
-   {
-      try
-      {
-         if (o instanceof Text)
-         {
-            ((Text)o).writeTo(this);
-         }
-         else
-         {
-            String s = String.valueOf(o);
-            write(s);
-         }
-      }
-      catch (IOException ignore)
-      {
-      }
-   }
 }
\ No newline at end of file

Modified: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/TableCharEncoder.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/TableCharEncoder.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/TableCharEncoder.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,8 @@
 
 package org.exoplatform.commons.utils;
 
+import java.nio.charset.Charset;
+
 /**
  * A char encoder that use a table to cache the result produced by a delegate char encoder. This encoder
  * is stateless and should only be composed with stateless char encoder otherwise an unexpected result
@@ -47,6 +49,11 @@
       this.table = new byte[MAX + 1][];
    }
 
+   public Charset getCharset()
+   {
+      return charEncoder.getCharset();
+   }
+
    public byte[] encode(char c)
    {
       byte[] bytes = table[c];

Modified: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Text.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Text.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/Text.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -20,11 +20,12 @@
 package org.exoplatform.commons.utils;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.nio.charset.Charset;
 
 /**
  * Represents text that can have several internal representations in order to minimize serialization when it is possible.
+ * The bytes returned by the byte oriented method must returned the data encoded with the UTF-8 encoding.
  *
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
@@ -36,12 +37,13 @@
     * Create a text object from the provided byte array.
     * 
     * @param bytes the markup as bytes
+    * @param charset the charset
     * @return the text object
     * @throws IllegalArgumentException if the bytes is null
     */
-   public static Text create(byte[] bytes) throws IllegalArgumentException
+   public static Text create(byte[] bytes, Charset charset) throws IllegalArgumentException
    {
-      return new Bytes(bytes);
+      return new Bytes(bytes, charset);
    }
 
    /**
@@ -61,7 +63,6 @@
     *
     * @param s the markup as bytes
     * @return the text object
-    * @todo provide an optimized subclass but it's not much used for now
     * @throws IllegalArgumentException if the string is null
     */
    public static Text create(String s) throws IllegalArgumentException
@@ -69,59 +70,46 @@
       return new Chars(s.toCharArray());
    }
 
-   public abstract byte[] getBytes();
-
-   public abstract char[] getChars();
-
-   public abstract void appendTo(Appendable appendable) throws IOException;
-
    public abstract void writeTo(Writer writer) throws IOException;
 
    private static class Bytes extends Text
    {
 
+      /** . */
       private final byte[] bytes;
 
-      private Bytes(byte[] bytes)
-      {
-         this.bytes = bytes;
-      }
+      /** . */
+      private final Charset charset;
 
-      public byte[] getBytes()
-      {
-         return bytes;
-      }
+      /** . */
+      private volatile String s;
 
-      public char[] getChars()
+      private Bytes(byte[] bytes, Charset charset)
       {
-         try
-         {
-            return new String(bytes, "utf-8").toCharArray();
-         }
-         catch (java.io.UnsupportedEncodingException e)
-         {
-            return new String(bytes).toCharArray();
-         }
+         this.bytes = bytes;
+         this.charset = charset;
       }
 
-      public void appendTo(Appendable appendable) throws IOException
+      public void writeTo(Writer writer) throws IOException
       {
-         for (char c : getChars())
+         if (writer instanceof BinaryOutput)
          {
-            appendable.append(c);
+            BinaryOutput osw = (BinaryOutput)writer;
+            if (charset.equals(osw.getCharset()))
+            {
+               osw.write(bytes);
+               return;
+            }
          }
-      }
-
-      public void writeTo(Writer writer) throws IOException
-      {
-         for (char c : getChars())
+         if (s == null)
          {
-            writer.append(c);
+            s = new String(bytes, charset.name());
          }
+         writer.append(s);
       }
    }
 
-   private static class Chars extends Text implements CharSequence
+   private static class Chars extends Text
    {
 
       /** Inclusive from index. */
@@ -147,73 +135,11 @@
          this.count = count;
       }
 
-      public byte[] getBytes()
-      {
-         String s = new String(chars, offset, count);
-         try
-         {
-            return s.getBytes("UTF-8");
-         }
-         catch (UnsupportedEncodingException e)
-         {
-            return s.getBytes();
-         }
-      }
-
-      public char[] getChars()
-      {
-         // Recompute the internal state
-         if (offset > 0 || count < chars.length)
-         {
-            char[] tmp = new char[count];
-            System.arraycopy(chars, offset, tmp, 0, count);
-            chars = tmp;
-            offset = 0;
-         }
-         return chars;
-      }
-
       public void writeTo(Writer writer) throws IOException
       {
          writer.write(chars, offset, count);
       }
 
-      public void appendTo(Appendable appendable) throws IOException
-      {
-         appendable.append(this);
-      }
-
-      public int length()
-      {
-         return count;
-      }
-
-      public char charAt(int index)
-      {
-         return chars[index - offset];
-      }
-
-      public CharSequence subSequence(int start, int end)
-      {
-         if (start < 0)
-         {
-            throw new ArrayIndexOutOfBoundsException("Start index cannot be negative");
-         }
-         if (end < 0)
-         {
-            throw new ArrayIndexOutOfBoundsException("End index cannot be negative");
-         }
-         if (start > end)
-         {
-            throw new ArrayIndexOutOfBoundsException("Start index cannot be greater than the end index");
-         }
-         if (end > count)
-         {
-            throw new ArrayIndexOutOfBoundsException("End index cannot be greater than the sequence length");
-         }
-         return new Chars(chars, offset + start, end - start);
-      }
-
       @Override
       public String toString()
       {

Modified: portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/TextEncoder.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/TextEncoder.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/main/java/org/exoplatform/commons/utils/TextEncoder.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.charset.Charset;
 
 /**
  * A text encoder that encodes text to an output stream. No assumptions must be made about the
@@ -32,6 +33,13 @@
 public interface TextEncoder
 {
 
+   /**
+    * Returns the charset that will perform the encoding.
+    *
+    * @return the charset for encoding
+    */
+   Charset getCharset();
+
    void encode(char c, OutputStream out) throws IOException;
 
    void encode(char[] chars, int off, int len, OutputStream out) throws IOException;

Deleted: portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/OutputStreamPrinterTestCase.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/OutputStreamPrinterTestCase.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/OutputStreamPrinterTestCase.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,312 +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.commons.utils;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.LinkedList;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class OutputStreamPrinterTestCase extends TestCase
-{
-
-   static final int NOOP = -1;
-
-   static final int WRITE = 0;
-
-   static final int FLUSH = 1;
-
-   static final int CLOSE = 2;
-
-   public void testIOExceptionBlocking()
-   {
-      internalTest(IOFailureFlow.RETHROW, true);
-   }
-
-   public void testUndeclaredIOExceptionBlocking()
-   {
-      internalTest(IOFailureFlow.THROW_UNDECLARED, true);
-   }
-
-   public void testIgnoreIOExceptionBlocking()
-   {
-      internalTest(IOFailureFlow.IGNORE, true);
-   }
-
-   public void testIOExceptionNoBlocking()
-   {
-      internalTest(IOFailureFlow.RETHROW, false);
-   }
-
-   public void testUndeclaredIOExceptionNoBlocking()
-   {
-      internalTest(IOFailureFlow.THROW_UNDECLARED, false);
-   }
-
-   public void testIgnoreIOExceptionNoBlocking()
-   {
-      internalTest(IOFailureFlow.IGNORE, false);
-   }
-
-   public void internalTest(IOFailureFlow mode, boolean blockOnFailure)
-   {
-      int writeAfterFailure = blockOnFailure ? NOOP : WRITE;
-      int flushAfterFailure = blockOnFailure ? NOOP : FLUSH;
-
-      //
-      TestOutputStream out = new TestOutputStream(true, mode, blockOnFailure);
-      out.write(mode);
-      out.assertOperation(WRITE).assertEmpty().wantFailure = false;
-      out.flush(IOFailureFlow.IGNORE);
-      out.assertOperation(flushAfterFailure).assertEmpty();
-      out.write(IOFailureFlow.IGNORE);
-      out.assertOperation(writeAfterFailure).assertEmpty();
-      out.close(IOFailureFlow.IGNORE);
-      out.assertOperation(CLOSE).assertEmpty();
-
-      //
-      out = new TestOutputStream(false, mode, blockOnFailure);
-      out.write(IOFailureFlow.IGNORE);
-      out.assertOperation(WRITE).assertEmpty().wantFailure = true;
-      out.flush(mode);
-      out.assertOperation(FLUSH).assertEmpty().wantFailure = false;
-      out.write(IOFailureFlow.IGNORE);
-      out.assertOperation(writeAfterFailure).assertEmpty();
-      out.close(IOFailureFlow.IGNORE);
-      out.assertOperation(CLOSE).assertEmpty();
-
-      //
-      out = new TestOutputStream(false, mode, blockOnFailure);
-      out.write(IOFailureFlow.IGNORE);
-      out.assertOperation(WRITE).assertEmpty();
-      out.flush(IOFailureFlow.IGNORE);
-      out.assertOperation(FLUSH).assertEmpty().wantFailure = true;
-      out.write(mode);
-      out.assertOperation(WRITE).assertEmpty().wantFailure = false;
-      out.close(IOFailureFlow.IGNORE);
-      out.assertOperation(CLOSE).assertEmpty();
-
-      //
-      out = new TestOutputStream(false, mode, blockOnFailure);
-      out.write(IOFailureFlow.IGNORE);
-      out.assertOperation(WRITE).assertEmpty();
-      out.flush(IOFailureFlow.IGNORE);
-      out.assertOperation(FLUSH).assertEmpty();
-      out.write(IOFailureFlow.IGNORE);
-      out.assertOperation(WRITE).assertEmpty().wantFailure = true;
-      out.close(mode);
-      out.assertOperation(CLOSE).assertEmpty();
-   }
-
-   private static class TestOutputStream extends OutputStream
-   {
-
-      boolean wantFailure = false;
-
-      final LinkedList<Integer> operations = new LinkedList<Integer>();
-
-      OutputStreamPrinter osp;
-
-      private TestOutputStream(boolean wantFailure, IOFailureFlow mode, boolean blockOnFailure)
-      {
-         this.wantFailure = wantFailure;
-         this.osp = new OutputStreamPrinter(CharsetTextEncoder.getUTF8(), this, mode, blockOnFailure);
-      }
-
-      public void write(int b) throws IOException
-      {
-         operations.add(WRITE);
-         if (wantFailure)
-         {
-            throw new IOException();
-         }
-      }
-
-      @Override
-      public void flush() throws IOException
-      {
-         operations.add(FLUSH);
-         if (wantFailure)
-         {
-            throw new IOException();
-         }
-      }
-
-      @Override
-      public void close() throws IOException
-      {
-         operations.add(CLOSE);
-         if (wantFailure)
-         {
-            throw new IOException();
-         }
-      }
-
-      public void write(IOFailureFlow mode)
-      {
-         switch (mode)
-         {
-            case RETHROW :
-               try
-               {
-                  osp.write("a");
-                  fail();
-               }
-               catch (IOException ignore)
-               {
-               }
-               break;
-            case THROW_UNDECLARED :
-               try
-               {
-                  osp.write("a");
-                  fail();
-               }
-               catch (UndeclaredIOException ignore)
-               {
-               }
-               catch (IOException expected)
-               {
-                  fail();
-               }
-               break;
-            case IGNORE :
-               try
-               {
-                  osp.write("a");
-               }
-               catch (UndeclaredIOException ignore)
-               {
-                  fail();
-               }
-               catch (IOException expected)
-               {
-                  fail();
-               }
-               break;
-         }
-      }
-
-      public void flush(IOFailureFlow mode)
-      {
-         switch (mode)
-         {
-            case RETHROW :
-               try
-               {
-                  osp.flush();
-                  fail();
-               }
-               catch (IOException ignore)
-               {
-               }
-               break;
-            case THROW_UNDECLARED :
-               try
-               {
-                  osp.flush();
-                  fail();
-               }
-               catch (UndeclaredIOException ignore)
-               {
-               }
-               catch (IOException e)
-               {
-                  fail();
-               }
-               break;
-            case IGNORE :
-               try
-               {
-                  osp.flush();
-               }
-               catch (IOException e)
-               {
-                  fail();
-               }
-               break;
-         }
-      }
-
-      public void close(IOFailureFlow mode)
-      {
-         switch (mode)
-         {
-            case RETHROW :
-               try
-               {
-                  osp.close();
-                  fail();
-               }
-               catch (IOException ignore)
-               {
-               }
-               break;
-            case THROW_UNDECLARED :
-               try
-               {
-                  osp.close();
-                  fail();
-               }
-               catch (UndeclaredIOException ignore)
-               {
-               }
-               catch (IOException e)
-               {
-                  fail();
-               }
-               break;
-            case IGNORE :
-               try
-               {
-                  osp.close();
-               }
-               catch (IOException e)
-               {
-                  fail();
-               }
-               break;
-         }
-      }
-
-      public TestOutputStream assertEmpty()
-      {
-         Assert.assertTrue(operations.isEmpty());
-         return this;
-      }
-
-      public TestOutputStream assertOperation(int operation)
-      {
-         if (operation != NOOP)
-         {
-            Assert.assertFalse(operations.isEmpty());
-            int actual = operations.removeFirst();
-            Assert.assertEquals(operation, actual);
-         }
-         return this;
-      }
-   }
-}

Deleted: portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/PrinterTestCase.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/PrinterTestCase.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/PrinterTestCase.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,135 +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.commons.utils;
-
-import junit.framework.TestCase;
-
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class PrinterTestCase extends TestCase
-{
-
-   private MyPrinter printer;
-
-   @Override
-   protected void setUp() throws Exception
-   {
-      printer = new MyPrinter();
-   }
-
-   @Override
-   protected void tearDown() throws Exception
-   {
-      printer = null;
-   }
-
-   public void testPrintNull()
-   {
-      printer.print(null);
-      assertEquals("null", printer.buffer.toString());
-   }
-
-   public void testPrint()
-   {
-      printer.print("foo");
-      assertEquals("foo", printer.buffer.toString());
-   }
-
-   public void testPrintlnNull()
-   {
-      printer.println(null);
-      assertEquals("null\n", printer.buffer.toString());
-   }
-
-   public void testPrintln()
-   {
-      printer.println("foo");
-      assertEquals("foo\n", printer.buffer.toString());
-   }
-
-   public void testPrintln2()
-   {
-      printer.println();
-      assertEquals("\n", printer.buffer.toString());
-   }
-
-   public void testWriteNull() throws IOException
-   {
-      try
-      {
-         printer.write((String)null);
-         fail();
-      }
-      catch (Exception ignore)
-      {
-         assertEquals("", printer.buffer.toString());
-      }
-      try
-      {
-         printer.write((String)null, 0, 10);
-         fail();
-      }
-      catch (Exception ignore)
-      {
-         assertEquals("", printer.buffer.toString());
-      }
-      try
-      {
-         printer.write((char[])null, 0, 10);
-         fail();
-      }
-      catch (Exception ignore)
-      {
-         assertEquals("", printer.buffer.toString());
-      }
-      try
-      {
-         printer.write((char[])null);
-         fail();
-      }
-      catch (Exception ignore)
-      {
-         assertEquals("", printer.buffer.toString());
-      }
-   }
-
-   private static class MyPrinter extends Printer
-   {
-
-      private StringBuffer buffer = new StringBuffer();
-
-      public void write(char[] cbuf, int off, int len) throws IOException
-      {
-         buffer.append(cbuf, off, len);
-      }
-
-      public void flush() throws IOException
-      {
-      }
-
-      public void close() throws IOException
-      {
-      }
-   }
-}

Deleted: portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/SafeTestCase.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/SafeTestCase.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/SafeTestCase.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,142 +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.commons.utils;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-import java.io.ByteArrayOutputStream;
-import java.io.Closeable;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class SafeTestCase extends TestCase
-{
-
-   public SafeTestCase()
-   {
-   }
-
-   public SafeTestCase(String s)
-   {
-      super(s);
-   }
-
-   public void testClose()
-   {
-      assertFalse(Safe.close(null));
-      assertTrue(Safe.close(new ByteArrayOutputStream()));
-      assertFalse(Safe.close(new Closeable()
-      {
-         public void close() throws IOException
-         {
-            throw new IOException();
-         }
-      }));
-      assertFalse(Safe.close(new Closeable()
-      {
-         public void close() throws IOException
-         {
-            throw new RuntimeException();
-         }
-      }));
-      final Error expectedError = new Error();
-      try
-      {
-         Safe.close(new Closeable()
-         {
-            public void close() throws IOException
-            {
-               throw expectedError;
-            }
-         });
-         fail();
-      }
-      catch (Error error)
-      {
-         assertSame(expectedError, error);
-      }
-   }
-
-   private static class Thrower
-   {
-
-      private final Throwable t;
-
-      private Thrower(Throwable t)
-      {
-         this.t = t;
-      }
-
-      @Override
-      public boolean equals(Object obj)
-      {
-         if (t instanceof Error)
-         {
-            throw ((Error)t);
-         }
-         if (t instanceof RuntimeException)
-         {
-            throw ((RuntimeException)t);
-         }
-         throw new AssertionFailedError();
-      }
-   }
-
-   public void testEquals()
-   {
-      Object o = new Object();
-      assertTrue(Safe.equals(o, o));
-      assertTrue(Safe.equals(null, null));
-      assertFalse(Safe.equals(new Object(), null));
-      assertFalse(Safe.equals(null, new Object()));
-      assertFalse(Safe.equals(new Object(), new Object()));
-      assertFalse(Safe.equals(new Thrower(new RuntimeException()), null));
-      assertFalse(Safe.equals(null, new Thrower(new RuntimeException())));
-      assertFalse(Safe.equals(new Object(), new Thrower(new RuntimeException())));
-      assertFalse(Safe.equals(new Thrower(new Error()), null));
-      assertFalse(Safe.equals(null, new Thrower(new Error())));
-      assertFalse(Safe.equals(new Object(), new Thrower(new Error())));
-      RuntimeException re = new RuntimeException();
-      Error er = new Error();
-      try
-      {
-         Safe.equals(new Thrower(er), new Object());
-         fail();
-      }
-      catch (Error e)
-      {
-         assertSame(er, e);
-      }
-      try
-      {
-         Safe.equals(new Thrower(re), new Object());
-         fail();
-      }
-      catch (RuntimeException e)
-      {
-         assertSame(re, e);
-      }
-   }
-
-}

Copied: portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestBufferingOutputStream.java (from rev 480, portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestBufferingOutputStream.java)
===================================================================
--- portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestBufferingOutputStream.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestBufferingOutputStream.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.commons.utils;
+
+import junit.framework.TestCase;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestBufferingOutputStream extends TestCase
+{
+
+   private ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+   private BufferingOutputStream out = new BufferingOutputStream(bytes, 5);
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      bytes = new ByteArrayOutputStream();
+      out = new BufferingOutputStream(bytes, 5);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      bytes = null;
+      out = null;
+   }
+
+   public void testCtorIAE()
+   {
+      try
+      {
+         new BufferingOutputStream(bytes, 0);
+      }
+      catch (IllegalArgumentException e)
+      {
+      }
+      try
+      {
+         new BufferingOutputStream(bytes, -1);
+      }
+      catch (IllegalArgumentException e)
+      {
+      }
+   }
+
+   public void testCtorNPE()
+   {
+      try
+      {
+         new BufferingOutputStream(null, 1);
+      }
+      catch (NullPointerException e)
+      {
+      }
+   }
+
+   public void testStreamClose() throws Exception
+   {
+      final AtomicBoolean closed = new AtomicBoolean(false);
+      BufferingOutputStream out = new BufferingOutputStream(new ByteArrayOutputStream()
+      {
+         @Override
+         public void close() throws IOException
+         {
+            closed.set(true);
+            super.close();
+         }
+      }, 1);
+      out.close();
+      assertTrue(closed.get());
+      try
+      {
+         out.write(0);
+      }
+      catch (IOException ignore)
+      {
+      }
+      try
+      {
+         out.write(new byte[]{0});
+      }
+      catch (IOException ignore)
+      {
+      }
+      try
+      {
+         out.flush();
+      }
+      catch (IOException ignore)
+      {
+      }
+      try
+      {
+         out.close();
+      }
+      catch (IOException ignore)
+      {
+      }
+   }
+
+   public void testFlush() throws Exception
+   {
+      out.write(0);
+      assertBytes();
+      out.flush();
+      assertBytes(0);
+      out.write(new byte[]{1, 2, 3, 4});
+      assertBytes();
+      out.close();
+      assertBytes(1, 2, 3, 4);
+   }
+
+   public void testWriteByte() throws Exception
+   {
+      out.write(0);
+      assertBytes();
+      out.close();
+      assertBytes(0);
+   }
+
+   public void testAlmostFill() throws Exception
+   {
+      out.write(new byte[]{0, 1, 2, 3});
+      assertBytes();
+      out.close();
+      assertBytes(0, 1, 2, 3);
+   }
+   
+   public void testFill() throws Exception
+   {
+      out.write(new byte[]{0, 1, 2, 3, 4});
+      assertBytes(0, 1, 2, 3, 4);
+      out.close();
+      assertBytes();
+   }
+
+   public void testBufferOverflowWithByte() throws Exception
+   {
+      out.write(new byte[]{0, 1, 2, 3});
+      assertBytes();
+      out.write(4);
+      assertBytes();
+      out.write(5);
+      assertBytes(0, 1, 2, 3, 4);
+      out.close();
+      assertBytes(5);
+   }
+   public void testBufferOverflowWithArray() throws Exception
+   {
+      out.write(new byte[]{0, 1, 2, 3});
+      assertBytes();
+      out.write(new byte[]{4});
+      assertBytes(0, 1, 2, 3);
+      out.close();
+      assertBytes(4);
+   }
+
+   public void testBufferOverflowWithLongArray() throws Exception
+   {
+      out.write(new byte[]{0, 1, 2, 3});
+      assertBytes();
+      out.write(new byte[]{4, 5, 6, 7, 8, 9});
+      assertBytes(0, 1, 2, 3, 4, 5, 6, 7, 8);
+      out.close();
+      assertBytes(9);
+   }
+
+   public void testBufferOverflowWithVeryLongArray() throws Exception
+   {
+      out.write(new byte[]{0, 1, 2, 3});
+      assertBytes();
+      out.write(new byte[]{4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14});
+      assertBytes(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
+      out.close();
+      assertBytes(14);
+   }
+
+   private void assertBytes(int... expectedBytes)
+   {
+      int len = expectedBytes.length;
+      assertEquals(len, bytes.size());
+      if (len > 0)
+      {
+         byte[] actualBytes = bytes.toByteArray();
+         for (int i = 0;i < len;i++)
+         {
+            int expectedByte = expectedBytes[i];
+            byte actualByte = actualBytes[i];
+            assertEquals("Was expecting byte at index " + i + " to be equals to " + expectedByte + " instead of " + actualByte, expectedByte, actualByte);
+         }
+         bytes.reset();
+      }
+   }
+
+}

Copied: portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestOutputStreamPrinter.java (from rev 480, portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestOutputStreamPrinter.java)
===================================================================
--- portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestOutputStreamPrinter.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestOutputStreamPrinter.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,312 @@
+/**
+ * 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.commons.utils;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestOutputStreamPrinter extends TestCase
+{
+
+   static final int NOOP = -1;
+
+   static final int WRITE = 0;
+
+   static final int FLUSH = 1;
+
+   static final int CLOSE = 2;
+
+   public void testIOExceptionBlocking()
+   {
+      internalTest(IOFailureFlow.RETHROW, true);
+   }
+
+   public void testUndeclaredIOExceptionBlocking()
+   {
+      internalTest(IOFailureFlow.THROW_UNDECLARED, true);
+   }
+
+   public void testIgnoreIOExceptionBlocking()
+   {
+      internalTest(IOFailureFlow.IGNORE, true);
+   }
+
+   public void testIOExceptionNoBlocking()
+   {
+      internalTest(IOFailureFlow.RETHROW, false);
+   }
+
+   public void testUndeclaredIOExceptionNoBlocking()
+   {
+      internalTest(IOFailureFlow.THROW_UNDECLARED, false);
+   }
+
+   public void testIgnoreIOExceptionNoBlocking()
+   {
+      internalTest(IOFailureFlow.IGNORE, false);
+   }
+
+   public void internalTest(IOFailureFlow mode, boolean blockOnFailure)
+   {
+      int writeAfterFailure = blockOnFailure ? NOOP : WRITE;
+      int flushAfterFailure = blockOnFailure ? NOOP : FLUSH;
+
+      //
+      TestOutputStream out = new TestOutputStream(true, mode, blockOnFailure);
+      out.write(mode);
+      out.assertOperation(WRITE).assertEmpty().wantFailure = false;
+      out.flush(IOFailureFlow.IGNORE);
+      out.assertOperation(flushAfterFailure).assertEmpty();
+      out.write(IOFailureFlow.IGNORE);
+      out.assertOperation(writeAfterFailure).assertEmpty();
+      out.close(IOFailureFlow.IGNORE);
+      out.assertOperation(CLOSE).assertEmpty();
+
+      //
+      out = new TestOutputStream(false, mode, blockOnFailure);
+      out.write(IOFailureFlow.IGNORE);
+      out.assertOperation(WRITE).assertEmpty().wantFailure = true;
+      out.flush(mode);
+      out.assertOperation(FLUSH).assertEmpty().wantFailure = false;
+      out.write(IOFailureFlow.IGNORE);
+      out.assertOperation(writeAfterFailure).assertEmpty();
+      out.close(IOFailureFlow.IGNORE);
+      out.assertOperation(CLOSE).assertEmpty();
+
+      //
+      out = new TestOutputStream(false, mode, blockOnFailure);
+      out.write(IOFailureFlow.IGNORE);
+      out.assertOperation(WRITE).assertEmpty();
+      out.flush(IOFailureFlow.IGNORE);
+      out.assertOperation(FLUSH).assertEmpty().wantFailure = true;
+      out.write(mode);
+      out.assertOperation(WRITE).assertEmpty().wantFailure = false;
+      out.close(IOFailureFlow.IGNORE);
+      out.assertOperation(CLOSE).assertEmpty();
+
+      //
+      out = new TestOutputStream(false, mode, blockOnFailure);
+      out.write(IOFailureFlow.IGNORE);
+      out.assertOperation(WRITE).assertEmpty();
+      out.flush(IOFailureFlow.IGNORE);
+      out.assertOperation(FLUSH).assertEmpty();
+      out.write(IOFailureFlow.IGNORE);
+      out.assertOperation(WRITE).assertEmpty().wantFailure = true;
+      out.close(mode);
+      out.assertOperation(CLOSE).assertEmpty();
+   }
+
+   private static class TestOutputStream extends OutputStream
+   {
+
+      boolean wantFailure = false;
+
+      final LinkedList<Integer> operations = new LinkedList<Integer>();
+
+      OutputStreamPrinter osp;
+
+      private TestOutputStream(boolean wantFailure, IOFailureFlow mode, boolean blockOnFailure)
+      {
+         this.wantFailure = wantFailure;
+         this.osp = new OutputStreamPrinter(CharsetTextEncoder.getUTF8(), this, mode, blockOnFailure, false, 0);
+      }
+
+      public void write(int b) throws IOException
+      {
+         operations.add(WRITE);
+         if (wantFailure)
+         {
+            throw new IOException();
+         }
+      }
+
+      @Override
+      public void flush() throws IOException
+      {
+         operations.add(FLUSH);
+         if (wantFailure)
+         {
+            throw new IOException();
+         }
+      }
+
+      @Override
+      public void close() throws IOException
+      {
+         operations.add(CLOSE);
+         if (wantFailure)
+         {
+            throw new IOException();
+         }
+      }
+
+      public void write(IOFailureFlow mode)
+      {
+         switch (mode)
+         {
+            case RETHROW :
+               try
+               {
+                  osp.write("a");
+                  fail();
+               }
+               catch (IOException ignore)
+               {
+               }
+               break;
+            case THROW_UNDECLARED :
+               try
+               {
+                  osp.write("a");
+                  fail();
+               }
+               catch (UndeclaredIOException ignore)
+               {
+               }
+               catch (IOException expected)
+               {
+                  fail();
+               }
+               break;
+            case IGNORE :
+               try
+               {
+                  osp.write("a");
+               }
+               catch (UndeclaredIOException ignore)
+               {
+                  fail();
+               }
+               catch (IOException expected)
+               {
+                  fail();
+               }
+               break;
+         }
+      }
+
+      public void flush(IOFailureFlow mode)
+      {
+         switch (mode)
+         {
+            case RETHROW :
+               try
+               {
+                  osp.flush();
+                  fail();
+               }
+               catch (IOException ignore)
+               {
+               }
+               break;
+            case THROW_UNDECLARED :
+               try
+               {
+                  osp.flush();
+                  fail();
+               }
+               catch (UndeclaredIOException ignore)
+               {
+               }
+               catch (IOException e)
+               {
+                  fail();
+               }
+               break;
+            case IGNORE :
+               try
+               {
+                  osp.flush();
+               }
+               catch (IOException e)
+               {
+                  fail();
+               }
+               break;
+         }
+      }
+
+      public void close(IOFailureFlow mode)
+      {
+         switch (mode)
+         {
+            case RETHROW :
+               try
+               {
+                  osp.close();
+                  fail();
+               }
+               catch (IOException ignore)
+               {
+               }
+               break;
+            case THROW_UNDECLARED :
+               try
+               {
+                  osp.close();
+                  fail();
+               }
+               catch (UndeclaredIOException ignore)
+               {
+               }
+               catch (IOException e)
+               {
+                  fail();
+               }
+               break;
+            case IGNORE :
+               try
+               {
+                  osp.close();
+               }
+               catch (IOException e)
+               {
+                  fail();
+               }
+               break;
+         }
+      }
+
+      public TestOutputStream assertEmpty()
+      {
+         Assert.assertTrue(operations.isEmpty());
+         return this;
+      }
+
+      public TestOutputStream assertOperation(int operation)
+      {
+         if (operation != NOOP)
+         {
+            Assert.assertFalse(operations.isEmpty());
+            int actual = operations.removeFirst();
+            Assert.assertEquals(operation, actual);
+         }
+         return this;
+      }
+   }
+}

Copied: portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestPrinter.java (from rev 480, portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestPrinter.java)
===================================================================
--- portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestPrinter.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestPrinter.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,137 @@
+/**
+ * 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.commons.utils;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestPrinter extends TestCase
+{
+
+   private MyPrinter printer;
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      printer = new MyPrinter();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      printer = null;
+   }
+
+/*
+   public void testPrintNull()
+   {
+      printer.print(null);
+      assertEquals("null", printer.buffer.toString());
+   }
+
+   public void testPrint()
+   {
+      printer.print("foo");
+      assertEquals("foo", printer.buffer.toString());
+   }
+
+   public void testPrintlnNull()
+   {
+      printer.println(null);
+      assertEquals("null\n", printer.buffer.toString());
+   }
+
+   public void testPrintln()
+   {
+      printer.println("foo");
+      assertEquals("foo\n", printer.buffer.toString());
+   }
+
+   public void testPrintln2()
+   {
+      printer.println();
+      assertEquals("\n", printer.buffer.toString());
+   }
+*/
+
+   public void testWriteNull() throws IOException
+   {
+      try
+      {
+         printer.write((String)null);
+         fail();
+      }
+      catch (Exception ignore)
+      {
+         assertEquals("", printer.buffer.toString());
+      }
+      try
+      {
+         printer.write((String)null, 0, 10);
+         fail();
+      }
+      catch (Exception ignore)
+      {
+         assertEquals("", printer.buffer.toString());
+      }
+      try
+      {
+         printer.write((char[])null, 0, 10);
+         fail();
+      }
+      catch (Exception ignore)
+      {
+         assertEquals("", printer.buffer.toString());
+      }
+      try
+      {
+         printer.write((char[])null);
+         fail();
+      }
+      catch (Exception ignore)
+      {
+         assertEquals("", printer.buffer.toString());
+      }
+   }
+
+   private static class MyPrinter extends Printer
+   {
+
+      private StringBuffer buffer = new StringBuffer();
+
+      public void write(char[] cbuf, int off, int len) throws IOException
+      {
+         buffer.append(cbuf, off, len);
+      }
+
+      public void flush() throws IOException
+      {
+      }
+
+      public void close() throws IOException
+      {
+      }
+   }
+}

Copied: portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestSafe.java (from rev 480, portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestSafe.java)
===================================================================
--- portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestSafe.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestSafe.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,142 @@
+/**
+ * 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.commons.utils;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestSafe extends TestCase
+{
+
+   public TestSafe()
+   {
+   }
+
+   public TestSafe(String s)
+   {
+      super(s);
+   }
+
+   public void testClose()
+   {
+      assertFalse(Safe.close(null));
+      assertTrue(Safe.close(new ByteArrayOutputStream()));
+      assertFalse(Safe.close(new Closeable()
+      {
+         public void close() throws IOException
+         {
+            throw new IOException();
+         }
+      }));
+      assertFalse(Safe.close(new Closeable()
+      {
+         public void close() throws IOException
+         {
+            throw new RuntimeException();
+         }
+      }));
+      final Error expectedError = new Error();
+      try
+      {
+         Safe.close(new Closeable()
+         {
+            public void close() throws IOException
+            {
+               throw expectedError;
+            }
+         });
+         fail();
+      }
+      catch (Error error)
+      {
+         assertSame(expectedError, error);
+      }
+   }
+
+   private static class Thrower
+   {
+
+      private final Throwable t;
+
+      private Thrower(Throwable t)
+      {
+         this.t = t;
+      }
+
+      @Override
+      public boolean equals(Object obj)
+      {
+         if (t instanceof Error)
+         {
+            throw ((Error)t);
+         }
+         if (t instanceof RuntimeException)
+         {
+            throw ((RuntimeException)t);
+         }
+         throw new AssertionFailedError();
+      }
+   }
+
+   public void testEquals()
+   {
+      Object o = new Object();
+      assertTrue(Safe.equals(o, o));
+      assertTrue(Safe.equals(null, null));
+      assertFalse(Safe.equals(new Object(), null));
+      assertFalse(Safe.equals(null, new Object()));
+      assertFalse(Safe.equals(new Object(), new Object()));
+      assertFalse(Safe.equals(new Thrower(new RuntimeException()), null));
+      assertFalse(Safe.equals(null, new Thrower(new RuntimeException())));
+      assertFalse(Safe.equals(new Object(), new Thrower(new RuntimeException())));
+      assertFalse(Safe.equals(new Thrower(new Error()), null));
+      assertFalse(Safe.equals(null, new Thrower(new Error())));
+      assertFalse(Safe.equals(new Object(), new Thrower(new Error())));
+      RuntimeException re = new RuntimeException();
+      Error er = new Error();
+      try
+      {
+         Safe.equals(new Thrower(er), new Object());
+         fail();
+      }
+      catch (Error e)
+      {
+         assertSame(er, e);
+      }
+      try
+      {
+         Safe.equals(new Thrower(re), new Object());
+         fail();
+      }
+      catch (RuntimeException e)
+      {
+         assertSame(re, e);
+      }
+   }
+
+}

Copied: portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestTextEncoder.java (from rev 480, portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestTextEncoder.java)
===================================================================
--- portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestTextEncoder.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TestTextEncoder.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,88 @@
+/**
+ * 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.commons.utils;
+
+import junit.framework.TestCase;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestTextEncoder extends TestCase
+{
+
+   public void testA() throws IOException
+   {
+      assertOK("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+      /*
+          assertOK("<>&\"\\=+");
+
+          // Chinese
+          assertOK(new String(new char[]{0x4EAC, 0x4EC5, 0x5C3D, 0x5F84, 0x60CA, 0x740E, 0x7579, 0x7D27, 0x7ECF, 0x8B66, 0x8C28, 0x9CB8}));
+
+          // Extended Roman
+          assertOK(new String(new char[]{0xEA, 0xFC, 0xE2, 0xCC}));
+
+          // Russian
+          assertOK(new String(new char[]{0x0433, 0x043E, 0x0432, 0x043E, 0x0440, 0x044E}));
+
+          // Greek
+          assertOK(new String(new char[]{0x0391, 0x03C5, 0x034, 0x03BF, 0x03C5}));
+      */
+   }
+
+   private void assertOK(String s) throws IOException
+   {
+      TextEncoder encoder = CharsetTextEncoder.getUTF8();
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      encoder.encode(s, 0, s.length(), baos);
+      baos.flush();
+      byte[] b1 = baos.toByteArray();
+
+      //
+      baos.reset();
+      OutputStreamWriter osw = new OutputStreamWriter(baos);
+      osw.write(s);
+      osw.close();
+      byte[] b2 = baos.toByteArray();
+
+      //
+      List<Byte> expected = toList(b2);
+      List<Byte> actual = toList(b1);
+      assertEquals(expected, actual);
+   }
+
+   private List<Byte> toList(byte[] bytes)
+   {
+      List<Byte> tmp = new ArrayList<Byte>(bytes.length);
+      for (byte aByte : bytes)
+      {
+         tmp.add(aByte);
+      }
+      return tmp;
+   }
+
+}

Deleted: portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TextEncoderTestCase.java
===================================================================
--- portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TextEncoderTestCase.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/common/src/test/java/org/exoplatform/commons/utils/TextEncoderTestCase.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,88 +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.commons.utils;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TextEncoderTestCase extends TestCase
-{
-
-   public void testA() throws IOException
-   {
-      assertOK("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
-      /*
-          assertOK("<>&\"\\=+");
-
-          // Chinese
-          assertOK(new String(new char[]{0x4EAC, 0x4EC5, 0x5C3D, 0x5F84, 0x60CA, 0x740E, 0x7579, 0x7D27, 0x7ECF, 0x8B66, 0x8C28, 0x9CB8}));
-
-          // Extended Roman
-          assertOK(new String(new char[]{0xEA, 0xFC, 0xE2, 0xCC}));
-
-          // Russian
-          assertOK(new String(new char[]{0x0433, 0x043E, 0x0432, 0x043E, 0x0440, 0x044E}));
-
-          // Greek
-          assertOK(new String(new char[]{0x0391, 0x03C5, 0x034, 0x03BF, 0x03C5}));
-      */
-   }
-
-   private void assertOK(String s) throws IOException
-   {
-      TextEncoder encoder = CharsetTextEncoder.getUTF8();
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      encoder.encode(s, 0, s.length(), baos);
-      baos.flush();
-      byte[] b1 = baos.toByteArray();
-
-      //
-      baos.reset();
-      OutputStreamWriter osw = new OutputStreamWriter(baos);
-      osw.write(s);
-      osw.close();
-      byte[] b2 = baos.toByteArray();
-
-      //
-      List<Byte> expected = toList(b2);
-      List<Byte> actual = toList(b1);
-      assertEquals(expected, actual);
-   }
-
-   private List<Byte> toList(byte[] bytes)
-   {
-      List<Byte> tmp = new ArrayList<Byte>(bytes.length);
-      for (byte aByte : bytes)
-      {
-         tmp.add(aByte);
-      }
-      return tmp;
-   }
-
-}

Modified: portal/branches/wsrp-integration/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java
===================================================================
--- portal/branches/wsrp-integration/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -25,7 +25,6 @@
 import org.exoplatform.portal.config.model.Container;
 import org.exoplatform.portal.config.model.Dashboard;
 import org.exoplatform.portal.config.model.gadget.GadgetId;
-import org.exoplatform.portal.pom.config.tasks.DashboardTask;
 import org.exoplatform.portal.webui.application.UIGadget;
 import org.exoplatform.portal.webui.application.UIPortlet;
 import org.exoplatform.portal.webui.container.UIContainer;
@@ -124,7 +123,7 @@
       Container dashboard;
       if (currentUIPortlet.getStorageId() != null)
       {
-         dashboard = service.execute(new DashboardTask.Load(currentUIPortlet.getStorageId())).getDashboard();
+         dashboard = service.loadDashboard(currentUIPortlet.getStorageId());
       }
       else
       {
@@ -461,7 +460,7 @@
       PortalDataMapper.toContainer(dashboard, uiRoot);
 
       // Get dashboard for merging
-      service.execute(new DashboardTask.Save(dashboard));
+      service.saveDashboard(dashboard);
    }
 
    public static class AddNewGadgetActionListener extends EventListener<UIDashboard>

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/conf/portal/configuration.xml
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/conf/portal/configuration.xml	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/conf/portal/configuration.xml	2009-11-04 20:32:31 UTC (rev 493)
@@ -36,11 +36,16 @@
   </component>
 
   <component>
-    <key>org.exoplatform.portal.config.DataStorage</key>
+    <key>org.exoplatform.portal.pom.data.ModelDataStorage</key>
     <type>org.exoplatform.portal.pom.config.POMDataStorage</type>
   </component>
-  
+
   <component>
+    <key>org.exoplatform.portal.config.DataStorage</key>
+    <type>org.exoplatform.portal.config.DataStorageImpl</type>
+  </component>
+
+  <component>
     <key>org.exoplatform.portal.config.UserACL</key>
     <type>org.exoplatform.portal.config.UserACL</type>   
     <init-params>	     

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/DataStorage.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -23,11 +23,11 @@
 import org.exoplatform.portal.application.PortletPreferences;
 import org.exoplatform.portal.config.model.ApplicationState;
 import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.Dashboard;
 import org.exoplatform.portal.config.model.ModelChange;
 import org.exoplatform.portal.config.model.Page;
 import org.exoplatform.portal.config.model.PageNavigation;
 import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.pom.config.POMTask;
 
 import java.util.Comparator;
 import java.util.List;
@@ -42,8 +42,6 @@
 public interface DataStorage
 {
 
-   public <T extends POMTask> T execute(T task) throws Exception;
-
    public void create(PortalConfig config) throws Exception;
 
    public void save(PortalConfig config) throws Exception;
@@ -109,4 +107,8 @@
    public <T> LazyPageList<T> find(Query<T> q, Comparator<T> sortComparator) throws Exception;
 
    public Container getSharedLayout() throws Exception;
+
+   public Dashboard loadDashboard(String dashboardId) throws Exception;
+
+   public void saveDashboard(Dashboard dashboard) throws Exception;
 }
\ No newline at end of file

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,289 @@
+/**
+ * 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.config;
+
+import org.exoplatform.commons.utils.LazyPageList;
+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.Container;
+import org.exoplatform.portal.config.model.Dashboard;
+import org.exoplatform.portal.config.model.ModelChange;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.pom.config.ModelDemarcation;
+import org.exoplatform.portal.pom.data.DashboardData;
+import org.exoplatform.portal.pom.data.ModelData;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.data.NavigationData;
+import org.exoplatform.portal.pom.data.NavigationKey;
+import org.exoplatform.portal.pom.data.PageData;
+import org.exoplatform.portal.pom.data.PageKey;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+
+import java.lang.reflect.Array;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class DataStorageImpl implements DataStorage, ModelDemarcation
+{
+
+   /** . */
+   private ModelDataStorage delegate;
+
+   public DataStorageImpl(ModelDataStorage delegate)
+   {
+      this.delegate = delegate;
+   }
+
+   public Page clonePage(String pageId, String clonedOwnerType, String clonedOwnerId, String clonedName) throws Exception
+   {
+      PageKey key = PageKey.create(pageId);
+      PageKey cloneKey = new PageKey(clonedOwnerType, clonedOwnerId, clonedName);
+      return new Page(delegate.clonePage(key, cloneKey));
+   }
+
+   public PageNavigation getPageNavigation(String ownerType, String id) throws Exception
+   {
+      NavigationData data = delegate.getPageNavigation(new NavigationKey(ownerType, id));
+      return data != null ? new PageNavigation(data) : null;
+   }
+
+   public void remove(Page page) throws Exception
+   {
+      delegate.remove(page.build());
+   }
+
+   public <S> S load(ApplicationState<S> state) throws Exception
+   {
+      return delegate.load(state);
+   }
+
+   public void create(Page page) throws Exception
+   {
+      delegate.create(page.build());
+   }
+
+   public PortletPreferences getPortletPreferences(String windowID) throws Exception
+   {
+      return delegate.getPortletPreferences(windowID);
+   }
+
+   public <S> ApplicationState<S> save(ApplicationState<S> state, S preferences) throws Exception
+   {
+      return delegate.save(state, preferences);
+   }
+
+   public Container getSharedLayout() throws Exception
+   {
+      return delegate.getSharedLayout();
+   }
+
+   public void save(PortalConfig config) throws Exception
+   {
+      delegate.save(config.build());
+   }
+
+   public void create(PortalConfig config) throws Exception
+   {
+      delegate.create(config.build());
+   }
+
+   public PortalConfig getPortalConfig(String portalName) throws Exception
+   {
+      return getPortalConfig(PortalConfig.PORTAL_TYPE, portalName);
+   }
+
+   public void save(PageNavigation navigation) throws Exception
+   {
+      delegate.save(navigation.build());
+   }
+
+   public void remove(PortalConfig config) throws Exception
+   {
+      delegate.remove(config.build());
+   }
+
+   public PageNavigation getPageNavigation(String fullId) throws Exception
+   {
+      NavigationKey key = NavigationKey.create(fullId);
+      NavigationData data = delegate.getPageNavigation(key);
+      return data != null ? new PageNavigation(data) : null;
+   }
+
+   public Page getPage(String pageId) throws Exception
+   {
+      PageKey key = PageKey.create(pageId);
+      PageData data = delegate.getPage(key);
+      return data != null ? new Page(data) : null;
+   }
+
+   public List<ModelChange> save(Page page) throws Exception
+   {
+      return delegate.save(page.build());
+   }
+
+   public void create(PageNavigation navigation) throws Exception
+   {
+      delegate.save(navigation.build());
+   }
+
+   private abstract class Bilto<O extends ModelObject, D extends ModelData>
+   {
+
+      final Query<O> q;
+
+      final Class<D> dataType;
+
+      Bilto(Query<O> q, Class<D> dataType)
+      {
+         this.q = q;
+         this.dataType = dataType;
+      }
+
+      protected abstract O create(D d);
+
+      LazyPageList<O> execute() throws Exception
+      {
+         Query<D> delegateQ = new Query<D>(q, dataType);
+         LazyPageList<D> r = delegate.find(delegateQ, null);
+         final List<D> list = r.getAll();
+         ListAccess<O> access = new ListAccess<O>()
+         {
+            public int getSize() throws Exception
+            {
+               return list.size();
+            }
+            public O[] load(int index, int length) throws Exception, IllegalArgumentException
+            {
+               O[] pages = (O[])Array.newInstance(q.getClassType(), length);
+               int i = 0;
+               for (D data : list.subList(index, index + length))
+               {
+                  pages[i++] = create(data);
+               }
+               return pages;
+            }
+         };
+         return new LazyPageList<O>(access, r.getPageSize());
+      }
+
+   }
+
+   public <T> LazyPageList<T> find(Query<T> q, Comparator<T> sortComparator) throws Exception
+   {
+      Class<T> type = q.getClassType();
+      if (type == Page.class)
+      {
+         Bilto<Page, PageData> bilto = new Bilto<Page, PageData>((Query<Page>)q, PageData.class)
+         {
+            @Override
+            protected Page create(PageData pageData)
+            {
+               return new Page(pageData);
+            }
+         };
+         return (LazyPageList<T>)bilto.execute();
+      }
+      else if (type == PageNavigation.class)
+      {
+         Bilto<PageNavigation, NavigationData> bilto = new Bilto<PageNavigation, NavigationData>((Query<PageNavigation>)q, NavigationData.class)
+         {
+            @Override
+            protected PageNavigation create(NavigationData page)
+            {
+               return new PageNavigation(page);
+            }
+         };
+         return (LazyPageList<T>)bilto.execute();
+      }
+      else if (type == PortalConfig.class)
+      {
+         Bilto<PortalConfig, PortalData> bilto = new Bilto<PortalConfig, PortalData>((Query<PortalConfig>)q, PortalData.class)
+         {
+            @Override
+            protected PortalConfig create(PortalData portalData)
+            {
+               return new PortalConfig(portalData);
+            }
+         };
+         return (LazyPageList<T>)bilto.execute();
+      }
+      else
+      {
+         throw new UnsupportedOperationException("Cannot query type " + type);
+      }
+   }
+
+   public <T> LazyPageList<T> find(Query<T> q) throws Exception
+   {
+      return find(q, null);
+   }
+
+   public void save(PortletPreferences portletPreferences) throws Exception
+   {
+      delegate.save(portletPreferences);
+   }
+
+   public PortalConfig getPortalConfig(String ownerType, String portalName) throws Exception
+   {
+      PortalKey key = new PortalKey(ownerType, portalName);
+      PortalData data = delegate.getPortalConfig(key);
+      return data != null ? new PortalConfig(data) : null;
+   }
+
+   public void remove(PageNavigation navigation) throws Exception
+   {
+      delegate.remove(navigation.build());
+   }
+
+   public Dashboard loadDashboard(String dashboardId) throws Exception
+   {
+      DashboardData data = delegate.loadDashboard(dashboardId);
+      return data != null ? new Dashboard(data) : null;
+   }
+
+   public void saveDashboard(Dashboard dashboard) throws Exception
+   {
+      delegate.saveDashboard(dashboard.build());
+   }
+
+   public void begin()
+   {
+      if (delegate instanceof ModelDemarcation)
+      {
+         ((ModelDemarcation)delegate).begin();
+      }
+   }
+
+   public void end(boolean save)
+   {
+      if (delegate instanceof ModelDemarcation)
+      {
+         ((ModelDemarcation)delegate).end(save);
+      }
+   }
+}

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/Query.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/Query.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/Query.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -55,6 +55,15 @@
       title_ = title;
    }
 
+   public Query(Query<?> that, Class<T> clazz)
+   {
+      ownerType_ = that.ownerType_;
+      ownerId_ = that.ownerId_;
+      classType_ = clazz;
+      name_ = that.name_;
+      title_ = that.title_;
+   }
+
    public String getOwnerType()
    {
       return ownerType_;
@@ -105,4 +114,35 @@
       this.title_ = title_;
    }
 
+   @Override
+   public String toString()
+   {
+      StringBuilder builder = new StringBuilder("Query[");
+      if (classType_ != null)
+      {
+         builder.append("class=").append(classType_.getSimpleName()).append(",");
+      }
+      if (ownerType_ != null)
+      {
+         builder.append("ownerType=").append(ownerType_).append(",");
+      }
+      if (ownerId_ != null)
+      {
+         builder.append("ownerId=").append(ownerId_).append(",");
+      }
+      if (name_ != null)
+      {
+         builder.append("name=").append(name_).append(",");
+      }
+      if (title_ != null)
+      {
+         builder.append("title=").append(title_).append(",");
+      }
+      if (builder.charAt(builder.length() - 1) == ',')
+      {
+         builder.setLength(builder.length() - 1);
+      }
+      builder.append(']');
+      return builder.toString();
+   }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,7 @@
 
 package org.exoplatform.portal.config;
 
+import org.exoplatform.commons.utils.PageList;
 import org.exoplatform.container.component.ComponentPlugin;
 import org.exoplatform.portal.config.model.Application;
 import org.exoplatform.portal.config.model.Container;
@@ -29,7 +30,7 @@
 import org.exoplatform.portal.config.model.PageNode;
 import org.exoplatform.portal.config.model.PortalConfig;
 import org.exoplatform.portal.config.model.TransientApplicationState;
-import org.exoplatform.portal.pom.config.POMDataStorage;
+import org.exoplatform.portal.pom.config.ModelDemarcation;
 import org.exoplatform.services.cache.CacheService;
 import org.exoplatform.services.cache.ExoCache;
 import org.exoplatform.services.cache.ExpireKeyStartWithSelector;
@@ -44,7 +45,9 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * Created by The eXo Platform SAS Apr 19, 2007 This service is used to load the
@@ -505,6 +508,75 @@
    }
 
    /**
+    * Load all navigation that user has edit permission.
+    *
+    * @return the navigation the user can edit
+    * @throws Exception any exception
+    */
+   public List<PageNavigation> loadEditableNavigations() throws Exception
+   {
+      Query<PageNavigation> query = new Query<PageNavigation>(PortalConfig.GROUP_TYPE, null, PageNavigation.class);
+      List<PageNavigation> navis = storage_.find(query, new Comparator<PageNavigation>()
+      {
+         public int compare(PageNavigation pconfig1, PageNavigation pconfig2)
+         {
+            return pconfig1.getOwnerId().compareTo(pconfig2.getOwnerId());
+         }
+      }).getAll();
+
+      //
+      List<PageNavigation> navigations = new ArrayList<PageNavigation>();
+      for (PageNavigation ele : navis)
+      {
+         if (userACL_.hasEditPermission(ele))
+         {
+            navigations.add(ele);
+         }
+      }
+      return navigations;
+   }
+
+   /**
+    * Returns the list of group ids that do not have an existing navigation.
+    *
+    * @return the group id with no navigation
+    * @throws Exception any exception
+    */
+   public Set<String> findGroupWithoutNavigation() throws Exception
+   {
+      Query<PageNavigation> query = new Query<PageNavigation>(PortalConfig.GROUP_TYPE, null, PageNavigation.class);
+      Set<String> groupIds = new HashSet<String>();
+      List<PageNavigation> navis = storage_.find(query).getAll();
+      for (PageNavigation ele : navis)
+      {
+         groupIds.add(ele.getOwnerId());
+      }
+      return groupIds;
+   }
+
+   /**
+    * Returns the list of all portal names.
+    *
+    * @return the list of all portal names
+    * @throws Exception any exception
+    */
+   public List<String> getAllPortalNames() throws Exception
+   {
+      List<String> list = new ArrayList<String>();
+      Query<PortalConfig> query = new Query<PortalConfig>("portal", null, null, null, PortalConfig.class);
+      PageList<PortalConfig> pageList = storage_.find(query);
+      List<PortalConfig> configs = pageList.getAll();
+      for (PortalConfig ele : configs)
+      {
+         if (userACL_.hasPermission(ele))
+         {
+            list.add(ele.getName());
+         }
+      }
+      return list;
+   }
+
+   /**
     * Update the ownership recursively on the model graph.
     *
     * @param object the model object graph root
@@ -566,22 +638,28 @@
             return;
 
          //
-         if (storage_ instanceof POMDataStorage)
+         if (storage_ instanceof ModelDemarcation)
          {
-            ((POMDataStorage)storage_).getPOMSessionManager().openSession();
+            ((ModelDemarcation)storage_).begin();
          }
 
          newPortalConfigListener_.run();
       }
       catch (Exception e)
       {
-         log.error("", e);
+         log.error("Could not import initial data", e);
+
+         //
+         if (storage_ instanceof ModelDemarcation)
+         {
+            ((ModelDemarcation)storage_).end(false);
+         }
       }
       finally
       {
-         if (storage_ instanceof POMDataStorage)
+         if (storage_ instanceof ModelDemarcation)
          {
-            ((POMDataStorage)storage_).getPOMSessionManager().closeSession(true);
+            ((ModelDemarcation)storage_).end(true);
          }
       }
    }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Application.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Application.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Application.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,10 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.data.ApplicationData;
+import org.exoplatform.portal.pom.data.ModelData;
+
 /**
  * May 13, 2004
  * @author: Tuan Nguyen
@@ -60,6 +64,31 @@
 
    private boolean isModifiable;
 
+   public Application(ApplicationData<S, I> data)
+   {
+      super(data.getStorageId());
+
+      // For now here, need to make a real NAME and
+      // remove disturbing storage name
+      this.storageName = data.getStorageName();
+
+      //
+      this.state = data.getState();
+      this.ref = data.getRef();
+      this.id = data.getId();
+      this.title = data.getTitle();
+      this.icon = data.getIcon();
+      this.description = data.getDescription();
+      this.showInfoBar = data.isShowInfoBar();
+      this.showApplicationState = data.isShowApplicationState();
+      this.showApplicationMode = data.isShowApplicationMode();
+      this.theme = data.getTheme();
+      this.width = data.getWidth();
+      this.height = data.getHeight();
+      this.properties = new Properties(data.getProperties());
+      this.accessPermissions = data.getAccessPermissions().toArray(new String[data.getAccessPermissions().size()]);
+   }
+
    public Application(String storageId, I ref)
    {
       super(storageId);
@@ -224,4 +253,27 @@
       this.theme = theme;
    }
 
+   @Override
+   public ModelData build()
+   {
+      return new ApplicationData<S,I>(
+         storageId,
+         storageName,
+         getType(),
+         state,
+         ref,
+         id,
+         title,
+         icon,
+         description,
+         showInfoBar,
+         showApplicationState,
+         showApplicationMode,
+         theme,
+         width,
+         height,
+         Utils.safeImmutableMap(properties),
+         Utils.safeImmutableList(accessPermissions)
+      );
+   }
 }
\ No newline at end of file

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Container.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Container.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Container.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,7 +19,14 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.ContainerData;
+import org.exoplatform.portal.pom.data.ModelData;
+
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * May 13, 2004
@@ -50,7 +57,7 @@
 
    protected String height;
 
-   private String[] accessPermissions;
+   protected String[] accessPermissions;
 
    protected ArrayList<ModelObject> children;
 
@@ -67,6 +74,32 @@
       this.children = new ArrayList<ModelObject>();
    }
 
+   public Container(ContainerData data)
+   {
+      super(data.getStorageId());
+
+      //
+      ArrayList<ModelObject> children = new ArrayList<ModelObject>();
+      for (ComponentData child : data.getChildren())
+      {
+         children.add(ModelObject.build(child));
+      }
+
+      //
+      this.id = data.getId();
+      this.name = data.getName();
+      this.icon = data.getIcon();
+      this.decorator = data.getDecorator();
+      this.template = data.getTemplate();
+      this.factoryId = data.getFactoryId();
+      this.title = data.getTitle();
+      this.description = data.getDescription();
+      this.width = data.getWidth();
+      this.height = data.getHeight();
+      this.accessPermissions = data.getAccessPermissions().toArray(new String[data.getAccessPermissions().size()]);
+      this.children = children;
+   }
+
    public String getId()
    {
       return id;
@@ -187,4 +220,43 @@
       this.accessPermissions = accessPermissions;
    }
 
+   @Override
+   public ContainerData build()
+   {
+      List<ComponentData> children = buildChildren();
+      return new ContainerData(
+         storageId,
+         id,
+         name,
+         icon,
+         decorator,
+         template,
+         factoryId,
+         title,
+         description,
+         width,
+         height,
+         Utils.safeImmutableList(accessPermissions),
+         children
+      );
+   }
+
+   protected List<ComponentData> buildChildren()
+   {
+      if (children != null && children.size() > 0)
+      {
+         ArrayList<ComponentData> dataChildren = new ArrayList<ComponentData>(children.size());
+         for (int i = 0;i < children.size();i++)
+         {
+            ModelObject node = children.get(i);
+            ModelData data = node.build();
+            dataChildren.add((ComponentData)data);
+         }
+         return Collections.unmodifiableList(dataChildren);
+      }
+      else
+      {
+         return Collections.emptyList();
+      }
+   }
 }
\ No newline at end of file

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Dashboard.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Dashboard.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Dashboard.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,12 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.DashboardData;
+
+import java.util.List;
+
 /**
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
@@ -26,6 +32,11 @@
 public class Dashboard extends Container
 {
 
+   public Dashboard(DashboardData data)
+   {
+      super(data);
+   }
+
    public Dashboard()
    {
    }
@@ -34,4 +45,25 @@
    {
       super(storageId);
    }
+
+   @Override
+   public DashboardData build()
+   {
+      List<ComponentData> children = buildChildren();
+      return new DashboardData(
+         storageId,
+         id,
+         name,
+         icon,
+         decorator,
+         template,
+         factoryId,
+         title,
+         description,
+         width,
+         height,
+         Utils.safeImmutableList(accessPermissions),
+         children
+      );
+   }
 }

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/MappedAttributes.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/MappedAttributes.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/MappedAttributes.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,126 +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.config.model;
-
-import org.gatein.mop.api.Key;
-import org.gatein.mop.api.ValueType;
-
-import java.util.Date;
-
-/**
- * A class to hold the various attributes mapped between the model and the mop layer.
- *
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class MappedAttributes
-{
-
-   private MappedAttributes()
-   {
-   }
-
-   /** . */
-   public static final Key<String> ID = Key.create("id", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> NAME = Key.create("name", ValueType.STRING);
-
-   /** . */
-   public static final Key<Boolean> SHOW_MAX_WINDOW = Key.create("show-max-window", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<String> TITLE = Key.create("title", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> FACTORY_ID = Key.create("factory-id", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> ACCESS_PERMISSIONS = Key.create("access-permissions", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> EDIT_PERMISSION = Key.create("edit-permission", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> CREATOR = Key.create("creator", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> MODIFIER = Key.create("modifier", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> DESCRIPTION = Key.create("description", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> DECORATOR = Key.create("decorator", ValueType.STRING);
-
-   /** . */
-   public static final Key<Integer> PRIORITY = Key.create("priority", ValueType.INTEGER);
-
-   /** . */
-   public static final Key<String> LABEL = Key.create("label", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> ICON = Key.create("icon", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> URI = Key.create("uri", ValueType.STRING);
-
-   /** . */
-   public static final Key<Date> START_PUBLICATION_DATE = Key.create("start-publication-date", ValueType.DATE);
-
-   /** . */
-   public static final Key<Date> END_PUBLICATION_DATE = Key.create("end-publication-date", ValueType.DATE);
-
-   /** . */
-   public static final Key<Boolean> VISIBLE = Key.create("visible", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<String> TEMPLATE = Key.create("template", ValueType.STRING);
-
-   /** . */
-   public static final Key<Boolean> SHOW_PUBLICATION_DATE = Key.create("show-publication-date", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<Boolean> SHOW_INFO_BAR = Key.create("show-info-bar", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<Boolean> SHOW_STATE = Key.create("show-state", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<Boolean> SHOW_MODE = Key.create("show-mode", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<String> LOCALE = Key.create("locale", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> SKIN = Key.create("skin", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> WIDTH = Key.create("width", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> HEIGHT = Key.create("height", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> TYPE = Key.create("type", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> THEME = Key.create("theme", ValueType.STRING);
-}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Mapper.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Mapper.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Mapper.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,1050 +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.config.model;
-
-import org.exoplatform.portal.config.model.gadget.GadgetApplication;
-import org.exoplatform.portal.config.model.portlet.PortletApplication;
-import org.exoplatform.portal.config.model.portlet.PortletId;
-import org.exoplatform.portal.config.model.wsrp.WSRPApplication;
-import org.exoplatform.portal.config.model.wsrp.WSRPId;
-import org.exoplatform.portal.pom.config.POMSession;
-import static org.exoplatform.portal.pom.config.Utils.join;
-import static org.exoplatform.portal.pom.config.Utils.split;
-import org.exoplatform.portal.pom.spi.gadget.Gadget;
-import org.exoplatform.portal.pom.spi.portlet.Preferences;
-import org.exoplatform.portal.pom.spi.wsrp.WSRP;
-import org.gatein.mop.api.Attributes;
-import org.gatein.mop.api.content.ContentType;
-import org.gatein.mop.api.content.Customization;
-import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Site;
-import org.gatein.mop.api.workspace.Workspace;
-import org.gatein.mop.api.workspace.WorkspaceObject;
-import org.gatein.mop.api.workspace.link.Link;
-import org.gatein.mop.api.workspace.link.PageLink;
-import org.gatein.mop.api.workspace.ui.UIBody;
-import org.gatein.mop.api.workspace.ui.UIComponent;
-import org.gatein.mop.api.workspace.ui.UIContainer;
-import org.gatein.mop.api.workspace.ui.UIWindow;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class Mapper
-{
-
-   /** . */
-   private static final Set<String> portalPropertiesBlackList = new HashSet<String>(Arrays.asList(
-      "jcr:uuid", "jcr:primaryType",
-      MappedAttributes.LOCALE.getName(), MappedAttributes.ACCESS_PERMISSIONS.getName(), MappedAttributes.EDIT_PERMISSION.getName(), MappedAttributes.SKIN.getName(),
-      MappedAttributes.TITLE.getName(), MappedAttributes.CREATOR.getName(), MappedAttributes.MODIFIER.getName()
-   ));
-
-   /** . */
-   private static final Set<String> windowPropertiesBlackList = new HashSet<String>(Arrays.asList(
-      "jcr:uuid", "jcr:primaryType",
-      MappedAttributes.TYPE.getName(), MappedAttributes.THEME.getName(), MappedAttributes.TITLE.getName(), MappedAttributes.ACCESS_PERMISSIONS.getName(), MappedAttributes.SHOW_INFO_BAR.getName(),
-      MappedAttributes.SHOW_STATE.getName(), MappedAttributes.SHOW_MODE.getName(), MappedAttributes.DESCRIPTION.getName(),
-      MappedAttributes.ICON.getName(), MappedAttributes.WIDTH.getName(), MappedAttributes.HEIGHT.getName()
-   ));
-
-   /** . */
-   private final POMSession session;
-
-   public Mapper(POMSession session)
-   {
-      this.session = session;
-   }
-
-   public PageNavigation load(Navigation src)
-   {
-      return load(src, PageNavigation.class);
-   }
-
-   private <T extends PageNodeContainer> T load(Navigation src, Class<T> type)
-   {
-      T dst;
-      if (type == PageNavigation.class)
-      {
-         PageNavigation dstNav = new PageNavigation(src.getObjectId());
-         Site site = src.getSite();
-         String ownerType = getOwnerType(site.getObjectType());
-         String ownerId = site.getName();
-         dstNav.setOwnerId(ownerId);
-         dstNav.setOwnerType(ownerType);
-         Attributes attrs = src.getAttributes();
-         dstNav.setCreator(attrs.getValue(MappedAttributes.CREATOR));
-         dstNav.setModifier(attrs.getValue(MappedAttributes.MODIFIER));
-         dstNav.setDescription(attrs.getValue(MappedAttributes.DESCRIPTION));
-         Integer priority = attrs.getValue(MappedAttributes.PRIORITY);
-         if (priority != null)
-         {
-            dstNav.setPriority(priority);
-         }
-         dst = (T)dstNav;
-      }
-      else if (type == PageNode.class)
-      {
-         PageNode dstNode = new PageNode(src.getObjectId());
-         Attributes attrs = src.getAttributes();
-         dstNode.setName(src.getName());
-         dstNode.setLabel(attrs.getValue(MappedAttributes.LABEL));
-         dstNode.setIcon(attrs.getValue(MappedAttributes.ICON));
-         dstNode.setUri(attrs.getValue(MappedAttributes.URI));
-         dstNode.setStartPublicationDate(attrs.getValue(MappedAttributes.START_PUBLICATION_DATE));
-         dstNode.setEndPublicationDate(attrs.getValue(MappedAttributes.END_PUBLICATION_DATE));
-         dstNode.setShowPublicationDate(attrs.getValue(MappedAttributes.SHOW_PUBLICATION_DATE));
-         dstNode.setVisible(attrs.getValue(MappedAttributes.VISIBLE));
-         dstNode.setChildren(new ArrayList<PageNode>());
-         Link link = src.getLink();
-         if (link instanceof PageLink)
-         {
-            PageLink pageLink = (PageLink)link;
-            org.gatein.mop.api.workspace.Page target = pageLink.getPage();
-            if (target != null)
-            {
-               Site site = target.getSite();
-               ObjectType<? extends Site> siteType = site.getObjectType();
-               String pageRef = getOwnerType(siteType) + "::" + site.getName() + "::" + target.getName();
-               dstNode.setPageReference(pageRef);
-            }
-         }
-         dst = (T)dstNode;
-      }
-      else
-      {
-         throw new AssertionError();
-      }
-
-      //
-      for (Navigation srcChild : src.getChildren())
-      {
-         PageNode dstChild = load(srcChild, PageNode.class);
-         dst.getNodes().add(dstChild);
-      }
-
-      //
-      return dst;
-   }
-
-   public void save(PageNavigation src, Navigation dst)
-   {
-      save((PageNodeContainer)src, dst);
-   }
-
-   private void save(PageNodeContainer src, Navigation dst)
-   {
-      if (src instanceof PageNode)
-      {
-         PageNode node = (PageNode)src;
-         Workspace workspace = dst.getSite().getWorkspace();
-         String reference = node.getPageReference();
-         if (reference != null)
-         {
-            String[] pageChunks = split("::", reference);
-            ObjectType<? extends Site> siteType = parseSiteType(pageChunks[0]);
-            Site site = workspace.getSite(siteType, pageChunks[1]);
-            org.gatein.mop.api.workspace.Page target = site.getRootPage().getChild("pages").getChild(pageChunks[2]);
-            PageLink link = dst.linkTo(ObjectType.PAGE_LINK);
-            link.setPage(target);
-         }
-
-         //
-         Attributes attrs = dst.getAttributes();
-         attrs.setValue(MappedAttributes.URI, node.getUri());
-         attrs.setValue(MappedAttributes.LABEL, node.getLabel());
-         attrs.setValue(MappedAttributes.ICON, node.getIcon());
-         attrs.setValue(MappedAttributes.START_PUBLICATION_DATE, node.getStartPublicationDate());
-         attrs.setValue(MappedAttributes.END_PUBLICATION_DATE, node.getEndPublicationDate());
-         attrs.setValue(MappedAttributes.SHOW_PUBLICATION_DATE, node.isShowPublicationDate());
-         attrs.setValue(MappedAttributes.VISIBLE, node.isVisible());
-      }
-      else if (src instanceof PageNavigation)
-      {
-         PageNavigation pageNav = (PageNavigation)src;
-
-         //
-         Attributes attrs = dst.getAttributes();
-         attrs.setValue(MappedAttributes.PRIORITY, pageNav.getPriority());
-         attrs.setValue(MappedAttributes.CREATOR, pageNav.getCreator());
-         attrs.setValue(MappedAttributes.MODIFIER, pageNav.getModifier());
-         attrs.setValue(MappedAttributes.DESCRIPTION, pageNav.getDescription());
-      }
-      else
-      {
-         throw new AssertionError();
-      }
-
-      //
-      Set<String> savedSet = new HashSet<String>();
-      if (src.getNodes() != null)
-      {
-         for (PageNode node : src.getNodes())
-         {
-            String srcId = node.getStorageId();
-            Navigation dstChild;
-            if (srcId != null)
-            {
-               dstChild = session.findObjectById(ObjectType.NAVIGATION, srcId);
-            }
-            else
-            {
-               dstChild = dst.getChild(node.getName());
-               if (dstChild == null)
-               {
-                  dstChild = dst.addChild(node.getName());
-               }
-               srcId = dstChild.getObjectId();
-            }
-            save(node, dstChild);
-            savedSet.add(srcId);
-         }
-         for (Iterator<? extends Navigation> i = dst.getChildren().iterator(); i.hasNext();)
-         {
-            Navigation dstChild = i.next();
-            if (!savedSet.contains(dstChild.getObjectId()))
-            {
-               i.remove();
-            }
-         }
-      }
-      else
-      {
-         dst.getChildren().clear();
-      }
-   }
-
-   public PortalConfig load(Site src)
-   {
-      String type = Mapper.getOwnerType(src.getObjectType());
-      PortalConfig dst = new PortalConfig(src.getObjectId(), type);
-      load(src, dst);
-      return dst;
-   }
-
-   private void load(Site src, PortalConfig dst)
-   {
-      dst.setName(src.getName());
-      Attributes attrs = src.getAttributes();
-      dst.setLocale(attrs.getValue(MappedAttributes.LOCALE));
-      dst.setAccessPermissions(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS)));
-      dst.setEditPermission(attrs.getValue(MappedAttributes.EDIT_PERMISSION));
-      dst.setSkin(attrs.getValue(MappedAttributes.SKIN));
-      dst.setTitle(attrs.getValue(MappedAttributes.TITLE));
-      dst.setCreator(attrs.getValue(MappedAttributes.CREATOR));
-      dst.setModifier(attrs.getValue(MappedAttributes.MODIFIER));
-      Properties properties = new Properties();
-      load(attrs, properties, portalPropertiesBlackList);
-      dst.setProperties(properties);
-
-      //
-      org.gatein.mop.api.workspace.Page template = src.getRootNavigation().getTemplate();
-      Container dstLayout = new Container();
-      UIContainer srcLayout = template.getRootComponent();
-
-      //
-      load(srcLayout, dstLayout);
-      loadChildren(srcLayout, dstLayout);
-
-      //
-      dst.setPortalLayout(dstLayout);
-   }
-
-   public void save(PortalConfig src, Site dst)
-   {
-      if (src.getStorageId() != null && !src.getStorageId().equals(dst.getObjectId()))
-      {
-         String msg = "Attempt to save a site " + src.getType() + "/" + src.getName() + " on the wrong target site " +
-            dst.getObjectType() + "/" + dst.getName();
-         throw new IllegalArgumentException(msg);
-      }
-
-
-      //
-      Attributes attrs = dst.getAttributes();
-      attrs.setValue(MappedAttributes.LOCALE, src.getLocale());
-      attrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
-      attrs.setValue(MappedAttributes.EDIT_PERMISSION, src.getEditPermission());
-      attrs.setValue(MappedAttributes.SKIN, src.getSkin());
-      attrs.setValue(MappedAttributes.TITLE, src.getTitle());
-      attrs.setValue(MappedAttributes.CREATOR, src.getCreator());
-      attrs.setValue(MappedAttributes.MODIFIER, src.getModifier());
-      if (src.getProperties() != null)
-      {
-         save(src.getProperties(), attrs);
-      }
-
-      //
-      org.gatein.mop.api.workspace.Page templates = dst.getRootPage().getChild("templates");
-      org.gatein.mop.api.workspace.Page template = templates.getChild("default");
-      if (template == null)
-      {
-         template = templates.addChild("default");
-      }
-
-      //
-      Container srcContainer = src.getPortalLayout();
-      UIContainer dstContainer = template.getRootComponent();
-
-      //
-      save(srcContainer, dstContainer);
-      saveChildren(srcContainer, dstContainer);
-
-      //
-      dst.getRootNavigation().setTemplate(template);
-   }
-
-   public Page load(org.gatein.mop.api.workspace.Page src)
-   {
-      Page dst = new Page(src.getRootComponent().getObjectId());
-      load(src, dst);
-      return dst;
-   }
-
-   private void load(org.gatein.mop.api.workspace.Page src, Page dst)
-   {
-      Site site = src.getSite();
-      String ownerType = getOwnerType(site.getObjectType());
-      String ownerId = site.getName();
-      String name = src.getName();
-      String pageId = join("::", ownerType, ownerId, name);
-
-      //
-      Attributes attrs = src.getAttributes();
-      dst.setId(pageId);
-      dst.setOwnerId(ownerId);
-      dst.setOwnerType(ownerType);
-      dst.setName(name);
-      dst.setTitle(attrs.getValue(MappedAttributes.TITLE));
-      dst.setShowMaxWindow(attrs.getValue(MappedAttributes.SHOW_MAX_WINDOW, false));
-      dst.setCreator(attrs.getValue(MappedAttributes.CREATOR));
-      dst.setModifier(attrs.getValue(MappedAttributes.MODIFIER));
-      dst.setAccessPermissions(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS)));
-      dst.setEditPermission(attrs.getValue(MappedAttributes.EDIT_PERMISSION));
-      dst.setFactoryId(attrs.getValue(MappedAttributes.FACTORY_ID));
-
-      //
-      loadChildren(src.getRootComponent(), dst);
-   }
-
-   public List<ModelChange> save(Page src, Site site, String name)
-   {
-      org.gatein.mop.api.workspace.Page root = site.getRootPage();
-      org.gatein.mop.api.workspace.Page pages = root.getChild("pages");
-      org.gatein.mop.api.workspace.Page dst = pages.getChild(name);
-
-      //
-      LinkedList<ModelChange> changes = new LinkedList<ModelChange>();
-
-      //
-      if (dst == null)
-      {
-         dst = pages.addChild(name);
-         changes.add(new ModelChange.Create(src));
-         src.storageId = dst.getObjectId();
-      }
-      else
-      {
-         changes.add(new ModelChange.Update(src));
-      }
-
-      //
-      Attributes attrs = dst.getAttributes();
-      attrs.setValue(MappedAttributes.TITLE, src.getTitle());
-      attrs.setValue(MappedAttributes.FACTORY_ID, src.getFactoryId());
-      attrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
-      attrs.setValue(MappedAttributes.EDIT_PERMISSION, src.getEditPermission());
-      attrs.setValue(MappedAttributes.SHOW_MAX_WINDOW, src.isShowMaxWindow());
-      attrs.setValue(MappedAttributes.CREATOR, src.getCreator());
-      attrs.setValue(MappedAttributes.MODIFIER, src.getModifier());
-
-      //
-      changes.addAll(saveChildren(src, dst.getRootComponent()));
-
-      //
-      return changes;
-   }
-
-   private void load(UIContainer src, Container dst)
-   {
-      Attributes attrs = src.getAttributes();
-      dst.setId(attrs.getValue(MappedAttributes.ID));
-      dst.setName(attrs.getValue(MappedAttributes.NAME));
-      dst.setTitle(attrs.getValue(MappedAttributes.TITLE));
-      dst.setIcon(attrs.getValue(MappedAttributes.ICON));
-      dst.setTemplate(attrs.getValue(MappedAttributes.TEMPLATE));
-      dst.setAccessPermissions(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS)));
-      dst.setFactoryId(attrs.getValue(MappedAttributes.FACTORY_ID));
-      dst.setDecorator(attrs.getValue(MappedAttributes.DECORATOR));
-      dst.setDescription(attrs.getValue(MappedAttributes.DESCRIPTION));
-      dst.setWidth(attrs.getValue(MappedAttributes.WIDTH));
-      dst.setHeight(attrs.getValue(MappedAttributes.HEIGHT));
-   }
-
-   private void loadChildren(UIContainer src, Container dst)
-   {
-      for (UIComponent component : src)
-      {
-
-         // Obtain a model object from the ui component
-         ModelObject mo;
-         if (component instanceof UIContainer)
-         {
-            UIContainer srcContainer = (UIContainer)component;
-            Attributes attrs = srcContainer.getAttributes();
-            String type = attrs.getValue(MappedAttributes.TYPE);
-            if ("dashboard".equals(type))
-            {
-               TransientApplicationState<Preferences> state = new TransientApplicationState<Preferences>();
-               Site owner = src.getPage().getSite();
-               state.setOwnerType(getOwnerType(owner.getObjectType()));
-               state.setOwnerId(owner.getName());
-               PortletApplication dashboardApp = new PortletApplication(srcContainer.getObjectId(), "dashboard", "DashboardPortlet");
-               dashboardApp.setStorageName(component.getName());
-               dashboardApp.setState(state);
-               dashboardApp.setShowInfoBar(false);
-               dashboardApp.setShowApplicationState(false);
-               mo = dashboardApp;
-            }
-            else
-            {
-               Container dstContainer = new Container(component.getObjectId());
-               load(srcContainer, dstContainer);
-               loadChildren(srcContainer, dstContainer);
-               mo = dstContainer;
-            }
-         }
-         else if (component instanceof UIWindow)
-         {
-            UIWindow window = (UIWindow)component;
-            Application application = load(window);
-            mo = application;
-         }
-         else if (component instanceof UIBody)
-         {
-            mo = new PageBody(component.getObjectId());
-         }
-         else
-         {
-            throw new AssertionError();
-         }
-
-         // Set the loaded name
-         mo.storageName = component.getName();
-
-         // Add among children
-         dst.getChildren().add(mo);
-      }
-   }
-
-   private void save(Container src, UIContainer dst)
-   {
-      Attributes dstAttrs = dst.getAttributes();
-      dstAttrs.setValue(MappedAttributes.ID, src.getId());
-      dstAttrs.setValue(MappedAttributes.TYPE, src instanceof Dashboard ? "dashboard" : null);
-      dstAttrs.setValue(MappedAttributes.TITLE, src.getTitle());
-      dstAttrs.setValue(MappedAttributes.ICON, src.getIcon());
-      dstAttrs.setValue(MappedAttributes.TEMPLATE, src.getTemplate());
-      dstAttrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
-      dstAttrs.setValue(MappedAttributes.FACTORY_ID, src.getFactoryId());
-      dstAttrs.setValue(MappedAttributes.DECORATOR, src.getDecorator());
-      dstAttrs.setValue(MappedAttributes.DESCRIPTION, src.getDescription());
-      dstAttrs.setValue(MappedAttributes.WIDTH, src.getWidth());
-      dstAttrs.setValue(MappedAttributes.HEIGHT, src.getHeight());
-      dstAttrs.setValue(MappedAttributes.NAME, src.getName());
-   }
-
-   private void save(ModelObject src, WorkspaceObject dst, LinkedList<ModelChange> changes, Map<String, String> hierarchyRelationships)
-   {
-      if (src instanceof Container)
-      {
-         save((Container)src, (UIContainer)dst);
-         saveChildren((Container)src, (UIContainer)dst, changes, hierarchyRelationships);
-      }
-      else if (src instanceof Application)
-      {
-         save((Application<?, ?>)src, (UIWindow)dst);
-      }
-      else if (src instanceof PageBody)
-      {
-         // Stateless
-      }
-      else
-      {
-         throw new AssertionError("Was not expecting child " + src);
-      }
-   }
-
-   /** . */
-   private static final PortletId DASHBOARD_ID = new PortletId("dashboard", "DashboardPortlet");
-
-   private LinkedList<ModelChange> saveChildren(final Container src, UIContainer dst)
-   {
-
-      //
-      LinkedList<ModelChange> changes = new LinkedList<ModelChange>();
-
-      //
-      Map<String, String> hierarchyRelationships = new HashMap<String, String>();
-
-      //
-      build(src, hierarchyRelationships);
-
-      //
-      saveChildren(src, dst, changes, Collections.unmodifiableMap(hierarchyRelationships));
-
-      //
-      return changes;
-   }
-
-   private void build(Container parent, Map<String, String> hierarchyRelationships)
-   {
-      String parentId = parent.getStorageId();
-      if (parentId != null)
-      {
-         for (ModelObject child : parent.getChildren())
-         {
-            String childId = child.getStorageId();
-            if (childId != null)
-            {
-               if (hierarchyRelationships.put(childId, parentId) != null)
-               {
-                  throw new AssertionError("The same object is present two times in the object hierarchy");
-               }
-               if (child instanceof Container)
-               {
-                  build((Container)child, hierarchyRelationships);
-               }
-            }
-         }
-      }
-   }
-
-   private void saveChildren(final Container src, UIContainer dst, LinkedList<ModelChange> changes, Map<String, String> hierarchyRelationships)
-   {
-      final List<String> orders = new ArrayList<String>();
-      final Map<String, ModelObject> modelObjectMap = new HashMap<String, ModelObject>();
-
-      //
-      for (ModelObject srcChild : src.getChildren())
-      {
-         String srcId = srcChild.getStorageId();
-
-         // Replace dashboard application by container if needed
-         if (srcChild instanceof Application)
-         {
-            Application app = (Application)srcChild;
-            if (app.getType() == ApplicationType.PORTLET)
-            {
-               PortletApplication portletApp = (PortletApplication)app;
-               if (DASHBOARD_ID.equals(portletApp.getRef()))
-               {
-                  if (app.storageId != null)
-                  {
-                     UIContainer dstDashboard = session.findObjectById(ObjectType.CONTAINER, app.storageId);
-                     Dashboard srcDashboard = new Dashboard(app.storageId);
-                     load(dstDashboard, srcDashboard);
-                     loadChildren(dstDashboard, srcDashboard);
-                     srcChild = srcDashboard;
-                  }
-                  else
-                  {
-                     Dashboard dashboard = new Dashboard();
-                     dashboard.setTemplate("classpath:groovy/dashboard/webui/component/UIColumnContainer.gtmpl");
-                     for (int i = 0; i < 3; i++)
-                     {
-                        Container row = new Container();
-                        row.setTemplate("classpath:groovy/dashboard/webui/component/UIContainer.gtmpl");
-                        dashboard.getChildren().add(row);
-                     }
-                     srcChild = dashboard;
-                  }
-               }
-            }
-         }
-
-         //
-         UIComponent dstChild;
-         if (srcId != null)
-         {
-            dstChild = session.findObjectById(ObjectType.COMPONENT, srcId);
-            if (dstChild == null)
-            {
-               throw new AssertionError("Could not find supposed present child with id " + srcId);
-            }
-            // julien : this can fail due to a bug in chromattic not implementing equals method properly
-            // and is replaced with the foreach below
-/*
-        if (!dst.contains(dstChild)) {
-          throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild) +
-            "that is not present in the target ui container " + session.pathOf(dst));
-        }
-*/
-            boolean found = false;
-            for (UIComponent child : dst)
-            {
-               if (child.getObjectId().equals(srcId))
-               {
-                  found = true;
-                  break;
-               }
-            }
-            if (!found)
-            {
-               if (hierarchyRelationships.containsKey(srcId))
-               {
-                  // It's a move operation, so we move the node first
-                  dst.add(dstChild);
-               }
-               else
-               {
-                  throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild) +
-                     "that is not present in the target ui container " + session.pathOf(dst));
-               }
-            }
-
-            //
-            changes.add(new ModelChange.Update(srcChild));
-         }
-         else
-         {
-            String name = srcChild.getStorageName();
-            if (name == null)
-            {
-               // We manufacture one name
-               name = UUID.randomUUID().toString();
-            }
-            if (srcChild instanceof Container)
-            {
-               dstChild = dst.add(ObjectType.CONTAINER, name);
-            }
-            else if (srcChild instanceof Application)
-            {
-               dstChild = dst.add(ObjectType.WINDOW, name);
-            }
-            else if (srcChild instanceof PageBody)
-            {
-               dstChild = dst.add(ObjectType.BODY, name);
-            }
-            else
-            {
-               throw new AssertionError("Was not expecting child " + srcChild);
-            }
-            srcChild.storageId = dstChild.getObjectId();
-            srcChild.storageName = name;
-            changes.add(new ModelChange.Create(srcChild));
-         }
-
-         //
-         save(srcChild, dstChild, changes, hierarchyRelationships);
-
-         //
-         String dstId = dstChild.getObjectId();
-         modelObjectMap.put(dstId, srcChild);
-         orders.add(dstId);
-      }
-
-      // Take care of move operation that could be seen as a remove
-      for (UIComponent dstChild : dst)
-      {
-         String dstId = dstChild.getObjectId();
-         if (!modelObjectMap.containsKey(dstId) && hierarchyRelationships.containsKey(dstId))
-         {
-            String parentId = hierarchyRelationships.get(dstId);
-
-            // Get the new parent
-            UIContainer parent = session.findObjectById(ObjectType.CONTAINER, parentId);
-
-            // Perform the move
-            parent.add(dstChild);
-
-            //
-            changes.add(new ModelChange.Destroy(dstId));
-         }
-      }
-
-      // Delete removed children
-      for (Iterator<UIComponent> i = dst.iterator(); i.hasNext();)
-      {
-         UIComponent dstChild = i.next();
-         String dstId = dstChild.getObjectId();
-         if (!modelObjectMap.containsKey(dstId))
-         {
-            i.remove();
-            changes.add(new ModelChange.Destroy(dstId));
-         }
-      }
-
-      // Now sort children according to the order provided by the container
-      // need to replace that with Collections.sort once the set(int index, E element) is implemented in Chromattic lists
-      UIComponent[] a = dst.toArray(new UIComponent[dst.size()]);
-      Arrays.sort(a, new Comparator<UIComponent>()
-      {
-         public int compare(UIComponent o1, UIComponent o2)
-         {
-            int i1 = orders.indexOf(o1.getObjectId());
-            int i2 = orders.indexOf(o2.getObjectId());
-            return i1 - i2;
-         }
-      });
-      for (int j = 0; j < a.length; j++)
-      {
-         dst.add(j, a[j]);
-      }
-   }
-
-   private <S, I> Application<S, I> load(UIWindow src)
-   {
-      Attributes attrs = src.getAttributes();
-
-      //
-      Customization<?> customization = src.getCustomization();
-
-      //
-      ContentType<?> contentType = customization.getType();
-
-      //
-      String customizationid = customization.getId();
-
-      //
-      String contentId = customization.getContentId();
-
-      //
-      Application<S, I> dst;
-      if (contentType == null || contentType == Preferences.CONTENT_TYPE)
-      {
-         int pos = contentId.indexOf('/');
-         String applicationName = contentId.substring(0, pos);
-         String portletName = contentId.substring(pos + 1);
-         @SuppressWarnings("unchecked") Application<S, I> application = (Application<S, I>)new PortletApplication(src.getObjectId(), applicationName, portletName);
-         dst = application;
-      }
-      else if (contentType == Gadget.CONTENT_TYPE)
-      {
-         @SuppressWarnings("unchecked") Application<S, I> application = (Application<S, I>)new GadgetApplication(src.getObjectId(), contentId);
-         dst = application;
-      }
-      else if (contentType == WSRP.CONTENT_TYPE)
-      {
-         @SuppressWarnings("unchecked") Application<S, I> application = (Application<S, I>)new WSRPApplication(src.getObjectId(), new WSRPId(contentId));
-         dst = application;
-      }
-      else
-      {
-         throw new AssertionError("Unknown type: " + contentType);
-      }
-
-      //
-      dst.setTheme(attrs.getValue(MappedAttributes.THEME));
-      dst.setTitle(attrs.getValue(MappedAttributes.TITLE));
-      dst.setAccessPermissions(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS)));
-      dst.setShowInfoBar(attrs.getValue(MappedAttributes.SHOW_INFO_BAR));
-      dst.setShowApplicationState(attrs.getValue(MappedAttributes.SHOW_STATE));
-      dst.setShowApplicationMode(attrs.getValue(MappedAttributes.SHOW_MODE));
-      dst.setDescription(attrs.getValue(MappedAttributes.DESCRIPTION));
-      dst.setIcon(attrs.getValue(MappedAttributes.ICON));
-      dst.setWidth(attrs.getValue(MappedAttributes.WIDTH));
-      dst.setHeight(attrs.getValue(MappedAttributes.HEIGHT));
-      load(attrs, dst.getProperties(), windowPropertiesBlackList);
-
-      //
-      PersistentApplicationState<S> instanceState = new PersistentApplicationState<S>(customizationid);
-
-      //
-      dst.setState(instanceState);
-
-      //
-      return dst;
-   }
-
-   public <S, I> void save(Application<S, I> src, UIWindow dst)
-   {
-      Attributes attrs = dst.getAttributes();
-      attrs.setValue(MappedAttributes.THEME, src.getTheme());
-      attrs.setValue(MappedAttributes.TITLE, src.getTitle());
-      attrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
-      attrs.setValue(MappedAttributes.SHOW_INFO_BAR, src.getShowInfoBar());
-      attrs.setValue(MappedAttributes.SHOW_STATE, src.getShowApplicationState());
-      attrs.setValue(MappedAttributes.SHOW_MODE, src.getShowApplicationMode());
-      attrs.setValue(MappedAttributes.DESCRIPTION, src.getDescription());
-      attrs.setValue(MappedAttributes.ICON, src.getIcon());
-      attrs.setValue(MappedAttributes.WIDTH, src.getWidth());
-      attrs.setValue(MappedAttributes.HEIGHT, src.getHeight());
-      save(src.getProperties(), attrs);
-
-      //
-      ApplicationState<S> instanceState = src.getState();
-
-      // We modify only transient portlet state
-      // and we ignore any persistent portlet state
-      if (instanceState instanceof TransientApplicationState)
-      {
-
-         //
-         TransientApplicationState<S> transientState = (TransientApplicationState<S>)instanceState;
-
-         // Attempt to get a site from the instance state
-         Site site = null;
-         if (transientState.getOwnerType() != null && transientState.getOwnerId() != null)
-         {
-            ObjectType<Site> siteType = parseSiteType(transientState.getOwnerType());
-            site = session.getWorkspace().getSite(siteType, transientState.getOwnerId());
-         }
-
-         // The current site
-         Site currentSite = dst.getPage().getSite();
-
-         // If it is the same site than the current page
-         // set null
-         if (site == dst.getPage().getSite())
-         {
-            site = null;
-         }
-
-         // The content id
-         String contentId;
-         ContentType<S> contentType = src.getType().getContentType();
-         if (contentType == Preferences.CONTENT_TYPE)
-         {
-            PortletApplication portletApp = (PortletApplication)src;
-            contentId = portletApp.getRef().getApplicationName() + "/" + portletApp.getRef().getPortletName();
-         }
-         else if (contentType == Gadget.CONTENT_TYPE)
-         {
-            GadgetApplication gadgetApp = (GadgetApplication)src;
-            contentId = gadgetApp.getRef().getGadgetName();
-         }
-         else if (contentType == WSRP.CONTENT_TYPE)
-         {
-            WSRPApplication wsrpApp = (WSRPApplication)src;
-            contentId = wsrpApp.getRef().getUri();
-         }
-         else
-         {
-            throw new UnsupportedOperationException("Unsupported content type");
-         }
-
-         // The customization that we will inherit from if not null
-         Customization<?> customization = null;
-
-         // Now inspect the unique id
-         String uniqueId = transientState.getUniqueId();
-         if (uniqueId != null)
-         {
-
-            // This is a customized window
-            if (uniqueId.startsWith("@"))
-            {
-               String id = uniqueId.substring(1);
-
-               // It's another window, we get its customization
-               if (!dst.getObjectId().equals(id))
-               {
-                  UIWindow window = session.findObjectById(ObjectType.WINDOW, id);
-                  Customization<?> windowCustomization = window.getCustomization();
-                  if (windowCustomization.getType().equals(contentType))
-                  {
-                     customization = windowCustomization;
-                  }
-               }
-            }
-            else
-            {
-               int pos = uniqueId.indexOf('#');
-               if (pos == -1)
-               {
-
-                  // If it's a different site than the page one (it has to be at this point)
-                  // then we get its customization
-                  if (site != null)
-                  {
-                     customization = site.getCustomization(uniqueId);
-                  }
-                  else
-                  {
-                     customization = currentSite.getCustomization(uniqueId);
-
-                     // If it does not exist we create it
-                     if (customization == null)
-                     {
-                        customization = currentSite.customize(uniqueId, contentType, contentId, null);
-                     }
-                  }
-               }
-               else
-               {
-
-                  // Otherwise we get the page customization
-                  String a = uniqueId.substring(0, pos);
-                  String b = uniqueId.substring(pos + 1);
-                  org.gatein.mop.api.workspace.Page page = site.getRootPage().getChild("pages").getChild(b);
-                  customization = page.getCustomization(a);
-               }
-            }
-         }
-
-         // Destroy existing window previous customization
-         if (dst.getCustomization() != null)
-         {
-            dst.getCustomization().destroy();
-         }
-
-         // If the existing customization is not null and matches the content id
-         Customization<S> dstCustomization;
-         if (customization != null && customization.getType().equals(contentType) && customization.getContentId().equals(contentId))
-         {
-
-            // Cast is ok as content type matches
-            @SuppressWarnings("unchecked") Customization<S> bilto = (Customization<S>)customization;
-
-            // If it's a customization of the current site we extend it
-            if (bilto.getContext() == currentSite)
-            {
-               dstCustomization = dst.customize(bilto);
-            }
-            else
-            {
-               // Otherwise we clone it propertly
-               S state = bilto.getVirtualState();
-               dstCustomization = dst.customize(contentType, contentId, state);
-            }
-         }
-         else
-         {
-            // Otherwise we create an empty customization
-            dstCustomization = dst.customize(contentType, contentId, null);
-         }
-
-         // At this point we have customized the window
-         // now if we have any additional state payload we must merge it
-         // with the current state
-         S state = ((TransientApplicationState<S>)instanceState).getContentState();
-         if (state != null)
-         {
-            dstCustomization.setState(state);
-         }
-      }
-   }
-
-   public Dashboard loadDashboard(UIContainer container)
-   {
-      Dashboard dashboard = new Dashboard(container.getObjectId());
-      load(container, dashboard);
-      loadChildren(container, dashboard);
-      return dashboard;
-   }
-
-   public void saveDashboard(Dashboard dashboard, UIContainer dst)
-   {
-      save(dashboard, dst);
-      saveChildren(dashboard, dst);
-   }
-
-   public static String[] parseWindowId(String windowId)
-   {
-      int i0 = windowId.indexOf("#");
-      int i1 = windowId.indexOf(":/", i0 + 1);
-      String ownerType = windowId.substring(0, i0);
-      String ownerId = windowId.substring(i0 + 1, i1);
-      String persistenceid = windowId.substring(i1 + 2);
-      String[] chunks = split("/", 2, persistenceid);
-      chunks[0] = ownerType;
-      chunks[1] = ownerId;
-      return chunks;
-   }
-
-   private static void load(Attributes src, Properties dst, Set<String> blackList)
-   {
-      for (String name : src.getKeys())
-      {
-         if (!blackList.contains(name))
-         {
-            Object value = src.getObject(name);
-            if (value instanceof String)
-            {
-               dst.setProperty(name, (String)value);
-            }
-         }
-      }
-   }
-
-   public static void save(Properties src, Attributes dst)
-   {
-      for (Map.Entry<String, String> property : src.entrySet())
-      {
-         dst.setString(property.getKey(), property.getValue());
-      }
-   }
-
-   public static String getOwnerType(ObjectType<? extends Site> siteType)
-   {
-      if (siteType == ObjectType.PORTAL_SITE)
-      {
-         return PortalConfig.PORTAL_TYPE;
-      }
-      else if (siteType == ObjectType.GROUP_SITE)
-      {
-         return PortalConfig.GROUP_TYPE;
-      }
-      else if (siteType == ObjectType.USER_SITE)
-      {
-         return PortalConfig.USER_TYPE;
-      }
-      else
-      {
-         throw new IllegalArgumentException("Invalid site type " + siteType);
-      }
-   }
-
-   public static ObjectType<Site> parseSiteType(String ownerType)
-   {
-      if (ownerType.equals(PortalConfig.PORTAL_TYPE))
-      {
-         return ObjectType.PORTAL_SITE;
-      }
-      else if (ownerType.equals(PortalConfig.GROUP_TYPE))
-      {
-         return ObjectType.GROUP_SITE;
-      }
-      else if (ownerType.equals(PortalConfig.USER_TYPE))
-      {
-         return ObjectType.USER_SITE;
-      }
-      else
-      {
-         throw new IllegalArgumentException("Invalid owner type " + ownerType);
-      }
-   }
-}

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/ModelChange.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/ModelChange.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/ModelChange.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,8 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.data.ModelData;
+
 /**
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
@@ -30,14 +32,14 @@
    {
 
       /** . */
-      private final ModelObject object;
+      private final ModelData object;
 
-      public Create(ModelObject object)
+      public Create(ModelData object)
       {
          this.object = object;
       }
 
-      public ModelObject getObject()
+      public ModelData getObject()
       {
          return object;
       }
@@ -47,14 +49,14 @@
    {
 
       /** . */
-      private final ModelObject object;
+      private final ModelData object;
 
-      public Update(ModelObject object)
+      public Update(ModelData object)
       {
          this.object = object;
       }
 
-      public ModelObject getObject()
+      public ModelData getObject()
       {
          return object;
       }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/ModelObject.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/ModelObject.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/ModelObject.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,21 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.config.model.gadget.GadgetApplication;
+import org.exoplatform.portal.config.model.gadget.GadgetId;
+import org.exoplatform.portal.config.model.portlet.PortletApplication;
+import org.exoplatform.portal.config.model.portlet.PortletId;
+import org.exoplatform.portal.config.model.wsrp.WSRPApplication;
+import org.exoplatform.portal.config.model.wsrp.WSRPId;
+import org.exoplatform.portal.pom.data.ApplicationData;
+import org.exoplatform.portal.pom.data.BodyData;
+import org.exoplatform.portal.pom.data.ContainerData;
+import org.exoplatform.portal.pom.data.ModelData;
+import org.exoplatform.portal.pom.data.PageData;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.exoplatform.portal.pom.spi.portlet.Preferences;
+import org.exoplatform.portal.pom.spi.wsrp.WSRP;
+
 /**
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
@@ -62,4 +77,55 @@
       this.storageName = storageName;
    }
 
+   public abstract ModelData build();
+
+   public static ModelObject build(ModelData data)
+   {
+      if (data instanceof ContainerData)
+      {
+         return new Container((ContainerData)data);
+      }
+      else if (data instanceof PageData)
+      {
+         return new Page((PageData)data);
+      }
+      else if (data instanceof BodyData)
+      {
+         BodyData bodyData = (BodyData)data;
+         switch (bodyData.getType())
+         {
+            case PAGE:
+               return new PageBody(data.getStorageId());
+            case SITE:
+               return new SiteBody(data.getStorageId());
+            default:
+               throw new AssertionError();
+         }
+      }
+      else if (data instanceof ApplicationData)
+      {
+         ApplicationData applicationData = (ApplicationData)data;
+         ApplicationType type = applicationData.getType();
+         if (ApplicationType.PORTLET == type)
+         {
+            return new PortletApplication((ApplicationData<Preferences, PortletId>)applicationData);
+         }
+         else if (ApplicationType.GADGET == type)
+         {
+            return new GadgetApplication((ApplicationData<Gadget, GadgetId>)applicationData);
+         }
+         else if (ApplicationType.WSRP_PORTLET == type)
+         {
+            return new WSRPApplication((ApplicationData<WSRP, WSRPId>)applicationData);
+         }
+         else
+         {
+            throw new AssertionError();
+         }
+      }
+      else
+      {
+         throw new UnsupportedOperationException("todo " + data);
+      }
+   }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,7 +19,12 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.data.ComponentData;
+import org.exoplatform.portal.pom.data.PageData;
+
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * May 13, 2004
@@ -35,8 +40,6 @@
 
    private String ownerId;
 
-   private String[] accessPermissions;
-
    private String editPermission;
 
    private boolean showMaxWindow = false;
@@ -51,6 +54,19 @@
    {
    }
 
+   public Page(PageData data)
+   {
+      super(data);
+
+      //
+      this.ownerType = data.getOwnerType();
+      this.ownerId = data.getOwnerId();
+      this.editPermission = data.getEditPermission();
+      this.showMaxWindow = data.isShowMaxWindow();
+      this.creator = data.getCreator();
+      this.modifier = data.getModifier();
+   }
+
    public Page(String storageId)
    {
       super(storageId);
@@ -76,16 +92,6 @@
       this.ownerType = ownerType;
    }
 
-   public String[] getAccessPermissions()
-   {
-      return accessPermissions;
-   }
-
-   public void setAccessPermissions(String[] s)
-   {
-      accessPermissions = s;
-   }
-
    public String getEditPermission()
    {
       return editPermission;
@@ -169,6 +175,32 @@
       modifier = s;
    }
 
+   @Override
+   public PageData build()
+   {
+      List<ComponentData> children = buildChildren();
+      return new PageData(
+         storageId,
+         id,
+         name,
+         icon,
+         decorator,
+         template,
+         factoryId,
+         title,
+         description,
+         width,
+         height,
+         Utils.safeImmutableList(accessPermissions),
+         children,
+         ownerType,
+         ownerId,
+         editPermission,
+         showMaxWindow,
+         creator,
+         modifier);
+   }
+
    static public class PageSet
    {
       private ArrayList<Page> pages;

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageBody.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageBody.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageBody.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,10 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.data.BodyData;
+import org.exoplatform.portal.pom.data.BodyType;
+import org.exoplatform.portal.pom.data.ModelData;
+
 /**
  * Created by The eXo Platform SAS
  * Apr 25, 2007  
@@ -34,4 +38,10 @@
    public PageBody()
    {
    }
+
+   @Override
+   public ModelData build()
+   {
+      return new BodyData(storageId, BodyType.PAGE);
+   }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,8 +19,12 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.data.NavigationData;
+import org.exoplatform.portal.pom.data.NavigationNodeData;
+
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 
 public class PageNavigation extends PageNodeContainer
@@ -38,19 +42,44 @@
 
    private String modifier;
 
-   private ArrayList<PageNode> pageNodes = new ArrayList<PageNode>();
+   private ArrayList<PageNode> pageNodes;
 
    private int priority = 1;
 
    PageNavigation(String storageId)
    {
       super(storageId);
+
+      //
+      this.pageNodes = new ArrayList<PageNode>();
    }
 
    public PageNavigation()
    {
+      this((String)null);
    }
 
+   public PageNavigation(NavigationData nav)
+   {
+      super(nav.getStorageId());
+
+      ArrayList<PageNode> children = new ArrayList<PageNode>(nav.getNodes().size());
+      for (NavigationNodeData child : nav.getNodes())
+      {
+         PageNode node = new PageNode(child);
+         children.add(node);
+      }
+
+      //
+      this.ownerType = nav.getOwnerType();
+      this.ownerId = nav.getOwnerId();
+      this.description = nav.getDescription();
+      this.creator = nav.getCreator();
+      this.modifier = nav.getModifier();
+      this.priority = nav.getPriority();
+      this.pageNodes = children;
+   }
+
    public int getId()
    {
       return getOwner().hashCode();
@@ -226,4 +255,20 @@
    {
       return "PageNavigation[ownerType=" + ownerType + ",ownerId=" + ownerId + "]";
    }
+
+   @Override
+   public NavigationData build()
+   {
+      List<NavigationNodeData> children = buildNavigationChildren();
+      return new NavigationData(
+         storageId,
+         ownerType,
+         ownerId,
+         description,
+         creator,
+         modifier,
+         priority,
+         children
+      );
+   }
 }
\ No newline at end of file

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -20,6 +20,7 @@
 package org.exoplatform.portal.config.model;
 
 import org.exoplatform.commons.utils.ExpressionUtil;
+import org.exoplatform.portal.pom.data.NavigationNodeData;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -29,7 +30,7 @@
 public class PageNode extends PageNodeContainer
 {
 
-   private ArrayList<PageNode> children = new ArrayList<PageNode>(5);
+   private ArrayList<PageNode> children;
 
    private String uri;
 
@@ -53,14 +54,43 @@
 
    private transient boolean modifiable;
 
+   public PageNode(NavigationNodeData nav)
+   {
+      super(nav.getStorageId());
+
+      //
+      ArrayList<PageNode> children = new ArrayList<PageNode>(nav.getNodes().size());
+      for (NavigationNodeData child : nav.getNodes())
+      {
+         PageNode node = new PageNode(child);
+         children.add(node);
+      }
+
+      //
+      this.uri = nav.getURI();
+      this.label = nav.getLabel();
+      this.resolvedLabel = nav.getLabel();
+      this.icon = nav.getIcon();
+      this.name = nav.getName();
+      this.startPublicationDate = nav.getStartPublicationDate();
+      this.endPublicationDate = nav.getEndPublicationDate();
+      this.showPublicationDate = nav.getShowPublicationDate();
+      this.visible = nav.isVisible();
+      this.pageReference = nav.getPageReference();
+      this.children = children;
+   }
+
    public PageNode(String storageId)
    {
       super(storageId);
+
+      //
+      this.children = new ArrayList<PageNode>();
    }
 
    public PageNode()
    {
-      super();
+      this((String)null);
    }
 
    public String getUri()
@@ -258,4 +288,22 @@
       return newNode;
    }
 
+   @Override
+   public NavigationNodeData build()
+   {
+      List<NavigationNodeData> children = buildNavigationChildren();
+      return new NavigationNodeData(
+         storageId,
+         uri,
+         label,
+         icon,
+         name,
+         startPublicationDate,
+         endPublicationDate,
+         showPublicationDate,
+         visible,
+         pageReference,
+         children
+      );
+   }
 }
\ No newline at end of file

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNodeContainer.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNodeContainer.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNodeContainer.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,11 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.data.NavigationNodeContainerData;
+import org.exoplatform.portal.pom.data.NavigationNodeData;
+
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -38,4 +43,27 @@
    }
 
    public abstract List<PageNode> getNodes();
+
+   protected List<NavigationNodeData> buildNavigationChildren()
+   {
+      List<PageNode> nodes = getNodes();
+      if (nodes != null)
+      {
+         ArrayList<NavigationNodeData> children = new ArrayList<NavigationNodeData>();
+         for (int i = 0;i < nodes.size();i++)
+         {
+            PageNode node = nodes.get(i);
+            NavigationNodeData child = node.build();
+            children.add(child);
+         }
+         return Collections.unmodifiableList(children);
+      }
+      else
+      {
+         return Collections.emptyList();
+      }
+   }
+
+   public abstract NavigationNodeContainerData build();
+
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PersistentApplicationState.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PersistentApplicationState.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PersistentApplicationState.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,13 +19,15 @@
 
 package org.exoplatform.portal.config.model;
 
+import java.io.Serializable;
+
 /**
  * Represents the state of the application when it is bound to the database.
  *
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
-public class PersistentApplicationState<S> extends ApplicationState<S>
+public class PersistentApplicationState<S> extends ApplicationState<S> implements Serializable
 {
 
    /** The id of the content state. */

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,7 +19,12 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.data.PortalData;
+
 import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 /**
  * May 13, 2004
@@ -85,6 +90,24 @@
       setPortalLayout(new Container());
    }
 
+   public PortalConfig(PortalData data)
+   {
+      super(data.getStorageId());
+
+      //
+      this.name = data.getName();
+      this.type = data.getType();
+      this.locale = data.getLocale();
+      this.accessPermissions = data.getAccessPermissions().toArray(new String[data.getAccessPermissions().size()]);
+      this.editPermission = data.getEditPermission();
+      this.properties = new Properties(data.getProperties());
+      this.skin = data.getSkin();
+      this.title = data.getTitle();
+      this.portalLayout = new Container(data.getPortalLayout());
+      this.creator = data.getCreator();
+      this.modifier = data.getModifier();
+   }
+
    PortalConfig(String storageId, String type)
    {
       super(storageId);
@@ -297,4 +320,23 @@
       container.setChildren(children);
       return container;
    }
+
+   public PortalData build()
+   {
+      List<String> accessPermissions = Utils.safeImmutableList(this.accessPermissions);
+      Map<String, String> properties = Utils.safeImmutableMap(this.properties);
+      return new PortalData(
+         storageId,
+         name,
+         type,
+         locale,
+         accessPermissions,
+         editPermission,
+         properties,
+         skin,
+         title,
+         portalLayout.build(),
+         creator,
+         modifier);
+   }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Properties.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Properties.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/Properties.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -20,6 +20,7 @@
 package org.exoplatform.portal.config.model;
 
 import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Created by The eXo Platform SARL
@@ -31,9 +32,14 @@
 public class Properties extends HashMap<String, String>
 {
 
+   public Properties(Map<String, String> m)
+   {
+      super(m);
+   }
+
    public Properties()
    {
-      super(10);
+      super();
    }
 
    public Properties(int size)

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/SiteBody.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/SiteBody.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/SiteBody.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,10 @@
 
 package org.exoplatform.portal.config.model;
 
+import org.exoplatform.portal.pom.data.BodyData;
+import org.exoplatform.portal.pom.data.BodyType;
+import org.exoplatform.portal.pom.data.ModelData;
+
 public class SiteBody extends ModelObject
 {
 
@@ -30,4 +34,10 @@
    public SiteBody()
    {
    }
+
+   @Override
+   public ModelData build()
+   {
+      return new BodyData(storageId, BodyType.SITE);
+   }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/gadget/GadgetApplication.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/gadget/GadgetApplication.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/gadget/GadgetApplication.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -21,6 +21,7 @@
 
 import org.exoplatform.portal.config.model.Application;
 import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.pom.data.ApplicationData;
 import org.exoplatform.portal.pom.spi.gadget.Gadget;
 
 /**
@@ -30,6 +31,11 @@
 public class GadgetApplication extends Application<Gadget, GadgetId>
 {
 
+   public GadgetApplication(ApplicationData<Gadget, GadgetId> data)
+   {
+      super(data);
+   }
+
    public GadgetApplication(String storageId, String gadgetName)
    {
       super(storageId, new GadgetId(gadgetName));

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/portlet/PortletApplication.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/portlet/PortletApplication.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/portlet/PortletApplication.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -21,6 +21,7 @@
 
 import org.exoplatform.portal.config.model.Application;
 import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.pom.data.ApplicationData;
 import org.exoplatform.portal.pom.spi.portlet.Preferences;
 
 /**
@@ -30,6 +31,11 @@
 public class PortletApplication extends Application<Preferences, PortletId>
 {
 
+   public PortletApplication(ApplicationData<Preferences, PortletId> data)
+   {
+      super(data);
+   }
+
    public PortletApplication(String storageId, String applicationName, String portletName)
    {
       super(storageId, new PortletId(applicationName, portletName));

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/wsrp/WSRPApplication.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/wsrp/WSRPApplication.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/config/model/wsrp/WSRPApplication.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -21,6 +21,7 @@
 
 import org.exoplatform.portal.config.model.Application;
 import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.pom.data.ApplicationData;
 import org.exoplatform.portal.pom.spi.wsrp.WSRP;
 
 /**
@@ -29,6 +30,10 @@
  */
 public class WSRPApplication extends Application<WSRP, WSRPId>
 {
+   public WSRPApplication(ApplicationData<WSRP, WSRPId> wsrpwsrpIdApplicationData)
+   {
+      super(wsrpwsrpIdApplicationData);
+   }
 
    public WSRPApplication(String storageId, WSRPId id)
    {

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/ExecutorDispatcher.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,54 @@
+/**
+ * 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;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ExecutorDispatcher implements TaskExecutor
+{
+
+   /** . */
+   private final Log log = ExoLogger.getLogger(getClass());
+
+   /** . */
+   private static final String[] padding = {"    ", "   ", "  ", " "};
+
+   public void execute(POMSession session, POMTask task) throws Exception
+   {
+      String s = task.toString();
+      long t0 = System.currentTimeMillis();
+      session.execute(task);
+      long t1 = System.currentTimeMillis();
+      String t = "" + (t1 - t0);
+      if (t.length() < 4)
+      {
+         t = padding[t.length()] + t;
+         log.debug("Executed [" + t + "] " + s + "");
+      }
+      else
+      {
+         log.debug("Executed in " + t + " " + s + "");
+      }
+   }
+}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/ModelDemarcation.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/ModelDemarcation.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/ModelDemarcation.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/ModelDemarcation.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,32 @@
+/**
+ * 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 at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public interface ModelDemarcation
+{
+
+   void begin();
+
+   void end(boolean save);
+
+}

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -23,24 +23,33 @@
 import org.exoplatform.commons.utils.LazyPageList;
 import org.exoplatform.container.configuration.ConfigurationManager;
 import org.exoplatform.portal.application.PortletPreferences;
-import org.exoplatform.portal.config.DataStorage;
 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.Container;
 import org.exoplatform.portal.config.model.ModelChange;
 import org.exoplatform.portal.config.model.ModelObject;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.config.model.PageNavigation;
 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.cache.DataCache;
+import org.exoplatform.portal.pom.config.tasks.DashboardTask;
 import org.exoplatform.portal.pom.config.tasks.PageNavigationTask;
 import org.exoplatform.portal.pom.config.tasks.PageTask;
 import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
 import org.exoplatform.portal.pom.config.tasks.PortletPreferencesTask;
 import org.exoplatform.portal.pom.config.tasks.PreferencesTask;
 import org.exoplatform.portal.pom.config.tasks.SearchTask;
+import org.exoplatform.portal.pom.data.DashboardData;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.data.NavigationData;
+import org.exoplatform.portal.pom.data.NavigationKey;
+import org.exoplatform.portal.pom.data.PageData;
+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.cache.CacheService;
+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;
@@ -54,103 +63,126 @@
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
-public class POMDataStorage implements DataStorage
+public class POMDataStorage implements ModelDataStorage, ModelDemarcation
 {
 
    /** . */
    private final POMSessionManager pomMgr;
 
+   /** . */
    private ConfigurationManager confManager_;
 
-   public POMDataStorage(POMSessionManager pomMgr, ConfigurationManager confManager)
+   /** . */
+   private final Log log = ExoLogger.getLogger(getClass());
+   
+   /** . */
+   private final TaskExecutor executor;
+
+   public POMDataStorage(CacheService cacheService, POMSessionManager pomMgr, ConfigurationManager confManager)
    {
       this.pomMgr = pomMgr;
-      confManager_ = confManager;
+      this.confManager_ = confManager;
+      this.executor = new DataCache(cacheService, new ExecutorDispatcher());
    }
 
-   public <T extends POMTask> T execute(T task) throws Exception
-   {
-      pomMgr.execute(task);
-      return task;
-   }
-
    public POMSessionManager getPOMSessionManager()
    {
       return pomMgr;
    }
+   
+   /**
+    * <p>Execute the task with a session. The method attempts first to get a current session and if no such session
+    * is found then a session will be created for the scope of the method.</p>
+    *
+    * @param task the task to execute
+    * @throws Exception any exception thrown by the task
+    */
+   private <T extends POMTask> T execute(T task) throws Exception
+   {
+      POMSession session = POMSessionManager.getSession();
+      if (session == null)
+      {
+         session = pomMgr.openSession();
+         try
+         {
+            executor.execute(session, task);
+         }
+         finally
+         {
+            pomMgr.closeSession(true);
+         }
+      }
+      else
+      {
+         session.execute(task);
+      }
 
-   public PortalConfig getPortalConfig(String portalName) throws Exception
-   {
-      return execute(new PortalConfigTask.Load(PortalConfig.PORTAL_TYPE, portalName)).getConfig();
+      //
+      return task;
    }
 
-   public PortalConfig getPortalConfig(String ownerType, String portalName) throws Exception
+   public PortalData getPortalConfig(PortalKey key) throws Exception
    {
-      return execute(new PortalConfigTask.Load(ownerType, portalName)).getConfig();
+      return execute(new PortalConfigTask.Load(key)).getConfig();
    }
 
-   public void create(PortalConfig config) throws Exception
+   public void create(PortalData config) throws Exception
    {
       execute(new PortalConfigTask.Save(config, true));
    }
 
-   public void save(PortalConfig config) throws Exception
+   public void save(PortalData config) throws Exception
    {
       execute(new PortalConfigTask.Save(config, true));
    }
 
-   public void remove(PortalConfig config) throws Exception
+   public void remove(PortalData config) throws Exception
    {
-      execute(new PortalConfigTask.Remove(config.getType(), config.getName()));
+      execute(new PortalConfigTask.Remove(config.getKey()));
    }
 
-   public Page getPage(String pageId) throws Exception
+   public PageData getPage(PageKey key) throws Exception
    {
-      return execute(new PageTask.Load(pageId)).getPage();
+      return execute(new PageTask.Load(key)).getPage();
    }
 
-   public Page clonePage(String pageId, String clonedOwnerType, String clonedOwnerId, String clonedName)
+   public PageData clonePage(PageKey key, PageKey cloneKey)
       throws Exception
    {
-      return execute(new PageTask.Clone(pageId, clonedOwnerType, clonedOwnerId, clonedName, true)).getPage();
+      return execute(new PageTask.Clone(key, cloneKey, true)).getPage();
    }
 
-   public void remove(Page page) throws Exception
+   public void remove(PageData page) throws Exception
    {
       execute(new PageTask.Remove(page));
    }
 
-   public void create(Page page) throws Exception
+   public void create(PageData page) throws Exception
    {
       execute(new PageTask.Save(page));
    }
 
-   public List<ModelChange> save(Page page) throws Exception
+   public List<ModelChange> save(PageData page) throws Exception
    {
       return execute(new PageTask.Save(page)).getChanges();
    }
 
-   public PageNavigation getPageNavigation(String fullId) throws Exception
+   public NavigationData getPageNavigation(NavigationKey key) throws Exception
    {
-      return execute(new PageNavigationTask.Load(fullId)).getPageNavigation();
+      return execute(new PageNavigationTask.Load(key)).getPageNavigation();
    }
 
-   public PageNavigation getPageNavigation(String ownerType, String id) throws Exception
+   public void save(NavigationData navigation) throws Exception
    {
-      return execute(new PageNavigationTask.Load(ownerType + "::" + id)).getPageNavigation();
-   }
-
-   public void save(PageNavigation navigation) throws Exception
-   {
       execute(new PageNavigationTask.Save(navigation, true));
    }
 
-   public void create(PageNavigation navigation) throws Exception
+   public void create(NavigationData navigation) throws Exception
    {
       execute(new PageNavigationTask.Save(navigation, false));
    }
 
-   public void remove(PageNavigation navigation) throws Exception
+   public void remove(NavigationData navigation) throws Exception
    {
       execute(new PageNavigationTask.Remove(navigation));
    }
@@ -202,26 +234,30 @@
 
    public <T> LazyPageList<T> find(Query<T> q, Comparator<T> sortComparator) throws Exception
    {
-      if (Page.class.equals(q.getClassType()))
+      Class<T> type = q.getClassType();
+      if (PageData.class.equals(type))
       {
-         return (LazyPageList<T>)execute(new SearchTask.FindPage((Query<Page>)q)).getResult();
+         return (LazyPageList<T>)execute(new SearchTask.FindPage((Query<PageData>)q)).getResult();
       }
-      else if (PageNavigation.class.equals(q.getClassType()))
+      else if (NavigationData.class.equals(type))
       {
-         return (LazyPageList<T>)execute(new SearchTask.FindNavigation((Query<PageNavigation>)q)).getResult();
+         return (LazyPageList<T>)execute(new SearchTask.FindNavigation((Query<NavigationData>)q)).getResult();
       }
-      else if (PortletPreferences.class.equals(q.getClassType()))
+      else if (PortletPreferences.class.equals(type))
       {
-         return (LazyPageList<T>)execute(new SearchTask.FindPortletPreferences((Query<PortletPreferences>)q))
-            .getResult();
+         return (LazyPageList<T>)execute(new SearchTask.FindPortletPreferences((Query<PortletPreferences>)q)).getResult();
       }
-      else if (PortalConfig.class.equals(q.getClassType()))
+      else if (PortalData.class.equals(type))
       {
-         return (LazyPageList<T>)execute(new SearchTask.FindSite((Query<PortalConfig>)q)).getResult();
+         return (LazyPageList<T>)execute(new SearchTask.FindSite((Query<PortalData>)q)).getResult();
       }
+      else if (PortalKey.class.equals(type) && "portal".equals(q.getOwnerType()))
+      {
+         return (LazyPageList<T>)execute(new SearchTask.FindSiteKey((Query<PortalKey>)q)).getResult();
+      }
       else
       {
-         throw new UnsupportedOperationException();
+         throw new UnsupportedOperationException("Could not perform search on query " + q);
       }
    }
 
@@ -244,6 +280,16 @@
       }
    }
 
+   public DashboardData loadDashboard(String dashboardId) throws Exception
+   {
+      return execute(new DashboardTask.Load(dashboardId)).getDashboard();
+   }
+
+   public void saveDashboard(DashboardData dashboard) throws Exception
+   {
+      execute(new DashboardTask.Save(dashboard));
+   }
+
    public Container getSharedLayout() throws Exception
    {
       String path = "war:/conf/portal/portal/sharedlayout.xml";
@@ -255,4 +301,14 @@
       generateStorageName(container);
       return container;
    }
+
+   public void begin()
+   {
+      getPOMSessionManager().openSession();
+   }
+
+   public void end(boolean save)
+   {
+      getPOMSessionManager().closeSession(save);
+   }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -20,8 +20,9 @@
 package org.exoplatform.portal.pom.config;
 
 import org.chromattic.api.ChromatticSession;
+import org.chromattic.api.UndeclaredRepositoryException;
 import org.exoplatform.portal.application.PortletPreferences;
-import org.exoplatform.portal.config.model.Mapper;
+import org.exoplatform.portal.pom.data.Mapper;
 import org.gatein.mop.api.Model;
 import org.gatein.mop.api.content.Customization;
 import org.gatein.mop.api.workspace.ObjectType;
@@ -33,6 +34,7 @@
 import org.gatein.mop.core.api.workspace.NavigationImpl;
 import org.gatein.mop.core.api.workspace.PageImpl;
 
+import javax.jcr.RepositoryException;
 import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -78,20 +80,31 @@
       return model;
    }
 
-   /*
-     public ChromatticSession getSession() {
-       try {
-         Model model = getModel();
-         Field f = model.getClass().getDeclaredField("session");
-         f.setAccessible(true);
-         return (ChromatticSession)f.get(model);
-       }
-       catch (Exception e) {
-         throw new Error(e);
-       }
-     }
-   */
+   // julien todo : investigate how expensive is the call to hasPendingChanges method
+   public boolean isModified()
+   {
+      try
+      {
+         return getSession().getJCRSession().hasPendingChanges();
+      }
+      catch (RepositoryException e)
+      {
+         throw new UndeclaredRepositoryException(e);
+      }
+   }
 
+  private ChromatticSession getSession() {
+    try {
+      Model model = getModel();
+      Field f = model.getClass().getDeclaredField("session");
+      f.setAccessible(true);
+      return (ChromatticSession)f.get(model);
+    }
+    catch (Exception e) {
+      throw new Error(e);
+    }
+  }
+
    public Workspace getWorkspace()
    {
       return getModel().getWorkspace();

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,16 +1,16 @@
 /**
  * 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
@@ -223,8 +223,8 @@
    }
 
    /**
-    * <p>Open and returns a session to the model. When the current thread is already associated with a previously opened
-    * session the method will throw an <tt>IllegalStateException</tt>.</p>
+    * <p>Open and returns a session to the model. When the current thread is already associated with a previously
+    * opened session the method will throw an <tt>IllegalStateException</tt>.</p>
     *
     * @return a session to the model.
     */
@@ -255,8 +255,8 @@
    }
 
    /**
-    * <p>Closes the current session and optionally saves its content. If no session is associated then this method has
-    * no effects and returns false.</p>
+    * <p>Closes the current session and optionally saves its content. If no session is associated
+    * then this method has no effects and returns false.</p>
     *
     * @param save if the session must be saved
     * @return a boolean indicating if the session was closed
@@ -286,32 +286,4 @@
          return true;
       }
    }
-
-   /**
-    * <p>Execute the task with a session. The method attempts first to get a current session and if no such session is
-    * found then a session will be created for the scope of the method.</p>
-    *
-    * @param task the task to execute
-    * @throws Exception any exception thrown by the task
-    */
-   public void execute(POMTask task) throws Exception
-   {
-      POMSession session = getSession();
-      if (session == null)
-      {
-         session = openSession();
-         try
-         {
-            session.execute(task);
-         }
-         finally
-         {
-            closeSession(true);
-         }
-      }
-      else
-      {
-         session.execute(task);
-      }
-   }
 }

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutor.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutor.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutor.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/TaskExecutor.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,30 @@
+/**
+ * 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 at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public interface TaskExecutor
+{
+
+   void execute(POMSession session, POMTask task) throws Exception;
+
+}

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/Utils.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/Utils.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/Utils.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,13 @@
 
 package org.exoplatform.portal.pom.config;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
@@ -45,6 +52,16 @@
       return sb.toString();
    }
 
+   public static String join(String separator, List<String> strings)
+   {
+      if (strings == null)
+      {
+         return null;
+      }
+      String[] array = strings.toArray(new String[strings.size()]);
+      return join(separator, array);
+   }
+
    public static String[] split(String separator, String s)
    {
       if (s == null)
@@ -54,6 +71,60 @@
       return split(s, 0, 0, separator);
    }
 
+   public static <E> List<E> safeImmutableList(E... list)
+   {
+      if (list == null || list.length == 0)
+      {
+         return Collections.emptyList();
+      }
+      else if (list.length == 1)
+      {
+         E e = list[0];
+         return Collections.singletonList(e);
+      }
+      else
+      {
+         List<E> copy = Arrays.asList(list);
+         return Collections.unmodifiableList(copy);
+      }
+   }
+
+   public static <E> List<E> safeImmutableList(List<E> list)
+   {
+      if (list == null || list.size() == 0)
+      {
+         return Collections.emptyList();
+      }
+      else if (list.size() == 1)
+      {
+         E e = list.get(0);
+         return Collections.singletonList(e);
+      }
+      else
+      {
+         ArrayList<E> copy = new ArrayList<E>(list);
+         return Collections.unmodifiableList(copy);
+      }
+   }
+
+   public static <K, V> Map<K, V> safeImmutableMap(Map<K, V> map)
+   {
+      if (map == null || map.size() == 0)
+      {
+         return Collections.emptyMap();
+      }
+      else if (map.size() == 1)
+      {
+         Map.Entry<K, V> entry = map.entrySet().iterator().next();
+         return Collections.singletonMap(entry.getKey(), entry.getValue());
+      }
+      else
+      {
+         Map<K, V> copy = new HashMap<K,V>(map);
+         return Collections.unmodifiableMap(copy);
+      }
+   }
+
    /**
     * Splits a string according to a string separator.
     *

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache)

Deleted: portal/branches/wsrp-integration/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-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,42 +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.cache;
-
-import org.exoplatform.portal.pom.config.POMTask;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public interface CacheableDataTask<K extends Serializable, V> extends POMTask
-{
-
-   DataAccessMode getAccessMode();
-
-   K getKey();
-
-   V getValue();
-
-   void setValue(V value);
-
-   Class<V> getValueType();
-
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/CacheableDataTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,42 @@
+/**
+ * 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.cache;
+
+import org.exoplatform.portal.pom.config.POMTask;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public interface CacheableDataTask<K extends Serializable, V> extends POMTask
+{
+
+   DataAccessMode getAccessMode();
+
+   K getKey();
+
+   V getValue();
+
+   void setValue(V value);
+
+   Class<V> getValueType();
+
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataAccessMode.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataAccessMode.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataAccessMode.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,30 +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.cache;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public enum DataAccessMode
-{
-
-   CREATE, READ, WRITE, DESTROY
-
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataAccessMode.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataAccessMode.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataAccessMode.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataAccessMode.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,30 @@
+/**
+ * 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.cache;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum DataAccessMode
+{
+
+   CREATE, READ, WRITE, DESTROY
+
+}

Deleted: portal/branches/wsrp-integration/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-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,132 +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.cache;
-
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.POMTask;
-import org.exoplatform.portal.pom.config.TaskExecutor;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.ExoCache;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class DataCache implements TaskExecutor
-{
-
-   /** . */
-   private TaskExecutor next;
-
-   /** . */
-   private ExoCache<Serializable, Object> cache;
-
-   public DataCache(CacheService cacheService, TaskExecutor next)
-   {
-      this.next = next;
-      this.cache = cacheService.getCacheInstance(DataCache.class.getSimpleName());
-   }
-
-   public void execute(POMSession session, POMTask task) throws Exception
-   {
-      if (task instanceof CacheableDataTask)
-      {
-         if (!session.isModified())
-         {
-            CacheableDataTask<?, ?> loadTask = (CacheableDataTask<?,?>)task;
-            switch (loadTask.getAccessMode())
-            {
-               case READ:
-                  read(session, loadTask);
-                  break;
-               case CREATE:
-                  create(session, loadTask);
-                  break;
-               case WRITE:
-                  write(session, loadTask);
-                  break;
-               case DESTROY:
-                  remove(session, loadTask);
-                  break;
-               default:
-                  throw new UnsupportedOperationException();
-            }
-         }
-      }
-      else
-      {
-         next.execute(session, task);
-      }
-   }
-
-   private <K extends Serializable, V> void remove(POMSession session, CacheableDataTask<K, V> task) throws Exception
-   {
-      K key = task.getKey();
-      cache.remove(key);
-      next.execute(session, task);
-   }
-
-   private <K extends Serializable, V> void write(POMSession session, CacheableDataTask<K, V> task) throws Exception
-   {
-      K key = task.getKey();
-      cache.remove(key);
-      next.execute(session, task);
-   }
-
-   private <K extends Serializable, V> void create(POMSession session, CacheableDataTask<K, V> task) throws Exception
-   {
-      // Nothing to do for now
-      next.execute(session, task);
-   }
-
-   private <K extends Serializable, V> void read(POMSession session, CacheableDataTask<K, V> task) throws Exception
-   {
-      K key = task.getKey();
-      Object o = cache.get(key);
-      V v = null;
-      if (o != null)
-      {
-         Class<V> type = task.getValueType();
-         if (type.isInstance(o))
-         {
-            v = type.cast(o);
-         }
-      }
-
-      //
-      if (v != null)
-      {
-         task.setValue(v);
-      }
-      else
-      {
-         //
-         next.execute(session, task);
-
-         //
-         v = task.getValue();
-         if (v != null)
-         {
-            cache.put(key, v);
-         }
-      }
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,132 @@
+/**
+ * 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.cache;
+
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMTask;
+import org.exoplatform.portal.pom.config.TaskExecutor;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class DataCache implements TaskExecutor
+{
+
+   /** . */
+   private TaskExecutor next;
+
+   /** . */
+   private ExoCache<Serializable, Object> cache;
+
+   public DataCache(CacheService cacheService, TaskExecutor next)
+   {
+      this.next = next;
+      this.cache = cacheService.getCacheInstance(DataCache.class.getSimpleName());
+   }
+
+   public void execute(POMSession session, POMTask task) throws Exception
+   {
+      if (task instanceof CacheableDataTask)
+      {
+         if (!session.isModified())
+         {
+            CacheableDataTask<?, ?> loadTask = (CacheableDataTask<?,?>)task;
+            switch (loadTask.getAccessMode())
+            {
+               case READ:
+                  read(session, loadTask);
+                  break;
+               case CREATE:
+                  create(session, loadTask);
+                  break;
+               case WRITE:
+                  write(session, loadTask);
+                  break;
+               case DESTROY:
+                  remove(session, loadTask);
+                  break;
+               default:
+                  throw new UnsupportedOperationException();
+            }
+         }
+      }
+      else
+      {
+         next.execute(session, task);
+      }
+   }
+
+   private <K extends Serializable, V> void remove(POMSession session, CacheableDataTask<K, V> task) throws Exception
+   {
+      K key = task.getKey();
+      cache.remove(key);
+      next.execute(session, task);
+   }
+
+   private <K extends Serializable, V> void write(POMSession session, CacheableDataTask<K, V> task) throws Exception
+   {
+      K key = task.getKey();
+      cache.remove(key);
+      next.execute(session, task);
+   }
+
+   private <K extends Serializable, V> void create(POMSession session, CacheableDataTask<K, V> task) throws Exception
+   {
+      // Nothing to do for now
+      next.execute(session, task);
+   }
+
+   private <K extends Serializable, V> void read(POMSession session, CacheableDataTask<K, V> task) throws Exception
+   {
+      K key = task.getKey();
+      Object o = cache.get(key);
+      V v = null;
+      if (o != null)
+      {
+         Class<V> type = task.getValueType();
+         if (type.isInstance(o))
+         {
+            v = type.cast(o);
+         }
+      }
+
+      //
+      if (v != null)
+      {
+         task.setValue(v);
+      }
+      else
+      {
+         //
+         next.execute(session, task);
+
+         //
+         v = task.getValue();
+         if (v != null)
+         {
+            cache.put(key, v);
+         }
+      }
+   }
+}

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/DashboardTask.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/DashboardTask.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/DashboardTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,10 +19,10 @@
 
 package org.exoplatform.portal.pom.config.tasks;
 
-import org.exoplatform.portal.config.model.Dashboard;
-import org.exoplatform.portal.config.model.Mapper;
 import org.exoplatform.portal.pom.config.AbstractPOMTask;
 import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.data.DashboardData;
+import org.exoplatform.portal.pom.data.Mapper;
 import org.gatein.mop.api.workspace.ObjectType;
 import org.gatein.mop.api.workspace.ui.UIContainer;
 
@@ -40,7 +40,7 @@
       protected final String storageId;
 
       /** . */
-      protected Dashboard dashboard;
+      protected DashboardData dashboard;
 
       public Load(String storageId)
       {
@@ -58,20 +58,34 @@
          }
       }
 
-      public Dashboard getDashboard()
+      public DashboardData getDashboard()
       {
          return dashboard;
       }
+
+      @Override
+      public String toString()
+      {
+         return "DashboardTask.Load[id=" + storageId + "]";
+      }
    }
 
    public static class Save extends DashboardTask
    {
 
       /** The dashboard object. */
-      protected final Dashboard dashboard;
+      protected final DashboardData dashboard;
 
-      public Save(Dashboard dashboard)
+      public Save(DashboardData dashboard)
       {
+         if (dashboard == null)
+         {
+            throw new NullPointerException("No null dashboard accepted");
+         }
+         if (dashboard.getStorageId() == null)
+         {
+            throw new IllegalArgumentException("No dasbhoard with null storage id accepted");
+         }
          this.dashboard = dashboard;
       }
 
@@ -96,5 +110,11 @@
          //
          mapper.saveDashboard(dashboard, container);
       }
+
+      @Override
+      public String toString()
+      {
+         return "DashboardTask.Save[id=" + dashboard.getStorageId() + "]";
+      }
    }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageNavigationTask.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageNavigationTask.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageNavigationTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,12 +19,13 @@
 
 package org.exoplatform.portal.pom.config.tasks;
 
-import static org.exoplatform.portal.pom.config.Utils.split;
-
-import org.exoplatform.portal.config.model.Mapper;
-import org.exoplatform.portal.config.model.PageNavigation;
 import org.exoplatform.portal.pom.config.AbstractPOMTask;
 import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
+import org.exoplatform.portal.pom.config.cache.DataAccessMode;
+import org.exoplatform.portal.pom.data.Mapper;
+import org.exoplatform.portal.pom.data.NavigationData;
+import org.exoplatform.portal.pom.data.NavigationKey;
 import org.gatein.mop.api.workspace.Navigation;
 import org.gatein.mop.api.workspace.ObjectType;
 import org.gatein.mop.api.workspace.Site;
@@ -38,52 +39,62 @@
 {
 
    /** . */
-   protected final String owner;
+   protected final ObjectType<? extends Site> siteType;
 
    /** . */
-   protected final String ownerType;
+   protected final NavigationKey key;
 
-   /** . */
-   protected final String ownerId;
-
-   /** . */
-   protected final ObjectType<? extends Site> siteType;
-
-   protected PageNavigationTask(String owner)
+   protected PageNavigationTask(NavigationKey key)
    {
-      String[] chunks = split("::", owner);
-      if (chunks.length != 2)
-      {
-         throw new IllegalArgumentException("Wrong owner format should be ownerType::ownerId was " + owner);
-      }
-
-      //
-      this.ownerType = chunks[0];
-      this.ownerId = chunks[1];
-      this.siteType = Mapper.parseSiteType(ownerType);
-      this.owner = owner;
+      this.key = key;
+      this.siteType = Mapper.parseSiteType(key.getType());
    }
 
-   public static class Load extends PageNavigationTask
+   public static class Load extends PageNavigationTask implements CacheableDataTask<NavigationKey, NavigationData>
    {
 
       /** . */
-      private PageNavigation pageNav;
+      private NavigationData pageNav;
 
-      public Load(String owner)
+      public Load(NavigationKey key)
       {
-         super(owner);
+         super(key);
       }
 
-      public PageNavigation getPageNavigation()
+      public NavigationData getPageNavigation()
       {
          return pageNav;
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return DataAccessMode.READ;
+      }
+
+      public NavigationKey getKey()
+      {
+         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
       {
          Workspace workspace = session.getWorkspace();
-         Site site = workspace.getSite(siteType, ownerId);
+         Site site = workspace.getSite(siteType, key.getId());
          if (site != null)
          {
             Navigation nav = site.getRootNavigation();
@@ -95,38 +106,69 @@
          }
          else
          {
-            System.out.println("Cannot load page navigation " + owner + " as the corresponding portal " + ownerId
+            System.out.println("Cannot load page navigation as the corresponding portal " + key.getId()
                + " with type " + siteType + " does not exist");
          }
       }
+
+      @Override
+      public String toString()
+      {
+         return "PageNavigation.Load[ownerType=" + key.getType() + ",ownerId=" + key.getId() + "]";
+      }
    }
 
-   public static class Save extends PageNavigationTask
+   public static class Save extends PageNavigationTask implements CacheableDataTask<NavigationKey, NavigationData>
    {
 
       /** . */
-      private final PageNavigation pageNav;
+      private final NavigationData pageNav;
 
       /** . */
       private final boolean overwrite;
 
-      public Save(PageNavigation pageNav, boolean overwrite)
+      public Save(NavigationData pageNav, boolean overwrite)
       {
-         super(pageNav.getOwner());
+         super(pageNav.getKey());
 
          //
          this.pageNav = pageNav;
          this.overwrite = overwrite;
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return pageNav.getStorageId() != null ? DataAccessMode.WRITE : DataAccessMode.CREATE;
+      }
+
+      public void setValue(NavigationData value)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public Class<NavigationData> getValueType()
+      {
+         return NavigationData.class;
+      }
+
+      public NavigationData getValue()
+      {
+         return pageNav;
+      }
+
+      public NavigationKey getKey()
+      {
+         return key;
+      }
+
       public void run(POMSession session) throws Exception
       {
          Workspace workspace = session.getWorkspace();
-         Site site = workspace.getSite(siteType, ownerId);
+         Site site = workspace.getSite(siteType, key.getId());
          if (site == null)
          {
-            throw new IllegalArgumentException("Cannot insert page navigation " + owner
-               + " as the corresponding portal " + ownerId + " with type " + siteType + " does not exist");
+            throw new IllegalArgumentException("Cannot insert page navigation "
+               + " as the corresponding portal " + key.getId() + " with type " + siteType + " does not exist");
          }
 
          // Delete node descendants first
@@ -143,24 +185,54 @@
          new Mapper(session).save(pageNav, defaultNav);
       }
 
+      @Override
+      public String toString()
+      {
+         return "PageNavigation.Save[ownerType=" + key.getType() + ",ownerId=" + key.getId() + "]";
+      }
    }
 
-   public static class Remove extends PageNavigationTask
+   public static class Remove extends PageNavigationTask implements CacheableDataTask<NavigationKey, NavigationData>
    {
 
-      public Remove(PageNavigation pageNav)
+      public Remove(NavigationData pageNav)
       {
-         super(pageNav.getOwner());
+         super(pageNav.getKey());
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return DataAccessMode.DESTROY;
+      }
+
+      public void setValue(NavigationData value)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public Class<NavigationData> getValueType()
+      {
+         return NavigationData.class;
+      }
+
+      public NavigationData getValue()
+      {
+         return null;
+      }
+
+      public NavigationKey getKey()
+      {
+         return key;
+      }
+
       public void run(POMSession session) throws Exception
       {
          Workspace workspace = session.getWorkspace();
-         Site site = workspace.getSite(siteType, ownerId);
+         Site site = workspace.getSite(siteType, key.getId());
          if (site == null)
          {
-            throw new IllegalArgumentException("Cannot insert page navigation " + owner
-               + " as the corresponding portal " + ownerId + " with type " + siteType + " does not exist");
+            throw new IllegalArgumentException("Cannot insert page navigation "
+               + " as the corresponding portal " + key.getId() + " with type " + siteType + " does not exist");
          }
 
          // Delete descendants
@@ -173,5 +245,11 @@
             defaultNav.destroy();
          }
       }
+
+      @Override
+      public String toString()
+      {
+         return "PageNavigation.Remove[ownerType=" + key.getType() + ",ownerId=" + key.getId() + "]";
+      }
    }
 }
\ No newline at end of file

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageTask.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageTask.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PageTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,13 +19,14 @@
 
 package org.exoplatform.portal.pom.config.tasks;
 
-import static org.exoplatform.portal.pom.config.Utils.split;
-
-import org.exoplatform.portal.config.model.Mapper;
 import org.exoplatform.portal.config.model.ModelChange;
-import org.exoplatform.portal.config.model.Page;
 import org.exoplatform.portal.pom.config.AbstractPOMTask;
 import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
+import org.exoplatform.portal.pom.config.cache.DataAccessMode;
+import org.exoplatform.portal.pom.data.Mapper;
+import org.exoplatform.portal.pom.data.PageData;
+import org.exoplatform.portal.pom.data.PageKey;
 import org.gatein.mop.api.Attributes;
 import org.gatein.mop.api.content.ContentType;
 import org.gatein.mop.api.content.Customization;
@@ -47,9 +48,6 @@
 {
 
    /** . */
-   protected final String pageId;
-
-   /** . */
    protected final String ownerType;
 
    /** . */
@@ -59,28 +57,17 @@
    protected final String name;
 
    /** . */
+   protected final PageKey key;
+
+   /** . */
    protected final ObjectType<? extends Site> siteType;
 
-   protected PageTask(String pageId)
+   protected PageTask(PageKey key)
    {
-      String[] chunks = split("::", pageId);
-
-      //
-      if (chunks.length != 3)
-      {
-         throw new IllegalArgumentException("Wrong pageId format should be ownerType::ownerId:name was " + pageId);
-      }
-
-      //
-      String ownerType = chunks[0];
-      String ownerId = chunks[1];
-      String name = chunks[2];
-
-      //
-      this.pageId = pageId;
-      this.ownerType = ownerType;
-      this.ownerId = ownerId;
-      this.name = name;
+      this.key = key;
+      this.ownerType = key.getType();
+      this.ownerId = key.getId();
+      this.name = key.getName();
       this.siteType = Mapper.parseSiteType(ownerType);
    }
 
@@ -100,19 +87,19 @@
       private final String cloneName;
 
       /** . */
-      private Page page;
+      private PageData page;
 
       /** . */
       private boolean deep;
 
-      public Clone(String pageId, String cloneOwnerType, String cloneOwnerId, String cloneName, boolean deep)
+      public Clone(PageKey key, PageKey cloneKey, boolean deep)
       {
-         super(pageId);
+         super(key);
 
          //
-         this.cloneOwnerType = cloneOwnerType;
-         this.cloneOwnerId = cloneOwnerId;
-         this.cloneName = cloneName;
+         this.cloneOwnerType = cloneKey.getType();
+         this.cloneOwnerId = cloneKey.getId();
+         this.cloneName = cloneKey.getName();
          this.deep = deep;
          this.cloneSiteType = Mapper.parseSiteType(cloneOwnerType);
       }
@@ -235,20 +222,52 @@
          }
       }
 
-      public Page getPage()
+      public PageData getPage()
       {
          return page;
       }
+
+      @Override
+      public String toString()
+      {
+         return "PageTask.Clone[srcOwnerType=" + ownerType + ",srcOwnerId=" + ownerId + "srcName," + name +
+            "dstOwnerType=" + cloneOwnerType + ",dstOwnerId=" + cloneOwnerId + "dstName," + cloneName + "]";
+      }
    }
 
-   public static class Remove extends PageTask
+   public static class Remove extends PageTask implements CacheableDataTask<PageKey, PageData>
    {
 
-      public Remove(Page page)
+      public Remove(PageData page)
       {
-         super(page.getPageId());
+         super(page.getKey());
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return DataAccessMode.DESTROY;
+      }
+
+      public void setValue(PageData value)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public Class<PageData> getValueType()
+      {
+         return PageData.class;
+      }
+
+      public PageData getValue()
+      {
+         return null;
+      }
+
+      public PageKey getKey()
+      {
+         return key;
+      }
+
       public void run(POMSession session)
       {
          Workspace workspace = session.getWorkspace();
@@ -271,32 +290,63 @@
             page.destroy();
          }
       }
+
+      @Override
+      public String toString()
+      {
+         return "PageTask.Remove[ownerType=" + ownerType + ",ownerId=" + ownerId + "name," + name + "]";
+      }
    }
 
-   public static class Save extends PageTask
+   public static class Save extends PageTask implements CacheableDataTask<PageKey, PageData>
    {
 
       /** . */
-      private final Page page;
+      private final PageData page;
 
       /** . */
       private List<ModelChange> changes;
 
-      public Save(Page page)
+      public Save(PageData page)
       {
-         super(page.getPageId());
+         super(page.getKey());
 
          //
          this.page = page;
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return page.getStorageId() != null ? DataAccessMode.WRITE : DataAccessMode.CREATE;
+      }
+
+      public void setValue(PageData value)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public Class<PageData> getValueType()
+      {
+         return PageData.class;
+      }
+
+      public PageData getValue()
+      {
+         return page;
+      }
+
+      public PageKey getKey()
+      {
+         return key;
+      }
+
       public void run(POMSession session) throws Exception
       {
          Workspace workspace = session.getWorkspace();
          Site site = workspace.getSite(siteType, ownerId);
          if (site == null)
          {
-            throw new IllegalArgumentException("Cannot insert page " + pageId + " as the corresponding portal "
+            throw new IllegalArgumentException("Cannot insert page " + page + " as the corresponding portal "
                + ownerId + " with type " + siteType + " does not exist");
          }
 
@@ -309,24 +359,55 @@
       {
          return changes;
       }
+
+      @Override
+      public String toString()
+      {
+         return "PageTask.Save[ownerType=" + ownerType + ",ownerId=" + ownerId + "name," + name + "]";
+      }
    }
 
-   public static class Load extends PageTask
+   public static class Load extends PageTask implements CacheableDataTask<PageKey, PageData>
    {
 
       /** . */
-      private Page page;
+      private PageData page;
 
-      public Load(String pageId)
+      public Load(PageKey key)
       {
-         super(pageId);
+         super(key);
       }
 
-      public Page getPage()
+      public PageData getPage()
       {
          return page;
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return DataAccessMode.READ;
+      }
+
+      public PageKey getKey()
+      {
+         return key;
+      }
+
+      public Class<PageData> getValueType()
+      {
+         return PageData.class;
+      }
+
+      public void setValue(PageData value)
+      {
+         page = value;
+      }
+
+      public PageData getValue()
+      {
+         return page;
+      }
+
       public void run(POMSession session)
       {
          Workspace workspace = session.getWorkspace();
@@ -342,5 +423,11 @@
             }
          }
       }
+
+      @Override
+      public String toString()
+      {
+         return "PageTask.Load[ownerType=" + ownerType + ",ownerId=" + ownerId + "name," + name + "]";
+      }
    }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -20,10 +20,13 @@
 package org.exoplatform.portal.pom.config.tasks;
 
 import org.exoplatform.portal.application.PortletPreferences;
-import org.exoplatform.portal.config.model.Mapper;
-import org.exoplatform.portal.config.model.PortalConfig;
 import org.exoplatform.portal.pom.config.AbstractPOMTask;
 import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
+import org.exoplatform.portal.pom.config.cache.DataAccessMode;
+import org.exoplatform.portal.pom.data.Mapper;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
 import org.gatein.mop.api.workspace.ObjectType;
 import org.gatein.mop.api.workspace.Page;
 import org.gatein.mop.api.workspace.Site;
@@ -37,62 +40,118 @@
 {
 
    /** . */
-   protected final String name;
+   protected final PortalKey key;
 
    /** . */
    protected final ObjectType<? extends Site> type;
 
-   protected PortalConfigTask(String type, String name)
+   protected PortalConfigTask(PortalKey key)
    {
-      this.type = Mapper.parseSiteType(type);
-      this.name = name;
+      this.key = key;
+      this.type = Mapper.parseSiteType(key.getType());
    }
 
-   public static class Remove extends PortalConfigTask
+   public static class Remove extends PortalConfigTask implements CacheableDataTask<PortalKey, PortalData>
    {
 
-      public Remove(String type, String name)
+      public Remove(PortalKey key)
       {
-         super(type, name);
+         super(key);
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return DataAccessMode.DESTROY;
+      }
+
+      public Class<PortalData> getValueType()
+      {
+         return PortalData.class;
+      }
+
+      public PortalKey getKey()
+      {
+         return key;
+      }
+
+      public void setValue(PortalData value)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public PortalData getValue()
+      {
+         return null;
+      }
+
       public void run(POMSession session)
       {
          Workspace workspace = session.getWorkspace();
-         Site site = workspace.getSite(type, name);
+         Site site = workspace.getSite(type, key.getId());
          if (site == null)
          {
-            throw new NullPointerException("Could not remove non existing portal " + name);
+            throw new NullPointerException("Could not remove non existing portal " + key.getId());
          }
          else
          {
             site.destroy();
          }
       }
+
+      @Override
+      public String toString()
+      {
+         return "PortalConfig.Remove[ownerType=" + key.getType() + ",ownerId=" + key.getId() + "]";
+      }
    }
 
-   public static class Save extends PortalConfigTask
+   public static class Save extends PortalConfigTask implements CacheableDataTask<PortalKey, PortalData>
    {
 
       /** . */
-      private final PortalConfig config;
+      private final PortalData config;
 
       /** . */
       private boolean overwrite;
 
-      public Save(PortalConfig config, boolean overwrite)
+      public Save(PortalData config, boolean overwrite)
       {
-         super(config.getType(), config.getName());
+         super(config.getKey());
 
          //
          this.config = config;
          this.overwrite = overwrite;
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return config.getStorageId() != null ? DataAccessMode.WRITE : DataAccessMode.CREATE;
+      }
+
+      public void setValue(PortalData value)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public Class<PortalData> getValueType()
+      {
+         return PortalData.class;
+      }
+
+      public PortalData getValue()
+      {
+         return config;
+      }
+
+      public PortalKey getKey()
+      {
+         return key;
+      }
+
       public void run(POMSession session) throws Exception
       {
          Workspace workspace = session.getWorkspace();
-         Site site = workspace.getSite(type, name);
+         Site site = workspace.getSite(type, key.getId());
          if (site != null)
          {
             if (!overwrite)
@@ -115,32 +174,69 @@
          }
          new Mapper(session).save(config, site);
       }
+
+      @Override
+      public String toString()
+      {
+         return "PortalConfig.Save[ownerType=" + key.getType() + ",ownerId=" + key.getId() + "]";
+      }
    }
 
-   public static class Load extends PortalConfigTask
+   public static class Load extends PortalConfigTask implements CacheableDataTask<PortalKey, PortalData>
    {
 
       /** . */
-      private PortalConfig config;
+      private PortalData config;
 
-      public Load(String type, String name)
+      public Load(PortalKey key)
       {
-         super(type, name);
+         super(key);
       }
 
-      public PortalConfig getConfig()
+      public DataAccessMode getAccessMode()
       {
+         return DataAccessMode.READ;
+      }
+
+      public PortalKey getKey()
+      {
+         return key;
+      }
+
+      public void setValue(PortalData value)
+      {
+         config = value;
+      }
+
+      public Class<PortalData> getValueType()
+      {
+         return PortalData.class;
+      }
+
+      public PortalData getValue()
+      {
          return config;
       }
 
+      public PortalData getConfig()
+      {
+         return config;
+      }
+
       public void run(POMSession session)
       {
          Workspace workspace = session.getWorkspace();
-         Site site = workspace.getSite(type, name);
+         Site site = workspace.getSite(type, key.getId());
          if (site != null)
          {
             this.config = new Mapper(session).load(site);
          }
       }
+
+      @Override
+      public String toString()
+      {
+         return "PortalConfig.Load[ownerType=" + key.getType() + ",ownerId=" + key.getId() + "]";
+      }
    }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortletPreferencesTask.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortletPreferencesTask.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortletPreferencesTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -21,9 +21,9 @@
 
 import org.exoplatform.portal.application.PortletPreferences;
 import org.exoplatform.portal.application.Preference;
-import org.exoplatform.portal.config.model.Mapper;
 import org.exoplatform.portal.pom.config.AbstractPOMTask;
 import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.data.Mapper;
 import org.exoplatform.portal.pom.spi.portlet.Preferences;
 import org.exoplatform.portal.pom.spi.portlet.PreferencesBuilder;
 import org.gatein.mop.api.content.Customization;

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -22,6 +22,8 @@
 import org.exoplatform.portal.config.model.PersistentApplicationState;
 import org.exoplatform.portal.pom.config.AbstractPOMTask;
 import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
+import org.exoplatform.portal.pom.config.cache.DataAccessMode;
 import org.gatein.mop.api.content.Customization;
 
 /**
@@ -31,7 +33,10 @@
 public abstract class PreferencesTask<S> extends AbstractPOMTask
 {
 
-   public static class Load<S> extends PreferencesTask<S>
+   /** . */
+   private static final Object NULL_PREFS = new Object();
+
+   public static class Load<S> extends PreferencesTask<S> implements CacheableDataTask<PersistentApplicationState<S>, Object>
    {
 
       /** . */
@@ -40,11 +45,39 @@
       /** . */
       private S prefs;
 
-      public Load(PersistentApplicationState state)
+      public Load(PersistentApplicationState<S> state)
       {
          this.state = state;
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return DataAccessMode.READ;
+      }
+
+      public void setValue(Object value)
+      {
+         if (value != NULL_PREFS)
+         {
+            prefs = (S)value;
+         }
+      }
+
+      public Class<Object> getValueType()
+      {
+         return Object.class;
+      }
+
+      public Object getValue()
+      {
+         return prefs == null ? NULL_PREFS : prefs;
+      }
+
+      public PersistentApplicationState<S> getKey()
+      {
+         return state;
+      }
+
       public void run(POMSession session) throws Exception
       {
          String id = state.getStorageId();
@@ -56,9 +89,15 @@
       {
          return prefs;
       }
+
+      @Override
+      public String toString()
+      {
+         return "PreferencesTask.Load[state=" + state.getStorageId() + "]";
+      }
    }
 
-   public static class Save<S> extends PreferencesTask<S>
+   public static class Save<S> extends PreferencesTask<S> implements CacheableDataTask<PersistentApplicationState<S>, Object>
    {
 
       /** . */
@@ -73,6 +112,31 @@
          this.prefs = prefs;
       }
 
+      public DataAccessMode getAccessMode()
+      {
+         return DataAccessMode.WRITE;
+      }
+
+      public void setValue(Object value)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public Class<Object> getValueType()
+      {
+         return Object.class;
+      }
+
+      public Object getValue()
+      {
+         return prefs == null ? NULL_PREFS : prefs ;
+      }
+
+      public PersistentApplicationState<S> getKey()
+      {
+         return state;
+      }
+
       public void run(POMSession session) throws Exception
       {
 
@@ -89,5 +153,11 @@
             customization.setState(null);
          }
       }
+
+      @Override
+      public String toString()
+      {
+         return "PreferencesTask.Save[state=" + state.getStorageId() + "]";
+      }
    }
 }

Modified: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/SearchTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -23,12 +23,13 @@
 import org.exoplatform.commons.utils.ListAccess;
 import org.exoplatform.portal.application.PortletPreferences;
 import org.exoplatform.portal.config.Query;
-import org.exoplatform.portal.config.model.Mapper;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PortalConfig;
 import org.exoplatform.portal.pom.config.AbstractPOMTask;
 import org.exoplatform.portal.pom.config.POMSession;
+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.gatein.mop.api.workspace.Navigation;
 import org.gatein.mop.api.workspace.ObjectType;
 import org.gatein.mop.api.workspace.Site;
@@ -47,29 +48,6 @@
 public abstract class SearchTask<T> extends AbstractPOMTask
 {
 
-   /*
-   new Query<Page>(PortalConfig.GROUP_TYPE, groupId,  Page.class);
-   new Query<Page>(PortalConfig.GROUP_TYPE, groupId,  Page.class);
-   new Query<Page>(PortalConfig.USER_TYPE, userName, Page.class);
-   new Query<Page>(PortalConfig.USER_TYPE, userName, Page.class);
-   new Query<Page>(PortalConfig.PORTAL_TYPE, portalName, null, null, Page.class);
-   new Query<Page>(null, null, null, null, Page.class);
-
-   new Query<PortletPreferences>(PortalConfig.GROUP_TYPE, groupId, PortletPreferences.class);
-   new Query<PortletPreferences>(PortalConfig.GROUP_TYPE, groupId, PortletPreferences.class);
-   new Query<PortletPreferences>(PortalConfig.USER_TYPE, userName, PortletPreferences.class);
-   new Query<PortletPreferences>(PortalConfig.PORTAL_TYPE, portalName, null, null, PortletPreferences.class);
-
-   new Query<PageNavigation>(PortalConfig.GROUP_TYPE, null, PageNavigation.class);
-   new Query<PageNavigation>(PortalConfig.GROUP_TYPE, null, PageNavigation.class);
-   new Query<PageNavigation>(PortalConfig.GROUP_TYPE, null, PageNavigation.class);
-
-   new Query<PortalConfig>(null, null, null, null, PortalConfig.class);
-   new Query<PortalConfig>(null, null, null, null, PortalConfig.class);
-   new Query<PortalConfig>(null, null, null, null, PortalConfig.class);
-   new Query<PortalConfig>(null, null, null, null, PortalConfig.class);
-   */
-
    /** . */
    protected final Query<T> q;
 
@@ -153,10 +131,10 @@
 
    }
 
-   public static class FindPage extends FindSiteObject<org.gatein.mop.api.workspace.Page, Page>
+   public static class FindPage extends FindSiteObject<org.gatein.mop.api.workspace.Page, PageData>
    {
 
-      public FindPage(Query<Page> pageQuery)
+      public FindPage(Query<PageData> pageQuery)
       {
          super(pageQuery);
       }
@@ -167,21 +145,21 @@
          return session.findObjects(ObjectType.PAGE, siteType, q.getOwnerId(), q.getTitle());
       }
 
-      protected Page[] createT(int length)
+      protected PageData[] createT(int length)
       {
-         return new Page[length];
+         return new PageData[length];
       }
 
-      protected Page loadT(POMSession session, org.gatein.mop.api.workspace.Page w)
+      protected PageData loadT(POMSession session, org.gatein.mop.api.workspace.Page w)
       {
          return new Mapper(session).load(w);
       }
    }
 
-   public static class FindNavigation extends FindSiteObject<Navigation, PageNavigation>
+   public static class FindNavigation extends FindSiteObject<Navigation, NavigationData>
    {
 
-      public FindNavigation(Query<PageNavigation> pageQuery)
+      public FindNavigation(Query<NavigationData> pageQuery)
       {
          super(pageQuery);
       }
@@ -192,12 +170,12 @@
          return session.findObjects(ObjectType.NAVIGATION, siteType, q.getOwnerId(), q.getTitle());
       }
 
-      protected PageNavigation[] createT(int length)
+      protected NavigationData[] createT(int length)
       {
-         return new PageNavigation[length];
+         return new NavigationData[length];
       }
 
-      protected PageNavigation loadT(POMSession session, Navigation w)
+      protected NavigationData loadT(POMSession session, Navigation w)
       {
          return new Mapper(session).load(w);
       }
@@ -230,10 +208,10 @@
       }
    }
 
-   public static class FindSite extends SearchTask<PortalConfig>
+   public static class FindSite extends SearchTask<PortalData>
    {
 
-      public FindSite(Query<PortalConfig> siteQuery)
+      public FindSite(Query<PortalData> siteQuery)
       {
          super(siteQuery);
       }
@@ -241,15 +219,16 @@
       public void run(final POMSession session) throws Exception
       {
          Workspace workspace = session.getWorkspace();
-         final Collection<? extends Site> portals = workspace.getSites(ObjectType.PORTAL_SITE);
-
-         ListAccess<PortalConfig> la = new ListAccess<PortalConfig>()
+         String ownerType = q.getOwnerType();
+         ObjectType<Site> siteType = ownerType == null ? ObjectType.PORTAL_SITE : Mapper.parseSiteType(ownerType);
+         final Collection<? extends Site> portals = workspace.getSites(siteType);
+         ListAccess<PortalData> la = new ListAccess<PortalData>()
          {
-            public PortalConfig[] load(int index, int length) throws Exception, IllegalArgumentException
+            public PortalData[] load(int index, int length) throws Exception, IllegalArgumentException
             {
                Iterator<? extends Site> iterator = portals.iterator();
                Mapper mapper = new Mapper(session);
-               PortalConfig[] result = new PortalConfig[length];
+               PortalData[] result = new PortalData[length];
                for (int i = 0; i < length; i++)
                {
                   result[i] = mapper.load(iterator.next());
@@ -262,7 +241,42 @@
                return portals.size();
             }
          };
-         result = new LazyPageList<PortalConfig>(la, 10);
+         result = new LazyPageList<PortalData>(la, 10);
       }
    }
+
+   public static class FindSiteKey extends SearchTask<PortalKey>
+   {
+
+      public FindSiteKey(Query<PortalKey> siteQuery)
+      {
+         super(siteQuery);
+      }
+
+      public void run(final POMSession session) throws Exception
+      {
+         Workspace workspace = session.getWorkspace();
+         final Collection<? extends Site> portals = workspace.getSites(ObjectType.PORTAL_SITE);
+         ListAccess<PortalKey> la = new ListAccess<PortalKey>()
+         {
+            public PortalKey[] load(int index, int length) throws Exception, IllegalArgumentException
+            {
+               Iterator<? extends Site> iterator = portals.iterator();
+               PortalKey[] result = new PortalKey[length];
+               for (int i = 0; i < length; i++)
+               {
+                  Site site = iterator.next();
+                  result[i] = new PortalKey("portal", site.getName());
+               }
+               return result;
+            }
+
+            public int getSize() throws Exception
+            {
+               return portals.size();
+            }
+         };
+         result = new LazyPageList<PortalKey>(la, 10);
+      }
+   }
 }

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data)

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ApplicationData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ApplicationData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ApplicationData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,191 +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.data;
-
-import org.exoplatform.portal.config.model.ApplicationState;
-import org.exoplatform.portal.config.model.ApplicationType;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class ApplicationData<S, I> extends ComponentData
-{
-
-   /** . */
-   private final ApplicationType<S, I> type;
-
-   /** . */
-   private final ApplicationState<S> state;
-
-   /** . */
-   private final I ref;
-
-   /** . */
-   private final String id;
-
-   /** . */
-   private final String title;
-
-   /** . */
-   private final String icon;
-
-   /** . */
-   private final String description;
-
-   /** . */
-   private final boolean showInfoBar;
-
-   /** . */
-   private final boolean showApplicationState;
-
-   /** . */
-   private final boolean showApplicationMode;
-
-   /** . */
-   private final String theme;
-
-   /** . */
-   private final String width;
-
-   /** . */
-   private final String height;
-
-   /** . */
-   private final Map<String, String> properties;
-
-   /** . */
-   private final List<String> accessPermissions;
-
-   public ApplicationData(
-      String storageId,
-      String storageName,
-      ApplicationType<S, I> type,
-      ApplicationState<S> state,
-      I ref,
-      String id,
-      String title,
-      String icon,
-      String description,
-      boolean showInfoBar,
-      boolean showApplicationState,
-      boolean showApplicationMode,
-      String theme, String width,
-      String height,
-      Map<String, String> properties,
-      List<String> accessPermissions)
-   {
-      super(storageId, storageName);
-
-      //
-      this.type = type;
-      this.state = state;
-      this.ref = ref;
-      this.id = id;
-      this.title = title;
-      this.icon = icon;
-      this.description = description;
-      this.showInfoBar = showInfoBar;
-      this.showApplicationState = showApplicationState;
-      this.showApplicationMode = showApplicationMode;
-      this.theme = theme;
-      this.width = width;
-      this.height = height;
-      this.properties = properties;
-      this.accessPermissions = accessPermissions;
-   }
-
-   public ApplicationType<S, I> getType()
-   {
-      return type;
-   }
-
-   public ApplicationState<S> getState()
-   {
-      return state;
-   }
-
-   public I getRef()
-   {
-      return ref;
-   }
-
-   public String getId()
-   {
-      return id;
-   }
-
-   public String getTitle()
-   {
-      return title;
-   }
-
-   public String getIcon()
-   {
-      return icon;
-   }
-
-   public String getDescription()
-   {
-      return description;
-   }
-
-   public boolean isShowInfoBar()
-   {
-      return showInfoBar;
-   }
-
-   public boolean isShowApplicationState()
-   {
-      return showApplicationState;
-   }
-
-   public boolean isShowApplicationMode()
-   {
-      return showApplicationMode;
-   }
-
-   public String getTheme()
-   {
-      return theme;
-   }
-
-   public String getWidth()
-   {
-      return width;
-   }
-
-   public String getHeight()
-   {
-      return height;
-   }
-
-   public Map<String, String> getProperties()
-   {
-      return properties;
-   }
-
-   public List<String> getAccessPermissions()
-   {
-      return accessPermissions;
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ApplicationData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ApplicationData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ApplicationData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ApplicationData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,191 @@
+/**
+ * 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.data;
+
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ApplicationData<S, I> extends ComponentData
+{
+
+   /** . */
+   private final ApplicationType<S, I> type;
+
+   /** . */
+   private final ApplicationState<S> state;
+
+   /** . */
+   private final I ref;
+
+   /** . */
+   private final String id;
+
+   /** . */
+   private final String title;
+
+   /** . */
+   private final String icon;
+
+   /** . */
+   private final String description;
+
+   /** . */
+   private final boolean showInfoBar;
+
+   /** . */
+   private final boolean showApplicationState;
+
+   /** . */
+   private final boolean showApplicationMode;
+
+   /** . */
+   private final String theme;
+
+   /** . */
+   private final String width;
+
+   /** . */
+   private final String height;
+
+   /** . */
+   private final Map<String, String> properties;
+
+   /** . */
+   private final List<String> accessPermissions;
+
+   public ApplicationData(
+      String storageId,
+      String storageName,
+      ApplicationType<S, I> type,
+      ApplicationState<S> state,
+      I ref,
+      String id,
+      String title,
+      String icon,
+      String description,
+      boolean showInfoBar,
+      boolean showApplicationState,
+      boolean showApplicationMode,
+      String theme, String width,
+      String height,
+      Map<String, String> properties,
+      List<String> accessPermissions)
+   {
+      super(storageId, storageName);
+
+      //
+      this.type = type;
+      this.state = state;
+      this.ref = ref;
+      this.id = id;
+      this.title = title;
+      this.icon = icon;
+      this.description = description;
+      this.showInfoBar = showInfoBar;
+      this.showApplicationState = showApplicationState;
+      this.showApplicationMode = showApplicationMode;
+      this.theme = theme;
+      this.width = width;
+      this.height = height;
+      this.properties = properties;
+      this.accessPermissions = accessPermissions;
+   }
+
+   public ApplicationType<S, I> getType()
+   {
+      return type;
+   }
+
+   public ApplicationState<S> getState()
+   {
+      return state;
+   }
+
+   public I getRef()
+   {
+      return ref;
+   }
+
+   public String getId()
+   {
+      return id;
+   }
+
+   public String getTitle()
+   {
+      return title;
+   }
+
+   public String getIcon()
+   {
+      return icon;
+   }
+
+   public String getDescription()
+   {
+      return description;
+   }
+
+   public boolean isShowInfoBar()
+   {
+      return showInfoBar;
+   }
+
+   public boolean isShowApplicationState()
+   {
+      return showApplicationState;
+   }
+
+   public boolean isShowApplicationMode()
+   {
+      return showApplicationMode;
+   }
+
+   public String getTheme()
+   {
+      return theme;
+   }
+
+   public String getWidth()
+   {
+      return width;
+   }
+
+   public String getHeight()
+   {
+      return height;
+   }
+
+   public Map<String, String> getProperties()
+   {
+      return properties;
+   }
+
+   public List<String> getAccessPermissions()
+   {
+      return accessPermissions;
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,43 +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.data;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class BodyData extends ComponentData
-{
-
-   /** . */
-   private final BodyType type;
-
-   public BodyData(String storageId, BodyType type)
-   {
-      super(storageId, null);
-
-      //
-      this.type = type;
-   }
-
-   public BodyType getType()
-   {
-      return type;
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,43 @@
+/**
+ * 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.data;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class BodyData extends ComponentData
+{
+
+   /** . */
+   private final BodyType type;
+
+   public BodyData(String storageId, BodyType type)
+   {
+      super(storageId, null);
+
+      //
+      this.type = type;
+   }
+
+   public BodyType getType()
+   {
+      return type;
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyType.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyType.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyType.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,30 +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.data;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public enum BodyType
-{
-
-   SITE, PAGE
-
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyType.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyType.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyType.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/BodyType.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,30 @@
+/**
+ * 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.data;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum BodyType
+{
+
+   SITE, PAGE
+
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,32 +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.data;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class ComponentData extends ModelData
-{
-
-   public ComponentData(String storageId, String storageName)
-   {
-      super(storageId, storageName);
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,32 @@
+/**
+ * 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.data;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ComponentData extends ModelData
+{
+
+   public ComponentData(String storageId, String storageName)
+   {
+      super(storageId, storageName);
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ContainerData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ContainerData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ContainerData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,157 +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.data;
-
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class ContainerData extends ComponentData
-{
-
-   /** . */
-   private final String id;
-
-   /** . */
-   private final String name;
-
-   /** . */
-   private final String icon;
-
-   /** . */
-   private final String decorator;
-
-   /** . */
-   private final String template;
-
-   /** . */
-   private final String factoryId;
-
-   /** . */
-   private final String title;
-
-   /** . */
-   private final String description;
-
-   /** . */
-   private final String width;
-
-   /** . */
-   private final String height;
-
-   /** . */
-   private final List<String> accessPermissions;
-
-   /** . */
-   private final List<ComponentData> children;
-
-   public ContainerData(
-      String storageId,
-      String id,
-      String name,
-      String icon,
-      String decorator,
-      String template,
-      String factoryId,
-      String title,
-      String description,
-      String width,
-      String height,
-      List<String> accessPermissions,
-      List<ComponentData> children)
-   {
-      super(storageId, null);
-
-      //
-      this.id = id;
-      this.name = name;
-      this.icon = icon;
-      this.decorator = decorator;
-      this.template = template;
-      this.factoryId = factoryId;
-      this.title = title;
-      this.description = description;
-      this.width = width;
-      this.height = height;
-      this.accessPermissions = accessPermissions;
-      this.children = children;
-   }
-
-   public String getId()
-   {
-      return id;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public String getIcon()
-   {
-      return icon;
-   }
-
-   public String getDecorator()
-   {
-      return decorator;
-   }
-
-   public String getTemplate()
-   {
-      return template;
-   }
-
-   public String getFactoryId()
-   {
-      return factoryId;
-   }
-
-   public String getTitle()
-   {
-      return title;
-   }
-
-   public String getDescription()
-   {
-      return description;
-   }
-
-   public String getWidth()
-   {
-      return width;
-   }
-
-   public String getHeight()
-   {
-      return height;
-   }
-
-   public List<String> getAccessPermissions()
-   {
-      return accessPermissions;
-   }
-
-   public List<ComponentData> getChildren()
-   {
-      return children;
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ContainerData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ContainerData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ContainerData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ContainerData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,157 @@
+/**
+ * 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.data;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ContainerData extends ComponentData
+{
+
+   /** . */
+   private final String id;
+
+   /** . */
+   private final String name;
+
+   /** . */
+   private final String icon;
+
+   /** . */
+   private final String decorator;
+
+   /** . */
+   private final String template;
+
+   /** . */
+   private final String factoryId;
+
+   /** . */
+   private final String title;
+
+   /** . */
+   private final String description;
+
+   /** . */
+   private final String width;
+
+   /** . */
+   private final String height;
+
+   /** . */
+   private final List<String> accessPermissions;
+
+   /** . */
+   private final List<ComponentData> children;
+
+   public ContainerData(
+      String storageId,
+      String id,
+      String name,
+      String icon,
+      String decorator,
+      String template,
+      String factoryId,
+      String title,
+      String description,
+      String width,
+      String height,
+      List<String> accessPermissions,
+      List<ComponentData> children)
+   {
+      super(storageId, null);
+
+      //
+      this.id = id;
+      this.name = name;
+      this.icon = icon;
+      this.decorator = decorator;
+      this.template = template;
+      this.factoryId = factoryId;
+      this.title = title;
+      this.description = description;
+      this.width = width;
+      this.height = height;
+      this.accessPermissions = accessPermissions;
+      this.children = children;
+   }
+
+   public String getId()
+   {
+      return id;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public String getIcon()
+   {
+      return icon;
+   }
+
+   public String getDecorator()
+   {
+      return decorator;
+   }
+
+   public String getTemplate()
+   {
+      return template;
+   }
+
+   public String getFactoryId()
+   {
+      return factoryId;
+   }
+
+   public String getTitle()
+   {
+      return title;
+   }
+
+   public String getDescription()
+   {
+      return description;
+   }
+
+   public String getWidth()
+   {
+      return width;
+   }
+
+   public String getHeight()
+   {
+      return height;
+   }
+
+   public List<String> getAccessPermissions()
+   {
+      return accessPermissions;
+   }
+
+   public List<ComponentData> getChildren()
+   {
+      return children;
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/DashboardData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/DashboardData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/DashboardData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,105 +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.data;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class DashboardData extends ContainerData
-{
-
-   public DashboardData(
-      String storageId,
-      String id,
-      String name,
-      String icon,
-      String decorator,
-      String template,
-      String factoryId,
-      String title,
-      String description,
-      String width,
-      String height,
-      List<String> accessPermissions,
-      List<ComponentData> children)
-   {
-      super(
-         storageId,
-         id,
-         name,
-         icon,
-         decorator,
-         template,
-         factoryId,
-         title,
-         description,
-         width,
-         height,
-         accessPermissions,
-         children);
-   }
-
-   /** . */
-   static final DashboardData INITIAL_DASHBOARD;
-
-   static
-   {
-      List<ComponentData> children = new ArrayList<ComponentData>();
-      for (int i = 0; i < 3; i++)
-      {
-         ContainerData row = new ContainerData(
-            null,
-            null,
-            null,
-            null,
-            null,
-            "classpath:groovy/dashboard/webui/component/UIContainer.gtmpl",
-            null,
-            null,
-            null,
-            null,
-            null,
-            Collections.<String>emptyList(),
-            Collections.<ComponentData>emptyList());
-         children.add(row);
-      }
-
-      INITIAL_DASHBOARD = new DashboardData(
-         null,
-         null,
-         null,
-         null,
-         null,
-         "classpath:groovy/dashboard/webui/component/UIColumnContainer.gtmpl",
-         null,
-         null,
-         null,
-         null,
-         null,
-         Collections.<String>emptyList(),
-         Collections.unmodifiableList(children)
-      );
-   }
-
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/DashboardData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/DashboardData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/DashboardData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/DashboardData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,105 @@
+/**
+ * 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.data;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class DashboardData extends ContainerData
+{
+
+   public DashboardData(
+      String storageId,
+      String id,
+      String name,
+      String icon,
+      String decorator,
+      String template,
+      String factoryId,
+      String title,
+      String description,
+      String width,
+      String height,
+      List<String> accessPermissions,
+      List<ComponentData> children)
+   {
+      super(
+         storageId,
+         id,
+         name,
+         icon,
+         decorator,
+         template,
+         factoryId,
+         title,
+         description,
+         width,
+         height,
+         accessPermissions,
+         children);
+   }
+
+   /** . */
+   static final DashboardData INITIAL_DASHBOARD;
+
+   static
+   {
+      List<ComponentData> children = new ArrayList<ComponentData>();
+      for (int i = 0; i < 3; i++)
+      {
+         ContainerData row = new ContainerData(
+            null,
+            null,
+            null,
+            null,
+            null,
+            "classpath:groovy/dashboard/webui/component/UIContainer.gtmpl",
+            null,
+            null,
+            null,
+            null,
+            null,
+            Collections.<String>emptyList(),
+            Collections.<ComponentData>emptyList());
+         children.add(row);
+      }
+
+      INITIAL_DASHBOARD = new DashboardData(
+         null,
+         null,
+         null,
+         null,
+         null,
+         "classpath:groovy/dashboard/webui/component/UIColumnContainer.gtmpl",
+         null,
+         null,
+         null,
+         null,
+         null,
+         Collections.<String>emptyList(),
+         Collections.unmodifiableList(children)
+      );
+   }
+
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,126 +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.data;
-
-import org.gatein.mop.api.Key;
-import org.gatein.mop.api.ValueType;
-
-import java.util.Date;
-
-/**
- * A class to hold the various attributes mapped between the model and the mop layer.
- *
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class MappedAttributes
-{
-
-   private MappedAttributes()
-   {
-   }
-
-   /** . */
-   public static final Key<String> ID = Key.create("id", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> NAME = Key.create("name", ValueType.STRING);
-
-   /** . */
-   public static final Key<Boolean> SHOW_MAX_WINDOW = Key.create("show-max-window", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<String> TITLE = Key.create("title", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> FACTORY_ID = Key.create("factory-id", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> ACCESS_PERMISSIONS = Key.create("access-permissions", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> EDIT_PERMISSION = Key.create("edit-permission", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> CREATOR = Key.create("creator", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> MODIFIER = Key.create("modifier", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> DESCRIPTION = Key.create("description", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> DECORATOR = Key.create("decorator", ValueType.STRING);
-
-   /** . */
-   public static final Key<Integer> PRIORITY = Key.create("priority", ValueType.INTEGER);
-
-   /** . */
-   public static final Key<String> LABEL = Key.create("label", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> ICON = Key.create("icon", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> URI = Key.create("uri", ValueType.STRING);
-
-   /** . */
-   public static final Key<Date> START_PUBLICATION_DATE = Key.create("start-publication-date", ValueType.DATE);
-
-   /** . */
-   public static final Key<Date> END_PUBLICATION_DATE = Key.create("end-publication-date", ValueType.DATE);
-
-   /** . */
-   public static final Key<Boolean> VISIBLE = Key.create("visible", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<String> TEMPLATE = Key.create("template", ValueType.STRING);
-
-   /** . */
-   public static final Key<Boolean> SHOW_PUBLICATION_DATE = Key.create("show-publication-date", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<Boolean> SHOW_INFO_BAR = Key.create("show-info-bar", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<Boolean> SHOW_STATE = Key.create("show-state", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<Boolean> SHOW_MODE = Key.create("show-mode", ValueType.BOOLEAN);
-
-   /** . */
-   public static final Key<String> LOCALE = Key.create("locale", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> SKIN = Key.create("skin", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> WIDTH = Key.create("width", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> HEIGHT = Key.create("height", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> TYPE = Key.create("type", ValueType.STRING);
-
-   /** . */
-   public static final Key<String> THEME = Key.create("theme", ValueType.STRING);
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,126 @@
+/**
+ * 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.data;
+
+import org.gatein.mop.api.Key;
+import org.gatein.mop.api.ValueType;
+
+import java.util.Date;
+
+/**
+ * A class to hold the various attributes mapped between the model and the mop layer.
+ *
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class MappedAttributes
+{
+
+   private MappedAttributes()
+   {
+   }
+
+   /** . */
+   public static final Key<String> ID = Key.create("id", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> NAME = Key.create("name", ValueType.STRING);
+
+   /** . */
+   public static final Key<Boolean> SHOW_MAX_WINDOW = Key.create("show-max-window", ValueType.BOOLEAN);
+
+   /** . */
+   public static final Key<String> TITLE = Key.create("title", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> FACTORY_ID = Key.create("factory-id", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> ACCESS_PERMISSIONS = Key.create("access-permissions", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> EDIT_PERMISSION = Key.create("edit-permission", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> CREATOR = Key.create("creator", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> MODIFIER = Key.create("modifier", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> DESCRIPTION = Key.create("description", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> DECORATOR = Key.create("decorator", ValueType.STRING);
+
+   /** . */
+   public static final Key<Integer> PRIORITY = Key.create("priority", ValueType.INTEGER);
+
+   /** . */
+   public static final Key<String> LABEL = Key.create("label", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> ICON = Key.create("icon", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> URI = Key.create("uri", ValueType.STRING);
+
+   /** . */
+   public static final Key<Date> START_PUBLICATION_DATE = Key.create("start-publication-date", ValueType.DATE);
+
+   /** . */
+   public static final Key<Date> END_PUBLICATION_DATE = Key.create("end-publication-date", ValueType.DATE);
+
+   /** . */
+   public static final Key<Boolean> VISIBLE = Key.create("visible", ValueType.BOOLEAN);
+
+   /** . */
+   public static final Key<String> TEMPLATE = Key.create("template", ValueType.STRING);
+
+   /** . */
+   public static final Key<Boolean> SHOW_PUBLICATION_DATE = Key.create("show-publication-date", ValueType.BOOLEAN);
+
+   /** . */
+   public static final Key<Boolean> SHOW_INFO_BAR = Key.create("show-info-bar", ValueType.BOOLEAN);
+
+   /** . */
+   public static final Key<Boolean> SHOW_STATE = Key.create("show-state", ValueType.BOOLEAN);
+
+   /** . */
+   public static final Key<Boolean> SHOW_MODE = Key.create("show-mode", ValueType.BOOLEAN);
+
+   /** . */
+   public static final Key<String> LOCALE = Key.create("locale", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> SKIN = Key.create("skin", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> WIDTH = Key.create("width", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> HEIGHT = Key.create("height", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> TYPE = Key.create("type", ValueType.STRING);
+
+   /** . */
+   public static final Key<String> THEME = Key.create("theme", ValueType.STRING);
+}

Deleted: portal/branches/wsrp-integration/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	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,1088 +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.data;
-
-import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.model.ApplicationState;
-import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.pom.data.BodyType;
-import org.exoplatform.portal.config.model.ModelChange;
-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.config.model.gadget.GadgetId;
-import org.exoplatform.portal.pom.config.Utils;
-import static org.exoplatform.portal.pom.config.Utils.join;
-import static org.exoplatform.portal.pom.config.Utils.split;
-
-import org.exoplatform.portal.config.model.portlet.PortletId;
-import org.exoplatform.portal.config.model.wsrp.WSRPId;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.data.ApplicationData;
-import org.exoplatform.portal.pom.data.BodyData;
-import org.exoplatform.portal.pom.data.ComponentData;
-import org.exoplatform.portal.pom.data.ContainerData;
-import org.exoplatform.portal.pom.data.DashboardData;
-import org.exoplatform.portal.pom.data.ModelData;
-import org.exoplatform.portal.pom.data.NavigationNodeContainerData;
-import org.exoplatform.portal.pom.data.PageData;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.spi.gadget.Gadget;
-import org.exoplatform.portal.pom.spi.portlet.Preferences;
-import org.exoplatform.portal.pom.spi.wsrp.WSRPState;
-import org.gatein.mop.api.Attributes;
-import org.gatein.mop.api.content.ContentType;
-import org.gatein.mop.api.content.Customization;
-import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Site;
-import org.gatein.mop.api.workspace.Workspace;
-import org.gatein.mop.api.workspace.WorkspaceObject;
-import org.gatein.mop.api.workspace.link.Link;
-import org.gatein.mop.api.workspace.link.PageLink;
-import org.gatein.mop.api.workspace.ui.UIBody;
-import org.gatein.mop.api.workspace.ui.UIComponent;
-import org.gatein.mop.api.workspace.ui.UIContainer;
-import org.gatein.mop.api.workspace.ui.UIWindow;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class Mapper
-{
-
-   /** . */
-   private static final Set<String> portalPropertiesBlackList =
-      new HashSet<String>(Arrays.asList("jcr:uuid", "jcr:primaryType", MappedAttributes.LOCALE.getName(),
-         MappedAttributes.ACCESS_PERMISSIONS.getName(), MappedAttributes.EDIT_PERMISSION.getName(),
-         MappedAttributes.SKIN.getName(), MappedAttributes.TITLE.getName(), MappedAttributes.CREATOR.getName(),
-         MappedAttributes.MODIFIER.getName()));
-
-   /** . */
-   private static final Set<String> windowPropertiesBlackList =
-      new HashSet<String>(Arrays.asList("jcr:uuid", "jcr:primaryType", MappedAttributes.TYPE.getName(),
-         MappedAttributes.THEME.getName(), MappedAttributes.TITLE.getName(), MappedAttributes.ACCESS_PERMISSIONS
-            .getName(), MappedAttributes.SHOW_INFO_BAR.getName(), MappedAttributes.SHOW_STATE.getName(),
-         MappedAttributes.SHOW_MODE.getName(), MappedAttributes.DESCRIPTION.getName(), MappedAttributes.ICON.getName(),
-         MappedAttributes.WIDTH.getName(), MappedAttributes.HEIGHT.getName()));
-
-   /** . */
-   private final POMSession session;
-
-   public Mapper(POMSession session)
-   {
-      this.session = session;
-   }
-
-   public NavigationData load(Navigation src)
-   {
-      return load(src, NavigationData.class);
-   }
-
-   private <T extends NavigationNodeContainerData> T load(Navigation src, Class<T> type)
-   {
-
-      //
-      ArrayList<NavigationNodeData> children = new ArrayList<NavigationNodeData>(src.getChildren().size());
-      for (Navigation srcChild : src.getChildren())
-      {
-         NavigationNodeData dstChild = load(srcChild, NavigationNodeData.class);
-         children.add(dstChild);
-      }
-
-      //
-      T dst;
-      if (type == NavigationData.class)
-      {
-         Site site = src.getSite();
-         String ownerType = getOwnerType(site.getObjectType());
-         String ownerId = site.getName();
-         Attributes attrs = src.getAttributes();
-         NavigationData dstNav = new NavigationData(
-            src.getObjectId(),
-            ownerType,
-            ownerId,
-            attrs.getValue(MappedAttributes.DESCRIPTION),
-            attrs.getValue(MappedAttributes.CREATOR),
-            attrs.getValue(MappedAttributes.MODIFIER),
-            attrs.getValue(MappedAttributes.PRIORITY, 1),
-            children);
-         dst = (T)dstNav;
-      }
-      else if (type == NavigationNodeData.class)
-      {
-         Attributes attrs = src.getAttributes();
-         String pageReference = null;
-         Link link = src.getLink();
-         if (link instanceof PageLink)
-         {
-            PageLink pageLink = (PageLink)link;
-            org.gatein.mop.api.workspace.Page target = pageLink.getPage();
-            if (target != null)
-            {
-               Site site = target.getSite();
-               ObjectType<? extends Site> siteType = site.getObjectType();
-               pageReference = getOwnerType(siteType) + "::" + site.getName() + "::" + target.getName();
-            }
-         }
-         NavigationNodeData dstNode = new NavigationNodeData(
-            src.getObjectId(),
-            attrs.getValue(MappedAttributes.URI),
-            attrs.getValue(MappedAttributes.LABEL),
-            attrs.getValue(MappedAttributes.ICON),
-            src.getName(),
-            attrs.getValue(MappedAttributes.START_PUBLICATION_DATE),
-            attrs.getValue(MappedAttributes.END_PUBLICATION_DATE),
-            attrs.getValue(MappedAttributes.SHOW_PUBLICATION_DATE, false),
-            attrs.getValue(MappedAttributes.VISIBLE, true),
-            pageReference,
-            children
-         );
-
-         dst = (T)dstNode;
-      }
-      else
-      {
-         throw new AssertionError();
-      }
-
-      //
-      return dst;
-   }
-
-   public void save(NavigationData src, Navigation dst)
-   {
-      save((NavigationNodeContainerData)src, dst);
-   }
-
-   private void save(NavigationNodeContainerData src, Navigation dst)
-   {
-      if (src instanceof NavigationNodeData)
-      {
-         NavigationNodeData node = (NavigationNodeData)src;
-         Workspace workspace = dst.getSite().getWorkspace();
-         String reference = node.getPageReference();
-         if (reference != null)
-         {
-            String[] pageChunks = split("::", reference);
-            ObjectType<? extends Site> siteType = parseSiteType(pageChunks[0]);
-            Site site = workspace.getSite(siteType, pageChunks[1]);
-            org.gatein.mop.api.workspace.Page target = site.getRootPage().getChild("pages").getChild(pageChunks[2]);
-            PageLink link = dst.linkTo(ObjectType.PAGE_LINK);
-            link.setPage(target);
-         }
-
-         //
-         Attributes attrs = dst.getAttributes();
-         attrs.setValue(MappedAttributes.URI, node.getURI());
-         attrs.setValue(MappedAttributes.LABEL, node.getLabel());
-         attrs.setValue(MappedAttributes.ICON, node.getIcon());
-         attrs.setValue(MappedAttributes.START_PUBLICATION_DATE, node.getStartPublicationDate());
-         attrs.setValue(MappedAttributes.END_PUBLICATION_DATE, node.getEndPublicationDate());
-         attrs.setValue(MappedAttributes.SHOW_PUBLICATION_DATE, node.getShowPublicationDate());
-         attrs.setValue(MappedAttributes.VISIBLE, node.isVisible());
-      }
-      else if (src instanceof NavigationData)
-      {
-         NavigationData pageNav = (NavigationData)src;
-
-         //
-         Attributes attrs = dst.getAttributes();
-         attrs.setValue(MappedAttributes.PRIORITY, pageNav.getPriority());
-         attrs.setValue(MappedAttributes.CREATOR, pageNav.getCreator());
-         attrs.setValue(MappedAttributes.MODIFIER, pageNav.getModifier());
-         attrs.setValue(MappedAttributes.DESCRIPTION, pageNav.getDescription());
-      }
-      else
-      {
-         throw new AssertionError();
-      }
-
-      //
-      Set<String> savedSet = new HashSet<String>();
-      for (NavigationNodeData node : src.getNodes())
-      {
-         String srcId = node.getStorageId();
-         Navigation dstChild;
-         if (srcId != null)
-         {
-            dstChild = session.findObjectById(ObjectType.NAVIGATION, srcId);
-         }
-         else
-         {
-            dstChild = dst.getChild(node.getName());
-            if (dstChild == null)
-            {
-               dstChild = dst.addChild(node.getName());
-            }
-            srcId = dstChild.getObjectId();
-         }
-         save(node, dstChild);
-         savedSet.add(srcId);
-      }
-      for (Iterator<? extends Navigation> i = dst.getChildren().iterator(); i.hasNext();)
-      {
-         Navigation dstChild = i.next();
-         if (!savedSet.contains(dstChild.getObjectId()))
-         {
-            i.remove();
-         }
-      }
-   }
-
-   public PortalData load(Site src)
-   {
-      String type = Mapper.getOwnerType(src.getObjectType());
-      Attributes attrs = src.getAttributes();
-
-      //
-      org.gatein.mop.api.workspace.Page template = src.getRootNavigation().getTemplate();
-      UIContainer srcLayout = template.getRootComponent();
-
-      //
-      Map<String, String> properties = new HashMap<String, String>();
-      load(attrs, properties, portalPropertiesBlackList);
-
-      //
-      List<ComponentData> layoutChildren = loadChildren(srcLayout);
-      ContainerData layout = load(srcLayout, layoutChildren);
-
-      //
-      return new PortalData(
-         src.getObjectId(),
-         src.getName(),
-         type,
-         attrs.getValue(MappedAttributes.LOCALE),
-         Collections.unmodifiableList(Arrays.asList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS, "")))),
-         attrs.getValue(MappedAttributes.EDIT_PERMISSION),
-         Collections.unmodifiableMap(properties),
-         attrs.getValue(MappedAttributes.SKIN),
-         attrs.getValue(MappedAttributes.TITLE),
-         layout,
-         attrs.getValue(MappedAttributes.CREATOR),
-         attrs.getValue(MappedAttributes.MODIFIER));
-   }
-
-   public void save(PortalData src, Site dst)
-   {
-      if (src.getStorageId() != null && !src.getStorageId().equals(dst.getObjectId()))
-      {
-         String msg =
-            "Attempt to save a site " + src.getType() + "/" + src.getName() + " on the wrong target site "
-               + dst.getObjectType() + "/" + dst.getName();
-         throw new IllegalArgumentException(msg);
-      }
-
-      //
-      Attributes attrs = dst.getAttributes();
-      attrs.setValue(MappedAttributes.LOCALE, src.getLocale());
-      attrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
-      attrs.setValue(MappedAttributes.EDIT_PERMISSION, src.getEditPermission());
-      attrs.setValue(MappedAttributes.SKIN, src.getSkin());
-      attrs.setValue(MappedAttributes.TITLE, src.getTitle());
-      attrs.setValue(MappedAttributes.CREATOR, src.getCreator());
-      attrs.setValue(MappedAttributes.MODIFIER, src.getModifier());
-      if (src.getProperties() != null)
-      {
-         save(src.getProperties(), attrs);
-      }
-
-      //
-      org.gatein.mop.api.workspace.Page templates = dst.getRootPage().getChild("templates");
-      org.gatein.mop.api.workspace.Page template = templates.getChild("default");
-      if (template == null)
-      {
-         template = templates.addChild("default");
-      }
-
-      //
-      ContainerData srcContainer = src.getPortalLayout();
-      UIContainer dstContainer = template.getRootComponent();
-
-      //
-      save(srcContainer, dstContainer);
-      saveChildren(srcContainer, dstContainer);
-
-      //
-      dst.getRootNavigation().setTemplate(template);
-   }
-
-   public PageData load(org.gatein.mop.api.workspace.Page src)
-   {
-      Site site = src.getSite();
-      String ownerType = getOwnerType(site.getObjectType());
-      String ownerId = site.getName();
-      String name = src.getName();
-      List<ComponentData> children = loadChildren(src.getRootComponent());
-      Attributes attrs = src.getAttributes();
-
-      //
-      return new PageData(
-         src.getObjectId(),
-         null,
-         name,
-         null,
-         null,
-         null,
-         attrs.getValue(MappedAttributes.FACTORY_ID),
-         attrs.getValue(MappedAttributes.TITLE),
-         null,
-         null,
-         null,
-         Utils.safeImmutableList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS))),
-         children,
-         ownerType,
-         ownerId,
-         attrs.getValue(MappedAttributes.EDIT_PERMISSION),
-         attrs.getValue(MappedAttributes.SHOW_MAX_WINDOW, false),
-         attrs.getValue(MappedAttributes.CREATOR),
-         attrs.getValue(MappedAttributes.MODIFIER)
-      );
-   }
-
-   public List<ModelChange> save(PageData src, Site site, String name)
-   {
-      org.gatein.mop.api.workspace.Page root = site.getRootPage();
-      org.gatein.mop.api.workspace.Page pages = root.getChild("pages");
-      org.gatein.mop.api.workspace.Page dst = pages.getChild(name);
-
-      //
-      LinkedList<ModelChange> changes = new LinkedList<ModelChange>();
-
-      //
-      if (dst == null)
-      {
-         dst = pages.addChild(name);
-         changes.add(new ModelChange.Create(src));
-      }
-      else
-      {
-         changes.add(new ModelChange.Update(src));
-      }
-
-      //
-      Attributes attrs = dst.getAttributes();
-      attrs.setValue(MappedAttributes.TITLE, src.getTitle());
-      attrs.setValue(MappedAttributes.FACTORY_ID, src.getFactoryId());
-      attrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
-      attrs.setValue(MappedAttributes.EDIT_PERMISSION, src.getEditPermission());
-      attrs.setValue(MappedAttributes.SHOW_MAX_WINDOW, src.isShowMaxWindow());
-      attrs.setValue(MappedAttributes.CREATOR, src.getCreator());
-      attrs.setValue(MappedAttributes.MODIFIER, src.getModifier());
-
-      //
-      changes.addAll(saveChildren(src, dst.getRootComponent()));
-
-      //
-      return changes;
-   }
-
-   private ContainerData load(UIContainer src, List<ComponentData> children)
-   {
-      Attributes attrs = src.getAttributes();
-      return new ContainerData(
-         src.getObjectId(),
-         attrs.getValue(MappedAttributes.ID),
-         attrs.getValue(MappedAttributes.NAME),
-         attrs.getValue(MappedAttributes.ICON),
-         attrs.getValue(MappedAttributes.DECORATOR),
-         attrs.getValue(MappedAttributes.TEMPLATE),
-         attrs.getValue(MappedAttributes.FACTORY_ID),
-         attrs.getValue(MappedAttributes.TITLE),
-         attrs.getValue(MappedAttributes.DESCRIPTION),
-         attrs.getValue(MappedAttributes.WIDTH),
-         attrs.getValue(MappedAttributes.HEIGHT),
-         Utils.safeImmutableList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS))),
-         children
-      );
-   }
-
-   private List<ComponentData> loadChildren(UIContainer src)
-   {
-      ArrayList<ComponentData> children = new ArrayList<ComponentData>(src.size());
-      for (UIComponent component : src)
-      {
-
-         // Obtain a model object from the ui component
-         ComponentData mo;
-         if (component instanceof UIContainer)
-         {
-            UIContainer srcContainer = (UIContainer)component;
-            Attributes attrs = srcContainer.getAttributes();
-            String type = attrs.getValue(MappedAttributes.TYPE);
-            if ("dashboard".equals(type))
-            {
-               TransientApplicationState<Preferences> state = new TransientApplicationState<Preferences>();
-               Site owner = src.getPage().getSite();
-               state.setOwnerType(getOwnerType(owner.getObjectType()));
-               state.setOwnerId(owner.getName());
-               mo = new ApplicationData<Preferences, PortletId>(
-                  srcContainer.getObjectId(),
-                  component.getName(),
-                  ApplicationType.PORTLET,
-                  state,
-                  new PortletId("dashboard", "DashboardPortlet"),
-                  null,
-                  null,
-                  null,
-                  null,
-                  false,
-                  false,
-                  false,
-                  null,
-                  null,
-                  null,
-                  Collections.<String, String>emptyMap(),
-                  Collections.singletonList(UserACL.EVERYONE));
-               // Julien : the everyone is bad but having null permission
-               // means the same thing cf {@link UIPortalComponent} class
-               // we need to solve that somehow
-            }
-            else
-            {
-               List<ComponentData> dstChildren = loadChildren(srcContainer);
-               mo = load(srcContainer, dstChildren);
-            }
-         }
-         else if (component instanceof UIWindow)
-         {
-            UIWindow window = (UIWindow)component;
-            ApplicationData application = load(window);
-            mo = application;
-         }
-         else if (component instanceof UIBody)
-         {
-            mo = new BodyData(component.getObjectId(), BodyType.PAGE);
-         }
-         else
-         {
-            throw new AssertionError();
-         }
-
-         // Add among children
-         children.add(mo);
-      }
-      return children;
-   }
-
-   private void save(ContainerData src, UIContainer dst)
-   {
-      Attributes dstAttrs = dst.getAttributes();
-      dstAttrs.setValue(MappedAttributes.ID, src.getId());
-      dstAttrs.setValue(MappedAttributes.TYPE, src instanceof DashboardData ? "dashboard" : null);
-      dstAttrs.setValue(MappedAttributes.TITLE, src.getTitle());
-      dstAttrs.setValue(MappedAttributes.ICON, src.getIcon());
-      dstAttrs.setValue(MappedAttributes.TEMPLATE, src.getTemplate());
-      dstAttrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
-      dstAttrs.setValue(MappedAttributes.FACTORY_ID, src.getFactoryId());
-      dstAttrs.setValue(MappedAttributes.DECORATOR, src.getDecorator());
-      dstAttrs.setValue(MappedAttributes.DESCRIPTION, src.getDescription());
-      dstAttrs.setValue(MappedAttributes.WIDTH, src.getWidth());
-      dstAttrs.setValue(MappedAttributes.HEIGHT, src.getHeight());
-      dstAttrs.setValue(MappedAttributes.NAME, src.getName());
-   }
-
-   private void save(ModelData src, WorkspaceObject dst, LinkedList<ModelChange> changes,
-      Map<String, String> hierarchyRelationships)
-   {
-      if (src instanceof ContainerData)
-      {
-         save((ContainerData)src, (UIContainer)dst);
-         saveChildren((ContainerData)src, (UIContainer)dst, changes, hierarchyRelationships);
-      }
-      else if (src instanceof ApplicationData)
-      {
-         save((ApplicationData<?, ?>)src, (UIWindow)dst);
-      }
-      else if (src instanceof BodyData)
-      {
-         // Stateless
-      }
-      else
-      {
-         throw new AssertionError("Was not expecting child " + src);
-      }
-   }
-
-   /** . */
-   private static final PortletId DASHBOARD_ID = new PortletId("dashboard", "DashboardPortlet");
-
-   private LinkedList<ModelChange> saveChildren(final ContainerData src, UIContainer dst)
-   {
-
-      //
-      LinkedList<ModelChange> changes = new LinkedList<ModelChange>();
-
-      //
-      Map<String, String> hierarchyRelationships = new HashMap<String, String>();
-
-      //
-      build(src, hierarchyRelationships);
-
-      //
-      saveChildren(src, dst, changes, Collections.unmodifiableMap(hierarchyRelationships));
-
-      //
-      return changes;
-   }
-
-   private void build(ContainerData parent, Map<String, String> hierarchyRelationships)
-   {
-      String parentId = parent.getStorageId();
-      if (parentId != null)
-      {
-         for (ModelData child : parent.getChildren())
-         {
-            String childId = child.getStorageId();
-            if (childId != null)
-            {
-               if (hierarchyRelationships.put(childId, parentId) != null)
-               {
-                  throw new AssertionError("The same object is present two times in the object hierarchy");
-               }
-               if (child instanceof ContainerData)
-               {
-                  build((ContainerData)child, hierarchyRelationships);
-               }
-            }
-         }
-      }
-   }
-
-   private void saveChildren(final ContainerData src, UIContainer dst, LinkedList<ModelChange> changes,
-      Map<String, String> hierarchyRelationships)
-   {
-      final List<String> orders = new ArrayList<String>();
-      final Map<String, ModelData> modelObjectMap = new HashMap<String, ModelData>();
-
-      //
-      for (ModelData srcChild : src.getChildren())
-      {
-         String srcId = srcChild.getStorageId();
-
-         // Replace dashboard application by container if needed
-         if (srcChild instanceof ApplicationData)
-         {
-            ApplicationData app = (ApplicationData)srcChild;
-            if (app.getType() == ApplicationType.PORTLET)
-            {
-               PortletId ref = (PortletId)app.getRef();
-               if (DASHBOARD_ID.equals(ref))
-               {
-                  if (app.getStorageId() != null)
-                  {
-                     UIContainer dstDashboard = session.findObjectById(ObjectType.CONTAINER, app.getStorageId());
-                     srcChild = loadDashboard(dstDashboard);
-                  }
-                  else
-                  {
-                     srcChild = DashboardData.INITIAL_DASHBOARD;
-                  }
-               }
-            }
-         }
-
-         //
-         UIComponent dstChild;
-         if (srcId != null)
-         {
-            dstChild = session.findObjectById(ObjectType.COMPONENT, srcId);
-            if (dstChild == null)
-            {
-               throw new AssertionError("Could not find supposed present child with id " + srcId);
-            }
-            // julien : this can fail due to a bug in chromattic not implementing equals method properly
-            // and is replaced with the foreach below
-            /*
-                    if (!dst.contains(dstChild)) {
-                      throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild) +
-                        "that is not present in the target ui container " + session.pathOf(dst));
-                    }
-            */
-            boolean found = false;
-            for (UIComponent child : dst)
-            {
-               if (child.getObjectId().equals(srcId))
-               {
-                  found = true;
-                  break;
-               }
-            }
-            if (!found)
-            {
-               if (hierarchyRelationships.containsKey(srcId))
-               {
-                  // It's a move operation, so we move the node first
-                  dst.add(dstChild);
-               }
-               else
-               {
-                  throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild)
-                     + "that is not present in the target ui container " + session.pathOf(dst));
-               }
-            }
-
-            //
-            changes.add(new ModelChange.Update(srcChild));
-         }
-         else
-         {
-            String name = srcChild.getStorageName();
-            if (name == null)
-            {
-               // We manufacture one name
-               name = UUID.randomUUID().toString();
-            }
-            if (srcChild instanceof ContainerData)
-            {
-               dstChild = dst.add(ObjectType.CONTAINER, name);
-            }
-            else if (srcChild instanceof ApplicationData)
-            {
-               dstChild = dst.add(ObjectType.WINDOW, name);
-            }
-            else if (srcChild instanceof BodyData)
-            {
-               dstChild = dst.add(ObjectType.BODY, name);
-            }
-            else
-            {
-               throw new AssertionError("Was not expecting child " + srcChild);
-            }
-            changes.add(new ModelChange.Create(srcChild));
-         }
-
-         //
-         save(srcChild, dstChild, changes, hierarchyRelationships);
-
-         //
-         String dstId = dstChild.getObjectId();
-         modelObjectMap.put(dstId, srcChild);
-         orders.add(dstId);
-      }
-
-      // Take care of move operation that could be seen as a remove
-      for (UIComponent dstChild : dst)
-      {
-         String dstId = dstChild.getObjectId();
-         if (!modelObjectMap.containsKey(dstId) && hierarchyRelationships.containsKey(dstId))
-         {
-            String parentId = hierarchyRelationships.get(dstId);
-
-            // Get the new parent
-            UIContainer parent = session.findObjectById(ObjectType.CONTAINER, parentId);
-
-            // Perform the move
-            parent.add(dstChild);
-
-            //
-            changes.add(new ModelChange.Destroy(dstId));
-         }
-      }
-
-      // Delete removed children
-      for (Iterator<UIComponent> i = dst.iterator(); i.hasNext();)
-      {
-         UIComponent dstChild = i.next();
-         String dstId = dstChild.getObjectId();
-         if (!modelObjectMap.containsKey(dstId))
-         {
-            i.remove();
-            changes.add(new ModelChange.Destroy(dstId));
-         }
-      }
-
-      // Now sort children according to the order provided by the container
-      // need to replace that with Collections.sort once the set(int index, E element) is implemented in Chromattic lists
-      UIComponent[] a = dst.toArray(new UIComponent[dst.size()]);
-      Arrays.sort(a, new Comparator<UIComponent>()
-      {
-         public int compare(UIComponent o1, UIComponent o2)
-         {
-            int i1 = orders.indexOf(o1.getObjectId());
-            int i2 = orders.indexOf(o2.getObjectId());
-            return i1 - i2;
-         }
-      });
-      for (int j = 0; j < a.length; j++)
-      {
-         dst.add(j, a[j]);
-      }
-   }
-
-   private <S, I> ApplicationData<S, I> load(UIWindow src)
-   {
-      Attributes attrs = src.getAttributes();
-
-      //
-      Customization<?> customization = src.getCustomization();
-
-      //
-      ContentType<?> contentType = customization.getType();
-
-      //
-      String customizationid = customization.getId();
-
-      //
-      String contentId = customization.getContentId();
-
-      //
-      I ref;
-      ApplicationType<S, I> type;
-      if (contentType == null || contentType == Preferences.CONTENT_TYPE)
-      {
-         int pos = contentId.indexOf('/');
-         String applicationName = contentId.substring(0, pos);
-         String portletName = contentId.substring(pos + 1);
-         ref = (I)new PortletId(applicationName, portletName);
-         type = (ApplicationType<S,I>)ApplicationType.PORTLET;
-      }
-      else if (contentType == Gadget.CONTENT_TYPE)
-      {
-         ref = (I)new GadgetId(contentId);
-         type = (ApplicationType<S,I>)ApplicationType.GADGET;
-      }
-      else if (contentType == WSRPState.CONTENT_TYPE)
-      {
-         ref = (I)new WSRPId(contentId);
-         type = (ApplicationType<S,I>)ApplicationType.WSRP_PORTLET;
-      }
-      else
-      {
-         throw new AssertionError("Unknown type: " + contentType);
-      }
-
-      //
-      PersistentApplicationState<S> instanceState = new PersistentApplicationState<S>(customizationid);
-
-      //
-      HashMap<String, String> properties = new HashMap<String, String>();
-      load(attrs, properties, windowPropertiesBlackList);
-
-      //
-      return new ApplicationData<S,I>(
-         src.getObjectId(),
-         src.getName(),
-         type,
-         instanceState,
-         ref,
-         null,
-         attrs.getValue(MappedAttributes.TITLE),
-         attrs.getValue(MappedAttributes.ICON),
-         attrs.getValue(MappedAttributes.DESCRIPTION),
-         attrs.getValue(MappedAttributes.SHOW_INFO_BAR),
-         attrs.getValue(MappedAttributes.SHOW_STATE),
-         attrs.getValue(MappedAttributes.SHOW_MODE),
-         attrs.getValue(MappedAttributes.THEME),
-         attrs.getValue(MappedAttributes.WIDTH),
-         attrs.getValue(MappedAttributes.HEIGHT),
-         Utils.safeImmutableMap(properties),
-         Utils.safeImmutableList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS)))
-      );
-   }
-
-   public <S, I> void save(ApplicationData<S, I> src, UIWindow dst)
-   {
-      Attributes attrs = dst.getAttributes();
-      attrs.setValue(MappedAttributes.THEME, src.getTheme());
-      attrs.setValue(MappedAttributes.TITLE, src.getTitle());
-      attrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
-      attrs.setValue(MappedAttributes.SHOW_INFO_BAR, src.isShowInfoBar());
-      attrs.setValue(MappedAttributes.SHOW_STATE, src.isShowApplicationState());
-      attrs.setValue(MappedAttributes.SHOW_MODE, src.isShowApplicationMode());
-      attrs.setValue(MappedAttributes.DESCRIPTION, src.getDescription());
-      attrs.setValue(MappedAttributes.ICON, src.getIcon());
-      attrs.setValue(MappedAttributes.WIDTH, src.getWidth());
-      attrs.setValue(MappedAttributes.HEIGHT, src.getHeight());
-      save(src.getProperties(), attrs);
-
-      //
-      ApplicationState<S> instanceState = src.getState();
-
-      // We modify only transient portlet state
-      // and we ignore any persistent portlet state
-      if (instanceState instanceof TransientApplicationState)
-      {
-
-         //
-         TransientApplicationState<S> transientState = (TransientApplicationState<S>)instanceState;
-
-         // Attempt to get a site from the instance state
-         Site site = null;
-         if (transientState.getOwnerType() != null && transientState.getOwnerId() != null)
-         {
-            ObjectType<Site> siteType = parseSiteType(transientState.getOwnerType());
-            site = session.getWorkspace().getSite(siteType, transientState.getOwnerId());
-         }
-
-         // The current site
-         Site currentSite = dst.getPage().getSite();
-
-         // If it is the same site than the current page
-         // set null
-         if (site == dst.getPage().getSite())
-         {
-            site = null;
-         }
-
-         // The content id
-         String contentId;
-         ContentType<S> contentType = src.getType().getContentType();
-         if (contentType == Preferences.CONTENT_TYPE)
-         {
-            PortletId id = (PortletId)src.getRef();
-            contentId = id.getApplicationName() + "/" + id.getPortletName();
-         }
-         else if (contentType == Gadget.CONTENT_TYPE)
-         {
-            GadgetId id = (GadgetId)src.getRef();
-            contentId = id.getGadgetName();
-         }
-         else if (contentType == WSRPState.CONTENT_TYPE)
-         {
-            WSRPId id = (WSRPId)src.getRef();
-            contentId = id.getUri();
-         }
-         else
-         {
-            throw new UnsupportedOperationException("Unsupported content type");
-         }
-
-         // The customization that we will inherit from if not null
-         Customization<?> customization = null;
-
-         // Now inspect the unique id
-         String uniqueId = transientState.getUniqueId();
-         if (uniqueId != null)
-         {
-
-            // This is a customized window
-            if (uniqueId.startsWith("@"))
-            {
-               String id = uniqueId.substring(1);
-
-               // It's another window, we get its customization
-               if (!dst.getObjectId().equals(id))
-               {
-                  UIWindow window = session.findObjectById(ObjectType.WINDOW, id);
-                  Customization<?> windowCustomization = window.getCustomization();
-                  if (windowCustomization.getType().equals(contentType))
-                  {
-                     customization = windowCustomization;
-                  }
-               }
-            }
-            else
-            {
-               int pos = uniqueId.indexOf('#');
-               if (pos == -1)
-               {
-
-                  // If it's a different site than the page one (it has to be at this point)
-                  // then we get its customization
-                  if (site != null)
-                  {
-                     customization = site.getCustomization(uniqueId);
-                  }
-                  else
-                  {
-                     customization = currentSite.getCustomization(uniqueId);
-
-                     // If it does not exist we create it
-                     if (customization == null)
-                     {
-                        customization = currentSite.customize(uniqueId, contentType, contentId, null);
-                     }
-                  }
-               }
-               else
-               {
-
-                  // Otherwise we get the page customization
-                  String a = uniqueId.substring(0, pos);
-                  String b = uniqueId.substring(pos + 1);
-                  org.gatein.mop.api.workspace.Page page = site.getRootPage().getChild("pages").getChild(b);
-                  customization = page.getCustomization(a);
-               }
-            }
-         }
-
-         // Destroy existing window previous customization
-         if (dst.getCustomization() != null)
-         {
-            dst.getCustomization().destroy();
-         }
-
-         // If the existing customization is not null and matches the content id
-         Customization<S> dstCustomization;
-         if (customization != null && customization.getType().equals(contentType)
-            && customization.getContentId().equals(contentId))
-         {
-
-            // Cast is ok as content type matches
-            @SuppressWarnings("unchecked")
-            Customization<S> bilto = (Customization<S>)customization;
-
-            // If it's a customization of the current site we extend it
-            if (bilto.getContext() == currentSite)
-            {
-               dstCustomization = dst.customize(bilto);
-            }
-            else
-            {
-               // Otherwise we clone it propertly
-               S state = bilto.getVirtualState();
-               dstCustomization = dst.customize(contentType, contentId, state);
-            }
-         }
-         else
-         {
-            // Otherwise we create an empty customization
-            dstCustomization = dst.customize(contentType, contentId, null);
-         }
-
-         // At this point we have customized the window
-         // now if we have any additional state payload we must merge it
-         // with the current state
-         S state = ((TransientApplicationState<S>)instanceState).getContentState();
-         if (state != null)
-         {
-            dstCustomization.setState(state);
-         }
-      }
-   }
-
-   public DashboardData loadDashboard(UIContainer container)
-   {
-      Attributes attrs = container.getAttributes();
-      List<ComponentData> children = loadChildren(container);
-      return new DashboardData(
-         container.getObjectId(),
-         attrs.getValue(MappedAttributes.ID),
-         attrs.getValue(MappedAttributes.NAME),
-         attrs.getValue(MappedAttributes.ICON),
-         attrs.getValue(MappedAttributes.DECORATOR),
-         attrs.getValue(MappedAttributes.TEMPLATE),
-         attrs.getValue(MappedAttributes.FACTORY_ID),
-         attrs.getValue(MappedAttributes.TITLE),
-         attrs.getValue(MappedAttributes.DESCRIPTION),
-         attrs.getValue(MappedAttributes.WIDTH),
-         attrs.getValue(MappedAttributes.HEIGHT),
-         Utils.safeImmutableList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS))),
-         children
-      );
-   }
-
-   public void saveDashboard(DashboardData dashboard, UIContainer dst)
-   {
-      save(dashboard, dst);
-      saveChildren(dashboard, dst);
-   }
-
-   public static String[] parseWindowId(String windowId)
-   {
-      int i0 = windowId.indexOf("#");
-      int i1 = windowId.indexOf(":/", i0 + 1);
-      String ownerType = windowId.substring(0, i0);
-      String ownerId = windowId.substring(i0 + 1, i1);
-      String persistenceid = windowId.substring(i1 + 2);
-      String[] chunks = split("/", 2, persistenceid);
-      chunks[0] = ownerType;
-      chunks[1] = ownerId;
-      return chunks;
-   }
-
-   private static void load(Attributes src, Map<String, String> dst, Set<String> blackList)
-   {
-      for (String name : src.getKeys())
-      {
-         if (!blackList.contains(name))
-         {
-            Object value = src.getObject(name);
-            if (value instanceof String)
-            {
-               dst.put(name, (String)value);
-            }
-         }
-      }
-   }
-
-   public static void save(Map<String, String> src, Attributes dst)
-   {
-      for (Map.Entry<String, String> property : src.entrySet())
-      {
-         dst.setString(property.getKey(), property.getValue());
-      }
-   }
-
-   public static String getOwnerType(ObjectType<? extends Site> siteType)
-   {
-      if (siteType == ObjectType.PORTAL_SITE)
-      {
-         return PortalConfig.PORTAL_TYPE;
-      }
-      else if (siteType == ObjectType.GROUP_SITE)
-      {
-         return PortalConfig.GROUP_TYPE;
-      }
-      else if (siteType == ObjectType.USER_SITE)
-      {
-         return PortalConfig.USER_TYPE;
-      }
-      else
-      {
-         throw new IllegalArgumentException("Invalid site type " + siteType);
-      }
-   }
-
-   public static ObjectType<Site> parseSiteType(String ownerType)
-   {
-      if (ownerType.equals(PortalConfig.PORTAL_TYPE))
-      {
-         return ObjectType.PORTAL_SITE;
-      }
-      else if (ownerType.equals(PortalConfig.GROUP_TYPE))
-      {
-         return ObjectType.GROUP_SITE;
-      }
-      else if (ownerType.equals(PortalConfig.USER_TYPE))
-      {
-         return ObjectType.USER_SITE;
-      }
-      else
-      {
-         throw new IllegalArgumentException("Invalid owner type " + ownerType);
-      }
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,1081 @@
+/**
+ * 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.data;
+
+import org.exoplatform.portal.config.UserACL;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.ModelChange;
+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.config.model.gadget.GadgetId;
+import org.exoplatform.portal.config.model.portlet.PortletId;
+import org.exoplatform.portal.config.model.wsrp.WSRPId;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.exoplatform.portal.pom.spi.portlet.Preferences;
+import org.exoplatform.portal.pom.spi.wsrp.WSRP;
+import org.gatein.mop.api.Attributes;
+import org.gatein.mop.api.content.ContentType;
+import org.gatein.mop.api.content.Customization;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.api.workspace.Workspace;
+import org.gatein.mop.api.workspace.WorkspaceObject;
+import org.gatein.mop.api.workspace.link.Link;
+import org.gatein.mop.api.workspace.link.PageLink;
+import org.gatein.mop.api.workspace.ui.UIBody;
+import org.gatein.mop.api.workspace.ui.UIComponent;
+import org.gatein.mop.api.workspace.ui.UIContainer;
+import org.gatein.mop.api.workspace.ui.UIWindow;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import static org.exoplatform.portal.pom.config.Utils.join;
+import static org.exoplatform.portal.pom.config.Utils.split;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Mapper
+{
+
+   /** . */
+   private static final Set<String> portalPropertiesBlackList =
+      new HashSet<String>(Arrays.asList("jcr:uuid", "jcr:primaryType", MappedAttributes.LOCALE.getName(),
+         MappedAttributes.ACCESS_PERMISSIONS.getName(), MappedAttributes.EDIT_PERMISSION.getName(),
+         MappedAttributes.SKIN.getName(), MappedAttributes.TITLE.getName(), MappedAttributes.CREATOR.getName(),
+         MappedAttributes.MODIFIER.getName()));
+
+   /** . */
+   private static final Set<String> windowPropertiesBlackList =
+      new HashSet<String>(Arrays.asList("jcr:uuid", "jcr:primaryType", MappedAttributes.TYPE.getName(),
+         MappedAttributes.THEME.getName(), MappedAttributes.TITLE.getName(), MappedAttributes.ACCESS_PERMISSIONS
+            .getName(), MappedAttributes.SHOW_INFO_BAR.getName(), MappedAttributes.SHOW_STATE.getName(),
+         MappedAttributes.SHOW_MODE.getName(), MappedAttributes.DESCRIPTION.getName(), MappedAttributes.ICON.getName(),
+         MappedAttributes.WIDTH.getName(), MappedAttributes.HEIGHT.getName()));
+
+   /** . */
+   private final POMSession session;
+
+   public Mapper(POMSession session)
+   {
+      this.session = session;
+   }
+
+   public NavigationData load(Navigation src)
+   {
+      return load(src, NavigationData.class);
+   }
+
+   private <T extends NavigationNodeContainerData> T load(Navigation src, Class<T> type)
+   {
+
+      //
+      ArrayList<NavigationNodeData> children = new ArrayList<NavigationNodeData>(src.getChildren().size());
+      for (Navigation srcChild : src.getChildren())
+      {
+         NavigationNodeData dstChild = load(srcChild, NavigationNodeData.class);
+         children.add(dstChild);
+      }
+
+      //
+      T dst;
+      if (type == NavigationData.class)
+      {
+         Site site = src.getSite();
+         String ownerType = getOwnerType(site.getObjectType());
+         String ownerId = site.getName();
+         Attributes attrs = src.getAttributes();
+         NavigationData dstNav = new NavigationData(
+            src.getObjectId(),
+            ownerType,
+            ownerId,
+            attrs.getValue(MappedAttributes.DESCRIPTION),
+            attrs.getValue(MappedAttributes.CREATOR),
+            attrs.getValue(MappedAttributes.MODIFIER),
+            attrs.getValue(MappedAttributes.PRIORITY, 1),
+            children);
+         dst = (T)dstNav;
+      }
+      else if (type == NavigationNodeData.class)
+      {
+         Attributes attrs = src.getAttributes();
+         String pageReference = null;
+         Link link = src.getLink();
+         if (link instanceof PageLink)
+         {
+            PageLink pageLink = (PageLink)link;
+            org.gatein.mop.api.workspace.Page target = pageLink.getPage();
+            if (target != null)
+            {
+               Site site = target.getSite();
+               ObjectType<? extends Site> siteType = site.getObjectType();
+               pageReference = getOwnerType(siteType) + "::" + site.getName() + "::" + target.getName();
+            }
+         }
+         NavigationNodeData dstNode = new NavigationNodeData(
+            src.getObjectId(),
+            attrs.getValue(MappedAttributes.URI),
+            attrs.getValue(MappedAttributes.LABEL),
+            attrs.getValue(MappedAttributes.ICON),
+            src.getName(),
+            attrs.getValue(MappedAttributes.START_PUBLICATION_DATE),
+            attrs.getValue(MappedAttributes.END_PUBLICATION_DATE),
+            attrs.getValue(MappedAttributes.SHOW_PUBLICATION_DATE, false),
+            attrs.getValue(MappedAttributes.VISIBLE, true),
+            pageReference,
+            children
+         );
+
+         dst = (T)dstNode;
+      }
+      else
+      {
+         throw new AssertionError();
+      }
+
+      //
+      return dst;
+   }
+
+   public void save(NavigationData src, Navigation dst)
+   {
+      save((NavigationNodeContainerData)src, dst);
+   }
+
+   private void save(NavigationNodeContainerData src, Navigation dst)
+   {
+      if (src instanceof NavigationNodeData)
+      {
+         NavigationNodeData node = (NavigationNodeData)src;
+         Workspace workspace = dst.getSite().getWorkspace();
+         String reference = node.getPageReference();
+         if (reference != null)
+         {
+            String[] pageChunks = split("::", reference);
+            ObjectType<? extends Site> siteType = parseSiteType(pageChunks[0]);
+            Site site = workspace.getSite(siteType, pageChunks[1]);
+            org.gatein.mop.api.workspace.Page target = site.getRootPage().getChild("pages").getChild(pageChunks[2]);
+            PageLink link = dst.linkTo(ObjectType.PAGE_LINK);
+            link.setPage(target);
+         }
+
+         //
+         Attributes attrs = dst.getAttributes();
+         attrs.setValue(MappedAttributes.URI, node.getURI());
+         attrs.setValue(MappedAttributes.LABEL, node.getLabel());
+         attrs.setValue(MappedAttributes.ICON, node.getIcon());
+         attrs.setValue(MappedAttributes.START_PUBLICATION_DATE, node.getStartPublicationDate());
+         attrs.setValue(MappedAttributes.END_PUBLICATION_DATE, node.getEndPublicationDate());
+         attrs.setValue(MappedAttributes.SHOW_PUBLICATION_DATE, node.getShowPublicationDate());
+         attrs.setValue(MappedAttributes.VISIBLE, node.isVisible());
+      }
+      else if (src instanceof NavigationData)
+      {
+         NavigationData pageNav = (NavigationData)src;
+
+         //
+         Attributes attrs = dst.getAttributes();
+         attrs.setValue(MappedAttributes.PRIORITY, pageNav.getPriority());
+         attrs.setValue(MappedAttributes.CREATOR, pageNav.getCreator());
+         attrs.setValue(MappedAttributes.MODIFIER, pageNav.getModifier());
+         attrs.setValue(MappedAttributes.DESCRIPTION, pageNav.getDescription());
+      }
+      else
+      {
+         throw new AssertionError();
+      }
+
+      //
+      Set<String> savedSet = new HashSet<String>();
+      for (NavigationNodeData node : src.getNodes())
+      {
+         String srcId = node.getStorageId();
+         Navigation dstChild;
+         if (srcId != null)
+         {
+            dstChild = session.findObjectById(ObjectType.NAVIGATION, srcId);
+         }
+         else
+         {
+            dstChild = dst.getChild(node.getName());
+            if (dstChild == null)
+            {
+               dstChild = dst.addChild(node.getName());
+            }
+            srcId = dstChild.getObjectId();
+         }
+         save(node, dstChild);
+         savedSet.add(srcId);
+      }
+      for (Iterator<? extends Navigation> i = dst.getChildren().iterator(); i.hasNext();)
+      {
+         Navigation dstChild = i.next();
+         if (!savedSet.contains(dstChild.getObjectId()))
+         {
+            i.remove();
+         }
+      }
+   }
+
+   public PortalData load(Site src)
+   {
+      String type = Mapper.getOwnerType(src.getObjectType());
+      Attributes attrs = src.getAttributes();
+
+      //
+      org.gatein.mop.api.workspace.Page template = src.getRootNavigation().getTemplate();
+      UIContainer srcLayout = template.getRootComponent();
+
+      //
+      Map<String, String> properties = new HashMap<String, String>();
+      load(attrs, properties, portalPropertiesBlackList);
+
+      //
+      List<ComponentData> layoutChildren = loadChildren(srcLayout);
+      ContainerData layout = load(srcLayout, layoutChildren);
+
+      //
+      return new PortalData(
+         src.getObjectId(),
+         src.getName(),
+         type,
+         attrs.getValue(MappedAttributes.LOCALE),
+         Collections.unmodifiableList(Arrays.asList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS, "")))),
+         attrs.getValue(MappedAttributes.EDIT_PERMISSION),
+         Collections.unmodifiableMap(properties),
+         attrs.getValue(MappedAttributes.SKIN),
+         attrs.getValue(MappedAttributes.TITLE),
+         layout,
+         attrs.getValue(MappedAttributes.CREATOR),
+         attrs.getValue(MappedAttributes.MODIFIER));
+   }
+
+   public void save(PortalData src, Site dst)
+   {
+      if (src.getStorageId() != null && !src.getStorageId().equals(dst.getObjectId()))
+      {
+         String msg =
+            "Attempt to save a site " + src.getType() + "/" + src.getName() + " on the wrong target site "
+               + dst.getObjectType() + "/" + dst.getName();
+         throw new IllegalArgumentException(msg);
+      }
+
+      //
+      Attributes attrs = dst.getAttributes();
+      attrs.setValue(MappedAttributes.LOCALE, src.getLocale());
+      attrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
+      attrs.setValue(MappedAttributes.EDIT_PERMISSION, src.getEditPermission());
+      attrs.setValue(MappedAttributes.SKIN, src.getSkin());
+      attrs.setValue(MappedAttributes.TITLE, src.getTitle());
+      attrs.setValue(MappedAttributes.CREATOR, src.getCreator());
+      attrs.setValue(MappedAttributes.MODIFIER, src.getModifier());
+      if (src.getProperties() != null)
+      {
+         save(src.getProperties(), attrs);
+      }
+
+      //
+      org.gatein.mop.api.workspace.Page templates = dst.getRootPage().getChild("templates");
+      org.gatein.mop.api.workspace.Page template = templates.getChild("default");
+      if (template == null)
+      {
+         template = templates.addChild("default");
+      }
+
+      //
+      ContainerData srcContainer = src.getPortalLayout();
+      UIContainer dstContainer = template.getRootComponent();
+
+      //
+      save(srcContainer, dstContainer);
+      saveChildren(srcContainer, dstContainer);
+
+      //
+      dst.getRootNavigation().setTemplate(template);
+   }
+
+   public PageData load(org.gatein.mop.api.workspace.Page src)
+   {
+      Site site = src.getSite();
+      String ownerType = getOwnerType(site.getObjectType());
+      String ownerId = site.getName();
+      String name = src.getName();
+      List<ComponentData> children = loadChildren(src.getRootComponent());
+      Attributes attrs = src.getAttributes();
+
+      //
+      return new PageData(
+         src.getObjectId(),
+         null,
+         name,
+         null,
+         null,
+         null,
+         attrs.getValue(MappedAttributes.FACTORY_ID),
+         attrs.getValue(MappedAttributes.TITLE),
+         null,
+         null,
+         null,
+         Utils.safeImmutableList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS))),
+         children,
+         ownerType,
+         ownerId,
+         attrs.getValue(MappedAttributes.EDIT_PERMISSION),
+         attrs.getValue(MappedAttributes.SHOW_MAX_WINDOW, false),
+         attrs.getValue(MappedAttributes.CREATOR),
+         attrs.getValue(MappedAttributes.MODIFIER)
+      );
+   }
+
+   public List<ModelChange> save(PageData src, Site site, String name)
+   {
+      org.gatein.mop.api.workspace.Page root = site.getRootPage();
+      org.gatein.mop.api.workspace.Page pages = root.getChild("pages");
+      org.gatein.mop.api.workspace.Page dst = pages.getChild(name);
+
+      //
+      LinkedList<ModelChange> changes = new LinkedList<ModelChange>();
+
+      //
+      if (dst == null)
+      {
+         dst = pages.addChild(name);
+         changes.add(new ModelChange.Create(src));
+      }
+      else
+      {
+         changes.add(new ModelChange.Update(src));
+      }
+
+      //
+      Attributes attrs = dst.getAttributes();
+      attrs.setValue(MappedAttributes.TITLE, src.getTitle());
+      attrs.setValue(MappedAttributes.FACTORY_ID, src.getFactoryId());
+      attrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
+      attrs.setValue(MappedAttributes.EDIT_PERMISSION, src.getEditPermission());
+      attrs.setValue(MappedAttributes.SHOW_MAX_WINDOW, src.isShowMaxWindow());
+      attrs.setValue(MappedAttributes.CREATOR, src.getCreator());
+      attrs.setValue(MappedAttributes.MODIFIER, src.getModifier());
+
+      //
+      changes.addAll(saveChildren(src, dst.getRootComponent()));
+
+      //
+      return changes;
+   }
+
+   private ContainerData load(UIContainer src, List<ComponentData> children)
+   {
+      Attributes attrs = src.getAttributes();
+      return new ContainerData(
+         src.getObjectId(),
+         attrs.getValue(MappedAttributes.ID),
+         attrs.getValue(MappedAttributes.NAME),
+         attrs.getValue(MappedAttributes.ICON),
+         attrs.getValue(MappedAttributes.DECORATOR),
+         attrs.getValue(MappedAttributes.TEMPLATE),
+         attrs.getValue(MappedAttributes.FACTORY_ID),
+         attrs.getValue(MappedAttributes.TITLE),
+         attrs.getValue(MappedAttributes.DESCRIPTION),
+         attrs.getValue(MappedAttributes.WIDTH),
+         attrs.getValue(MappedAttributes.HEIGHT),
+         Utils.safeImmutableList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS))),
+         children
+      );
+   }
+
+   private List<ComponentData> loadChildren(UIContainer src)
+   {
+      ArrayList<ComponentData> children = new ArrayList<ComponentData>(src.size());
+      for (UIComponent component : src)
+      {
+
+         // Obtain a model object from the ui component
+         ComponentData mo;
+         if (component instanceof UIContainer)
+         {
+            UIContainer srcContainer = (UIContainer)component;
+            Attributes attrs = srcContainer.getAttributes();
+            String type = attrs.getValue(MappedAttributes.TYPE);
+            if ("dashboard".equals(type))
+            {
+               TransientApplicationState<Preferences> state = new TransientApplicationState<Preferences>();
+               Site owner = src.getPage().getSite();
+               state.setOwnerType(getOwnerType(owner.getObjectType()));
+               state.setOwnerId(owner.getName());
+               mo = new ApplicationData<Preferences, PortletId>(
+                  srcContainer.getObjectId(),
+                  component.getName(),
+                  ApplicationType.PORTLET,
+                  state,
+                  new PortletId("dashboard", "DashboardPortlet"),
+                  null,
+                  null,
+                  null,
+                  null,
+                  false,
+                  false,
+                  false,
+                  null,
+                  null,
+                  null,
+                  Collections.<String, String>emptyMap(),
+                  Collections.singletonList(UserACL.EVERYONE));
+               // Julien : the everyone is bad but having null permission
+               // means the same thing cf {@link UIPortalComponent} class
+               // we need to solve that somehow
+            }
+            else
+            {
+               List<ComponentData> dstChildren = loadChildren(srcContainer);
+               mo = load(srcContainer, dstChildren);
+            }
+         }
+         else if (component instanceof UIWindow)
+         {
+            UIWindow window = (UIWindow)component;
+            ApplicationData application = load(window);
+            mo = application;
+         }
+         else if (component instanceof UIBody)
+         {
+            mo = new BodyData(component.getObjectId(), BodyType.PAGE);
+         }
+         else
+         {
+            throw new AssertionError();
+         }
+
+         // Add among children
+         children.add(mo);
+      }
+      return children;
+   }
+
+   private void save(ContainerData src, UIContainer dst)
+   {
+      Attributes dstAttrs = dst.getAttributes();
+      dstAttrs.setValue(MappedAttributes.ID, src.getId());
+      dstAttrs.setValue(MappedAttributes.TYPE, src instanceof DashboardData ? "dashboard" : null);
+      dstAttrs.setValue(MappedAttributes.TITLE, src.getTitle());
+      dstAttrs.setValue(MappedAttributes.ICON, src.getIcon());
+      dstAttrs.setValue(MappedAttributes.TEMPLATE, src.getTemplate());
+      dstAttrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
+      dstAttrs.setValue(MappedAttributes.FACTORY_ID, src.getFactoryId());
+      dstAttrs.setValue(MappedAttributes.DECORATOR, src.getDecorator());
+      dstAttrs.setValue(MappedAttributes.DESCRIPTION, src.getDescription());
+      dstAttrs.setValue(MappedAttributes.WIDTH, src.getWidth());
+      dstAttrs.setValue(MappedAttributes.HEIGHT, src.getHeight());
+      dstAttrs.setValue(MappedAttributes.NAME, src.getName());
+   }
+
+   private void save(ModelData src, WorkspaceObject dst, LinkedList<ModelChange> changes,
+      Map<String, String> hierarchyRelationships)
+   {
+      if (src instanceof ContainerData)
+      {
+         save((ContainerData)src, (UIContainer)dst);
+         saveChildren((ContainerData)src, (UIContainer)dst, changes, hierarchyRelationships);
+      }
+      else if (src instanceof ApplicationData)
+      {
+         save((ApplicationData<?, ?>)src, (UIWindow)dst);
+      }
+      else if (src instanceof BodyData)
+      {
+         // Stateless
+      }
+      else
+      {
+         throw new AssertionError("Was not expecting child " + src);
+      }
+   }
+
+   /** . */
+   private static final PortletId DASHBOARD_ID = new PortletId("dashboard", "DashboardPortlet");
+
+   private LinkedList<ModelChange> saveChildren(final ContainerData src, UIContainer dst)
+   {
+
+      //
+      LinkedList<ModelChange> changes = new LinkedList<ModelChange>();
+
+      //
+      Map<String, String> hierarchyRelationships = new HashMap<String, String>();
+
+      //
+      build(src, hierarchyRelationships);
+
+      //
+      saveChildren(src, dst, changes, Collections.unmodifiableMap(hierarchyRelationships));
+
+      //
+      return changes;
+   }
+
+   private void build(ContainerData parent, Map<String, String> hierarchyRelationships)
+   {
+      String parentId = parent.getStorageId();
+      if (parentId != null)
+      {
+         for (ModelData child : parent.getChildren())
+         {
+            String childId = child.getStorageId();
+            if (childId != null)
+            {
+               if (hierarchyRelationships.put(childId, parentId) != null)
+               {
+                  throw new AssertionError("The same object is present two times in the object hierarchy");
+               }
+               if (child instanceof ContainerData)
+               {
+                  build((ContainerData)child, hierarchyRelationships);
+               }
+            }
+         }
+      }
+   }
+
+   private void saveChildren(final ContainerData src, UIContainer dst, LinkedList<ModelChange> changes,
+      Map<String, String> hierarchyRelationships)
+   {
+      final List<String> orders = new ArrayList<String>();
+      final Map<String, ModelData> modelObjectMap = new HashMap<String, ModelData>();
+
+      //
+      for (ModelData srcChild : src.getChildren())
+      {
+         String srcId = srcChild.getStorageId();
+
+         // Replace dashboard application by container if needed
+         if (srcChild instanceof ApplicationData)
+         {
+            ApplicationData app = (ApplicationData)srcChild;
+            if (app.getType() == ApplicationType.PORTLET)
+            {
+               PortletId ref = (PortletId)app.getRef();
+               if (DASHBOARD_ID.equals(ref))
+               {
+                  if (app.getStorageId() != null)
+                  {
+                     UIContainer dstDashboard = session.findObjectById(ObjectType.CONTAINER, app.getStorageId());
+                     srcChild = loadDashboard(dstDashboard);
+                  }
+                  else
+                  {
+                     srcChild = DashboardData.INITIAL_DASHBOARD;
+                  }
+               }
+            }
+         }
+
+         //
+         UIComponent dstChild;
+         if (srcId != null)
+         {
+            dstChild = session.findObjectById(ObjectType.COMPONENT, srcId);
+            if (dstChild == null)
+            {
+               throw new AssertionError("Could not find supposed present child with id " + srcId);
+            }
+            // julien : this can fail due to a bug in chromattic not implementing equals method properly
+            // and is replaced with the foreach below
+            /*
+                    if (!dst.contains(dstChild)) {
+                      throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild) +
+                        "that is not present in the target ui container " + session.pathOf(dst));
+                    }
+            */
+            boolean found = false;
+            for (UIComponent child : dst)
+            {
+               if (child.getObjectId().equals(srcId))
+               {
+                  found = true;
+                  break;
+               }
+            }
+            if (!found)
+            {
+               if (hierarchyRelationships.containsKey(srcId))
+               {
+                  // It's a move operation, so we move the node first
+                  dst.add(dstChild);
+               }
+               else
+               {
+                  throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild)
+                     + "that is not present in the target ui container " + session.pathOf(dst));
+               }
+            }
+
+            //
+            changes.add(new ModelChange.Update(srcChild));
+         }
+         else
+         {
+            String name = srcChild.getStorageName();
+            if (name == null)
+            {
+               // We manufacture one name
+               name = UUID.randomUUID().toString();
+            }
+            if (srcChild instanceof ContainerData)
+            {
+               dstChild = dst.add(ObjectType.CONTAINER, name);
+            }
+            else if (srcChild instanceof ApplicationData)
+            {
+               dstChild = dst.add(ObjectType.WINDOW, name);
+            }
+            else if (srcChild instanceof BodyData)
+            {
+               dstChild = dst.add(ObjectType.BODY, name);
+            }
+            else
+            {
+               throw new AssertionError("Was not expecting child " + srcChild);
+            }
+            changes.add(new ModelChange.Create(srcChild));
+         }
+
+         //
+         save(srcChild, dstChild, changes, hierarchyRelationships);
+
+         //
+         String dstId = dstChild.getObjectId();
+         modelObjectMap.put(dstId, srcChild);
+         orders.add(dstId);
+      }
+
+      // Take care of move operation that could be seen as a remove
+      for (UIComponent dstChild : dst)
+      {
+         String dstId = dstChild.getObjectId();
+         if (!modelObjectMap.containsKey(dstId) && hierarchyRelationships.containsKey(dstId))
+         {
+            String parentId = hierarchyRelationships.get(dstId);
+
+            // Get the new parent
+            UIContainer parent = session.findObjectById(ObjectType.CONTAINER, parentId);
+
+            // Perform the move
+            parent.add(dstChild);
+
+            //
+            changes.add(new ModelChange.Destroy(dstId));
+         }
+      }
+
+      // Delete removed children
+      for (Iterator<UIComponent> i = dst.iterator(); i.hasNext();)
+      {
+         UIComponent dstChild = i.next();
+         String dstId = dstChild.getObjectId();
+         if (!modelObjectMap.containsKey(dstId))
+         {
+            i.remove();
+            changes.add(new ModelChange.Destroy(dstId));
+         }
+      }
+
+      // Now sort children according to the order provided by the container
+      // need to replace that with Collections.sort once the set(int index, E element) is implemented in Chromattic lists
+      UIComponent[] a = dst.toArray(new UIComponent[dst.size()]);
+      Arrays.sort(a, new Comparator<UIComponent>()
+      {
+         public int compare(UIComponent o1, UIComponent o2)
+         {
+            int i1 = orders.indexOf(o1.getObjectId());
+            int i2 = orders.indexOf(o2.getObjectId());
+            return i1 - i2;
+         }
+      });
+      for (int j = 0; j < a.length; j++)
+      {
+         dst.add(j, a[j]);
+      }
+   }
+
+   private <S, I> ApplicationData<S, I> load(UIWindow src)
+   {
+      Attributes attrs = src.getAttributes();
+
+      //
+      Customization<?> customization = src.getCustomization();
+
+      //
+      ContentType<?> contentType = customization.getType();
+
+      //
+      String customizationid = customization.getId();
+
+      //
+      String contentId = customization.getContentId();
+
+
+
+
+      //
+      I ref;
+      ApplicationType<S, I> type;
+      if (contentType == null || contentType == Preferences.CONTENT_TYPE)
+      {
+         int pos = contentId.indexOf('/');
+         String applicationName = contentId.substring(0, pos);
+         String portletName = contentId.substring(pos + 1);
+         ref = (I)new PortletId(applicationName, portletName);
+         type = (ApplicationType<S,I>)ApplicationType.PORTLET;
+      }
+      else if (contentType == Gadget.CONTENT_TYPE)
+      {
+         ref = (I)new GadgetId(contentId);
+         type = (ApplicationType<S,I>)ApplicationType.GADGET;
+      }
+      else if (contentType == WSRP.CONTENT_TYPE)
+      {
+         ref = (I)new WSRPId(contentId);
+         type = (ApplicationType<S,I>)ApplicationType.WSRP_PORTLET;
+      }
+      else
+      {
+         throw new AssertionError("Unknown type: " + contentType);
+      }
+
+      //
+      PersistentApplicationState<S> instanceState = new PersistentApplicationState<S>(customizationid);
+
+      //
+      HashMap<String, String> properties = new HashMap<String, String>();
+      load(attrs, properties, windowPropertiesBlackList);
+
+      //
+      return new ApplicationData<S,I>(
+         src.getObjectId(),
+         src.getName(),
+         type,
+         instanceState,
+         ref,
+         null,
+         attrs.getValue(MappedAttributes.TITLE),
+         attrs.getValue(MappedAttributes.ICON),
+         attrs.getValue(MappedAttributes.DESCRIPTION),
+         attrs.getValue(MappedAttributes.SHOW_INFO_BAR),
+         attrs.getValue(MappedAttributes.SHOW_STATE),
+         attrs.getValue(MappedAttributes.SHOW_MODE),
+         attrs.getValue(MappedAttributes.THEME),
+         attrs.getValue(MappedAttributes.WIDTH),
+         attrs.getValue(MappedAttributes.HEIGHT),
+         Utils.safeImmutableMap(properties),
+         Utils.safeImmutableList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS)))
+      );
+   }
+
+   public <S, I> void save(ApplicationData<S, I> src, UIWindow dst)
+   {
+      Attributes attrs = dst.getAttributes();
+      attrs.setValue(MappedAttributes.THEME, src.getTheme());
+      attrs.setValue(MappedAttributes.TITLE, src.getTitle());
+      attrs.setValue(MappedAttributes.ACCESS_PERMISSIONS, join("|", src.getAccessPermissions()));
+      attrs.setValue(MappedAttributes.SHOW_INFO_BAR, src.isShowInfoBar());
+      attrs.setValue(MappedAttributes.SHOW_STATE, src.isShowApplicationState());
+      attrs.setValue(MappedAttributes.SHOW_MODE, src.isShowApplicationMode());
+      attrs.setValue(MappedAttributes.DESCRIPTION, src.getDescription());
+      attrs.setValue(MappedAttributes.ICON, src.getIcon());
+      attrs.setValue(MappedAttributes.WIDTH, src.getWidth());
+      attrs.setValue(MappedAttributes.HEIGHT, src.getHeight());
+      save(src.getProperties(), attrs);
+
+      //
+      ApplicationState<S> instanceState = src.getState();
+
+      // We modify only transient portlet state
+      // and we ignore any persistent portlet state
+      if (instanceState instanceof TransientApplicationState)
+      {
+
+         //
+         TransientApplicationState<S> transientState = (TransientApplicationState<S>)instanceState;
+
+         // Attempt to get a site from the instance state
+         Site site = null;
+         if (transientState.getOwnerType() != null && transientState.getOwnerId() != null)
+         {
+            ObjectType<Site> siteType = parseSiteType(transientState.getOwnerType());
+            site = session.getWorkspace().getSite(siteType, transientState.getOwnerId());
+         }
+
+         // The current site
+         Site currentSite = dst.getPage().getSite();
+
+         // If it is the same site than the current page
+         // set null
+         if (site == dst.getPage().getSite())
+         {
+            site = null;
+         }
+
+         // The content id
+         String contentId;
+         ContentType<S> contentType = src.getType().getContentType();
+         if (contentType == Preferences.CONTENT_TYPE)
+         {
+            PortletId id = (PortletId)src.getRef();
+            contentId = id.getApplicationName() + "/" + id.getPortletName();
+         }
+         else if (contentType == Gadget.CONTENT_TYPE)
+         {
+            GadgetId id = (GadgetId)src.getRef();
+            contentId = id.getGadgetName();
+         }
+         else if (contentType == WSRP.CONTENT_TYPE)
+         {
+            WSRPId id = (WSRPId)src.getRef();
+            contentId = id.getUri();
+         }
+         else
+         {
+            throw new UnsupportedOperationException("Unsupported content type");
+         }
+
+         // The customization that we will inherit from if not null
+         Customization<?> customization = null;
+
+         // Now inspect the unique id
+         String uniqueId = transientState.getUniqueId();
+         if (uniqueId != null)
+         {
+
+            // This is a customized window
+            if (uniqueId.startsWith("@"))
+            {
+               String id = uniqueId.substring(1);
+
+               // It's another window, we get its customization
+               if (!dst.getObjectId().equals(id))
+               {
+                  UIWindow window = session.findObjectById(ObjectType.WINDOW, id);
+                  Customization<?> windowCustomization = window.getCustomization();
+                  if (windowCustomization.getType().equals(contentType))
+                  {
+                     customization = windowCustomization;
+                  }
+               }
+            }
+            else
+            {
+               int pos = uniqueId.indexOf('#');
+               if (pos == -1)
+               {
+
+                  // If it's a different site than the page one (it has to be at this point)
+                  // then we get its customization
+                  if (site != null)
+                  {
+                     customization = site.getCustomization(uniqueId);
+                  }
+                  else
+                  {
+                     customization = currentSite.getCustomization(uniqueId);
+
+                     // If it does not exist we create it
+                     if (customization == null)
+                     {
+                        customization = currentSite.customize(uniqueId, contentType, contentId, null);
+                     }
+                  }
+               }
+               else
+               {
+
+                  // Otherwise we get the page customization
+                  String a = uniqueId.substring(0, pos);
+                  String b = uniqueId.substring(pos + 1);
+                  org.gatein.mop.api.workspace.Page page = site.getRootPage().getChild("pages").getChild(b);
+                  customization = page.getCustomization(a);
+               }
+            }
+         }
+
+         // Destroy existing window previous customization
+         if (dst.getCustomization() != null)
+         {
+            dst.getCustomization().destroy();
+         }
+
+         // If the existing customization is not null and matches the content id
+         Customization<S> dstCustomization;
+         if (customization != null && customization.getType().equals(contentType)
+            && customization.getContentId().equals(contentId))
+         {
+
+            // Cast is ok as content type matches
+            @SuppressWarnings("unchecked")
+            Customization<S> bilto = (Customization<S>)customization;
+
+            // If it's a customization of the current site we extend it
+            if (bilto.getContext() == currentSite)
+            {
+               dstCustomization = dst.customize(bilto);
+            }
+            else
+            {
+               // Otherwise we clone it propertly
+               S state = bilto.getVirtualState();
+               dstCustomization = dst.customize(contentType, contentId, state);
+            }
+         }
+         else
+         {
+            // Otherwise we create an empty customization
+            dstCustomization = dst.customize(contentType, contentId, null);
+         }
+
+         // At this point we have customized the window
+         // now if we have any additional state payload we must merge it
+         // with the current state
+         S state = ((TransientApplicationState<S>)instanceState).getContentState();
+         if (state != null)
+         {
+            dstCustomization.setState(state);
+         }
+      }
+   }
+
+   public DashboardData loadDashboard(UIContainer container)
+   {
+      Attributes attrs = container.getAttributes();
+      List<ComponentData> children = loadChildren(container);
+      return new DashboardData(
+         container.getObjectId(),
+         attrs.getValue(MappedAttributes.ID),
+         attrs.getValue(MappedAttributes.NAME),
+         attrs.getValue(MappedAttributes.ICON),
+         attrs.getValue(MappedAttributes.DECORATOR),
+         attrs.getValue(MappedAttributes.TEMPLATE),
+         attrs.getValue(MappedAttributes.FACTORY_ID),
+         attrs.getValue(MappedAttributes.TITLE),
+         attrs.getValue(MappedAttributes.DESCRIPTION),
+         attrs.getValue(MappedAttributes.WIDTH),
+         attrs.getValue(MappedAttributes.HEIGHT),
+         Utils.safeImmutableList(split("|", attrs.getValue(MappedAttributes.ACCESS_PERMISSIONS))),
+         children
+      );
+   }
+
+   public void saveDashboard(DashboardData dashboard, UIContainer dst)
+   {
+      save(dashboard, dst);
+      saveChildren(dashboard, dst);
+   }
+
+   public static String[] parseWindowId(String windowId)
+   {
+      int i0 = windowId.indexOf("#");
+      int i1 = windowId.indexOf(":/", i0 + 1);
+      String ownerType = windowId.substring(0, i0);
+      String ownerId = windowId.substring(i0 + 1, i1);
+      String persistenceid = windowId.substring(i1 + 2);
+      String[] chunks = split("/", 2, persistenceid);
+      chunks[0] = ownerType;
+      chunks[1] = ownerId;
+      return chunks;
+   }
+
+   private static void load(Attributes src, Map<String, String> dst, Set<String> blackList)
+   {
+      for (String name : src.getKeys())
+      {
+         if (!blackList.contains(name))
+         {
+            Object value = src.getObject(name);
+            if (value instanceof String)
+            {
+               dst.put(name, (String)value);
+            }
+         }
+      }
+   }
+
+   public static void save(Map<String, String> src, Attributes dst)
+   {
+      for (Map.Entry<String, String> property : src.entrySet())
+      {
+         dst.setString(property.getKey(), property.getValue());
+      }
+   }
+
+   public static String getOwnerType(ObjectType<? extends Site> siteType)
+   {
+      if (siteType == ObjectType.PORTAL_SITE)
+      {
+         return PortalConfig.PORTAL_TYPE;
+      }
+      else if (siteType == ObjectType.GROUP_SITE)
+      {
+         return PortalConfig.GROUP_TYPE;
+      }
+      else if (siteType == ObjectType.USER_SITE)
+      {
+         return PortalConfig.USER_TYPE;
+      }
+      else
+      {
+         throw new IllegalArgumentException("Invalid site type " + siteType);
+      }
+   }
+
+   public static ObjectType<Site> parseSiteType(String ownerType)
+   {
+      if (ownerType.equals(PortalConfig.PORTAL_TYPE))
+      {
+         return ObjectType.PORTAL_SITE;
+      }
+      else if (ownerType.equals(PortalConfig.GROUP_TYPE))
+      {
+         return ObjectType.GROUP_SITE;
+      }
+      else if (ownerType.equals(PortalConfig.USER_TYPE))
+      {
+         return ObjectType.USER_SITE;
+      }
+      else
+      {
+         throw new IllegalArgumentException("Invalid owner type " + ownerType);
+      }
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,50 +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.data;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class ModelData
-{
-
-   /** Storage id. */
-   private final String storageId;
-
-   /** The storage name that is unique among a container context. */
-   private final String storageName;
-
-   protected ModelData(String storageId, String storageName)
-   {
-      this.storageId = storageId;
-      this.storageName = storageName;
-   }
-
-   public String getStorageId()
-   {
-      return storageId;
-   }
-
-   public String getStorageName()
-   {
-      return storageName;
-   }
-}
\ No newline at end of file

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,50 @@
+/**
+ * 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.data;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class ModelData
+{
+
+   /** Storage id. */
+   private final String storageId;
+
+   /** The storage name that is unique among a container context. */
+   private final String storageName;
+
+   protected ModelData(String storageId, String storageName)
+   {
+      this.storageId = storageId;
+      this.storageName = storageName;
+   }
+
+   public String getStorageId()
+   {
+      return storageId;
+   }
+
+   public String getStorageName()
+   {
+      return storageName;
+   }
+}
\ No newline at end of file

Deleted: portal/branches/wsrp-integration/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-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,109 +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.data;
-
-import org.exoplatform.commons.utils.LazyPageList;
-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.Container;
-import org.exoplatform.portal.config.model.Dashboard;
-import org.exoplatform.portal.config.model.ModelChange;
-import org.exoplatform.portal.pom.data.PageData;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.config.POMTask;
-
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS
- * Apr 19, 2007
- *
- * This interface is used to load the PortalConfig, Page config  and  Navigation config from the
- * database
- */
-public interface ModelDataStorage
-{
-
-   public void create(PortalData config) throws Exception;
-
-   public void save(PortalData config) throws Exception;
-
-   public PortalData getPortalConfig(PortalKey key) throws Exception;
-
-   public void remove(PortalData config) throws Exception;
-
-   public PageData getPage(PageKey key) throws Exception;
-
-   /**
-    * Clones a page.
-    *
-    * @param key the key of the page to clone
-    * @param cloneKey the key of the clone
-    * @return the cloned page
-    * @throws Exception any exception
-    */
-   public PageData clonePage(PageKey key, PageKey cloneKey)
-      throws Exception;
-
-   public void remove(PageData page) throws Exception;
-
-   public void create(PageData page) throws Exception;
-
-   /**
-    * Saves a page. If a page with the same id already exists then a merge operation will occur, otherwise
-    * a new page will be created from the provided argument.
-    *
-    * The operation returns a list of the change object that describes the changes that occured during the
-    * save operation.
-    *
-    * @param page the page to save
-    * @return the list of model changes that occured during the save operation
-    * @throws Exception any exception
-    */
-   public List<ModelChange> save(PageData page) throws Exception;
-
-   public NavigationData getPageNavigation(NavigationKey key) throws Exception;
-
-   public void save(NavigationData navigation) throws Exception;
-
-   public void create(NavigationData navigation) throws Exception;
-
-   public void remove(NavigationData navigation) throws Exception;
-
-   public void save(PortletPreferences portletPreferences) throws Exception;
-
-   public <S> S load(ApplicationState<S> state) throws Exception;
-
-   public <S> ApplicationState<S> save(ApplicationState<S> state, S preferences) throws Exception;
-
-   public PortletPreferences getPortletPreferences(String windowID) throws Exception;
-
-   public <T> LazyPageList<T> find(Query<T> q) throws Exception;
-
-   public <T> LazyPageList<T> find(Query<T> q, Comparator<T> sortComparator) throws Exception;
-
-   public Container getSharedLayout() throws Exception;
-
-   public DashboardData loadDashboard(String dashboardId) throws Exception;
-
-   public void saveDashboard(DashboardData dashboard) throws Exception;
-}
\ No newline at end of file

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelDataStorage.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,105 @@
+/**
+ * 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.data;
+
+import org.exoplatform.commons.utils.LazyPageList;
+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.Container;
+import org.exoplatform.portal.config.model.ModelChange;
+
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS
+ * Apr 19, 2007
+ *
+ * This interface is used to load the PortalConfig, Page config  and  Navigation config from the
+ * database
+ */
+public interface ModelDataStorage
+{
+
+   public void create(PortalData config) throws Exception;
+
+   public void save(PortalData config) throws Exception;
+
+   public PortalData getPortalConfig(PortalKey key) throws Exception;
+
+   public void remove(PortalData config) throws Exception;
+
+   public PageData getPage(PageKey key) throws Exception;
+
+   /**
+    * Clones a page.
+    *
+    * @param key the key of the page to clone
+    * @param cloneKey the key of the clone
+    * @return the cloned page
+    * @throws Exception any exception
+    */
+   public PageData clonePage(PageKey key, PageKey cloneKey)
+      throws Exception;
+
+   public void remove(PageData page) throws Exception;
+
+   public void create(PageData page) throws Exception;
+
+   /**
+    * Saves a page. If a page with the same id already exists then a merge operation will occur, otherwise
+    * a new page will be created from the provided argument.
+    *
+    * The operation returns a list of the change object that describes the changes that occured during the
+    * save operation.
+    *
+    * @param page the page to save
+    * @return the list of model changes that occured during the save operation
+    * @throws Exception any exception
+    */
+   public List<ModelChange> save(PageData page) throws Exception;
+
+   public NavigationData getPageNavigation(NavigationKey key) throws Exception;
+
+   public void save(NavigationData navigation) throws Exception;
+
+   public void create(NavigationData navigation) throws Exception;
+
+   public void remove(NavigationData navigation) throws Exception;
+
+   public void save(PortletPreferences portletPreferences) throws Exception;
+
+   public <S> S load(ApplicationState<S> state) throws Exception;
+
+   public <S> ApplicationState<S> save(ApplicationState<S> state, S preferences) throws Exception;
+
+   public PortletPreferences getPortletPreferences(String windowID) throws Exception;
+
+   public <T> LazyPageList<T> find(Query<T> q) throws Exception;
+
+   public <T> LazyPageList<T> find(Query<T> q, Comparator<T> sortComparator) throws Exception;
+
+   public Container getSharedLayout() throws Exception;
+
+   public DashboardData loadDashboard(String dashboardId) throws Exception;
+
+   public void saveDashboard(DashboardData dashboard) throws Exception;
+}
\ No newline at end of file

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,121 +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.data;
-
-import java.util.List;
-
-/**
-* @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
-* @version $Revision$
-*/
-public class NavigationData extends NavigationNodeContainerData
-{
-
-   /** . */
-   private final NavigationKey key;
-
-   /** . */
-   private final String description;
-
-   /** . */
-   private final String creator;
-
-   /** . */
-   private final String modifier;
-
-   /** . */
-   private final int priority;
-
-   public NavigationData(
-      String ownerType,
-      String ownerId,
-      String description,
-      String creator,
-      String modifier,
-      Integer priority,
-      List<NavigationNodeData> children)
-   {
-      this(null, ownerType, ownerId, description, creator, modifier, priority, children);
-   }
-
-   public NavigationData(
-      String storageId,
-      String ownerType,
-      String ownerId,
-      String description,
-      String creator,
-      String modifier,
-      Integer priority,
-      List<NavigationNodeData> children)
-   {
-      super(storageId, children);
-
-      //
-      if (ownerType == null)
-      {
-         throw new NullPointerException("No null owner type");
-      }
-      if (ownerId == null)
-      {
-         throw new NullPointerException("No null owner id");
-      }
-
-      //
-      this.key = new NavigationKey(ownerType, ownerId);
-      this.description = description;
-      this.creator = creator;
-      this.modifier = modifier;
-      this.priority = priority != null ? priority : 1;
-   }
-
-   public NavigationKey getKey()
-   {
-      return key;
-   }
-
-   public String getOwnerType()
-   {
-      return key.getType();
-   }
-
-   public String getOwnerId()
-   {
-      return key.getId();
-   }
-
-   public String getDescription()
-   {
-      return description;
-   }
-
-   public String getCreator()
-   {
-      return creator;
-   }
-
-   public String getModifier()
-   {
-      return modifier;
-   }
-
-   public int getPriority()
-   {
-      return priority;
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,121 @@
+/**
+ * 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.data;
+
+import java.util.List;
+
+/**
+* @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+* @version $Revision$
+*/
+public class NavigationData extends NavigationNodeContainerData
+{
+
+   /** . */
+   private final NavigationKey key;
+
+   /** . */
+   private final String description;
+
+   /** . */
+   private final String creator;
+
+   /** . */
+   private final String modifier;
+
+   /** . */
+   private final int priority;
+
+   public NavigationData(
+      String ownerType,
+      String ownerId,
+      String description,
+      String creator,
+      String modifier,
+      Integer priority,
+      List<NavigationNodeData> children)
+   {
+      this(null, ownerType, ownerId, description, creator, modifier, priority, children);
+   }
+
+   public NavigationData(
+      String storageId,
+      String ownerType,
+      String ownerId,
+      String description,
+      String creator,
+      String modifier,
+      Integer priority,
+      List<NavigationNodeData> children)
+   {
+      super(storageId, children);
+
+      //
+      if (ownerType == null)
+      {
+         throw new NullPointerException("No null owner type");
+      }
+      if (ownerId == null)
+      {
+         throw new NullPointerException("No null owner id");
+      }
+
+      //
+      this.key = new NavigationKey(ownerType, ownerId);
+      this.description = description;
+      this.creator = creator;
+      this.modifier = modifier;
+      this.priority = priority != null ? priority : 1;
+   }
+
+   public NavigationKey getKey()
+   {
+      return key;
+   }
+
+   public String getOwnerType()
+   {
+      return key.getType();
+   }
+
+   public String getOwnerId()
+   {
+      return key.getId();
+   }
+
+   public String getDescription()
+   {
+      return description;
+   }
+
+   public String getCreator()
+   {
+      return creator;
+   }
+
+   public String getModifier()
+   {
+      return modifier;
+   }
+
+   public int getPriority()
+   {
+      return priority;
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationKey.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationKey.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationKey.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,48 +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.data;
-
-import org.exoplatform.portal.pom.config.Utils;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class NavigationKey extends OwnerKey
-{
-
-   public NavigationKey(String type, String id)
-   {
-      super(type, id);
-   }
-
-   public static NavigationKey create(String compositeId)
-   {
-      if (compositeId == null)
-      {
-         throw new NullPointerException();
-      }
-      String[] components = Utils.split("::", compositeId);
-      if (components.length != 2)
-      {
-         throw new IllegalArgumentException("Wrong navigation id key format " + compositeId);
-      }
-      return new NavigationKey(components[0], components[1]);
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationKey.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationKey.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationKey.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationKey.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,48 @@
+/**
+ * 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.data;
+
+import org.exoplatform.portal.pom.config.Utils;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class NavigationKey extends OwnerKey
+{
+
+   public NavigationKey(String type, String id)
+   {
+      super(type, id);
+   }
+
+   public static NavigationKey create(String compositeId)
+   {
+      if (compositeId == null)
+      {
+         throw new NullPointerException();
+      }
+      String[] components = Utils.split("::", compositeId);
+      if (components.length != 2)
+      {
+         throw new IllegalArgumentException("Wrong navigation id key format " + compositeId);
+      }
+      return new NavigationKey(components[0], components[1]);
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,47 +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.data;
-
-import org.exoplatform.portal.pom.data.ModelData;
-
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class NavigationNodeContainerData extends ModelData
-{
-
-   /** . */
-   private final List<NavigationNodeData> nodes;
-
-   public NavigationNodeContainerData(String storageId, List<NavigationNodeData> nodes)
-   {
-      super(storageId, null);
-
-      //
-      this.nodes = nodes;
-   }
-
-   public List<NavigationNodeData> getNodes()
-   {
-      return nodes;
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,45 @@
+/**
+ * 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.data;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class NavigationNodeContainerData extends ModelData
+{
+
+   /** . */
+   private final List<NavigationNodeData> nodes;
+
+   public NavigationNodeContainerData(String storageId, List<NavigationNodeData> nodes)
+   {
+      super(storageId, null);
+
+      //
+      this.nodes = nodes;
+   }
+
+   public List<NavigationNodeData> getNodes()
+   {
+      return nodes;
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,143 +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.data;
-
-import java.util.Date;
-import java.util.List;
-
-/**
-* @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
-* @version $Revision$
-*/
-public class NavigationNodeData extends NavigationNodeContainerData
-{
-
-   /** . */
-   private final String uri;
-
-   /** . */
-   private final String label;
-
-   /** . */
-   private final String icon;
-
-   /** . */
-   private final String name;
-
-   /** . */
-   private final Date startPublicationDate;
-
-   /** . */
-   private final Date endPublicationDate;
-
-   /** . */
-   private final boolean showPublicationDate;
-
-   /** . */
-   private final boolean visible;
-
-   /** . */
-   private final String pageReference;
-
-   public NavigationNodeData(
-      String uri,
-      String label,
-      String icon,
-      String name,
-      Date startPublicationDate,
-      Date endPublicationDate,
-      Boolean showPublicationDate,
-      Boolean visible,
-      String pageReference,
-      List<NavigationNodeData> children)
-   {
-      this(null, uri, label, icon, name, startPublicationDate, endPublicationDate, showPublicationDate, visible, pageReference, children);
-   }
-
-   public NavigationNodeData(
-      String storageId,
-      String uri,
-      String label,
-      String icon,
-      String name,
-      Date startPublicationDate,
-      Date endPublicationDate,
-      Boolean showPublicationDate,
-      Boolean visible,
-      String pageReference,
-      List<NavigationNodeData> children)
-   {
-      super(storageId, children);
-
-      //
-      this.uri = uri;
-      this.label = label;
-      this.icon = icon;
-      this.name = name;
-      this.startPublicationDate = startPublicationDate;
-      this.endPublicationDate = endPublicationDate;
-      this.showPublicationDate = showPublicationDate != null ? showPublicationDate : false;
-      this.visible = visible != null ? visible : true;
-      this.pageReference = pageReference;
-   }
-   public String getURI()
-   {
-      return uri;
-   }
-
-   public String getLabel()
-   {
-      return label;
-   }
-
-   public String getIcon()
-   {
-      return icon;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public Date getStartPublicationDate()
-   {
-      return startPublicationDate;
-   }
-
-   public Date getEndPublicationDate()
-   {
-      return endPublicationDate;
-   }
-
-   public boolean getShowPublicationDate()
-   {
-      return showPublicationDate;
-   }
-
-   public boolean isVisible()
-   {
-      return visible;
-   }
-
-   public String getPageReference()
-   {
-      return pageReference;
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,143 @@
+/**
+ * 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.data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+* @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+* @version $Revision$
+*/
+public class NavigationNodeData extends NavigationNodeContainerData
+{
+
+   /** . */
+   private final String uri;
+
+   /** . */
+   private final String label;
+
+   /** . */
+   private final String icon;
+
+   /** . */
+   private final String name;
+
+   /** . */
+   private final Date startPublicationDate;
+
+   /** . */
+   private final Date endPublicationDate;
+
+   /** . */
+   private final boolean showPublicationDate;
+
+   /** . */
+   private final boolean visible;
+
+   /** . */
+   private final String pageReference;
+
+   public NavigationNodeData(
+      String uri,
+      String label,
+      String icon,
+      String name,
+      Date startPublicationDate,
+      Date endPublicationDate,
+      Boolean showPublicationDate,
+      Boolean visible,
+      String pageReference,
+      List<NavigationNodeData> children)
+   {
+      this(null, uri, label, icon, name, startPublicationDate, endPublicationDate, showPublicationDate, visible, pageReference, children);
+   }
+
+   public NavigationNodeData(
+      String storageId,
+      String uri,
+      String label,
+      String icon,
+      String name,
+      Date startPublicationDate,
+      Date endPublicationDate,
+      Boolean showPublicationDate,
+      Boolean visible,
+      String pageReference,
+      List<NavigationNodeData> children)
+   {
+      super(storageId, children);
+
+      //
+      this.uri = uri;
+      this.label = label;
+      this.icon = icon;
+      this.name = name;
+      this.startPublicationDate = startPublicationDate;
+      this.endPublicationDate = endPublicationDate;
+      this.showPublicationDate = showPublicationDate != null ? showPublicationDate : false;
+      this.visible = visible != null ? visible : true;
+      this.pageReference = pageReference;
+   }
+   public String getURI()
+   {
+      return uri;
+   }
+
+   public String getLabel()
+   {
+      return label;
+   }
+
+   public String getIcon()
+   {
+      return icon;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public Date getStartPublicationDate()
+   {
+      return startPublicationDate;
+   }
+
+   public Date getEndPublicationDate()
+   {
+      return endPublicationDate;
+   }
+
+   public boolean getShowPublicationDate()
+   {
+      return showPublicationDate;
+   }
+
+   public boolean isVisible()
+   {
+      return visible;
+   }
+
+   public String getPageReference()
+   {
+      return pageReference;
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/OwnerKey.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/OwnerKey.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/OwnerKey.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,76 +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.data;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class OwnerKey implements Serializable
-{
-
-   /** . */
-   private final String type;
-
-   /** . */
-   private final String id;
-
-   public OwnerKey(String type, String id)
-   {
-      if (type == null)
-      {
-         throw new NullPointerException();
-      }
-      if (id == null)
-      {
-         throw new NullPointerException();
-      }
-      this.type = type;
-      this.id = id;
-   }
-
-   public String getType()
-   {
-      return type;
-   }
-
-   public String getId()
-   {
-      return id;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      return id.hashCode() ^ type.hashCode();
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (obj instanceof OwnerKey)
-      {
-         OwnerKey that = (OwnerKey)obj;
-         return type.equals(that.type) && id.equals(that.id);
-      }
-      return false;
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/OwnerKey.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/OwnerKey.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/OwnerKey.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/OwnerKey.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,76 @@
+/**
+ * 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.data;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class OwnerKey implements Serializable
+{
+
+   /** . */
+   private final String type;
+
+   /** . */
+   private final String id;
+
+   public OwnerKey(String type, String id)
+   {
+      if (type == null)
+      {
+         throw new NullPointerException();
+      }
+      if (id == null)
+      {
+         throw new NullPointerException();
+      }
+      this.type = type;
+      this.id = id;
+   }
+
+   public String getType()
+   {
+      return type;
+   }
+
+   public String getId()
+   {
+      return id;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return id.hashCode() ^ type.hashCode();
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof OwnerKey)
+      {
+         OwnerKey that = (OwnerKey)obj;
+         return type.equals(that.type) && id.equals(that.id);
+      }
+      return false;
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,110 +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.data;
-
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class PageData extends ContainerData
-{
-
-   /** . */
-   private final PageKey key;
-
-   /** . */
-   private final String editPermission;
-
-   /** . */
-   private final boolean showMaxWindow;
-
-   /** . */
-   private final String creator;
-
-   /** . */
-   private final String modifier;
-
-   public PageData(
-      String storageId,
-      String id,
-      String name,
-      String icon,
-      String decorator,
-      String template,
-      String factoryId,
-      String title,
-      String description,
-      String width,
-      String height,
-      List<String> accessPermissions,
-      List<ComponentData> children,
-      String ownerType,
-      String ownerId,
-      String editPermission,
-      boolean showMaxWindow,
-      String creator,
-      String modifier)
-   {
-      super(storageId, id, name, icon, decorator, template, factoryId, title, description, width, height, accessPermissions, children);
-
-      //
-      this.key = new PageKey(ownerType, ownerId, name);
-      this.editPermission = editPermission;
-      this.showMaxWindow = showMaxWindow;
-      this.creator = creator;
-      this.modifier = modifier;
-   }
-
-   public PageKey getKey()
-   {
-      return key;
-   }
-
-   public String getOwnerType()
-   {
-      return key.getType();
-   }
-
-   public String getOwnerId()
-   {
-      return key.getId();
-   }
-
-   public String getEditPermission()
-   {
-      return editPermission;
-   }
-
-   public boolean isShowMaxWindow()
-   {
-      return showMaxWindow;
-   }
-
-   public String getCreator()
-   {
-      return creator;
-   }
-
-   public String getModifier()
-   {
-      return modifier;
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,110 @@
+/**
+ * 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.data;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PageData extends ContainerData
+{
+
+   /** . */
+   private final PageKey key;
+
+   /** . */
+   private final String editPermission;
+
+   /** . */
+   private final boolean showMaxWindow;
+
+   /** . */
+   private final String creator;
+
+   /** . */
+   private final String modifier;
+
+   public PageData(
+      String storageId,
+      String id,
+      String name,
+      String icon,
+      String decorator,
+      String template,
+      String factoryId,
+      String title,
+      String description,
+      String width,
+      String height,
+      List<String> accessPermissions,
+      List<ComponentData> children,
+      String ownerType,
+      String ownerId,
+      String editPermission,
+      boolean showMaxWindow,
+      String creator,
+      String modifier)
+   {
+      super(storageId, id, name, icon, decorator, template, factoryId, title, description, width, height, accessPermissions, children);
+
+      //
+      this.key = new PageKey(ownerType, ownerId, name);
+      this.editPermission = editPermission;
+      this.showMaxWindow = showMaxWindow;
+      this.creator = creator;
+      this.modifier = modifier;
+   }
+
+   public PageKey getKey()
+   {
+      return key;
+   }
+
+   public String getOwnerType()
+   {
+      return key.getType();
+   }
+
+   public String getOwnerId()
+   {
+      return key.getId();
+   }
+
+   public String getEditPermission()
+   {
+      return editPermission;
+   }
+
+   public boolean isShowMaxWindow()
+   {
+      return showMaxWindow;
+   }
+
+   public String getCreator()
+   {
+      return creator;
+   }
+
+   public String getModifier()
+   {
+      return modifier;
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageKey.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageKey.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageKey.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,86 +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.data;
-
-import org.exoplatform.portal.pom.config.Utils;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class PageKey extends OwnerKey
-{
-
-   /** . */
-   private final String name;
-
-   public PageKey(String type, String id, String name)
-   {
-      super(type, id);
-
-      //
-      if (name == null)
-      {
-         throw new NullPointerException();
-      }
-
-      //
-      this.name = name;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      return super.hashCode() ^ name.hashCode();
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (obj == this)
-      {
-         return true;
-      }
-      if (obj instanceof PageKey)
-      {
-         PageKey that = (PageKey)obj;
-         return super.equals(that) &&name.equals(that.name);
-      }
-      return false;
-   }
-
-   public static PageKey create(String compositeId)
-   {
-      if (compositeId == null)
-      {
-         throw new NullPointerException();
-      }
-      String[] components = Utils.split("::", compositeId);
-      if (components.length != 3)
-      {
-         throw new IllegalArgumentException("Wrong page id key format " + compositeId);
-      }
-      return new PageKey(components[0], components[1], components[2]);
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageKey.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageKey.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageKey.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PageKey.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,86 @@
+/**
+ * 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.data;
+
+import org.exoplatform.portal.pom.config.Utils;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PageKey extends OwnerKey
+{
+
+   /** . */
+   private final String name;
+
+   public PageKey(String type, String id, String name)
+   {
+      super(type, id);
+
+      //
+      if (name == null)
+      {
+         throw new NullPointerException();
+      }
+
+      //
+      this.name = name;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return super.hashCode() ^ name.hashCode();
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+      {
+         return true;
+      }
+      if (obj instanceof PageKey)
+      {
+         PageKey that = (PageKey)obj;
+         return super.equals(that) &&name.equals(that.name);
+      }
+      return false;
+   }
+
+   public static PageKey create(String compositeId)
+   {
+      if (compositeId == null)
+      {
+         throw new NullPointerException();
+      }
+      String[] components = Utils.split("::", compositeId);
+      if (components.length != 3)
+      {
+         throw new IllegalArgumentException("Wrong page id key format " + compositeId);
+      }
+      return new PageKey(components[0], components[1], components[2]);
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalData.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,149 +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.data;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class PortalData extends ModelData
-{
-
-   /** . */
-   private final PortalKey key;
-
-   /** . */
-   private final String locale;
-
-   /** . */
-   private final List<String> accessPermissions;
-
-   /** . */
-   private final String editPermission;
-
-   /** . */
-   private final Map<String, String> properties;
-
-   /** . */
-   private final String skin;
-
-   /** . */
-   private final String title;
-
-   /** . */
-   private final ContainerData portalLayout;
-
-   /** . */
-   private final String creator;
-
-   /** . */
-   private final String modifier;
-
-   public PortalData(
-      String storageId,
-      String name,
-      String type,
-      String locale,
-      List<String> accessPermissions,
-      String editPermission,
-      Map<String, String> properties,
-      String skin,
-      String title,
-      ContainerData portalLayout,
-      String creator,
-      String modifier)
-   {
-      super(storageId, null);
-
-      //
-      this.key = new PortalKey(type, name);
-      this.locale = locale;
-      this.accessPermissions = accessPermissions;
-      this.editPermission = editPermission;
-      this.properties = properties;
-      this.skin = skin;
-      this.title = title;
-      this.portalLayout = portalLayout;
-      this.creator = creator;
-      this.modifier = modifier;
-   }
-
-   public PortalKey getKey()
-   {
-      return key;
-   }
-
-   public String getName()
-   {
-      return key.getId();
-   }
-
-   public String getType()
-   {
-      return key.getType();
-   }
-
-   public String getLocale()
-   {
-      return locale;
-   }
-
-   public List<String> getAccessPermissions()
-   {
-      return accessPermissions;
-   }
-
-   public String getEditPermission()
-   {
-      return editPermission;
-   }
-
-   public Map<String, String> getProperties()
-   {
-      return properties;
-   }
-
-   public String getSkin()
-   {
-      return skin;
-   }
-
-   public String getTitle()
-   {
-      return title;
-   }
-
-   public ContainerData getPortalLayout()
-   {
-      return portalLayout;
-   }
-
-   public String getCreator()
-   {
-      return creator;
-   }
-
-   public String getModifier()
-   {
-      return modifier;
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalData.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalData.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalData.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalData.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,149 @@
+/**
+ * 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.data;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortalData extends ModelData
+{
+
+   /** . */
+   private final PortalKey key;
+
+   /** . */
+   private final String locale;
+
+   /** . */
+   private final List<String> accessPermissions;
+
+   /** . */
+   private final String editPermission;
+
+   /** . */
+   private final Map<String, String> properties;
+
+   /** . */
+   private final String skin;
+
+   /** . */
+   private final String title;
+
+   /** . */
+   private final ContainerData portalLayout;
+
+   /** . */
+   private final String creator;
+
+   /** . */
+   private final String modifier;
+
+   public PortalData(
+      String storageId,
+      String name,
+      String type,
+      String locale,
+      List<String> accessPermissions,
+      String editPermission,
+      Map<String, String> properties,
+      String skin,
+      String title,
+      ContainerData portalLayout,
+      String creator,
+      String modifier)
+   {
+      super(storageId, null);
+
+      //
+      this.key = new PortalKey(type, name);
+      this.locale = locale;
+      this.accessPermissions = accessPermissions;
+      this.editPermission = editPermission;
+      this.properties = properties;
+      this.skin = skin;
+      this.title = title;
+      this.portalLayout = portalLayout;
+      this.creator = creator;
+      this.modifier = modifier;
+   }
+
+   public PortalKey getKey()
+   {
+      return key;
+   }
+
+   public String getName()
+   {
+      return key.getId();
+   }
+
+   public String getType()
+   {
+      return key.getType();
+   }
+
+   public String getLocale()
+   {
+      return locale;
+   }
+
+   public List<String> getAccessPermissions()
+   {
+      return accessPermissions;
+   }
+
+   public String getEditPermission()
+   {
+      return editPermission;
+   }
+
+   public Map<String, String> getProperties()
+   {
+      return properties;
+   }
+
+   public String getSkin()
+   {
+      return skin;
+   }
+
+   public String getTitle()
+   {
+      return title;
+   }
+
+   public ContainerData getPortalLayout()
+   {
+      return portalLayout;
+   }
+
+   public String getCreator()
+   {
+      return creator;
+   }
+
+   public String getModifier()
+   {
+      return modifier;
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalKey.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalKey.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalKey.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,48 +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.data;
-
-import org.exoplatform.portal.pom.config.Utils;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class PortalKey extends OwnerKey
-{
-
-   public PortalKey(String type, String id)
-   {
-      super(type, id);
-   }
-
-   public static PortalKey create(String compositeId)
-   {
-      if (compositeId == null)
-      {
-         throw new NullPointerException();
-      }
-      String[] components = Utils.split("::", compositeId);
-      if (components.length != 2)
-      {
-         throw new IllegalArgumentException("Wrong navigation id key format " + compositeId);
-      }
-      return new PortalKey(components[0], components[1]);
-   }
-}

Copied: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalKey.java (from rev 480, portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalKey.java)
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalKey.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/pom/data/PortalKey.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,48 @@
+/**
+ * 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.data;
+
+import org.exoplatform.portal.pom.config.Utils;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortalKey extends OwnerKey
+{
+
+   public PortalKey(String type, String id)
+   {
+      super(type, id);
+   }
+
+   public static PortalKey create(String compositeId)
+   {
+      if (compositeId == null)
+      {
+         throw new NullPointerException();
+      }
+      String[] components = Utils.split("::", compositeId);
+      if (components.length != 2)
+      {
+         throw new IllegalArgumentException("Wrong navigation id key format " + compositeId);
+      }
+      return new PortalKey(components[0], components[1]);
+   }
+}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/resource/config/tasks/JavascriptTask.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/resource/config/tasks/JavascriptTask.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/resource/config/tasks/JavascriptTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,62 +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.resource.config.tasks;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.servlet.ServletContext;
-
-import org.exoplatform.web.application.javascript.JavascriptConfigService;
-
-/**
- * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
- * @version $Id$
- *
- */
-public class JavascriptTask
-{
-   
-   private List<Parameter> parameters;
-   
-   public JavascriptTask(){
-      parameters = new ArrayList<Parameter>();
-   }
-   
-   public void execute(JavascriptConfigService service, ServletContext scontext){
-      for(Parameter param : parameters){
-         service.addJavascript(param.moduleName, param.scriptPath, scontext);
-      }
-   }
-   
-   public void addParam(String moduleName, String scriptPath){
-      parameters.add(new Parameter(moduleName, scriptPath));
-   }
-   
-   private class Parameter {
-      
-      private String moduleName;
-      private String scriptPath;
-      
-      Parameter(String _moduleName, String _scriptPath){
-         moduleName = _moduleName;
-         scriptPath = _scriptPath;
-      }     
-   }
-}

Deleted: portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/resource/config/xml/JavascriptConfigParser.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/resource/config/xml/JavascriptConfigParser.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/main/java/org/exoplatform/portal/resource/config/xml/JavascriptConfigParser.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,95 +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.resource.config.xml;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.servlet.ServletContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.exoplatform.portal.resource.config.tasks.JavascriptTask;
-import org.exoplatform.web.application.javascript.JavascriptConfigService;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
- * @version $Id$
- *
- */
-public class JavascriptConfigParser
-{
-
-   public static void processConfigResource(InputStream is, JavascriptConfigService service, ServletContext scontext){
-      List<JavascriptTask> tasks = fetchTasks(is);
-      if(tasks != null){
-         for(JavascriptTask task : tasks){
-            task.execute(service, scontext);
-         }
-      }
-   }
-   
-   private static List<JavascriptTask> fetchTasks(InputStream is)
-   {
-      try
-      {
-         DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-         Document document = docBuilder.parse(is);
-         return fetchTasksFromXMLConfig(document);
-      }
-      catch (Exception ex)
-      {
-         return null;
-      }
-   }
-   
-   private static List<JavascriptTask> fetchTasksFromXMLConfig(Document document){
-      List<JavascriptTask> tasks = new ArrayList<JavascriptTask>();
-      Element element = document.getDocumentElement();
-      NodeList nodes = element.getElementsByTagName(GateinResource.JAVA_SCRIPT_TAG);
-      
-      for(int i = nodes.getLength() - 1 ; i >= 0; i--){
-         JavascriptTask task = xmlToTask((Element)nodes.item(i));
-         if(task != null){
-            tasks.add(task);
-         }
-      }
-      return tasks;
-   }
-   
-   private static JavascriptTask xmlToTask(Element element){
-      try{
-         JavascriptTask task = new JavascriptTask();
-         NodeList nodes = element.getElementsByTagName(GateinResource.JAVA_SCRIPT_PARAM);
-         for(int i = nodes.getLength() - 1 ; i >= 0; i--){
-            Element param_ele = (Element)nodes.item(i);
-            task.addParam(param_ele.getFirstChild().getNodeValue(), param_ele.getLastChild().getNodeValue());
-         }
-         return task;
-      }catch(Exception ex){
-         return null;
-      }
-   }
-   
-   
-}

Modified: portal/branches/wsrp-integration/component/portal/src/test/java/conf/portal/test-configuration.xml
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/test/java/conf/portal/test-configuration.xml	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/test/java/conf/portal/test-configuration.xml	2009-11-04 20:32:31 UTC (rev 493)
@@ -28,10 +28,14 @@
     <type>org.exoplatform.portal.pom.config.POMSessionManager</type>
   </component>
   <component>
-    <key>org.exoplatform.portal.config.DataStorage</key>
+    <key>org.exoplatform.portal.pom.data.ModelDataStorage</key>
     <type>org.exoplatform.portal.pom.config.POMDataStorage</type>
   </component>
   <component>
+    <key>org.exoplatform.portal.config.DataStorage</key>
+    <type>org.exoplatform.portal.config.DataStorageImpl</type>
+  </component>
+  <component>
     <key>org.exoplatform.portal.config.UserACL</key>
     <type>org.exoplatform.portal.config.UserACL</type>
     <init-params>

Modified: portal/branches/wsrp-integration/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
--- portal/branches/wsrp-integration/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,8 +19,6 @@
 
 package org.exoplatform.portal.config;
 
-import static org.exoplatform.portal.pom.config.Utils.split;
-
 import org.exoplatform.container.PortalContainer;
 import org.exoplatform.portal.application.PortletPreferences;
 import org.exoplatform.portal.application.Preference;
@@ -37,7 +35,6 @@
 import org.exoplatform.portal.config.model.gadget.GadgetApplication;
 import org.exoplatform.portal.config.model.portlet.PortletApplication;
 import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.exoplatform.portal.pom.config.tasks.DashboardTask;
 import org.exoplatform.portal.pom.spi.gadget.Gadget;
 import org.exoplatform.portal.pom.spi.portlet.Preferences;
 import org.exoplatform.portal.pom.spi.portlet.PreferencesBuilder;
@@ -47,6 +44,8 @@
 import java.util.Collections;
 import java.util.List;
 
+import static org.exoplatform.portal.pom.config.Utils.split;
+
 /**
  * Created by The eXo Platform SARL Author : Tung Pham thanhtungty at gmail.com Nov
  * 13, 2007
@@ -327,17 +326,17 @@
       List<ModelChange> changes = storage_.save(page);
       assertEquals(6, changes.size());
       ModelChange.Update c0 = (ModelChange.Update)changes.get(0);
-      assertSame(page, c0.getObject());
+//      assertSame(page, c0.getObject());
       ModelChange.Update c1 = (ModelChange.Update)changes.get(1);
-      assertSame(page.getChildren().get(0), c1.getObject());
+//      assertSame(page.getChildren().get(0), c1.getObject());
       ModelChange.Update c2 = (ModelChange.Update)changes.get(2);
-      assertSame(page.getChildren().get(1), c2.getObject());
+//      assertSame(page.getChildren().get(1), c2.getObject());
       ModelChange.Update c3 = (ModelChange.Update)changes.get(3);
-      assertSame(container.getChildren().get(0), c3.getObject());
+//      assertSame(container.getChildren().get(0), c3.getObject());
       ModelChange.Create c4 = (ModelChange.Create)changes.get(4);
-      assertSame(container.getChildren().get(1), c4.getObject());
+//      assertSame(container.getChildren().get(1), c4.getObject());
       ModelChange.Update c5 = (ModelChange.Update)changes.get(5);
-      assertSame(container.getChildren().get(2), c5.getObject());
+//      assertSame(container.getChildren().get(2), c5.getObject());
 
       // Check it is existing at the correct location
       // and also that the ids are still the same
@@ -465,8 +464,7 @@
       dashboard.getChildren().add(app);
 
       // Attempt to save a dashboard with a portlet on it
-      DashboardTask task = new DashboardTask.Save(dashboard);
-      storage_.execute(task);
+      storage_.saveDashboard(dashboard);
 
       // Test that load page does not load the children
       page = storage_.getPage("portal::test::foo");
@@ -474,7 +472,7 @@
       assertTrue(page.getChildren().get(0) instanceof PortletApplication);
 
       // Now check we have the state on the dashboard
-      dashboard = storage_.execute(new DashboardTask.Load(dashboardId)).getDashboard();
+      dashboard = storage_.loadDashboard(dashboardId);
       assertEquals(1, dashboard.getChildren().size());
       app = (PortletApplication)dashboard.getChildren().get(0);
       assertEquals("foo", app.getRef().getApplicationName());
@@ -498,14 +496,14 @@
       String dashboardId = page.getChildren().get(0).getStorageId();
 
       //
-      Dashboard dashboard = storage_.execute(new DashboardTask.Load(dashboardId)).getDashboard();
+      Dashboard dashboard = storage_.loadDashboard(dashboardId);
       assertEquals(3, dashboard.getChildren().size());
 
       // Now save the page with the dashboard
       storage_.save(page);
 
       //
-      dashboard = storage_.execute(new DashboardTask.Load(dashboardId)).getDashboard();
+      dashboard = storage_.loadDashboard(dashboardId);
       assertEquals(3, dashboard.getChildren().size());
    }
 
@@ -519,7 +517,7 @@
       String id = page.getChildren().get(0).getStorageId();
 
       // Load the dashboard itself
-      Dashboard dashboard = storage_.execute(new DashboardTask.Load(id)).getDashboard();
+      Dashboard dashboard = storage_.loadDashboard(id);
 
       // Put a gadget in one container
       Container row0 = (Container)dashboard.getChildren().get(0);
@@ -528,10 +526,10 @@
       row0.getChildren().add(gadgetApp);
 
       // Save the dashboard
-      storage_.execute(new DashboardTask.Save(dashboard));
+      storage_.saveDashboard(dashboard);
 
       // Load again the persisted version
-      dashboard = storage_.execute(new DashboardTask.Load(id)).getDashboard();
+      dashboard = storage_.loadDashboard(id);
 
       // Now move the gadget from one container to another to simulate a move
       row0 = (Container)dashboard.getChildren().get(0);
@@ -539,10 +537,10 @@
       row1.getChildren().add(row0.getChildren().remove(0));
 
       // Save  
-      storage_.execute(new DashboardTask.Save(dashboard));
+      storage_.saveDashboard(dashboard);
 
       // Load again the persisted version and check the move was done in the storage
-      dashboard = storage_.execute(new DashboardTask.Load(id)).getDashboard();
+      dashboard = storage_.loadDashboard(id);
       row0 = (Container)dashboard.getChildren().get(0);
       row1 = (Container)dashboard.getChildren().get(1);
       assertEquals(0, row0.getChildren().size());
@@ -561,7 +559,7 @@
       String id = page.getChildren().get(0).getStorageId();
 
       // Load the dashboard itself
-      Dashboard dashboard = storage_.execute(new DashboardTask.Load(id)).getDashboard();
+      Dashboard dashboard = storage_.loadDashboard(id);
 
       // Put a gadget in one container
       Container row1 = (Container)dashboard.getChildren().get(1);
@@ -570,10 +568,10 @@
       row1.getChildren().add(gadgetApp);
 
       // Save the dashboard
-      storage_.execute(new DashboardTask.Save(dashboard));
+      storage_.saveDashboard(dashboard);
 
       // Load again the persisted version
-      dashboard = storage_.execute(new DashboardTask.Load(id)).getDashboard();
+      dashboard = storage_.loadDashboard(id);
 
       // Now move the gadget from one container to another to simulate a move
       row1 = (Container)dashboard.getChildren().get(1);
@@ -581,10 +579,10 @@
       row0.getChildren().add(row1.getChildren().remove(0));
 
       // Save
-      storage_.execute(new DashboardTask.Save(dashboard));
+      storage_.saveDashboard(dashboard);
 
       // Load again the persisted version and check the move was done in the storage
-      dashboard = storage_.execute(new DashboardTask.Load(id)).getDashboard();
+      dashboard = storage_.loadDashboard(id);
       row0 = (Container)dashboard.getChildren().get(0);
       row1 = (Container)dashboard.getChildren().get(1);
       assertEquals(0, row1.getChildren().size());

Modified: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/commons/utils/PortalPrinter.java
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/commons/utils/PortalPrinter.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/commons/utils/PortalPrinter.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,51 +19,22 @@
 
 package org.exoplatform.commons.utils;
 
-import java.io.IOException;
 import java.io.OutputStream;
 
 /**
+ * The portal printer convert char to bytes based on a charset encoder.
+ *
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
 public class PortalPrinter extends OutputStreamPrinter
 {
 
-   public PortalPrinter(TextEncoder encoder, OutputStream out) throws IllegalArgumentException
-   {
-      super(encoder, out);
-   }
+   /** The optimized encoder. */
+   private static final TextEncoder encoder = new CharsetTextEncoder(new TableCharEncoder(CharsetCharEncoder.getUTF8()));
 
-   public void println()
+   public PortalPrinter(OutputStream out, boolean flushOnClose, int bufferSize) throws IllegalArgumentException
    {
-      try
-      {
-         write('\n');
-      }
-      catch (IOException e)
-      {
-      }
+      super(encoder, out, flushOnClose, bufferSize);
    }
-
-   public void print(Object o)
-   {
-      try
-      {
-         if (o == null)
-         {
-            write("null");
-         }
-         else if (o instanceof Text)
-         {
-            ((Text)o).writeTo(this);
-         }
-         else
-         {
-            write(String.valueOf(o));
-         }
-      }
-      catch (IOException e)
-      {
-      }
-   }
 }

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/BaseScript.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/BaseScript.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/BaseScript.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/BaseScript.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import groovy.lang.Binding;
+import groovy.lang.Script;
+
+import java.io.IOException;
+
+/**
+ * The internal base script of a Groovy script as seen by the Groovy world.
+ *
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class BaseScript extends Script
+{
+
+   GroovyPrinter printer;
+
+   protected BaseScript()
+   {
+   }
+
+   protected BaseScript(Binding binding)
+   {
+      super(binding);
+   }
+
+   @Override
+   public Object getProperty(String property)
+   {
+      if ("out".equals(property))
+      {
+         return printer;
+      }
+      else
+      {
+         return super.getProperty(property);
+      }
+   }
+
+   @Override
+   public void println(Object o)
+   {
+      printer.println(o);
+   }
+
+   @Override
+   public void println()
+   {
+      printer.println();
+   }
+
+   @Override
+   public void print(Object o)
+   {
+      printer.print(o);
+   }
+
+   public void flush()
+   {
+      try
+      {
+         printer.flush();
+      }
+      catch (IOException e)
+      {
+         //TODO: need to check again
+         //      	e.printStackTrace();
+      }
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyCompilationException.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyCompilationException.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyCompilationException.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyCompilationException.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GroovyCompilationException extends TemplateCompilationException
+{
+
+   /** . */
+   private final String groovyText;
+
+   public GroovyCompilationException(Throwable cause, String templateText, String groovyText)
+   {
+      super(cause, templateText);
+
+      //
+      this.groovyText = groovyText;
+   }
+
+   public String getGroovyText()
+   {
+      return groovyText;
+   }
+
+   @Override
+   public String getMessage()
+   {
+      return "Groovy compilation exception\n" +
+         "template: " +
+         getTemplateText() + "\n" +
+         "compiled to Groovy: " +
+         getGroovyText() + "\n";
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyPrinter.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyPrinter.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyPrinter.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyPrinter.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import groovy.lang.GroovyInterceptable;
+import groovy.lang.GroovyObjectSupport;
+import org.exoplatform.commons.utils.Text;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+abstract class GroovyPrinter extends GroovyObjectSupport implements GroovyInterceptable
+{
+
+   /**
+    * Optimize the call to the various print methods.
+    *
+    * @param name the method name
+    * @param args the method arguments
+    * @return the return value
+    */
+   @Override
+   public Object invokeMethod(String name, Object args)
+   {
+      // Optimize access to print methods
+      if (args instanceof Object[])
+      {
+         Object[] array = (Object[])args;
+         if (array.length == 1)
+         {
+            if ("print".equals(name))
+            {
+               print(array[0]);
+               return null;
+            }
+            else if ("println".equals(name))
+            {
+               println(array[0]);
+               return null;
+            }
+         }
+      }
+
+      // Back to Groovy method call
+      return super.invokeMethod(name, args);
+   }
+
+   public final void println(Object o)
+   {
+      print(o);
+      println();
+   }
+
+   public final void println()
+   {
+      try
+      {
+         write('\n');
+      }
+      catch (IOException ignore)
+      {
+      }
+   }
+
+   public final void print(Object o)
+   {
+      try
+      {
+         if (o == null)
+         {
+            write("null");
+         }
+         else if (o instanceof Text)
+         {
+            write((Text)o);
+         }
+         else
+         {
+            write(o.toString());
+         }
+      }
+      catch (IOException ignore)
+      {
+      }
+   }
+
+   protected abstract void write(char c) throws IOException;
+
+   protected abstract void write(String s) throws IOException;
+
+   protected abstract void write(Text text) throws IOException;
+
+   protected abstract void flush() throws IOException;
+
+   protected abstract void close() throws IOException;
+
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScript.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScript.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScript.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScript.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import groovy.lang.Binding;
+import org.codehaus.groovy.runtime.InvokerHelper;
+import org.exoplatform.commons.utils.OutputStreamPrinter;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+
+/**
+ * A wrapper for a Groovy script and its meta data.
+ *
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GroovyScript
+{
+
+   /** . */
+   private final String groovyText;
+
+   /** . */
+   private final Class<?> scriptClass;
+
+   /** . */
+   private final Map<Integer, TextItem> lineTable;
+
+   public GroovyScript(String groovyText, Class<?> scriptClass, Map<Integer, TextItem> lineTable)
+   {
+      this.groovyText = groovyText;
+      this.scriptClass = scriptClass;
+      this.lineTable = lineTable;
+   }
+
+   public String getGroovyText()
+   {
+      return groovyText;
+   }
+
+   public Class<?> getScriptClass()
+   {
+      return scriptClass;
+   }
+
+   public void render(Map context, Writer writer) throws IOException, TemplateRuntimeException
+   {
+      Binding binding = context != null ? new Binding(context) : new Binding();
+
+      //
+      GroovyPrinter printer;
+      if (writer instanceof OutputStreamPrinter)
+      {
+         printer = new OutputStreamWriterGroovyPrinter((OutputStreamPrinter)writer);
+      }
+      else
+      {
+         printer = new WriterGroovyPrinter(writer);
+      }
+
+      //
+      BaseScript script = (BaseScript)InvokerHelper.createScript(scriptClass, binding);
+      script.printer = printer;
+
+      //
+      try
+      {
+         script.run();
+      }
+      catch (Exception e)
+      {
+         if (e instanceof IOException)
+         {
+            throw (IOException)e;
+         }
+         else
+         {
+            throw buildRuntimeException(e);
+         }
+      }
+      catch (Throwable e)
+      {
+         if (e instanceof Error)
+         {
+            throw ((Error)e);
+         }
+         throw buildRuntimeException(e);
+      }
+
+      //
+      script.flush();
+   }
+
+   private TemplateRuntimeException buildRuntimeException(Throwable t)
+   {
+      StackTraceElement[] trace = t.getStackTrace();
+
+      //
+      TextItem firstItem = null;
+
+      // Try to find the groovy script lines
+      for (int i = 0;i < trace.length;i++)
+      {
+         StackTraceElement element = trace[i];
+         if (element.getClassName().equals(scriptClass.getName()))
+         {
+            int lineNumber = element.getLineNumber();
+            TextItem item = lineTable.get(lineNumber);
+            int templateLineNumber;
+            if (item != null)
+            {
+               templateLineNumber = item.getPosition().getLine();
+               if (firstItem == null)
+               {
+                  firstItem = item;
+               }
+            }
+            else
+            {
+               templateLineNumber = -1;
+            }
+            element = new StackTraceElement(
+               element.getClassName(),
+               element.getMethodName(),
+               element.getFileName(),
+               templateLineNumber);
+            trace[i] = element;
+         }
+      }
+
+      //
+      t.setStackTrace(trace);
+
+      //
+      return new TemplateRuntimeException(firstItem, t);
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScriptBuilder.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScriptBuilder.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScriptBuilder.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyScriptBuilder.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyCodeSource;
+import org.codehaus.groovy.control.CompilationFailedException;
+import org.codehaus.groovy.control.CompilerConfiguration;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GroovyScriptBuilder 
+{
+
+   /** . */
+   private final String name;
+
+   /** . */
+   private final String templateText;
+
+   /** . */
+   private SectionType currentType = null;
+
+   /** . */
+   private StringBuilder accumulatedText = new StringBuilder();
+
+   /** . */
+   private Script script = new Script();
+
+   public GroovyScriptBuilder(String name, String templateText)
+   {
+      this.name = name;
+      this.templateText = templateText;
+   }
+
+   private void begin(SectionType sectionType, Position pos)
+   {
+      if (sectionType == null)
+      {
+         throw new NullPointerException();
+      }
+      if (pos == null)
+      {
+         throw new NullPointerException();
+      }
+      if (currentType != null)
+      {
+         throw new IllegalStateException();
+      }
+      this.currentType = sectionType;
+
+      //
+      switch (currentType)
+      {
+         case STRING:
+            break;
+         case SCRIPTLET:
+            break;
+         case EXPR:
+            script.appendGroovy(";out.print(\"${");
+            break;
+      }
+   }
+
+   private void append(SectionItem item)
+   {
+      if (item instanceof TextItem)
+      {
+         TextItem textItem = (TextItem)item;
+         String text = textItem.getData();
+         switch (currentType)
+         {
+            case STRING:
+               accumulatedText.append(text);
+               break;
+            case SCRIPTLET:
+               script.appendGroovy(text);
+               script.positionTable.put(script.lineNumber, textItem);
+               break;
+            case EXPR:
+               script.appendGroovy(text);
+               script.positionTable.put(script.lineNumber, textItem);
+               break;
+         }
+      }
+      else if (item instanceof LineBreakItem)
+      {
+         switch (currentType)
+         {
+            case STRING:
+               accumulatedText.append("\n");
+               break;
+            case SCRIPTLET:
+            case EXPR:
+               script.appendGroovy("\n");
+               script.lineNumber++;
+               break;
+         }
+      }
+      else
+      {
+         throw new AssertionError();
+      }
+   }
+
+   private void end()
+   {
+      if (currentType == null)
+      {
+         throw new IllegalStateException();
+      }
+
+      //
+      switch (currentType)
+      {
+         case STRING:
+            if (accumulatedText.length() > 0)
+            {
+               script.appendText(accumulatedText.toString());
+               accumulatedText.setLength(0);
+            }
+            break;
+         case SCRIPTLET:
+            // We append a line break because we want that any line comment does not affect the template
+            script.appendGroovy("\n");
+            script.lineNumber++;
+            break;
+         case EXPR:
+            script.appendGroovy("}\");\n");
+            script.lineNumber++;
+            break;
+      }
+
+      //
+      this.currentType = null;
+   }
+
+   public GroovyScript build() throws TemplateCompilationException
+   {
+      List<TemplateSection> sections = new TemplateParser().parse(templateText);
+
+      //
+      for (TemplateSection section : sections)
+      {
+         begin(section.getType(), section.getItems().get(0).getPosition());
+         for (SectionItem item : section.getItems())
+         {
+            append(item);
+         }
+         end();
+      }
+
+      //
+      String groovyText = script.toString();
+
+      //
+      CompilerConfiguration config = new CompilerConfiguration();
+
+      //
+      byte[] bytes;
+      try
+      {
+         config.setScriptBaseClass(BaseScript.class.getName());
+         bytes = groovyText.getBytes(config.getSourceEncoding());
+      }
+      catch (UnsupportedEncodingException e)
+      {
+         throw new TemplateCompilationException(e, groovyText);
+      }
+
+      //
+      InputStream in = new ByteArrayInputStream(bytes);
+      GroovyCodeSource gcs = new GroovyCodeSource(in, name, "/groovy/shell");
+      GroovyClassLoader loader = new GroovyClassLoader(Thread.currentThread().getContextClassLoader(), config);
+      Class<?> scriptClass;
+      try
+      {
+         scriptClass = loader.parseClass(gcs, false);
+      }
+      catch (CompilationFailedException e)
+      {
+         throw new GroovyCompilationException(e, templateText, groovyText);
+      }
+      catch (ClassFormatError e)
+      {
+         throw new GroovyCompilationException(e, templateText, groovyText);
+      }
+
+      return new GroovyScript(
+         script.toString(), scriptClass, Collections.unmodifiableMap(new HashMap<Integer, TextItem>(script.positionTable))
+      );
+   }
+
+   /**
+    * Internal representation of a script
+    */
+   private static class Script
+   {
+
+      /** . */
+      private StringBuilder out = new StringBuilder();
+
+      /** . */
+      private List<TextContant> textMethods = new ArrayList<TextContant>();
+
+      /** . */
+      private int methodCount = 0;
+
+      /** The line number table. */
+      private Map<Integer, TextItem> positionTable = new HashMap<Integer, TextItem>();
+
+      /** The current line number. */
+      private int lineNumber = 1;
+
+      @Override
+      public String toString()
+      {
+         StringBuilder builder = new StringBuilder();
+         builder.append(out.toString());
+         builder.append("\n");
+         builder.append("public class Constants\n");
+         builder.append("{\n");
+         for (TextContant method : textMethods)
+         {
+            builder.append(method.getDeclaration()).append("\n");
+         }
+         builder.append("}\n");
+         return builder.toString();
+      }
+
+      public void appendText(String text)
+      {
+         TextContant m = new TextContant("s" + methodCount++, text);
+         out.append("out.print(Constants.").append(m.name).append(");\n");
+         textMethods.add(m);
+         lineNumber++;
+      }
+
+      public void appendGroovy(String s)
+      {
+         out.append(s);
+      }
+   }
+
+   /**
+    * This object encapsulate the generation of a method that outputs the specified text.
+    */
+   private static class TextContant
+   {
+
+      /** . */
+      private final String name;
+
+      /** . */
+      private final String text;
+
+      private TextContant(String name, String text)
+      {
+         this.name = name;
+         this.text = text;
+      }
+
+      public String getDeclaration()
+      {
+         StringBuilder builder = new StringBuilder("");
+         for (int i = 0;i < text.length();i++)
+         {
+            char c = text.charAt(i);
+            if (c == '\n')
+            {
+               builder.append("\\n");
+            }
+            else if (c == '\"')
+            {
+               builder.append("\\\"");
+            }
+            else
+            {
+               builder.append(c);
+            }
+         }
+         return "public static final " + GroovyText.class.getName() + " " + name + " = new " + GroovyText.class.getName() + "(\"" + builder + "\");";
+      }
+   }
+}
\ No newline at end of file

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplate.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplate.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplate.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplate.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Map;
+
+/**
+ * A Groovy template.
+ *
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GroovyTemplate
+{
+
+   private static String read(Reader reader) throws IOException
+   {
+      StringBuilder builder = new StringBuilder();
+      char[] chars = new char[256];
+      for (int s = reader.read(chars);s != -1; s = reader.read(chars))
+      {
+         builder.append(chars, 0, s);
+      }
+      return builder.toString();
+   }
+
+   /** The name of the template. */
+   private final String name;
+
+   /** The text of the template. */
+   private final String templateText;
+
+   /** The groovy script. */
+   private final GroovyScript script;
+
+   public GroovyTemplate(String name, Reader scriptReader) throws IOException, TemplateCompilationException
+   {
+      this(name, read(scriptReader));
+   }
+
+   public GroovyTemplate(Reader scriptReader) throws IOException, TemplateCompilationException
+   {
+      this(read(scriptReader));
+   }
+
+   public GroovyTemplate(String templateText) throws TemplateCompilationException
+   {
+      this(null, templateText);
+   }
+
+   public GroovyTemplate(String name, String templateText) throws TemplateCompilationException
+   {
+      if (name == null)
+      {
+         name = "fic";
+      }
+
+      //
+      GroovyScriptBuilder compiler = new GroovyScriptBuilder(name, templateText);
+
+      //
+      this.name = name;
+      this.script = compiler.build();
+      this.templateText = templateText;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public String getClassName()
+   {
+      return script.getScriptClass().getName();
+   }
+
+   public String getTemplateText()
+   {
+      return templateText;
+   }
+
+   public String getGroovyText()
+   {
+      return script.getGroovyText();
+   }
+
+   public void render(Writer writer) throws IOException, TemplateRuntimeException
+   {
+      render(writer, null);
+   }
+
+   public void render(Writer writer, Map binding) throws IOException, TemplateRuntimeException
+   {
+      script.render(binding, writer);
+   }
+
+   public String render() throws IOException, TemplateRuntimeException
+   {
+      return render((Map)null);
+   }
+
+   public String render(Map binding) throws IOException, TemplateRuntimeException
+   {
+      StringWriter buffer = new StringWriter();
+      render(buffer, binding);
+      buffer.close();
+      return buffer.toString();
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplateEngine.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplateEngine.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplateEngine.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyTemplateEngine.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GroovyTemplateEngine
+{
+   public GroovyTemplate createTemplate(String text) throws TemplateCompilationException
+   {
+      return new GroovyTemplate(text);
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyText.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyText.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyText.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyText.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import org.exoplatform.commons.utils.BinaryOutput;
+import org.exoplatform.commons.utils.Text;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.nio.charset.Charset;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GroovyText extends Text 
+{
+
+   /** . */
+   private final String s;
+
+   /** . */
+   private final byte[] bytes;
+
+   /** . */
+   private static final Charset UTF_8 = Charset.forName("UTF-8");
+
+   public GroovyText(String s)
+   {
+      try
+      {
+         this.s = s;
+         this.bytes = s.getBytes("UTF-8");
+      }
+      catch (UnsupportedEncodingException e)
+      {
+         throw new UndeclaredThrowableException(e);
+      }
+   }
+
+   @Override
+   public void writeTo(Writer writer) throws IOException
+   {
+      if (writer instanceof BinaryOutput)
+      {
+         BinaryOutput osw = (BinaryOutput)writer;
+         if (UTF_8.equals(osw.getCharset()))
+         {
+            osw.write(bytes);
+            return;
+         }
+      }
+      writer.append(s);
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/LineBreakItem.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/LineBreakItem.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/LineBreakItem.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/LineBreakItem.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class LineBreakItem extends SectionItem
+{
+
+   public LineBreakItem(Position pos)
+   {
+      super(pos);
+   }
+
+   @Override
+   public String toString()
+   {
+      return "LineBreak[position=" + getPosition() + "]";
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      return obj == this || obj instanceof LineBreakItem;
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/OutputStreamWriterGroovyPrinter.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/OutputStreamWriterGroovyPrinter.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/OutputStreamWriterGroovyPrinter.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/OutputStreamWriterGroovyPrinter.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import org.exoplatform.commons.utils.BinaryOutput;
+import org.exoplatform.commons.utils.OutputStreamPrinter;
+import org.exoplatform.commons.utils.Text;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class OutputStreamWriterGroovyPrinter extends GroovyPrinter implements BinaryOutput
+{
+
+   /** . */
+   private final OutputStreamPrinter out;
+
+   public OutputStreamWriterGroovyPrinter(OutputStreamPrinter out)
+   {
+      if (out == null)
+      {
+         throw new NullPointerException();
+      }
+      this.out = out;
+   }
+
+   @Override
+   protected void write(char c) throws IOException
+   {
+      out.write(c);
+   }
+
+   @Override
+   protected void write(String s) throws IOException
+   {
+      out.write(s);
+   }
+
+   @Override
+   protected void write(Text text) throws IOException
+   {
+      text.writeTo(out);
+   }
+
+   @Override
+   public void flush() throws IOException
+   {
+      out.flush();
+   }
+
+   @Override
+   public void close() throws IOException
+   {
+      out.close();
+   }
+
+   public Charset getCharset()
+   {
+      return out.getCharset();
+   }
+
+   public void write(byte[] bytes) throws IOException
+   {
+      out.write(bytes);
+   }
+
+   public void write(byte[] b, int off, int len) throws IOException
+   {
+      out.write(b, off, len);
+   }
+
+   public void write(byte b) throws IOException
+   {
+      out.write(b);
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/Position.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/Position.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/Position.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/Position.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Position
+{
+
+   /** . */
+   private final int col;
+
+   /** . */
+   private final int line;
+
+   public Position(int col, int line)
+   {
+      if (col < 0)
+      {
+         throw new IllegalArgumentException();
+      }
+      if (line < 0)
+      {
+         throw new IllegalArgumentException();
+      }
+      
+      //
+      this.col = col;
+      this.line = line;
+   }
+
+   public int getCol()
+   {
+      return col;
+   }
+
+   public int getLine()
+   {
+      return line;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+      {
+         return true;
+      }
+      if (obj instanceof Position)
+      {
+         Position that = (Position)obj;
+         return col == that.col && line == that.line;
+      }
+      return false;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "Position[col=" + col + ",line=" + line + "]";
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionItem.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionItem.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionItem.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionItem.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class SectionItem
+{
+
+   /** . */
+   private final Position pos;
+
+   protected SectionItem(Position pos)
+   {
+      if (pos == null)
+      {
+         throw new NullPointerException("No null position accepted");
+      }
+      this.pos = pos;
+   }
+
+   public Position getPosition()
+   {
+      return pos;
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionType.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionType.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionType.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/SectionType.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum SectionType
+{
+
+   STRING,
+
+   SCRIPTLET,
+
+   EXPR
+
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateCompilationException.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateCompilationException.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateCompilationException.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateCompilationException.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TemplateCompilationException extends Exception
+{
+
+   /** . */
+   private final String templateText;
+
+   public TemplateCompilationException(Throwable cause, String templateText)
+   {
+      super(cause);
+
+      //
+      this.templateText = templateText;
+   }
+
+   public String getTemplateText()
+   {
+      return templateText;
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateParser.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateParser.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateParser.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateParser.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,315 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import org.exoplatform.commons.utils.UndeclaredIOException;
+
+import java.io.IOException;
+import java.io.PushbackReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TemplateParser
+{
+
+   private enum Status
+   {
+      TEXT,
+
+      EXPR,
+
+      SCRIPTLET,
+
+      START_ANGLE,
+
+      SCRIPLET_OR_EXPR,
+
+      MAYBE_SCRIPLET_END,
+
+      MAYBE_EXPR_END,
+
+      MAYBE_GSTRING_EXPR,
+
+      GSTRING_CURLY_EXPR,
+
+      GSTRING_EXPR
+   }
+
+   public List<TemplateSection> parse(String s)
+   {
+      try
+      {
+         return parse(new StringReader(s));
+      }
+      catch (IOException e)
+      {
+         throw new UndeclaredIOException(e);
+      }
+   }
+
+   public List<TemplateSection> parse(Reader tmp) throws IOException
+   {
+      PushbackReader reader = new PushbackReader(tmp);
+
+
+      //
+      ArrayList<TemplateSection> sections = new ArrayList<TemplateSection>();
+      StringBuilder accumulator = new StringBuilder();
+
+      //
+      int lineNumber = 1;
+      int colNumber = 1;
+      Position pos = new Position(1, 1);
+      Status status = Status.TEXT;
+      int i;
+      while ((i = reader.read()) != -1)
+      {
+         char c = (char)i;
+         
+         //
+         if (c == '\r')
+         {
+            // On Windows, "\r\n" is a new line
+            int j = reader.read();
+            if (j != -1)
+            {
+               char c2 = (char)j;
+               if (c2 == '\n')
+               {
+                  c = '\n';
+               }
+               else
+               {
+                  reader.unread(j);
+               }
+            }
+         }
+
+         // Update current position
+         if (c == '\n')
+         {
+            colNumber = 1;
+            lineNumber++;
+         }
+         else
+         {
+            colNumber++;
+         }
+
+         //
+         switch (status)
+         {
+            case TEXT:
+               if (c == '<')
+               {
+                  status = Status.START_ANGLE;
+               }
+               else if (c == '$')
+               {
+                  status = Status.MAYBE_GSTRING_EXPR;
+               }
+               else
+               {
+                  accumulator.append(c);
+               }
+               break;
+            case EXPR:
+               if (c == '%')
+               {
+                  status = Status.MAYBE_EXPR_END;
+               }
+               else
+               {
+                  accumulator.append(c);
+               }
+               break;
+            case SCRIPTLET:
+               if (c == '%')
+               {
+                  status = Status.MAYBE_SCRIPLET_END;
+               }
+               else
+               {
+                  accumulator.append(c);
+               }
+               break;
+            case START_ANGLE:
+               if (c == '%')
+               {
+                  status = Status.SCRIPLET_OR_EXPR;
+               }
+               else
+               {
+                  status = Status.TEXT;
+                  accumulator.append('<').append(c);
+               }
+               break;
+            case SCRIPLET_OR_EXPR:
+               if (accumulator.length() > 0)
+               {
+                  sections.add(new TemplateSection(SectionType.STRING, accumulator.toString(), pos));
+                  accumulator.setLength(0);
+                  pos = new Position(colNumber, lineNumber);
+               }
+               if (c == '=')
+               {
+                  status = Status.EXPR;
+               }
+               else if (c == '%')
+               {
+                  status = Status.MAYBE_SCRIPLET_END;
+               }
+               else
+               {
+                  status = Status.SCRIPTLET;
+                  accumulator.append(c);
+               }
+               break;
+            case MAYBE_SCRIPLET_END:
+               if (c == '>')
+               {
+                  sections.add(new TemplateSection(SectionType.SCRIPTLET, accumulator.toString(), pos));
+                  accumulator.setLength(0);
+                  pos = new Position(colNumber, lineNumber);
+
+                  //
+                  status = Status.TEXT;
+               }
+               else if (c == '%')
+               {
+                  accumulator.append('%');
+               }
+               else
+               {
+                  status = Status.SCRIPTLET;
+                  accumulator.append('%').append(c);
+               }
+               break;
+            case MAYBE_EXPR_END:
+               if (c == '>')
+               {
+                  sections.add(new TemplateSection(SectionType.EXPR, accumulator.toString(), pos));
+                  accumulator.setLength(0);
+                  pos = new Position(colNumber, lineNumber);
+
+                  //
+                  status = Status.TEXT;
+               }
+               else if (c == '%')
+               {
+                  accumulator.append('%');
+               }
+               else
+               {
+                  status = Status.EXPR;
+                  accumulator.append('%').append(c);
+               }
+               break;
+            case MAYBE_GSTRING_EXPR:
+               if (c == '{')
+               {
+                  if (accumulator.length() > 0)
+                  {
+                     sections.add(new TemplateSection(SectionType.STRING, accumulator.toString(), pos));
+                     accumulator.setLength(0);
+                     pos = new Position(colNumber, lineNumber);
+                  }
+                  status = Status.GSTRING_CURLY_EXPR;
+               }
+               else if (Character.isJavaIdentifierStart(c))
+               {
+                  if (accumulator.length() > 0)
+                  {
+                     sections.add(new TemplateSection(SectionType.STRING, accumulator.toString(), pos));
+                     accumulator.setLength(0);
+                     pos = new Position(colNumber, lineNumber);
+                  }
+                  status = Status.GSTRING_EXPR;
+                  accumulator.append(c);
+               }
+               else
+               {
+                  accumulator.append('$').append(c);
+               }
+               break;
+            case GSTRING_CURLY_EXPR:
+               if (c == '}')
+               {
+                  sections.add(new TemplateSection(SectionType.EXPR, accumulator.toString(), pos));
+                  accumulator.setLength(0);
+                  pos = new Position(colNumber, lineNumber);
+
+                  //
+                  status = Status.TEXT;
+               }
+               else
+               {
+                  accumulator.append(c);
+               }
+               break;
+            case GSTRING_EXPR:
+               if (c == '.' || Character.isJavaIdentifierPart(c))
+               {
+                  accumulator.append(c);
+               }
+               else
+               {
+                  sections.add(new TemplateSection(SectionType.EXPR, accumulator.toString(), pos));
+                  accumulator.setLength(0);
+                  pos = new Position(colNumber, lineNumber);
+
+                  //
+                  status = Status.TEXT;
+                  accumulator.append(c);
+               }
+               break;
+            default:
+               throw new AssertionError();
+         }
+      }
+
+      // Last section
+      if (accumulator.length() > 0)
+      {
+         switch (status)
+         {
+            case TEXT:
+               sections.add(new TemplateSection(SectionType.STRING, accumulator.toString(), pos));
+               accumulator.setLength(0);
+               pos = new Position(colNumber, lineNumber);
+               break;
+            case GSTRING_EXPR:
+               sections.add(new TemplateSection(SectionType.EXPR, accumulator.toString(), pos));
+               accumulator.setLength(0);
+               pos = new Position(colNumber, lineNumber);
+               break;
+            default:
+               throw new AssertionError();
+         }
+      }
+
+      //
+      return Collections.unmodifiableList(sections);
+   }
+}
\ No newline at end of file

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateRuntimeException.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateRuntimeException.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateRuntimeException.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateRuntimeException.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+/**
+ * A *checked* exception that denotes a Groovy runtime exception.
+ *
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TemplateRuntimeException extends Exception
+{
+
+   /** . */
+   private final TextItem textItem;
+
+   public TemplateRuntimeException(TextItem textItem, String message, Throwable cause)
+   {
+      super(message, cause);
+
+      //
+      this.textItem = textItem;
+   }
+
+   public TemplateRuntimeException(TextItem textItem, Throwable cause)
+   {
+      super(cause);
+
+      //
+      this.textItem = textItem;
+   }
+
+   public TextItem getTextItem()
+   {
+      return textItem;
+   }
+
+   public Integer getLineNumber()
+   {
+      return textItem != null ? textItem.getPosition().getLine() : null;
+   }
+
+   public String getText()
+   {
+      return textItem != null ? textItem.getData() : null;
+   }
+
+   @Override
+   public String getMessage()
+   {
+      return textItem != null ? ("Groovy template exception at " + textItem) : "Groovy template exception";
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateSection.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateSection.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateSection.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TemplateSection.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TemplateSection
+{
+
+   /** . */
+   private final SectionType type;
+
+   /** . */
+   private final List<SectionItem> items;
+
+   public TemplateSection(SectionType type, String text)
+   {
+      this(type, text, 0, 0);
+   }
+
+   public TemplateSection(SectionType type, String text, Position pos)
+   {
+      this(type, text, pos.getCol(), pos.getLine());
+   }
+
+   public TemplateSection(SectionType type, String text, int colNumber, int lineNumber)
+   {
+      if (type == null)
+      {
+         throw new NullPointerException();
+      }
+      if (text == null)
+      {
+         throw new NullPointerException();
+      }
+
+      // Now we process the line breaks
+      ArrayList<SectionItem> sections = new ArrayList<SectionItem>();
+
+      //
+      int from = 0;
+      while (true)
+      {
+         int to = text.indexOf('\n', from);
+
+         //
+         if (to != -1)
+         {
+            String chunk = text.substring(from, to);
+            sections.add(new TextItem(new Position(colNumber, lineNumber), chunk));
+
+            //
+            sections.add(new LineBreakItem(new Position(colNumber + (to - from), lineNumber)));
+
+            //
+            from = to + 1;
+            lineNumber++;
+            colNumber = 1;
+         }
+         else
+         {
+            String chunk = text.substring(from);
+            sections.add(new TextItem(new Position(colNumber, lineNumber), chunk));
+            break;
+         }
+      }
+
+      //
+      this.type = type;
+      this.items = Collections.unmodifiableList(sections);
+   }
+
+   public SectionType getType()
+   {
+      return type;
+   }
+
+   public List<SectionItem> getItems()
+   {
+      return items;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+      {
+         return true;
+      }
+      if (obj instanceof TemplateSection)
+      {
+         TemplateSection that = (TemplateSection)obj;
+         return type == that.type && items.equals(that.items);
+      }
+      return false;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "TextSection[type=" + type + ",text=" + items + "]";
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TextItem.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/TextItem.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TextItem.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/TextItem.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TextItem extends SectionItem
+{
+
+   /** . */
+   private final String data;
+
+   public TextItem(Position pos, String data)
+   {
+      super(pos);
+
+      //
+      if (data == null)
+      {
+         throw new NullPointerException();
+      }
+
+      //
+      this.data = data;
+   }
+
+   public String getData()
+   {
+      return data;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+      {
+         return true;
+      }
+      if (obj instanceof TextItem)
+      {
+         TextItem that = (TextItem)obj;
+         return data.equals(that.data);
+      }
+      return false;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "DataText[pos=" + getPosition() + ",data=" + data + "]";
+   }
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/WriterGroovyPrinter.java (from rev 480, portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/WriterGroovyPrinter.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/WriterGroovyPrinter.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/WriterGroovyPrinter.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import org.exoplatform.commons.utils.Text;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class WriterGroovyPrinter extends GroovyPrinter
+{
+
+   /** . */
+   private Writer writer;
+
+   public WriterGroovyPrinter(Writer writer)
+   {
+      if (writer == null)
+      {
+         throw new NullPointerException();
+      }
+      this.writer = writer;
+   }
+
+   @Override
+   protected void write(char c) throws IOException
+   {
+      writer.write(c);
+   }
+
+   @Override
+   protected void write(String s) throws IOException
+   {
+      writer.write(s);
+   }
+
+   @Override
+   protected void write(Text text) throws IOException
+   {
+      text.writeTo(writer);
+   }
+
+   @Override
+   public void flush() throws IOException
+   {
+      writer.flush();
+   }
+
+   @Override
+   public void close() throws IOException 
+   {
+      writer.close();
+   }
+}

Deleted: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/text/SimpleTemplateEngine.java
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/text/SimpleTemplateEngine.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/text/SimpleTemplateEngine.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,324 +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.groovyscript.text;
-
-import groovy.lang.Binding;
-import groovy.lang.GroovyClassLoader;
-import groovy.lang.GroovyCodeSource;
-import groovy.lang.GroovyShell;
-import groovy.lang.Script;
-import groovy.lang.Writable;
-import groovy.text.Template;
-import groovy.text.TemplateEngine;
-
-import org.codehaus.groovy.control.CompilationFailedException;
-import org.codehaus.groovy.control.CompilerConfiguration;
-import org.codehaus.groovy.runtime.InvokerHelper;
-import org.exoplatform.commons.utils.Printer;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Map;
-
-/**
- * This simple template engine uses JSP <% %> script and <%= %> expression syntax.  It also lets you use normal groovy expressions in
- * the template text much like the new JSP EL functionality.  The variable 'out' is bound to the writer that the template is being written to.
- * 
- * @author sam
- * @author Christian Stein
- */
-public class SimpleTemplateEngine extends TemplateEngine
-{
-
-   private final boolean verbose;
-
-   public SimpleTemplateEngine()
-   {
-      this(false);
-   }
-
-   public SimpleTemplateEngine(boolean verbose)
-   {
-      this.verbose = verbose;
-   }
-
-   public Template createTemplate(Reader reader) throws CompilationFailedException, IOException
-   {
-      SimpleTemplate template = new SimpleTemplate();
-      GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader());
-      String script = template.parse(reader);
-      if (verbose)
-      {
-         System.out.println("\n-- script source --");
-         System.out.print(script);
-         System.out.println("\n-- script end --\n");
-      }
-
-      //
-      CompilerConfiguration config = new CompilerConfiguration();
-      config.setScriptBaseClass(ExoScript.class.getName());
-      byte[] bytes = script.getBytes(config.getSourceEncoding());
-      InputStream in = new ByteArrayInputStream(bytes);
-      GroovyCodeSource gcs = new GroovyCodeSource(in, "fic", "/groovy/shell");
-      GroovyClassLoader loader = new GroovyClassLoader(Thread.currentThread().getContextClassLoader(), config);
-      loader.parseClass(gcs, false);
-      template.scriptClass = loader.parseClass(script);
-      return template;
-   }
-
-   public static abstract class ExoScript extends Script
-   {
-
-      private Printer printer;
-
-      protected ExoScript()
-      {
-      }
-
-      protected ExoScript(Binding binding)
-      {
-         super(binding);
-      }
-
-      @Override
-      public void println(Object o)
-      {
-         printer.println(o);
-      }
-
-      @Override
-      public void println()
-      {
-         printer.println();
-      }
-
-      @Override
-      public void print(Object o)
-      {
-         printer.print(o);
-      }
-
-      public void flush()
-      {
-         try
-         {
-            printer.flush();
-         }
-         catch (IOException e)
-         {
-            //TODO: need to check again
-            //      	e.printStackTrace();
-         }
-      }
-   }
-
-   private static class SimpleTemplate implements Template
-   {
-
-      protected Class scriptClass;
-
-      public Writable make()
-      {
-         return make(null);
-      }
-
-      public Writable make(final Map map)
-      {
-         return new Writable()
-         {
-            /**
-             * Write the template document with the set binding applied to the writer.
-             *
-             * @see groovy.lang.Writable#writeTo(java.io.Writer)
-             */
-            public Writer writeTo(Writer writer)
-            {
-               Binding context;
-               if (map == null)
-                  context = new Binding();
-               else
-                  context = new Binding(map);
-
-               //
-               ExoScript script = (ExoScript)InvokerHelper.createScript(scriptClass, context);
-               script.printer = (Printer)writer;
-               script.setProperty("out", script.printer);
-               script.run();
-               script.flush();
-               return writer;
-            }
-
-            /**
-             * Convert the template and binding into a result String.
-             *
-             * @see java.lang.Object#toString()
-             */
-            public String toString()
-            {
-               try
-               {
-                  StringWriter sw = new StringWriter();
-                  writeTo(sw);
-                  return sw.toString();
-               }
-               catch (Exception e)
-               {
-                  return e.toString();
-               }
-            }
-         };
-      }
-
-      /**
-       * Parse the text document looking for <% or <%= and then call out to the appropriate handler, otherwise copy the text directly
-       * into the script while escaping quotes.
-       * 
-       * @param reader
-       * @throws IOException
-       */
-      protected String parse(Reader reader) throws IOException
-      {
-         if (!reader.markSupported())
-         {
-            reader = new BufferedReader(reader);
-         }
-         StringWriter sw = new StringWriter();
-         startScript(sw);
-         int c;
-         while ((c = reader.read()) != -1)
-         {
-            if (c == '<')
-            {
-               reader.mark(1);
-               c = reader.read();
-               if (c != '%')
-               {
-                  sw.write('<');
-                  reader.reset();
-                  continue;
-               }
-               reader.mark(1);
-               c = reader.read();
-               if (c == '=')
-                  groovyExpression(reader, sw);
-               else
-               {
-                  reader.reset();
-                  groovySection(reader, sw);
-               }
-               continue; // at least '<' is consumed ... read next chars.
-            }
-            if (c == '\"')
-               sw.write('\\');
-            /*
-             * Handle raw new line characters.
-             */
-            if (c == '\n' || c == '\r')
-            {
-               if (c == '\r')
-               { // on Windows, "\r\n" is a new line.
-                  reader.mark(1);
-                  c = reader.read();
-                  if (c != '\n')
-                     reader.reset();
-               }
-               sw.write("\\n\");\nout.print(\"");
-               continue;
-            }
-            sw.write(c);
-         }
-         endScript(sw);
-         String result = sw.toString();
-         return result;
-      }
-
-      private void startScript(StringWriter sw)
-      {
-         sw.write("/* Generated by SimpleTemplateEngine */\n");
-         sw.write("out.print(\"");
-      }
-
-      private void endScript(StringWriter sw)
-      {
-         sw.write("\");\n");
-      }
-
-      /**
-       * Closes the currently open write and writes out the following text as a GString expression until it reaches an end %>.
-       * 
-       * @param reader
-       * @param sw
-       * @throws IOException
-       */
-      private void groovyExpression(Reader reader, StringWriter sw) throws IOException
-      {
-         sw.write("\");out.print(\"${");
-         int c;
-         while ((c = reader.read()) != -1)
-         {
-            if (c == '%')
-            {
-               c = reader.read();
-               if (c == '>')
-                  break;
-               sw.write('%');
-            }
-            if (c != '\n' && c != '\r')
-               sw.write(c);
-         }
-         sw.write("}\");\nout.print(\"");
-      }
-
-      /**
-       * Closes the currently open write and writes the following text as normal Groovy script code until it reaches an end %>.
-       * 
-       * @param reader
-       * @param sw
-       * @throws IOException
-       */
-      private void groovySection(Reader reader, StringWriter sw) throws IOException
-      {
-         sw.write("\");");
-         int c;
-         while ((c = reader.read()) != -1)
-         {
-            if (c == '%')
-            {
-               c = reader.read();
-               if (c == '>')
-                  break;
-               sw.write('%');
-            }
-            /* Don't eat EOL chars in sections - as they are valid instruction separators.
-             * See http://jira.codehaus.org/browse/GROOVY-980
-             */
-            // if (c != '\n' && c != '\r') {
-            sw.write(c);
-            //}
-         }
-         sw.write(";\nout.print(\"");
-      }
-   }
-}

Modified: portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -21,9 +21,10 @@
 
 import groovy.lang.Writable;
 import groovy.text.Template;
-
 import org.exoplatform.commons.utils.IOUtil;
 import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.groovyscript.GroovyTemplate;
+import org.exoplatform.groovyscript.GroovyTemplateEngine;
 import org.exoplatform.management.annotations.Managed;
 import org.exoplatform.management.annotations.ManagedDescription;
 import org.exoplatform.management.annotations.ManagedName;
@@ -45,9 +46,9 @@
 public class TemplateService
 {
 
-   private SimpleTemplateEngine engine_;
+   private GroovyTemplateEngine engine_;
 
-   private ExoCache<String, Template> templatesCache_;
+   private ExoCache<String, GroovyTemplate> templatesCache_;
 
    private TemplateStatisticService statisticService;
 
@@ -56,7 +57,7 @@
    public TemplateService(InitParams params, TemplateStatisticService statisticService, CacheService cservice)
       throws Exception
    {
-      engine_ = new SimpleTemplateEngine();
+      engine_ = new GroovyTemplateEngine();
       this.statisticService = statisticService;
       templatesCache_ = cservice.getCacheInstance(TemplateService.class.getName());
       getTemplatesCache().setLiveTime(10000);
@@ -66,11 +67,10 @@
    {
       long startTime = System.currentTimeMillis();
 
-      Template template = getTemplate(name, context.getResourceResolver());
+      GroovyTemplate template = getTemplate(name, context.getResourceResolver());
       context.put("_ctx", context);
       context.setGroovyTemplateService(this);
-      Writable writable = template.make(context);
-      writable.writeTo(context.getWriter());
+      template.render(context.getWriter(), context);
 
       long endTime = System.currentTimeMillis();
 
@@ -93,24 +93,22 @@
       if (context == null)
          throw new Exception("Binding cannot be null");
       context.put("_ctx", context);
-      Template template = getTemplate(name, context.getResourceResolver());
-      Writable writable = template.make(context);
-      writable.writeTo(context.getWriter());
-
+      GroovyTemplate template = getTemplate(name, context.getResourceResolver());
+      template.render(context.getWriter(), context);
    }
 
-   final public Template getTemplate(String name, ResourceResolver resolver) throws Exception
+   final public GroovyTemplate getTemplate(String name, ResourceResolver resolver) throws Exception
    {
       return getTemplate(name, resolver, cacheTemplate_);
    }
 
-   final public Template getTemplate(String url, ResourceResolver resolver, boolean cacheable) throws Exception
+   final public GroovyTemplate getTemplate(String url, ResourceResolver resolver, boolean cacheable) throws Exception
    {
-      Template template = null;
+      GroovyTemplate template = null;
       if (cacheable)
       {
          String resourceId = resolver.createResourceId(url);
-         template = (Template)getTemplatesCache().get(resourceId);
+         template = getTemplatesCache().get(resourceId);
       }
       if (template != null)
          return template;
@@ -138,13 +136,8 @@
       getTemplatesCache().remove(resourceId);
    }
 
-   public void setTemplatesCache(ExoCache<String, Template> templatesCache_)
+   public ExoCache<String, GroovyTemplate> getTemplatesCache()
    {
-      this.templatesCache_ = templatesCache_;
-   }
-
-   public ExoCache<String, Template> getTemplatesCache()
-   {
       return templatesCache_;
    }
 

Copied: portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript (from rev 480, portal/trunk/component/scripting/src/test/java/org/exoplatform/groovyscript)

Deleted: portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateCompiler.java
===================================================================
--- portal/trunk/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateCompiler.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateCompiler.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2003-2007 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.groovyscript;
-
-import junit.framework.TestCase;
-
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestTemplateCompiler extends TestCase
-{
-
-   /** . */
-//   private final TemplateCompiler compiler = new TemplateCompiler();
-
-   public void testFoo() throws IOException
-   {
-//      assertEquals("", compiler.compile(""));
-//      assertEquals("out.print(\"a\");", compiler.compile("a"));
-//      assertEquals("out.print(\"a\n\");\nout.print(\"b\");", compiler.compile("a\nb"));
-//      assertEquals("", compiler.compile("<%%>"));
-//      assertEquals("a", compiler.compile("<%a%>"));
-//      assertEquals("a\nb", compiler.compile("<%a\nb%>"));
-   }
-}

Copied: portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateCompiler.java (from rev 480, portal/trunk/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateCompiler.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateCompiler.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateCompiler.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestTemplateCompiler extends TestCase
+{
+
+   /** . */
+//   private final TemplateCompiler compiler = new TemplateCompiler();
+
+   public void testFoo() throws IOException
+   {
+//      assertEquals("", compiler.compile(""));
+//      assertEquals("out.print(\"a\");", compiler.compile("a"));
+//      assertEquals("out.print(\"a\n\");\nout.print(\"b\");", compiler.compile("a\nb"));
+//      assertEquals("", compiler.compile("<%%>"));
+//      assertEquals("a", compiler.compile("<%a%>"));
+//      assertEquals("a\nb", compiler.compile("<%a\nb%>"));
+   }
+}

Deleted: portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateParser.java
===================================================================
--- portal/trunk/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateParser.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateParser.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2003-2007 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.groovyscript;
-
-import junit.framework.TestCase;
-import org.exoplatform.groovyscript.TemplateSection;
-import org.exoplatform.groovyscript.SectionType;
-import org.exoplatform.groovyscript.TemplateParser;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestTemplateParser extends TestCase
-{
-
-   /** . */
-   private TemplateParser parser = new TemplateParser();
-
-   public void testEmpty() throws IOException
-   {
-      assertEquals(Collections.<TemplateSection>emptyList(), parser.parse(""));
-   }
-
-   public void testText() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.STRING, "a")), parser.parse("a"));
-   }
-
-   public void testSingleEmptyScriplet() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.SCRIPTLET, "")), parser.parse("<%%>"));
-   }
-
-   public void testSingleEmptyExpression() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.EXPR, "")), parser.parse("<%=%>"));
-   }
-
-   public void testSingleScriplet() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.SCRIPTLET, "a")), parser.parse("<%a%>"));
-   }
-
-   public void testSingleExpression() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.EXPR, "a")), parser.parse("<%=a%>"));
-   }
-
-   public void testPercentScriplet() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.SCRIPTLET, "%")), parser.parse("<%%%>"));
-   }
-
-   public void testPercentExpression() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.EXPR, "%")), parser.parse("<%=%%>"));
-   }
-
-   public void testStartAngleBracketScriplet() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.SCRIPTLET, "<")), parser.parse("<%<%>"));
-   }
-
-   public void testStartAngleBracketExpression() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.EXPR, "<")), parser.parse("<%=<%>"));
-   }
-
-   public void testSimpleScript() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(
-         new TemplateSection(SectionType.STRING, "a"),
-         new TemplateSection(SectionType.SCRIPTLET, "b"),
-         new TemplateSection(SectionType.STRING, "c")
-         ), parser.parse("a<%b%>c"));
-   }
-
-   public void testSimpleScript2() throws IOException
-   {
-      assertEquals(Arrays.<TemplateSection>asList(
-         new TemplateSection(SectionType.STRING, "a"),
-         new TemplateSection(SectionType.EXPR, "b"),
-         new TemplateSection(SectionType.STRING, "c")
-         ), parser.parse("a<%=b%>c"));
-   }
-
-   public void testWindowsLineBreak() throws IOException
-   {
-
-   }
-
-   public void testPosition() throws IOException
-   {
-      List<TemplateSection> sections = parser.parse("a\nb<%= foo %>d");
-      assertEquals(new Position(1, 1), sections.get(0).getItems().get(0).getPosition());
-      assertEquals(new Position(2, 1), sections.get(0).getItems().get(1).getPosition());
-      assertEquals(new Position(1, 2), sections.get(0).getItems().get(2).getPosition());
-      assertEquals(new Position(5, 2), sections.get(1).getItems().get(0).getPosition());
-      assertEquals(new Position(12, 2), sections.get(2).getItems().get(0).getPosition());
-
-   }
-}

Copied: portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateParser.java (from rev 480, portal/trunk/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateParser.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateParser.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateParser.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestTemplateParser extends TestCase
+{
+
+   /** . */
+   private TemplateParser parser = new TemplateParser();
+
+   public void testEmpty() throws IOException
+   {
+      assertEquals(Collections.<TemplateSection>emptyList(), parser.parse(""));
+   }
+
+   public void testText() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.STRING, "a")), parser.parse("a"));
+   }
+
+   public void testSingleEmptyScriplet() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.SCRIPTLET, "")), parser.parse("<%%>"));
+   }
+
+   public void testSingleEmptyExpression() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.EXPR, "")), parser.parse("<%=%>"));
+   }
+
+   public void testSingleScriplet() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.SCRIPTLET, "a")), parser.parse("<%a%>"));
+   }
+
+   public void testSingleExpression() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.EXPR, "a")), parser.parse("<%=a%>"));
+   }
+
+   public void testPercentScriplet() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.SCRIPTLET, "%")), parser.parse("<%%%>"));
+   }
+
+   public void testPercentExpression() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.EXPR, "%")), parser.parse("<%=%%>"));
+   }
+
+   public void testStartAngleBracketScriplet() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.SCRIPTLET, "<")), parser.parse("<%<%>"));
+   }
+
+   public void testStartAngleBracketExpression() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(new TemplateSection(SectionType.EXPR, "<")), parser.parse("<%=<%>"));
+   }
+
+   public void testSimpleScript() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(
+         new TemplateSection(SectionType.STRING, "a"),
+         new TemplateSection(SectionType.SCRIPTLET, "b"),
+         new TemplateSection(SectionType.STRING, "c")
+         ), parser.parse("a<%b%>c"));
+   }
+
+   public void testSimpleScript2() throws IOException
+   {
+      assertEquals(Arrays.<TemplateSection>asList(
+         new TemplateSection(SectionType.STRING, "a"),
+         new TemplateSection(SectionType.EXPR, "b"),
+         new TemplateSection(SectionType.STRING, "c")
+         ), parser.parse("a<%=b%>c"));
+   }
+
+   public void testWindowsLineBreak() throws IOException
+   {
+
+   }
+
+   public void testPosition() throws IOException
+   {
+      List<TemplateSection> sections = parser.parse("a\nb<%= foo %>d");
+      assertEquals(new Position(1, 1), sections.get(0).getItems().get(0).getPosition());
+      assertEquals(new Position(2, 1), sections.get(0).getItems().get(1).getPosition());
+      assertEquals(new Position(1, 2), sections.get(0).getItems().get(2).getPosition());
+      assertEquals(new Position(5, 2), sections.get(1).getItems().get(0).getPosition());
+      assertEquals(new Position(12, 2), sections.get(2).getItems().get(0).getPosition());
+
+   }
+}

Deleted: portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java
===================================================================
--- portal/trunk/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) 2003-2007 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.groovyscript;
-
-import junit.framework.TestCase;
-import org.exoplatform.commons.utils.CharsetTextEncoder;
-import org.exoplatform.commons.utils.OutputStreamPrinter;
-
-import java.awt.*;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.EmptyStackException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestTemplateRendering extends TestCase
-{
-
-   public void testOutputStreamWriter() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("a<%='b'%>c<%out.print('d');%>e");
-      ByteArrayOutputStream  baos = new ByteArrayOutputStream();
-      OutputStreamPrinter writer = new OutputStreamPrinter(CharsetTextEncoder.getUTF8(), baos);
-      template.render(writer);
-      writer.close();
-      assertEquals("abcde", baos.toString("UTF-8"));
-   }
-
-   public void testFoo() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("a");
-      String render = template.render();
-      assertEquals("a", render);
-   }
-
-   public void testBar() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("<%='a'%>");
-      String render = template.render();
-      assertEquals("a", render);
-   }
-
-   public void testFooBar() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("a<%='b'%>c");
-      String render = template.render();
-      assertEquals("abc", render);
-   }
-
-   public void testJuu() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("<% out.print(\"a\"); %>");
-      String render = template.render();
-      assertEquals("a", render);
-   }
-
-   public void testLineBreak() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("\n");
-      String render = template.render();
-      assertEquals("\n", render);
-   }
-
-   public void testMultiLine() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate(
-         "a\n" +
-         "b\n" +
-         "<%= 'c' %>\n" +
-         "d"
-      );
-      String render = template.render();
-      assertEquals("a\nb\nc\nd", render);
-   }
-
-   public void testIf() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate(
-         "a\n" +
-         "<% if (true) {\n %>" +
-         "b\n" +
-         "<% } %>");
-      String s = template.render();
-      assertEquals("a\nb\n", s);
-   }
-
-   public void testLineComment() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("<% // foo %>a\nb");
-      String s = template.render();
-      assertEquals("a\nb", s);
-   }
-
-   public void testContextResolution() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("<%= foo %>");
-      Map<String, String> context = new HashMap<String, String>();
-      context.put("foo", "bar");
-      String s = template.render(context);
-      assertEquals("bar", s);
-   }
-
-   public void testGString() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("$foo");
-      Map<String, String> context = new HashMap<String, String>();
-      context.put("foo", "bar");
-      String s = template.render(context);
-      assertEquals("bar", s);
-   }
-
-   public void testGString2() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("$foo\"");
-      Map<String, String> context = new HashMap<String, String>();
-      context.put("foo", "bar");
-      String s = template.render(context);
-      assertEquals("bar\"", s);
-   }
-
-   public void testQuote() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("\"");
-      String s = template.render();
-      assertEquals("\"", s);
-   }
-
-   public void testFooFoo() throws Exception
-   {
-      InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("UIPortalApplication.gtmpl");
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      byte[] buffer = new byte[256];
-      for (int l = in.read(buffer);l != -1;l = in.read(buffer))
-      {
-         baos.write(buffer, 0, l);
-      }
-      String gtmpl = baos.toString("UTF-8");
-      GroovyTemplate template = new GroovyTemplate(gtmpl);
-   }
-
-   public void testException() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("<% throw new java.awt.AWTException(); %>");
-      try
-      {
-         template.render();
-         fail();
-      }
-      catch (TemplateRuntimeException e)
-      {
-         assertTrue(e.getCause() instanceof AWTException);
-      }
-   }
-
-   public void testRuntimeException() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("<% throw new java.util.EmptyStackException(); %>");
-      try
-      {
-         template.render();
-         fail();
-      }
-      catch (TemplateRuntimeException e)
-      {
-         assertTrue(e.getCause() instanceof EmptyStackException);
-      }
-   }
-
-   public void testIOException() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("<% throw new java.io.IOException(); %>");
-      try
-      {
-         template.render();
-         fail();
-      }
-      catch (IOException e)
-      {
-      }
-   }
-
-   public void testError() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("<% throw new java.awt.AWTError(); %>");
-      try
-      {
-         template.render();
-         fail();
-      }
-      catch (AWTError e)
-      {
-      }
-   }
-
-   public void testThrowable() throws Exception
-   {
-      GroovyTemplate template = new GroovyTemplate("<% throw new Throwable(); %>");
-      try
-      {
-         template.render();
-         fail();
-      }
-      catch (Throwable t)
-      {
-      }
-   }
-
-   public void testScriptLineNumber() throws Exception
-   {
-      testLineNumber("<%");
-      assertLineNumber(2, "throw new Exception('e')", "<%\nthrow new Exception('e')%>");
-   }
-
-   public void testExpressionLineNumber() throws Exception
-   {
-      testLineNumber("<%=");
-   }
-
-   private void testLineNumber(String prolog) throws Exception
-   {
-      assertLineNumber(1, "throw new Exception('a')", prolog + "throw new Exception('a')%>");
-      assertLineNumber(1, "throw new Exception('b')", "foo" + prolog + "throw new Exception('b')%>");
-      assertLineNumber(2, "throw new Exception('c')", "foo\n" + prolog + "throw new Exception('c')%>");
-      assertLineNumber(1, "throw new Exception('d')", "<%;%>foo" + prolog + "throw new Exception('d')%>");
-   }
-
-   private void assertLineNumber(int expectedLineNumber, String expectedText, String script) throws TemplateCompilationException, IOException
-   {
-      GroovyTemplate template = new GroovyTemplate(script);
-      try
-      {
-         template.render();
-         fail();
-      }
-      catch (TemplateRuntimeException t)
-      {
-         assertEquals(expectedText, t.getText());
-         assertEquals(expectedLineNumber, (Object)t.getLineNumber());
-         StackTraceElement scriptElt = null;
-         for (StackTraceElement elt : t.getCause().getStackTrace())
-         {
-            if (elt.getClassName().equals(template.getClassName()))
-            {
-               scriptElt = elt;
-               break;
-            }
-         }
-         assertEquals(expectedLineNumber, scriptElt.getLineNumber());
-      }
-   }
-
-}

Copied: portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java (from rev 480, portal/trunk/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,271 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.groovyscript;
+
+import junit.framework.TestCase;
+import org.exoplatform.commons.utils.CharsetTextEncoder;
+import org.exoplatform.commons.utils.OutputStreamPrinter;
+
+import java.awt.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.EmptyStackException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestTemplateRendering extends TestCase
+{
+
+   public void testOutputStreamWriter() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("a<%='b'%>c<%out.print('d');%>e");
+      ByteArrayOutputStream  baos = new ByteArrayOutputStream();
+      OutputStreamPrinter writer = new OutputStreamPrinter(CharsetTextEncoder.getUTF8(), baos);
+      template.render(writer);
+      writer.close();
+      assertEquals("abcde", baos.toString("UTF-8"));
+   }
+
+   public void testFoo() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("a");
+      String render = template.render();
+      assertEquals("a", render);
+   }
+
+   public void testBar() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("<%='a'%>");
+      String render = template.render();
+      assertEquals("a", render);
+   }
+
+   public void testFooBar() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("a<%='b'%>c");
+      String render = template.render();
+      assertEquals("abc", render);
+   }
+
+   public void testJuu() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("<% out.print(\"a\"); %>");
+      String render = template.render();
+      assertEquals("a", render);
+   }
+
+   public void testLineBreak() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("\n");
+      String render = template.render();
+      assertEquals("\n", render);
+   }
+
+   public void testMultiLine() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate(
+         "a\n" +
+         "b\n" +
+         "<%= 'c' %>\n" +
+         "d"
+      );
+      String render = template.render();
+      assertEquals("a\nb\nc\nd", render);
+   }
+
+   public void testIf() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate(
+         "a\n" +
+         "<% if (true) {\n %>" +
+         "b\n" +
+         "<% } %>");
+      String s = template.render();
+      assertEquals("a\nb\n", s);
+   }
+
+   public void testLineComment() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("<% // foo %>a\nb");
+      String s = template.render();
+      assertEquals("a\nb", s);
+   }
+
+   public void testContextResolution() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("<%= foo %>");
+      Map<String, String> context = new HashMap<String, String>();
+      context.put("foo", "bar");
+      String s = template.render(context);
+      assertEquals("bar", s);
+   }
+
+   public void testGString() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("$foo");
+      Map<String, String> context = new HashMap<String, String>();
+      context.put("foo", "bar");
+      String s = template.render(context);
+      assertEquals("bar", s);
+   }
+
+   public void testGString2() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("$foo\"");
+      Map<String, String> context = new HashMap<String, String>();
+      context.put("foo", "bar");
+      String s = template.render(context);
+      assertEquals("bar\"", s);
+   }
+
+   public void testQuote() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("\"");
+      String s = template.render();
+      assertEquals("\"", s);
+   }
+
+   public void testFooFoo() throws Exception
+   {
+      InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("UIPortalApplication.gtmpl");
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      byte[] buffer = new byte[256];
+      for (int l = in.read(buffer);l != -1;l = in.read(buffer))
+      {
+         baos.write(buffer, 0, l);
+      }
+      String gtmpl = baos.toString("UTF-8");
+      GroovyTemplate template = new GroovyTemplate(gtmpl);
+   }
+
+   public void testException() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("<% throw new java.awt.AWTException(); %>");
+      try
+      {
+         template.render();
+         fail();
+      }
+      catch (TemplateRuntimeException e)
+      {
+         assertTrue(e.getCause() instanceof AWTException);
+      }
+   }
+
+   public void testRuntimeException() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("<% throw new java.util.EmptyStackException(); %>");
+      try
+      {
+         template.render();
+         fail();
+      }
+      catch (TemplateRuntimeException e)
+      {
+         assertTrue(e.getCause() instanceof EmptyStackException);
+      }
+   }
+
+   public void testIOException() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("<% throw new java.io.IOException(); %>");
+      try
+      {
+         template.render();
+         fail();
+      }
+      catch (IOException e)
+      {
+      }
+   }
+
+   public void testError() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("<% throw new java.awt.AWTError(); %>");
+      try
+      {
+         template.render();
+         fail();
+      }
+      catch (AWTError e)
+      {
+      }
+   }
+
+   public void testThrowable() throws Exception
+   {
+      GroovyTemplate template = new GroovyTemplate("<% throw new Throwable(); %>");
+      try
+      {
+         template.render();
+         fail();
+      }
+      catch (Throwable t)
+      {
+      }
+   }
+
+   public void testScriptLineNumber() throws Exception
+   {
+      testLineNumber("<%");
+      assertLineNumber(2, "throw new Exception('e')", "<%\nthrow new Exception('e')%>");
+   }
+
+   public void testExpressionLineNumber() throws Exception
+   {
+      testLineNumber("<%=");
+   }
+
+   private void testLineNumber(String prolog) throws Exception
+   {
+      assertLineNumber(1, "throw new Exception('a')", prolog + "throw new Exception('a')%>");
+      assertLineNumber(1, "throw new Exception('b')", "foo" + prolog + "throw new Exception('b')%>");
+      assertLineNumber(2, "throw new Exception('c')", "foo\n" + prolog + "throw new Exception('c')%>");
+      assertLineNumber(1, "throw new Exception('d')", "<%;%>foo" + prolog + "throw new Exception('d')%>");
+   }
+
+   private void assertLineNumber(int expectedLineNumber, String expectedText, String script) throws TemplateCompilationException, IOException
+   {
+      GroovyTemplate template = new GroovyTemplate(script);
+      try
+      {
+         template.render();
+         fail();
+      }
+      catch (TemplateRuntimeException t)
+      {
+         assertEquals(expectedText, t.getText());
+         assertEquals(expectedLineNumber, (Object)t.getLineNumber());
+         StackTraceElement scriptElt = null;
+         for (StackTraceElement elt : t.getCause().getStackTrace())
+         {
+            if (elt.getClassName().equals(template.getClassName()))
+            {
+               scriptElt = elt;
+               break;
+            }
+         }
+         assertEquals(expectedLineNumber, scriptElt.getLineNumber());
+      }
+   }
+
+}

Copied: portal/branches/wsrp-integration/component/scripting/src/test/resources (from rev 480, portal/trunk/component/scripting/src/test/resources)

Deleted: portal/branches/wsrp-integration/component/scripting/src/test/resources/UIPortalApplication.gtmpl
===================================================================
--- portal/trunk/component/scripting/src/test/resources/UIPortalApplication.gtmpl	2009-11-03 15:40:51 UTC (rev 480)
+++ portal/branches/wsrp-integration/component/scripting/src/test/resources/UIPortalApplication.gtmpl	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,134 +0,0 @@
-<!DOCTYPE html 
-    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<%
-  def rcontext = _ctx.getRequestContext() ;
-  String docBase =  rcontext.getRequestContextPath() ;
-  String skin = uicomponent.getSkin();
-  def portalSkins = uicomponent.getPortalSkins() ;
-  def portletSkins = uicomponent.getPortletSkins() ;
-  def scriptsPaths = uicomponent.getJavascriptURLs();
-  def lang = uicomponent.getLocale().getLanguage();
-  def title = rcontext.getTitle();
-  def metaInformation = rcontext.getMetaInformation();
-%>
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$lang" lang="$lang" dir="$dir">
-  <head id="head">
-    <title><%=title%></title>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-    <%
-    	if(metaInformation!= null) {
-	    	Iterator<String> keys = metaInformation.keySet().iterator();
-	    	while(keys.hasNext()) {
-	    		String metaName = keys.next();
-	    		String metaContent = metaInformation.get(metaName);
-	  %>
-	   	<meta name="<%=metaName%>" content="<%=metaContent%>" />
-	  <% } } %>
-
-    <link rel="shortcut icon" type="image/x-icon"  href="<%=docBase%>/favicon.ico" />
-    <%for(skinConfig in portalSkins) {
-    def url = skinConfig.createURL();
-    url.setOrientation(orientation);
-    %>
-      <link id="${skinConfig.id}" rel="stylesheet" type="text/css" href="$url" />
-    <%}%>
-    <%for(portletSkin in portletSkins) {
-    def url = portletSkin.createURL();
-    url.setOrientation(orientation);
-    %>
-      <link id="${portletSkin.id}" rel="stylesheet" type="text/css" href= "$url" />
-    <%}%>
-     <script type="text/javascript">
-     // This variable must be used only to initialize other variables otherwise
-     // please use eXo.env.portal.context or eXo.env.portal.context instead
-     // Those 2 last variables cannot be used to initialize variables because
-     // we cannot be sure that they will be initialized before initializing your script
-      var currentContext = '<%=docBase%>' ;
-    </script>
-    <%if(org.exoplatform.commons.utils.PropertyManager.isDevelopping()) {
-        for(path in scriptsPaths) { %>
-          <script type="text/javascript" src="<%=path%>"></script>
-    <%  }
-      } else {
-    %>
-        <script type="text/javascript" src="<%=docBase%>/javascript/merged.js"></script>
-    <%}%>
-    <script type="text/javascript">
-      eXo.env.portal.context = '<%=docBase%>' ;
-      <%if(rcontext.getAccessPath() == 0) {%>
-          eXo.env.portal.accessMode = 'public' ;
-      <%} else {%>
-          eXo.env.portal.accessMode = 'private' ;
-      <%}%>
-      eXo.env.portal.portalName = '<%=rcontext.getPortalOwner()%>' ;
-      eXo.env.server.context = '<%=docBase%>' ;
-      eXo.env.server.portalBaseURL = '<%=rcontext.getURLBuilder().getBaseURL()%>' ;
-      eXo.env.client.skin = '$skin' ;
-      <%
-        String sessionAliveLevel = (portal == null ? null : portal.sessionAlive) ;
-        boolean canKeepState = sessionAliveLevel == null ? false : !sessionAliveLevel.equals(PortalProperties.SESSION_NEVER) ;
-      %>
-
-      eXo.portal.portalMode = <%= uicomponent.getModeState() %>;
-
-      eXo.session.level = '$sessionAliveLevel';
-      eXo.session.canKeepState = $canKeepState;
-      eXo.session.isOpen = $uicomponent.isSessionOpen ;
-      eXo.session.itvTime = ${(rcontext).getRequest().getSession().getMaxInactiveInterval()} ;
-    </script>
-    <script type="text/javascript" src="/eXoResources/javascript/eXo/i18n/I18NMessage.js"></script>
-    <script type="text/javascript" src="/eXoResources/javascript/eXo/i18n/MessageResource_<%=lang%>.js"></script>
-  </head>
-
-  <body style="height: 100%;">
-    <%
-      /*Hide All Popup Menu when click on document*/
-      rcontext.getJavascriptManager().addOnLoadJavascript('eXo.core.DOMUtil.hideElements');
-      //rcontext.getJavascriptManager().addOnResizeJavascript('eXo.core.UIMaskLayer.resizeMaskLayer');
-    %>
-
-	<div class="$uicomponent.skin" id="UIPortalApplication" style="!height: 100%;">
-
-		<div class="AjaxLoadingMask" id="AjaxLoadingMask" style="display: none; margin: auto;">
-      <div class="LoadingContainer">
-        <div class="CenterLoadingContainer">
-          <div class="LoadingText"><%=_ctx.appRes("UIPortalApplication.label.Loading")%></div>
-          <div class="LoadingProgressBar"><span></span></div>
-
-          <div class="UIAction">
-				    <table class="ActionContainer">
-					    <tr>
-					    	<td>
-						      <div onclick="javascript:ajaxAbort();" class="ActionButton LightBlueStyle">
-						        <div class="ButtonLeft">
-						          <div class="ButtonRight">
-						            <div class="ButtonMiddle">
-						              <a href="javascript:void(0);"><%=_ctx.appRes("UIPortalApplication.label.Abort")%></a>
-						            </div>
-						          </div>
-						        </div>
-						      </div>
-						    </td>
-				      </tr>
-				 	  </table>
-					</div>
-
-        </div>
-      </div>
-	  </div>
-
-	  <%uicomponent.renderChildren();%>
-	</div>
-
-
-
-    <script type="text/javascript">
-      <%=rcontext.getJavascriptManager().getJavascript()%>
-        eXo.core.Browser.onLoad();
-      <%=rcontext.getJavascriptManager().getCustomizedOnLoadScript();%>
-      <%if(canKeepState && uicomponent.isSessionOpen) {%> eXo.session.itvInit() ;<%}%>
-    </script>
-  </body>
-</html>

Copied: portal/branches/wsrp-integration/component/scripting/src/test/resources/UIPortalApplication.gtmpl (from rev 480, portal/trunk/component/scripting/src/test/resources/UIPortalApplication.gtmpl)
===================================================================
--- portal/branches/wsrp-integration/component/scripting/src/test/resources/UIPortalApplication.gtmpl	                        (rev 0)
+++ portal/branches/wsrp-integration/component/scripting/src/test/resources/UIPortalApplication.gtmpl	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,134 @@
+<!DOCTYPE html 
+    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<%
+  def rcontext = _ctx.getRequestContext() ;
+  String docBase =  rcontext.getRequestContextPath() ;
+  String skin = uicomponent.getSkin();
+  def portalSkins = uicomponent.getPortalSkins() ;
+  def portletSkins = uicomponent.getPortletSkins() ;
+  def scriptsPaths = uicomponent.getJavascriptURLs();
+  def lang = uicomponent.getLocale().getLanguage();
+  def title = rcontext.getTitle();
+  def metaInformation = rcontext.getMetaInformation();
+%>
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$lang" lang="$lang" dir="$dir">
+  <head id="head">
+    <title><%=title%></title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <%
+    	if(metaInformation!= null) {
+	    	Iterator<String> keys = metaInformation.keySet().iterator();
+	    	while(keys.hasNext()) {
+	    		String metaName = keys.next();
+	    		String metaContent = metaInformation.get(metaName);
+	  %>
+	   	<meta name="<%=metaName%>" content="<%=metaContent%>" />
+	  <% } } %>
+
+    <link rel="shortcut icon" type="image/x-icon"  href="<%=docBase%>/favicon.ico" />
+    <%for(skinConfig in portalSkins) {
+    def url = skinConfig.createURL();
+    url.setOrientation(orientation);
+    %>
+      <link id="${skinConfig.id}" rel="stylesheet" type="text/css" href="$url" />
+    <%}%>
+    <%for(portletSkin in portletSkins) {
+    def url = portletSkin.createURL();
+    url.setOrientation(orientation);
+    %>
+      <link id="${portletSkin.id}" rel="stylesheet" type="text/css" href= "$url" />
+    <%}%>
+     <script type="text/javascript">
+     // This variable must be used only to initialize other variables otherwise
+     // please use eXo.env.portal.context or eXo.env.portal.context instead
+     // Those 2 last variables cannot be used to initialize variables because
+     // we cannot be sure that they will be initialized before initializing your script
+      var currentContext = '<%=docBase%>' ;
+    </script>
+    <%if(org.exoplatform.commons.utils.PropertyManager.isDevelopping()) {
+        for(path in scriptsPaths) { %>
+          <script type="text/javascript" src="<%=path%>"></script>
+    <%  }
+      } else {
+    %>
+        <script type="text/javascript" src="<%=docBase%>/javascript/merged.js"></script>
+    <%}%>
+    <script type="text/javascript">
+      eXo.env.portal.context = '<%=docBase%>' ;
+      <%if(rcontext.getAccessPath() == 0) {%>
+          eXo.env.portal.accessMode = 'public' ;
+      <%} else {%>
+          eXo.env.portal.accessMode = 'private' ;
+      <%}%>
+      eXo.env.portal.portalName = '<%=rcontext.getPortalOwner()%>' ;
+      eXo.env.server.context = '<%=docBase%>' ;
+      eXo.env.server.portalBaseURL = '<%=rcontext.getURLBuilder().getBaseURL()%>' ;
+      eXo.env.client.skin = '$skin' ;
+      <%
+        String sessionAliveLevel = (portal == null ? null : portal.sessionAlive) ;
+        boolean canKeepState = sessionAliveLevel == null ? false : !sessionAliveLevel.equals(PortalProperties.SESSION_NEVER) ;
+      %>
+
+      eXo.portal.portalMode = <%= uicomponent.getModeState() %>;
+
+      eXo.session.level = '$sessionAliveLevel';
+      eXo.session.canKeepState = $canKeepState;
+      eXo.session.isOpen = $uicomponent.isSessionOpen ;
+      eXo.session.itvTime = ${(rcontext).getRequest().getSession().getMaxInactiveInterval()} ;
+    </script>
+    <script type="text/javascript" src="/eXoResources/javascript/eXo/i18n/I18NMessage.js"></script>
+    <script type="text/javascript" src="/eXoResources/javascript/eXo/i18n/MessageResource_<%=lang%>.js"></script>
+  </head>
+
+  <body style="height: 100%;">
+    <%
+      /*Hide All Popup Menu when click on document*/
+      rcontext.getJavascriptManager().addOnLoadJavascript('eXo.core.DOMUtil.hideElements');
+      //rcontext.getJavascriptManager().addOnResizeJavascript('eXo.core.UIMaskLayer.resizeMaskLayer');
+    %>
+
+	<div class="$uicomponent.skin" id="UIPortalApplication" style="!height: 100%;">
+
+		<div class="AjaxLoadingMask" id="AjaxLoadingMask" style="display: none; margin: auto;">
+      <div class="LoadingContainer">
+        <div class="CenterLoadingContainer">
+          <div class="LoadingText"><%=_ctx.appRes("UIPortalApplication.label.Loading")%></div>
+          <div class="LoadingProgressBar"><span></span></div>
+
+          <div class="UIAction">
+				    <table class="ActionContainer">
+					    <tr>
+					    	<td>
+						      <div onclick="javascript:ajaxAbort();" class="ActionButton LightBlueStyle">
+						        <div class="ButtonLeft">
+						          <div class="ButtonRight">
+						            <div class="ButtonMiddle">
+						              <a href="javascript:void(0);"><%=_ctx.appRes("UIPortalApplication.label.Abort")%></a>
+						            </div>
+						          </div>
+						        </div>
+						      </div>
+						    </td>
+				      </tr>
+				 	  </table>
+					</div>
+
+        </div>
+      </div>
+	  </div>
+
+	  <%uicomponent.renderChildren();%>
+	</div>
+
+
+
+    <script type="text/javascript">
+      <%=rcontext.getJavascriptManager().getJavascript()%>
+        eXo.core.Browser.onLoad();
+      <%=rcontext.getJavascriptManager().getCustomizedOnLoadScript();%>
+      <%if(canKeepState && uicomponent.isSessionOpen) {%> eXo.session.itvInit() ;<%}%>
+    </script>
+  </body>
+</html>

Copied: portal/branches/wsrp-integration/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigParser.java (from rev 480, portal/trunk/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigParser.java)
===================================================================
--- portal/branches/wsrp-integration/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigParser.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigParser.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,100 @@
+/*
+ * 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.web.application.javascript;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import javax.servlet.ServletContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
+ * @version $Id$
+ *
+ */
+public class JavascriptConfigParser
+{
+
+   public static void processConfigResource(InputStream is, JavascriptConfigService service, ServletContext scontext){
+      List<JavascriptTask> tasks = fetchTasks(is);
+      if(tasks != null){
+         for(JavascriptTask task : tasks){
+            task.execute(service, scontext);
+         }
+      }
+   }
+   
+   private static List<JavascriptTask> fetchTasks(InputStream is)
+   {
+      try
+      {
+         DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+         Document document = docBuilder.parse(is);
+         return fetchTasksFromXMLConfig(document);
+      }
+      catch (Exception ex)
+      {
+         return null;
+      }
+   }
+   
+   private static List<JavascriptTask> fetchTasksFromXMLConfig(Document document){
+      List<JavascriptTask> tasks = new ArrayList<JavascriptTask>();
+      Element element = document.getDocumentElement();
+      //NodeList nodes = element.getElementsByTagName(GateinResource.JAVA_SCRIPT_TAG);
+      NodeList nodes = element.getElementsByTagName("javascript");
+      int length = nodes.getLength();
+      for(int i = 0; i < length; i++){
+         JavascriptTask task = xmlToTask((Element)nodes.item(i));
+         if(task != null){
+            tasks.add(task);
+         }
+      }
+      return tasks;
+   }
+   
+   private static JavascriptTask xmlToTask(Element element){
+      //if(!GateinResource.JAVA_SCRIPT_TAG.equals(element.getTagName())){
+      if(!"javascript".equals(element.getTagName())){
+         return null;
+      }
+      try{
+         JavascriptTask task = new JavascriptTask();
+         //NodeList nodes = element.getElementsByTagName(GateinResource.JAVA_SCRIPT_PARAM);
+         NodeList nodes = element.getElementsByTagName("param");
+         int length = nodes.getLength();
+         for(int i = 0; i < length ; i++){
+            Element param_ele = (Element)nodes.item(i);
+            String js_module = param_ele.getElementsByTagName("js-module").item(0).getFirstChild().getNodeValue();
+            String js_path = param_ele.getElementsByTagName("js-path").item(0).getFirstChild().getNodeValue();
+            task.addParam(js_module, js_path);
+         }
+         return task;
+      }catch(Exception ex){
+         ex.printStackTrace();
+         return null;
+      }
+   }   
+}

Copied: portal/branches/wsrp-integration/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptTask.java (from rev 480, portal/trunk/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptTask.java)
===================================================================
--- portal/branches/wsrp-integration/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptTask.java	                        (rev 0)
+++ portal/branches/wsrp-integration/component/web/src/main/java/org/exoplatform/web/application/javascript/JavascriptTask.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -0,0 +1,60 @@
+/*
+ * 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.web.application.javascript;
+
+import javax.servlet.ServletContext;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
+ * @version $Id$
+ *
+ */
+public class JavascriptTask
+{
+   
+   private List<Parameter> parameters;
+   
+   public JavascriptTask(){
+      parameters = new ArrayList<Parameter>();
+   }
+   
+   public void execute(JavascriptConfigService service, ServletContext scontext){
+      for(Parameter param : parameters){
+         service.addJavascript(param.moduleName, param.scriptPath, scontext);
+      }
+   }
+   
+   public void addParam(String moduleName, String scriptPath){
+      parameters.add(new Parameter(moduleName, scriptPath));
+   }
+   
+   private class Parameter {
+      
+      private String moduleName;
+      private String scriptPath;
+      
+      Parameter(String _moduleName, String _scriptPath){
+         moduleName = _moduleName;
+         scriptPath = _scriptPath;
+      }     
+   }
+}

Modified: portal/branches/wsrp-integration/packaging/module/src/main/javascript/portal.packaging.module.js
===================================================================
--- portal/branches/wsrp-integration/packaging/module/src/main/javascript/portal.packaging.module.js	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/packaging/module/src/main/javascript/portal.packaging.module.js	2009-11-04 20:32:31 UTC (rev 493)
@@ -90,7 +90,7 @@
    new Project("org.exoplatform.portal", "exo.portal.component.scripting", "jar", module.version).
       addDependency(module.component.xmlParser).
       addDependency(new Project("rhino", "js", "jar", "1.6R5")).
-      addDependency(new Project("org.codehaus.groovy", "groovy-all", "jar", "1.5.7"));
+      addDependency(new Project("org.codehaus.groovy", "groovy-all", "jar", "1.6.5"));
 
    module.component.web =
    new Project("org.exoplatform.portal", "exo.portal.component.web", "jar", module.version).

Modified: portal/branches/wsrp-integration/pom.xml
===================================================================
--- portal/branches/wsrp-integration/pom.xml	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/pom.xml	2009-11-04 20:32:31 UTC (rev 493)
@@ -49,7 +49,7 @@
       <org.jboss.identity.idm>1.0.0.Beta3</org.jboss.identity.idm>
       <org.gatein.wsrp.version>1.0.0-Beta01</org.gatein.wsrp.version>
       <org.gatein.mop.version>1.0.0-Beta09</org.gatein.mop.version>
-      <version.chromattic>1.0.0-beta5</version.chromattic>
+      <version.chromattic>1.0.0-beta6</version.chromattic>
       <version.reflect>1.0.0-beta3</version.reflect>
    
       <!-- ************** -->
@@ -125,10 +125,8 @@
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
-                  <skip>${exo.test.skip}</skip>
-                  <forkMode>pertest</forkMode>
+                  <forkMode>once</forkMode>
                   <!--once , pertest -->
-                  <testFailureIgnore>${exo.test.failure.ignore}</testFailureIgnore>
                   <includes>
                      <include>**/${exo.test.includes}.java</include>
                   </includes>

Modified: portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
===================================================================
--- portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -22,11 +22,9 @@
 import org.exoplatform.commons.utils.ObjectPageList;
 import org.exoplatform.portal.application.PortalRequestContext;
 import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.Query;
 import org.exoplatform.portal.config.UserACL;
 import org.exoplatform.portal.config.UserPortalConfigService;
 import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PortalConfig;
 import org.exoplatform.portal.webui.navigation.UIAddGroupNavigation;
 import org.exoplatform.portal.webui.navigation.UINavigationManagement;
 import org.exoplatform.portal.webui.navigation.UINavigationNodeSelector;
@@ -54,7 +52,6 @@
 import org.exoplatform.webui.event.EventListener;
 
 import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.List;
 import java.util.UUID;
 
@@ -96,26 +93,8 @@
 
    public void loadNavigations() throws Exception
    {
-      navigations = new ArrayList<PageNavigation>();
-      UserACL userACL = getApplicationComponent(UserACL.class);
-      DataStorage dataStorage = getApplicationComponent(DataStorage.class);
-      // load all navigation that user has edit permission
-      Query<PageNavigation> query = new Query<PageNavigation>(PortalConfig.GROUP_TYPE, null, PageNavigation.class);
-      List<PageNavigation> navis = dataStorage.find(query, new Comparator<PageNavigation>()
-      {
-         public int compare(PageNavigation pconfig1, PageNavigation pconfig2)
-         {
-            return pconfig1.getOwnerId().compareTo(pconfig2.getOwnerId());
-         }
-      }).getAll();
-      for (PageNavigation ele : navis)
-      {
-         if (userACL.hasEditPermission(ele))
-         {
-            navigations.add(ele);
-         }
-      }
-
+      UserPortalConfigService userPortalConfigService = getApplicationComponent(UserPortalConfigService.class);
+      navigations = userPortalConfigService.loadEditableNavigations();
       UIVirtualList virtualList = getChild(UIVirtualList.class);
       virtualList.dataBind(new ObjectPageList<PageNavigation>(navigations, navigations.size()));
    }

Modified: portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
===================================================================
--- portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,10 +19,7 @@
 
 package org.exoplatform.toolbar.webui.component;
 
-import org.exoplatform.commons.utils.PageList;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.Query;
-import org.exoplatform.portal.config.UserACL;
+import org.exoplatform.portal.config.UserPortalConfigService;
 import org.exoplatform.portal.config.model.PageNavigation;
 import org.exoplatform.portal.config.model.PageNode;
 import org.exoplatform.portal.config.model.PortalConfig;
@@ -32,7 +29,6 @@
 import org.exoplatform.webui.core.UIPortletApplication;
 import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -53,20 +49,8 @@
 
    public List<String> getAllPortalNames() throws Exception
    {
-      List<String> list = new ArrayList<String>();
-      DataStorage dataStorage = getApplicationComponent(DataStorage.class);
-      Query<PortalConfig> query = new Query<PortalConfig>(null, null, null, null, PortalConfig.class);
-      PageList pageList = dataStorage.find(query);
-      UserACL userACL = getApplicationComponent(UserACL.class);
-      List<PortalConfig> configs = pageList.getAll();
-      for (PortalConfig ele : configs)
-      {
-         if (userACL.hasPermission(ele))
-         {
-            list.add(ele.getName());
-         }
-      }
-      return list;
+      UserPortalConfigService dataStorage = getApplicationComponent(UserPortalConfigService.class);
+      return dataStorage.getAllPortalNames();
    }
 
    public String getCurrentPortal()

Modified: portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/PortalNavigationPortlet_vi.xml
===================================================================
--- portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/PortalNavigationPortlet_vi.xml	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/PortalNavigationPortlet_vi.xml	2009-11-04 20:32:31 UTC (rev 493)
@@ -28,7 +28,7 @@
   	<label>
   		<editLayout>Edit Layout</editLayout>
   		<editNav>Edit Navigation</editNav>
-  		<editPortalProp>Edit Portal's Properties</editNavProp>
+  		<editPortalProp>Edit Portal's Properties</editPortalProp>
   		<deletePortal>Delete Portal</deletePortal>
   	</label>
   </UISiteManagement>

Modified: portal/branches/wsrp-integration/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java
===================================================================
--- portal/branches/wsrp-integration/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -28,26 +28,24 @@
 import org.exoplatform.webui.config.annotation.ComponentConfig;
 import org.exoplatform.webui.config.annotation.EventConfig;
 import org.exoplatform.webui.core.UIBreadcumbs;
-import org.exoplatform.webui.core.UIPortletApplication;
 import org.exoplatform.webui.core.UIBreadcumbs.LocalPath;
-import org.exoplatform.webui.core.UIBreadcumbs.SelectPathActionListener;
+import org.exoplatform.webui.core.UIPortletApplication;
 import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
 import org.exoplatform.webui.event.Event;
 import org.exoplatform.webui.event.EventListener;
 
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.portlet.PortletPreferences;
-import javax.portlet.PortletRequest;
-
 /**
  * Author : Nhu Dinh Thuan
  *          nhudinhthuan at yahoo.com
  * May 30, 2006
  * @version:: $Id$
  */
- at ComponentConfig(lifecycle = UIApplicationLifecycle.class, events = @EventConfig(listeners = SelectPathActionListener.class))
+ at ComponentConfig(lifecycle = UIApplicationLifecycle.class, events = @EventConfig(listeners = UIBreadcumbsPortlet.SelectPathActionListener.class))
 public class UIBreadcumbsPortlet extends UIPortletApplication
 {
 

Modified: portal/branches/wsrp-integration/web/eXoResources/src/main/webapp/WEB-INF/gatein-resources.xml
===================================================================
--- portal/branches/wsrp-integration/web/eXoResources/src/main/webapp/WEB-INF/gatein-resources.xml	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/web/eXoResources/src/main/webapp/WEB-INF/gatein-resources.xml	2009-11-04 20:32:31 UTC (rev 493)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
 
     Copyright (C) 2009 eXo Platform SAS.
@@ -19,12 +19,8 @@
     02110-1301 USA, or see the FSF site: http://www.fsf.org.
 
 -->
+<gatein-resources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_resources_1_0.xsd" xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_0.xsd">
 
-<gatein-resources
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-   	xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_resources_1_0.xsd"
-   	xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_0.xsd">
-
 	<portal-skin>
 		<skin-name>Default</skin-name>
 		<css-path>/skin/Stylesheet.css</css-path>
@@ -112,4 +108,205 @@
 		</style-theme>
 	</window-style>
 	
-</gatein-resources>
+	<javascript>
+		<param>
+			<js-module>eXo</js-module>
+			<js-path>/javascript/eXo.js</js-path>
+		</param>
+	</javascript>
+
+	<!-- CORE Javascripts -->
+	<javascript>
+		<param>
+			<js-module>eXo.core.Utils</js-module>
+			<js-path>/javascript/eXo/core/Util.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.DOMUtil</js-module>
+			<js-path>/javascript/eXo/core/DOMUtil.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.Browser</js-module>
+			<js-path>/javascript/eXo/core/Browser.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.MouseEventManager</js-module>
+			<js-path>/javascript/eXo/core/MouseEventManager.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.UIMaskLayer</js-module>
+			<js-path>/javascript/eXo/core/UIMaskLayer.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.Skin</js-module>
+			<js-path>/javascript/eXo/core/Skin.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.DragDrop</js-module>
+			<js-path>/javascript/eXo/core/DragDrop.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.DragDrop2</js-module>
+			<js-path>/javascript/eXo/core/DragDrop2.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.Topic</js-module>
+			<js-path>/javascript/eXo/core/Topic.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.JSON</js-module>
+			<js-path>/javascript/eXo/core/JSON.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.Cometd</js-module>
+			<js-path>/javascript/eXo/core/Cometd.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.Spliter</js-module>
+			<js-path>/javascript/eXo/core/Spliter.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.Notification</js-module>
+			<js-path>/javascript/eXo/core/Notification.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.Loader</js-module>
+			<js-path>/javascript/eXo/core/Loader.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.core.I18n</js-module>
+			<js-path>/javascript/eXo/core/I18n.js</js-path>
+		</param>
+	</javascript>
+
+	<!-- Gadget Javascripts -->
+	<javascript>
+		<param>
+			<js-module>eXo.gadget.UIGadget</js-module>
+			<js-path>/javascript/eXo/gadget/UIGadget.js</js-path>
+		</param>
+	</javascript>
+
+	<!-- WebUI Javascripts -->
+	<javascript> 
+		<param>
+			<js-module>eXo.webui.UIItemSelector</js-module>
+			<js-path>/javascript/eXo/webui/UIItemSelector.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIForm</js-module>
+			<js-path>/javascript/eXo/webui/UIForm.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIPopup</js-module>
+			<js-path>/javascript/eXo/webui/UIPopup.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIPopupSelectCategory</js-module>
+			<js-path>/javascript/eXo/webui/UIPopupSelectCategory.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIPopupWindow</js-module>
+			<js-path>/javascript/eXo/webui/UIPopupWindow.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIHorizontalTabs</js-module>
+			<js-path>/javascript/eXo/webui/UIHorizontalTabs.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIPopupMenu</js-module>
+			<js-path>/javascript/eXo/webui/UIPopupMenu.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIDropDownControl</js-module>
+			<js-path>/javascript/eXo/webui/UIDropDownControl.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIRightClickPopupMenu</js-module>
+			<js-path>/javascript/eXo/webui/UIRightClickPopupMenu.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIVerticalSlideTabs</js-module>
+			<js-path>/javascript/eXo/webui/UIVerticalSlideTabs.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIPermissionSelectorTab</js-module>
+			<js-path>/javascript/eXo/webui/UIPermissionSelectorTab.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIDashboard</js-module>
+			<js-path>/javascript/eXo/webui/UIDashboard.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIDashboardUtil</js-module>
+			<js-path>/javascript/eXo/webui/UIDashboardUtil.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UINotification</js-module>
+			<js-path>/javascript/eXo/webui/UINotification.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIUserSelector</js-module>
+			<js-path>/javascript/eXo/webui/UIUserSelector.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UICombobox</js-module>
+			<js-path>/javascript/eXo/webui/UICombobox.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UICombobox</js-module>
+			<js-path>/javascript/eXo/webui/UIVirtualList.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.webui.UIColorPicker</js-module>
+			<js-path>/javascript/eXo/webui/UIColorPicker.js</js-path>
+		</param>
+	</javascript>
+
+	<!-- Portal Javascripts -->
+	<javascript>
+		<param>
+			<js-module>eXo.portal.PortalHttpRequest</js-module>
+			<js-path>/javascript/eXo/portal/PortalHttpRequest.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.portal.UIPortal</js-module>
+			<js-path>/javascript/eXo/portal/UIPortal.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.portal.UIWorkspace</js-module>
+			<js-path>/javascript/eXo/portal/UIWorkspace.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.portal.UIPortalControl</js-module>
+			<js-path>/javascript/eXo/portal/UIPortalControl.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.portal.PortalDragDrop</js-module>
+			<js-path>/javascript/eXo/portal/PortalDragDrop.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.portal.UIPortalNavigation</js-module>
+			<js-path>/javascript/eXo/portal/UIPortalNavigation.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.portal.UIPortalNavigation2</js-module>
+			<js-path>/javascript/eXo/portal/UIPortalNavigation2.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.portal.UIMaskWorkspace</js-module>
+			<js-path>/javascript/eXo/portal/UIMaskWorkspace.js</js-path>
+		</param>
+		<param>
+			<js-module>eXo.portal.UIBrowseContent</js-module>
+			<js-path>/javascript/eXo/portal/UIBrowseContent.js</js-path>
+		</param>
+	</javascript>
+
+	<javascript>
+		<param>
+			<js-module>eXo.webui.UIPortlet</js-module>
+			<js-path>/javascript/eXo/webui/UIPortlet.js</js-path>
+		</param>
+	</javascript>
+</gatein-resources>
\ No newline at end of file

Modified: portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/classes/locale/navigation/group/organization/management/executive-board_en.properties
===================================================================
--- portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/classes/locale/navigation/group/organization/management/executive-board_en.properties	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/classes/locale/navigation/group/organization/management/executive-board_en.properties	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,4 +19,4 @@
 
 organization.title=Organization
 organization.newstaff=New Staff
-organization.management=Management
\ No newline at end of file
+organization.management=Users and groups management
\ No newline at end of file

Modified: portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/portal/group/platform/administrators/navigation.xml
===================================================================
--- portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/portal/group/platform/administrators/navigation.xml	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/portal/group/platform/administrators/navigation.xml	2009-11-04 20:32:31 UTC (rev 493)
@@ -35,7 +35,7 @@
 				<label>#{administration.application-registry}</label>
 				<page-reference>group::/platform/administrators::registry</page-reference>
 			</node>
-	    
+	    <!-- 
 	    <node>
 		    <uri>administration/newAccount</uri>
 		    <name>newAccount</name>
@@ -49,7 +49,8 @@
 		    <label>#{administration.community-management}</label>
 		    <page-reference>group::/platform/administrators::communityManagement</page-reference>
 	    </node>
-	    
+	     -->
+	     
 	    <node>
 		    <uri>administration/i18n</uri>
 		    <name>i18n</name>

Modified: portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
===================================================================
--- portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml	2009-11-04 20:32:31 UTC (rev 493)
@@ -25,21 +25,19 @@
    xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
    xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
 				  
-<!--
   <component>
-    <key>org.exoplatform.portal.config.DataStorage</key>
-    <type>org.exoplatform.portal.config.jcr.DataStorageImpl</type>     
+    <key>org.exoplatform.portal.pom.config.POMSessionManager</key>
+    <type>org.exoplatform.portal.pom.config.POMSessionManager</type>
   </component>
--->
 
   <component>
-    <key>org.exoplatform.portal.pom.config.POMSessionManager</key>
-    <type>org.exoplatform.portal.pom.config.POMSessionManager</type>
+    <key>org.exoplatform.portal.pom.data.ModelDataStorage</key>
+    <type>org.exoplatform.portal.pom.config.POMDataStorage</type>
   </component>
 
   <component>
     <key>org.exoplatform.portal.config.DataStorage</key>
-    <type>org.exoplatform.portal.pom.config.POMDataStorage</type>
+    <type>org.exoplatform.portal.config.DataStorageImpl</type>
   </component>
 
   <component>

Modified: portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/gatein-resources.xml
===================================================================
--- portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/gatein-resources.xml	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/gatein-resources.xml	2009-11-04 20:32:31 UTC (rev 493)
@@ -31,6 +31,12 @@
 		<skin-name>Default</skin-name>
 		<css-path>/templates/skin/webui/component/UIHomePagePortlet/DefaultStylesheet.css</css-path>
 	</portlet-skin>
-	
+	        <!-- External libraries -->
+	<javascript>
+		<param>
+			<js-module>FCKEditor</js-module>
+			<js-path>/fckeditor/fckeditor.js</js-path>
+		</param>
+	</javascript>
 </gatein-resources>
 

Modified: portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/gatein_resources_1_0.xsd
===================================================================
--- portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/gatein_resources_1_0.xsd	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/web/portal/src/main/webapp/WEB-INF/gatein_resources_1_0.xsd	2009-11-04 20:32:31 UTC (rev 493)
@@ -31,7 +31,7 @@
 				<xs:element name="portal-skin" type="portal-skin" />
 				<xs:element name="portlet-skin" type="portlet-skin" />
 				<xs:element name="window-style" type="window-style" />
-				<xs:element name="script" type="script" />
+				<xs:element name="javascript" type="javascript" />
 				<xs:element name="resource-bundle" type="resource-bundle" />
 			</xs:sequence>
 		</xs:complexType>
@@ -66,9 +66,19 @@
 		</xs:sequence>
 	</xs:complexType>
 	
-	<xs:complexType name="script">
+	<xs:complexType name="javascript">
+		<xs:sequence>
+			<xs:element name="param" type="xs:param" />
+		</xs:sequence>
 	</xs:complexType>
 	
+	<xs:complexType name="param">
+		<xs:sequence>
+			<xs:element name="js-module" type="xs:string" />
+			<xs:element name="js-path" type="xs:string" />
+		</xs:sequence>
+	</xs:complexType>
+	
 	<xs:complexType name="resource-bundle">
 	</xs:complexType>
 </xs:schema>
\ No newline at end of file

Modified: portal/branches/wsrp-integration/web/portal/src/main/webapp/groovy/portal/webui/page/UIWizardPageSelectLayoutForm.gtmpl
===================================================================
--- portal/branches/wsrp-integration/web/portal/src/main/webapp/groovy/portal/webui/page/UIWizardPageSelectLayoutForm.gtmpl	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/web/portal/src/main/webapp/groovy/portal/webui/page/UIWizardPageSelectLayoutForm.gtmpl	2009-11-04 20:32:31 UTC (rev 493)
@@ -9,7 +9,7 @@
 
 	def categories = uicomponent.getItemCategories();
 	UIForm form = uicomponent.getParent();
-	UIDropDownControl drop = form.getChild(UIDropDownControl.class);
+	UIDropDownControl drop = form.getChild(UIDropDownControl.class);
 %>
 <div class="UIItemSelector">
 	<div class="RightColumnStyle">
@@ -21,7 +21,20 @@
 				for(category in categories){
 					templates = category.getSelectItemOptions();
 					String display = "none";	
-					if(category.isSelected()) display = "block"; else templates.get(0).setSelected(true);	 
+					if(category.isSelected()) display = "block"; else 
+					{
+						boolean isSelected = false;
+						
+						for(template in templates) {
+							if(template.isSelected()) {
+								isSelected = true;
+								break;
+							}	
+						}
+						
+						if(!isSelected)
+							templates.get(0).setSelected(true);
+					}	 
 			%>
 					<div class="ItemList ItemListBackground"	style="display: $display;">
 						<%								

Modified: portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java
===================================================================
--- portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,8 @@
 
 package org.exoplatform.webui.application.portlet;
 
+import org.exoplatform.commons.utils.PortalPrinter;
+import org.exoplatform.commons.utils.Safe;
 import org.exoplatform.resolver.ApplicationResourceResolver;
 import org.exoplatform.resolver.PortletResourceResolver;
 import org.exoplatform.services.log.ExoLogger;
@@ -33,11 +35,6 @@
 import org.exoplatform.webui.event.Event;
 import org.exoplatform.webui.event.Event.Phase;
 
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.EventRequest;
@@ -48,6 +45,9 @@
 import javax.portlet.PortletResponse;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
 
 /**
  * May 26, 2006
@@ -245,6 +245,11 @@
       }
       finally
       {
+
+         // Close the writer
+         Safe.close(context.getWriter());
+
+         //
          try
          {
             for (ApplicationLifecycle<RequestContext> lifecycle : getApplicationLifecycle())
@@ -275,12 +280,12 @@
    {
       String attributeName = getApplicationId() + "$PortletRequest";
       PortletRequestContext context = (PortletRequestContext)parentAppRequestContext.getAttribute(attributeName);
-      Writer w = null;
+      PortalPrinter w = null;
       if (res instanceof RenderResponse)
       {
          RenderResponse renderRes = (RenderResponse)res;
          renderRes.setContentType("text/html; charset=UTF-8");
-         w = renderRes.getWriter();
+         w = new PortalPrinter(renderRes.getPortletOutputStream(), true, 0);
       }
       if (context != null)
       {

Modified: portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
===================================================================
--- portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,16 +19,12 @@
 
 package org.exoplatform.webui.application.portlet;
 
-import org.exoplatform.commons.utils.WriterPrinter;
 import org.exoplatform.services.resources.Orientation;
 import org.exoplatform.web.application.URLBuilder;
 import org.exoplatform.webui.application.WebuiApplication;
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.lifecycle.HtmlValidator;
 
-import java.io.Writer;
-
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletMode;
 import javax.portlet.PortletModeException;
@@ -36,6 +32,7 @@
 import javax.portlet.PortletResponse;
 import javax.portlet.RenderResponse;
 import javax.portlet.StateAwareResponse;
+import java.io.Writer;
 
 /**
  * The request context of a portlet
@@ -75,7 +72,8 @@
    {
       request_ = req;
       response_ = res;
-      writer_ = HtmlValidator.DEBUG_MODE ? new WriterPrinter(new HtmlValidator(writer)) : new WriterPrinter(writer);
+//      writer_ = HtmlValidator.DEBUG_MODE ? new WriterPrinter(new HtmlValidator(writer)) : new WriterPrinter(writer);
+      writer_ = writer;
       windowId_ = req.getWindowID();
    }
 

Modified: portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java
===================================================================
--- portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -30,8 +30,7 @@
 import org.exoplatform.webui.event.Event;
 
 /**
- * Created by The eXo Platform SAS
- * May 7, 2006
+ * Created by The eXo Platform SAS May 7, 2006
  */
 public class Lifecycle<E extends UIComponent>
 {
@@ -40,7 +39,8 @@
 
    private Decorator decorator_ = new Decorator();
 
-   //  public void init(UIComponent uicomponent, WebuiRequestContext context) throws Exception {}
+   // public void init(UIComponent uicomponent, WebuiRequestContext context)
+   // throws Exception {}
 
    public void processDecode(E uicomponent, WebuiRequestContext context) throws Exception
    {
@@ -57,14 +57,16 @@
    }
 
    /**
-    * That method is the most generic one for every UICOmponent that is bound to this Lifecycle object
-    * and the class that extends it withouyt overiding the method.
+    * That method is the most generic one for every UICOmponent that is bound to
+    * this Lifecycle object and the class that extends it withouyt overiding the
+    * method.
     * 
-    * According to the template type associated with the UI component (groovy or javascript one); the 
-    * template is rendered using either the method renderJSTemplate() or renderTemplate(). In the case
-    * of the use of a groovy template, a context object of type WebuiBindingContext is used to then 
-    * provide to the template all the necessary objects to render (WebuiBindingContext extends the Map
-    * class) 
+    * According to the template type associated with the UI component (groovy or
+    * javascript one); the template is rendered using either the method
+    * renderJSTemplate() or renderTemplate(). In the case of the use of a groovy
+    * template, a context object of type WebuiBindingContext is used to then
+    * provide to the template all the necessary objects to render
+    * (WebuiBindingContext extends the Map class)
     * 
     */
    public void processRender(E uicomponent, WebuiRequestContext context) throws Exception
@@ -77,18 +79,19 @@
       renderTemplate(template, bcontext);
    }
 
-   //  public void destroy(UIComponent uicomponent) throws Exception {}
+   // public void destroy(UIComponent uicomponent) throws Exception {}
 
    /**
     * The method allows to use Groovy templates to render the portal components.
     * 
-    * 1) Add a decorator object into the context
-    * 2) Get a reference of the TemplateService
-    * 3) If the system property "exo.product.developing" is set to true, the templates are not cached
-    * 4) If the writer used to render the output is of type HtmlValidator, which is the case in the
-    *    Portal environement, then it is also possible to validate the generated HTML (for debug purposes)
-    * 6) The template and the context are then merged using the method service.merge(groovyTemplate, bcontext)
-    *    to generate the HTML fragment  
+    * 1) Add a decorator object into the context 2) Get a reference of the
+    * TemplateService 3) If the system property "exo.product.developing" is set
+    * to true, the templates are not cached 4) If the writer used to render the
+    * output is of type HtmlValidator, which is the case in the Portal
+    * environement, then it is also possible to validate the generated HTML (for
+    * debug purposes) 6) The template and the context are then merged using the
+    * method service.merge(groovyTemplate, bcontext) to generate the HTML
+    * fragment
     * 
     */
    protected void renderTemplate(String template, WebuiBindingContext bcontext) throws Exception
@@ -127,9 +130,9 @@
             validator.endComponent();
          }
       }
-      catch (Exception e)
+      catch (NullPointerException e)
       {
-         log.error("template : " + template, e);
+         log.error("Template: " + template + " not found");
       }
    }
 }
\ No newline at end of file

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -20,11 +20,7 @@
 package org.exoplatform.portal.application;
 
 import org.exoplatform.Constants;
-import org.exoplatform.commons.utils.CharsetCharEncoder;
-import org.exoplatform.commons.utils.CharsetTextEncoder;
 import org.exoplatform.commons.utils.PortalPrinter;
-import org.exoplatform.commons.utils.TableCharEncoder;
-import org.exoplatform.commons.utils.TextEncoder;
 import org.exoplatform.commons.utils.WriterPrinter;
 import org.exoplatform.portal.webui.portal.UIPortal;
 import org.exoplatform.portal.webui.util.Util;
@@ -275,19 +271,13 @@
       return request_.isUserInRole(roleUser);
    }
 
-   /** The optimized encoder. */
-   private static final TextEncoder encoder =
-      new CharsetTextEncoder(new TableCharEncoder(CharsetCharEncoder.getUTF8()));
-
    final public Writer getWriter() throws Exception
    {
       if (writer_ == null)
       {
+         PortalPrinter printer = new PortalPrinter(response_.getOutputStream(), true, 30000);
 
          //
-         PortalPrinter printer = new PortalPrinter(encoder, response_.getOutputStream());
-
-         //
          if (HtmlValidator.DEBUG_MODE)
          {
             writer_ = new WriterPrinter(new HtmlValidator(printer));

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,6 +19,7 @@
 
 package org.exoplatform.portal.application;
 
+import org.exoplatform.commons.utils.Safe;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
 import org.exoplatform.web.WebAppController;
@@ -27,10 +28,9 @@
 import org.exoplatform.webui.application.WebuiRequestContext;
 import org.exoplatform.webui.core.UIApplication;
 
-import java.util.List;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * Created by The eXo Platform SAS
@@ -112,6 +112,11 @@
       }
       finally
       {
+
+         // We close the writer here once and for all
+         Safe.close(context.getWriter());
+
+         //
          try
          {
             for (ApplicationLifecycle lifecycle : lifecycles)

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -22,6 +22,7 @@
 import org.exoplatform.Constants;
 import org.exoplatform.container.ExoContainer;
 import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.application.UserProfileLifecycle;
 import org.exoplatform.portal.config.model.ApplicationType;
 import org.exoplatform.portal.config.model.portlet.PortletId;
 import org.exoplatform.portal.pom.spi.portlet.Preferences;
@@ -663,12 +664,9 @@
       //
       StatefulPortletContext<C> preferencesPortletContext = getPortletContext();
 
-      // todo : wire user profile
-      // Create an ExoUserContext in component.pc package
-      OrganizationService service = getApplicationComponent(OrganizationService.class);
-      UIPortalApplication uiPortalApp = getAncestorOfType(UIPortalApplication.class);
-      UserProfile userProfile = service.getUserProfileHandler().findUserProfileByName(uiPortalApp.getOwner());
-
+      // get the user profile cached in the prc during the start of the request
+      UserProfile userProfile = (UserProfile) prc.getAttribute(UserProfileLifecycle.USER_PROFILE_ATTRIBUTE_NAME);
+      
       // client context
       AbstractClientContext clientContext;
       Cookie[] cookies = servletRequest.getCookies();

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -620,14 +620,16 @@
     */
    static public void setupPublicRenderParams(UIPortlet uiPortlet, Map<String, String[]> requestParams)
    {
-      UIPortal uiPortal = Util.getUIPortal();
-      Map<String, String[]> publicParams = uiPortal.getPublicParameters();
-
-      for (String key : requestParams.keySet())
+      if (requestParams != null && !requestParams.isEmpty())
       {
-         if (uiPortlet.supportsPublicParam(key))
+         UIPortal uiPortal = Util.getUIPortal();
+         Map<String, String[]> publicParams = uiPortal.getPublicParameters();
+         for (String key : requestParams.keySet())
          {
-            publicParams.put(key, requestParams.get(key));
+            if (uiPortlet.supportsPublicParam(key))
+            {
+               publicParams.put(key, requestParams.get(key));
+            }
          }
       }
 

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -41,12 +41,12 @@
 import org.gatein.pc.api.invocation.response.FragmentResponse;
 import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
 
+import javax.portlet.WindowState;
 import java.io.Serializable;
+import java.nio.charset.Charset;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.portlet.WindowState;
-
 /**
  * Created by The eXo Platform SAS May 8, 2006
  */
@@ -175,7 +175,18 @@
                   if (response instanceof FragmentResponse)
                   {
                      FragmentResponse fragmentResponse = (FragmentResponse)response;
-                     markup = Text.create(fragmentResponse.getContent());
+                     switch (fragmentResponse.getType())
+                     {
+                        case FragmentResponse.TYPE_CHARS:
+                           markup = Text.create(fragmentResponse.getContent());
+                           break;
+                        case FragmentResponse.TYPE_BYTES:
+                           markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
+                           break;
+                        case FragmentResponse.TYPE_EMPTY:
+                           markup = Text.create("");
+                           break;
+                     }
                      portletTitle = fragmentResponse.getTitle();
                      if (fragmentResponse.getProperties() != null
                         && fragmentResponse.getProperties().getTransportHeaders() != null)
@@ -262,14 +273,8 @@
          }
          catch (Throwable ex)
          {
+            ex.printStackTrace();
          }
       }
-      try
-      {
-         prcontext.getResponse().flushBuffer();
-      }
-      catch (Throwable ex)
-      {
-      }
    }
 }

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -22,7 +22,6 @@
 import org.exoplatform.commons.utils.ObjectPageList;
 import org.exoplatform.portal.application.PortalRequestContext;
 import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.Query;
 import org.exoplatform.portal.config.UserACL;
 import org.exoplatform.portal.config.UserPortalConfigService;
 import org.exoplatform.portal.config.model.PageNavigation;
@@ -50,6 +49,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 
 /*
  * Created by The eXo Platform SAS
@@ -102,24 +102,14 @@
          listGroup = dataService.getMakableNavigations(pContext.getRemoteUser());
       }
 
-      List<PageNavigation> navigations = new ArrayList<PageNavigation>();
-      DataStorage dataStorage = getApplicationComponent(DataStorage.class);
-      // get all group navigation that user have edit permission
-      Query<PageNavigation> query = new Query<PageNavigation>(PortalConfig.GROUP_TYPE, null, PageNavigation.class);
-      // filter, only get group don't have navigation
       if (listGroup == null)
       {
          listGroup = new ArrayList<String>();
       }
 
-      List<PageNavigation> navis = dataStorage.find(query).getAll();
-      for (PageNavigation ele : navis)
-      {
-         if (listGroup.contains(ele.getOwnerId()))
-         {
-            listGroup.remove(ele.getOwnerId());
-         }
-      }
+      UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
+      Set<String> groupIdsWithNotNavigation = configService.findGroupWithoutNavigation();
+      listGroup.removeAll(groupIdsWithNotNavigation);
 
       UIVirtualList virtualList = getChild(UIVirtualList.class);
       virtualList.dataBind(new ObjectPageList<String>(listGroup, listGroup.size()));

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -19,9 +19,6 @@
 
 package org.exoplatform.portal.webui.navigation;
 
-import org.exoplatform.commons.utils.LazyPageList;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.Query;
 import org.exoplatform.portal.config.UserPortalConfigService;
 import org.exoplatform.portal.config.model.PageNavigation;
 import org.exoplatform.portal.webui.page.UIPageNodeForm2;
@@ -56,14 +53,6 @@
       addChild(UINavigationNodeSelector.class, null, null);
    }
 
-   public void loadNavigation(Query<PageNavigation> query) throws Exception
-   {
-      DataStorage service = getApplicationComponent(DataStorage.class);
-      LazyPageList navis = service.find(query);
-      UINavigationNodeSelector nodeSelector = getChild(UINavigationNodeSelector.class);
-      nodeSelector.initNavigations(navis.getAll());
-   }
-
    public void setOwner(String owner)
    {
       this.owner = owner;

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalSelector.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalSelector.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalSelector.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -24,6 +24,7 @@
 import org.exoplatform.portal.config.Query;
 import org.exoplatform.portal.config.UserACL;
 import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.pom.data.PortalData;
 import org.exoplatform.portal.webui.container.UIContainer;
 import org.exoplatform.portal.webui.workspace.UIMaskWorkspace;
 import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -58,21 +59,21 @@
       addChild(uiGrid.getUIPageIterator());
       uiGrid.getUIPageIterator().setRendered(false);
       DataStorage dataService = getApplicationComponent(DataStorage.class);
-      Query<PortalConfig> query = new Query<PortalConfig>(null, null, null, null, PortalConfig.class);
-      LazyPageList pageList = dataService.find(query);
+      Query<PortalData> query = new Query<PortalData>(null, null, null, null, PortalData.class);
+      LazyPageList<PortalData> pageList = dataService.find(query);
       pageList.setPageSize(10);
       pageList = extractPermissedPortal(pageList);
       uiGrid.getUIPageIterator().setPageList(pageList);
    }
 
-   private LazyPageList extractPermissedPortal(LazyPageList pageList) throws Exception
+   private LazyPageList<PortalData> extractPermissedPortal(LazyPageList<PortalData> pageList) throws Exception
    {
       UserACL userACL = getApplicationComponent(UserACL.class);
-      Iterator<?> itr = pageList.getAll().iterator();
+      Iterator<PortalData> itr = pageList.getAll().iterator();
       while (itr.hasNext())
       {
-         PortalConfig pConfig = (PortalConfig)itr.next();
-         if (!userACL.hasPermission(pConfig))
+         PortalData pConfig = itr.next();
+         if (!userACL.hasPermission(new PortalConfig(pConfig)))
             itr.remove();
       }
       return pageList;

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -304,6 +304,7 @@
 
    private static void toUIContainer(UIContainer uiContainer, Container model, boolean dashboard) throws Exception
    {
+      uiContainer.setStorageId(model.getStorageId());
       uiContainer.setId(model.getId());
       uiContainer.setWidth(model.getWidth());
       uiContainer.setHeight(model.getHeight());
@@ -426,7 +427,6 @@
          Container container = (Container)model;
          UIContainer uiTempContainer =
             uiContainer.createUIComponent(context, UIContainer.class, container.getFactoryId(), null);
-         uiTempContainer.setStorageId(container.getStorageId());
          toUIContainer(uiTempContainer, (Container)model, dashboard);
          uiComponent = uiTempContainer;
       }

Modified: portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
===================================================================
--- portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java	2009-11-04 18:35:16 UTC (rev 492)
+++ portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java	2009-11-04 20:32:31 UTC (rev 493)
@@ -423,6 +423,8 @@
    public void processRender(WebuiRequestContext context) throws Exception
    {
       Writer w = context.getWriter();
+
+      //
       if (!context.useAjax())
       {
          super.processRender(context);



More information about the gatein-commits mailing list