+ public void validateParams(Map<String, String> inParams, SvcLogicContext ctx)
+ throws SvcLogicException
+
+ {
+ String responsePrefix = inParams.get(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ String pdContent = inParams.get(ParamsHandlerConstant.INPUT_PARAM_PD_CONTENT);
+ String configParams =
+ inParams.get(ParamsHandlerConstant.OUTPUT_PARAM_CONFIGURATION_PARAMETER);
+ responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
+ log.info("Processed pdContent Param " + pdContent);
+ log.info("Processed config Param " + configParams);
+
+ try {
+ if (StringUtils.isBlank(pdContent)) {
+ throw new Exception("Request Param (pdContent) is Missing ..");
+ }
+
+ if (StringUtils.isBlank(configParams)) {
+ throw new Exception("Request Param (configParams) is Missing ..");
+ }
+ PropertyDefinition propertyDefinition = parsePDContent(pdContent);
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, String> requestParamMap = mapper.readValue(configParams, HashMap.class);
+ List<Parameter> parameters = propertyDefinition.getParameters();
+ Map<String, String> missingKeys = new HashMap<String, String>();
+ for (Parameter parameter : parameters) {
+ if (parameter != null) {
+ if (parameter.isRequired()) {
+ if (!requestParamMap.containsKey(parameter.getName())) {
+ missingKeys.put(parameter.getName(), parameter.getSource());
+ } else {
+ if ((requestParamMap.get(parameter.getName()) == null)
+ || (requestParamMap.get(parameter.getName()).equals("")))
+
+ {
+ missingKeys.put(parameter.getName(), parameter.getSource());
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ if (missingKeys != null && missingKeys.size() > 0) {
+
+ String requiredFields = mapper.writeValueAsString(missingKeys);
+ log.info(" Below mentioned keys and respective source type are mandatory");
+ log.info(requiredFields);
+
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS,
+ ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(ParamsHandlerConstant.OUTPUT_PARAM_STATUS,
+ ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_ERROR_MESSAGE,
+ "Missing Mandatory Keys and source are" + requiredFields);
+ throw new SvcLogicException(
+ " Missing Mandatory Keys and source are" + requiredFields);
+
+
+ } else {
+ log.info("success ");
+ ctx.setAttribute(ParamsHandlerConstant.OUTPUT_PARAM_STATUS,
+ ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
+
+ }
+
+ } catch (Exception e) {
+
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS,
+ ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(ParamsHandlerConstant.OUTPUT_PARAM_STATUS,
+ ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_ERROR_MESSAGE,
+ e.getMessage());
+ log.error(e.getMessage());
+ throw new SvcLogicException(e.getMessage());
+ }
+
+ }
+