mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.3-BUG-FIX to HEAD
23054: Merged BRANCHES/DEV/BELARUS/V3.3-BUG-FIX-2010_10_04 to BRANCHES/DEV/V3.3-BUG-FIX: 23044: ALF-5112 : Bug fix for ALF-3962 is incomplete (can cause fix-up of version history to be incorrectly ordered - in case where versions have the same frozen modified date) - merged with some updates, eg. force unit test to exercise the fix 23058: ALF-4379: Don't mix up email recipients for different actions git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@23059 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,11 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.web.bean.actions;
|
package org.alfresco.web.bean.actions;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -35,9 +34,6 @@ import javax.faces.model.DataModel;
|
|||||||
import javax.faces.model.ListDataModel;
|
import javax.faces.model.ListDataModel;
|
||||||
import javax.faces.model.SelectItem;
|
import javax.faces.model.SelectItem;
|
||||||
|
|
||||||
import org.springframework.extensions.config.Config;
|
|
||||||
import org.springframework.extensions.config.ConfigElement;
|
|
||||||
import org.springframework.extensions.config.ConfigService;
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||||
@@ -63,6 +59,9 @@ import org.alfresco.web.ui.common.Utils;
|
|||||||
import org.alfresco.web.ui.common.component.UIGenericPicker;
|
import org.alfresco.web.ui.common.component.UIGenericPicker;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.extensions.config.Config;
|
||||||
|
import org.springframework.extensions.config.ConfigElement;
|
||||||
|
import org.springframework.extensions.config.ConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for the "Run Action" and "Create Rule" wizards.
|
* Base class for the "Run Action" and "Create Rule" wizards.
|
||||||
@@ -73,6 +72,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
{
|
{
|
||||||
protected static final String PROP_ACTION_NAME = "actionName";
|
protected static final String PROP_ACTION_NAME = "actionName";
|
||||||
protected static final String PROP_ACTION_SUMMARY = "actionSummary";
|
protected static final String PROP_ACTION_SUMMARY = "actionSummary";
|
||||||
|
protected static final String PROP_ACTION_EMAIL_RECIPIENTS= "actionEmailRecipients";
|
||||||
protected static final String NO_PARAMS_MARKER = "noParamsMarker";
|
protected static final String NO_PARAMS_MARKER = "noParamsMarker";
|
||||||
protected static final String ERROR_ACTION_CANNOT_BE_EXECUTE_REPEATEDLY = "action_cannot_be_execute_repeatedly";
|
protected static final String ERROR_ACTION_CANNOT_BE_EXECUTE_REPEATEDLY = "action_cannot_be_execute_repeatedly";
|
||||||
|
|
||||||
@@ -91,10 +91,8 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
protected List<SelectItem> users;
|
protected List<SelectItem> users;
|
||||||
protected List<SelectItem> encodings;
|
protected List<SelectItem> encodings;
|
||||||
protected List<SelectItem> objectTypes;
|
protected List<SelectItem> objectTypes;
|
||||||
protected List<RecipientWrapper> emailRecipients;
|
|
||||||
|
|
||||||
transient protected DataModel allActionsDataModel;
|
transient protected DataModel allActionsDataModel;
|
||||||
transient protected DataModel emailRecipientsDataModel;
|
transient protected DataModel currentEmailRecipientsDataModel;
|
||||||
|
|
||||||
protected boolean editingAction;
|
protected boolean editingAction;
|
||||||
protected String action;
|
protected String action;
|
||||||
@@ -119,13 +117,14 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
this.action = null;
|
this.action = null;
|
||||||
this.users = null;
|
this.users = null;
|
||||||
this.actions = null;
|
this.actions = null;
|
||||||
this.emailRecipientsDataModel = null;
|
this.currentEmailRecipientsDataModel = null;
|
||||||
this.usingTemplate = null;
|
this.usingTemplate = null;
|
||||||
|
|
||||||
this.emailRecipients = new ArrayList<RecipientWrapper>(4);
|
|
||||||
this.allActionsProperties = new ArrayList<Map<String, Serializable>>();
|
this.allActionsProperties = new ArrayList<Map<String, Serializable>>();
|
||||||
this.currentActionProperties = new HashMap<String, Serializable>(3);
|
this.currentActionProperties = new HashMap<String, Serializable>(3);
|
||||||
|
|
||||||
|
this.editingAction = false;
|
||||||
|
|
||||||
initialiseActionHandlers();
|
initialiseActionHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,14 +187,14 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
*/
|
*/
|
||||||
public DataModel getEmailRecipientsDataModel()
|
public DataModel getEmailRecipientsDataModel()
|
||||||
{
|
{
|
||||||
if (this.emailRecipientsDataModel == null)
|
if (this.currentEmailRecipientsDataModel == null)
|
||||||
{
|
{
|
||||||
this.emailRecipientsDataModel = new ListDataModel();
|
this.currentEmailRecipientsDataModel = new ListDataModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emailRecipientsDataModel.setWrappedData(this.emailRecipients);
|
this.currentEmailRecipientsDataModel.setWrappedData(getEmailRecipients(this.currentActionProperties));
|
||||||
|
|
||||||
return this.emailRecipientsDataModel;
|
return this.currentEmailRecipientsDataModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -590,9 +589,15 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
*
|
*
|
||||||
* @return List of email recipients
|
* @return List of email recipients
|
||||||
*/
|
*/
|
||||||
public List<RecipientWrapper> getEmailRecipients()
|
public List<RecipientWrapper> getEmailRecipients(Map<String, Serializable> actionProperties)
|
||||||
{
|
{
|
||||||
return this.emailRecipients;
|
List<RecipientWrapper> currentEmailRecipients = (List<RecipientWrapper>) actionProperties.get(PROP_ACTION_EMAIL_RECIPIENTS);
|
||||||
|
if (currentEmailRecipients == null)
|
||||||
|
{
|
||||||
|
currentEmailRecipients = new ArrayList<RecipientWrapper>(4);
|
||||||
|
actionProperties.put(PROP_ACTION_EMAIL_RECIPIENTS, (Serializable)currentEmailRecipients);
|
||||||
|
}
|
||||||
|
return currentEmailRecipients;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
@@ -613,6 +618,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
HashMap<String, Serializable> actionProps = new HashMap<String, Serializable>(3);
|
HashMap<String, Serializable> actionProps = new HashMap<String, Serializable>(3);
|
||||||
actionProps.put(PROP_ACTION_NAME, this.action);
|
actionProps.put(PROP_ACTION_NAME, this.action);
|
||||||
this.currentActionProperties = actionProps;
|
this.currentActionProperties = actionProps;
|
||||||
|
this.currentEmailRecipientsDataModel = null;
|
||||||
|
|
||||||
// get the handler for the action, if there isn't one we presume it
|
// get the handler for the action, if there isn't one we presume it
|
||||||
// is a no-parameter action
|
// is a no-parameter action
|
||||||
@@ -660,9 +666,10 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
{
|
{
|
||||||
// use the built in JSF support for retrieving the object for the
|
// use the built in JSF support for retrieving the object for the
|
||||||
// row that was clicked by the user
|
// row that was clicked by the user
|
||||||
Map actionToEdit = (Map)this.allActionsDataModel.getRowData();
|
int index = this.allActionsDataModel.getRowIndex();
|
||||||
this.action = (String)actionToEdit.get(PROP_ACTION_NAME);
|
this.currentActionProperties = this.allActionsProperties.get(index);
|
||||||
this.currentActionProperties = actionToEdit;
|
this.action = (String)this.currentActionProperties.get(PROP_ACTION_NAME);
|
||||||
|
this.currentEmailRecipientsDataModel = null;
|
||||||
|
|
||||||
// set the flag to show we are editing an action
|
// set the flag to show we are editing an action
|
||||||
this.editingAction = true;
|
this.editingAction = true;
|
||||||
@@ -713,8 +720,8 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
// use the built in JSF support for retrieving the object for the
|
// use the built in JSF support for retrieving the object for the
|
||||||
// row that was clicked by the user
|
// row that was clicked by the user
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map actionToRemove = (Map)this.allActionsDataModel.getRowData();
|
int index = this.allActionsDataModel.getRowIndex();
|
||||||
this.allActionsProperties.remove(actionToRemove);
|
this.allActionsProperties.remove(index);
|
||||||
|
|
||||||
// reset the action drop down
|
// reset the action drop down
|
||||||
this.action = null;
|
this.action = null;
|
||||||
@@ -750,13 +757,14 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
String[] results = picker.getSelectedResults();
|
String[] results = picker.getSelectedResults();
|
||||||
if (results != null && results.length != 0)
|
if (results != null && results.length != 0)
|
||||||
{
|
{
|
||||||
|
List<RecipientWrapper> currentEmailRecipients = getEmailRecipients(this.currentActionProperties);
|
||||||
for (String authority : results)
|
for (String authority : results)
|
||||||
{
|
{
|
||||||
// first check the authority has not already been added to the list
|
// first check the authority has not already been added to the list
|
||||||
boolean alreadyAdded = false;
|
boolean alreadyAdded = false;
|
||||||
for (int i=0; i<emailRecipients.size(); i++)
|
for (int i=0; i<currentEmailRecipients.size(); i++)
|
||||||
{
|
{
|
||||||
RecipientWrapper wrapper = emailRecipients.get(i);
|
RecipientWrapper wrapper = currentEmailRecipients.get(i);
|
||||||
if (wrapper.getAuthority().equals(authority))
|
if (wrapper.getAuthority().equals(authority))
|
||||||
{
|
{
|
||||||
alreadyAdded = true;
|
alreadyAdded = true;
|
||||||
@@ -771,7 +779,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
|
|
||||||
// add the recipient to the list
|
// add the recipient to the list
|
||||||
RecipientWrapper wrapper = new RecipientWrapper(name, authority);
|
RecipientWrapper wrapper = new RecipientWrapper(name, authority);
|
||||||
this.emailRecipients.add(wrapper);
|
currentEmailRecipients.add(wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -782,8 +790,9 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
*/
|
*/
|
||||||
public void removeRecipient(ActionEvent event)
|
public void removeRecipient(ActionEvent event)
|
||||||
{
|
{
|
||||||
RecipientWrapper wrapper = (RecipientWrapper)this.emailRecipientsDataModel.getRowData();
|
List<RecipientWrapper> currentEmailRecipients = getEmailRecipients(this.currentActionProperties);
|
||||||
this.emailRecipients.remove(wrapper);
|
int index = this.currentEmailRecipientsDataModel.getRowIndex();
|
||||||
|
currentEmailRecipients.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1065,9 +1074,10 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
|
|
||||||
public boolean isFinishButtonDisabled()
|
public boolean isFinishButtonDisabled()
|
||||||
{
|
{
|
||||||
if (emailRecipients != null)
|
List<RecipientWrapper> currentEmailRecipients = (List<RecipientWrapper>) this.currentActionProperties.get(PROP_ACTION_EMAIL_RECIPIENTS);
|
||||||
|
if (currentEmailRecipients != null)
|
||||||
{
|
{
|
||||||
return emailRecipients.isEmpty();
|
return currentEmailRecipients.isEmpty();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1136,14 +1146,4 @@ public abstract class BaseActionWizard extends BaseWizardBean
|
|||||||
private String name;
|
private String name;
|
||||||
private String authority;
|
private String authority;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
|
|
||||||
{
|
|
||||||
in.defaultReadObject();
|
|
||||||
|
|
||||||
this.allActionsDataModel = new ListDataModel();
|
|
||||||
this.allActionsDataModel.setWrappedData(this.allActionsProperties);
|
|
||||||
this.emailRecipientsDataModel = new ListDataModel();
|
|
||||||
this.emailRecipientsDataModel.setWrappedData(this.emailRecipients);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -62,10 +62,11 @@ public class MailHandler extends BaseActionHandler
|
|||||||
getWizardManager().getBean();
|
getWizardManager().getBean();
|
||||||
|
|
||||||
// add the person(s) it's going to as a list of authorities
|
// add the person(s) it's going to as a list of authorities
|
||||||
List<String> recipients = new ArrayList<String>(wizard.getEmailRecipients().size());
|
List<RecipientWrapper> wizardRecipients = wizard.getEmailRecipients(actionProps);
|
||||||
for (int i=0; i < wizard.getEmailRecipients().size(); i++)
|
List<String> recipients = new ArrayList<String>(wizardRecipients.size());
|
||||||
|
for (int i=0; i < wizardRecipients.size(); i++)
|
||||||
{
|
{
|
||||||
RecipientWrapper wrapper = wizard.getEmailRecipients().get(i);
|
RecipientWrapper wrapper = wizardRecipients.get(i);
|
||||||
recipients.add(wrapper.getAuthority());
|
recipients.add(wrapper.getAuthority());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +134,7 @@ public void prepareForEdit(Map<String, Serializable> actionProps,
|
|||||||
// rebuild the list of RecipientWrapper objects from the stored action
|
// rebuild the list of RecipientWrapper objects from the stored action
|
||||||
for (String authority : recipients)
|
for (String authority : recipients)
|
||||||
{
|
{
|
||||||
wizard.getEmailRecipients().add(
|
wizard.getEmailRecipients(actionProps).add(
|
||||||
new RecipientWrapper(wizard.displayLabelForAuthority(authority),
|
new RecipientWrapper(wizard.displayLabelForAuthority(authority),
|
||||||
authority));
|
authority));
|
||||||
}
|
}
|
||||||
@@ -157,13 +158,14 @@ public void prepareForEdit(Map<String, Serializable> actionProps,
|
|||||||
|
|
||||||
if (addresses == null || addresses.length() == 0)
|
if (addresses == null || addresses.length() == 0)
|
||||||
{
|
{
|
||||||
if (actionWizard.getEmailRecipients().size() != 0)
|
List<RecipientWrapper> wizardRecipients = actionWizard.getEmailRecipients(actionProps);
|
||||||
|
if (wizardRecipients.size() != 0)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
for (int i=0; i < actionWizard.getEmailRecipients().size(); i++)
|
for (int i=0; i < wizardRecipients.size(); i++)
|
||||||
{
|
{
|
||||||
RecipientWrapper wrapper = actionWizard.getEmailRecipients().get(i);
|
RecipientWrapper wrapper = wizardRecipients.get(i);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
builder.append(", ");
|
builder.append(", ");
|
||||||
|
@@ -101,6 +101,7 @@ public class EditRuleWizard extends CreateCompositeRuleWizard
|
|||||||
for (Action action : actions)
|
for (Action action : actions)
|
||||||
{
|
{
|
||||||
this.currentActionProperties = new HashMap<String, Serializable>(3);
|
this.currentActionProperties = new HashMap<String, Serializable>(3);
|
||||||
|
this.currentEmailRecipientsDataModel = null;
|
||||||
this.action = action.getActionDefinitionName();
|
this.action = action.getActionDefinitionName();
|
||||||
this.currentActionProperties.put(PROP_ACTION_NAME, this.action);
|
this.currentActionProperties.put(PROP_ACTION_NAME, this.action);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user