06-01-2012 09:45 AM
<html>
<head>
<title>Folder ${folder.displayPath}/${folder.name}</title>
</head>
<body>
Alfresco ${server.edition} Edition v${server.version} : dir
<p>
Contents of folder ${folder.displayPath}/${folder.name}
<p>
<table>
<#list folder.children as child>
<tr>
<td><#if child.isContainer>d</#if></td>
<#if verbose>
<td>${child.properties.modifier}</td>
<td><#if child.isDocument>
${child.properties.content.size}</#if></td>
<td>${child.properties.modified?date}</td>
</#if>
<td>${child.name}</td>
</tr>
</#list>
</table>
</body>
</html>
06-04-2012 03:13 AM
06-04-2012 10:07 AM
06-04-2012 10:30 AM
Hi,
Did you register your Java-based web script as spring bean?
This is important for the Web Script Framework to locate your script.
Regards,
Blaz
06-05-2012 04:05 AM
06-05-2012 05:51 AM
Hi,
try this:1) put your class into a jar under alfresco classpath namely under tomcat/webapps/alfresco/WEB-INF/lib
Hope this helps
2) put the javadir.desc.xml and javadir.get.html.ftl under tomcat/webapps/alfresco/extension/templates/webscripts
3) as stated by point 2.c) Place the Spring Framework configuration file into the extension classpath of the Alfresco content application server, so under tomcat/webapps/alfresco/extension
4) be sure that the javadir-context.xml is correctly configured
Regards
06-05-2012 05:55 AM
/alfresco-4.0.d/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension
If you don't have one you can create it.06-05-2012 09:09 AM
Sorry the correct path for steps 2 and 3 isIf you don't have one you can create it./alfresco-4.0.d/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension
In your jar put the compiled class only.
I have one since I install my application as an AMP module.
Regards
03-08-2013 10:25 AM
package org.example;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.repo.model.Repository;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
public class JavaDir extends DeclarativeWebScript
{
private Repository repository;
public void setRepository(Repository repository)
{
this.repository = repository;
}
protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status, Cache cache)
{
NodeRef folder;
// extract folder listing arguments from URI
String verboseArg = req.getParameter("verbose");
Boolean verbose = Boolean.parseBoolean(verboseArg);
Map<String, String> templateArgs =
req.getServiceMatch().getTemplateVars();
String folderPath = templateArgs.get("folderpath");
if (folderPath.equals("Company Home")){
folder = repository.getCompanyHome();
}
else {
String nodePath = "workspace/SpacesStore/" + folderPath;
folder = repository.findNodeRef("path", nodePath.split("/"));
}
// validate that folder has been found
if (folder == null)
{
throw new WebScriptException(Status.STATUS_NOT_FOUND,
"Folder " + folderPath + " not found");
}
// construct model for response template to render
Map<String, Object> model = new HashMap<String, Object>();
model.put("verbose", verbose);
model.put("folder", folder);
return model;
}
}
06-05-2012 10:01 AM
String folderPath = templateArgs.get("folderpath");
String nodePath = "workspace/SpacesStore/" + folderPath;
NodeRef folder = repository.findNodeRef("path", nodePath.split("/"));
The findNodeRef method javadoc states:public org.alfresco.service.cmr.repository.NodeRef findNodeRef(java.lang.String referenceType,
java.lang.String[] reference)
Helper to convert a Web Script Request URL to a Node Ref
1) Node - {store_type}/{store_id}/{node_id}
Resolve to node via its Node Reference.
2) Path - {store_type}/{store_id}/{path}
Resolve to node via its display path.
3) AVM Path - {store_id}/{path}
Resolve to AVM node via its display path
4) QName - {store_type}/{store_id}/{child_qname_path} TODO: Implement
Resolve to node via its child qname path.
Parameters:
referenceType - one of node, path, avmpath or qname
Returns:
reference array of reference segments (as described above for each reference type)
You might also take a look at the Alfresco Node Browser to find out other information about these folders.Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.