mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Web Scripts:
- samples - fix "execute" javascript error - fix hidden exception when status template had errors - addition of 'roothome' script & template root object git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6011 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,7 +32,7 @@ ok> get <path>
|
|||||||
|
|
||||||
<path> URL relative to /alfresco/service
|
<path> URL relative to /alfresco/service
|
||||||
|
|
||||||
e.g. get /blog/category?c=Web20
|
e.g. get /blog/search?q=tutorial
|
||||||
|
|
||||||
ok> put <path>
|
ok> put <path>
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ Back to [[HTTP API]].
|
|||||||
|
|
||||||
Welcome to the reference documentation for the Alfresco [[HTTP API]].
|
Welcome to the reference documentation for the Alfresco [[HTTP API]].
|
||||||
|
|
||||||
This document was generated from the URL
|
This document was generated from the Alfresco Server URL
|
||||||
|
|
||||||
GET <nowiki>http://</nowiki><host>:<port>${url.service}
|
GET <nowiki>http://</nowiki><host>:<port>${url.service}
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ on ${date?datetime} using Alfresco v${server.version}.
|
|||||||
|
|
||||||
= Web Script Reference =
|
= Web Script Reference =
|
||||||
|
|
||||||
This section provides technical information for all ${webscripts?size} [[Web Scripts]], organised by Web Script Package.
|
This section provides technical information for all ${webscripts?size} [[Web Scripts]], organized by Web Script Package.
|
||||||
|
|
||||||
Documentation for each Web Script includes:
|
Documentation for each Web Script includes:
|
||||||
|
|
||||||
|
@@ -34,7 +34,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.alfresco.repo.jscript.ScriptNode;
|
|
||||||
import org.alfresco.repo.jscript.ScriptableHashMap;
|
import org.alfresco.repo.jscript.ScriptableHashMap;
|
||||||
import org.alfresco.repo.template.AbsoluteUrlMethod;
|
import org.alfresco.repo.template.AbsoluteUrlMethod;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
@@ -226,16 +225,21 @@ public abstract class AbstractWebScript implements WebScript
|
|||||||
if (getDescription().getRequiredAuthentication() != RequiredAuthentication.none &&
|
if (getDescription().getRequiredAuthentication() != RequiredAuthentication.none &&
|
||||||
getDescription().getRequiredTransaction() != RequiredTransaction.none)
|
getDescription().getRequiredTransaction() != RequiredTransaction.none)
|
||||||
{
|
{
|
||||||
|
NodeRef rootHome = scriptContext.getRootHome();
|
||||||
|
if (rootHome != null)
|
||||||
|
{
|
||||||
|
model.put("roothome", rootHome);
|
||||||
|
}
|
||||||
NodeRef companyHome = scriptContext.getCompanyHome();
|
NodeRef companyHome = scriptContext.getCompanyHome();
|
||||||
if (companyHome != null)
|
if (companyHome != null)
|
||||||
{
|
{
|
||||||
model.put("companyhome", new ScriptNode(scriptContext.getCompanyHome(), serviceRegistry));
|
model.put("companyhome", companyHome);
|
||||||
}
|
}
|
||||||
NodeRef person = scriptContext.getPerson();
|
NodeRef person = scriptContext.getPerson();
|
||||||
if (person != null)
|
if (person != null)
|
||||||
{
|
{
|
||||||
model.put("person", new ScriptNode(person, serviceRegistry));
|
model.put("person", person);
|
||||||
model.put("userhome", new ScriptNode(scriptContext.getUserHome(person), serviceRegistry));
|
model.put("userhome", scriptContext.getUserHome(person));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,10 +277,15 @@ public abstract class AbstractWebScript implements WebScript
|
|||||||
if (getDescription().getRequiredAuthentication() != RequiredAuthentication.none &&
|
if (getDescription().getRequiredAuthentication() != RequiredAuthentication.none &&
|
||||||
getDescription().getRequiredTransaction() != RequiredTransaction.none)
|
getDescription().getRequiredTransaction() != RequiredTransaction.none)
|
||||||
{
|
{
|
||||||
|
NodeRef rootHome = scriptContext.getRootHome();
|
||||||
|
if (rootHome != null)
|
||||||
|
{
|
||||||
|
model.put("roothome", rootHome);
|
||||||
|
}
|
||||||
NodeRef companyHome = scriptContext.getCompanyHome();
|
NodeRef companyHome = scriptContext.getCompanyHome();
|
||||||
if (companyHome != null)
|
if (companyHome != null)
|
||||||
{
|
{
|
||||||
model.put("companyhome", scriptContext.getCompanyHome());
|
model.put("companyhome", companyHome);
|
||||||
}
|
}
|
||||||
NodeRef person = scriptContext.getPerson();
|
NodeRef person = scriptContext.getPerson();
|
||||||
if (person != null)
|
if (person != null)
|
||||||
@@ -316,7 +325,10 @@ public abstract class AbstractWebScript implements WebScript
|
|||||||
*/
|
*/
|
||||||
final protected void renderTemplate(String templatePath, Map<String, Object> model, Writer writer)
|
final protected void renderTemplate(String templatePath, Map<String, Object> model, Writer writer)
|
||||||
{
|
{
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
getWebScriptRegistry().getTemplateProcessor().process(templatePath, model, writer);
|
getWebScriptRegistry().getTemplateProcessor().process(templatePath, model, writer);
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Rendered template " + templatePath + " in " + (System.currentTimeMillis() - start) + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -521,7 +533,10 @@ public abstract class AbstractWebScript implements WebScript
|
|||||||
*/
|
*/
|
||||||
final protected void executeScript(ScriptLocation location, Map<String, Object> model)
|
final protected void executeScript(ScriptLocation location, Map<String, Object> model)
|
||||||
{
|
{
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
getWebScriptRegistry().getScriptProcessor().executeScript(location, model);
|
getWebScriptRegistry().getScriptProcessor().executeScript(location, model);
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Executed script " + location.toString() + " in " + (System.currentTimeMillis() - start) + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -105,7 +105,7 @@ public class ScriptProcessor
|
|||||||
*/
|
*/
|
||||||
public Object executeScript(ScriptLocation location, Map<String, Object> model)
|
public Object executeScript(ScriptLocation location, Map<String, Object> model)
|
||||||
{
|
{
|
||||||
return scriptService.executeScript(location, model);
|
return scriptService.executeScript("javascript", location, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.web.scripts;
|
package org.alfresco.web.scripts;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.alfresco.repo.template.FreeMarkerProcessor;
|
import org.alfresco.repo.template.FreeMarkerProcessor;
|
||||||
@@ -123,8 +124,13 @@ public class TemplateProcessor extends FreeMarkerProcessor implements Applicatio
|
|||||||
Template template = templateConfig.getTemplate(templatePath);
|
Template template = templateConfig.getTemplate(templatePath);
|
||||||
hasTemplate = (template != null);
|
hasTemplate = (template != null);
|
||||||
}
|
}
|
||||||
|
catch(FileNotFoundException e)
|
||||||
|
{
|
||||||
|
// NOTE: return false as template is not found
|
||||||
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
|
throw new WebScriptException("Failed to retrieve template " + templatePath, e);
|
||||||
}
|
}
|
||||||
return hasTemplate;
|
return hasTemplate;
|
||||||
}
|
}
|
||||||
|
@@ -188,6 +188,17 @@ public class WebScriptContext implements ApplicationContextAware, ApplicationLis
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the root home of the company home store
|
||||||
|
*
|
||||||
|
* @return root node ref
|
||||||
|
*/
|
||||||
|
public NodeRef getRootHome()
|
||||||
|
{
|
||||||
|
return nodeService.getRootNode(companyHomeStore);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Company Home
|
* Gets the Company Home
|
||||||
*
|
*
|
||||||
@@ -224,5 +235,5 @@ public class WebScriptContext implements ApplicationContextAware, ApplicationLis
|
|||||||
{
|
{
|
||||||
return (NodeRef)nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER);
|
return (NodeRef)nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user