diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java index 7dc2553534..607ea57b65 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java @@ -38,6 +38,8 @@ import org.alfresco.model.ContentModel; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.avmsync.AVMDifference; +import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; @@ -73,9 +75,13 @@ public class CreateWebContentWizard extends BaseContentWizard protected List renditions = null; protected FormInstanceData formInstanceData = null; protected boolean formSelectDisabled = false; + protected boolean startWorkflow = false; /** AVM service bean reference */ protected AVMService avmService; + + /** AVM sync service bean reference */ + protected AVMSyncService avmSyncService; /** AVM Browse Bean reference */ protected AVMBrowseBean avmBrowseBean; @@ -88,6 +94,14 @@ public class CreateWebContentWizard extends BaseContentWizard { this.avmService = avmService; } + + /** + * @param avmSyncService The AVMSyncService to set. + */ + public void setAvmSyncService(final AVMSyncService avmSyncService) + { + this.avmSyncService = avmSyncService; + } /** * @param avmBrowseBean The AVMBrowseBean to set. @@ -109,6 +123,9 @@ public class CreateWebContentWizard extends BaseContentWizard this.inlineEdit = true; this.formName = null; this.mimeType = MimetypeMap.MIMETYPE_XML; + this.formInstanceData = null; + this.renditions = null; + this.startWorkflow = false; // check for a form ID being passed in as a parameter if (this.parameters.get(UIUserSandboxes.PARAM_FORM_ID) != null) @@ -127,10 +144,32 @@ public class CreateWebContentWizard extends BaseContentWizard } @Override - protected String finishImpl(FacesContext context, String outcome) + protected String finishImpl(final FacesContext context, final String outcome) throws Exception { - + final List diffList = new ArrayList(1 + this.renditions.size()); + diffList.add(new AVMDifference(-1, this.createdPath, + -1, this.createdPath.replaceFirst(AVMConstants.STORE_PREVIEW, + AVMConstants.STORE_MAIN), + AVMDifference.NEWER)); + for (Rendition rendition : this.renditions) + { + final String path = AVMNodeConverter.ToAVMVersionPath(rendition.getNodeRef()).getSecond(); + diffList.add(new AVMDifference(-1, path, + -1, path.replaceFirst(AVMConstants.STORE_PREVIEW, + AVMConstants.STORE_MAIN), + AVMDifference.NEWER)); + } + this.avmSyncService.update(diffList, true, true, true, true, null, null); + + if (this.startWorkflow) + { + System.err.println("************* starting workflow"); + } + else + { + System.err.println("************* not starting workflow"); + } // return the default outcome return outcome; } @@ -169,6 +208,7 @@ public class CreateWebContentWizard extends BaseContentWizard logger.debug("saving file content to " + this.fileName); // get the parent path of the location to save the content 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 FormsService fs = FormsService.getInstance(); @@ -387,6 +427,16 @@ public class CreateWebContentWizard extends BaseContentWizard this.formSelectDisabled = formSelectDisabled; } + public void setStartWorkflow(final boolean startWorkflow) + { + this.startWorkflow = startWorkflow; + } + + public boolean getStartWorkflow() + { + return this.startWorkflow; + } + /** * @return Returns the summary data for the wizard. */ diff --git a/source/java/org/alfresco/web/forms/FormInstanceData.java b/source/java/org/alfresco/web/forms/FormInstanceData.java index 7cd97db419..b974332e7c 100644 --- a/source/java/org/alfresco/web/forms/FormInstanceData.java +++ b/source/java/org/alfresco/web/forms/FormInstanceData.java @@ -35,4 +35,7 @@ public interface FormInstanceData /** the path relative to the containing webapp */ public String getWebappRelativePath(); + + /** the url to the asset */ + public String getUrl(); } diff --git a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java index 317059745a..740760c8e1 100644 --- a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java +++ b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java @@ -79,6 +79,11 @@ public class FormInstanceDataImpl return this.nodeRef; } + public String getUrl() + { + return AVMConstants.buildAVMAssetUrl(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond()); + } + private ServiceRegistry getServiceRegistry() { final FacesContext fc = FacesContext.getCurrentInstance(); diff --git a/source/java/org/alfresco/web/forms/Rendition.java b/source/java/org/alfresco/web/forms/Rendition.java index c0ef18e1a8..ebf14d8d3c 100644 --- a/source/java/org/alfresco/web/forms/Rendition.java +++ b/source/java/org/alfresco/web/forms/Rendition.java @@ -41,4 +41,7 @@ public interface Rendition /** the node ref containing the contents of this rendition */ public NodeRef getNodeRef(); + + /** the url to the asset */ + public String getUrl(); } diff --git a/source/java/org/alfresco/web/forms/RenditionImpl.java b/source/java/org/alfresco/web/forms/RenditionImpl.java index 3d308e3fc2..2e86ced186 100644 --- a/source/java/org/alfresco/web/forms/RenditionImpl.java +++ b/source/java/org/alfresco/web/forms/RenditionImpl.java @@ -93,6 +93,11 @@ public class RenditionImpl return this.nodeRef; } + public String getUrl() + { + return AVMConstants.buildAVMAssetUrl(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond()); + } + private ServiceRegistry getServiceRegistry() { final FacesContext fc = FacesContext.getCurrentInstance(); diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 189c190b83..9ecf442ee2 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -2115,6 +2115,10 @@ avmService #{AVMService} + + avmSyncService + #{AVMSyncService} + avmBrowseBean #{AVMBrowseBean} 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 16db1a8ee5..0d164ef3d5 100644 --- a/source/web/jsp/wcm/create-web-content-wizard/summary.jsp +++ b/source/web/jsp/wcm/create-web-content-wizard/summary.jsp @@ -24,6 +24,10 @@ window.onload = function() { document.getElementById("wizard:finish-button").focus(); } + + + @@ -46,10 +50,14 @@ - ${rendition.name} + ${rendition.name} ${rendition.webappRelativePath} - +