diff options
Diffstat (limited to 'ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java')
-rw-r--r-- | ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java | 16 |
1 files changed, 11 insertions, 5 deletions
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); |