Fix for ETHREEOH-100, cleanup to some webscripts as ETHREEOH-100 now fixed.

Basic "people" API for FreeMarker - just getPerson() and getGroup() currently.
Template cache size and delay now configurable in RepositoryTemplateProcessor (like they already are in PresentationTemplateProcessor) - related default cache size tweaks.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13788 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2009-03-31 19:42:31 +00:00
parent dbec12a9c7
commit 2c43d8eb06
7 changed files with 122 additions and 101 deletions

View File

@@ -38,4 +38,3 @@ function main()
} }
main(); main();

View File

@@ -1,5 +1,5 @@
<#macro membershipJSON site role person> <#macro membershipJSON site role person>
<#escape x as jsonUtils.encodeJSONString(x)> <#escape x as jsonUtils.encodeJSONString(x)>
{ {
"role" : "${role}", "role" : "${role}",
"person": "person":
@@ -20,5 +20,5 @@
}, },
"url" : "${url.serviceContext + "/api/sites/" + site.shortName + "/memberships/" + person.properties.userName}" "url" : "${url.serviceContext + "/api/sites/" + site.shortName + "/memberships/" + person.properties.userName}"
} }
</#escape> </#escape>
</#macro> </#macro>

View File

@@ -15,17 +15,17 @@ var peopleList = Array(memberships.length);
for (userName in memberships) for (userName in memberships)
{ {
var person = people.getPerson(userName); var person = people.getPerson(userName);
peopleList["_" + userName] = person; // make sure the keys are strings // make sure the keys are strings - as usernames may be all numbers!
peopleList['_' + userName] = person;
} }
// also copy over the memberships. // also copy over the memberships.
var mems = {}; var mems = {};
var pos = 0; // memberships[userName] won't return the correct value if userName is a digit-only value
for (userName in memberships) for (userName in memberships)
{ {
var membershipType = memberships[pos]; var membershipType = memberships[userName];
mems["_" + userName] = membershipType; // make sure the keys are strings // make sure the keys are strings - as usernames may be all numbers!
pos++; mems['_' + userName] = membershipType;
} }
// Pass the information to the template // Pass the information to the template

View File

@@ -64,11 +64,14 @@ public class RepositoryTemplateProcessor extends FreeMarkerProcessor
protected String defaultEncoding; protected String defaultEncoding;
protected Configuration templateConfig; protected Configuration templateConfig;
protected FreeMarkerProcessor freeMarkerProcessor; protected FreeMarkerProcessor freeMarkerProcessor;
private int updateDelay = 0;
private int cacheSize = 512;
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.repo.template.FreeMarkerProcessor#setDefaultEncoding(java.lang.String) * @see org.alfresco.repo.template.FreeMarkerProcessor#setDefaultEncoding(java.lang.String)
*/ */
@Override
public void setDefaultEncoding(String defaultEncoding) public void setDefaultEncoding(String defaultEncoding)
{ {
this.defaultEncoding = defaultEncoding; this.defaultEncoding = defaultEncoding;
@@ -82,6 +85,25 @@ public class RepositoryTemplateProcessor extends FreeMarkerProcessor
return this.defaultEncoding; return this.defaultEncoding;
} }
/**
* @param updateDelay the time in seconds between checks on the modified date for cached templates
*/
public void setUpdateDelay(int updateDelay)
{
this.updateDelay = updateDelay;
}
/**
* @param cacheSize the size of the MRU template cache, default is 256
*/
public void setCacheSize(int cacheSize)
{
if (cacheSize >= 0)
{
this.cacheSize = cacheSize;
}
}
/** /**
* @param searchPath * @param searchPath
*/ */
@@ -151,8 +173,8 @@ public class RepositoryTemplateProcessor extends FreeMarkerProcessor
Configuration config = new Configuration(); Configuration config = new Configuration();
// setup template cache // setup template cache
config.setCacheStorage(new MruCacheStorage(20, 100)); config.setCacheStorage(new MruCacheStorage(this.cacheSize, this.cacheSize << 1));
config.setTemplateUpdateDelay(0); config.setTemplateUpdateDelay(updateDelay);
// setup template loaders // setup template loaders
List<TemplateLoader> loaders = new ArrayList<TemplateLoader>(); List<TemplateLoader> loaders = new ArrayList<TemplateLoader>();