diff --git a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java index c7a347a17d..50fca9ba84 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java @@ -359,7 +359,7 @@ public class AVMEditBean if (nodeService.getProperty(avmRef, WCMModel.PROP_PARENT_FORM) != null) { final FormsService fs = FormsService.getInstance(); - fs.regenerate(avmRef); + fs.regenerateRenditions(avmRef); } resetState(); diff --git a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java index 1e703ce67d..2730459e77 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java @@ -115,6 +115,7 @@ public class CreateFormWizard extends BaseWizardBean private String schemaRootTagName; private String formName; + private String formDescription; private Class renderingEngineType = null; protected ContentService contentService; private DataModel renderingEnginesDataModel; @@ -158,7 +159,7 @@ public class CreateFormWizard extends BaseWizardBean // apply the titled aspect - title and description Map props = new HashMap(2, 1.0f); props.put(ContentModel.PROP_TITLE, this.getFormName()); - props.put(ContentModel.PROP_DESCRIPTION, ""); + props.put(ContentModel.PROP_DESCRIPTION, this.getFormDescription()); this.nodeService.addAspect(schemaNodeRef, ContentModel.ASPECT_TITLED, props); props = new HashMap(1, 1.0f); @@ -211,6 +212,7 @@ public class CreateFormWizard extends BaseWizardBean this.removeUploadedRenderingEngineFile(); this.schemaRootTagName = null; this.formName = null; + this.formDescription = null; this.renderingEngineType = null; this.renderingEngines = new ArrayList(); this.fileExtension = null; @@ -534,6 +536,22 @@ public class CreateFormWizard extends BaseWizardBean ? this.getSchemaFileName().replaceAll("(.+)\\..*", "$1") : this.formName); } + + /** + * Sets the description for this form. + */ + public void setFormDescription(final String formDescription) + { + this.formDescription = formDescription; + } + + /** + * @return the description for this form. + */ + public String getFormDescription() + { + return this.formDescription; + } /** * @return Returns the summary data for the wizard. diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java index c97e7fbf98..d6641e09ca 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java @@ -104,20 +104,20 @@ public class CreateWebContentWizard extends BaseContentWizard { if (logger.isDebugEnabled()) logger.debug("generating form data renderer output for " + this.formName); - final Form tt = this.getForm(); - final FormsService ts = FormsService.getInstance(); - + final Form form = this.getForm(); + final FormsService fs = FormsService.getInstance(); + final NodeRef formInstanceDataNodeRef = + AVMNodeConverter.ToNodeRef(-1, this.createdPath); final Map props = new HashMap(1, 1.0f); - props.put(WCMModel.PROP_PARENT_FORM, tt.getNodeRef()); - props.put(WCMModel.PROP_PARENT_FORM_NAME, tt.getName()); - this.nodeService.addAspect(AVMNodeConverter.ToNodeRef(-1, this.createdPath), + props.put(WCMModel.PROP_PARENT_FORM, form.getNodeRef()); + props.put(WCMModel.PROP_PARENT_FORM_NAME, form.getName()); + this.nodeService.addAspect(formInstanceDataNodeRef, WCMModel.ASPECT_FORM_INSTANCE_DATA, props); - ts.generate(this.createdPath.substring(0, this.createdPath.lastIndexOf('/')), - ts.parseXML(this.content), - tt, - this.fileName); + fs.generateRenditions(formInstanceDataNodeRef, + fs.parseXML(this.content), + form); } // return the default outcome diff --git a/source/java/org/alfresco/web/forms/FormsService.java b/source/java/org/alfresco/web/forms/FormsService.java index 57fb228b42..cf79e42e77 100644 --- a/source/java/org/alfresco/web/forms/FormsService.java +++ b/source/java/org/alfresco/web/forms/FormsService.java @@ -196,6 +196,13 @@ public final class FormsService } } + /** + * Returns the form backed by the given NodeRef. The NodeRef should + * point to the schema for this form. + * + * @param nodeRef the node ref for the schema for the form + * @return the form for the given node ref. + */ public Form getForm(final NodeRef nodeRef) { return this.newForm(nodeRef); @@ -242,137 +249,139 @@ public final class FormsService return tt; } - public void generate(final String parentPath, - final Document xml, - final Form tt, - final String fileName) + /** + * Generates renditions for the provided formInstanceData. + * + * @param formInstanceDataNodeRef the noderef containing the form instance data + * @param formInstanceData the parsed contents of the form. + * @param form the form to use when generating renditions. + */ + public void generateRenditions(final NodeRef formInstanceDataNodeRef, + final Document formInstanceData, + final Form form) throws IOException, RenderingEngine.RenderingException { - for (RenderingEngine tom : tt.getRenderingEngines()) + final String formInstanceDataFileName = (String) + nodeService.getProperty(formInstanceDataNodeRef, ContentModel.PROP_NAME); + final String formInstanceDataAvmPath = AVMNodeConverter.ToAVMVersionPath(formInstanceDataNodeRef).getSecond(); + final String parentPath = AVMNodeConverter.SplitBase(formInstanceDataAvmPath)[0]; + + for (RenderingEngine re : form.getRenderingEngines()) { // get the node ref of the node that will contain the content - final String generatedFileName = stripExtension(fileName) + "." + tom.getFileExtension(); - final OutputStream fileOut = this.avmService.createFile(parentPath, generatedFileName); - final String fullAvmPath = parentPath + '/' + generatedFileName; - final String avmStore = parentPath.substring(0, parentPath.indexOf(":/")); - final String sandBoxUrl = AVMConstants.buildAVMStoreUrl(avmStore); + final String renditionFileName = + this.stripExtension(formInstanceDataFileName) + "." + re.getFileExtension(); + final OutputStream fileOut = this.avmService.createFile(parentPath, renditionFileName); + final String renditionAvmPath = parentPath + '/' + renditionFileName; if (LOGGER.isDebugEnabled()) - LOGGER.debug("Created file node for file: " + - fullAvmPath); + LOGGER.debug("Created file node for file: " + renditionAvmPath); final OutputStreamWriter out = new OutputStreamWriter(fileOut); final HashMap parameters = - getOutputMethodParameters(sandBoxUrl, fileName, generatedFileName, parentPath); - tom.generate(xml, parameters, out); + this.getOutputMethodParameters(formInstanceDataFileName, + renditionFileName, + parentPath); + re.generate(formInstanceData, parameters, out); out.close(); - NodeRef outputNodeRef = AVMNodeConverter.ToNodeRef(-1, fullAvmPath); + final NodeRef renditionNodeRef = + AVMNodeConverter.ToNodeRef(-1, parentPath + '/' + renditionFileName); Map props = new HashMap(2, 1.0f); - props.put(WCMModel.PROP_PARENT_FORM, tt.getNodeRef()); - props.put(WCMModel.PROP_PARENT_FORM_NAME, tt.getName()); - nodeService.addAspect(outputNodeRef, WCMModel.ASPECT_FORM_INSTANCE_DATA, props); + props.put(WCMModel.PROP_PARENT_FORM, form.getNodeRef()); + props.put(WCMModel.PROP_PARENT_FORM_NAME, form.getName()); + nodeService.addAspect(renditionNodeRef, WCMModel.ASPECT_FORM_INSTANCE_DATA, props); props = new HashMap(2, 1.0f); - props.put(WCMModel.PROP_PARENT_RENDERING_ENGINE, tom.getNodeRef()); + props.put(WCMModel.PROP_PARENT_RENDERING_ENGINE, re.getNodeRef()); props.put(WCMModel.PROP_PRIMARY_FORM_INSTANCE_DATA, - AVMNodeConverter.ToNodeRef(-1, parentPath + fileName)); - nodeService.addAspect(outputNodeRef, WCMModel.ASPECT_RENDITION, props); + AVMNodeConverter.ToNodeRef(-1, parentPath + formInstanceDataFileName)); + nodeService.addAspect(renditionNodeRef, WCMModel.ASPECT_RENDITION, props); props = new HashMap(1, 1.0f); - props.put(ContentModel.PROP_TITLE, fileName); - nodeService.addAspect(outputNodeRef, ContentModel.ASPECT_TITLED, props); + props.put(ContentModel.PROP_TITLE, renditionFileName); + nodeService.addAspect(renditionNodeRef, ContentModel.ASPECT_TITLED, props); - LOGGER.debug("generated " + generatedFileName + " using " + tom); + LOGGER.debug("generated " + renditionFileName + " using " + re); } } - public void regenerate(final NodeRef nodeRef) + /** + * Regenerates all renditions of the provided form instance data. + * + * @param formInstanceDataNodeRef the node ref containing the form instance data. + */ + public void regenerateRenditions(final NodeRef formInstanceDataNodeRef) throws IOException, SAXException, RenderingEngine.RenderingException { final NodeRef formNodeRef = (NodeRef) - nodeService.getProperty(nodeRef, WCMModel.PROP_PARENT_FORM); + nodeService.getProperty(formInstanceDataNodeRef, WCMModel.PROP_PARENT_FORM); - final Form tt = this.getForm(formNodeRef); + final Form form = this.getForm(formNodeRef); - final ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); - final Document xml = this.parseXML(reader.getContentInputStream()); - final String fileName = (String) - nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - final String avmPath = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(); - final String avmStore = avmPath.substring(0, avmPath.indexOf(":/")); - final String sandBoxUrl = AVMConstants.buildAVMStoreUrl(avmStore); - final String parentPath = AVMNodeConverter.SplitBase(avmPath)[0]; - for (RenderingEngine tom : tt.getRenderingEngines()) + final ContentReader reader = contentService.getReader(formInstanceDataNodeRef, ContentModel.PROP_CONTENT); + final Document formInstanceData = this.parseXML(reader.getContentInputStream()); + final String formInstanceDataFileName = (String) + nodeService.getProperty(formInstanceDataNodeRef, ContentModel.PROP_NAME); + + // other parameter values passed to rendering engine + final String formInstanceDataAvmPath = AVMNodeConverter.ToAVMVersionPath(formInstanceDataNodeRef).getSecond(); + final String parentPath = AVMNodeConverter.SplitBase(formInstanceDataAvmPath)[0]; + + for (RenderingEngine re : form.getRenderingEngines()) { - final String generatedFileName = stripExtension(fileName) + "." + tom.getFileExtension(); + final String renditionFileName = + this.stripExtension(formInstanceDataFileName) + "." + re.getFileExtension(); if (LOGGER.isDebugEnabled()) - LOGGER.debug("regenerating file node for : " + fileName + " (" + - nodeRef.toString() + ") to " + parentPath + "/" + generatedFileName); + LOGGER.debug("regenerating file node for : " + formInstanceDataFileName + + " (" + formInstanceDataNodeRef.toString() + + ") to " + parentPath + + "/" + renditionFileName); // get a writer for the content and put the file OutputStream out = null; try { - out = this.avmService.getFileOutputStream(parentPath + "/" + generatedFileName); + out = this.avmService.getFileOutputStream(parentPath + "/" + renditionFileName); } catch (AVMNotFoundException e) { - out = this.avmService.createFile(parentPath, generatedFileName); + out = this.avmService.createFile(parentPath, renditionFileName); } final OutputStreamWriter writer = new OutputStreamWriter(out); final HashMap parameters = - getOutputMethodParameters(sandBoxUrl, fileName, generatedFileName, parentPath); - tom.generate(xml, parameters, writer); + this.getOutputMethodParameters(formInstanceDataFileName, + renditionFileName, + parentPath); + re.generate(formInstanceData, parameters, writer); writer.close(); - LOGGER.debug("generated " + fileName + " using " + tom); + + LOGGER.debug("generated " + renditionFileName + " using " + re); } } - private static HashMap getOutputMethodParameters(final String sandBoxUrl, - final String fileName, - final String generatedFileName, - final String parentPath) + private static HashMap getOutputMethodParameters(final String formInstanceDataFileName, + final String renditionFileName, + final String parentAvmPath) { final HashMap parameters = new HashMap(); - parameters.put("avm_store_url", sandBoxUrl); - parameters.put("derived_from_file_name", fileName); - parameters.put("generated_file_name", generatedFileName); - parameters.put("parent_path", parentPath); + parameters.put("avm_sandbox_url", AVMConstants.buildAVMStoreUrl(parentAvmPath)); + parameters.put("form_instance_data_file_name", formInstanceDataFileName); + parameters.put("rendition_file_name", renditionFileName); + parameters.put("parent_path", parentAvmPath); return parameters; } /** utility function for creating a document */ public Document newDocument() { - try - { - final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - dbf.setValidating(false); - final DocumentBuilder db = dbf.newDocumentBuilder(); - return db.newDocument(); - } - catch (ParserConfigurationException pce) - { - assert false : pce; - LOGGER.error(pce); - return null; - } -// catch (SAXException saxe) -// { -// LOGGER.error(saxe); -// } -// catch (IOException ioe) -// { -// LOGGER.error(ioe); -// } + return this.getDocumentBuilder().newDocument(); } /** utility function for serializing a node */ @@ -423,7 +432,7 @@ public final class FormsService /** utility function for parsing xml */ public Document parseXML(final String source) - throws SAXException, + throws SAXException, IOException { return this.parseXML(new ByteArrayInputStream(source.getBytes())); @@ -482,5 +491,5 @@ public final class FormsService } } return FormsService.documentBuilder; - } + } } diff --git a/source/test-resources/websites/alfresco/ROOT/index.jsp b/source/test-resources/websites/alfresco/ROOT/index.jsp index 71e300a678..fae2cedfe5 100644 --- a/source/test-resources/websites/alfresco/ROOT/index.jsp +++ b/source/test-resources/websites/alfresco/ROOT/index.jsp @@ -1,364 +1,319 @@ - - - - -Alfresco - Open Source Enterprise Content Management (CMS) including Web Content Management - - - - - - - - - - - - - - - -
-
- - - - - -
- -
-
-
-
-
-
Alfresco Partner PodcastAlfresco 1.4 Community Preview now available
- -Listen Now - - -Learn More - -
-
-

Alfresco offers true Open Source Enterprise Content Management (ECM) - Document Management, Collaboration, Records Management, Knowledge Management, Web Content Management and Imaging. More...

-
- -
-
-
- -
-
-

Events & Training

- -

Optaros Open Source Content Management Solutions Webinar

-

Sep 26, 2006 (Online WebEx)

-

US Training - Alfresco for Developers

-

Sep 26-28, 2006 (Washington, DC)

-

Australia Training - Alfresco for Users and Administrators

-

Sep 26-28, 2006 (Melbourne)

-

Alfresco at Gartner Open Source

-

Sep 27-29, 2006 (Phoenix)

-

Alfresco at Forum de la Geide

-

Oct 03-05, 2006 (Paris)

-

More Events | More Training

-
-
-
-
-

Links

- -
-
-
-
- - -
-
- -
-
- - diff --git a/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.ftl b/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.ftl index f8f769cf27..47b366108b 100644 --- a/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.ftl +++ b/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.ftl @@ -21,10 +21,19 @@
Generated by output-method-callout.ftl
+
<#noparse>${alfresco.avm_sandbox_url}
+ ${alfresco.avm_sandbox_url} +
<#noparse>${alfresco.form_instance_data_file_name}
+ ${alfresco.form_instance_data_file_name} +
<#noparse>${alfresco.rendition_file_name}
+ ${alfresco.rendition_file_name} +
<#noparse>${alfresco.parent_path}
+ ${alfresco.parent_path} +
My value accessed using <#noparse>${simple.string}:
${simple.string} -
My value accessed using <#noparse>$alfresco.getXMLDocument(${alfresco.derived_from_file_name}):
- ${alfresco.getXMLDocument(alfresco.derived_from_file_name).simple.string} +
My value accessed using <#noparse>$alfresco.getXMLDocument(${alfresco.form_instance_data_file_name}):
+ ${alfresco.getXMLDocument(alfresco.form_instance_data_file_name).simple.string}
Values from xml files generated by in ${alfresco.parent_path}:
    <#list alfresco.getXMLDocuments('output-method-callout') as d> diff --git a/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.xsl b/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.xsl index 047057e084..2ff3924068 100644 --- a/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.xsl +++ b/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.xsl @@ -32,10 +32,27 @@ body
    Generated by output-method-callout.xsl
    +
    + <xsl:value-of select="$alfresco:avm_sandbox_url"/> +
    + +
    + <xsl:value-of select="$alfresco:form_instance_data_file_name"/> +
    + +
    + <xsl:value-of select="$alfresco:rendition_file_name"/> +
    + +
    + <xsl:value-of select="$alfresco:parent_path"/> +
    + +
    My value accessed using /simple/string:
    -
    My value accessed using alfresco:getXMLDocument():
    - +
    My value accessed using alfresco:getXMLDocument($alfresco:form_instance_data_file_name):
    +
    Values from xml files generated by in :
      diff --git a/source/web/jsp/wcm/create-form-wizard/details.jsp b/source/web/jsp/wcm/create-form-wizard/details.jsp index 1208f7c486..10ad5d9097 100644 --- a/source/web/jsp/wcm/create-form-wizard/details.jsp +++ b/source/web/jsp/wcm/create-form-wizard/details.jsp @@ -95,6 +95,7 @@ if (upload == null || upload.getFile() == null) } %> + @@ -103,7 +104,13 @@ if (upload == null || upload.getFile() == null) + + + + +