Author: chris.laprun(a)jboss.com
Date: 2011-08-09 05:36:57 -0400 (Tue, 09 Aug 2011)
New Revision: 7025
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
Log:
- Finished implementation, though createGadget method is completely untested and probably
doesn't work properly.
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-09
09:19:28 UTC (rev 7024)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-09
09:36:57 UTC (rev 7025)
@@ -22,6 +22,9 @@
package org.gatein.portal.api.impl.content;
+import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.application.gadget.Source;
+import org.exoplatform.application.gadget.SourceStorage;
import org.exoplatform.application.registry.ApplicationCategory;
import org.exoplatform.application.registry.ApplicationRegistryService;
import org.gatein.api.content.Category;
@@ -272,7 +275,34 @@
public Gadget createGadget(String gadget, String source)
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ try
+ {
+ gateIn.begin();
+ final GadgetRegistryService gadgetService = gateIn.getGadgetService();
+ org.exoplatform.application.gadget.Gadget original =
gadgetService.getGadget(gadget);
+ if (original == null)
+ {
+ original = new org.exoplatform.application.gadget.Gadget();
+ original.setName(gadget);
+ original.setUrl("http://www.gatein.org"); // todo: fix me
+ gadgetService.saveGadget(original);
+ }
+
+ SourceStorage sourceStorage = gateIn.getSourceStorage();
+ Source originalSource = sourceStorage.getSource(original);
+ originalSource.setTextContent(source);
+ sourceStorage.saveSource(original, originalSource);
+
+ return (Gadget)newContentFrom(gateIn.gadgetId(gadget), original, Gadget.class);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
}
public IterableIdentifiableCollection<Content> getAll()
@@ -412,11 +442,13 @@
public int size()
{
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ // todo: optimize
+ return getAll().size();
}
public <U extends Content> boolean contains(Id<U> id)
{
- return false; //To change body of implemented methods use File | Settings | File
Templates.
+ // todo: optimize
+ return get(id) != null;
}
}
Show replies by date