Author: areshetnyak
Date: 2011-11-29 03:51:25 -0500 (Tue, 29 Nov 2011)
New Revision: 5241
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java
Log:
EXOJCR-1659 : GroovyScript2Rest was used current repository if repository name was not
previously configured.
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 2011-11-25
12:38:43 UTC (rev 5240)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java 2011-11-29
08:51:25 UTC (rev 5241)
@@ -277,7 +277,8 @@
try
{
// Deploy auto-load scripts and start Observation Listeners.
- final String repositoryName =
observationListenerConfiguration.getRepository();
+ final String repositoryName = getWorkingRepositoryName();
+
List<String> workspaceNames =
observationListenerConfiguration.getWorkspaces();
final ManageableRepository repository =
repositoryService.getRepository(repositoryName);
@@ -370,7 +371,7 @@
private void autoLoadScripts(Session session) throws RepositoryException
{
String workspaceName = session.getWorkspace().getName();
- String repositoryName = observationListenerConfiguration.getRepository();
+ String repositoryName = getWorkingRepositoryName();
String xpath = "//element(*, " + getNodeType() +
")[@exo:autoload='true']";
Query query = session.getWorkspace().getQueryManager().createQuery(xpath,
Query.XPATH);
@@ -570,8 +571,11 @@
observationListenerConfiguration.setWorkspaces(wsList);
LOG.info("NodeType from RegistryService: " + getNodeType());
- LOG.info("Repository from RegistryService: " +
observationListenerConfiguration.getRepository());
- LOG.info("Workspaces node from RegistryService: " +
observationListenerConfiguration.getWorkspaces());
+ LOG.info("Repository name from RegistryService: "
+ + (observationListenerConfiguration.getRepository() != null ?
observationListenerConfiguration.getRepository()
+ : "not configured, will be used the current one"));
+
+ LOG.info("List of workspaces from RegistryService: " +
observationListenerConfiguration.getWorkspaces());
}
/**
@@ -688,8 +692,11 @@
LOG.info("NodeType from configuration file: " + getNodeType());
if (observationListenerConfiguration != null)
{
- LOG.info("Repository from configuration file: " +
observationListenerConfiguration.getRepository());
- LOG.info("Workspaces node from configuration file: " +
observationListenerConfiguration.getWorkspaces());
+ LOG.info("Repository name from configuration file: "
+ + (observationListenerConfiguration.getRepository() != null ?
observationListenerConfiguration
+ .getRepository() : "not configured, will be used the current
one"));
+
+ LOG.info("List of workspaces from configuration file: " +
observationListenerConfiguration.getWorkspaces());
}
}
@@ -1525,6 +1532,26 @@
}
/**
+ * Get working repository name. Returns the repository name from configuration
+ * if it previously configured and returns the name of current repository in other
case.
+ *
+ * @return String
+ * repository name
+ * @throws RepositoryException
+ */
+ private String getWorkingRepositoryName() throws RepositoryException
+ {
+ if (observationListenerConfiguration.getRepository() == null)
+ {
+ return repositoryService.getCurrentRepository().getConfiguration().getName();
+ }
+ else
+ {
+ return observationListenerConfiguration.getRepository();
+ }
+ }
+
+ /**
* Extract path to node's parent from full path.
*
* @param fullPath full path to node
Show replies by date