X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-PDP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpdp%2Frest%2Fapi%2Fservices%2FCreateUpdatePolicyServiceImpl.java;h=62b85037098b8b21abd60fe49efff5785cd2edcc;hp=f91f6e2f2282b9d3dcf7d20cbda8ef473dce43cb;hb=c5d97e8a9a6bea71f3be329a2e44bdbe5fe50882;hpb=c9039d15e8a84a9304fba40283a332a2a65ef854 diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java index f91f6e2f2..62b850370 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PDP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -177,7 +177,7 @@ public class CreateUpdatePolicyServiceImpl implements CreateUpdatePolicyService response = microServicesPolicyService.getResult(updateFlag); break; default: - String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " Invalid Config Type Present"; + message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " Invalid Config Type Present"; LOGGER.error(message); status = HttpStatus.BAD_REQUEST; return message; @@ -208,7 +208,7 @@ public class CreateUpdatePolicyServiceImpl implements CreateUpdatePolicyService break; } }else { - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Class found."; + message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Class found."; LOGGER.error(message); status = HttpStatus.BAD_REQUEST; response = message; @@ -254,7 +254,12 @@ public class CreateUpdatePolicyServiceImpl implements CreateUpdatePolicyService try { PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper(); PolicyRestAdapter policyData = wrapper.populateRequestParameters(policyParameters); - responseString = validation.validatePolicy(policyData); + if(policyData!=null) { + responseString = validation.validatePolicy(policyData); + } else { + message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody(); + return false; + } } catch (Exception e) { LOGGER.error("Exception Occured during Policy Validation" +e); if(e.getMessage()!=null){ @@ -277,7 +282,8 @@ public class CreateUpdatePolicyServiceImpl implements CreateUpdatePolicyService } if (responseString!=null){ - if("success".equals(responseString.toString())||"success@#".equals(responseString.toString())){ + String response = responseString.toString().substring(0, 7); + if("success".equals(response)) { return true; } else { message = XACMLErrorConstants.ERROR_DATA_ISSUE + PolicyApiUtils.formatResponse(responseString);