Update css file name in conf.py
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / policycontroller / PolicyCreation.java
index 34ea2c0..f2f2e8d 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PAP-REST
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -56,7 +56,7 @@ import org.onap.policy.pap.xacml.rest.util.AbstractPolicyCreation;
 import org.onap.policy.rest.adapter.PolicyRestAdapter;
 import org.onap.policy.rest.dao.CommonClassDao;
 import org.onap.policy.rest.jpa.ActionPolicyDict;
-import org.onap.policy.rest.jpa.BRMSParamTemplate;
+import org.onap.policy.rest.jpa.BrmsParamTemplate;
 import org.onap.policy.rest.jpa.PolicyEditorScopes;
 import org.onap.policy.rest.jpa.PolicyVersion;
 import org.onap.policy.rest.jpa.UserInfo;
@@ -314,8 +314,8 @@ public class PolicyCreation extends AbstractPolicyCreation {
                         String modelName = drlRuleAndUiParams.get("templateName");
                         PolicyLogger.info("Template name from API is: " + modelName);
 
-                        BRMSParamTemplate template = (BRMSParamTemplate) commonClassDao
-                                .getEntityItem(BRMSParamTemplate.class, "ruleName", modelName);
+                        BrmsParamTemplate template = (BrmsParamTemplate) commonClassDao
+                                .getEntityItem(BrmsParamTemplate.class, "ruleName", modelName);
                         if (template == null) {
                             String message =
                                     XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Template.  The template name, "
@@ -618,7 +618,13 @@ public class PolicyCreation extends AbstractPolicyCreation {
         } catch (Exception e) {
             LOGGER.error("Exception Occured : " + e.getMessage(), e);
             body = ERROR;
-            response.addHeader(ERROR, e.getMessage());
+            //
+            // Because we are catching any old exception instead of a dedicated exception,
+            // its possible the e.getMessage() returns a null value. You cannot add a header
+            // to the response with a null value, it will throw an exception. This is something
+            // this is undesirable.
+            //
+            response.addHeader(ERROR, (e.getMessage() == null ? "missing exception message" : e.getMessage()));
             response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
         }
         return new ResponseEntity<>(body, status);