diff --git a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java index 9e62d54931..719f77fec8 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java @@ -43,6 +43,8 @@ import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.forms.Form; import org.alfresco.web.forms.FormProcessor; import org.alfresco.web.forms.FormsService; +import org.alfresco.web.forms.Rendition; +import org.alfresco.web.forms.RenditionImpl; import org.alfresco.web.ui.common.Utils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -269,7 +271,7 @@ public class AVMEditBean { if (LOGGER.isDebugEnabled()) LOGGER.debug(avmRef + " is a rendition, editing primary rendition instead"); - avmRef = (NodeRef)this.nodeService.getProperty(avmRef, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA); + avmRef = new RenditionImpl(avmRef).getPrimaryFormInstanceData().getNodeRef(); final Pair p = AVMNodeConverter.ToAVMVersionPath(avmRef); if (LOGGER.isDebugEnabled()) diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java index f4bdc9896f..52e92d9c6c 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java @@ -232,6 +232,12 @@ public class CreateWebContentWizard extends BaseContentWizard AVMDifference.NEWER)); } this.avmSyncService.update(diffList, null, true, true, true, true, null, null); + + // reset all paths and structures to the main store + this.createdPath = this.createdPath.replaceFirst(AVMConstants.STORE_PREVIEW, + AVMConstants.STORE_MAIN); + this.formInstanceData = new FormInstanceDataImpl(AVMNodeConverter.ToNodeRef(-1, this.createdPath)); + this.renditions = this.formInstanceData.getRenditions(); if (this.startWorkflow) { @@ -317,6 +323,7 @@ public class CreateWebContentWizard extends BaseContentWizard this.nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true); parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef); // TODO: capture label and comment? + // ariel to kev: this.fileName may be inaccurate. use formInstanceData.getName() instead parameters.put(AVMWorkflowUtil.PROP_LABEL, this.fileName); parameters.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMConstants.buildAVMStoreRootPath( this.avmBrowseBean.getSandbox())); @@ -371,20 +378,21 @@ public class CreateWebContentWizard extends BaseContentWizard throws Exception { final FormsService fs = FormsService.getInstance(); - if (LOGGER.isDebugEnabled()) - LOGGER.debug("saving file content to " + this.fileName); - // get the parent path of the location to save the content + String fileName = this.fileName; + if (LOGGER.isDebugEnabled()) + LOGGER.debug("saving file content to " + fileName); + String path = this.avmBrowseBean.getCurrentPath(); path = path.replaceFirst(AVMConstants.STORE_MAIN, AVMConstants.STORE_PREVIEW); if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null) { final Document formInstanceData = fs.parseXML(this.content); - path = this.getForm().getOutputPathForFormInstanceData(path, this.fileName, formInstanceData); + path = this.getForm().getOutputPathForFormInstanceData(path, fileName, formInstanceData); final String[] sb = AVMNodeConverter.SplitBase(path); path = sb[0]; - this.fileName = sb[1]; + fileName = sb[1]; } if (LOGGER.isDebugEnabled()) @@ -399,20 +407,20 @@ public class CreateWebContentWizard extends BaseContentWizard fs.makeAllDirectories(path); if (LOGGER.isDebugEnabled()) - LOGGER.debug("creating file " + this.fileName + " in " + path); + LOGGER.debug("creating file " + fileName + " in " + path); // put the content of the file into the AVM store avmService.createFile(path, - this.fileName, + fileName, new ByteArrayInputStream((this.content == null ? "" : this.content).getBytes())); // remember the created path - this.createdPath = path + '/' + this.fileName; + this.createdPath = path + '/' + fileName; // add titled aspect for the read/edit properties screens final NodeRef formInstanceDataNodeRef = AVMNodeConverter.ToNodeRef(-1, this.createdPath); Map titledProps = new HashMap(1, 1.0f); - titledProps.put(ContentModel.PROP_TITLE, this.fileName); + titledProps.put(ContentModel.PROP_TITLE, fileName); this.nodeService.addAspect(formInstanceDataNodeRef, ContentModel.ASPECT_TITLED, titledProps); if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null) diff --git a/source/java/org/alfresco/web/forms/FormInstanceData.java b/source/java/org/alfresco/web/forms/FormInstanceData.java index e26e36dc6a..9a85ce0216 100644 --- a/source/java/org/alfresco/web/forms/FormInstanceData.java +++ b/source/java/org/alfresco/web/forms/FormInstanceData.java @@ -17,6 +17,7 @@ package org.alfresco.web.forms; import java.io.Serializable; +import java.util.List; import org.alfresco.service.cmr.repository.NodeRef; /** @@ -42,4 +43,7 @@ public interface FormInstanceData /** the noderef containing the form instance data */ public NodeRef getNodeRef(); + + /** returns all renditions of this form instance data */ + public List getRenditions(); } diff --git a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java index 971b449bfc..5a7a9100c7 100644 --- a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java +++ b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java @@ -16,11 +16,14 @@ */ package org.alfresco.web.forms; +import java.util.LinkedList; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.faces.context.FacesContext; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMAppModel; +import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.service.ServiceRegistry; @@ -46,6 +49,8 @@ public class FormInstanceDataImpl implements FormInstanceData { + private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class); + private final NodeRef nodeRef; public FormInstanceDataImpl(final NodeRef nodeRef) @@ -92,6 +97,29 @@ public class FormInstanceDataImpl return AVMConstants.buildAVMAssetUrl(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond()); } + public List getRenditions() + { + final AVMService avmService = this.getServiceRegistry().getAVMService(); + final List result = new LinkedList(); + for (RenderingEngineTemplate ret : this.getForm().getRenderingEngineTemplates()) + { + final String renditionAvmPath = + FormsService.getOutputAvmPathForRendition(ret, this.getNodeRef()); + if (avmService.lookup(-1, renditionAvmPath) == null) + { + LOGGER.warn("unable to locate rendition " + renditionAvmPath + + " for form instance data " + this.getName()); + } + else + { + final NodeRef renditionNodeRef = + AVMNodeConverter.ToNodeRef(-1, renditionAvmPath); + result.add(new RenditionImpl(renditionNodeRef)); + } + } + return result; + } + private ServiceRegistry getServiceRegistry() { final FacesContext fc = FacesContext.getCurrentInstance(); diff --git a/source/java/org/alfresco/web/forms/FormsService.java b/source/java/org/alfresco/web/forms/FormsService.java index 5a5b5d3f01..0e7ad90457 100644 --- a/source/java/org/alfresco/web/forms/FormsService.java +++ b/source/java/org/alfresco/web/forms/FormsService.java @@ -389,15 +389,15 @@ public final class FormsService public static String getOutputAvmPathForRendition(final RenderingEngineTemplate ret, final NodeRef formInstanceDataNodeRef) { - final String formInstanceDataAvmPath = - AVMNodeConverter.ToAVMVersionPath(formInstanceDataNodeRef).getSecond(); - String formInstanceDataFileName = AVMNodeConverter.SplitBase(formInstanceDataAvmPath)[1]; - formInstanceDataFileName = FormsService.stripExtension(formInstanceDataFileName); +// final String formInstanceDataAvmPath = +// AVMNodeConverter.ToAVMVersionPath(formInstanceDataNodeRef).getSecond(); +// String formInstanceDataFileName = AVMNodeConverter.SplitBase(formInstanceDataAvmPath)[1]; +// formInstanceDataFileName = FormsService.stripExtension(formInstanceDataFileName); String result = ret.getOutputPathForRendition(formInstanceDataNodeRef); - if (result != null && result.charAt(0) == '/') - { - - } +// if (result != null && result.charAt(0) == '/') +// { +// +// } return result; } diff --git a/source/java/org/alfresco/web/forms/RenderingEngineTemplate.java b/source/java/org/alfresco/web/forms/RenderingEngineTemplate.java index 78ffb72521..20bf0dc022 100644 --- a/source/java/org/alfresco/web/forms/RenderingEngineTemplate.java +++ b/source/java/org/alfresco/web/forms/RenderingEngineTemplate.java @@ -55,7 +55,6 @@ public interface RenderingEngineTemplate * Provides the noderef for this template. * * @return the noderef for this template. - * @deprecated i'd rather not expose this */ public NodeRef getNodeRef(); diff --git a/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java b/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java index abe9d86947..e5b2633bcf 100644 --- a/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java +++ b/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java @@ -192,7 +192,12 @@ public class RenderingEngineTemplateImpl final NodeService nodeService = this.getServiceRegistry().getNodeService(); final Map props = new HashMap(2, 1.0f); props.put(WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE, this.nodeRef); - props.put(WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA, primaryFormInstanceDataNodeRef); + + // extract a store relative path for the primary form instance data + String path = AVMNodeConverter.ToAVMVersionPath(primaryFormInstanceDataNodeRef).getSecond(); + path = path.substring(path.indexOf(':') + 1); + props.put(WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA, path); + nodeService.addAspect(renditionNodeRef, WCMAppModel.ASPECT_RENDITION, props); } diff --git a/source/java/org/alfresco/web/forms/RenditionImpl.java b/source/java/org/alfresco/web/forms/RenditionImpl.java index 60a673d6df..bf76100d86 100644 --- a/source/java/org/alfresco/web/forms/RenditionImpl.java +++ b/source/java/org/alfresco/web/forms/RenditionImpl.java @@ -47,6 +47,8 @@ public class RenditionImpl implements Rendition { + private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class); + private final NodeRef nodeRef; public RenditionImpl(final NodeRef nodeRef) @@ -76,9 +78,14 @@ public class RenditionImpl public FormInstanceData getPrimaryFormInstanceData() { final NodeService nodeService = this.getServiceRegistry().getNodeService(); - final NodeRef fidNodeRef = (NodeRef) + final String fidAVMStoreRelativePath = (String) nodeService.getProperty(this.nodeRef, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA); + String avmStore = AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(); + avmStore = avmStore.substring(0, avmStore.indexOf(':')); + + final NodeRef fidNodeRef = + AVMNodeConverter.ToNodeRef(-1, avmStore + ':' + fidAVMStoreRelativePath); return new FormInstanceDataImpl(fidNodeRef); } diff --git a/source/web/images/icons/arrow_down.gif b/source/web/images/icons/arrow_down.gif index 0c9b4f906a..db3ffe23d9 100644 Binary files a/source/web/images/icons/arrow_down.gif and b/source/web/images/icons/arrow_down.gif differ diff --git a/source/web/images/icons/arrow_up.gif b/source/web/images/icons/arrow_up.gif index f26caab535..a32f33cded 100644 Binary files a/source/web/images/icons/arrow_up.gif and b/source/web/images/icons/arrow_up.gif differ diff --git a/source/web/images/icons/minus.gif b/source/web/images/icons/minus.gif index 87776787f0..a977f9f40d 100644 Binary files a/source/web/images/icons/minus.gif and b/source/web/images/icons/minus.gif differ diff --git a/source/web/images/icons/plus.gif b/source/web/images/icons/plus.gif index 91c38ac0ca..78d509b214 100644 Binary files a/source/web/images/icons/plus.gif and b/source/web/images/icons/plus.gif differ diff --git a/source/web/jsp/wcm/create-form-wizard/summary.jsp b/source/web/jsp/wcm/create-form-wizard/summary.jsp index f2fe6c7728..c8b8fdf337 100644 --- a/source/web/jsp/wcm/create-form-wizard/summary.jsp +++ b/source/web/jsp/wcm/create-form-wizard/summary.jsp @@ -40,9 +40,9 @@ value="${WizardManager.bean.formName}" image="/images/icons/webform_large.gif"> -
${WizardManager.bean.formDescription}
+
${msg.description}: ${WizardManager.bean.formDescription}
${msg.schema_root_element_name}: ${WizardManager.bean.schemaRootElementName}
-
${msg.schema_root_element_name}: ${WizardManager.bean.outputPathPatternForFormInstanceData}
+
${msg.output_path_pattern}: ${WizardManager.bean.outputPathPatternForFormInstanceData}
diff --git a/source/web/jsp/wcm/create-web-content-wizard/summary.jsp b/source/web/jsp/wcm/create-web-content-wizard/summary.jsp index 46a00bb57b..fb529307b3 100644 --- a/source/web/jsp/wcm/create-web-content-wizard/summary.jsp +++ b/source/web/jsp/wcm/create-web-content-wizard/summary.jsp @@ -31,12 +31,20 @@ - - - - - - + + + +
${msg.form}: ${WizardManager.bean.formInstanceData.form.name}
+
${msg.location}: ${WizardManager.bean.formInstanceData.webappRelativePath}
+
+
+
- - + -