Author: julien_viet
Date: 2009-12-04 20:01:21 -0500 (Fri, 04 Dec 2009)
New Revision: 938
Modified:
portal/trunk/component/application-registry/pom.xml
portal/trunk/component/application-registry/src/main/java/conf/application-nodetypes.xml
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/impl/LocalGadgetData.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/impl/ApplicationRegistryChromatticLifeCycle.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticImpl.java
portal/trunk/component/portal/pom.xml
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
portal/trunk/pom.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml
Log:
- updated to mop 1.0.0-Beta12
- updated to chromattic 1.0.0-beta10
- removed the direct Node usage hack and instead use the org.chromattic.ntdef package that
has builtin node type support
Modified: portal/trunk/component/application-registry/pom.xml
===================================================================
--- portal/trunk/component/application-registry/pom.xml 2009-12-04 23:25:44 UTC (rev 937)
+++ portal/trunk/component/application-registry/pom.xml 2009-12-05 01:01:21 UTC (rev 938)
@@ -55,6 +55,12 @@
</dependency>
<dependency>
+ <groupId>org.chromattic</groupId>
+ <artifactId>chromattic.ntdef</artifactId>
+ <version>${version.chromattic}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.gatein.pc</groupId>
<artifactId>pc-api</artifactId>
<version>${org.gatein.pc.version}</version>
Modified:
portal/trunk/component/application-registry/src/main/java/conf/application-nodetypes.xml
===================================================================
---
portal/trunk/component/application-registry/src/main/java/conf/application-nodetypes.xml 2009-12-04
23:25:44 UTC (rev 937)
+++
portal/trunk/component/application-registry/src/main/java/conf/application-nodetypes.xml 2009-12-05
01:01:21 UTC (rev 938)
@@ -81,7 +81,7 @@
</propertyDefinition>
</propertyDefinitions>
<childNodeDefinitions>
- <childNodeDefinition name="resources"
defaultPrimaryType="nt:folder" autoCreated="false"
mandatory="true"
+ <childNodeDefinition name="resources"
defaultPrimaryType="nt:folder" autoCreated="true"
mandatory="true"
onParentVersion="COPY" protected="false"
sameNameSiblings="false">
<requiredPrimaryTypes>
<requiredPrimaryType>nt:folder</requiredPrimaryType>
Modified:
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 2009-12-04
23:25:44 UTC (rev 937)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/LocalImporter.java 2009-12-05
01:01:21 UTC (rev 938)
@@ -22,6 +22,8 @@
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.gadgets.spec.GadgetSpec;
import org.apache.shindig.gadgets.spec.ModulePrefs;
+import org.chromattic.ntdef.NTFolder;
+import org.chromattic.ntdef.Resource;
import org.exoplatform.application.gadget.impl.GadgetDefinition;
import org.exoplatform.application.gadget.impl.GadgetRegistry;
import org.exoplatform.application.gadget.impl.LocalGadgetData;
@@ -30,11 +32,9 @@
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@exoplatform.com">Julien
Viet</a>
@@ -59,7 +59,7 @@
private boolean local;
/** Used temporarily when importing resources. */
- private Node folder;
+ private NTFolder folder;
protected LocalImporter(
String name,
@@ -169,7 +169,7 @@
data.setFileName(fileName);
// Import resource
- folder = data.getNode().addNode("resources", "nt:folder");
+ folder = data.getResources();
String folderPath = getParent(gadgetPath);
visitChildren(folderPath);
folder = null;
@@ -195,24 +195,20 @@
{
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
+ String encoding = null;
if ("application/xml".equals(mimeType))
{
- String encoding = EncodingDetector.detect(new
ByteArrayInputStream(content));
- resource.setProperty("jcr:encoding", encoding);
+ encoding = EncodingDetector.detect(new ByteArrayInputStream(content));
}
+
+ //
+ folder.createFile(name, new Resource(mimeType, encoding, content));
}
}
else
{
- folder = folder.addNode(name, "nt:folder");
+ folder = folder.createFolder(name);
visitChildren(resourcePath);
folder = folder.getParent();
}
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 2009-12-04
23:25:44 UTC (rev 937)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java 2009-12-05
01:01:21 UTC (rev 938)
@@ -21,19 +21,20 @@
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.MappedBy;
import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToOne;
import org.chromattic.api.annotations.Property;
+import org.chromattic.ntdef.NTFile;
+import org.chromattic.ntdef.Resource;
import org.exoplatform.application.gadget.EncodingDetector;
import org.exoplatform.application.registry.impl.NodeAware;
-import org.gatein.common.io.IOTools;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
+import org.chromattic.ntdef.NTFolder;
+
import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Calendar;
+import java.util.Date;
/**
@@ -44,9 +45,6 @@
public abstract class LocalGadgetData extends GadgetData implements NodeAware
{
- /** Temporary hack, use with care. */
- private Node node;
-
@ManyToOne
public abstract GadgetDefinition getDefinition();
@@ -55,27 +53,24 @@
public abstract void setFileName(String fileName);
- public void setNode(Node node)
- {
- this.node = node;
- }
+ @OneToOne
+ @MappedBy("resources")
+ public abstract NTFolder getResources();
- public Node getNode()
- {
- return node;
+ private NTFile getGadgetContent() {
+ String fileName = getFileName();
+ NTFolder resources = getResources();
+ return resources.getFile(fileName);
}
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));
@@ -86,66 +81,22 @@
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());
+ NTFile content = getGadgetContent();
+ content.setContentResource(new Resource("application/xml", encoding,
bytes));
}
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);
+ NTFile content = getGadgetContent();
+ Resource res = content.getContentResource();
+ String encoding = res.getEncoding();
+ byte[] bytes = res.getData();
return new String(bytes, encoding);
}
- public Calendar getLastModified()
+ public Date 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);
- }
+ NTFile content = getGadgetContent();
+ return content.getLastModified();
}
-
- 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);
-*/
}
Modified:
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 2009-12-04
23:25:44 UTC (rev 937)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/SourceStorageImpl.java 2009-12-05
01:01:21 UTC (rev 938)
@@ -18,16 +18,11 @@
*/
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;
/**
@@ -41,10 +36,6 @@
public SourceStorageImpl(GadgetRegistryService gadgetRegistryService)
{
-
- // resources/Calculator.xml
- // resources/rssAggregator.xml
-
this.gadgetRegistryService = (GadgetRegistryServiceImpl)gadgetRegistryService;
}
@@ -64,7 +55,8 @@
{
LocalGadgetData localData = (LocalGadgetData)data;
String content = localData.getSource();
- Calendar lastModified = localData.getLastModified();
+ Calendar lastModified = Calendar.getInstance();
+ lastModified.setTime(localData.getLastModified());
//
Source source = new Source(gadget.getName());
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java 2009-12-04
23:25:44 UTC (rev 937)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java 2009-12-05
01:01:21 UTC (rev 938)
@@ -18,7 +18,6 @@
*/
package org.exoplatform.application.registry.impl;
-import org.chromattic.core.DomainSession;
import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
import org.exoplatform.commons.chromattic.SessionContext;
import org.exoplatform.container.xml.InitParams;
@@ -39,6 +38,6 @@
@Override
protected void onOpenSession(SessionContext context) {
- context.getSession().addEventListener(new Injector(registry,
(DomainSession)context.getSession()));
+ context.getSession().addEventListener(new Injector(registry));
}
}
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java 2009-12-04
23:25:44 UTC (rev 937)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java 2009-12-05
01:01:21 UTC (rev 938)
@@ -19,10 +19,7 @@
package org.exoplatform.application.registry.impl;
import org.chromattic.api.event.LifeCycleListener;
-import org.chromattic.core.DomainSession;
-import javax.jcr.Node;
-
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
@@ -34,12 +31,12 @@
private final ApplicationRegistryServiceImpl registry;
/** . */
- private final DomainSession session;
+// private final DomainSession session;
- public Injector(ApplicationRegistryServiceImpl registry, DomainSession session)
+ public Injector(ApplicationRegistryServiceImpl registry/*, DomainSession session*/)
{
this.registry = registry;
- this.session = session;
+// this.session = session;
}
public void created(Object o)
@@ -48,11 +45,13 @@
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;
@@ -61,11 +60,13 @@
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;
@@ -74,10 +75,12 @@
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/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticImpl.java
===================================================================
---
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticImpl.java 2009-12-04
23:25:44 UTC (rev 937)
+++
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticImpl.java 2009-12-05
01:01:21 UTC (rev 938)
@@ -20,7 +20,6 @@
import org.chromattic.api.Chromattic;
import org.chromattic.api.ChromatticSession;
-import org.chromattic.api.SessionTask;
import javax.jcr.Credentials;
@@ -70,14 +69,4 @@
{
throw new UnsupportedOperationException();
}
-
- public void execute(SessionTask task) throws Throwable
- {
- throw new UnsupportedOperationException();
- }
-
- public void stop()
- {
- throw new UnsupportedOperationException();
- }
}
Modified: portal/trunk/component/portal/pom.xml
===================================================================
--- portal/trunk/component/portal/pom.xml 2009-12-04 23:25:44 UTC (rev 937)
+++ portal/trunk/component/portal/pom.xml 2009-12-05 01:01:21 UTC (rev 938)
@@ -100,6 +100,13 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.chromattic</groupId>
+ <artifactId>chromattic.core</artifactId>
+ <version>${version.chromattic}</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2009-12-04
23:25:44 UTC (rev 937)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2009-12-05
01:01:21 UTC (rev 938)
@@ -323,7 +323,7 @@
throw new Error(e);
}
Class<O> mappedClass = (Class<O>)mapping.get(type);
- return session.createQueryBuilder().from(mappedClass).<O>
where(statement).get().iterator();
+ return session.createQueryBuilder().from(mappedClass).<O>
where(statement).get().objects();
}
private static final Map<ObjectType<?>, Class> mapping = new
HashMap<ObjectType<?>, Class>();
Modified: portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
===================================================================
---
portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js 2009-12-04
23:25:44 UTC (rev 937)
+++
portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js 2009-12-05
01:01:21 UTC (rev 938)
@@ -111,6 +111,7 @@
addDependency(new Project("org.chromattic", "chromattic.spi",
"jar", chromatticVersion)).
addDependency(new Project("org.chromattic", "chromattic.core",
"jar", chromatticVersion)).
addDependency(new Project("org.chromattic", "chromattic.apt",
"jar", chromatticVersion)).
+ addDependency(new Project("org.chromattic", "chromattic.ntdef",
"jar", chromatticVersion)).
addDependency(new Project("org.reflext", "reflext.api",
"jar", reflectVersion)).
addDependency(new Project("org.reflext", "reflext.core",
"jar", reflectVersion)).
addDependency(new Project("org.reflext", "reflext.spi",
"jar", reflectVersion)).
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2009-12-04 23:25:44 UTC (rev 937)
+++ portal/trunk/pom.xml 2009-12-05 01:01:21 UTC (rev 938)
@@ -48,12 +48,12 @@
<org.gatein.pc.version>2.1.0-CR01</org.gatein.pc.version>
<org.picketlink.idm>1.0.0.CR1</org.picketlink.idm>
<org.gatein.wsrp.version>1.0.0-Beta01</org.gatein.wsrp.version>
- <org.gatein.mop.version>1.0.0-Beta11</org.gatein.mop.version>
+ <org.gatein.mop.version>1.0.0-Beta12</org.gatein.mop.version>
<org.slf4j.version>1.5.6</org.slf4j.version>
<rhino.version>1.6R5</rhino.version>
<org.codehaus.groovy.version>1.6.5</org.codehaus.groovy.version>
<javax.servlet.version>2.5</javax.servlet.version>
- <version.chromattic>1.0.0-beta8</version.chromattic>
+ <version.chromattic>1.0.0-beta10</version.chromattic>
<version.reflect>1.0.0-beta4</version.reflect>
<!-- ************** -->
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
23:25:44 UTC (rev 937)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml 2009-12-05
01:01:21 UTC (rev 938)
@@ -545,6 +545,9 @@
<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.chromattic.ntdef.NTFile</value>
+ <value>org.chromattic.ntdef.NTFolder</value>
+ <value>org.chromattic.ntdef.NTResource</value>
</values-param>
</init-params>
</component-plugin>