Merge "Addressing Technical Debt for ONAP-XACML"
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / controller / AutoPushController.java
index c1468e3..9ade81d 100644 (file)
@@ -47,6 +47,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.model.PDPGroupContainer;
 import org.onap.policy.model.PDPPolicyContainer;
+import org.onap.policy.model.Roles;
 import org.onap.policy.rest.adapter.AutoPushTabAdapter;
 import org.onap.policy.rest.dao.CommonClassDao;
 import org.onap.policy.rest.jpa.PolicyEntity;
@@ -55,10 +56,9 @@ import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
 import org.onap.policy.xacml.std.pap.StdPDPGroup;
 import org.onap.policy.xacml.std.pap.StdPDPPolicy;
-import org.openecomp.policy.model.Roles;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.web.support.JsonMessage;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.web.support.JsonMessage;
+import org.onap.portalsdk.core.web.support.UserUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Controller;
@@ -120,7 +120,7 @@ public class AutoPushController extends RestrictedBaseController{
                try{
                        Set<String> scopes = null;
                        List<String> roles = null;
-                       data = new ArrayList<Object>();
+                       data = new ArrayList<>();
                        String userId = UserUtils.getUserSession(request).getOrgUserId();
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
@@ -187,6 +187,12 @@ public class AutoPushController extends RestrictedBaseController{
                        this.container = new PDPGroupContainer(controller.getPapEngine());
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
+                       
+                       String userId = UserUtils.getUserSession(request).getOrgUserId();
+                       logger.info("****************************************Logging UserID while Pushing  Policy to PDP Group*****************************************");
+                       logger.info("UserId:  " + userId + "Push Policy Data:  "+ root.get("pushTabData").toString());
+                       logger.info("***********************************************************************************************************************************");
+                       
                        AutoPushTabAdapter adapter = mapper.readValue(root.get("pushTabData").toString(), AutoPushTabAdapter.class);
                        for (Object pdpGroupId :  adapter.getPdpDatas()) {
                                LinkedHashMap<?, ?> selectedPDP = (LinkedHashMap<?, ?>)pdpGroupId;
@@ -224,7 +230,7 @@ public class AutoPushController extends RestrictedBaseController{
                                        String id = name;
                                        if (id.endsWith(".xml")) {
                                                id = id.replace(".xml", "");
-                                               id = id.substring(0, id.lastIndexOf("."));
+                                               id = id.substring(0, id.lastIndexOf('.'));
                                        }
                                        
                                        // Default policy to be Root policy; user can change to deferred
@@ -342,13 +348,19 @@ public class AutoPushController extends RestrictedBaseController{
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());  
-                       StdPDPGroup group = (StdPDPGroup)mapper.readValue(root.get("activePdpGroup").toString(), StdPDPGroup.class);
+                       StdPDPGroup group = mapper.readValue(root.get("activePdpGroup").toString(), StdPDPGroup.class);
                        JsonNode removePolicyData = root.get("data");
+                       
+                       String userId = UserUtils.getUserSession(request).getOrgUserId();
+                       logger.info("****************************************Logging UserID while Removing Policy from PDP Group*****************************************");
+                       logger.info("UserId:  " + userId + "PDP Group Data:  "+ root.get("activePdpGroup").toString() + "Remove Policy Data: "+root.get("data"));
+                       logger.info("***********************************************************************************************************************************");
+                       
                        policyContainer = new PDPPolicyContainer(group);
                        if(removePolicyData.size() > 0){
                                for(int i = 0 ; i < removePolicyData.size(); i++){
-                                       String data = removePolicyData.get(i).toString();
-                                       this.policyContainer.removeItem(data);
+                                       String polData = removePolicyData.get(i).toString();
+                                       this.policyContainer.removeItem(polData);
                                }
                                Set<PDPPolicy> changedPolicies = new HashSet<>();
                                changedPolicies.addAll((Collection<PDPPolicy>) this.policyContainer.getItemIds());
@@ -383,4 +395,4 @@ public class AutoPushController extends RestrictedBaseController{
                return null;
        }
 
-}
\ No newline at end of file
+}