- }
-
- protected Parameters getParameters(Map<String, String> paramMap) throws SvcLogicException {
- Parameters p = new Parameters();
- p.templateFileName = parseParam(paramMap, "templateFileName", false, null);
- p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null);
- p.restapiUser = parseParam(paramMap, "restapiUser", false, null);
- p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null);
- p.contentType = parseParam(paramMap, "contentType", false, null);
- p.format = Format.fromString(parseParam(paramMap, "format", false, "json"));
- p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post"));
- p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null);
- p.listNameList = getListNameList(paramMap);
- String skipSendingStr = paramMap.get("skipSending");
- p.skipSending = "true".equalsIgnoreCase(skipSendingStr);
- p.convertResponse = Boolean.valueOf(parseParam(paramMap, "convertResponse", false, "true"));
- p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null);
- p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null);
- p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null);
- p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null);
- p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null &&
- p.keyStorePassword != null;
- p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null);
- p.partner = parseParam(paramMap, "partner", false, null);
- p.dumpHeaders = Boolean.valueOf(parseParam(paramMap, "dumpHeaders", false, null));
- return p;
- }
-
- protected Set<String> getListNameList(Map<String, String> paramMap) {
- Set<String> ll = new HashSet<>();
- for (Map.Entry<String,String> entry : paramMap.entrySet())
- if (entry.getKey().startsWith("listName"))
- ll.add(entry.getValue());
- return ll;
- }
-
- protected String parseParam(Map<String, String> paramMap, String name, boolean required, String def)
- throws SvcLogicException {
- String s = paramMap.get(name);
-
- if (s == null || s.trim().length() == 0) {
- if (!required)
- return def;
- throw new SvcLogicException("Parameter " + name + " is required in RestapiCallNode");
- }
-
- s = s.trim();
- String value = "";
- int i = 0;
- int i1 = s.indexOf('%');
- while (i1 >= 0) {
- int i2 = s.indexOf('%', i1 + 1);
- if (i2 < 0)
- break;
-
- String varName = s.substring(i1 + 1, i2);
- String varValue = System.getenv(varName);
- if (varValue == null)
- varValue = "%" + varName + "%";
-
- value += s.substring(i, i1);
- value += varValue;
-
- i = i2 + 1;
- i1 = s.indexOf('%', i);