[gatein-commits] gatein SVN: r929 - in portal/trunk: component/application-registry/src/main/java/org/exoplatform/application/gadget and 10 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Dec 4 13:07:17 EST 2009


Author: julien_viet
Date: 2009-12-04 13:07:13 -0500 (Fri, 04 Dec 2009)
New Revision: 929

Added:
   portal/trunk/component/application-registry/src/main/java/conf/application-nodetypes.xml
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/EncodingDetector.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetDeployer.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/LocalImporter.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/ServletLocalImporter.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetData.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetDefinition.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistry.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/RemoteGadgetData.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/SourceStorageImpl.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/NodeAware.java
   portal/trunk/component/portal/src/main/java/conf/content-nodetypes.xml
Removed:
   portal/trunk/component/portal/src/main/java/conf/portal/portal-nodetypes.xml
Modified:
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegister.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/Source.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/SourceStorage.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/jcr/SourceStorageImpl.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ApplicationRegistryChromatticLifeCycle.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/Injector.java
   portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/MOPApplicationRegistryService.java
   portal/trunk/component/portal/src/test/java/conf/portal/jcr-configuration.xml
   portal/trunk/gadgets/eXoGadgets/src/main/webapp/WEB-INF/gadget.xml
   portal/trunk/gadgets/eXoGadgets/src/main/webapp/WEB-INF/web.xml
   portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java
   portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
   portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/jcr/jcr-configuration.xml
   portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml
Log:
GTNPORTAL-309 : Gadget persistence based on Chromattic (first pass, need to remove old stuff after)


Added: portal/trunk/component/application-registry/src/main/java/conf/application-nodetypes.xml
===================================================================
--- portal/trunk/component/application-registry/src/main/java/conf/application-nodetypes.xml	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/conf/application-nodetypes.xml	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,175 @@
+<!--
+
+    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.
+
+-->
+<nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
+
+  <nodeType name="mop:gadgetregistry" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+      <supertype>mix:referenceable</supertype>
+    </supertypes>
+    <childNodeDefinitions>
+      <childNodeDefinition name="*" defaultPrimaryType="mop:gadgetdefinition" autoCreated="false" mandatory="false"
+        onParentVersion="COPY" protected="false" sameNameSiblings="false">
+        <requiredPrimaryTypes>
+          <requiredPrimaryType>mop:gadgetdefinition</requiredPrimaryType>
+        </requiredPrimaryTypes>
+      </childNodeDefinition>
+    </childNodeDefinitions>
+  </nodeType>
+
+  <nodeType name="mop:gadgetdefinition" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+      <supertype>mix:referenceable</supertype>
+    </supertypes>
+    <propertyDefinitions>
+      <propertyDefinition name="title" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+      <propertyDefinition name="description" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+      <propertyDefinition name="thumbnail" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+      <propertyDefinition name="referenceurl" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+    </propertyDefinitions>
+    <childNodeDefinitions>
+      <childNodeDefinition name="data" defaultPrimaryType="mop:gadgetdata" autoCreated="false" mandatory="true"
+        onParentVersion="COPY" protected="false" sameNameSiblings="false">
+        <requiredPrimaryTypes>
+          <requiredPrimaryType>mop:gadgetdata</requiredPrimaryType>
+        </requiredPrimaryTypes>
+      </childNodeDefinition>
+    </childNodeDefinitions>
+  </nodeType>
+
+  <nodeType name="mop:gadgetdata" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+      <supertype>mix:referenceable</supertype>
+    </supertypes>
+  </nodeType>
+
+  <nodeType name="mop:localgadgetdata" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>mop:gadgetdata</supertype>
+    </supertypes>
+    <propertyDefinitions>
+      <propertyDefinition name="filename" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+    </propertyDefinitions>
+    <childNodeDefinitions>
+      <childNodeDefinition name="resources" defaultPrimaryType="nt:folder" autoCreated="false" mandatory="true"
+        onParentVersion="COPY" protected="false" sameNameSiblings="false">
+        <requiredPrimaryTypes>
+          <requiredPrimaryType>nt:folder</requiredPrimaryType>
+        </requiredPrimaryTypes>
+      </childNodeDefinition>
+    </childNodeDefinitions>
+  </nodeType>
+
+  <nodeType name="mop:remotegadgetdata" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>mop:gadgetdata</supertype>
+    </supertypes>
+    <propertyDefinitions>
+      <propertyDefinition name="url" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+    </propertyDefinitions>
+  </nodeType>
+
+  <nodeType name="mop:contentregistry" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+      <supertype>mix:referenceable</supertype>
+    </supertypes>
+    <childNodeDefinitions>
+      <childNodeDefinition name="*" defaultPrimaryType="mop:contentcategory" autoCreated="false" mandatory="false"
+        onParentVersion="COPY" protected="false" sameNameSiblings="false">
+        <requiredPrimaryTypes>
+          <requiredPrimaryType>mop:contentcategory</requiredPrimaryType>
+        </requiredPrimaryTypes>
+      </childNodeDefinition>
+    </childNodeDefinitions>
+  </nodeType>
+
+  <nodeType name="mop:contentcategory" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+      <supertype>mix:referenceable</supertype>
+    </supertypes>
+    <propertyDefinitions>
+      <propertyDefinition name="displayname" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+        <valueConstraints/>
+      </propertyDefinition>
+      <propertyDefinition name="description" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+      <propertyDefinition name="creationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+      <propertyDefinition name="lastmodificationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+      <propertyDefinition name="accesspermissions" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+        <valueConstraints/>
+      </propertyDefinition>
+    </propertyDefinitions>
+    <childNodeDefinitions>
+      <childNodeDefinition name="*" defaultPrimaryType="mop:content" autoCreated="false" mandatory="false"
+        onParentVersion="COPY" protected="false" sameNameSiblings="false">
+        <requiredPrimaryTypes>
+          <requiredPrimaryType>mop:content</requiredPrimaryType>
+        </requiredPrimaryTypes>
+      </childNodeDefinition>
+    </childNodeDefinitions>
+  </nodeType>
+
+  <nodeType name="mop:content" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+      <supertype>mix:referenceable</supertype>
+    </supertypes>
+      <propertyDefinitions>
+        <propertyDefinition name="displayname" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+          <valueConstraints/>
+        </propertyDefinition>
+        <propertyDefinition name="description" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+          <valueConstraints/>
+        </propertyDefinition>
+        <propertyDefinition name="creationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+          <valueConstraints/>
+        </propertyDefinition>
+        <propertyDefinition name="lastmodificationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+          <valueConstraints/>
+        </propertyDefinition>
+        <propertyDefinition name="accesspermissions" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+          <valueConstraints/>
+        </propertyDefinition>
+      </propertyDefinitions>
+  </nodeType>
+
+</nodeTypes>

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/EncodingDetector.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/EncodingDetector.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/EncodingDetector.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,74 @@
+/*
+ * 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.application.gadget;
+
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.Locator2;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class EncodingDetector extends DefaultHandler
+{
+
+   public static String detect(InputStream in) throws IOException, ParserConfigurationException, SAXException
+   {
+      EncodingDetector detector = new EncodingDetector();
+      SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
+      parser.parse(in, detector);
+      return detector.encoding;
+   }
+
+   /** . */
+   private Locator2 locator;
+
+   /** Use UTF-8 if nothing provided. */
+   private String encoding = "UTF-8";
+
+   private EncodingDetector()
+   {
+   }
+
+   @Override
+   public void setDocumentLocator(Locator locator)
+   {
+      if (locator instanceof Locator2)
+      {
+         this.locator = (Locator2)locator;
+      }
+   }
+
+   @Override
+   public void startDocument() throws SAXException
+   {
+      if (locator != null)
+      {
+         encoding = locator.getEncoding();
+      }
+   }
+}

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetDeployer.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetDeployer.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetDeployer.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,160 @@
+/*
+ * 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.application.gadget;
+
+import org.exoplatform.application.gadget.impl.GadgetRegistryServiceImpl;
+import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
+import org.exoplatform.commons.chromattic.SessionContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.RootContainer;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+import org.gatein.common.xml.XMLTools;
+import org.gatein.wci.WebApp;
+import org.gatein.wci.WebAppEvent;
+import org.gatein.wci.WebAppLifeCycleEvent;
+import org.gatein.wci.WebAppListener;
+import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.picocontainer.Startable;
+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.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GadgetDeployer implements WebAppListener, Startable
+{
+
+   /** . */
+   private final Logger log = LoggerFactory.getLogger(GadgetDeployer.class);
+
+   /** . */
+   private GadgetRegistryServiceImpl gadgetRegistryService;
+
+   public GadgetDeployer(GadgetRegistryService gadgetRegistryService)
+   {
+      this.gadgetRegistryService = (GadgetRegistryServiceImpl)gadgetRegistryService;
+   }
+
+   public void onEvent(WebAppEvent webAppEvent)
+   {
+      if (webAppEvent instanceof WebAppLifeCycleEvent)
+      {
+         WebAppLifeCycleEvent lfEvent = (WebAppLifeCycleEvent)webAppEvent;
+         if (lfEvent.getType() == WebAppLifeCycleEvent.ADDED)
+         {
+            WebApp webApp = webAppEvent.getWebApp();
+            ServletContext scontext = webApp.getServletContext();
+            try
+            {
+               final URL url = scontext.getResource("/WEB-INF/gadget.xml");
+               if (url != null)
+               {
+                  final RootContainer.PortalContainerPostInitTask task = new RootContainer.PortalContainerPostInitTask()
+                  {
+                     public void execute(ServletContext context, PortalContainer portalContainer)
+                     {
+                        handle(context, url);
+                     }
+                  };
+                  PortalContainer.addInitTask(scontext, task);
+               }
+            }
+            catch (MalformedURLException e)
+            {
+               log.error("Could not read the content of the gadget file", e);
+            }
+         }
+      }
+   }
+
+   public void start()
+   {
+      DefaultServletContainerFactory.getInstance().getServletContainer().addWebAppListener(this);
+   }
+
+   public void stop()
+   {
+      DefaultServletContainerFactory.getInstance().getServletContainer().addWebAppListener(this);
+   }
+
+   private void handle(ServletContext scontext, URL gadgetsURL)
+   {
+      ChromatticLifeCycle lifeCycle = gadgetRegistryService.getChromatticLifeCycle();
+      SessionContext context = lifeCycle.openContext();
+      InputStream in;
+      try
+      {
+         in = gadgetsURL.openStream();
+         DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+         Document docXML = db.parse(in);
+         NodeList nodeList = docXML.getElementsByTagName("gadget");
+         for (int i = 0; i < nodeList.getLength(); i++)
+         {
+            Element gadgetElement = (Element)nodeList.item(i);
+            String gadgetName = gadgetElement.getAttribute("name");
+            System.out.println("About to import " + gadgetName);
+            Element pathElt = XMLTools.getUniqueChild(gadgetElement, "path", false);
+            if (pathElt != null)
+            {
+               String path = XMLTools.asString(pathElt, true);
+               ServletLocalImporter importer = new ServletLocalImporter(
+                  gadgetName,
+                  gadgetRegistryService.getRegistry(),
+                  path,
+                  scontext,
+                  true);
+               importer.doImport();
+            }
+            else
+            {
+               Element urlElt = XMLTools.getUniqueChild(gadgetElement, "url", false);
+               if (urlElt != null)
+               {
+                  String url = XMLTools.asString(urlElt, true);
+                  ServletLocalImporter importer = new ServletLocalImporter(
+                     gadgetName,
+                     gadgetRegistryService.getRegistry(),
+                     url, 
+                     scontext,
+                     false);
+                  importer.doImport();
+               }
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         log.error("Could not process gadget file " + gadgetsURL, e);
+      }
+      finally
+      {
+         lifeCycle.closeContext(context, true);
+      }
+   }
+}

Modified: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegister.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegister.java	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegister.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -111,18 +111,18 @@
                      File homeDir = sourceFile.getParentFile();
                      String fileName = sourceFile.getName();
                      //Saves source of gadget
-                     Source source = new Source(fileName, getMimeType(context, fileName), "UTF-8");
-                     source.setStreamContent(sourceIs);
+                     Source source = new Source(fileName, getMimeType(context, fileName));
+//                     source.setStreamContent(sourceIs);
                      source.setLastModified(Calendar.getInstance());
                      String homeName = homeDir.getName();
-                     sourceStorage.saveSource(homeName, source);
+                     // sourceStorage.saveSource(homeName, source);
                      //Saves gadget
                      ModulePrefs prefs =
                         GadgetApplication.getModulePreferences(Uri.parse("http://www.exoplatform.org"), source
                            .getTextContent());
                      Gadget gadget = new Gadget();
                      gadget.setName(gadgetName);
-                     gadget.setUrl(sourceStorage.getSourceURI(homeName + "/" + fileName));
+                     // gadget.setUrl(sourceStorage.getSourceURI(homeName + "/" + fileName));
                      gadget.setTitle(getGadgetTitle(prefs, gadget.getName()));
                      gadget.setDescription(prefs.getDescription());
                      gadget.setThumbnail(prefs.getThumbnail().toString());
@@ -177,10 +177,10 @@
    {
       if (file.isFile())
       {
-         Source includedSource = new Source(file.getName(), getMimeType(context, file.getName()), "UTF-8");
-         includedSource.setStreamContent(new FileInputStream(file));
+         Source includedSource = new Source(file.getName(), getMimeType(context, file.getName()));
+//         includedSource.setStreamContent(new FileInputStream(file));
          includedSource.setLastModified(Calendar.getInstance());
-         storage.saveSource(savePath, includedSource);
+         // storage.saveSource(savePath, includedSource);
       }
       else if (file.isDirectory())
       {

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/LocalImporter.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/LocalImporter.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/LocalImporter.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,240 @@
+/*
+ * 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.application.gadget;
+
+import org.apache.shindig.common.uri.Uri;
+import org.apache.shindig.gadgets.spec.GadgetSpec;
+import org.apache.shindig.gadgets.spec.ModulePrefs;
+import org.exoplatform.application.gadget.impl.GadgetDefinition;
+import org.exoplatform.application.gadget.impl.GadgetRegistry;
+import org.exoplatform.application.gadget.impl.LocalGadgetData;
+import org.exoplatform.application.gadget.impl.RemoteGadgetData;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+import org.gatein.common.net.URLTools;
+
+import javax.jcr.Node;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Calendar;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class LocalImporter
+{
+
+   /** . */
+   private static final Logger log = LoggerFactory.getLogger(LocalImporter.class);
+
+   /** The gadget name as seen by GateIn. */
+   private String name;
+
+   /** The gadget registry. */
+   private GadgetRegistry registry;
+
+   /** The gadget path. */
+   private String gadgetPath;
+
+   /** . */
+   private boolean local;
+
+   /** Used temporarily when importing resources. */
+   private Node folder;
+
+   protected LocalImporter(
+      String name,
+      GadgetRegistry registry,
+      String gadgetPath,
+      boolean local)
+   {
+      this.name = name;
+      this.registry = registry;
+      this.gadgetPath = gadgetPath;
+      this.local = local;
+   }
+
+   private byte[] getGadgetBytes() throws IOException
+   {
+      if (local)
+      {
+         return getContent(gadgetPath);
+      }
+      else
+      {
+         URL url = new URL(gadgetPath);
+         return URLTools.getContent(url, 5000, 5000);
+      }
+   }
+
+   private String getGadgetURL() throws Exception
+   {
+      if (local)
+      {
+         return "http://www.gatein.org";
+      }
+      else
+      {
+         return gadgetPath;
+      }
+   }
+
+   private String getGadgetTitle(ModulePrefs prefs, String defaultValue)
+   {
+      String title = prefs.getDirectoryTitle();
+      if (title == null || title.trim().length() < 1)
+      {
+         title = prefs.getTitle();
+      }
+      if (title == null || title.trim().length() < 1)
+      {
+         return defaultValue;
+      }
+      return title;
+   }
+
+   public void doImport() throws Exception
+   {
+      if (registry.getGadget(name) != null)
+      {
+         System.out.println("Cannot import existing gagdet " + name);
+         return;
+      }
+
+      // Get bytes
+      byte[] bytes = getGadgetBytes();
+      if (bytes == null)
+      {
+         System.out.println("Coult not import gadget " + gadgetPath);
+         return;
+      }
+
+      // Get encoding
+      String encoding = EncodingDetector.detect(new ByteArrayInputStream(bytes));
+
+      //
+      String gadget = new String(bytes, encoding);
+
+      //
+      String gadgetURL = getGadgetURL();
+      GadgetSpec spec = new GadgetSpec(Uri.parse(gadgetURL), gadget);
+      ModulePrefs prefs = spec.getModulePrefs();
+
+      //
+      GadgetDefinition def = registry.addGadget(name);
+
+      //
+      String description = prefs.getDescription();
+      String thumbnail = prefs.getThumbnail().toString();
+      String title = getGadgetTitle(prefs, name);
+      String referenceURL = prefs.getTitleUrl().toString();
+
+      //
+      log.info("Importing gadget name=" + name + " description=" + description + " thumbnail=" + thumbnail + " title=" +
+               thumbnail + " title=" + title);
+
+      //
+      def.setDescription(description);
+      def.setThumbnail(thumbnail); // Do something better than that
+      def.setTitle(title);
+      def.setReferenceURL(referenceURL);
+      def.setLocal(local);
+
+      //
+      if (local)
+      {
+         LocalGadgetData data = (LocalGadgetData)def.getData();
+
+         //
+         String fileName = getName(gadgetPath);
+         data.setFileName(fileName);
+
+         // Import resource
+         folder = data.getNode().addNode("resources", "nt:folder");
+         String folderPath = getParent(gadgetPath);
+         visitChildren(folderPath);
+         folder = null;
+      }
+      else
+      {
+         RemoteGadgetData data = (RemoteGadgetData)def.getData();
+
+         // Set remote URL
+         data.setURL(gadgetPath);
+      }
+   }
+
+   private void visit(String resourcePath) throws Exception
+   {
+      String name = getName(resourcePath);
+      if (isFile(resourcePath))
+      {
+         byte[] content = getContent(resourcePath);
+
+         //
+         if (content != null)
+         {
+            String mimeType = getMimeType(name);
+
+            //
+            Node file = folder.addNode(name, "nt:file");
+            Node resource = file.addNode("jcr:content", "nt:resource");
+            resource.setProperty("jcr:data", new ByteArrayInputStream(content));
+            resource.setProperty("jcr:lastModified", Calendar.getInstance());
+            resource.setProperty("jcr:mimeType", mimeType);
+
+            // We can detect encoding for XML files
+            if ("application/xml".equals(mimeType))
+            {
+               String encoding = EncodingDetector.detect(new ByteArrayInputStream(content));
+               resource.setProperty("jcr:encoding", encoding);
+            }
+         }
+      }
+      else
+      {
+         folder = folder.addNode(name, "nt:folder");
+         visitChildren(resourcePath);
+         folder = folder.getParent();
+      }
+   }
+
+   private void visitChildren(String folderPath) throws Exception
+   {
+      for (String childPath : getChildren(folderPath))
+      {
+         visit(childPath);
+      }
+   }
+
+   public abstract String getName(String resourcePath) throws IOException;
+
+   public abstract String getParent(String resourcePath) throws IOException;
+
+   public abstract byte[] getContent(String filePath) throws IOException;
+
+   public abstract Iterable<String> getChildren(String folderPath) throws IOException;
+
+   public abstract boolean isFile(String resourcePath) throws IOException;
+
+   public abstract String getMimeType(String fileName);
+}

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/ServletLocalImporter.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/ServletLocalImporter.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/ServletLocalImporter.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,122 @@
+/*
+ * 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.application.gadget;
+
+import org.exoplatform.application.gadget.impl.GadgetRegistry;
+import org.gatein.common.io.IOTools;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import javax.servlet.ServletContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ServletLocalImporter extends LocalImporter
+{
+
+   /** . */
+   private final Logger log = LoggerFactory.getLogger(ServletLocalImporter.class);
+
+   /** . */
+   private final ServletContext servletContext;
+
+   public ServletLocalImporter(
+      String name,
+      GadgetRegistry registry,
+      String gadgetPath,
+      ServletContext servletContext,
+      boolean local)
+   {
+      super(name, registry, gadgetPath, local);
+
+      //
+      this.servletContext = servletContext;
+   }
+
+   @Override
+   public String getName(String resourcePath) throws IOException
+   {
+      // It's a directory, remove the trailing '/'
+      if (resourcePath.endsWith("/"))
+      {
+         resourcePath = resourcePath.substring(0, resourcePath.length() - 1);
+      }
+
+      // Get index of last '/'
+      int index = resourcePath.lastIndexOf('/');
+
+      // Return name
+      return resourcePath.substring(index + 1);
+   }
+
+   @Override
+   public String getParent(String resourcePath) throws IOException
+   {
+      // It's a directory, remove the trailing '/'
+      if (resourcePath.endsWith("/"))
+      {
+         resourcePath = resourcePath.substring(0, resourcePath.length() - 1);
+      }
+
+      // Get index of last '/'
+      int index = resourcePath.lastIndexOf('/');
+
+      // Return the parent that ends with a '/'
+      return resourcePath.substring(0, index + 1);
+   }
+
+   @Override
+   public byte[] getContent(String filePath) throws IOException
+   {
+      InputStream in = servletContext.getResourceAsStream(filePath);
+      if (in == null)
+      {
+         log.error("Could not obtain input stream for file " + filePath);
+         return null;
+      }
+      else
+      {
+         return IOTools.getBytes(in);
+      }
+   }
+
+   @Override
+   public Iterable<String> getChildren(String folderPath) throws IOException
+   {
+      @SuppressWarnings("unchecked") Set resourcePaths = servletContext.getResourcePaths(folderPath);
+      return resourcePaths;
+   }
+
+   @Override
+   public boolean isFile(String resourcePath) throws IOException
+   {
+      return !resourcePath.endsWith("/");
+   }
+
+   @Override
+   public String getMimeType(String fileName)
+   {
+      return servletContext.getMimeType(fileName);
+   }
+}

Modified: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/Source.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/Source.java	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/Source.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -19,8 +19,6 @@
 
 package org.exoplatform.application.gadget;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
 import java.util.Calendar;
 
 /**
@@ -34,14 +32,10 @@
 
    private String name;
 
-   private byte[] content;
+   private String content;
 
    private String mimeType = "text/plain";
 
-   private String encoding = "UTF-8";
-
-   private long length = 0;
-
    private Calendar lastModified;
 
    public Source(String name)
@@ -49,11 +43,10 @@
       this.name = name;
    }
 
-   public Source(String name, String mimeType, String encoding)
+   public Source(String name, String mimeType)
    {
       this.name = name;
       this.mimeType = mimeType;
-      this.encoding = encoding;
    }
 
    public String getName()
@@ -76,16 +69,6 @@
       this.mimeType = mimeType;
    }
 
-   public String getEncoding()
-   {
-      return encoding;
-   }
-
-   public void setEncoding(String encoding)
-   {
-      this.encoding = encoding;
-   }
-
    public Calendar getLastModified()
    {
       return lastModified;
@@ -96,33 +79,13 @@
       this.lastModified = lastModified;
    }
 
-   public long getLength()
-   {
-      return length;
-   }
-
    public void setTextContent(String text) throws Exception
    {
-      String textContent = (text == null) ? "" : text;
-      content = textContent.getBytes(encoding);
-      length = content.length;
+      content = text;
    }
 
    public String getTextContent() throws Exception
    {
-      return new String(content, encoding);
+      return content;
    }
-
-   public void setStreamContent(InputStream is) throws Exception
-   {
-      content = new byte[is.available()];
-      is.read(content);
-      length = content.length;
-   }
-
-   public InputStream getStreamContent()
-   {
-      return new ByteArrayInputStream(content);
-   }
-
 }
\ No newline at end of file

Modified: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/SourceStorage.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/SourceStorage.java	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/SourceStorage.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -33,7 +33,7 @@
     * @return
     * @throws Exception
     */
-   public Source getSource(String sourcePath) throws Exception;
+   public Source getSource(Gadget gadget) throws Exception;
 
    /**
     * This method will save source to database to a specify path
@@ -41,21 +41,15 @@
     * @param source
     * @throws Exception
     */
-   public void saveSource(String dirPath, Source source) throws Exception;
+   public void saveSource(Gadget gadget, Source source) throws Exception;
 
    /**
-    * This method will remove source from database base on source path
-    * @param sourcePath
-    * @throws Exception
+    * julien : this method does nothing and should be removed since now deleting a gadget
+    * in the gadget registry also deletes the source for the local gadgets.
+    *
+    * @param sourcePath the source path
+    * @throws Exception any exception
     */
    public void removeSource(String sourcePath) throws Exception;
 
-   /**
-    * This method will get source URI from database. 
-    * For example: jcr/repository/collaboration/source/Todo.xml
-    * @param sourcePath
-    * @return
-    */
-   public String getSourceURI(String sourcePath);
-
 }
\ No newline at end of file

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetData.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetData.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetData.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,27 @@
+/*
+ * 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.application.gadget.impl;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class GadgetData
+{
+}

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetDefinition.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetDefinition.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetDefinition.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,98 @@
+/*
+ * 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.application.gadget.impl;
+
+import org.chromattic.api.annotations.Create;
+import org.chromattic.api.annotations.MappedBy;
+import org.chromattic.api.annotations.Name;
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToOne;
+import org.chromattic.api.annotations.Property;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at NodeMapping(name = "mop:gadgetdefinition")
+public abstract class GadgetDefinition
+{
+
+   @Name
+   public abstract String getName();
+
+   @Property(name = "title")
+   public abstract String getTitle();
+
+   public abstract void setTitle(String title);
+
+   @Property(name = "description")
+   public abstract String getDescription();
+
+   public abstract void setDescription(String description);
+
+   @Property(name = "thumbnail")
+   public abstract String getThumbnail();
+
+   public abstract void setThumbnail(String thumbnail);
+
+   @Property(name = "referenceurl")
+   public abstract String getReferenceURL();
+
+   public abstract void setReferenceURL(String referenceURL);
+
+   @OneToOne
+   @MappedBy("data")
+   public abstract GadgetData getData();
+
+   public abstract void setData(GadgetData data);
+
+   @Create
+   protected abstract LocalGadgetData createLocalData();
+
+   @Create
+   protected abstract RemoteGadgetData createRemoteData();
+
+   public boolean isLocal()
+   {
+      GadgetData data = getData();
+      return data instanceof LocalGadgetData;
+   }
+
+   public void setLocal(boolean local)
+   {
+      GadgetData data = getData();
+      if (local)
+      {
+         if (data == null || data instanceof RemoteGadgetData)
+         {
+            LocalGadgetData localData = createLocalData();
+            setData(localData);
+         }
+      }
+      else
+      {
+         if (data == null || data instanceof LocalGadgetData)
+         {
+            RemoteGadgetData localData = createRemoteData();
+            setData(localData);
+         }
+      }
+   }
+
+}

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistry.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistry.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistry.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,72 @@
+/*
+ * 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.application.gadget.impl;
+
+import org.chromattic.api.annotations.Create;
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToMany;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at NodeMapping(name = "mop:gadgetregistry")
+public abstract class GadgetRegistry
+{
+
+   @OneToMany
+   protected abstract Map<String, GadgetDefinition> getDefinitions();
+
+   @Create
+   protected abstract GadgetDefinition createGadget();
+
+/*
+   @Create
+   protected abstract NTFolder createFolder();
+*/
+
+   public Collection<GadgetDefinition> getGadgets()
+   {
+      return getDefinitions().values();
+   }
+
+   public GadgetDefinition getGadget(String name)
+   {
+      return getDefinitions().get(name);
+   }
+
+   public GadgetDefinition addGadget(String name)
+   {
+      if (name == null)
+      {
+         throw new NullPointerException();
+      }
+      GadgetDefinition def = createGadget();
+      getDefinitions().put(name, def);
+      return def;
+   }
+
+   public void removeGadget(String name)
+   {
+      getDefinitions().put(name, null);
+   }
+}

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,263 @@
+/*
+ * 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.application.gadget.impl;
+
+import org.chromattic.api.Chromattic;
+import org.chromattic.api.ChromatticSession;
+import org.exoplatform.application.gadget.Gadget;
+import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.application.registry.mop.ApplicationRegistryChromatticLifeCycle;
+import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
+import org.exoplatform.commons.chromattic.ChromatticManager;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.PropertiesParam;
+import org.exoplatform.container.xml.ValueParam;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GadgetRegistryServiceImpl implements GadgetRegistryService
+{
+
+   /** . */
+   private static final String DEFAULT_DEVELOPER_GROUP = "/platform/administrators";
+
+   /** . */
+   private ChromatticManager chromatticManager;
+
+   /** . */
+   private ChromatticLifeCycle chromatticLifeCycle;
+
+   /** . */
+   private String gadgetDeveloperGroup;
+
+   /** . */
+   private String country;
+
+   /** . */
+   private String language;
+
+   /** . */
+   private String moduleId;
+
+   /** . */
+   private String hostName;
+
+   public GadgetRegistryServiceImpl(ChromatticManager chromatticManager, InitParams params)
+   {
+      ApplicationRegistryChromatticLifeCycle lifeCycle = (ApplicationRegistryChromatticLifeCycle)chromatticManager.getLifeCycle("app");
+
+      //
+      String gadgetDeveloperGroup = null;
+      String country = null;
+      String language = null;
+      String moduleId = null;
+      String hostName = null;
+      if (params != null)
+      {
+         PropertiesParam properties = params.getPropertiesParam("developerInfo");
+         gadgetDeveloperGroup = properties != null ? properties.getProperty("developer.group") : null;
+         ValueParam gadgetCountry = params.getValueParam("gadgets.country");
+         country = gadgetCountry != null ? gadgetCountry.getValue() : null;
+         ValueParam gadgetLanguage = params.getValueParam("gadgets.language");
+         language = gadgetLanguage != null ? gadgetLanguage.getValue() : null;
+         ValueParam gadgetModuleId = params.getValueParam("gadgets.moduleId");
+         moduleId = gadgetModuleId != null ? gadgetModuleId.getValue() : null;
+         ValueParam gadgetHostName = params.getValueParam("gadgets.hostName");
+         hostName = gadgetHostName != null ? gadgetHostName.getValue() : null;
+      }
+
+      //
+      if (gadgetDeveloperGroup == null)
+      {
+         gadgetDeveloperGroup = DEFAULT_DEVELOPER_GROUP;
+      }
+
+      //
+      this.country = country;
+      this.language = language;
+      this.moduleId = moduleId;
+      this.hostName = hostName;
+      this.gadgetDeveloperGroup  = gadgetDeveloperGroup;
+      this.chromatticManager = chromatticManager;
+      this.chromatticLifeCycle = lifeCycle;
+   }
+
+   public GadgetRegistry getRegistry()
+   {
+      Chromattic chromattic = chromatticLifeCycle.getChromattic();
+      ChromatticSession session = chromattic.openSession();
+      GadgetRegistry registry = session.findByPath(GadgetRegistry.class, "gadgets");
+      if (registry == null)
+      {
+         registry = session.insert(GadgetRegistry.class, "gadgets");
+      }
+      return registry;
+   }
+
+   public ChromatticLifeCycle getChromatticLifeCycle()
+   {
+      return chromatticLifeCycle;
+   }
+
+   // ***************
+
+
+   public Gadget getGadget(String name) throws Exception
+   {
+      GadgetRegistry registry = getRegistry();
+
+      //
+      GadgetDefinition def = registry.getGadget(name);
+
+      //
+      return def == null ? null : loadGadget(def);
+   }
+
+   public List<Gadget> getAllGadgets() throws Exception
+   {
+      return getAllGadgets(null);
+   }
+
+   public List<Gadget> getAllGadgets(Comparator<Gadget> sortComparator) throws Exception
+   {
+      GadgetRegistry registry = getRegistry();
+      List<Gadget> gadgets = new ArrayList<Gadget>();
+      for (GadgetDefinition def : registry.getGadgets())
+      {
+         Gadget gadget = loadGadget(def);
+         gadgets.add(gadget);
+      }
+      if (sortComparator != null)
+      {
+         Collections.sort(gadgets, sortComparator);
+      }
+      return gadgets;
+   }
+
+   public void saveGadget(Gadget gadget) throws Exception
+   {
+      if (gadget == null)
+      {
+         throw new NullPointerException();
+      }
+
+      //
+      GadgetRegistry registry = getRegistry();
+      GadgetDefinition def = registry.getGadget(gadget.getName());
+
+      //
+      if (def == null)
+      {
+         throw new IllegalArgumentException("No such gadget " + gadget.getName());
+      }
+
+      //
+      saveGadget(def, gadget);
+   }
+
+   public void removeGadget(String name) throws Exception
+   {
+      if (name == null)
+      {
+         throw new NullPointerException();
+      }
+
+      //
+      GadgetRegistry registry = getRegistry();
+      GadgetDefinition def = registry.getGadget(name);
+
+      //
+      if (def == null)
+      {
+         throw new IllegalArgumentException("No such gadget " + name);
+      }
+
+      //
+      registry.removeGadget(name);
+   }
+
+   private void saveGadget(GadgetDefinition def, Gadget gadget)
+   {
+      def.setDescription(gadget.getDescription());
+      def.setReferenceURL(gadget.getReferenceUrl());
+      def.setTitle(gadget.getTitle());
+      def.setThumbnail(gadget.getThumbnail());
+   }
+
+   private Gadget loadGadget(GadgetDefinition def)
+   {
+      GadgetData data = def.getData();
+
+      //
+      String url;
+      if (data instanceof LocalGadgetData)
+      {
+         LocalGadgetData localData = (LocalGadgetData)data;
+         url = "jcr/repository/portal-system/gadgets/" + def.getName() + "/data/resources/" + localData.getFileName();
+      }
+      else
+      {
+         RemoteGadgetData remoteData = (RemoteGadgetData)data;
+         url = remoteData.getURL();
+      }
+
+      //
+      Gadget gadget = new Gadget();
+      gadget.setName(def.getName());
+      gadget.setDescription(def.getDescription());
+      gadget.setLocal(def.isLocal());
+      gadget.setTitle(def.getTitle());
+      gadget.setReferenceUrl(def.getReferenceURL());
+      gadget.setThumbnail(def.getThumbnail());
+      gadget.setUrl(url);
+      return gadget;
+   }
+
+   public boolean isGadgetDeveloper(String username)
+   {
+      return true;
+   }
+
+   public String getCountry()
+   {
+      return country ;
+   }
+
+   public String getLanguage()
+   {
+      return language ;
+   }
+
+   public String getModuleId()
+   {
+      return moduleId;
+   }
+
+   public String getHostName()
+   {
+      return hostName ;
+   }
+}

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,151 @@
+/**
+ * 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.application.gadget.impl;
+
+import org.apache.shindig.common.uri.Uri;
+import org.apache.shindig.gadgets.spec.GadgetSpec;
+import org.apache.shindig.gadgets.spec.ModulePrefs;
+import org.chromattic.api.UndeclaredRepositoryException;
+import org.chromattic.api.annotations.ManyToOne;
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.Property;
+import org.exoplatform.application.gadget.EncodingDetector;
+import org.exoplatform.application.registry.mop.NodeAware;
+import org.gatein.common.io.IOTools;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Calendar;
+
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at NodeMapping(name = "mop:localgadgetdata")
+public abstract class LocalGadgetData extends GadgetData implements NodeAware
+{
+
+   /** Temporary hack, use with care. */
+   private Node node;
+
+   @ManyToOne
+   public abstract GadgetDefinition getDefinition();
+
+   @Property(name = "filename")
+   public abstract String getFileName();
+
+   public abstract void setFileName(String fileName);
+
+   public void setNode(Node node)
+   {
+      this.node = node;
+   }
+
+   public Node getNode()
+   {
+      return node;
+   }
+
+   public void setSource(String gadgetXML) throws Exception
+   {
+
+      // Get the definition
+      GadgetDefinition def = getDefinition();
+
+      // Get the related content
+      GadgetSpec spec = new GadgetSpec(Uri.parse("http://www.gatein.org"), gadgetXML);
+      ModulePrefs prefs = spec.getModulePrefs();
+      String fileName = getFileName();
+      Node contentNode = node.getNode("resources/" + fileName + "/jcr:content");
+      byte[] bytes = gadgetXML.getBytes();
+      String encoding = EncodingDetector.detect(new ByteArrayInputStream(bytes));
+
+      // Update def
+      def.setDescription(prefs.getDescription());
+      def.setThumbnail(prefs.getThumbnail().toString()); // Do something better than that
+      def.setTitle(prefs.getTitle());
+      def.setReferenceURL(prefs.getTitleUrl().toString());
+
+      // Update content
+      contentNode.setProperty("jcr:encoding", encoding);
+      contentNode.setProperty("jcr:data", new ByteArrayInputStream(bytes));
+      contentNode.setProperty("jcr:mimeType", "application/xml");
+      contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+   }
+
+   public String getSource() throws Exception
+   {
+      String fileName = getFileName();
+      Node contentNode = node.getNode("resources/" + fileName + "/jcr:content");
+      InputStream in = contentNode.getProperty("jcr:data").getStream();
+      String encoding = contentNode.getProperty("jcr:encoding").getString();
+      byte[] bytes = IOTools.getBytes(in);
+      return new String(bytes, encoding);
+   }
+
+   public Calendar getLastModified()
+   {
+      try
+      {
+         String fileName = getFileName();
+         Node contentNode = node.getNode("resources/" + fileName + "/jcr:content");
+         return contentNode.getProperty("jcr:lastModified").getDate();
+      }
+      catch (RepositoryException e)
+      {
+         throw new UndeclaredRepositoryException(e);
+      }
+   }
+
+   private static String getProperty(Node node, String name, String defaultValue) throws Exception
+   {
+      if (node.hasProperty(name))
+      {
+         return node.getProperty(name).getString();
+      }
+      else
+      {
+         return defaultValue;
+      }
+   }
+
+   private static Calendar getCalendarProperty(Node node, String name) throws Exception
+   {
+      if (node.hasProperty(name))
+      {
+         return node.getProperty(name).getDate();
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+
+/*
+   @OneToOne
+   @MappedBy("folder")
+   public abstract NTFolder getFolder();
+
+   public abstract void setFolder(NTFolder folder);
+*/
+}

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/RemoteGadgetData.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/RemoteGadgetData.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/RemoteGadgetData.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,37 @@
+/*
+ * 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.application.gadget.impl;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.Property;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at NodeMapping(name = "mop:remotegadgetdata")
+public abstract class RemoteGadgetData extends GadgetData
+{
+
+   @Property(name = "url")
+   public abstract String getURL();
+
+   public abstract void setURL(String url);
+
+}

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/SourceStorageImpl.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/SourceStorageImpl.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/SourceStorageImpl.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,128 @@
+/*
+ * 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.application.gadget.impl;
+
+import org.exoplatform.application.gadget.EncodingDetector;
+import org.exoplatform.application.gadget.Gadget;
+import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.application.gadget.Source;
+import org.exoplatform.application.gadget.SourceStorage;
+import org.gatein.common.io.IOTools;
+
+import javax.jcr.Node;
+import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.util.Calendar;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class SourceStorageImpl implements SourceStorage
+{
+   /** . */
+   private GadgetRegistryServiceImpl gadgetRegistryService;
+
+   public SourceStorageImpl(GadgetRegistryService gadgetRegistryService)
+   {
+
+      // resources/Calculator.xml
+      // resources/rssAggregator.xml
+
+      this.gadgetRegistryService = (GadgetRegistryServiceImpl)gadgetRegistryService;
+   }
+
+   public Source getSource(Gadget gadget) throws Exception
+   {
+      GadgetDefinition def = gadgetRegistryService.getRegistry().getGadget(gadget.getName());
+
+      //
+      if (def == null)
+      {
+         return null;
+      }
+
+      //
+      GadgetData data = def.getData();
+      if (data instanceof LocalGadgetData)
+      {
+         LocalGadgetData localData = (LocalGadgetData)data;
+         String content = localData.getSource();
+         Calendar lastModified = localData.getLastModified();
+
+         //
+         Source source = new Source(gadget.getName());
+         source.setMimeType("application/xml");
+         source.setLastModified(lastModified);
+         source.setTextContent(content);
+
+         //
+         return source;
+      }
+      else
+      {
+         throw new IllegalArgumentException("The provided gadget is remote");
+      }
+   }
+
+   public void saveSource(Gadget gadget, Source source) throws Exception
+   {
+      if (gadget == null)
+      {
+         throw new NullPointerException();
+      }
+      if (source == null)
+      {
+         throw new NullPointerException();
+      }
+
+      //
+      GadgetDefinition def = gadgetRegistryService.getRegistry().getGadget(gadget.getName());
+
+      //
+      if (def == null)
+      {
+         throw new IllegalStateException("No such gadget " + gadget.getName());
+      }
+
+      //
+      GadgetData data = def.getData();
+      if (data instanceof LocalGadgetData)
+      {
+         LocalGadgetData localData = (LocalGadgetData)data;
+         localData.setSource(source.getTextContent());
+      }
+      else
+      {
+         throw new IllegalArgumentException("The provided gadget is remote");
+      }
+   }
+
+
+
+   public void removeSource(String sourcePath) throws Exception
+   {
+      // No op
+   }
+
+   public String getSourceURI(String sourcePath)
+   {
+      throw new UnsupportedOperationException("Cannot obtain URI from source " + sourcePath);
+   }
+}

Modified: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/jcr/SourceStorageImpl.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/jcr/SourceStorageImpl.java	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/jcr/SourceStorageImpl.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -19,6 +19,7 @@
 
 package org.exoplatform.application.gadget.jcr;
 
+import org.exoplatform.application.gadget.Gadget;
 import org.exoplatform.application.gadget.Source;
 import org.exoplatform.application.gadget.SourceStorage;
 import org.exoplatform.container.xml.InitParams;
@@ -70,6 +71,16 @@
       repoService = service;
    }
 
+   public Source getSource(Gadget gadget) throws Exception
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   public void saveSource(Gadget gadget, Source source) throws Exception
+   {
+      throw new UnsupportedOperationException();
+   }
+
    /**
     * Overridden method.
     * @param sourcePath
@@ -207,8 +218,8 @@
    {
       Source source = new Source(name);
       source.setMimeType(node.getProperty(JCR_MIME).getString());
-      source.setEncoding(node.getProperty(JCR_ENCODING).getString());
-      source.setStreamContent(node.getProperty(JCR_DATA).getStream());
+//      source.setEncoding(node.getProperty(JCR_ENCODING).getString());
+//      source.setStreamContent(node.getProperty(JCR_DATA).getStream());
       source.setLastModified(node.getProperty(JCR_MODIFIED).getDate());
       return source;
    }
@@ -222,8 +233,8 @@
    private void map(Node node, Source source) throws Exception
    {
       node.setProperty(JCR_MIME, source.getMimeType());
-      node.setProperty(JCR_ENCODING, source.getEncoding());
-      node.setProperty(JCR_DATA, source.getStreamContent());
+//      node.setProperty(JCR_ENCODING, source.getEncoding());
+//      node.setProperty(JCR_DATA, source.getStreamContent());
       node.setProperty(JCR_MODIFIED, source.getLastModified());
    }
 

Modified: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ApplicationRegistryChromatticLifeCycle.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ApplicationRegistryChromatticLifeCycle.java	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ApplicationRegistryChromatticLifeCycle.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -18,6 +18,7 @@
  */
 package org.exoplatform.application.registry.mop;
 
+import org.chromattic.core.DomainSession;
 import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
 import org.exoplatform.commons.chromattic.SessionContext;
 import org.exoplatform.container.xml.InitParams;
@@ -38,6 +39,6 @@
 
    @Override
    protected void onOpenSession(SessionContext context) {
-      context.getSession().addEventListener(new Injector(registry));
+      context.getSession().addEventListener(new Injector(registry, (DomainSession)context.getSession()));
    }
 }

Modified: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/Injector.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/Injector.java	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/Injector.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -19,7 +19,10 @@
 package org.exoplatform.application.registry.mop;
 
 import org.chromattic.api.event.LifeCycleListener;
+import org.chromattic.core.DomainSession;
 
+import javax.jcr.Node;
+
 /**
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
@@ -30,9 +33,13 @@
    /** . */
    private final MOPApplicationRegistryService registry;
 
-   public Injector(MOPApplicationRegistryService registry)
+   /** . */
+   private final DomainSession session;
+
+   public Injector(MOPApplicationRegistryService registry, DomainSession session)
    {
       this.registry = registry;
+      this.session = session;
    }
 
    public void created(Object o)
@@ -41,6 +48,11 @@
 
    public void loaded(String id, String path, String name, Object o)
    {
+      if (o instanceof NodeAware)
+      {
+         Node node = session.getNode(o);
+         ((NodeAware)o).setNode(node);
+      }
       if (o instanceof CategoryDefinition)
       {
          ((CategoryDefinition)o).registry = registry;
@@ -49,6 +61,11 @@
 
    public void added(String id, String path, String name, Object o)
    {
+      if (o instanceof NodeAware)
+      {
+         Node node = session.getNode(o);
+         ((NodeAware)o).setNode(node);
+      }
       if (o instanceof CategoryDefinition)
       {
          ((CategoryDefinition)o).registry = registry;
@@ -57,6 +74,10 @@
 
    public void removed(String id, String path, String name, Object o)
    {
+      if (o instanceof NodeAware)
+      {
+         ((NodeAware)o).setNode(null);
+      }
       if (o instanceof CategoryDefinition)
       {
          ((CategoryDefinition)o).registry = null;

Modified: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/MOPApplicationRegistryService.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/MOPApplicationRegistryService.java	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/MOPApplicationRegistryService.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -79,7 +79,7 @@
 
    public MOPApplicationRegistryService(ChromatticManager manager, POMSessionManager mopManager)
    {
-      ApplicationRegistryChromatticLifeCycle lifeCycle = (ApplicationRegistryChromatticLifeCycle)manager.getLifeCycle("registry");
+      ApplicationRegistryChromatticLifeCycle lifeCycle = (ApplicationRegistryChromatticLifeCycle)manager.getLifeCycle("app");
       lifeCycle.registry = this;
 
       //

Added: portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/NodeAware.java
===================================================================
--- portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/NodeAware.java	                        (rev 0)
+++ portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/NodeAware.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -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.application.registry.mop;
+
+import javax.jcr.Node;
+
+/**
+ * Temporary hack.
+ *
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public interface NodeAware
+{
+   void setNode(Node node);
+}

Copied: portal/trunk/component/portal/src/main/java/conf/content-nodetypes.xml (from rev 865, portal/trunk/component/portal/src/main/java/conf/portal/portal-nodetypes.xml)
===================================================================
--- portal/trunk/component/portal/src/main/java/conf/content-nodetypes.xml	                        (rev 0)
+++ portal/trunk/component/portal/src/main/java/conf/content-nodetypes.xml	2009-12-04 18:07:13 UTC (rev 929)
@@ -0,0 +1,80 @@
+<!--
+
+    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.
+
+-->
+<nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
+
+    <nodeType name="mop:portletpreferences" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+      <supertypes>
+        <supertype>mop:customizationstate</supertype>
+      </supertypes>
+      <childNodeDefinitions>
+        <childNodeDefinition name="*" defaultPrimaryType="mop:portletpreference" autoCreated="false" mandatory="false"
+          onParentVersion="COPY" protected="false" sameNameSiblings="false">
+          <requiredPrimaryTypes>
+            <requiredPrimaryType>mop:portletpreference</requiredPrimaryType>
+          </requiredPrimaryTypes>
+        </childNodeDefinition>
+      </childNodeDefinitions>
+    </nodeType>
+
+    <nodeType name="mop:portletpreference" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+      <supertypes>
+        <supertype>nt:base</supertype>
+        <supertype>mix:referenceable</supertype>
+      </supertypes>
+      <propertyDefinitions>
+        <propertyDefinition name="value" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+          <valueConstraints/>
+        </propertyDefinition>
+        <propertyDefinition name="readonly" requiredType="Boolean" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+          <valueConstraints/>
+        </propertyDefinition>
+      </propertyDefinitions>
+    </nodeType>
+
+    <nodeType name="mop:gadget" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+      <supertypes>
+        <supertype>mop:customizationstate</supertype>
+      </supertypes>
+      <propertyDefinitions>
+        <propertyDefinition name="prefs" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+          <valueConstraints/>
+        </propertyDefinition>
+      </propertyDefinitions>
+    </nodeType>
+
+    <nodeType name="mop:wsrpstate" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+       <supertypes>
+          <supertype>mop:customizationstate</supertype>
+       </supertypes>
+       <propertyDefinitions>
+          <propertyDefinition name="portletid" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+             <valueConstraints/>
+          </propertyDefinition>
+          <propertyDefinition name="state" requiredType="Binary" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+             <valueConstraints/>
+          </propertyDefinition>
+          <propertyDefinition name="cloned" requiredType="Boolean" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+             <valueConstraints/>
+          </propertyDefinition>
+       </propertyDefinitions>
+    </nodeType>
+
+</nodeTypes>

Deleted: portal/trunk/component/portal/src/main/java/conf/portal/portal-nodetypes.xml
===================================================================
--- portal/trunk/component/portal/src/main/java/conf/portal/portal-nodetypes.xml	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/component/portal/src/main/java/conf/portal/portal-nodetypes.xml	2009-12-04 18:07:13 UTC (rev 929)
@@ -1,151 +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.
-
--->
-<nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
-
-    <nodeType name="mop:contentregistry" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
-      <supertypes>
-        <supertype>nt:base</supertype>
-        <supertype>mix:referenceable</supertype>
-      </supertypes>
-        <childNodeDefinitions>
-          <childNodeDefinition name="*" defaultPrimaryType="mop:contentcategory" autoCreated="false" mandatory="false"
-            onParentVersion="COPY" protected="false" sameNameSiblings="false">
-            <requiredPrimaryTypes>
-              <requiredPrimaryType>mop:contentcategory</requiredPrimaryType>
-            </requiredPrimaryTypes>
-          </childNodeDefinition>
-        </childNodeDefinitions>
-    </nodeType>
-
-  <nodeType name="mop:contentcategory" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
-    <supertypes>
-      <supertype>nt:base</supertype>
-      <supertype>mix:referenceable</supertype>
-    </supertypes>
-      <propertyDefinitions>
-          <propertyDefinition name="displayname" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
-            <valueConstraints/>
-          </propertyDefinition>
-          <propertyDefinition name="description" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-            <valueConstraints/>
-          </propertyDefinition>
-          <propertyDefinition name="creationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-            <valueConstraints/>
-          </propertyDefinition>
-          <propertyDefinition name="lastmodificationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-            <valueConstraints/>
-          </propertyDefinition>
-          <propertyDefinition name="accesspermissions" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
-            <valueConstraints/>
-          </propertyDefinition>
-      </propertyDefinitions>
-      <childNodeDefinitions>
-        <childNodeDefinition name="*" defaultPrimaryType="mop:content" autoCreated="false" mandatory="false"
-          onParentVersion="COPY" protected="false" sameNameSiblings="false">
-          <requiredPrimaryTypes>
-            <requiredPrimaryType>mop:content</requiredPrimaryType>
-          </requiredPrimaryTypes>
-        </childNodeDefinition>
-      </childNodeDefinitions>
-  </nodeType>
-
-    <nodeType name="mop:content" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
-      <supertypes>
-        <supertype>nt:base</supertype>
-        <supertype>mix:referenceable</supertype>
-      </supertypes>
-        <propertyDefinitions>
-            <propertyDefinition name="displayname" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
-              <valueConstraints/>
-            </propertyDefinition>
-            <propertyDefinition name="description" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-              <valueConstraints/>
-            </propertyDefinition>
-            <propertyDefinition name="creationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-              <valueConstraints/>
-            </propertyDefinition>
-            <propertyDefinition name="lastmodificationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-              <valueConstraints/>
-            </propertyDefinition>
-            <propertyDefinition name="accesspermissions" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
-              <valueConstraints/>
-            </propertyDefinition>
-        </propertyDefinitions>
-    </nodeType>
-
-    <nodeType name="mop:portletpreferences" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
-      <supertypes>
-        <supertype>mop:customizationstate</supertype>
-      </supertypes>
-      <childNodeDefinitions>
-        <childNodeDefinition name="*" defaultPrimaryType="mop:portletpreference" autoCreated="false" mandatory="false"
-          onParentVersion="COPY" protected="false" sameNameSiblings="false">
-          <requiredPrimaryTypes>
-            <requiredPrimaryType>mop:portletpreference</requiredPrimaryType>
-          </requiredPrimaryTypes>
-        </childNodeDefinition>
-      </childNodeDefinitions>
-    </nodeType>
-
-    <nodeType name="mop:portletpreference" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
-      <supertypes>
-        <supertype>nt:base</supertype>
-        <supertype>mix:referenceable</supertype>
-      </supertypes>
-      <propertyDefinitions>
-        <propertyDefinition name="value" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
-          <valueConstraints/>
-        </propertyDefinition>
-        <propertyDefinition name="readonly" requiredType="Boolean" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-          <valueConstraints/>
-        </propertyDefinition>
-      </propertyDefinitions>
-    </nodeType>
-
-    <nodeType name="mop:gadget" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
-      <supertypes>
-        <supertype>mop:customizationstate</supertype>
-      </supertypes>
-      <propertyDefinitions>
-        <propertyDefinition name="prefs" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-          <valueConstraints/>
-        </propertyDefinition>
-      </propertyDefinitions>
-    </nodeType>
-
-    <nodeType name="mop:wsrpstate" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
-       <supertypes>
-          <supertype>mop:customizationstate</supertype>
-       </supertypes>
-       <propertyDefinitions>
-          <propertyDefinition name="portletid" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-             <valueConstraints/>
-          </propertyDefinition>
-          <propertyDefinition name="state" requiredType="Binary" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-             <valueConstraints/>
-          </propertyDefinition>
-          <propertyDefinition name="cloned" requiredType="Boolean" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
-             <valueConstraints/>
-          </propertyDefinition>
-       </propertyDefinitions>
-    </nodeType>
-
-</nodeTypes>

Modified: portal/trunk/component/portal/src/test/java/conf/portal/jcr-configuration.xml
===================================================================
--- portal/trunk/component/portal/src/test/java/conf/portal/jcr-configuration.xml	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/component/portal/src/test/java/conf/portal/jcr-configuration.xml	2009-12-04 18:07:13 UTC (rev 929)
@@ -80,7 +80,7 @@
  		      <name>autoCreatedInNewRepository</name>
  		      <description>Node types configuration file</description>
           <value>jar:/conf/mop-nodetypes.xml</value>
-          <value>jar:/conf/portal/portal-nodetypes.xml</value>
+          <value>jar:/conf/content-nodetypes.xml</value>
  		    </values-param>
  		  </init-params>
  		</component-plugin>

Modified: portal/trunk/gadgets/eXoGadgets/src/main/webapp/WEB-INF/gadget.xml
===================================================================
--- portal/trunk/gadgets/eXoGadgets/src/main/webapp/WEB-INF/gadget.xml	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/gadgets/eXoGadgets/src/main/webapp/WEB-INF/gadget.xml	2009-12-04 18:07:13 UTC (rev 929)
@@ -36,4 +36,8 @@
 	<gadget name="rssAggregator">
 		<path>/gadgets/rssAggregator/rssAggregator.xml</path>
 	</gadget>
+
+  <gadget name="Currency">
+    <url>http://www.donalobrien.net/apps/google/currency.xml</url>
+  </gadget>
 </gadgets>
\ No newline at end of file

Modified: portal/trunk/gadgets/eXoGadgets/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/gadgets/eXoGadgets/src/main/webapp/WEB-INF/web.xml	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/gadgets/eXoGadgets/src/main/webapp/WEB-INF/web.xml	2009-12-04 18:07:13 UTC (rev 929)
@@ -35,9 +35,5 @@
     <filter-name>ResourceRequestFilter</filter-name>
     <url-pattern>/*</url-pattern>
   </filter-mapping>  
-  
-	<listener>
-    <listener-class>org.exoplatform.application.gadget.GadgetRegister</listener-class>
-  </listener>
 
 </web-app>

Modified: portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -154,9 +154,12 @@
             fileName = name + ".xml";
             dirPath = name;
          }
+
+         //
+         Gadget gadget = service.getGadget(name);
          if (isEdit)
          {
-            if (service.getGadget(name) == null)
+            if (gadget == null)
             {
                UIApplication uiApp = event.getRequestContext().getUIApplication();
                uiApp.addMessage(new ApplicationMessage("gadget.msg.changeNotExist", null));
@@ -164,11 +167,17 @@
                return;
             }
          }
-         Source source = new Source(fileName, "application/xml", "UTF-8");
+
+         //
+         Source source = new Source(fileName, "application/xml");
          source.setTextContent(text);
          source.setLastModified(Calendar.getInstance());
-         sourceStorage.saveSource(dirPath, source);
-         service.saveGadget(GadgetUtil.toGadget(name, sourceStorage.getSourceURI(dirPath + "/" + fileName), true));
+
+         // This will update the source and also update the gadget related cached meta data
+         // from the source
+         sourceStorage.saveSource(gadget, source);
+
+         // service.saveGadget(GadgetUtil.toGadget(name, sourceStorage.getSourceURI(dirPath + "/" + fileName), true));
          uiManagement.initData();
          uiManagement.setSelectedGadget(name);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);

Modified: portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java	2009-12-04 18:07:13 UTC (rev 929)
@@ -107,7 +107,7 @@
       for (String name : nameList)
       {
          names.append(name);
-         if (name != nameList.get(nameList.size() - 1))
+         if (!name.equals(nameList.get(nameList.size() - 1)))
             names.append(", ");
       }
       return names.toString();
@@ -160,11 +160,17 @@
          InputStream is = conn.getInputStream();
          SourceStorage sourceStorage = uiInfo.getApplicationComponent(SourceStorage.class);
          String fileName = name + ".xml";
-         Source source = new Source(fileName, "application/xml", "UTF-8");
+         Source source = new Source(fileName, "application/xml");
          source.setTextContent(IOUtils.toString(is, "UTF-8"));
          source.setLastModified(Calendar.getInstance());
-         sourceStorage.saveSource(name, source);
-         service.saveGadget(GadgetUtil.toGadget(name, sourceStorage.getSourceURI(name + "/" + fileName), true));
+
+         // This will update the source and also update the gadget related cached meta data
+         // from the source
+         sourceStorage.saveSource(uiInfo.getGadget(), source);
+
+         //
+         // service.saveGadget(GadgetUtil.toGadget(name, sourceStorage.getSourceURI(name + "/" + fileName), true));
+         
          WebAppController webController = uiManagement.getApplicationComponent(WebAppController.class);
          webController.removeApplication(GadgetApplication.EXO_GADGET_GROUP + "/" + name);
          uiManagement.initData();
@@ -200,7 +206,7 @@
          String dirPath = gaggetUrlPart[gaggetUrlPart.length - 2];
          //String dirPath = gaggetUrlPart[gaggetUrlPart.length - 9];
          // get gadget's source: path = dir path + file name
-         Source source = sourceStorage.getSource(dirPath + "/" + fileName);
+         Source source = sourceStorage.getSource(gadget);
          uiEditor.setSource(source);
          uiEditor.setDirPath(dirPath);
          uiManagement.getChildren().clear();

Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/jcr/jcr-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/jcr/jcr-configuration.xml	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/jcr/jcr-configuration.xml	2009-12-04 18:07:13 UTC (rev 929)
@@ -106,6 +106,7 @@
  		      <name>namespaces</name>
  		      <property name="dc" value="http://purl.org/dc/elements/1.1/"/>
  		      <property name="mop" value="http://www.gatein.org/jcr/mop/1.0/"/>
+ 		      <property name="app" value="http://www.gatein.org/jcr/app/1.0/"/>
  		      </properties-param>
  		  </init-params>
  		</component-plugin>
@@ -120,7 +121,8 @@
  		      <value>jar:/conf/ext-nodetypes-config.xml</value>
  		      <value>jar:/conf/organization-nodetypes.xml</value>
  		      <value>jar:/conf/mop-nodetypes.xml</value>
-              <value>jar:/conf/portal/portal-nodetypes.xml</value>
+ 		      <value>jar:/conf/application-nodetypes.xml</value>
+          <value>jar:/conf/content-nodetypes.xml</value>
  		    </values-param>
  		  </init-params>
  		</component-plugin>

Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml	2009-12-04 17:17:43 UTC (rev 928)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml	2009-12-04 18:07:13 UTC (rev 929)
@@ -21,6 +21,9 @@
 -->
 <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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.application.gadget.GadgetRegistryService</key>
       <type>org.exoplatform.application.gadget.jcr.GadgetRegistryServiceImpl</type>
@@ -56,10 +59,12 @@
          </properties-param>
       </init-params>
    </component>
+-->
 
    <component>
       <key>org.exoplatform.application.gadget.SourceStorage</key>
-      <type>org.exoplatform.application.gadget.jcr.SourceStorageImpl</type>
+      <type>org.exoplatform.application.gadget.impl.SourceStorageImpl</type>
+<!--
       <init-params>
          <properties-param>
             <name>location</name>
@@ -69,8 +74,46 @@
             <property name="store.path" value="/"/>
          </properties-param>
       </init-params>
+-->
    </component>
 
+  <component>
+    <key>org.exoplatform.application.gadget.GadgetRegistryService</key>
+    <type>org.exoplatform.application.gadget.impl.GadgetRegistryServiceImpl</type>
+    <init-params>
+      <value-param>
+        <name>gadgets.country</name>
+        <description>US</description>
+        <value>US</value>
+      </value-param>
+      <value-param>
+        <name>gadgets.language</name>
+        <description>en</description>
+        <value>en</value>
+      </value-param>
+      <value-param>
+        <name>gadgets.moduleId</name>
+        <description>0</description>
+        <value>0</value>
+      </value-param>
+      <value-param>
+        <name>gadgets.hostName</name>
+        <description>Gadget server url</description>
+        <value>eXoGadgetServer/gadgets</value>
+      </value-param>
+      <properties-param>
+        <name>developerInfo</name>
+        <description>The group that is allowed to develop gadgets</description>
+        <property name="developer.group" value="/platform/administrators"/>
+      </properties-param>
+    </init-params>
+  </component>
+
+  <component>
+     <key>org.exoplatform.application.gadget.GadgetDeployer</key>
+     <type>org.exoplatform.application.gadget.GadgetDeployer</type>
+  </component>
+
    <component>
       <key>org.exoplatform.application.registry.ApplicationRegistryService</key>
       <type>org.exoplatform.application.registry.mop.MOPApplicationRegistryService</type>
@@ -537,7 +580,7 @@
       <init-params>
         <value-param>
           <name>name</name>
-          <value>registry</value>
+          <value>app</value>
         </value-param>
         <value-param>
           <name>workspace-name</name>
@@ -548,6 +591,15 @@
           <value>org.exoplatform.application.registry.mop.ContentRegistry</value>
           <value>org.exoplatform.application.registry.mop.CategoryDefinition</value>
           <value>org.exoplatform.application.registry.mop.ContentDefinition</value>
+          <value>org.exoplatform.application.gadget.impl.GadgetRegistry</value>
+          <value>org.exoplatform.application.gadget.impl.GadgetDefinition</value>
+          <value>org.exoplatform.application.gadget.impl.LocalGadgetData</value>
+          <value>org.exoplatform.application.gadget.impl.RemoteGadgetData</value>
+<!--
+          <value>org.exoplatform.application.gadget.impl.NTFolder</value>
+          <value>org.exoplatform.application.gadget.impl.NTFile</value>
+          <value>org.exoplatform.application.gadget.impl.NTResource</value>
+-->
         </values-param>
       </init-params>
     </component-plugin>



More information about the gatein-commits mailing list