mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. Single item, multiple item and all items submit now all go through the same Submit Dialog
. Changed submit form rendition calculation code to use new helper method provided by Ariel git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4566 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -79,7 +79,8 @@
|
|||||||
</permissions>
|
</permissions>
|
||||||
<label-id>submit</label-id>
|
<label-id>submit</label-id>
|
||||||
<image>/images/icons/submit.gif</image>
|
<image>/images/icons/submit.gif</image>
|
||||||
<action-listener>#{AVMBrowseBean.submitNode}</action-listener>
|
<action-listener>#{AVMBrowseBean.setupSubmitNodeAction}</action-listener>
|
||||||
|
<action>dialog:submitSandboxItems</action>
|
||||||
<params>
|
<params>
|
||||||
<param name="id">#{actionContext.path}</param>
|
<param name="id">#{actionContext.path}</param>
|
||||||
</params>
|
</params>
|
||||||
|
@@ -736,6 +736,17 @@ public class AVMBrowseBean implements IContextListener
|
|||||||
String store = params.get("store");
|
String store = params.get("store");
|
||||||
String username = params.get("username");
|
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
|
// can be null if it's the staging store - i.e. not a user specific store
|
||||||
setUsername(username);
|
setUsername(username);
|
||||||
|
|
||||||
@@ -756,16 +767,11 @@ public class AVMBrowseBean implements IContextListener
|
|||||||
// update UI state ready for return to the previous screen
|
// update UI state ready for return to the previous screen
|
||||||
this.location = null;
|
this.location = null;
|
||||||
setCurrentPath(null);
|
setCurrentPath(null);
|
||||||
|
setAvmActionNode(null);
|
||||||
|
|
||||||
this.submitAll = false;
|
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
|
* 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
|
* 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);
|
String path = getPathFromEventArgs(event);
|
||||||
|
String[] parts = path.split("[-:]");
|
||||||
UserTransaction tx = null;
|
String storename = parts[0];
|
||||||
try
|
String username = parts[1];
|
||||||
{
|
setupSandboxActionImpl(username, AVMConstants.buildAVMUserMainStoreName(storename, username));
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
setupContentAction(path, true);
|
||||||
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) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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();
|
setupSandboxAction(event);
|
||||||
Map<String, String> params = link.getParameterMap();
|
this.submitAll = true;
|
||||||
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<String, String> params = link.getParameterMap();
|
|
||||||
String username = params.get("username");
|
|
||||||
|
|
||||||
List<AVMNodeDescriptor> 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) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -52,9 +52,9 @@ import org.alfresco.web.app.Application;
|
|||||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||||
import org.alfresco.web.bean.BrowseBean;
|
import org.alfresco.web.bean.BrowseBean;
|
||||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||||
import org.alfresco.web.forms.Form;
|
import org.alfresco.web.forms.FormInstanceData;
|
||||||
import org.alfresco.web.forms.FormsService;
|
import org.alfresco.web.forms.FormInstanceDataImpl;
|
||||||
import org.alfresco.web.forms.RenderingEngineTemplate;
|
import org.alfresco.web.forms.Rendition;
|
||||||
import org.alfresco.web.ui.common.Utils;
|
import org.alfresco.web.ui.common.Utils;
|
||||||
import org.alfresco.web.ui.common.component.UIListItem;
|
import org.alfresco.web.ui.common.component.UIListItem;
|
||||||
import org.alfresco.web.ui.wcm.WebResources;
|
import org.alfresco.web.ui.wcm.WebResources;
|
||||||
@@ -380,9 +380,18 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
selected.add(node);
|
selected.add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (this.avmBrowseBean.getAvmActionNode() == null)
|
||||||
|
{
|
||||||
|
// multiple items selected
|
||||||
|
selected = this.avmBrowseBean.getSelectedSandboxItems();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selected = this.avmBrowseBean.getSelectedSandboxItems();
|
// single item selected
|
||||||
|
AVMNodeDescriptor node =
|
||||||
|
this.avmService.lookup(-1, this.avmBrowseBean.getAvmActionNode().getPath(), true);
|
||||||
|
selected = new ArrayList<AVMNodeDescriptor>(1);
|
||||||
|
selected.add(node);
|
||||||
}
|
}
|
||||||
if (selected != null)
|
if (selected != null)
|
||||||
{
|
{
|
||||||
@@ -410,31 +419,33 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
// found a generated rendition asset - locate the parent form instance data file
|
// found a generated rendition asset - locate the parent form instance data file
|
||||||
// and use this to find all generated assets that are appropriate
|
// 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
|
// NOTE: this ref will be in the 'preview' store convert back to user store first
|
||||||
String formInstanceDataPath = AVMNodeConverter.ToAVMVersionPath(
|
String strFormInstance = (String)this.nodeService.getProperty(
|
||||||
(NodeRef)this.nodeService.getProperty(
|
ref, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA);
|
||||||
ref, WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA)).getSecond();
|
strFormInstance = strFormInstance.replaceFirst(AVMConstants.STORE_PREVIEW,
|
||||||
formInstanceDataPath = formInstanceDataPath.replaceFirst(AVMConstants.STORE_PREVIEW,
|
|
||||||
AVMConstants.STORE_MAIN);
|
AVMConstants.STORE_MAIN);
|
||||||
formInstanceDataRef = AVMNodeConverter.ToNodeRef(-1, formInstanceDataPath);
|
formInstanceDataRef = new NodeRef(strFormInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the form instance data file to the list for submission
|
// add the form instance data file to the list for submission
|
||||||
AVMNodeDescriptor formInstanceNode = this.avmService.lookup(
|
AVMNodeDescriptor formInstanceNode = this.avmService.lookup(
|
||||||
-1, AVMNodeConverter.ToAVMVersionPath(formInstanceDataRef).getSecond());
|
-1, AVMNodeConverter.ToAVMVersionPath(formInstanceDataRef).getSecond());
|
||||||
|
if (submittedPaths.contains(formInstanceNode.getPath()) == false)
|
||||||
|
{
|
||||||
this.submitItems.add(new ItemWrapper(formInstanceNode));
|
this.submitItems.add(new ItemWrapper(formInstanceNode));
|
||||||
submittedPaths.add(formInstanceNode.getPath());
|
submittedPaths.add(formInstanceNode.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
// locate renditions for this form instance data file and add to list for submission
|
// locate renditions for this form instance data file and add to list for submission
|
||||||
NodeRef formNodeRef = (NodeRef)this.nodeService.getProperty(
|
FormInstanceData formImpl = new FormInstanceDataImpl(formInstanceDataRef);
|
||||||
formInstanceDataRef, WCMAppModel.PROP_PARENT_FORM);
|
for (Rendition rendition : formImpl.getRenditions())
|
||||||
Form form = FormsService.getInstance().getForm(formNodeRef);
|
|
||||||
for (RenderingEngineTemplate ret : form.getRenderingEngineTemplates())
|
|
||||||
{
|
{
|
||||||
String renditionAvmPath = FormsService.getOutputAvmPathForRendition(
|
String renditionPath = rendition.getPath();
|
||||||
ret, formInstanceDataRef);
|
if (submittedPaths.contains(renditionPath) == false)
|
||||||
AVMNodeDescriptor renditionNode = this.avmService.lookup(-1, renditionAvmPath);
|
{
|
||||||
|
AVMNodeDescriptor renditionNode = this.avmService.lookup(-1, renditionPath);
|
||||||
this.submitItems.add(new ItemWrapper(renditionNode));
|
this.submitItems.add(new ItemWrapper(renditionNode));
|
||||||
submittedPaths.add(renditionNode.getPath());
|
submittedPaths.add(renditionPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookup the associated Form workflow from the parent form property
|
// lookup the associated Form workflow from the parent form property
|
||||||
@@ -455,11 +466,6 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
submittedPaths.add(node.getPath());
|
submittedPaths.add(node.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
this.submitItems.add(new ItemWrapper(node));
|
|
||||||
submittedPaths.add(node.getPath());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -42,6 +42,9 @@ public interface Rendition
|
|||||||
/** the node ref containing the contents of this rendition */
|
/** the node ref containing the contents of this rendition */
|
||||||
public NodeRef getNodeRef();
|
public NodeRef getNodeRef();
|
||||||
|
|
||||||
|
/** the path to the contents of this rendition */
|
||||||
|
public String getPath();
|
||||||
|
|
||||||
/** the url to the asset */
|
/** the url to the asset */
|
||||||
public String getUrl();
|
public String getUrl();
|
||||||
|
|
||||||
|
@@ -108,6 +108,11 @@ public class RenditionImpl
|
|||||||
return this.nodeRef;
|
return this.nodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPath()
|
||||||
|
{
|
||||||
|
return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
|
||||||
|
}
|
||||||
|
|
||||||
public String getUrl()
|
public String getUrl()
|
||||||
{
|
{
|
||||||
return AVMConstants.buildAVMAssetUrl(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond());
|
return AVMConstants.buildAVMAssetUrl(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond());
|
||||||
|
Reference in New Issue
Block a user