Update css file name in conf.py
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / admin / RESTfulPAPEngine.java
index 6db7a40..d89dd27 100644 (file)
@@ -52,7 +52,7 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.rest.XACMLRestProperties;
+import org.onap.policy.rest.XacmlRestProperties;
 import org.onap.policy.rest.adapter.PolicyRestAdapter;
 import org.onap.policy.utils.PeCryptoUtils;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
@@ -95,7 +95,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
         //
         // Get our URL to the PAP servlet
         //
-        this.papServletUrlString = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
+        this.papServletUrlString = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL);
         if (StringUtils.isBlank(this.papServletUrlString)) {
             String message = "The property 'POLICYENGINE_ADMIN_ACTIVE' was not set during installation. "
                     + "Admin Console cannot call PAP.";
@@ -251,7 +251,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
 
     /**
      * validatePolicyRequest Creates a pap policy and then send to pap.
-     * 
+     *
      * @param policyAdapter Input Adapter
      * @param policyType Type of Policy
      * @return true if validated
@@ -270,7 +270,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
     public void publishPolicy(String id, String name, boolean isRoot, InputStream policy, OnapPDPGroup group)
             throws PAPException {
         // copy the (one) file into the target directory on the PAP servlet
-        copyFile(id, group, policy);
+        copyFile(id, group, policy, null);
 
         // adjust the local copy of the group to include the new policy
         PDPPolicy pdpPolicy = new StdPDPPolicy(id, isRoot, name);
@@ -289,10 +289,10 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
      * @param policy Input stream of policy
      * @throws PAPException exception
      */
-    public void copyFile(String policyId, OnapPDPGroup group, InputStream policy) throws PAPException {
+    public void copyFile(String policyId, OnapPDPGroup group, InputStream policy, String usrId) throws PAPException {
         // send the policy file to the PAP Servlet
         try {
-            sendToPap("POST", policy, null, null, GROUP_ID + group.getId(), "policyId=" + policyId);
+            sendToPap("POST", policy, null, null, GROUP_ID + group.getId(), "policyId=" + policyId, "userId=" + usrId );
         } catch (Exception e) {
             String message = UNABLE_MSG + policyId + EXCEPTION_MSG + e;
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + message, e);
@@ -301,12 +301,12 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
     }
 
     @Override
-    public void copyPolicy(PDPPolicy policy, OnapPDPGroup group) throws PAPException {
+    public void copyPolicy(PDPPolicy policy, OnapPDPGroup group, String userId) throws PAPException {
         if (policy == null || group == null) {
             throw new PAPException("Null input policy=" + policy + "  group=" + group);
         }
         try (InputStream is = new FileInputStream(new File(policy.getLocation()))) {
-            copyFile(policy.getId(), group, is);
+            copyFile(policy.getId(), group, is, userId);
         } catch (Exception e) {
             String message = UNABLE_MSG + policy.getId() + EXCEPTION_MSG + e;
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + message, e);
@@ -342,7 +342,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
      * <p>The content is either an InputStream to be copied to the Request OutputStream OR it is an object that is to be
      * encoded into JSON and pushed into the Request OutputStream.
      *
-     * <p>The Request parameters may be encoded in multiple "name=value" sets, or parameters may be 
+     * <p>The Request parameters may be encoded in multiple "name=value" sets, or parameters may be
      * combined by the caller.
      *
      * @param method method
@@ -357,11 +357,11 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
     private Object sendToPap(String method, Object content, Class collectionTypeClass, Class responseContentClass,
             String... parameters) throws PAPException {
         HttpURLConnection connection = null;
-        String papID = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID);
+        String papID = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_USERID);
         LOGGER.info("User Id is " + papID);
-        PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XACMLRestProperties.PROP_AES_KEY));
+        PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XacmlRestProperties.PROP_AES_KEY));
         String papPass = PeCryptoUtils
-                .decrypt(PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)));
+                .decrypt(PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_PASS)));
         Base64.Encoder encoder = Base64.getEncoder();
         String encoding = encoder.encodeToString((papID + ":" + papPass).getBytes(StandardCharsets.UTF_8));
         Object contentObj = content;