Author: ndkhoiits
Date: 2011-08-16 06:25:46 -0400 (Tue, 16 Aug 2011)
New Revision: 7151
Added:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calculator/images/
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calculator/images/Calculator.gif
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calendar/images/
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calendar/images/Calendar.gif
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Todo/images/
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Todo/images/Todo.gif
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/images/
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/images/rssAggregator.png
Modified:
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/GadgetImporter.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegistryService.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.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/GadgetRegistryServiceImpl.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calculator/Calculator.xml
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calendar/Calendar.xml
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Todo/Todo.xml
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/rssAggregator.xml
Log:
GTNPORTAL-2025 Could not display local gadget thumbnail properly
Re-organize gadget resources
Modified:
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 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetDeployer.java 2011-08-16
10:25:46 UTC (rev 7151)
@@ -132,7 +132,8 @@
importer = new ServletLocalImporter(
gadgetName,
path,
- scontext);
+ scontext,
+ gadgetRegistryService);
}
else
{
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetImporter.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetImporter.java 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetImporter.java 2011-08-16
10:25:46 UTC (rev 7151)
@@ -65,7 +65,7 @@
protected abstract byte[] getGadgetBytes(String gadgetURI) throws IOException;
- protected abstract String getGadgetURL(String gadgetURI) throws Exception;
+ protected abstract String getGadgetURL() throws Exception;
protected abstract void process(String gadgetURI, GadgetDefinition def) throws
Exception;
@@ -92,6 +92,9 @@
log.error("Cannot import gadget " + gadgetURI + " because its
data could not be found");
return;
}
+
+ //
+ process(gadgetURI, def);
// Get encoding
String encoding = EncodingDetector.detect(new ByteArrayInputStream(bytes));
@@ -100,7 +103,7 @@
String gadget = new String(bytes, encoding);
//
- String gadgetURL = getGadgetURL(gadgetURI);
+ String gadgetURL = getGadgetURL();
GadgetSpec spec = new GadgetSpec(Uri.parse(gadgetURL), gadget);
ModulePrefs prefs = spec.getModulePrefs();
@@ -117,12 +120,9 @@
//
def.setDescription(description);
- def.setThumbnail(thumbnail); // Do something better than that
+ def.setThumbnail(thumbnail);
def.setTitle(title);
def.setReferenceURL(referenceURL);
-
- //
- process(gadgetURI, def);
}
@Override
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegistryService.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegistryService.java 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/GadgetRegistryService.java 2011-08-16
10:25:46 UTC (rev 7151)
@@ -19,6 +19,8 @@
package org.exoplatform.application.gadget;
+import org.exoplatform.application.gadget.impl.GadgetDefinition;
+
import java.util.Comparator;
import java.util.List;
@@ -100,4 +102,17 @@
public String getModuleId();
public String getHostName();
+
+ /**
+ * Get the URL of gadget from gadget definition. There are 2 kind of gadget:
+ * <p>
+ * <ul>
+ * <li>Local gadget: Gadget definition and resource are stored in JCR workspace.
This gadget content can be also accessed by WebDAV
+ * <li>Remote gadget: An absolute link to gadget definition
+ * </ul>
+ *
+ * @param gadgetName
+ * @return link to local gadget definition stored in JCR or URL to remote gadget
+ */
+ public String getGadgetURL(String gadgetName);
}
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java 2011-08-16
10:25:46 UTC (rev 7151)
@@ -46,9 +46,9 @@
}
@Override
- protected String getGadgetURL(String gadgetURI) throws Exception
+ protected String getGadgetURL() throws Exception
{
- return "http://www.gatein.org";
+ return getGadgetURI();
}
@Override
Modified:
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 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/ServletLocalImporter.java 2011-08-16
10:25:46 UTC (rev 7151)
@@ -47,16 +47,20 @@
/** Used temporarily when importing resources. */
private NTFolder folder;
+
+ private GadgetRegistryService gadgetService;
public ServletLocalImporter(
String name,
String gadgetPath,
- ServletContext servletContext)
+ ServletContext servletContext,
+ GadgetRegistryService gadgetRegistryService)
{
super(name, gadgetPath);
//
this.servletContext = servletContext;
+ this.gadgetService = gadgetRegistryService;
}
@Override
@@ -66,13 +70,13 @@
}
@Override
- protected String getGadgetURL(String gadgetURI) throws Exception
+ protected String getGadgetURL() throws Exception
{
- return gadgetURI;
+ return gadgetService.getGadgetURL(getGadgetName());
}
@Override
- protected void process(String gadgetURI, GadgetDefinition def) throws Exception
+ protected void process(String gadgetPath, GadgetDefinition def) throws Exception
{
def.setLocal(true);
@@ -80,13 +84,13 @@
LocalGadgetData data = (LocalGadgetData)def.getData();
//
- String fileName = getName(gadgetURI);
+ String fileName = getName(gadgetPath);
data.setFileName(fileName);
// Import resource
folder = data.getResources();
- String folderPath = getParent(gadgetURI);
- visitChildren(gadgetURI, folderPath);
+ String folderPath = getParent(gadgetPath);
+ visitChildren(gadgetPath, folderPath);
folder = null;
}
Modified:
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 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2011-08-16
10:25:46 UTC (rev 7151)
@@ -28,6 +28,7 @@
import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticManager;
import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.container.xml.ValueParam;
@@ -235,6 +236,34 @@
//
registry.removeGadget(name);
}
+
+ public String getGadgetURL(String gadgetName)
+ {
+ String url;
+ GadgetData data = this.getRegistry().getGadget(gadgetName).getData();
+ if (data instanceof LocalGadgetData)
+ {
+ LocalGadgetData localData = (LocalGadgetData) data;
+ url = "/" + PortalContainer.getCurrentRestContextName() +
"/" + getJCRGadgetURL(localData);
+ }
+ else if (data instanceof RemoteGadgetData)
+ {
+ RemoteGadgetData remoteData = (RemoteGadgetData)data;
+ url = remoteData.getURL();
+ }
+ else
+ {
+ throw new IllegalStateException("Gadget has to be instance of
LocalGadgetData or RemoteGadgetData");
+ }
+
+ return url;
+ }
+
+ private String getJCRGadgetURL(LocalGadgetData data)
+ {
+ return "jcr/" + chromatticLifeCycle.getRepositoryName() + "/" +
chromatticLifeCycle.getWorkspaceName()
+ + data.getPath() + "/app:resources/" + data.getFileName();
+ }
private void saveGadget(GadgetDefinition def, Gadget gadget)
{
@@ -253,10 +282,7 @@
if (data instanceof LocalGadgetData)
{
LocalGadgetData localData = (LocalGadgetData)data;
- url =
- "jcr/" + chromatticLifeCycle.getRepositoryName() + "/" +
- chromatticLifeCycle.getWorkspaceName() +
"/production/app:gadgets/app:" + def.getName() +
- "/app:data/app:resources/" + localData.getFileName();
+ url = getJCRGadgetURL(localData);
}
else
{
@@ -308,7 +334,7 @@
/** . */
private final GadgetImporter importer;
-
+
private DeployTask(GadgetImporter importer)
{
this.importer = importer;
Modified:
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 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java 2011-08-16
10:25:46 UTC (rev 7151)
@@ -62,6 +62,9 @@
protected abstract void setResources(NTFolder resources);
+ @Path
+ public abstract String getPath();
+
private NTFile getGadgetContent() {
String fileName = getFileName();
NTFolder resources = getResources();
Modified:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calculator/Calculator.xml
===================================================================
---
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calculator/Calculator.xml 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calculator/Calculator.xml 2011-08-16
10:25:46 UTC (rev 7151)
@@ -34,7 +34,7 @@
directory_title="Calculator"
title_url="http://www.exoplatform.org"
description="This simple and useful calculator lets you perform most
of the basic arithmetic operations."
-
thumbnail="http://localhost:8080/eXoGadgets/skin/DefaultSkin/portletIcons/Calculator.png"
+ thumbnail="images/Calculator.gif"
height="227">
<Locale lang="ar" language_direction="rtl"/>
</ModulePrefs>
Added:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calculator/images/Calculator.gif
===================================================================
(Binary files differ)
Property changes on:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calculator/images/Calculator.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calendar/Calendar.xml
===================================================================
---
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calendar/Calendar.xml 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calendar/Calendar.xml 2011-08-16
10:25:46 UTC (rev 7151)
@@ -34,7 +34,7 @@
directory_title="Calendar"
title_url="http://www.exoplatform.org"
description="What date is it? Use this cool calendar to keep track of the date in
style. You can switch easily between daily, monthly or yearly view."
- thumbnail="http://localhost:8080/eXoGadgets/skin/DefaultSkin/portletIcons/Calendar.png"
+ thumbnail="images/Calendar.gif"
height="205">
<Locale lang="ar" language_direction="rtl"/>
</ModulePrefs>
Added:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calendar/images/Calendar.gif
===================================================================
(Binary files differ)
Property changes on:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Calendar/images/Calendar.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Todo/Todo.xml
===================================================================
--- portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Todo/Todo.xml 2011-08-16
10:05:35 UTC (rev 7150)
+++ portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Todo/Todo.xml 2011-08-16
10:25:46 UTC (rev 7151)
@@ -34,7 +34,7 @@
directory_title="Todo"
title_url="http://www.exoplatform.org"
description="ToDo Gadget, easily manage and track your daily to-do list."
- thumbnail="http://localhost:8080/eXoGadgets/skin/DefaultSkin/portletIcons/Todo.png"
+ thumbnail="images/Todo.gif"
height="235">
<Locale messages="locale/ALL_ALL.xml" />
<Locale lang="ar" messages="locale/ar_ALL.xml"
language_direction="rtl"/>
Added: portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Todo/images/Todo.gif
===================================================================
(Binary files differ)
Property changes on:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/Todo/images/Todo.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/images/rssAggregator.png
===================================================================
(Binary files differ)
Property changes on:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/images/rssAggregator.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified:
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/rssAggregator.xml
===================================================================
---
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/rssAggregator.xml 2011-08-16
10:05:35 UTC (rev 7150)
+++
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/rssAggregator.xml 2011-08-16
10:25:46 UTC (rev 7151)
@@ -23,7 +23,7 @@
<Module>
<ModulePrefs title="RSS Reader"
title_url="http://www.exoplatform.com" directory_title="RSS Reader"
description="RSS Reader"
- thumbnail="/eXoGadgets/skin/DefaultSkin/portletIcons/rssAggregator.png">
+ thumbnail="images/rssAggregator.png">
<Require feature="dynamic-height" />
<Require feature="setprefs"/>
<Require feature="settitle"/>