mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merge pull request #1487 from Alfresco/feature/ACS-3595_ActionParamMap
ACS-3651 Use Serializable for values in action parameters.
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
package org.alfresco.rest.actions.access;
|
package org.alfresco.rest.actions.access;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
import org.alfresco.rest.actions.access.pojo.Action;
|
import org.alfresco.rest.actions.access.pojo.Action;
|
||||||
import org.alfresco.rest.actions.access.pojo.ActionCondition;
|
import org.alfresco.rest.actions.access.pojo.ActionCondition;
|
||||||
import org.alfresco.rest.actions.access.pojo.Rule;
|
import org.alfresco.rest.actions.access.pojo.Rule;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class AccessRestrictionUtil {
|
public class AccessRestrictionUtil {
|
||||||
|
|
||||||
public static final String MAIL_ACTION = "mail";
|
public static final String MAIL_ACTION = "mail";
|
||||||
@@ -19,8 +21,8 @@ public class AccessRestrictionUtil {
|
|||||||
"Only admin or system user is allowed to define uses of or directly execute this action";
|
"Only admin or system user is allowed to define uses of or directly execute this action";
|
||||||
private static final String ERROR_MESSAGE_FAILED_TO_SEND_EMAIL = "Failed to send email to:";
|
private static final String ERROR_MESSAGE_FAILED_TO_SEND_EMAIL = "Failed to send email to:";
|
||||||
|
|
||||||
public static Map<String, String> createMailParameters(UserModel sender, UserModel recipient) {
|
public static Map<String, Serializable> createMailParameters(UserModel sender, UserModel recipient) {
|
||||||
Map<String, String> parameterValues = new HashMap<>();
|
Map<String, Serializable> parameterValues = new HashMap<>();
|
||||||
parameterValues.put("from", sender.getEmailAddress());
|
parameterValues.put("from", sender.getEmailAddress());
|
||||||
parameterValues.put("to", recipient.getEmailAddress());
|
parameterValues.put("to", recipient.getEmailAddress());
|
||||||
parameterValues.put("subject", "Test");
|
parameterValues.put("subject", "Test");
|
||||||
@@ -29,7 +31,7 @@ public class AccessRestrictionUtil {
|
|||||||
return parameterValues;
|
return parameterValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Rule createRuleWithAction(String actionName, Map<String, String> parameterValues) {
|
public static Rule createRuleWithAction(String actionName, Map<String, Serializable> parameterValues) {
|
||||||
Rule rule = new Rule();
|
Rule rule = new Rule();
|
||||||
rule.setId("");
|
rule.setId("");
|
||||||
rule.setTitle("Test rule title");
|
rule.setTitle("Test rule title");
|
||||||
@@ -57,7 +59,7 @@ public class AccessRestrictionUtil {
|
|||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Action createActionWithParameters(String actionName, Map<String, String> parameterValues) {
|
public static Action createActionWithParameters(String actionName, Map<String, Serializable> parameterValues) {
|
||||||
Action compositeAction = new Action();
|
Action compositeAction = new Action();
|
||||||
compositeAction.setActionDefinitionName("composite-action");
|
compositeAction.setActionDefinitionName("composite-action");
|
||||||
|
|
||||||
@@ -76,7 +78,7 @@ public class AccessRestrictionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Action createAction(String actionName, Map<String, String> parameterValues) {
|
public static Action createAction(String actionName, Map<String, Serializable> parameterValues) {
|
||||||
Action action = new Action();
|
Action action = new Action();
|
||||||
action.setActionDefinitionName(actionName);
|
action.setActionDefinitionName(actionName);
|
||||||
action.setParameterValues(parameterValues);
|
action.setParameterValues(parameterValues);
|
||||||
|
@@ -1,5 +1,15 @@
|
|||||||
package org.alfresco.rest.actions.access;
|
package org.alfresco.rest.actions.access;
|
||||||
|
|
||||||
|
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_ACCESS_RESTRICTED;
|
||||||
|
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_FIELD;
|
||||||
|
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.MAIL_ACTION;
|
||||||
|
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.createMailParameters;
|
||||||
|
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.getExpectedEmailSendFailureMessage;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
import org.alfresco.rest.RestTest;
|
||||||
import org.alfresco.rest.core.RestRequest;
|
import org.alfresco.rest.core.RestRequest;
|
||||||
import org.alfresco.rest.core.RestResponse;
|
import org.alfresco.rest.core.RestResponse;
|
||||||
@@ -13,15 +23,6 @@ import org.testng.annotations.BeforeClass;
|
|||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_ACCESS_RESTRICTED;
|
|
||||||
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_FIELD;
|
|
||||||
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.MAIL_ACTION;
|
|
||||||
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.createMailParameters;
|
|
||||||
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.getExpectedEmailSendFailureMessage;
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
|
||||||
|
|
||||||
public class FormProcAdminAccessRestrictionTest extends RestTest {
|
public class FormProcAdminAccessRestrictionTest extends RestTest {
|
||||||
|
|
||||||
private static final String ACTION_FORM_PROCESSOR_ENDPOINT = "alfresco/service/api/action/%s/formprocessor";
|
private static final String ACTION_FORM_PROCESSOR_ENDPOINT = "alfresco/service/api/action/%s/formprocessor";
|
||||||
@@ -75,7 +76,7 @@ public class FormProcAdminAccessRestrictionTest extends RestTest {
|
|||||||
.assertThat().body(ERROR_MESSAGE_FIELD, containsString(getExpectedEmailSendFailureMessage(testUser)));
|
.assertThat().body(ERROR_MESSAGE_FIELD, containsString(getExpectedEmailSendFailureMessage(testUser)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateBody(Map<String, String> mailParameters) {
|
private String generateBody(Map<String, Serializable> mailParameters) {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
mailParameters.forEach((key, value) -> json.put(PROPERTY_PREFIX + key, value));
|
mailParameters.forEach((key, value) -> json.put(PROPERTY_PREFIX + key, value));
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package org.alfresco.rest.actions.access.pojo;
|
package org.alfresco.rest.actions.access.pojo;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ public class Action {
|
|||||||
private String actionedUponNode;
|
private String actionedUponNode;
|
||||||
private List<ActionCondition> conditions;
|
private List<ActionCondition> conditions;
|
||||||
private List<Action> actions;
|
private List<Action> actions;
|
||||||
private Map<String, String> parameterValues;
|
private Map<String, Serializable> parameterValues;
|
||||||
|
|
||||||
private boolean executeAsynchronously;
|
private boolean executeAsynchronously;
|
||||||
|
|
||||||
@@ -47,11 +48,11 @@ public class Action {
|
|||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getParameterValues() {
|
public Map<String, Serializable> getParameterValues() {
|
||||||
return parameterValues;
|
return parameterValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParameterValues(Map<String, String> parameterValues) {
|
public void setParameterValues(Map<String, Serializable> parameterValues) {
|
||||||
this.parameterValues = parameterValues;
|
this.parameterValues = parameterValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
pom.xml
2
pom.xml
@@ -122,7 +122,7 @@
|
|||||||
<dependency.mariadb.version>2.7.4</dependency.mariadb.version>
|
<dependency.mariadb.version>2.7.4</dependency.mariadb.version>
|
||||||
<dependency.tas-utility.version>3.0.56</dependency.tas-utility.version>
|
<dependency.tas-utility.version>3.0.56</dependency.tas-utility.version>
|
||||||
<dependency.rest-assured.version>5.2.0</dependency.rest-assured.version>
|
<dependency.rest-assured.version>5.2.0</dependency.rest-assured.version>
|
||||||
<dependency.tas-restapi.version>1.133</dependency.tas-restapi.version>
|
<dependency.tas-restapi.version>1.134</dependency.tas-restapi.version>
|
||||||
<dependency.tas-email.version>1.9</dependency.tas-email.version>
|
<dependency.tas-email.version>1.9</dependency.tas-email.version>
|
||||||
<dependency.tas-webdav.version>1.7</dependency.tas-webdav.version>
|
<dependency.tas-webdav.version>1.7</dependency.tas-webdav.version>
|
||||||
<dependency.tas-ftp.version>1.7</dependency.tas-ftp.version>
|
<dependency.tas-ftp.version>1.7</dependency.tas-ftp.version>
|
||||||
|
Reference in New Issue
Block a user