mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- model changes
- adding freemarker expression for output path patterns - enabling using the same rendering engine template with multiple mime types - extracting rendering engine template from rendering engine to make moving to templateservice easier eventually git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4351 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
package org.alfresco.web.forms;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.faces.context.FacesContext;
|
||||
import org.alfresco.model.WCMModel;
|
||||
import org.alfresco.repo.avm.AVMRemote;
|
||||
@@ -41,51 +39,8 @@ public abstract class AbstractRenderingEngine
|
||||
protected static final String ALFRESCO_NS = "http://www.alfresco.org/alfresco";
|
||||
protected static final String ALFRESCO_NS_PREFIX = "alfresco";
|
||||
|
||||
private final NodeRef nodeRef;
|
||||
protected final NodeService nodeService;
|
||||
protected final ContentService contentService;
|
||||
|
||||
protected AbstractRenderingEngine(final NodeRef nodeRef,
|
||||
final NodeService nodeService,
|
||||
final ContentService contentService)
|
||||
protected AbstractRenderingEngine()
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
this.nodeService = nodeService;
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the node ref for the rendering engine template.
|
||||
*
|
||||
* @return the node ref for the rendering engine template.
|
||||
*/
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.nodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file extension to use for generated assets.
|
||||
*
|
||||
* @return the file extension to use for generated assets.
|
||||
*/
|
||||
public String getFileExtensionForRendition()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.nodeRef,
|
||||
WCMModel.PROP_FILE_EXTENSION_FOR_RENDITION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file extension to use for generated assets.
|
||||
*
|
||||
* @return the file extension to use for generated assets.
|
||||
*/
|
||||
public String getMimetypeForRendition()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.nodeRef,
|
||||
WCMModel.PROP_MIMETYPE_FOR_RENDITION);
|
||||
}
|
||||
|
||||
protected static AVMRemote getAVMRemote()
|
||||
@@ -101,48 +56,4 @@ public abstract class AbstractRenderingEngine
|
||||
{
|
||||
return new FormDataFunctions(AbstractRenderingEngine.getAVMRemote());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the provided path to an absolute path within the avm.
|
||||
*
|
||||
* @param parentAVMPath used as the parent path if the provided path
|
||||
* is relative, otherwise used to extract the parent path portion up until
|
||||
* the webapp directory.
|
||||
* @param path a path relative to the parentAVMPath path, or if it is
|
||||
* absolute, it is relative to the webapp used in the parentAVMPath.
|
||||
*
|
||||
* @return an absolute path within the avm using the paths provided.
|
||||
*/
|
||||
protected static String toAVMPath(final String parentAVMPath, final String path)
|
||||
{
|
||||
String parent = parentAVMPath;
|
||||
if (path == null ||
|
||||
path.length() == 0 ||
|
||||
".".equals(path) ||
|
||||
"./".equals(path))
|
||||
{
|
||||
return parentAVMPath;
|
||||
}
|
||||
|
||||
if (path.charAt(0) == '/')
|
||||
{
|
||||
final Pattern p = Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE +
|
||||
"/[^/]+/[^/]+).*");
|
||||
final Matcher m = p.matcher(parentAVMPath);
|
||||
if (m.matches())
|
||||
{
|
||||
parent = m.group(1);
|
||||
}
|
||||
}
|
||||
else if (parentAVMPath.charAt(parentAVMPath.length() - 1) != '/')
|
||||
{
|
||||
parent = parent + '/';
|
||||
}
|
||||
|
||||
final String result = parent + path;
|
||||
LOGGER.debug("built full avmPath " + result +
|
||||
" for parent " + parentAVMPath +
|
||||
" and request path " + path);
|
||||
return result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user