summaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/java/org/onap/policy/admin
diff options
context:
space:
mode:
authorrb7147 <rb7147@att.com>2017-12-04 16:45:55 -0500
committerrb7147 <rb7147@att.com>2017-12-08 10:45:57 -0500
commit428150834ee60899b9a8da019bae3c8bf009adf1 (patch)
tree7197eb324477cad918cf527c7a479302cb5029f7 /POLICY-SDK-APP/src/main/java/org/onap/policy/admin
parent775f45908025e46a40c9c147fca2066af5c8c5b8 (diff)
Upgraded the latest ONAP SDK
Upgraded latest ONAP SDK Code. Change-Id: I669d6cfcefe068b1e4c078889d7d6c77ce788e2e Issue-ID: POLICY-432 Signed-off-by: rb7147 <rb7147@att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/onap/policy/admin')
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java27
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java3
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java48
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java6
4 files changed, 69 insertions, 15 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
index d65d1da8a..cb373a1bd 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
@@ -33,9 +33,11 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -67,6 +69,7 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.components.HumanPolicyComponent;
import org.onap.policy.controller.PolicyController;
import org.onap.policy.controller.PolicyExportAndImportController;
+import org.onap.policy.model.Roles;
import org.onap.policy.rest.XACMLRest;
import org.onap.policy.rest.XACMLRestProperties;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
@@ -79,8 +82,7 @@ import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.utils.PolicyUtils;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.util.XACMLPolicyScanner;
-import org.openecomp.policy.model.Roles;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
+import org.onap.portalsdk.core.web.support.UserUtils;
import com.att.research.xacml.util.XACMLProperties;
import com.fasterxml.jackson.databind.JsonNode;
@@ -272,6 +274,12 @@ public class PolicyManagerServlet extends HttpServlet {
JSONObject jObj = new JSONObject(sb.toString());
JSONObject params = jObj.getJSONObject("params");
Mode mode = Mode.valueOf(params.getString("mode"));
+
+ String userId = UserUtils.getUserSession(request).getOrgUserId();
+ LOGGER.info("****************************************Logging UserID while doing actions on Editor tab*******************************************");
+ LOGGER.info("UserId: " + userId + "Action Mode: "+ mode.toString() + "Action Params: "+params.toString());
+ LOGGER.info("***********************************************************************************************************************************");
+
switch (mode) {
case ADDFOLDER:
case ADDSUBSCOPE:
@@ -623,7 +631,7 @@ public class PolicyManagerServlet extends HttpServlet {
if(!(scope.getScopeName().contains(File.separator))){
JSONObject el = new JSONObject();
el.put("name", scope.getScopeName());
- el.put("date", scope.getCreatedDate());
+ el.put("date", scope.getModifiedDate());
el.put("size", "");
el.put("type", "dir");
el.put("createdBy", scope.getUserCreatedBy().getUserName());
@@ -638,7 +646,7 @@ public class PolicyManagerServlet extends HttpServlet {
if(!scopesList.isEmpty()){
PolicyEditorScopes scopeById = (PolicyEditorScopes) scopesList.get(0);
el.put("name", scopeById.getScopeName());
- el.put("date", scopeById.getCreatedDate());
+ el.put("date", scopeById.getModifiedDate());
el.put("size", "");
el.put("type", "dir");
el.put("createdBy", scopeById.getUserCreatedBy().getUserName());
@@ -1149,6 +1157,7 @@ public class PolicyManagerServlet extends HttpServlet {
entityItem.setPolicyName(policyName);
entityItem.setCreatedBy(userId);
entityItem.setModifiedBy(userId);
+ entityItem.setModifiedDate(new Date());
controller.saveData(entityItem);
}
@@ -1212,9 +1221,9 @@ public class PolicyManagerServlet extends HttpServlet {
if(!policyEntityobjects.isEmpty()){
for(Object object : policyEntityobjects){
policyEntity = (PolicyEntity) object;
- String groupEntityquery = "from PolicyGroupEntity where policyid = :policyId";
+ String groupEntityquery = "from PolicyGroupEntity where policyid ='"+policyEntity.getPolicyId()+"'";
SimpleBindings pgeParams = new SimpleBindings();
- pgeParams.put("policyId", policyEntity.getPolicyId());
+ //pgeParams.put("policyIdValue", policyEntity.getPolicyId());
List<Object> groupobject = controller.getDataByQuery(groupEntityquery, pgeParams);
if(!groupobject.isEmpty()){
pdpCheck = true;
@@ -1226,8 +1235,10 @@ public class PolicyManagerServlet extends HttpServlet {
//Delete the entity from Policy Entity table
controller.deleteData(policyEntity);
if(policyNamewithoutExtension.contains("Config_")){
+ Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
controller.deleteData(policyEntity.getConfigurationData());
}else if(policyNamewithoutExtension.contains("Action_")){
+ Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
controller.deleteData(policyEntity.getActionBodyEntity());
}
}
@@ -1279,8 +1290,10 @@ public class PolicyManagerServlet extends HttpServlet {
//Delete the entity from Policy Entity table
controller.deleteData(policyEntity);
if(policyNamewithoutExtension.contains("Config_")){
+ Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
controller.deleteData(policyEntity.getConfigurationData());
}else if(policyNamewithoutExtension.contains("Action_")){
+ Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
controller.deleteData(policyEntity.getActionBodyEntity());
}
@@ -1337,8 +1350,10 @@ public class PolicyManagerServlet extends HttpServlet {
controller.deleteData(policyEntity);
policyNamewithoutExtension = policyEntity.getPolicyName();
if(policyNamewithoutExtension.contains("Config_")){
+ Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
controller.deleteData(policyEntity.getConfigurationData());
}else if(policyNamewithoutExtension.contains("Action_")){
+ Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
controller.deleteData(policyEntity.getActionBodyEntity());
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
index 2326a9fb7..67d9c8813 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
@@ -108,6 +108,9 @@ public class PolicyNotificationMail{
}
String policyFileName = entityItem.getPolicyName();
String checkPolicyName = policyName;
+ if(checkPolicyName.endsWith(".xml") || checkPolicyName.contains(".")){
+ checkPolicyName = checkPolicyName.substring(0, checkPolicyName.indexOf("."));
+ }
if(policyFileName.contains("/")){
policyFileName = policyFileName.substring(0, policyFileName.indexOf("/"));
policyFileName = policyFileName.replace("/", File.separator);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
index 08f80304c..f38f3e266 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
@@ -52,8 +52,8 @@ import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.utils.PolicyUtils;
import org.onap.policy.xacml.api.XACMLErrorConstants;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.web.support.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -108,7 +108,11 @@ public class PolicyRestController extends RestrictedBaseController{
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
try{
JsonNode root = mapper.readTree(request.getReader());
-
+
+ policyLogger.info("****************************************Logging UserID while Create/Update Policy**************************************************");
+ policyLogger.info("UserId: " + userId + "Policy Data Object: "+ root.get(PolicyController.getPolicydata()).get("policy").toString());
+ policyLogger.info("***********************************************************************************************************************************");
+
PolicyRestAdapter policyData = mapper.readValue(root.get(PolicyController.getPolicydata()).get("policy").toString(), PolicyRestAdapter.class);
if("file".equals(root.get(PolicyController.getPolicydata()).get(modal).get("type").toString().replace("\"", ""))){
@@ -204,9 +208,13 @@ public class PolicyRestController extends RestrictedBaseController{
HttpEntity<?> requestEntity = new HttpEntity<>(body, headers);
ResponseEntity<?> result = null;
HttpClientErrorException exception = null;
-
+ String uri = requestURI;
+ if(uri.startsWith("/")){
+ uri = uri.substring(uri.indexOf('/')+1);
+ }
+ uri = "onap" + uri.substring(uri.indexOf('/'));
try{
- result = restTemplate.exchange(papUrl + requestURI, method, requestEntity, String.class);
+ result = restTemplate.exchange(papUrl + uri, method, requestEntity, String.class);
}catch(Exception e){
policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + papUrl, e);
exception = new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
@@ -378,11 +386,21 @@ public class PolicyRestController extends RestrictedBaseController{
@RequestMapping(value={"/saveDictionary/*/*"}, method={RequestMethod.POST})
public ModelAndView saveDictionaryController(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ String userId = "";
String uri = request.getRequestURI().replace("/saveDictionary", "");
+ if(uri.startsWith("/")){
+ uri = uri.substring(uri.indexOf('/')+1);
+ }
+ uri = "/onap" + uri.substring(uri.indexOf('/'));
if(uri.contains(importDictionary)){
- String userId = UserUtils.getUserSession(request).getOrgUserId();
+ userId = UserUtils.getUserSession(request).getOrgUserId();
uri = uri+ "?userId=" +userId;
}
+
+ policyLogger.info("****************************************Logging UserID while Saving Dictionary*****************************************************");
+ policyLogger.info("UserId: " + userId);
+ policyLogger.info("***********************************************************************************************************************************");
+
String body = callPAP(request, "POST", uri.replaceFirst("/", "").trim());
response.getWriter().write(body);
return null;
@@ -391,6 +409,16 @@ public class PolicyRestController extends RestrictedBaseController{
@RequestMapping(value={"/deleteDictionary/*/*"}, method={RequestMethod.POST})
public ModelAndView deletetDictionaryController(HttpServletRequest request, HttpServletResponse response) throws IOException {
String uri = request.getRequestURI().replace("/deleteDictionary", "");
+ if(uri.startsWith("/")){
+ uri = uri.substring(uri.indexOf('/')+1);
+ }
+ uri = "/onap" + uri.substring(uri.indexOf('/'));
+
+ String userId = UserUtils.getUserSession(request).getOrgUserId();
+ policyLogger.info("****************************************Logging UserID while Deleting Dictionary*****************************************************");
+ policyLogger.info("UserId: " + userId);
+ policyLogger.info("*************************************************************************************************************************************");
+
String body = callPAP(request, "POST", uri.replaceFirst("/", "").trim());
response.getWriter().write(body);
return null;
@@ -400,6 +428,10 @@ public class PolicyRestController extends RestrictedBaseController{
public ModelAndView searchDictionaryController(HttpServletRequest request, HttpServletResponse response) throws IOException {
Object resultList = null;
String uri = request.getRequestURI();
+ if(uri.startsWith("/")){
+ uri = uri.substring(uri.indexOf('/')+1);
+ }
+ uri = "/onap" + uri.substring(uri.indexOf('/'));
try{
String body = callPAP(request, "POST", uri.replaceFirst("/", "").trim());
if(body.contains("CouldNotConnectException")){
@@ -429,6 +461,10 @@ public class PolicyRestController extends RestrictedBaseController{
public ModelAndView searchPolicy(HttpServletRequest request, HttpServletResponse response) throws IOException{
Object resultList = null;
String uri = request.getRequestURI()+"?action=search";
+ if(uri.startsWith("/")){
+ uri = uri.substring(uri.indexOf('/')+1);
+ }
+ uri = "/onap" + uri.substring(uri.indexOf('/'));
String body = callPAP(request, "POST", uri.replaceFirst("/", "").trim());
JSONObject json = new JSONObject(body);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java
index 5020662c8..96205c5b1 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java
@@ -28,9 +28,9 @@ import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-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.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;