- got extension functions working from freemarker with namespaces. there's still the caveat that you need to use the ftl tag to include the alfresco namespace if you're using extension functions and want the file name from getXMLDocuments, but other than that it's pretty much exactly what i wanted and mimics the xsl environment perfectly.

- beginning slowly to move to new and hopefully finalized terminology.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4171 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-10-20 00:56:09 +00:00
parent 11e6bdeda1
commit e808801107
10 changed files with 293 additions and 97 deletions

View File

@@ -31,6 +31,13 @@ import java.io.*;
import java.util.Map;
import java.util.HashMap;
/**
* Common implementation of functions called in the context of FormDataRenderers.
* This uses AVMRemote rather than AVMService so that in can be used in the context
* of both the alfresco webapp and the virtualization server.
*
* @author Ariel Backenroth
*/
public class ExtensionFunctions
{
private static final Log LOGGER = LogFactory.getLog(ExtensionFunctions.class);
@@ -44,6 +51,12 @@ public class ExtensionFunctions
this.avmRemote = avmRemote;
}
/**
* Loads and parses an xml document at the specified path using avm remote.
*
* @param avmPath a path within the avm repository.
* @return the parsed document.
*/
public Document getXMLDocument(final String avmPath)
throws IOException,
SAXException
@@ -64,12 +77,20 @@ public class ExtensionFunctions
}
}
public Map<String, Document> getXMLDocuments(final String templateTypeName, final String avmPath)
/**
* Loads and parses all xml documents at the specified path generated by the
* specified form using avm remote.
*
* @param formName a form name
* @param avmPath a path within the avm repository.
* @return the parsed document.
*/
public Map<String, Document> getXMLDocuments(final String formName, final String avmPath)
throws IOException,
SAXException
{
final Map<String, AVMNodeDescriptor> entries =
this.avmRemote.getDirectoryListing(-1, avmPath);
final Map<String, AVMNodeDescriptor> entries =
this.avmRemote.getDirectoryListing(-1, avmPath);
final DocumentBuilder db = this.getDocumentBuilder();
final Map<String, Document> result = new HashMap<String, Document>();
for (Map.Entry<String, AVMNodeDescriptor> entry : entries.entrySet())
@@ -84,7 +105,7 @@ public class ExtensionFunctions
WCMModel.PROP_FORM_DERIVED_FROM_NAME);
if (pv == null ||
pv.getStringValue() == null ||
!((String)pv.getStringValue()).equals(templateTypeName))
!((String)pv.getStringValue()).equals(formName))
{
// it's not generated by the same template type
continue;