. Fix to issue in login page redirect code where URL arguments (e.g. for templates and scripts) were removed and not passed through.

- this only affected the template/command servlets that were using parameters and had not already logged in

. Support for 'path' argument on DownloadContentServlet
  for example /alfresco/download/direct?path=/Company%20Home/Kev's%20Home%20Space/myimage.jpg
  - paths are specified in a similar way to webdav path - they are 'cm:name' based URL encoded strings
  - this means we no longer need to have the NodeRef to a document to download it

. Support for 'templatePath' and 'contextPath' URL arguments in TemplateContentServlet
  for example: /alfresco/template?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/doc_info.ftl&contextPath=/Company%20Home/file.txt
  - the 'templatePath' argument specifies the cm:name based path to the template to execute
  - the 'contextPath' argument specifies the cm:name based path to the context for the template

. Support for 'scriptPath' and 'contextPath' URL arguments in Script CommandProcessor
  for example: /alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/Scripts/append%20copyright.js&contextPath=/Company%20Home/file.txt
  - the 'scriptPath' argument specifies the cm:name based path to the script to execute
  - the 'contextPath' argument specifies the cm:name based path to the context for the script

. Adding debugging output to get timings for executing templates and scripts

. Enhancements and additions to JavaScript API:
  setPermission()
  removePermission()
  get/setInheritsPermissions()

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3297 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-07-11 10:13:30 +00:00
parent 8af011cd6d
commit 08f4586da7
8 changed files with 252 additions and 71 deletions

View File

@@ -16,11 +16,15 @@
*/
package org.alfresco.web.app.servlet.command;
import org.alfresco.service.ServiceRegistry;
import java.util.Map;
import javax.servlet.ServletContext;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Repository;
/**
* Initial implementation of a Command Processor that is always passed enough URL elements
@@ -37,21 +41,21 @@ public abstract class BaseNodeCommandProcessor implements CommandProcessor
protected NodeRef targetRef;
/**
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(org.alfresco.service.ServiceRegistry, java.lang.String, java.lang.String[])
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
*/
public boolean validateArguments(ServiceRegistry serviceRegistry, String command, String[] args)
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements)
{
if (args.length < 3)
if (urlElements.length < 3)
{
throw new IllegalArgumentException("Not enough URL arguments passed to command servlet.");
}
// get NodeRef to the node with the workflow attached to it
StoreRef storeRef = new StoreRef(args[0], args[1]);
this.targetRef = new NodeRef(storeRef, args[2]);
StoreRef storeRef = new StoreRef(urlElements[0], urlElements[1]);
this.targetRef = new NodeRef(storeRef, urlElements[2]);
// get the services we need to execute the workflow command
PermissionService permissionService = serviceRegistry.getPermissionService();
PermissionService permissionService = Repository.getServiceRegistry(sc).getPermissionService();
// check that the user has at least READ access on the node - else redirect to the login page
return (permissionService.hasPermission(this.targetRef, PermissionService.READ) == AccessStatus.ALLOWED);

View File

@@ -17,9 +17,10 @@
package org.alfresco.web.app.servlet.command;
import java.io.PrintWriter;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.alfresco.service.ServiceRegistry;
@@ -45,13 +46,15 @@ public interface CommandProcessor
* convert the supplied arguments to the objects it expects, and also check any permissions
* that are required by the current user to execute the command.
*
* @param serviceRegistry ServiceRegistry instance
* @param sc ServletContext, can be used to retrieve ServiceRegistry instance
* from the Repository bean.
* @param command Name of the command the arguments are for
* @param args String[] of the remaining URL arguments to the command servlet.
* @param args Map of URL args passed to the command servlet
* @param urlElements String[] of the remaining URL arguments to the command servlet
*
* @return true if the command can be executed by the current user given the supplied args.
*/
public boolean validateArguments(ServiceRegistry serviceRegistry, String command, String[] args);
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements);
/**
* Process the supplied command name. It is the responsibility of the Command Processor

View File

@@ -21,6 +21,7 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -31,6 +32,8 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.BaseServlet;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User;
/**
@@ -42,6 +45,9 @@ import org.alfresco.web.bean.repository.User;
*/
public final class ScriptCommandProcessor implements CommandProcessor
{
private static final String ARG_SCRIPT_PATH = "scriptPath";
private static final String ARG_CONTEXT_PATH = "contextPath";
private NodeRef scriptRef;
private NodeRef docRef;
private Object result;
@@ -52,29 +58,47 @@ public final class ScriptCommandProcessor implements CommandProcessor
CommandFactory.getInstance().registerCommand("execute", ExecuteScriptCommand.class);
}
/**
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(org.alfresco.service.ServiceRegistry, java.lang.String, java.lang.String[])
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
*/
public boolean validateArguments(ServiceRegistry serviceRegistry, String command, String[] args)
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements)
{
if (args.length < 3)
boolean allowed = false;
String scriptPath = args.get(ARG_SCRIPT_PATH);
if (scriptPath != null)
{
throw new IllegalArgumentException("Not enough URL arguments passed to command servlet.");
// resolve path to a node
this.scriptRef = BaseServlet.resolveNamePath(sc, scriptPath).NodeRef;
// same for the document context path if specified
String docPath = args.get(ARG_CONTEXT_PATH);
if (docPath != null)
{
this.docRef = BaseServlet.resolveNamePath(sc, docPath).NodeRef;
}
}
// get NodeRef to the node script to execute
StoreRef storeRef = new StoreRef(args[0], args[1]);
this.scriptRef = new NodeRef(storeRef, args[2]);
if (args.length >= 6)
else
{
storeRef = new StoreRef(args[3], args[4]);
this.docRef = new NodeRef(storeRef, args[5]);
if (urlElements.length < 3)
{
throw new IllegalArgumentException("Not enough URL arguments passed to command servlet.");
}
// get NodeRef to the node script to execute
StoreRef storeRef = new StoreRef(urlElements[0], urlElements[1]);
this.scriptRef = new NodeRef(storeRef, urlElements[2]);
if (urlElements.length >= 6)
{
storeRef = new StoreRef(urlElements[3], urlElements[4]);
this.docRef = new NodeRef(storeRef, urlElements[5]);
}
}
// check we can access the nodes specified
PermissionService ps = serviceRegistry.getPermissionService();
boolean allowed = (ps.hasPermission(this.scriptRef, PermissionService.READ) == AccessStatus.ALLOWED);
PermissionService ps = Repository.getServiceRegistry(sc).getPermissionService();
allowed = (ps.hasPermission(this.scriptRef, PermissionService.READ) == AccessStatus.ALLOWED);
if (this.docRef != null)
{
allowed &= (ps.hasPermission(this.docRef, PermissionService.READ) == AccessStatus.ALLOWED);

View File

@@ -21,7 +21,6 @@ import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.ServiceRegistry;