mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.0 to HEAD
5497: cwd variable and forminstancedata 5512: AR-1303 MLPropertyInterceptor 5527: CIFS invalid characters git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5543 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,6 +21,7 @@ import java.io.File;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
@@ -590,12 +591,44 @@ public class AVMEditBean
|
|||||||
|
|
||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
LOGGER.debug("regenerating renditions of " + fid);
|
LOGGER.debug("regenerating renditions of " + fid);
|
||||||
|
String originalParentAvmPath = (String)
|
||||||
|
this.nodeService.getProperty(((FormInstanceDataImpl)fid).getNodeRef(),
|
||||||
|
WCMAppModel.PROP_ORIGINAL_PARENT_PATH);
|
||||||
|
if (originalParentAvmPath == null)
|
||||||
|
{
|
||||||
|
originalParentAvmPath = AVMNodeConverter.SplitBase(avmPath)[0];
|
||||||
|
}
|
||||||
|
final HashSet<RenderingEngineTemplate> allRets =
|
||||||
|
new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
|
||||||
|
|
||||||
for (RenderingEngineTemplate ret : this.getForm().getRenderingEngineTemplates())
|
// regenerate existing renditions
|
||||||
|
for (final Rendition r : fid.getRenditions())
|
||||||
|
{
|
||||||
|
final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
|
||||||
|
if (!allRets.contains(ret))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ret.render(fid, r);
|
||||||
|
allRets.remove(ret);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Utils.addErrorMessage("error regenerating rendition using " + ret.getName() +
|
||||||
|
": " + e.getMessage(),
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// render all renditions for newly added templates
|
||||||
|
for (final RenderingEngineTemplate ret : allRets)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ret.render(fid);
|
final String path = ret.getOutputPathForRendition(fid, originalParentAvmPath);
|
||||||
|
ret.render(fid, path);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@@ -465,16 +465,16 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
LOGGER.debug("saving file content to " + fileName);
|
LOGGER.debug("saving file content to " + fileName);
|
||||||
|
|
||||||
String path = this.avmBrowseBean.getCurrentPath();
|
final String cwd = AVMConstants.getCorrespondingPathInPreviewStore(this.avmBrowseBean.getCurrentPath());
|
||||||
path = AVMConstants.getCorrespondingPathInPreviewStore(path);
|
|
||||||
final Form form = (MimetypeMap.MIMETYPE_XML.equals(this.mimeType)
|
final Form form = (MimetypeMap.MIMETYPE_XML.equals(this.mimeType)
|
||||||
? this.getForm()
|
? this.getForm()
|
||||||
: null);
|
: null);
|
||||||
|
String path = null;
|
||||||
if (form != null)
|
if (form != null)
|
||||||
{
|
{
|
||||||
path = form.getOutputPathForFormInstanceData(this.instanceDataDocument,
|
path = form.getOutputPathForFormInstanceData(this.instanceDataDocument,
|
||||||
fileName,
|
fileName,
|
||||||
path,
|
cwd,
|
||||||
this.avmBrowseBean.getWebapp());
|
this.avmBrowseBean.getWebapp());
|
||||||
this.content = XMLUtil.toString(this.instanceDataDocument, false);
|
this.content = XMLUtil.toString(this.instanceDataDocument, false);
|
||||||
final String[] sb = AVMNodeConverter.SplitBase(path);
|
final String[] sb = AVMNodeConverter.SplitBase(path);
|
||||||
@@ -513,6 +513,7 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
};
|
};
|
||||||
props.clear();
|
props.clear();
|
||||||
props.put(WCMAppModel.PROP_PARENT_FORM_NAME, form.getName());
|
props.put(WCMAppModel.PROP_PARENT_FORM_NAME, form.getName());
|
||||||
|
props.put(WCMAppModel.PROP_ORIGINAL_PARENT_PATH, cwd);
|
||||||
this.nodeService.addAspect(formInstanceDataNodeRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA, props);
|
this.nodeService.addAspect(formInstanceDataNodeRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA, props);
|
||||||
|
|
||||||
this.renditions = new LinkedList<Rendition>();
|
this.renditions = new LinkedList<Rendition>();
|
||||||
@@ -520,7 +521,8 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.renditions.add(ret.render(this.formInstanceData));
|
path = ret.getOutputPathForRendition(this.formInstanceData, cwd);
|
||||||
|
this.renditions.add(ret.render(this.formInstanceData, path));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@@ -154,6 +154,7 @@ public class FormImpl
|
|||||||
root.put("xml", NodeModel.wrap(formInstanceData));
|
root.put("xml", NodeModel.wrap(formInstanceData));
|
||||||
root.put("name", formInstanceDataName);
|
root.put("name", formInstanceDataName);
|
||||||
root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME));
|
root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME));
|
||||||
|
root.put("cwd", AVMConstants.getWebappRelativePath(parentAVMPath));
|
||||||
|
|
||||||
final TemplateService templateService = this.getServiceRegistry().getTemplateService();
|
final TemplateService templateService = this.getServiceRegistry().getTemplateService();
|
||||||
|
|
||||||
|
@@ -69,9 +69,13 @@ public interface RenderingEngineTemplate
|
|||||||
/**
|
/**
|
||||||
* Returns the output path for the rendition.
|
* Returns the output path for the rendition.
|
||||||
*
|
*
|
||||||
|
* @param formInstanceData the form instance data to use for
|
||||||
|
* processing the pattern.
|
||||||
|
* @param currentAVMPath the current path where the form is being created.
|
||||||
* @return the output path for the rendition.
|
* @return the output path for the rendition.
|
||||||
*/
|
*/
|
||||||
public String getOutputPathForRendition(final FormInstanceData formInstanceData);
|
public String getOutputPathForRendition(final FormInstanceData formInstanceData,
|
||||||
|
final String currentAVMPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the mimetype to use when generating content for this
|
* Returns the mimetype to use when generating content for this
|
||||||
@@ -87,8 +91,10 @@ public interface RenderingEngineTemplate
|
|||||||
*
|
*
|
||||||
* @param formInstanceData the form instance data for which to produce
|
* @param formInstanceData the form instance data for which to produce
|
||||||
* the rendition.
|
* the rendition.
|
||||||
|
* @param renditionAVMPath the path to use for the rendition.
|
||||||
*/
|
*/
|
||||||
public Rendition render(final FormInstanceData formInstanceData)
|
public Rendition render(final FormInstanceData formInstanceData,
|
||||||
|
final String renditionAVMPath)
|
||||||
throws IOException,
|
throws IOException,
|
||||||
SAXException,
|
SAXException,
|
||||||
RenderingEngine.RenderingException;
|
RenderingEngine.RenderingException;
|
||||||
|
@@ -178,9 +178,12 @@ public class RenderingEngineTemplateImpl
|
|||||||
* Generates an output path for the rendition by compiling the output path pattern
|
* Generates an output path for the rendition by compiling the output path pattern
|
||||||
* as a freemarker template.
|
* as a freemarker template.
|
||||||
*
|
*
|
||||||
|
* @param formInstanceData the form instance data to use for the rendition path.
|
||||||
|
* @param currentAVMPath the current path in which the form is being created.
|
||||||
|
*
|
||||||
* @return the output path to use for renditions.
|
* @return the output path to use for renditions.
|
||||||
*/
|
*/
|
||||||
public String getOutputPathForRendition(final FormInstanceData formInstanceData /*,final String parentAVMPath */)
|
public String getOutputPathForRendition(final FormInstanceData formInstanceData, final String currentAVMPath)
|
||||||
{
|
{
|
||||||
final ServiceRegistry sr = this.getServiceRegistry();
|
final ServiceRegistry sr = this.getServiceRegistry();
|
||||||
final NodeService nodeService = sr.getNodeService();
|
final NodeService nodeService = sr.getNodeService();
|
||||||
@@ -212,11 +215,12 @@ public class RenderingEngineTemplateImpl
|
|||||||
LOGGER.error(e);
|
LOGGER.error(e);
|
||||||
throw new AlfrescoRuntimeException(e.getMessage(), e);
|
throw new AlfrescoRuntimeException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
final String parentAVMPath = AVMNodeConverter.SplitBase(formInstanceDataAVMPath)[0];
|
||||||
|
|
||||||
root.put("xml", NodeModel.wrap(formInstanceDataDocument));
|
root.put("xml", NodeModel.wrap(formInstanceDataDocument));
|
||||||
root.put("node", new TemplateNode(((FormInstanceDataImpl)formInstanceData).getNodeRef(), sr, null));
|
root.put("node", new TemplateNode(((FormInstanceDataImpl)formInstanceData).getNodeRef(), sr, null));
|
||||||
root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME));
|
root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME));
|
||||||
|
root.put("cwd", AVMConstants.getWebappRelativePath(currentAVMPath));
|
||||||
final TemplateService templateService = sr.getTemplateService();
|
final TemplateService templateService = sr.getTemplateService();
|
||||||
final String outputPathPattern = (FreeMarkerUtil.buildNamespaceDeclaration(formInstanceDataDocument) +
|
final String outputPathPattern = (FreeMarkerUtil.buildNamespaceDeclaration(formInstanceDataDocument) +
|
||||||
this.getOutputPathPattern());
|
this.getOutputPathPattern());
|
||||||
@@ -236,7 +240,7 @@ public class RenderingEngineTemplateImpl
|
|||||||
":\n" + te.getMessage(),
|
":\n" + te.getMessage(),
|
||||||
te);
|
te);
|
||||||
}
|
}
|
||||||
final String parentAVMPath = AVMNodeConverter.SplitBase(formInstanceDataAVMPath)[0];
|
|
||||||
result = AVMConstants.buildPath(parentAVMPath,
|
result = AVMConstants.buildPath(parentAVMPath,
|
||||||
result,
|
result,
|
||||||
AVMConstants.PathRelation.SANDBOX_RELATIVE);
|
AVMConstants.PathRelation.SANDBOX_RELATIVE);
|
||||||
@@ -251,13 +255,13 @@ public class RenderingEngineTemplateImpl
|
|||||||
WCMAppModel.PROP_MIMETYPE_FOR_RENDITION);
|
WCMAppModel.PROP_MIMETYPE_FOR_RENDITION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rendition render(final FormInstanceData formInstanceData)
|
public Rendition render(final FormInstanceData formInstanceData,
|
||||||
|
final String renditionAvmPath)
|
||||||
throws IOException,
|
throws IOException,
|
||||||
SAXException,
|
SAXException,
|
||||||
RenderingEngine.RenderingException
|
RenderingEngine.RenderingException
|
||||||
{
|
{
|
||||||
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
||||||
final String renditionAvmPath = this.getOutputPathForRendition(formInstanceData);
|
|
||||||
final boolean isRegenerate = avmService.lookup(-1, renditionAvmPath) != null;
|
final boolean isRegenerate = avmService.lookup(-1, renditionAvmPath) != null;
|
||||||
if (!isRegenerate)
|
if (!isRegenerate)
|
||||||
{
|
{
|
||||||
@@ -559,5 +563,10 @@ public class RenderingEngineTemplateImpl
|
|||||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
return Repository.getServiceRegistry(fc);
|
return Repository.getServiceRegistry(fc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return this.getName().hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,10 +18,12 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr><td><tt style="font-weight:bold;">name</td></tt><td>The name of the form instance data as entered by the user in the create web content wizard.</td></tr>
|
<tr><td><tt style="font-weight:bold;">name</td></tt><td>The name of the form instance data as entered by the user in the create web content wizard.</td></tr>
|
||||||
<tr><td><tt style="font-weight:bold;">webapp</td></tt><td>The name of the webapp in which the form instance data is being created. Typically, if specifying an absolute output path pattern, the path will begin with the webapp folder (i.e. <tt>/${webapp}/...</tt>)</td></tr>
|
<tr><td><tt style="font-weight:bold;">webapp</td></tt><td>The name of the webapp in which the form instance data is being created. Typically, if specifying an absolute output path pattern, the path will begin with the webapp folder (i.e. <tt>/${webapp}/...</tt>)</td></tr>
|
||||||
|
<tr><td><tt style="font-weight:bold;">cwd</td></tt><td>The webapp relative path in which the form is being created.</td></tr>
|
||||||
<tr><td><tt style="font-weight:bold;">extension</td></tt><td>The default extension associated with the mime-type configured for the rendering engine template. This variable is only available for rendition ouput path patterns.</td></tr>
|
<tr><td><tt style="font-weight:bold;">extension</td></tt><td>The default extension associated with the mime-type configured for the rendering engine template. This variable is only available for rendition ouput path patterns.</td></tr>
|
||||||
<tr><td><tt style="font-weight:bold;">xml</td></tt><td>The xml instance data collected by the form.</td></tr>
|
<tr><td><tt style="font-weight:bold;">xml</td></tt><td>The xml instance data collected by the form.</td></tr>
|
||||||
<tr><td><tt style="font-weight:bold;">node</td></tt><td>The form instance data node. This variable is only available for rendition ouput path patterns.</td></tr>
|
<tr><td><tt style="font-weight:bold;">node</td></tt><td>The form instance data node. This variable is only available for rendition ouput path patterns.</td></tr>
|
||||||
<tr><td><tt style="font-weight:bold;">date</td></tt><td>The current date at which the form instance data is being saved. Refer to the <a style="color:blue;" href="http://freemarker.sourceforge.net/docs/ref_builtins_date.htm">FreeMarker date reference</a> for more information.</td></tr>
|
<tr><td><tt style="font-weight:bold;">date</td></tt><td>The current date at which the form instance data is being saved. Refer to the <a style="color:blue;" href="http://freemarker.sourceforge.net/docs/ref_builtins_date.htm">FreeMarker date reference</a> for more information.</td></tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<br/>
|
<br/>
|
||||||
|
Reference in New Issue
Block a user