From do-not-reply at jboss.org Tue Nov 29 06:55:15 2011
Content-Type: multipart/mixed; boundary="===============3658278186007603731=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r5243 -
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy.
Date: Tue, 29 Nov 2011 06:55:14 -0500
Message-ID: <201111291155.pATBtEQO013634@svn01.web.mwc.hst.phx2.redhat.com>
--===============3658278186007603731==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: areshetnyak
Date: 2011-11-29 06:55:14 -0500 (Tue, 29 Nov 2011)
New Revision: 5243
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/ext/script/groovy/GroovyScript2RestLoaderPlugin.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/ext/script/groovy/GroovyScriptAddRepoPlugin.java
Log:
EXOJCR-1659 : GroovyScriptAddRepoPlugin and the GroovyScript2RestLoaderPlug=
in are used current repository if repository name was not previously config=
ured.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/script/groovy/GroovyScript2RestLoaderPlugin.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/script/groovy/GroovyScript2RestLoaderPlugin.java 2011-11-29 09:32:4=
1 UTC (rev 5242)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/script/groovy/GroovyScript2RestLoaderPlugin.java 2011-11-29 11:55:1=
4 UTC (rev 5243)
@@ -21,6 +21,7 @@
import org.exoplatform.container.component.BaseComponentPlugin;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
+import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
=
@@ -28,6 +29,8 @@
import java.util.Iterator;
import java.util.List;
=
+import javax.jcr.RepositoryException;
+
/**
* @author Andrey Parfonov
* @version $Id: GroovyScript2RestLoaderPlugin.java 34445 2009-07-24 07:51=
:18Z dkatayev $
@@ -38,6 +41,9 @@
/** Logger. */
private static final Log LOG =3D ExoLogger.getLogger("exo.jcr.component=
.ext.GroovyScript2RestLoaderPlugin");
=
+ /** Repository service **/
+ private static RepositoryService repositoryService;
+
/** Configurations for scripts what were got from XML. */
private List l =3D new ArrayList();
=
@@ -51,9 +57,12 @@
private String node;
=
@SuppressWarnings("unchecked")
- public GroovyScript2RestLoaderPlugin(InitParams params)
+ public GroovyScript2RestLoaderPlugin(InitParams params, RepositoryServi=
ce repoServiceo)
{
- repository =3D params.getValueParam("repository").getValue();
+ this.repositoryService =3D repoServiceo;
+
+ repository =3D params.containsKey("repository") ? params.getValuePar=
am("repository").getValue() : null;
+
workspace =3D params.getValueParam("workspace").getValue();
node =3D params.getValueParam("node").getValue();
Iterator iterator =3D params.getPropertiesParamIter=
ator();
@@ -75,11 +84,30 @@
}
=
/**
- * @return the repository
+ * Get working repository name. Returns the repository name from config=
uration =
+ * if it previously configured and returns the name of current reposito=
ry in other case.
+ *
+ * @return String
+ * repository name
+ * @throws RepositoryException
*/
public String getRepository()
{
- return repository;
+ if (repository =3D=3D null)
+ {
+ try
+ {
+ return repositoryService.getCurrentRepository().getConfigurati=
on().getName();
+ }
+ catch (RepositoryException e)
+ {
+ throw new RuntimeException("Can not get current repository and=
repository name was not configured", e);
+ }
+ }
+ else
+ {
+ return repository;
+ }
}
=
/**
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java 2011-11-29 09:32:41 UT=
C (rev 5242)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java 2011-11-29 11:55:14 UT=
C (rev 5243)
@@ -23,6 +23,7 @@
import org.exoplatform.container.component.BaseComponentPlugin;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
+import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.ext.resource.UnifiedNodeReference;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -37,6 +38,8 @@
import java.util.Iterator;
import java.util.Set;
=
+import javax.jcr.RepositoryException;
+
/**
* @author Andrey Parfonov
* @version $Id$
@@ -49,9 +52,12 @@
=
private final InitParams params;
=
- public GroovyScriptAddRepoPlugin(InitParams params)
+ private final RepositoryService repositoryService;
+
+ public GroovyScriptAddRepoPlugin(InitParams params, RepositoryService r=
epoService)
{
this.params =3D params;
+ this.repositoryService =3D repoService;
}
=
@SuppressWarnings("unchecked")
@@ -65,7 +71,8 @@
while (iterator.hasNext())
{
PropertiesParam p =3D iterator.next();
- final String repository =3D p.getProperty("repository");
+ final String repository =3D getWorkingRepositoryName(p);
+
final String workspace =3D p.getProperty("workspace");
final String path =3D p.getProperty("path");
try
@@ -87,4 +94,34 @@
}
return repos;
}
+
+ /**
+ * Get working repository name. Returns the repository name from config=
uration =
+ * if it previously configured and returns the name of current reposito=
ry in other case.
+ *
+ * @props PropertiesParam
+ * the properties parameters =
+ * @return String
+ * repository name
+ * @throws RepositoryException
+ */
+ private String getWorkingRepositoryName(PropertiesParam props)
+ {
+ =
+ if (props.getProperty("repository") =3D=3D null)
+ {
+ try
+ {
+ return repositoryService.getCurrentRepository().getConfigurati=
on().getName();
+ }
+ catch (RepositoryException e)
+ {
+ throw new RuntimeException("Can not get current repository and=
repository name was not configured", e);
+ }
+ }
+ else
+ {
+ return props.getProperty("repository");
+ }
+ }
}
--===============3658278186007603731==--