use of org.alfresco.service.cmr.action.ParameterConstraint in project alfresco-remote-api by Alfresco.
the class RuleServiceTest method testGetActionConstraint.
public void testGetActionConstraint() throws Exception {
List<ParameterConstraint> constraints = actionService.getParameterConstraints();
if (constraints.size() == 0) {
return;
}
String name = constraints.get(0).getName();
Response response = sendRequest(new GetRequest(formateActionConstraintUrl(name)), 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertNotNull(result);
assertTrue(result.has("data"));
JSONObject data = result.getJSONObject("data");
assertTrue(data.has("name"));
assertTrue(data.has("values"));
JSONArray values = data.getJSONArray("values");
for (int i = 0; i < values.length(); i++) {
JSONObject value = values.getJSONObject(i);
assertTrue(value.has("value"));
assertTrue(value.has("displayLabel"));
}
}
use of org.alfresco.service.cmr.action.ParameterConstraint in project alfresco-remote-api by Alfresco.
the class ActionConstraintsGet method executeImpl.
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
Map<String, Object> model = new HashMap<String, Object>();
// get request parameters
String[] names = req.getParameterValues("name");
List<ParameterConstraint> parameterConstraints = null;
if (names != null && names.length > 0) {
// filter is present in request
parameterConstraints = new ArrayList<ParameterConstraint>();
// find specified parameter constraints
for (String name : names) {
ParameterConstraint parameterConstraint = actionService.getParameterConstraint(name);
if (parameterConstraint != null) {
parameterConstraints.add(parameterConstraint);
}
}
} else {
// no filter was provided, return all parameter constraints
parameterConstraints = actionService.getParameterConstraints();
}
model.put("actionConstraints", parameterConstraints);
return model;
}
use of org.alfresco.service.cmr.action.ParameterConstraint in project alfresco-remote-api by Alfresco.
the class ActionConstraintGet method executeImpl.
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
Map<String, Object> model = new HashMap<String, Object>();
// get request parameters
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
String name = templateVars.get("name");
// get specified parameter constraint
ParameterConstraint parameterConstraint = actionService.getParameterConstraint(name);
if (parameterConstraint == null) {
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find parameter constraint with name: " + name);
}
model.put("actionConstraint", parameterConstraint);
return model;
}
Aggregations