First part of merge from WEB-PROTO-3.0-2 branch - rename of 'web-framework' project to 'webscript-framework' revs 8566:8590

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8757 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-04-14 10:10:43 +00:00
parent 8e7ce5c19c
commit db63dcbc88
2 changed files with 90 additions and 28 deletions

View File

@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="source/java"/> <classpathentry kind="src" path="source/java"/>
<classpathentry kind="src" path="config"/> <classpathentry kind="src" path="config"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/Repository"/> <classpathentry kind="src" path="/Repository"/>
<classpathentry kind="src" path="/Core"/> <classpathentry kind="src" path="/Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Remote API"/> <classpathentry combineaccessrules="false" kind="src" path="/Remote API"/>
<classpathentry kind="lib" path="/3rd Party/lib/commons/commons-httpclient-3.0.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/commons/commons-httpclient-3.0.jar"/>
<classpathentry kind="lib" path="/3rd Party/lib/commons/commons-jxpath-1.2.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/commons/commons-jxpath-1.2.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/3rd Party"/> <classpathentry combineaccessrules="false" kind="src" path="/3rd Party"/>
<classpathentry kind="lib" path="/3rd Party/lib/xercesImpl-2.8.0.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/xercesImpl-2.8.0.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Jndi-Client"/> <classpathentry combineaccessrules="false" kind="src" path="/Jndi-Client"/>
<classpathentry kind="lib" path="/3rd Party/lib/bsf-2.4.0.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/bsf-2.4.0.jar"/>
<classpathentry kind="lib" path="/3rd Party/lib/fop/xmlgraphics-commons-1.2.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/fop/xmlgraphics-commons-1.2.jar"/>
<classpathentry kind="lib" path="/3rd Party/lib/fop/fop-0.94.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/fop/fop-0.94.jar"/>
<classpathentry kind="lib" path="/3rd Party/lib/fop/avalon-framework-4.2.0.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/fop/avalon-framework-4.2.0.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/MBean"/> <classpathentry combineaccessrules="false" kind="src" path="/MBean"/>
<classpathentry kind="lib" path="/3rd Party/lib/chiba-1.3.0.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/chiba-1.3.0.jar"/>
<classpathentry kind="lib" path="/3rd Party/lib/json.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/json.jar"/>
<classpathentry kind="lib" path="/3rd Party/lib/fop/batik-all-1.6.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/fop/batik-all-1.6.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Web-Framework"/> <classpathentry combineaccessrules="false" kind="src" path="/Alfresco JLAN"/>
<classpathentry combineaccessrules="false" kind="src" path="/Alfresco JLAN"/> <classpathentry combineaccessrules="false" kind="src" path="/WebScript Framework"/>
<classpathentry kind="output" path="build/classes"/> <classpathentry kind="output" path="build/classes"/>
</classpath> </classpath>

View File

@@ -308,7 +308,7 @@ public class RepoStore implements Store, TenantDeployer
public String[] execute() throws Exception public String[] execute() throws Exception
{ {
int baseDirLength = getBaseDir().length() +1; int baseDirLength = getBaseDir().length() +1;
List<String> documentPaths = new ArrayList<String>(); List<String> documentPaths = null;
String scriptPath = script.getDescription().getScriptPath(); String scriptPath = script.getDescription().getScriptPath();
NodeRef scriptNodeRef = (scriptPath.length() == 0) ? getBaseNodeRef() : findNodeRef(scriptPath); NodeRef scriptNodeRef = (scriptPath.length() == 0) ? getBaseNodeRef() : findNodeRef(scriptPath);
if (scriptNodeRef != null) 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 id = script.getDescription().getId().substring(scriptPath.length() + (scriptPath.length() > 0 ? 1 : 0));
String query = "+PATH:\"" + repoScriptPath.toPrefixString(namespaceService) + "//*\" +QNAME:" + id + "*"; String query = "+PATH:\"" + repoScriptPath.toPrefixString(namespaceService) + "//*\" +QNAME:" + id + "*";
ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query); ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query);
documentPaths = new ArrayList<String>(resultSet.length());
List<NodeRef> nodes = resultSet.getNodeRefs(); List<NodeRef> nodes = resultSet.getNodeRefs();
for (NodeRef nodeRef : nodes) 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 public String[] execute() throws Exception
{ {
int baseDirLength = getBaseDir().length() +1; int baseDirLength = getBaseDir().length() +1;
List<String> documentPaths = new ArrayList<String>();
String query = "+PATH:\"" + repoPath + "//*\" +QNAME:*.desc.xml"; String query = "+PATH:\"" + repoPath + "//*\" +QNAME:*.desc.xml";
ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query); ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query);
List<String> documentPaths = new ArrayList<String>(resultSet.length());
List<NodeRef> nodes = resultSet.getNodeRefs(); List<NodeRef> nodes = resultSet.getNodeRefs();
for (NodeRef nodeRef : nodes) for (NodeRef nodeRef : nodes)
{ {
@@ -373,6 +374,38 @@ public class RepoStore implements Store, TenantDeployer
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
} }
/* (non-Javadoc)
* @see org.alfresco.web.scripts.Store#getAllDocumentPaths()
*/
public String[] getAllDocumentPaths()
{
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<String[]>()
{
public String[] doWork() throws Exception
{
return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<String[]>()
{
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<String> documentPaths = new ArrayList<String>(resultSet.length());
List<NodeRef> 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) /* (non-Javadoc)
* @see org.alfresco.web.scripts.Store#lastModified(java.lang.String) * @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()); ContentWriter writer = fileService.getWriter(fileInfo.getNodeRef());
writer.putContent(content); 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) /* (non-Javadoc)
* @see org.alfresco.web.scripts.Store#getTemplateLoader() * @see org.alfresco.web.scripts.Store#getTemplateLoader()