+ /* Unobfuscate param value */
+ private static String getObfuscatedVal(String paramValue) {
+ String resValue = paramValue;
+ if (paramValue != null && paramValue.startsWith("${") && paramValue.endsWith("}"))
+ {
+ String paramStr = paramValue.substring(2, paramValue.length()-1);
+ if (paramStr != null && paramStr.length() > 0)
+ {
+ String val = System.getenv(paramStr);
+ if (val != null && val.length() > 0)
+ {
+ resValue=val;
+ log.info("Obfuscated value RESET for param value:" + paramValue);
+ }
+ }
+ }
+ return resValue;
+ }
+
+ /**
+ * Returns parameters from the parameter map.
+ *
+ * @param paramMap parameter map
+ * @param p parameters instance
+ * @return parameters filed instance
+ * @throws SvcLogicException when svc logic exception occurs
+ */
+ public static Parameters getParameters(Map<String, String> paramMap, Parameters p) throws SvcLogicException {
+
+ p.templateFileName = parseParam(paramMap, "templateFileName", false, null);
+ p.requestBody = parseParam(paramMap, "requestBody", false, null);
+ p.restapiUrl = parseParam(paramMap, restapiUrlString, true, null);
+ p.restapiUrlSuffix = parseParam(paramMap, "restapiUrlSuffix", false, null);
+ if (p.restapiUrlSuffix != null) {
+ p.restapiUrl = p.restapiUrl + p.restapiUrlSuffix;
+ }
+
+ p.restapiUrl = UriBuilder.fromUri(p.restapiUrl).toTemplate();
+ validateUrl(p.restapiUrl);
+
+ p.restapiUser = parseParam(paramMap, restapiUserKey, false, null);
+ p.restapiPassword = parseParam(paramMap, restapiPasswordKey, false, null);
+ p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null);
+ p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null);
+ p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null);
+ p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null);
+ p.contentType = parseParam(paramMap, "contentType", false, null);
+ p.format = Format.fromString(parseParam(paramMap, "format", false, "json"));
+ p.authtype = fromString(parseParam(paramMap, "authType", false, "unspecified"));
+ p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post"));
+ p.responsePrefix = parseParam(paramMap, responsePrefix, false, null);
+ p.listNameList = getListNameList(paramMap);
+ String skipSendingStr = paramMap.get(skipSendingMessage);
+ p.skipSending = "true".equalsIgnoreCase(skipSendingStr);
+ p.convertResponse = 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 = valueOf(parseParam(paramMap, "dumpHeaders", false, null));
+ p.returnRequestPayload = valueOf(parseParam(paramMap, "returnRequestPayload", false, null));
+ p.accept = parseParam(paramMap, "accept", false, null);
+ p.multipartFormData = valueOf(parseParam(paramMap, "multipartFormData", false, "false"));
+ p.multipartFile = parseParam(paramMap, "multipartFile", false, null);
+ p.targetEntity = parseParam(paramMap, "targetEntity", false, null);
+ return p;
+ }
+
+ /**
+ * Validates the given URL in the parameters.
+ *
+ * @param restapiUrl rest api URL
+ * @throws SvcLogicException when URL validation fails
+ */
+ private static void validateUrl(String restapiUrl) throws SvcLogicException {
+ if (restapiUrl.contains(",")) {
+ String[] urls = restapiUrl.split(",");
+ for (String url : urls) {
+ validateUrl(url);
+ }
+ } else {
+ try {
+ URI.create(restapiUrl);
+ } catch (IllegalArgumentException e) {
+ throw new SvcLogicException("Invalid input of url " + e.getLocalizedMessage(), e);
+ }
+ }
+ }