Merge V3.2 To HEAD

17834: Fix for ETHREEOH-3613. Now you can add two different pieces of content with the same name to a package.



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18230 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2010-01-21 17:22:18 +00:00
parent 4d31a35d31
commit d2796c513b
2 changed files with 896 additions and 853 deletions

View File

@@ -22,6 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.web.bean.workflow;
import java.io.Serializable;
@@ -137,26 +138,23 @@ public class ManageTaskDialog extends BaseDialogBean
{
// setup a transient node to represent the task we're managing
WorkflowTaskDefinition taskDef = this.task.definition;
this.taskNode = new TransientNode(taskDef.metadata.getName(),
"task_" + System.currentTimeMillis(), this.task.properties);
this.taskNode = new TransientNode(taskDef.metadata.getName(), "task_" + System.currentTimeMillis(),
this.task.properties);
// get access to the workflow instance for the task
this.workflowInstance = this.task.path.instance;
// setup the workflow package for the task
this.workflowPackage = (NodeRef)this.task.properties.get(WorkflowModel.ASSOC_PACKAGE);
this.workflowPackage = (NodeRef) this.task.properties.get(WorkflowModel.ASSOC_PACKAGE);
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Task: " + this.task);
LOGGER.debug("Trasient node: " + this.taskNode);
Boolean isSystemPackage = (Boolean)
this.getNodeService().getProperty(this.workflowPackage,
Boolean isSystemPackage = (Boolean) this.getNodeService().getProperty(this.workflowPackage,
WorkflowModel.PROP_IS_SYSTEM_PACKAGE);
LOGGER.debug("Workflow package: " + this.workflowPackage +
" system package: " + isSystemPackage);
boolean isWCMWorkflow = (this.workflowPackage.getStoreRef().getProtocol().equals(
StoreRef.PROTOCOL_AVM));
LOGGER.debug("Workflow package: " + this.workflowPackage + " system package: " + isSystemPackage);
boolean isWCMWorkflow = (this.workflowPackage.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM));
LOGGER.debug("is wcm workflow: " + isWCMWorkflow);
}
}
@@ -174,8 +172,7 @@ public class ManageTaskDialog extends BaseDialogBean
}
@Override
protected String finishImpl(FacesContext context, String outcome)
throws Exception
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
if (LOGGER.isDebugEnabled())
LOGGER.debug("Saving task: " + this.getWorkflowTask().id);
@@ -236,10 +233,11 @@ public class ManageTaskDialog extends BaseDialogBean
Object hiddenTransitions = this.taskNode.getProperties().get(WorkflowModel.PROP_HIDDEN_TRANSITIONS);
for (WorkflowTransition trans : this.transitions)
{
if (hiddenTransitions == null ||
(hiddenTransitions instanceof String && ((String)hiddenTransitions).equals("")) ||
(hiddenTransitions instanceof String && !((String)hiddenTransitions).equals(trans.id)) ||
(hiddenTransitions instanceof List) && !((List<String>)hiddenTransitions).contains(trans.id))
if (hiddenTransitions == null
|| (hiddenTransitions instanceof String && ((String) hiddenTransitions).equals(""))
|| (hiddenTransitions instanceof String && !((String) hiddenTransitions)
.equals(trans.id)) || (hiddenTransitions instanceof List<?>)
&& !((List<?>) hiddenTransitions).contains(trans.id))
{
buttons.add(new DialogButtonConfig(ID_PREFIX + trans.title, trans.title, null,
"#{DialogManager.bean.transition}", "false", null));
@@ -281,7 +279,7 @@ public class ManageTaskDialog extends BaseDialogBean
// ------------------------------------------------------------------------------
// Event handlers
@SuppressWarnings("unused")
@SuppressWarnings("deprecation")
public String takeOwnership()
{
String outcome = getDefaultFinishOutcome();
@@ -291,7 +289,8 @@ public class ManageTaskDialog extends BaseDialogBean
FacesContext context = FacesContext.getCurrentInstance();
// before taking ownership check the task still exists and is not completed
// before taking ownership check the task still exists and is not
// completed
WorkflowTask checkTask = this.getWorkflowService().getTaskById(this.getWorkflowTask().id);
if (checkTask == null || checkTask.state == WorkflowTaskState.COMPLETED)
{
@@ -322,7 +321,16 @@ public class ManageTaskDialog extends BaseDialogBean
catch (Throwable e)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
try
{
if (tx != null)
{
tx.rollback();
}
}
catch (Exception ex)
{
}
Utils.addErrorMessage(formatErrorMessage(e), e);
outcome = this.getErrorOutcome(e);
}
@@ -330,7 +338,7 @@ public class ManageTaskDialog extends BaseDialogBean
return outcome;
}
@SuppressWarnings("unused")
@SuppressWarnings("deprecation")
public String returnOwnership()
{
String outcome = getDefaultFinishOutcome();
@@ -339,7 +347,8 @@ public class ManageTaskDialog extends BaseDialogBean
LOGGER.debug("Returning ownership of task to pool: " + this.getWorkflowTask().id);
FacesContext context = FacesContext.getCurrentInstance();
// before returning ownership check the task still exists and is not completed
// before returning ownership check the task still exists and is not
// completed
WorkflowTask checkTask = this.getWorkflowService().getTaskById(this.getWorkflowTask().id);
if (checkTask == null || checkTask.state == WorkflowTaskState.COMPLETED)
{
@@ -368,7 +377,16 @@ public class ManageTaskDialog extends BaseDialogBean
catch (Throwable e)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
try
{
if (tx != null)
{
tx.rollback();
}
}
catch (Exception ex)
{
}
Utils.addErrorMessage(formatErrorMessage(e), e);
outcome = this.getErrorOutcome(e);
}
@@ -376,7 +394,7 @@ public class ManageTaskDialog extends BaseDialogBean
return outcome;
}
@SuppressWarnings("unused")
@SuppressWarnings("deprecation")
public String transition()
{
String outcome = getDefaultFinishOutcome();
@@ -396,7 +414,7 @@ public class ManageTaskDialog extends BaseDialogBean
// to find out which transition button was pressed we need
// to look for the button's id in the request parameters,
// the first non-null result is the button that was pressed.
Map reqParams = context.getExternalContext().getRequestParameterMap();
Map<?, ?> reqParams = context.getExternalContext().getRequestParameterMap();
String selectedTransition = null;
for (WorkflowTransition trans : this.getWorkflowTransitions())
@@ -439,7 +457,16 @@ public class ManageTaskDialog extends BaseDialogBean
catch (Throwable e)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
try
{
if (tx != null)
{
tx.rollback();
}
}
catch (Exception ex)
{
}
Utils.addErrorMessage(formatErrorMessage(e), e);
outcome = this.getErrorOutcome(e);
}
@@ -448,7 +475,8 @@ public class ManageTaskDialog extends BaseDialogBean
}
/**
* Prepares the dialog to allow the user to add an item to the workflow package
* Prepares the dialog to allow the user to add an item to the workflow
* package
*
* @param event The event
*/
@@ -484,9 +512,12 @@ public class ManageTaskDialog extends BaseDialogBean
for (String item : this.itemsToAdd)
{
// if this item is in the remove list it means it was there originally
// and has now been re-added, as a result we don't need to do anything
// to the original workflow package, therefore remove from the remove list
// if this item is in the remove list it means it was there
// originally
// and has now been re-added, as a result we don't need to do
// anything
// to the original workflow package, therefore remove from the
// remove list
if (this.packageItemsToRemove != null && this.packageItemsToRemove.contains(item))
{
this.packageItemsToRemove.remove(item);
@@ -518,13 +549,14 @@ public class ManageTaskDialog extends BaseDialogBean
*/
public void removePackageItem(ActionEvent event)
{
UIActionLink link = (UIActionLink)event.getComponent();
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String nodeRef = new NodeRef(Repository.getStoreRef(), params.get("id")).toString();
if (this.packageItemsToAdd != null && this.packageItemsToAdd.contains(nodeRef))
{
// remove the item from the added list if it was added in this dialog session
// remove the item from the added list if it was added in this
// dialog session
this.packageItemsToAdd.remove(nodeRef);
if (LOGGER.isDebugEnabled())
@@ -551,7 +583,8 @@ public class ManageTaskDialog extends BaseDialogBean
/**
* Toggles the complete flag for a workflow package item
*
* @param event The event containing a reference to the item to toggle the status for
* @param event The event containing a reference to the item to toggle the
* status for
*/
public void togglePackageItemComplete(ActionEvent event)
{
@@ -562,7 +595,8 @@ public class ManageTaskDialog extends BaseDialogBean
// Bean Getters and Setters
/**
* Returns a String array of NodeRef's that are being added to the workflow package
* Returns a String array of NodeRef's that are being added to the workflow
* package
*
* @return String array of NodeRef's
*/
@@ -582,7 +616,8 @@ public class ManageTaskDialog extends BaseDialogBean
}
/**
* Determines whether an item is currently being added to the workflow package
* Determines whether an item is currently being added to the workflow
* package
*
* @return true if an item is being added
*/
@@ -628,7 +663,7 @@ public class ManageTaskDialog extends BaseDialogBean
*/
public boolean isPooledTask()
{
List pooledActors = (List)taskNode.getAssociations().get(WorkflowModel.ASSOC_POOLED_ACTORS);
List<?> pooledActors = (List<?>) taskNode.getAssociations().get(WorkflowModel.ASSOC_POOLED_ACTORS);
return (pooledActors != null && pooledActors.size() > 0);
}
@@ -663,24 +698,23 @@ public class ManageTaskDialog extends BaseDialogBean
*/
public String getPackageActionGroup()
{
return (String)this.getWorkflowTask().properties.get(
WorkflowModel.PROP_PACKAGE_ACTION_GROUP);
return (String) this.getWorkflowTask().properties.get(WorkflowModel.PROP_PACKAGE_ACTION_GROUP);
}
/**
* Returns the action group the current task uses for each workflow package item
* Returns the action group the current task uses for each workflow package
* item
*
* @return action group id
*/
public String getPackageItemActionGroup()
{
return (String)this.getWorkflowTask().properties.get(
WorkflowModel.PROP_PACKAGE_ITEM_ACTION_GROUP);
return (String) this.getWorkflowTask().properties.get(WorkflowModel.PROP_PACKAGE_ITEM_ACTION_GROUP);
}
/**
* Returns a list of resources associated with this task
* i.e. the children of the workflow package
* Returns a list of resources associated with this task i.e. the children
* of the workflow package
*
* @return The list of nodes
*/
@@ -699,34 +733,37 @@ public class ManageTaskDialog extends BaseDialogBean
List<NodeRef> contents = this.workflowService.getPackageContents(getWorkflowTask().id);
for (NodeRef nodeRef : contents)
{
if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
{
Pair<Integer, String> vp = AVMNodeConverter.ToAVMVersionPath(nodeRef);
this.addAVMNode(new AVMNode(this.getAvmService().lookup(vp.getFirst(),
vp.getSecond(),
true)));
this.addAVMNode(new AVMNode(this.getAvmService().lookup(vp.getFirst(), vp.getSecond(), true)));
}
else
{
if (this.getNodeService().exists(nodeRef))
{
// find it's type so we can see if it's a node we are interested in
// find it's type so we can see if it's a node we
// are interested in
QName type = this.getNodeService().getType(nodeRef);
// make sure the type is defined in the data dictionary
// make sure the type is defined in the data
// dictionary
if (this.getDictionaryService().getType(type) != null)
{
// look for content nodes or links to content
// NOTE: folders within workflow packages are ignored for now
if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT) || ApplicationModel.TYPE_FILELINK.equals(type))
// NOTE: folders within workflow packages are
// ignored for now
if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT)
|| ApplicationModel.TYPE_FILELINK.equals(type))
{
// if the node is not in the removed list then add create the
// client side representation and add to the list
if (this.packageItemsToRemove == null ||
this.packageItemsToRemove.contains(nodeRef.toString()) == false)
// if the node is not in the removed list
// then add create the
// client side representation and add to the
// list
if (this.packageItemsToRemove == null
|| this.packageItemsToRemove.contains(nodeRef.toString()) == false)
{
createAndAddNode(nodeRef);
}
@@ -736,8 +773,8 @@ public class ManageTaskDialog extends BaseDialogBean
}
}
// now iterate through the items to add list and add them to the list of resources
// now iterate through the items to add list and add them to the
// list of resources
if (this.packageItemsToAdd != null)
{
for (String newItem : this.packageItemsToAdd)
@@ -745,8 +782,10 @@ public class ManageTaskDialog extends BaseDialogBean
NodeRef nodeRef = new NodeRef(newItem);
if (this.getNodeService().exists(nodeRef))
{
// we know the type is correct as this was added as a result of a query
// for all content items so just add the item to the resources list
// we know the type is correct as this was added as
// a result of a query
// for all content items so just add the item to the
// resources list
createAndAddNode(nodeRef);
}
else
@@ -762,10 +801,19 @@ public class ManageTaskDialog extends BaseDialogBean
}
catch (Throwable err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
this.resources = Collections.<Node>emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(),
Repository.ERROR_GENERIC), err.getMessage()), err);
this.resources = Collections.<Node> emptyList();
try
{
if (tx != null)
{
tx.rollback();
}
}
catch (Exception tex)
{
}
}
}
else if (LOGGER.isDebugEnabled())
@@ -779,8 +827,7 @@ public class ManageTaskDialog extends BaseDialogBean
/**
* Sets the workflow service to use
*
* @param workflowService
* WorkflowService instance
* @param workflowService WorkflowService instance
*/
public void setWorkflowService(WorkflowService workflowService)
{
@@ -799,8 +846,7 @@ public class ManageTaskDialog extends BaseDialogBean
/**
* Sets the avm service to use
*
* @param avmService
* AvmService instance
* @param avmService AvmService instance
*/
public void setAvmService(final AVMService avmService)
{
@@ -819,8 +865,7 @@ public class ManageTaskDialog extends BaseDialogBean
/**
* Sets the avm sync service to use
*
* @param avmSyncService
* AvmSycService instance
* @param avmSyncService AvmSycService instance
*/
public void setAvmSyncService(final AVMSyncService avmSyncService)
{
@@ -848,7 +893,8 @@ public class ManageTaskDialog extends BaseDialogBean
{
if (wpService == null)
{
wpService = (WebProjectService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "WebProjectService");
wpService = (WebProjectService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(),
"WebProjectService");
}
return wpService;
}
@@ -889,8 +935,7 @@ public class ManageTaskDialog extends BaseDialogBean
this.resources.add(node);
if (node.isDirectory() && !node.getDescriptor().isDeleted())
{
for (final AVMNodeDescriptor d :
this.getAvmService().getDirectoryListingArray(node.getDescriptor(), true))
for (final AVMNodeDescriptor d : this.getAvmService().getDirectoryListingArray(node.getDescriptor(), true))
{
this.addAVMNode(new AVMNode(d));
}
@@ -907,8 +952,9 @@ public class ManageTaskDialog extends BaseDialogBean
node.addPropertyResolver("path", this.browseBean.resolverPath);
node.addPropertyResolver("displayPath", this.browseBean.resolverDisplayPath);
// add a property resolver to indicate whether the item has been completed or not
// node.addPropertyResolver("completed", this.completeResolver);
// add a property resolver to indicate whether the item has been
// completed or not
// node.addPropertyResolver("completed", this.completeResolver);
// add the id of the task being managed
node.getProperties().put("taskId", this.getWorkflowTask().id);
@@ -919,8 +965,7 @@ public class ManageTaskDialog extends BaseDialogBean
protected void updateResources()
{
// remove any items the user selected to remove
if (this.workflowPackage != null && this.packageItemsToRemove != null &&
this.packageItemsToRemove.size() > 0)
if (this.workflowPackage != null && this.packageItemsToRemove != null && this.packageItemsToRemove.size() > 0)
{
for (String removedItem : this.packageItemsToRemove)
{
@@ -929,16 +974,18 @@ public class ManageTaskDialog extends BaseDialogBean
}
// add any items the user selected to add
if (this.workflowPackage != null && this.packageItemsToAdd != null &&
this.packageItemsToAdd.size() > 0)
if (this.workflowPackage != null && this.packageItemsToAdd != null && this.packageItemsToAdd.size() > 0)
{
for (String addedItem : this.packageItemsToAdd)
{
NodeRef addedNodeRef = new NodeRef(addedItem);
this.getNodeService().addChild(this.workflowPackage, addedNodeRef,
ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
QName.createValidLocalName((String)this.getNodeService().getProperty(
addedNodeRef, ContentModel.PROP_NAME))));
this.getNodeService().addChild(
this.workflowPackage,
addedNodeRef,
WorkflowModel.ASSOC_PACKAGE_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName
.createValidLocalName((String) this.getNodeService().getProperty(addedNodeRef,
ContentModel.PROP_NAME))));
}
}
}
@@ -947,7 +994,8 @@ public class ManageTaskDialog extends BaseDialogBean
// Inner classes
/**
* Property resolver to determine if the given node has been flagged as complete
* Property resolver to determine if the given node has been flagged as
* complete
*/
protected class TaskCompleteResolver implements NodePropertyResolver
{
@@ -956,16 +1004,11 @@ public class ManageTaskDialog extends BaseDialogBean
public Object get(Node node)
{
String result = Application.getMessage(FacesContext.getCurrentInstance(), "no");
List<NodeRef> completedItems = (List<NodeRef>)getWorkflowTask().properties.get(
WorkflowModel.PROP_COMPLETED_ITEMS);
if (completedItems != null && completedItems.size() > 0 &&
completedItems.contains(node.getNodeRef()))
List<?> completedItems = (List<?>) getWorkflowTask().properties.get(WorkflowModel.PROP_COMPLETED_ITEMS);
if (completedItems != null && completedItems.size() > 0 && completedItems.contains(node.getNodeRef()))
{
result = Application.getMessage(FacesContext.getCurrentInstance(), "yes");
}
return result;
}
}

View File

@@ -207,7 +207,7 @@ public class StartWorkflowWizard extends BaseWizardBean
{
NodeRef addedNodeRef = new NodeRef(addedItem);
this.getUnprotectedNodeService().addChild(workflowPackage, addedNodeRef,
ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
WorkflowModel.ASSOC_PACKAGE_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
QName.createValidLocalName((String)this.getNodeService().getProperty(
addedNodeRef, ContentModel.PROP_NAME))));
}