Modified the code to fix various pushPolicy issues
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / policycontroller / PolicyCreation.java
index 64324d4..2af8a6e 100644 (file)
@@ -193,6 +193,15 @@ public class PolicyCreation extends AbstractPolicyCreation{
                                        return new ResponseEntity<String>(body, status);
                                }               
                        }else{
+                               // if policy does not exist and the request is updatePolicy return error
+                               if(policyData.isEditPolicy()){
+                                       body = "policyNotAvailableForEdit";
+                                       status = HttpStatus.NOT_FOUND;
+                                       response.setStatus(HttpServletResponse.SC_NOT_FOUND);
+                                       response.addHeader("error", body);
+                                       response.addHeader("message", policyData.getPolicyName() + " does not exist on the PAP and cannot be updated.");
+                                       return new ResponseEntity<String>(body, status);
+                               }
                                version = 1;
                                if(userId == null){
                                        createdBy = "API";