exo-jcr SVN: r2696 - in jcr/branches/1.12.x/exo.jcr.component.webdav/src: test/java/org/exoplatform/services/jcr/webdav/ext and 1 other directory.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-24 10:59:24 -0400 (Thu, 24 Jun 2010)
New Revision: 2696
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
Log:
EXOJCR-774 Test failing with Unparseable date Exception fixed
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-06-24 10:24:59 UTC (rev 2695)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-06-24 14:59:24 UTC (rev 2696)
@@ -48,6 +48,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
@@ -131,7 +132,7 @@
// check before any other reads
if (ifModifiedSince != null)
{
- DateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN);
+ DateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
Date lastModifiedDate = dateFormat.parse(lastModifiedProperty.getValue());
dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.MODIFICATION);
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java 2010-06-24 10:24:59 UTC (rev 2695)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java 2010-06-24 14:59:24 UTC (rev 2696)
@@ -94,7 +94,7 @@
assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
}
-
+
public void testCacheConf() throws Exception
{
ArrayList<CacheControlType> testValues = new ArrayList<CacheControlType>();
13 years, 10 months
exo-jcr SVN: r2695 - jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-24 06:24:59 -0400 (Thu, 24 Jun 2010)
New Revision: 2695
Modified:
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
Log:
EXOJCR-774 Caching tests activated
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java 2010-06-24 10:14:38 UTC (rev 2694)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java 2010-06-24 10:24:59 UTC (rev 2695)
@@ -32,6 +32,7 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Locale;
import javax.jcr.Node;
import javax.jcr.Property;
@@ -58,7 +59,7 @@
node = TestUtils.addContent(session, path, inputStream, defaultFileNodeType, "");
}
- public void _testNotModifiedSince() throws Exception
+ public void testNotModifiedSince() throws Exception
{
Node contentNode = node.getNode("jcr:content");
Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
@@ -77,7 +78,7 @@
assertEquals(HTTPStatus.OK, response.getStatus());
}
- public void _testIfModifiedSince() throws Exception
+ public void testIfModifiedSince() throws Exception
{
Node contentNode = node.getNode("jcr:content");
Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
@@ -95,6 +96,22 @@
assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
}
+ public void _testNotModifiedSinceFRLocale() throws Exception
+ {
+ Node contentNode = node.getNode("jcr:content");
+ Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
+
+ SimpleDateFormat sdf = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.FRENCH);
+
+ String ifModifiedDate = sdf.format(sdf.getCalendar().getTime());
+
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedDate);
+ ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
+
+ assertEquals(HTTPStatus.OK, response.getStatus());
+ }
+
public void testCacheConf() throws Exception
{
ArrayList<CacheControlType> testValues = new ArrayList<CacheControlType>();
13 years, 10 months
exo-jcr SVN: r2694 - jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-24 06:14:38 -0400 (Thu, 24 Jun 2010)
New Revision: 2694
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
Log:
EXOJCR-774 Test failing with Unparseable date Exception fixed
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-06-23 14:25:54 UTC (rev 2693)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-06-24 10:14:38 UTC (rev 2694)
@@ -48,6 +48,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
@@ -132,7 +133,7 @@
if (ifModifiedSince != null)
{
- DateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN);
+ DateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
Date lastModifiedDate = dateFormat.parse(lastModifiedProperty.getValue());
dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.MODIFICATION);
13 years, 10 months
exo-jcr SVN: r2693 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: util/jdbc and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-23 10:25:54 -0400 (Wed, 23 Jun 2010)
New Revision: 2693
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
Log:
EXOJCR-754: close unclosed ResultSets
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-06-23 14:25:19 UTC (rev 2692)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-06-23 14:25:54 UTC (rev 2693)
@@ -211,7 +211,21 @@
try
{
ResultSet trs = con.getMetaData().getTables(null, null, configTableName, null);
- return trs.next();
+ try
+ {
+ return trs.next();
+ }
+ finally
+ {
+ try
+ {
+ trs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-23 14:25:19 UTC (rev 2692)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-23 14:25:54 UTC (rev 2693)
@@ -173,25 +173,53 @@
protected boolean isTableExists(Connection conn, String tableName) throws SQLException
{
ResultSet trs = conn.getMetaData().getTables(null, null, tableName, null);
- boolean res = false;
- while (trs.next())
+ try
{
- res = true; // check for columns/table type matching etc.
+ boolean res = false;
+ while (trs.next())
+ {
+ res = true; // check for columns/table type matching etc.
+ }
+ return res;
}
- return res;
+ finally
+ {
+ try
+ {
+ trs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
protected boolean isIndexExists(Connection conn, String tableName, String indexName) throws SQLException
{
ResultSet irs = conn.getMetaData().getIndexInfo(null, null, tableName, false, true);
- boolean res = false;
- while (irs.next())
+ try
{
- if (irs.getShort("TYPE") != DatabaseMetaData.tableIndexStatistic
- && irs.getString("INDEX_NAME").equalsIgnoreCase(indexName))
- res = true; // check for index params matching etc.
+ boolean res = false;
+ while (irs.next())
+ {
+ if (irs.getShort("TYPE") != DatabaseMetaData.tableIndexStatistic
+ && irs.getString("INDEX_NAME").equalsIgnoreCase(indexName))
+ res = true; // check for index params matching etc.
+ }
+ return res;
}
- return res;
+ finally
+ {
+ try
+ {
+ irs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
protected boolean isSequenceExists(Connection conn, String sequenceName) throws SQLException
13 years, 10 months
exo-jcr SVN: r2692 - in jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: util/jdbc and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-23 10:25:19 -0400 (Wed, 23 Jun 2010)
New Revision: 2692
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
Log:
EXOJCR-754: close unclosed ResultSets
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-06-23 13:20:24 UTC (rev 2691)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-06-23 14:25:19 UTC (rev 2692)
@@ -211,7 +211,21 @@
try
{
ResultSet trs = con.getMetaData().getTables(null, null, configTableName, null);
- return trs.next();
+ try
+ {
+ return trs.next();
+ }
+ finally
+ {
+ try
+ {
+ trs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-23 13:20:24 UTC (rev 2691)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-23 14:25:19 UTC (rev 2692)
@@ -155,25 +155,53 @@
protected boolean isTableExists(Connection conn, String tableName) throws SQLException
{
ResultSet trs = conn.getMetaData().getTables(null, null, tableName, null);
- boolean res = false;
- while (trs.next())
+ try
{
- res = true; // check for columns/table type matching etc.
+ boolean res = false;
+ while (trs.next())
+ {
+ res = true; // check for columns/table type matching etc.
+ }
+ return res;
}
- return res;
+ finally
+ {
+ try
+ {
+ trs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
protected boolean isIndexExists(Connection conn, String tableName, String indexName) throws SQLException
{
ResultSet irs = conn.getMetaData().getIndexInfo(null, null, tableName, false, true);
- boolean res = false;
- while (irs.next())
+ try
{
- if (irs.getShort("TYPE") != DatabaseMetaData.tableIndexStatistic
- && irs.getString("INDEX_NAME").equalsIgnoreCase(indexName))
- res = true; // check for index params matching etc.
+ boolean res = false;
+ while (irs.next())
+ {
+ if (irs.getShort("TYPE") != DatabaseMetaData.tableIndexStatistic
+ && irs.getString("INDEX_NAME").equalsIgnoreCase(indexName))
+ res = true; // check for index params matching etc.
+ }
+ return res;
}
- return res;
+ finally
+ {
+ try
+ {
+ irs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
protected boolean isSequenceExists(Connection conn, String sequenceName) throws SQLException
13 years, 10 months
exo-jcr SVN: r2691 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-06-23 09:20:24 -0400 (Wed, 23 Jun 2010)
New Revision: 2691
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access/BaseAuthenticator.java
Log:
EXOJCR-779 : ConversationState for anonymous user is created by filter now. Removed useless code from BaseAuthenticator.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access/BaseAuthenticator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access/BaseAuthenticator.java 2010-06-23 13:15:38 UTC (rev 2690)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access/BaseAuthenticator.java 2010-06-23 13:20:24 UTC (rev 2691)
@@ -19,17 +19,12 @@
package org.exoplatform.services.jcr.impl.core.access;
import org.exoplatform.services.jcr.access.AuthenticationPolicy;
-import org.exoplatform.services.jcr.access.SystemIdentity;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.ConversationState;
-import org.exoplatform.services.security.Identity;
import org.exoplatform.services.security.IdentityRegistry;
-import org.exoplatform.services.security.MembershipEntry;
-import java.util.HashSet;
-
import javax.jcr.LoginException;
/**
@@ -59,18 +54,7 @@
*/
public ConversationState authenticate() throws LoginException
{
-
- ConversationState state = ConversationState.getCurrent();
-
- if (state == null)
- {
- log.debug("No current identity found, ANONYMOUS one will be used");
- return new ConversationState(new Identity(SystemIdentity.ANONIM, new HashSet<MembershipEntry>()));
- }
-
- ConversationState.setCurrent(state);
- return state;
-
+ return ConversationState.getCurrent();
}
}
13 years, 10 months
exo-jcr SVN: r2690 - in jcr/trunk/exo.jcr.component.ext/src: main/java/org/exoplatform/services/jcr/ext/resource/jcr and 4 other directories.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-06-23 09:15:38 -0400 (Wed, 23 Jun 2010)
New Revision: 2690
Added:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java
jcr/trunk/exo.jcr.component.ext/src/test/resources/TestDependency.groovy
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/resource/JcrURLConnection.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/resource/jcr/Handler.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoaderTest.java
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
jcr/trunk/exo.jcr.component.ext/src/test/resources/test1.groovy
jcr/trunk/exo.jcr.component.ext/src/test/resources/test2.groovy
Log:
EXOJCR-482 : support for loading dependencies from JCR
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/resource/JcrURLConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/resource/JcrURLConnection.java 2010-06-23 13:11:43 UTC (rev 2689)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/resource/JcrURLConnection.java 2010-06-23 13:15:38 UTC (rev 2690)
@@ -82,7 +82,7 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ //e.printStackTrace();
throw new IOException("Connection refused!");
}
}
@@ -103,7 +103,7 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ //e.printStackTrace();
throw new IOException("can't get input stream");
}
}
@@ -148,7 +148,7 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ //e.printStackTrace();
}
return null;
}
@@ -169,11 +169,14 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ //e.printStackTrace();
}
return -1;
}
+
+
+
/*
* (non-Javadoc)
* @see java.net.URLConnection#setDoOutput(boolean)
@@ -202,7 +205,7 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ //e.printStackTrace();
}
return null;
}
@@ -216,11 +219,14 @@
{
try
{
+ if (!connected)
+ connect();
+
return nodeRepresentation.getLastModified();
}
catch (Exception e)
{
- e.printStackTrace();
+ //e.printStackTrace();
}
return 0;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/resource/jcr/Handler.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/resource/jcr/Handler.java 2010-06-23 13:11:43 UTC (rev 2689)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/resource/jcr/Handler.java 2010-06-23 13:15:38 UTC (rev 2690)
@@ -37,7 +37,7 @@
/**
* URLStreamHandler for protocol <tt>jcr://</tt>.
- *
+ *
* @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
@@ -48,12 +48,13 @@
* This is implements as Startable to be independent from other services. It
* should be guaranty created, and set special system property.
* Static fields repositoryService, nodeRepresentationService should be
- * initialized once when Handler created by container.
+ * initialized once when Handler created by container.
*/
/**
- * It specifies the package prefix name with should be added in System property
- * java.protocol.handler.pkgs. Protocol handlers will be in a class called <tt>jcr</tt>.Handler.
+ * It specifies the package prefix name with should be added in System
+ * property java.protocol.handler.pkgs. Protocol handlers will be in a class
+ * called <tt>jcr</tt>.Handler.
*/
private static final String protocolPathPkg = "org.exoplatform.services.jcr.ext.resource";
@@ -110,10 +111,6 @@
sessionProvider =
(SessionProvider)ConversationState.getCurrent().getAttribute(SessionProvider.SESSION_PROVIDER);
- // if still not set use anonymous session provider
- if (sessionProvider == null)
- sessionProvider = SessionProvider.createAnonimProvider();
-
ManageableRepository repository;
String repositoryName = nodeReference.getRepository();
if (repositoryName == null || repositoryName.length() == 0)
@@ -132,7 +129,7 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ //e.printStackTrace();
throw new IOException("Open connection to URL '" + url.toString() + "' failed!");
}
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java 2010-06-23 13:11:43 UTC (rev 2689)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java 2010-06-23 13:15:38 UTC (rev 2690)
@@ -34,6 +34,7 @@
import org.exoplatform.services.jcr.ext.registry.RegistryService;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.ext.groovy.DefaultGroovyResourceLoader;
import org.exoplatform.services.rest.ext.groovy.GroovyJaxrsPublisher;
import org.exoplatform.services.rest.ext.groovy.ResourceId;
import org.exoplatform.services.rest.impl.ResourceBinder;
@@ -47,13 +48,16 @@
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
@@ -135,10 +139,11 @@
*/
public GroovyScript2RestLoader(ResourceBinder binder, GroovyScriptInstantiator groovyScriptInstantiator,
RepositoryService repositoryService, ThreadLocalSessionProviderService sessionProviderService,
- ConfigurationManager configurationManager, InitParams params)
+ ConfigurationManager configurationManager, org.exoplatform.services.jcr.ext.resource.jcr.Handler jcrUrlHandler,
+ InitParams params)
{
this(binder, groovyScriptInstantiator, repositoryService, sessionProviderService, configurationManager, null,
- new GroovyJaxrsPublisher(binder, groovyScriptInstantiator), params);
+ new GroovyJaxrsPublisher(binder, groovyScriptInstantiator), jcrUrlHandler, params);
}
/**
@@ -152,16 +157,17 @@
*/
public GroovyScript2RestLoader(ResourceBinder binder, GroovyScriptInstantiator groovyScriptInstantiator,
RepositoryService repositoryService, ThreadLocalSessionProviderService sessionProviderService,
- ConfigurationManager configurationManager, RegistryService registryService, InitParams params)
+ ConfigurationManager configurationManager, RegistryService registryService,
+ org.exoplatform.services.jcr.ext.resource.jcr.Handler jcrUrlHandler, InitParams params)
{
this(binder, groovyScriptInstantiator, repositoryService, sessionProviderService, configurationManager,
- registryService, new GroovyJaxrsPublisher(binder, groovyScriptInstantiator), params);
+ registryService, new GroovyJaxrsPublisher(binder, groovyScriptInstantiator), jcrUrlHandler, params);
}
public GroovyScript2RestLoader(ResourceBinder binder, GroovyScriptInstantiator groovyScriptInstantiator,
RepositoryService repositoryService, ThreadLocalSessionProviderService sessionProviderService,
ConfigurationManager configurationManager, RegistryService registryService, GroovyJaxrsPublisher groovyPublisher,
- InitParams params)
+ org.exoplatform.services.jcr.ext.resource.jcr.Handler jcrUrlHandler, InitParams params)
{
this.binder = binder;
this.repositoryService = repositoryService;
@@ -393,6 +399,25 @@
LOG.error("Error occurs ", e);
}
}
+
+ if (addRepoPlugins != null && addRepoPlugins.size() > 0)
+ {
+ try
+ {
+ Set<URL> repos = new HashSet<URL>();
+ for (GroovyScriptAddRepoPlugin pl : addRepoPlugins)
+ {
+ repos.addAll(pl.getRepositories());
+ }
+ this.groovyPublisher.getGroovyClassLoader().setResourceLoader(
+ new JcrGroovyResourceLoader(repos.toArray(new URL[repos.size()])));
+ }
+ catch (MalformedURLException e)
+ {
+ LOG.error("Unable add groovy script repository. ", e);
+ }
+ }
+
// Finally bind this object as RESTful service.
// NOTE this service does not implement ResourceContainer, as usually
// done for this type of services. It can't be binded in common way cause
@@ -414,6 +439,8 @@
*/
protected List<GroovyScript2RestLoaderPlugin> loadPlugins;
+ protected List<GroovyScriptAddRepoPlugin> addRepoPlugins;
+
/**
* @param cp See {@link ComponentPlugin}
*/
@@ -427,6 +454,14 @@
}
loadPlugins.add((GroovyScript2RestLoaderPlugin)cp);
}
+ if (cp instanceof GroovyScriptAddRepoPlugin)
+ {
+ if (addRepoPlugins == null)
+ {
+ addRepoPlugins = new ArrayList<GroovyScriptAddRepoPlugin>();
+ }
+ addRepoPlugins.add((GroovyScriptAddRepoPlugin)cp);
+ }
}
/**
@@ -1316,6 +1351,93 @@
}
/**
+ * JCR groovy resource resolver.
+ */
+ class JcrGroovyResourceLoader extends DefaultGroovyResourceLoader
+ {
+
+ public JcrGroovyResourceLoader(URL[] roots) throws MalformedURLException
+ {
+ super(normalizeJcrURL(roots));
+ }
+
+ @Override
+ protected URL getResource(String filename) throws MalformedURLException
+ {
+ filename = filename.intern();
+ URL resource = null;
+ synchronized (filename)
+ {
+ resource = resources.get(filename);
+ boolean inCache = resource != null;
+ for (URL root : roots)
+ {
+ if (resource == null)
+ {
+ if ("jcr".equals(root.getProtocol()))
+ {
+ // In JCR URL path represented by fragment
+ // jcr://repository/workspace#/path
+ String ref = root.getRef();
+ resource = new URL(root, "#" + ref + filename);
+ }
+ else
+ {
+ resource = new URL(root, filename);
+ }
+ }
+ try
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Try to load resource from URL : " + resource);
+
+ InputStream script = resource.openStream();
+ script.close();
+
+ break;
+ }
+ catch (IOException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Can't open URL : " + resource);
+
+ resource = null;
+ }
+ }
+ if (resource != null)
+ {
+ resources.put(filename, resource);
+ }
+ else if (inCache)
+ {
+ // Remove from map if resource is unreachable
+ resources.remove(filename);
+ }
+ }
+ return resource;
+ }
+ }
+
+ private static URL[] normalizeJcrURL(URL[] src) throws MalformedURLException
+ {
+ URL[] res = new URL[src.length];
+ for (int i = 0; i < src.length; i++)
+ {
+ String ref = src[i].getRef();
+ if (ref == null)
+ {
+ ref = "/";
+ }
+ else if (ref.charAt(ref.length() - 1) != '/')
+ {
+ ref = ref + "/";
+ }
+ res[i] = new URL(src[i], "#" + ref);
+ }
+ return res;
+ }
+
+ /**
* Script metadata, used for pass script metada as JSON.
*/
public static class ScriptMetadata
Added: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java (rev 0)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java 2010-06-23 13:15:38 UTC (rev 2690)
@@ -0,0 +1,74 @@
+/**
+ * Copyright (C) 2010 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.services.jcr.ext.script.groovy;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.PropertiesParam;
+import org.exoplatform.services.jcr.ext.resource.UnifiedNodeReference;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class GroovyScriptAddRepoPlugin extends BaseComponentPlugin
+{
+
+ private final InitParams params;
+
+ public GroovyScriptAddRepoPlugin(InitParams params)
+ {
+ this.params = params;
+ }
+
+ public Collection<URL> getRepositories()
+ {
+ if (params == null)
+ return Collections.emptyList();
+
+ Set<URL> repos = new HashSet<URL>();
+ Iterator<PropertiesParam> iterator = params.getPropertiesParamIterator();
+ while (iterator.hasNext())
+ {
+ PropertiesParam p = iterator.next();
+ String repository = p.getProperty("repository");
+ String workspace = p.getProperty("workspace");
+ String path = p.getProperty("path");
+ try
+ {
+ repos.add(new UnifiedNodeReference(repository, workspace, path).getURL());
+ }
+ catch (MalformedURLException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return repos;
+ }
+}
Property changes on: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoaderTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoaderTest.java 2010-06-23 13:11:43 UTC (rev 2689)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoaderTest.java 2010-06-23 13:15:38 UTC (rev 2690)
@@ -62,6 +62,8 @@
private Node script;
+ private Node groovyRepo;
+
private int resourceNumber = 0;
/**
@@ -87,6 +89,10 @@
script.setProperty("jcr:lastModified", Calendar.getInstance());
script
.setProperty("jcr:data", Thread.currentThread().getContextClassLoader().getResourceAsStream("test1.groovy"));
+
+ // repository for groovy dependencies
+ groovyRepo = root.addNode("repo", "nt:folder");
+
session.save();
}
@@ -286,4 +292,31 @@
handler.handleRequest(creq, cres);
assertEquals(200, cres.getStatus());
}
+
+ public void testGroovyDependency() throws Exception
+ {
+ // Add script in dependency repository
+ Node deps = groovyRepo.addNode("dependencies", "nt:folder");
+ Node dep = deps.addNode("Dep1.groovy", "nt:file");
+ dep = dep.addNode("jcr:content", "nt:resource");
+ dep.setProperty("jcr:mimeType", "script/groovy");
+ dep.setProperty("jcr:lastModified", Calendar.getInstance());
+ dep.setProperty("jcr:data", "package dependencies; class Dep1 { String name = getClass().getName() }");
+
+ script.setProperty("jcr:data", Thread.currentThread().getContextClassLoader().getResourceAsStream(
+ "TestDependency.groovy"));
+
+ session.save();
+
+ // must be rebounded , not created other one
+ assertEquals(resourceNumber + 1, binder.getSize());
+ ContainerRequest creq =
+ new ContainerRequest("GET", new URI("/groovy-test-dependency"), new URI(""), null, new InputHeadersMap(
+ new MultivaluedMapImpl()));
+ ContainerResponse cres = new ContainerResponse(new DummyContainerResponseWriter());
+ handler.handleRequest(creq, cres);
+ assertEquals(200, cres.getStatus());
+ assertEquals("dependencies.Dep1", cres.getEntity());
+
+ }
}
Added: jcr/trunk/exo.jcr.component.ext/src/test/resources/TestDependency.groovy
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/TestDependency.groovy (rev 0)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/TestDependency.groovy 2010-06-23 13:15:38 UTC (rev 2690)
@@ -0,0 +1,16 @@
+package org.exoplatform.groovy.test
+
+import javax.ws.rs.GET
+import javax.ws.rs.Path
+
+import dependencies.Dep1
+
+@Path("groovy-test-dependency")
+public class TestDependency {
+
+ @GET
+ def method() {
+ return new Dep1().getName()
+ }
+
+}
\ No newline at end of file
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2010-06-23 13:11:43 UTC (rev 2689)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2010-06-23 13:15:38 UTC (rev 2690)
@@ -939,6 +939,23 @@
</component>
<external-component-plugins>
+ <target-component>org.exoplatform.services.jcr.ext.script.groovy.GroovyScript2RestLoader</target-component>
+ <component-plugin>
+ <name>add groovy repo</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.ext.script.groovy.GroovyScriptAddRepoPlugin</type>
+ <init-params>
+ <properties-param>
+ <name>repo1</name>
+ <property name="repository" value="db1"/>
+ <property name="workspace" value="ws"/>
+ <property name="path" value="/repo"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+ <external-component-plugins>
<target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
<component-plugin>
<name>bind.datasource</name>
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/test1.groovy
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/test1.groovy 2010-06-23 13:11:43 UTC (rev 2689)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/test1.groovy 2010-06-23 13:15:38 UTC (rev 2690)
@@ -13,9 +13,8 @@
@GET
@Path("/groovy1/{param}/")
- public String method(@PathParam("param") String name) {
- def String resp = "Hello from groovy to " + name
- return resp
+ def method(@PathParam("param") String name) {
+ return "Hello from groovy to " + name
}
}
\ No newline at end of file
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/test2.groovy
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/test2.groovy 2010-06-23 13:11:43 UTC (rev 2689)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/test2.groovy 2010-06-23 13:15:38 UTC (rev 2690)
@@ -13,9 +13,8 @@
@GET
@Path("/groovy2/{param}/")
- public String method(@PathParam("param") String name) {
- def String resp = "Hello from groovy to >>>>> " + name
- return resp
+ def method(@PathParam("param") String name) {
+ return "Hello from groovy to >>>>> " + name
}
}
13 years, 10 months
exo-jcr SVN: r2689 - ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-06-23 09:11:43 -0400 (Wed, 23 Jun 2010)
New Revision: 2689
Modified:
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/DefaultGroovyResourceLoader.java
Log:
EXOJCR-482 : use doPrivileged for loading resources
Modified: ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/DefaultGroovyResourceLoader.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/DefaultGroovyResourceLoader.java 2010-06-23 12:54:39 UTC (rev 2688)
+++ ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/DefaultGroovyResourceLoader.java 2010-06-23 13:11:43 UTC (rev 2689)
@@ -26,13 +26,17 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
- * @version $Id$
+ * @version $Id: DefaultGroovyResourceLoader.java 2680 2010-06-22 11:43:00Z
+ * aparfonov $
*/
public class DefaultGroovyResourceLoader implements GroovyResourceLoader
{
@@ -66,9 +70,32 @@
/**
* {@inheritDoc}
*/
- public URL loadGroovySource(String filename) throws MalformedURLException
+ public final URL loadGroovySource(String classname) throws MalformedURLException
{
- filename = filename.replace('.', File.separatorChar) + ".groovy";
+ final String filename = classname.replace('.', File.separatorChar) + ".groovy";
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<URL>()
+ {
+ public URL run() throws Exception
+ {
+ return getResource(filename);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ Throwable cause = e.getCause();
+ if (cause instanceof Error)
+ throw (Error)cause;
+ if (cause instanceof RuntimeException)
+ throw (RuntimeException)cause;
+ throw (MalformedURLException)cause;
+ }
+ }
+
+ protected URL getResource(String filename) throws MalformedURLException
+ {
filename = filename.intern();
URL resource = null;
synchronized (filename)
@@ -81,7 +108,6 @@
{
resource = new URL(root, filename);
}
- //System.out.println(resource);
try
{
InputStream script = resource.openStream();
@@ -103,6 +129,7 @@
resources.remove(filename);
}
}
+
return resource;
}
13 years, 10 months
exo-jcr SVN: r2688 - core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security/web.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-06-23 08:54:39 -0400 (Wed, 23 Jun 2010)
New Revision: 2688
Modified:
core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security/web/SetCurrentIdentityFilter.java
Log:
EXOJCR-779 : returning new ConversationState for anonymous user now.
Modified: core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security/web/SetCurrentIdentityFilter.java
===================================================================
--- core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security/web/SetCurrentIdentityFilter.java 2010-06-23 12:44:27 UTC (rev 2687)
+++ core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security/web/SetCurrentIdentityFilter.java 2010-06-23 12:54:39 UTC (rev 2688)
@@ -26,6 +26,7 @@
import org.exoplatform.services.security.ConversationRegistry;
import org.exoplatform.services.security.ConversationState;
import org.exoplatform.services.security.Identity;
+import org.exoplatform.services.security.IdentityConstants;
import org.exoplatform.services.security.IdentityRegistry;
import org.exoplatform.services.security.StateKey;
@@ -72,7 +73,9 @@
// NOTE may be set as null
ConversationState.setCurrent(state);
if (state != null && log.isDebugEnabled())
+ {
log.debug(">>> Memberships " + state.getIdentity().getMemberships());
+ }
chain.doFilter(request, response);
}
finally
@@ -138,7 +141,9 @@
state.setAttribute(ConversationState.SUBJECT, identity.getSubject());
}
else
+ {
log.error("Not found identity in IdentityRegistry for user " + userId + ", check Login Module.");
+ }
if (state != null)
{
@@ -151,6 +156,10 @@
}
}
}
+ else
+ {
+ state = new ConversationState(new Identity(IdentityConstants.ANONIM));
+ }
return state;
}
13 years, 10 months
exo-jcr SVN: r2687 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-06-23 08:44:27 -0400 (Wed, 23 Jun 2010)
New Revision: 2687
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/SystemIdentity.java
Log:
EXOJCR-780 : org.exoplatform.services.jcr.access.SystemIdentity class moved to org.exoplatform.services.security in core.component.security project, called IdentityConstants to avoid same-name classes. Needed for EXOJCR-779 . Class at org.exoplatform.services.jcr.access.SystemIdentity is now marked as deprecated and actually is just a wrapper over org.exoplatform.services.security.IdentityConstants from core project.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/SystemIdentity.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/SystemIdentity.java 2010-06-23 12:41:50 UTC (rev 2686)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/SystemIdentity.java 2010-06-23 12:44:27 UTC (rev 2687)
@@ -18,20 +18,18 @@
*/
package org.exoplatform.services.jcr.access;
+import org.exoplatform.services.security.IdentityConstants;
+
/**
* Created by The eXo Platform SAS.
+ * Please use {@link IdentityConstants} instead.
*
* @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady Azarenkov</a>
* @version $Id: SystemIdentity.java 11907 2008-03-13 15:36:21Z ksm $
*/
-public class SystemIdentity
+@Deprecated
+public class SystemIdentity extends IdentityConstants
{
- public static final String ANY = "any".intern();
-
- public static final String SYSTEM = "__system".intern();
-
- public static final String ANONIM = "__anonim".intern();
-
}
13 years, 10 months