diff --git a/.classpath b/.classpath
index 416de11e4f..684bb572de 100644
--- a/.classpath
+++ b/.classpath
@@ -1,25 +1,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/java/org/alfresco/repo/web/scripts/RepoStore.java b/source/java/org/alfresco/repo/web/scripts/RepoStore.java
index 1fa69b46b0..d00dde97f1 100644
--- a/source/java/org/alfresco/repo/web/scripts/RepoStore.java
+++ b/source/java/org/alfresco/repo/web/scripts/RepoStore.java
@@ -308,7 +308,7 @@ public class RepoStore implements Store, TenantDeployer
public String[] execute() throws Exception
{
int baseDirLength = getBaseDir().length() +1;
- List documentPaths = new ArrayList();
+ List documentPaths = null;
String scriptPath = script.getDescription().getScriptPath();
NodeRef scriptNodeRef = (scriptPath.length() == 0) ? getBaseNodeRef() : findNodeRef(scriptPath);
if (scriptNodeRef != null)
@@ -317,6 +317,7 @@ public class RepoStore implements Store, TenantDeployer
String id = script.getDescription().getId().substring(scriptPath.length() + (scriptPath.length() > 0 ? 1 : 0));
String query = "+PATH:\"" + repoScriptPath.toPrefixString(namespaceService) + "//*\" +QNAME:" + id + "*";
ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query);
+ documentPaths = new ArrayList(resultSet.length());
List nodes = resultSet.getNodeRefs();
for (NodeRef nodeRef : nodes)
{
@@ -330,7 +331,7 @@ public class RepoStore implements Store, TenantDeployer
}
}
- return documentPaths.toArray(new String[documentPaths.size()]);
+ return documentPaths != null ? documentPaths.toArray(new String[documentPaths.size()]) : new String[0];
}
});
}
@@ -351,10 +352,10 @@ public class RepoStore implements Store, TenantDeployer
public String[] execute() throws Exception
{
int baseDirLength = getBaseDir().length() +1;
- List documentPaths = new ArrayList();
String query = "+PATH:\"" + repoPath + "//*\" +QNAME:*.desc.xml";
ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query);
+ List documentPaths = new ArrayList(resultSet.length());
List nodes = resultSet.getNodeRefs();
for (NodeRef nodeRef : nodes)
{
@@ -373,6 +374,38 @@ public class RepoStore implements Store, TenantDeployer
}, AuthenticationUtil.getSystemUserName());
}
+ /* (non-Javadoc)
+ * @see org.alfresco.web.scripts.Store#getAllDocumentPaths()
+ */
+ public String[] getAllDocumentPaths()
+ {
+ return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork()
+ {
+ public String[] doWork() throws Exception
+ {
+ return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback()
+ {
+ public String[] execute() throws Exception
+ {
+ int baseDirLength = getBaseDir().length() +1;
+
+ String query = "+PATH:\"" + repoPath + "//*\" +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"";
+ ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query);
+ List documentPaths = new ArrayList(resultSet.length());
+ List nodes = resultSet.getNodeRefs();
+ for (NodeRef nodeRef : nodes)
+ {
+ String nodeDir = getPath(nodeRef);
+ documentPaths.add(nodeDir.substring(baseDirLength));
+ }
+
+ return documentPaths.toArray(new String[documentPaths.size()]);
+ }
+ });
+ }
+ }, AuthenticationUtil.getSystemUserName());
+ }
+
/* (non-Javadoc)
* @see org.alfresco.web.scripts.Store#lastModified(java.lang.String)
*/
@@ -478,6 +511,35 @@ public class RepoStore implements Store, TenantDeployer
ContentWriter writer = fileService.getWriter(fileInfo.getNodeRef());
writer.putContent(content);
}
+
+ /* (non-Javadoc)
+ * @see org.alfresco.web.scripts.Store#updateDocument(java.lang.String, java.lang.String)
+ */
+ public void updateDocument(String documentPath, String content) throws IOException
+ {
+ String[] pathElements = documentPath.split("/");
+
+ // get parent folder
+ NodeRef parentRef;
+ if (pathElements.length == 1)
+ {
+ parentRef = getBaseNodeRef();
+ }
+ else
+ {
+ parentRef = findNodeRef(documentPath.substring(0, documentPath.lastIndexOf('/')));
+ }
+
+ // update file
+ String fileName = pathElements[pathElements.length -1];
+ if (fileService.searchSimple(parentRef, fileName) == null)
+ {
+ throw new IOException("Document " + documentPath + " does not exists");
+ }
+ FileInfo fileInfo = fileService.create(parentRef, fileName, ContentModel.TYPE_CONTENT);
+ ContentWriter writer = fileService.getWriter(fileInfo.getNodeRef());
+ writer.putContent(content);
+ }
/* (non-Javadoc)
* @see org.alfresco.web.scripts.Store#getTemplateLoader()