diff --git a/config/alfresco/web-client-config-wcm-actions.xml b/config/alfresco/web-client-config-wcm-actions.xml
index 9ccb8a7f89..6fe4d2df8c 100644
--- a/config/alfresco/web-client-config-wcm-actions.xml
+++ b/config/alfresco/web-client-config-wcm-actions.xml
@@ -79,7 +79,8 @@
submit
/images/icons/submit.gif
- #{AVMBrowseBean.submitNode}
+ #{AVMBrowseBean.setupSubmitNodeAction}
+ dialog:submitSandboxItems
#{actionContext.path}
diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java
index 9ec0d9604f..95a3853a79 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java
@@ -736,6 +736,17 @@ public class AVMBrowseBean implements IContextListener
String store = params.get("store");
String username = params.get("username");
+ setupSandboxActionImpl(store, username);
+ }
+
+ /**
+ * Setup the context for a sandbox browse action
+ *
+ * @param store The store name for the action
+ * @param username The authority pertinent to the action (null for staging store actions)
+ */
+ private void setupSandboxActionImpl(String store, String username)
+ {
// can be null if it's the staging store - i.e. not a user specific store
setUsername(username);
@@ -756,16 +767,11 @@ public class AVMBrowseBean implements IContextListener
// update UI state ready for return to the previous screen
this.location = null;
setCurrentPath(null);
+ setAvmActionNode(null);
this.submitAll = false;
}
- public void setupSubmitAllAction(ActionEvent event)
- {
- setupSandboxAction(event);
- this.submitAll = true;
- }
-
/**
* Action event called by all actions that need to setup a Content node context on the
* before an action page/wizard is called. The context will be an AVMNodeDescriptor in
@@ -803,125 +809,26 @@ public class AVMBrowseBean implements IContextListener
}
/**
- * Submit a node from a user sandbox into the staging area sandbox
+ * Submit a node from a user sandbox into the staging area sandbox via worklfow
*/
- public void submitNode(ActionEvent event)
+ public void setupSubmitNodeAction(ActionEvent event)
{
+ // extract store and username from the path to this node
String path = getPathFromEventArgs(event);
-
- UserTransaction tx = null;
- try
- {
- FacesContext context = FacesContext.getCurrentInstance();
- tx = Repository.getUserTransaction(context, false);
- tx.begin();
-
- AVMNodeDescriptor node = this.avmService.lookup(-1, path, true);
- if (node != null)
- {
- Action action = this.actionService.createAction(SimpleAVMSubmitAction.NAME);
- this.actionService.executeAction(action, AVMNodeConverter.ToNodeRef(-1, path));
- }
-
- // commit the transaction
- tx.commit();
-
- // if we get here, all was well - output friendly status message to the user
- String msg = MessageFormat.format(Application.getMessage(
- context, MSG_SUBMIT_SUCCESS), node.getName());
- displayStatusMessage(context, msg);
- }
- catch (Throwable err)
- {
- err.printStackTrace(System.err);
- Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
- FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
- try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
- }
+ String[] parts = path.split("[-:]");
+ String storename = parts[0];
+ String username = parts[1];
+ setupSandboxActionImpl(username, AVMConstants.buildAVMUserMainStoreName(storename, username));
+ setupContentAction(path, true);
}
/**
- * Submit an entire user sandbox
+ * Submit all nodes from user sandbox into the staging area sandbox via workflow
*/
- public void submitAll(ActionEvent event)
+ public void setupSubmitAllAction(ActionEvent event)
{
- UIActionLink link = (UIActionLink)event.getComponent();
- Map params = link.getParameterMap();
- String store = params.get("store");
- String username = params.get("username");
-
- String rootPath = AVMConstants.buildAVMStoreRootPath(store);
- NodeRef rootRef = AVMNodeConverter.ToNodeRef(-1, rootPath);
-
- UserTransaction tx = null;
- try
- {
- FacesContext context = FacesContext.getCurrentInstance();
- tx = Repository.getUserTransaction(context, true);
- tx.begin();
-
- Action action = this.actionService.createAction(SimpleAVMSubmitAction.NAME);
- this.actionService.executeAction(action, rootRef);
-
- // commit the transaction
- tx.commit();
-
- // if we get here, all was well - output friendly status message to the user
- String msg = MessageFormat.format(Application.getMessage(
- context, MSG_SUBMITALL_SUCCESS), username);
- displayStatusMessage(context, msg);
- }
- catch (Throwable err)
- {
- Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
- FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
- try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
- }
- }
-
- /**
- * Submit items selected using multi-select
- */
- public void submitSelected(ActionEvent event)
- {
- UIActionLink link = (UIActionLink)event.getComponent();
- Map params = link.getParameterMap();
- String username = params.get("username");
-
- List selected = this.userSandboxes.getSelectedNodes(username);
- if (selected != null)
- {
- UserTransaction tx = null;
- try
- {
- FacesContext context = FacesContext.getCurrentInstance();
- tx = Repository.getUserTransaction(context, false);
- tx.begin();
-
- // TODO: better to duplicate code in action rather than call multiple times?
- for (AVMNodeDescriptor node : selected)
- {
- Action action = this.actionService.createAction(SimpleAVMSubmitAction.NAME);
- this.actionService.executeAction(action, AVMNodeConverter.ToNodeRef(-1, node.getPath()));
- }
-
- // commit the transaction
- tx.commit();
-
- // if we get here, all was well - output friendly status message to the user
- // TODO: different message once the submit screen is available
- String msg = MessageFormat.format(Application.getMessage(
- context, MSG_SUBMITSELECTED_SUCCESS), username);
- displayStatusMessage(context, msg);
- }
- catch (Throwable err)
- {
- err.printStackTrace(System.err);
- Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
- FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
- try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
- }
- }
+ setupSandboxAction(event);
+ this.submitAll = true;
}
/**
diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java
index 994d986b58..293aac1f01 100644
--- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java
+++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java
@@ -52,9 +52,9 @@ import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.dialog.BaseDialogBean;
-import org.alfresco.web.forms.Form;
-import org.alfresco.web.forms.FormsService;
-import org.alfresco.web.forms.RenderingEngineTemplate;
+import org.alfresco.web.forms.FormInstanceData;
+import org.alfresco.web.forms.FormInstanceDataImpl;
+import org.alfresco.web.forms.Rendition;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.wcm.WebResources;
@@ -380,9 +380,18 @@ public class SubmitDialog extends BaseDialogBean
selected.add(node);
}
}
+ else if (this.avmBrowseBean.getAvmActionNode() == null)
+ {
+ // multiple items selected
+ selected = this.avmBrowseBean.getSelectedSandboxItems();
+ }
else
{
- selected = this.avmBrowseBean.getSelectedSandboxItems();
+ // single item selected
+ AVMNodeDescriptor node =
+ this.avmService.lookup(-1, this.avmBrowseBean.getAvmActionNode().getPath(), true);
+ selected = new ArrayList(1);
+ selected.add(node);
}
if (selected != null)
{
@@ -410,31 +419,33 @@ public class SubmitDialog extends BaseDialogBean
// found a generated rendition asset - locate the parent form instance data file
// and use this to find all generated assets that are appropriate
// NOTE: this ref will be in the 'preview' store convert back to user store first
- String formInstanceDataPath = AVMNodeConverter.ToAVMVersionPath(
- (NodeRef)this.nodeService.getProperty(
- ref, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA)).getSecond();
- formInstanceDataPath = formInstanceDataPath.replaceFirst(AVMConstants.STORE_PREVIEW,
- AVMConstants.STORE_MAIN);
- formInstanceDataRef = AVMNodeConverter.ToNodeRef(-1, formInstanceDataPath);
+ String strFormInstance = (String)this.nodeService.getProperty(
+ ref, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA);
+ strFormInstance = strFormInstance.replaceFirst(AVMConstants.STORE_PREVIEW,
+ AVMConstants.STORE_MAIN);
+ formInstanceDataRef = new NodeRef(strFormInstance);
}
// add the form instance data file to the list for submission
AVMNodeDescriptor formInstanceNode = this.avmService.lookup(
-1, AVMNodeConverter.ToAVMVersionPath(formInstanceDataRef).getSecond());
- this.submitItems.add(new ItemWrapper(formInstanceNode));
- submittedPaths.add(formInstanceNode.getPath());
+ if (submittedPaths.contains(formInstanceNode.getPath()) == false)
+ {
+ this.submitItems.add(new ItemWrapper(formInstanceNode));
+ submittedPaths.add(formInstanceNode.getPath());
+ }
// locate renditions for this form instance data file and add to list for submission
- NodeRef formNodeRef = (NodeRef)this.nodeService.getProperty(
- formInstanceDataRef, WCMAppModel.PROP_PARENT_FORM);
- Form form = FormsService.getInstance().getForm(formNodeRef);
- for (RenderingEngineTemplate ret : form.getRenderingEngineTemplates())
+ FormInstanceData formImpl = new FormInstanceDataImpl(formInstanceDataRef);
+ for (Rendition rendition : formImpl.getRenditions())
{
- String renditionAvmPath = FormsService.getOutputAvmPathForRendition(
- ret, formInstanceDataRef);
- AVMNodeDescriptor renditionNode = this.avmService.lookup(-1, renditionAvmPath);
- this.submitItems.add(new ItemWrapper(renditionNode));
- submittedPaths.add(renditionNode.getPath());
+ String renditionPath = rendition.getPath();
+ if (submittedPaths.contains(renditionPath) == false)
+ {
+ AVMNodeDescriptor renditionNode = this.avmService.lookup(-1, renditionPath);
+ this.submitItems.add(new ItemWrapper(renditionNode));
+ submittedPaths.add(renditionPath);
+ }
}
// lookup the associated Form workflow from the parent form property
@@ -455,11 +466,6 @@ public class SubmitDialog extends BaseDialogBean
submittedPaths.add(node.getPath());
}
}
- else
- {
- this.submitItems.add(new ItemWrapper(node));
- submittedPaths.add(node.getPath());
- }
}
else
{
diff --git a/source/java/org/alfresco/web/forms/Rendition.java b/source/java/org/alfresco/web/forms/Rendition.java
index a73b1e922b..3553bf373e 100644
--- a/source/java/org/alfresco/web/forms/Rendition.java
+++ b/source/java/org/alfresco/web/forms/Rendition.java
@@ -41,6 +41,9 @@ public interface Rendition
/** the node ref containing the contents of this rendition */
public NodeRef getNodeRef();
+
+ /** the path to the contents of this rendition */
+ public String getPath();
/** 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 bf76100d86..49cfb7c652 100644
--- a/source/java/org/alfresco/web/forms/RenditionImpl.java
+++ b/source/java/org/alfresco/web/forms/RenditionImpl.java
@@ -107,6 +107,11 @@ public class RenditionImpl
{
return this.nodeRef;
}
+
+ public String getPath()
+ {
+ return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
+ }
public String getUrl()
{