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:
Derek Hulley
2007-04-25 02:13:55 +00:00
parent 77656d03e1
commit 58bb2adc27
6 changed files with 66 additions and 13 deletions

View File

@@ -21,6 +21,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import javax.faces.context.FacesContext;
@@ -590,12 +591,44 @@ public class AVMEditBean
if (LOGGER.isDebugEnabled())
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
{
ret.render(fid);
final String path = ret.getOutputPathForRendition(fid, originalParentAvmPath);
ret.render(fid, path);
}
catch (Exception e)
{

View File

@@ -465,16 +465,16 @@ public class CreateWebContentWizard extends BaseContentWizard
if (LOGGER.isDebugEnabled())
LOGGER.debug("saving file content to " + fileName);
String path = this.avmBrowseBean.getCurrentPath();
path = AVMConstants.getCorrespondingPathInPreviewStore(path);
final String cwd = AVMConstants.getCorrespondingPathInPreviewStore(this.avmBrowseBean.getCurrentPath());
final Form form = (MimetypeMap.MIMETYPE_XML.equals(this.mimeType)
? this.getForm()
: null);
String path = null;
if (form != null)
{
path = form.getOutputPathForFormInstanceData(this.instanceDataDocument,
fileName,
path,
cwd,
this.avmBrowseBean.getWebapp());
this.content = XMLUtil.toString(this.instanceDataDocument, false);
final String[] sb = AVMNodeConverter.SplitBase(path);
@@ -513,6 +513,7 @@ public class CreateWebContentWizard extends BaseContentWizard
};
props.clear();
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.renditions = new LinkedList<Rendition>();
@@ -520,7 +521,8 @@ public class CreateWebContentWizard extends BaseContentWizard
{
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)
{

View File

@@ -154,6 +154,7 @@ public class FormImpl
root.put("xml", NodeModel.wrap(formInstanceData));
root.put("name", formInstanceDataName);
root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME));
root.put("cwd", AVMConstants.getWebappRelativePath(parentAVMPath));
final TemplateService templateService = this.getServiceRegistry().getTemplateService();

View File

@@ -69,9 +69,13 @@ public interface RenderingEngineTemplate
/**
* 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.
*/
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
@@ -87,8 +91,10 @@ public interface RenderingEngineTemplate
*
* @param formInstanceData the form instance data for which to produce
* 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,
SAXException,
RenderingEngine.RenderingException;

View File

@@ -178,9 +178,12 @@ public class RenderingEngineTemplateImpl
* Generates an output path for the rendition by compiling the output path pattern
* 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.
*/
public String getOutputPathForRendition(final FormInstanceData formInstanceData /*,final String parentAVMPath */)
public String getOutputPathForRendition(final FormInstanceData formInstanceData, final String currentAVMPath)
{
final ServiceRegistry sr = this.getServiceRegistry();
final NodeService nodeService = sr.getNodeService();
@@ -212,11 +215,12 @@ public class RenderingEngineTemplateImpl
LOGGER.error(e);
throw new AlfrescoRuntimeException(e.getMessage(), e);
}
final String parentAVMPath = AVMNodeConverter.SplitBase(formInstanceDataAVMPath)[0];
root.put("xml", NodeModel.wrap(formInstanceDataDocument));
root.put("node", new TemplateNode(((FormInstanceDataImpl)formInstanceData).getNodeRef(), sr, null));
root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME));
root.put("cwd", AVMConstants.getWebappRelativePath(currentAVMPath));
final TemplateService templateService = sr.getTemplateService();
final String outputPathPattern = (FreeMarkerUtil.buildNamespaceDeclaration(formInstanceDataDocument) +
this.getOutputPathPattern());
@@ -236,7 +240,7 @@ public class RenderingEngineTemplateImpl
":\n" + te.getMessage(),
te);
}
final String parentAVMPath = AVMNodeConverter.SplitBase(formInstanceDataAVMPath)[0];
result = AVMConstants.buildPath(parentAVMPath,
result,
AVMConstants.PathRelation.SANDBOX_RELATIVE);
@@ -251,13 +255,13 @@ public class RenderingEngineTemplateImpl
WCMAppModel.PROP_MIMETYPE_FOR_RENDITION);
}
public Rendition render(final FormInstanceData formInstanceData)
public Rendition render(final FormInstanceData formInstanceData,
final String renditionAvmPath)
throws IOException,
SAXException,
RenderingEngine.RenderingException
{
final AVMService avmService = this.getServiceRegistry().getAVMService();
final String renditionAvmPath = this.getOutputPathForRendition(formInstanceData);
final boolean isRegenerate = avmService.lookup(-1, renditionAvmPath) != null;
if (!isRegenerate)
{
@@ -559,5 +563,10 @@ public class RenderingEngineTemplateImpl
final FacesContext fc = FacesContext.getCurrentInstance();
return Repository.getServiceRegistry(fc);
}
public int hashCode()
{
return this.getName().hashCode();
}
}

View File

@@ -18,10 +18,12 @@
<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;">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>/&#36;{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;">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;">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>
</table>
<br/>