aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src
diff options
context:
space:
mode:
authorRavindra Bakkamanthala <rb7147@att.com>2017-05-15 12:53:18 -0400
committerRavindra Bakkamanthala <rb7147@att.com>2017-05-15 13:55:23 -0400
commit7e547eaa55920dfbc9691eab33bb728395b50cf2 (patch)
tree5d0d64928b4754f65b427cb79b43718f16019582 /POLICY-SDK-APP/src
parentdda032f8bb161d54eb1f59de2b4a3efb774fc4d1 (diff)
Policy TestSuite Enabled
Change-Id: I9f98c7dcdcf98713d73544956d873a84fc82adf7 Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
Diffstat (limited to 'POLICY-SDK-APP/src')
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyAdapter.java6
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java36
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java37
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyUserInfoController.java6
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/PolicyImportWindow.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java8
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java18
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java20
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java27
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java29
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java32
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java25
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java16
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java14
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java95
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java6
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/attributeDictGridController.js2
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/ecompNameDictGridController.js69
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html1
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js2
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSShowParamRuleModal.html6
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js6
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_Dictionary.html4
28 files changed, 317 insertions, 174 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyAdapter.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyAdapter.java
index 329e3bd29..ef25376f3 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyAdapter.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyAdapter.java
@@ -1,5 +1,7 @@
package org.openecomp.policy.admin;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.controller.ActionPolicyController;
import org.openecomp.policy.controller.CreateBRMSParamController;
import org.openecomp.policy.controller.CreateBRMSRawController;
@@ -16,6 +18,8 @@ import com.att.research.xacml.util.XACMLProperties;
public class PolicyAdapter {
+ private static final Logger LOGGER = FlexLogger.getLogger(PolicyAdapter.class);
+
public void configure(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
String policyNameValue = null ;
String configPolicyName = null ;
@@ -102,7 +106,7 @@ public class PolicyAdapter {
Class<?> policyAdapter = Class.forName(XACMLProperties.getProperty("policyAdapter.impl.className", PolicyAdapter.class.getName()));
return (PolicyAdapter) policyAdapter.newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
return null;
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java
index 6c60c58c2..aa8a227d3 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java
@@ -143,7 +143,7 @@ public class PolicyManagerServlet extends HttpServlet {
try {
inputStream = new FileInputStream(location);
} catch (FileNotFoundException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured while initializing the JSONConfig file"+e);
}
if (location.endsWith("json")) {
JsonReader jsonReader = null;
@@ -295,7 +295,7 @@ public class PolicyManagerServlet extends HttpServlet {
private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) {
Set<String> scopes = null;
List<String> roles = null;
- policyData = null;
+ policyData = new ArrayList<Object>();
JSONArray policyList = null;
if(params.has("policyList")){
policyList = (JSONArray) params.get("policyList");
@@ -492,7 +492,7 @@ public class PolicyManagerServlet extends HttpServlet {
bw.close();
object = HumanPolicyComponent.DescribePolicy(temp);
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured while Describing the Policy"+e);
}finally{
temp.delete();
}
@@ -679,6 +679,9 @@ public class PolicyManagerServlet extends HttpServlet {
private String getUserName(String loginId){
PolicyController controller = new PolicyController();
UserInfo userInfo = (UserInfo) controller.getEntityItem(UserInfo.class, "userLoginId", loginId);
+ if(userInfo == null){
+ return "super-admin";
+ }
return userInfo.getUserName();
}
@@ -798,13 +801,15 @@ public class PolicyManagerServlet extends HttpServlet {
}
}else{
//Query the Policy Entity with oldPolicy Name
- String oldpolicyEntityquery = "FROM PolicyEntity where policyName = '"+oldPolicySplit[1]+"' and scope ='"+oldPolicySplit[0]+"'";
- System.out.println(oldpolicyEntityquery);
+ String policyEntityCheck = oldPolicySplit[1].substring(0, oldPolicySplit[1].indexOf("."));
+ String oldpolicyEntityquery = "FROM PolicyEntity where policyName like '"+policyEntityCheck+"%' and scope ='"+oldPolicySplit[0]+"'";
List<Object> oldEntityData = controller.getDataByQuery(oldpolicyEntityquery);
if(!oldEntityData.isEmpty()){
- entity = (PolicyEntity) oldEntityData.get(0);
+ for(int i=0; i<oldEntityData.size(); i++){
+ entity = (PolicyEntity) oldEntityData.get(i);
+ checkOldPolicyEntryAndUpdate(entity, newPolicySplit[0] , newPolicySplit[1], oldPolicySplit[0], oldPolicySplit[1], policyName, newpolicyName, oldpolicyName, userId);
+ }
}
- checkOldPolicyEntryAndUpdate(entity, newPolicySplit[0] , newPolicySplit[1], oldPolicySplit[0], oldPolicySplit[1], policyName, newpolicyName, oldpolicyName, userId);
}
return success();
@@ -833,17 +838,15 @@ public class PolicyManagerServlet extends HttpServlet {
oldPolicyNameWithoutExtension = oldPolicyNameWithoutExtension.substring(0, oldPolicyNameWithoutExtension.indexOf("."));
newPolicyNameWithoutExtension = newPolicyNameWithoutExtension.substring(0, newPolicyNameWithoutExtension.indexOf("."));
}
- entity.setPolicyName(entity.getPolicyName().replace(removeoldPolicyExtension, removenewPolicyExtension));
+ entity.setPolicyName(entity.getPolicyName().replace(oldPolicyNameWithoutExtension, newPolicyNameWithoutExtension));
entity.setPolicyData(entity.getPolicyData().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
entity.setScope(newScope);
entity.setModifiedBy(userId);
- String oldConfigRemoveExtension = removeoldPolicyExtension.replace(".xml", "");
- String newConfigRemoveExtension = removenewPolicyExtension.replace(".xml", "");
if(newpolicyName.contains("Config_")){
- configEntity.setConfigurationName(configEntity.getConfigurationName().replace(oldScope +"."+oldConfigRemoveExtension, newScope+"."+newConfigRemoveExtension));
+ configEntity.setConfigurationName(configEntity.getConfigurationName().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
controller.updateData(configEntity);
}else if(newpolicyName.contains("Action_")){
- actionEntity.setActionBody(actionEntity.getActionBody().replace(oldScope +"."+oldConfigRemoveExtension, newScope+"."+newConfigRemoveExtension));
+ actionEntity.setActionBody(actionEntity.getActionBody().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
controller.updateData(actionEntity);
}
controller.updateData(entity);
@@ -875,7 +878,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
return success();
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
return error(e.getMessage());
}
}
@@ -1021,7 +1024,7 @@ public class PolicyManagerServlet extends HttpServlet {
controller.saveData(entityItem);
}
- LOGGER.debug("copy from: {} to: {}" + oldPath +newPath);
+ LOGGER.debug("copy from: {} to: {}" + oldPath +newPath);
return success();
} catch (Exception e) {
@@ -1225,6 +1228,9 @@ public class PolicyManagerServlet extends HttpServlet {
String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
controller.executeQuery(policyScopeQuery);
}
+ }else{
+ String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
+ controller.executeQuery(policyScopeQuery);
}
}
return success();
@@ -1379,4 +1385,4 @@ public class PolicyManagerServlet extends HttpServlet {
throw new ServletException(e);
}
}
-}
+} \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java
index c40f0da0c..75e3d0b8a 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java
@@ -28,6 +28,7 @@ import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
@@ -321,7 +322,7 @@ public class PolicyRestController extends RestrictedBaseController{
}
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}finally{
if(file != null){
if(file.exists()){
@@ -378,13 +379,43 @@ public class PolicyRestController extends RestrictedBaseController{
return null;
}
+ @RequestMapping(value={"/searchDictionary"}, method={RequestMethod.POST})
+ public ModelAndView searchDictionaryController(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ Object resultList = null;
+ String uri = request.getRequestURI();
+ String body = callPAP(request, response, "POST", uri.replaceFirst("/", "").trim());
+ if(body.contains("CouldNotConnectException")){
+ List<String> data = new ArrayList<String>();
+ data.add("Elastic Search Server is down");
+ resultList = data;
+ }else{
+ JSONObject json = new JSONObject(body);
+ resultList = json.get("policyresult");
+ }
+
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application / json");
+ PrintWriter out = response.getWriter();
+ JSONObject j = new JSONObject("{result: " + resultList + "}");
+ out.write(j.toString());
+ return null;
+ }
+
@RequestMapping(value={"/searchPolicy"}, method={RequestMethod.POST})
public ModelAndView searchPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ Object resultList = null;
String uri = request.getRequestURI()+"?action=search";
String body = callPAP(request, response, "POST", uri.replaceFirst("/", "").trim());
+
JSONObject json = new JSONObject(body);
- Object resultList = json.get("policyresult");
-
+ try{
+ resultList = json.get("policyresult");
+ }catch(Exception e){
+ List<String> data = new ArrayList<String>();
+ data.add("Elastic Search Server is down");
+ resultList = data;
+ }
+
response.setCharacterEncoding("UTF-8");
response.setContentType("application / json");
request.setCharacterEncoding("UTF-8");
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyUserInfoController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyUserInfoController.java
index 97d26a4ee..a170b34aa 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyUserInfoController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyUserInfoController.java
@@ -26,6 +26,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.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;
@@ -39,6 +41,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RequestMapping("/")
public class PolicyUserInfoController extends RestrictedBaseController{
+ private static final Logger LOGGER = FlexLogger.getLogger(PolicyUserInfoController.class);
+
@RequestMapping(value="/get_PolicyUserInfo", method = RequestMethod.GET)
private void getPolicyUserInfo(HttpServletRequest request, HttpServletResponse response){
JsonMessage msg = null;
@@ -51,7 +55,7 @@ public class PolicyUserInfoController extends RestrictedBaseController{
JSONObject j = new JSONObject(msg);
response.getWriter().write(j.toString());
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/PolicyImportWindow.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/PolicyImportWindow.java
index 30a49a1ae..6e40c2be2 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/PolicyImportWindow.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/PolicyImportWindow.java
@@ -99,7 +99,7 @@ public class PolicyImportWindow{
}
}
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -152,7 +152,7 @@ public class PolicyImportWindow{
outputFile.close();
} catch (IOException e) {
LOGGER.info("IOException:" +e);
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java
index 2e555f254..b0bbaf9cf 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java
@@ -115,7 +115,7 @@ public class ActionPolicyController extends RestrictedBaseController{
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// Component attributes are saved under Target here we are fetching them back.
- // One row is default so we are not adding dynamic componet at index 0.
+ // One row is default so we are not adding dynamic component at index 0.
Map<String, String> attribute = new HashMap<String, String>();
attribute.put("key", attributeId);
attribute.put("value", value);
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java
index ee5ed7279..46fb2bbfe 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java
@@ -29,6 +29,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.rest.dao.CommonClassDao;
import org.openecomp.policy.rest.jpa.GlobalRoleSettings;
import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
@@ -47,11 +49,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RequestMapping({"/"})
public class AdminTabController extends RestrictedBaseController{
+ private static final Logger LOGGER = FlexLogger.getLogger(AdminTabController.class);
+
@Autowired
CommonClassDao commonClassDao;
-
-
@RequestMapping(value={"/get_LockDownData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getAdminTabEntityData(HttpServletRequest request, HttpServletResponse response){
try{
@@ -63,7 +65,7 @@ public class AdminTabController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java
index 86d9920d9..8751d735c 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java
@@ -154,7 +154,7 @@ public class AutoPushController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
@@ -251,7 +251,7 @@ public class AutoPushController extends RestrictedBaseController{
try {
PolicyController.getPapEngine().copyPolicy(selectedPolicy, (StdPDPGroup) pdpDestinationGroupId);
} catch (PAPException e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
return null;
}
selectedPolicies.add(selectedPolicy);
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
index 786e17a16..265b7b7b2 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
@@ -57,6 +57,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
@@ -275,7 +276,6 @@ public class CreateBRMSParamController extends RestrictedBaseController {
List<AllOfType> allOfList = anyOf.getAllOf();
if (allOfList != null) {
Iterator<AllOfType> iterAllOf = allOfList.iterator();
- int index = 0;
while (iterAllOf.hasNext()) {
AllOfType allOf = iterAllOf.next();
// Under AllOFType we have Match
@@ -285,29 +285,27 @@ public class CreateBRMSParamController extends RestrictedBaseController {
while (iterMatch.hasNext()) {
MatchType match = iterMatch.next();
//
- // Under the match we have attributevalue and
+ // Under the match we have attribute value and
// attributeDesignator. So,finally down to the actual attribute.
//
AttributeValueType attributeValue = match.getAttributeValue();
String value = (String) attributeValue.getContent().get(0);
+ AttributeDesignatorType designator = match.getAttributeDesignator();
+ String attributeId = designator.getAttributeId();
- if (index == 3){
+ if (attributeId.equals("RiskType")){
policyAdapter.setRiskType(value);
}
-
- if (index == 4){
+ if (attributeId.equals("RiskLevel")){
policyAdapter.setRiskLevel(value);
}
-
- if (index == 5){
+ if (attributeId.equals("guard")){
policyAdapter.setGuard(value);
}
- if (index == 6 && !value.contains("NA")){
+ if (attributeId.equals("TTLDate") && !value.contains("NA")){
String newDate = convertDate(value, true);
policyAdapter.setTtlDate(newDate);
}
-
- index++;
}
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java
index 381673ca5..b31f70297 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java
@@ -35,6 +35,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
@@ -112,7 +113,6 @@ public class CreateBRMSRawController{
List<AllOfType> allOfList = anyOf.getAllOf();
if (allOfList != null) {
Iterator<AllOfType> iterAllOf = allOfList.iterator();
- int index = 0;
while (iterAllOf.hasNext()) {
AllOfType allOf = iterAllOf.next();
// Under AllOFType we have Match
@@ -122,29 +122,27 @@ public class CreateBRMSRawController{
while (iterMatch.hasNext()) {
MatchType match = iterMatch.next();
//
- // Under the match we have attributevalue and
+ // Under the match we have attribute value and
// attributeDesignator. So,finally down to the actual attribute.
//
AttributeValueType attributeValue = match.getAttributeValue();
String value = (String) attributeValue.getContent().get(0);
-
- if (index == 3){
+ AttributeDesignatorType designator = match.getAttributeDesignator();
+ String attributeId = designator.getAttributeId();
+
+ if (attributeId.equals("RiskType")){
policyAdapter.setRiskType(value);
}
-
- if (index == 4){
+ if (attributeId.equals("RiskLevel")){
policyAdapter.setRiskLevel(value);
}
-
- if (index == 5){
+ if (attributeId.equals("guard")){
policyAdapter.setGuard(value);
}
- if (index == 6 && !value.contains("NA")){
+ if (attributeId.equals("TTLDate") && !value.contains("NA")){
String newDate = convertDate(value, true);
policyAdapter.setTtlDate(newDate);
}
-
- index++;
}
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java
index d75231ef0..d2a2845e8 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java
@@ -29,6 +29,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.rest.adapter.ClosedLoopFaultBody;
import org.openecomp.policy.rest.adapter.ClosedLoopFaultTriggerUISignatures;
import org.openecomp.policy.rest.adapter.ClosedLoopSignatures;
@@ -49,6 +51,7 @@ import com.fasterxml.jackson.databind.ObjectWriter;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
@@ -58,6 +61,8 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
@RequestMapping("/")
public class CreateClosedLoopFaultController extends RestrictedBaseController{
+ private static final Logger LOGGER = FlexLogger.getLogger(CreateClosedLoopFaultController.class);
+
protected PolicyRestAdapter policyAdapter = null;
@@ -512,7 +517,6 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
List<AllOfType> allOfList = anyOf.getAllOf();
if (allOfList != null) {
Iterator<AllOfType> iterAllOf = allOfList.iterator();
- int index = 0;
while (iterAllOf.hasNext()) {
AllOfType allOf = iterAllOf.next();
// Under AllOFType we have Match
@@ -522,35 +526,34 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
while (iterMatch.hasNext()) {
MatchType match = iterMatch.next();
//
- // Under the match we have attributevalue and
+ // Under the match we have attribute value and
// attributeDesignator. So,finally down to the actual attribute.
//
AttributeValueType attributeValue = match.getAttributeValue();
String value = (String) attributeValue.getContent().get(0);
-
+ AttributeDesignatorType designator = match.getAttributeDesignator();
+ String attributeId = designator.getAttributeId();
+
// First match in the target is EcompName, so set that value.
- if (index == 1) {
+ if (attributeId.equals("ECOMPName")) {
policyAdapter.setEcompName(value);
EcompName ecompName = new EcompName();
ecompName.setEcompName(value);
policyAdapter.setEcompNameField(ecompName);
}
- if (index == 2){
+ if (attributeId.equals("RiskType")){
policyAdapter.setRiskType(value);
}
-
- if (index == 3){
+ if (attributeId.equals("RiskLevel")){
policyAdapter.setRiskLevel(value);
}
-
- if (index == 4){
+ if (attributeId.equals("guard")){
policyAdapter.setGuard(value);
}
- if (index == 5 && !value.contains("NA")){
+ if (attributeId.equals("TTLDate") && !value.contains("NA")){
String newDate = convertDate(value, true);
policyAdapter.setTtlDate(newDate);
}
- index++;
}
}
}
@@ -600,7 +603,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
}
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
return null;
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java
index 375866aa8..385ca159c 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java
@@ -30,6 +30,8 @@ import javax.json.JsonArray;
import javax.json.JsonObject;
import org.openecomp.policy.admin.PolicyManagerServlet;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.rest.adapter.ClosedLoopPMBody;
import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
import org.openecomp.policy.rest.jpa.PolicyEntity;
@@ -38,6 +40,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
@@ -45,6 +48,8 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
public class CreateClosedLoopPMController{
+ private static final Logger LOGGER = FlexLogger.getLogger(CreateClosedLoopPMController.class);
+
protected PolicyRestAdapter policyAdapter = null;
public void prePopulateClosedLoopPMPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
@@ -79,39 +84,36 @@ public class CreateClosedLoopPMController{
// Under AllOFType we have Match
List<MatchType> matchList = allOf.getMatch();
if (matchList != null) {
- int index = 0;
Iterator<MatchType> iterMatch = matchList.iterator();
while (matchList.size()>1 && iterMatch.hasNext()) {
MatchType match = iterMatch.next();
//
- // Under the match we have attributevalue and
+ // Under the match we have attribute value and
// attributeDesignator. So,finally down to the actual attribute.
//
AttributeValueType attributeValue = match.getAttributeValue();
String value = (String) attributeValue.getContent().get(0);
+ AttributeDesignatorType designator = match.getAttributeDesignator();
+ String attributeId = designator.getAttributeId();
// First match in the target is EcompName, so set that value.
- if (index == 0) {
+ if (attributeId.equals("ECOMPName")) {
policyAdapter.setEcompName(value);
}
-
- if (index == 1){
+ if (attributeId.equals("RiskType")){
policyAdapter.setRiskType(value);
}
-
- if (index == 2){
+ if (attributeId.equals("RiskLevel")){
policyAdapter.setRiskLevel(value);
}
-
- if (index == 3){
+ if (attributeId.equals("guard")){
policyAdapter.setGuard(value);
}
-
- if (index == 4 && !value.contains("NA")){
+ if (attributeId.equals("TTLDate") && !value.contains("NA")){
String newDate = convertDate(value, true);
policyAdapter.setTtlDate(newDate);
}
- if (index == 5){
+ if (attributeId.equals("ServiceType")){
LinkedHashMap<String, String> serviceTypePolicyName1 = new LinkedHashMap<>();
String key = "serviceTypePolicyName";
serviceTypePolicyName1.put(key, value);
@@ -126,7 +128,6 @@ public class CreateClosedLoopPMController{
attributes.put("attributes", getAttributes(value));
policyAdapter.setAttributeFields(attributes);
}
- index++;
}
}
}
@@ -160,7 +161,7 @@ public class CreateClosedLoopPMController{
ClosedLoopPMBody closedLoopBody = mapper.readValue(entity.getConfigurationData().getConfigBody(), ClosedLoopPMBody.class);
policyAdapter.setJsonBodyData(closedLoopBody);
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java
index aeb5266c5..ce6531f38 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java
@@ -92,6 +92,7 @@ import com.google.gson.Gson;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
@@ -1020,52 +1021,45 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
// Under AllOFType we have Match
List<MatchType> matchList = allOf.getMatch();
if (matchList != null) {
- int index = 0;
Iterator<MatchType> iterMatch = matchList.iterator();
while (matchList.size()>1 && iterMatch.hasNext()) {
MatchType match = iterMatch.next();
//
- // Under the match we have attributevalue and
+ // Under the match we have attribute value and
// attributeDesignator. So,finally down to the actual attribute.
//
AttributeValueType attributeValue = match.getAttributeValue();
String value = (String) attributeValue.getContent().get(0);
-
+ AttributeDesignatorType designator = match.getAttributeDesignator();
+ String attributeId = designator.getAttributeId();
// First match in the target is EcompName, so set that value.
- if (index == 0) {
+ if (attributeId.equals("ECOMPName")) {
policyAdapter.setEcompName(value);
}
- if (index == 1){
+ if (attributeId.equals("ConfigName")){
policyAdapter.setConfigName(value);
}
- if (index == 2){
- if(value != null){
- readFile(policyAdapter, entity);
- }
- }
- if (index == 3){
+ if (attributeId.equals("uuid")){
policyAdapter.setUuid(value);
}
- if (index == 4){
+ if (attributeId.equals("location")){
policyAdapter.setLocation(value);
}
- if (index == 5){
+ if (attributeId.equals("RiskType")){
policyAdapter.setRiskType(value);
}
-
- if (index == 6){
+ if (attributeId.equals("RiskLevel")){
policyAdapter.setRiskLevel(value);
}
-
- if (index == 7){
+ if (attributeId.equals("guard")){
policyAdapter.setGuard(value);
}
- if (index == 8 && !value.contains("NA")){
+ if (attributeId.equals("TTLDate") && !value.contains("NA")){
String newDate = convertDate(value, true);
policyAdapter.setTtlDate(newDate);
}
- index++;
}
+ readFile(policyAdapter, entity);
}
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java
index 41c960680..1326aba7d 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java
@@ -76,6 +76,7 @@ import com.fasterxml.jackson.databind.ObjectWriter;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
@@ -247,7 +248,6 @@ public class CreateFirewallController extends RestrictedBaseController {
// Under target we have AnyOFType
List<AnyOfType> anyOfList = target.getAnyOf();
if (anyOfList != null) {
- int index = 0;
Iterator<AnyOfType> iterAnyOf = anyOfList.iterator();
while (iterAnyOf.hasNext()) {
AnyOfType anyOf = iterAnyOf.next();
@@ -270,25 +270,24 @@ public class CreateFirewallController extends RestrictedBaseController {
//
AttributeValueType attributeValue = match.getAttributeValue();
String value = (String) attributeValue.getContent().get(0);
- if (index == 1) {
+ AttributeDesignatorType designator = match.getAttributeDesignator();
+ String attributeId = designator.getAttributeId();
+ if (attributeId.equals("ConfigName")) {
policyAdapter.setConfigName(value);
}
- if (index == 2){
+ if (attributeId.equals("RiskType")){
policyAdapter.setRiskType(value);
}
-
- if (index == 3){
+ if (attributeId.equals("RiskLevel")){
policyAdapter.setRiskLevel(value);
}
-
- if (index == 4){
+ if (attributeId.equals("guard")){
policyAdapter.setGuard(value);
}
- if (index == 5 && !value.contains("NA")){
+ if (attributeId.equals("TTLDate") && !value.contains("NA")){
String newDate = convertDate(value, true);
policyAdapter.setTtlDate(newDate);
}
- index++;
}
}
}
@@ -915,15 +914,15 @@ public class CreateFirewallController extends RestrictedBaseController {
try {
json = om.writeValueAsString(tc);
} catch (JsonGenerationException e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
} catch (JsonMappingException e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}catch (Exception e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
return json;
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java
index 9a31d7f72..bca63eb0f 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java
@@ -106,7 +106,7 @@ public class CreatePolicyController extends RestrictedBaseController{
while (iterMatch.hasNext()) {
MatchType match = iterMatch.next();
//
- // Under the match we have attributevalue and
+ // Under the match we have attribute value and
// attributeDesignator. So,finally down to the actual attribute.
//
AttributeValueType attributeValue = match.getAttributeValue();
@@ -114,25 +114,23 @@ public class CreatePolicyController extends RestrictedBaseController{
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// First match in the target is EcompName, so set that value.
- if (index == 1) {
+ if (attributeId.equals("ECOMPName")) {
policyAdapter.setEcompName(value);
}
- if (index == 2){
+ if (attributeId.equals("RiskType")){
policyAdapter.setRiskType(value);
}
-
- if (index == 3){
+ if (attributeId.equals("RiskLevel")){
policyAdapter.setRiskLevel(value);
}
-
- if (index == 4){
+ if (attributeId.equals("guard")){
policyAdapter.setGuard(value);
}
- if (index == 5 && !value.contains("NA")){
+ if (attributeId.equals("TTLDate") && !value.contains("NA")){
String newDate = convertDate(value, true);
policyAdapter.setTtlDate(newDate);
}
- if (index == 6){
+ if (attributeId.equals("ConfigName")){
policyAdapter.setConfigName(value);
}
// After Ecomp and Config it is optional to have attributes, so
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java
index fcde0f370..7ba1e847c 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java
@@ -99,7 +99,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
@@ -114,7 +114,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
@@ -131,7 +131,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
@@ -149,7 +149,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
@@ -167,7 +167,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
@@ -288,7 +288,7 @@ public class DashboardController extends RestrictedBaseController{
logger.error("MalformedObjectNameException for JMX connection");
} catch (MBeanException e) {
logger.error("MBeanException for JMX connection");
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
} catch (ReflectionException e) {
logger.error("ReflectionException for JMX connection");
}
@@ -395,7 +395,7 @@ public class DashboardController extends RestrictedBaseController{
logger.error("MalformedObjectNameException for JMX connection");
} catch (MBeanException e) {
logger.error("MBeanException for JMX connection");
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
} catch (ReflectionException e) {
logger.error("ReflectionException for JMX connection");
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java
index 57e8821f4..82fc24b40 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java
@@ -115,11 +115,11 @@ public class DecisionPolicyController extends RestrictedBaseController {
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// First match in the target is EcompName, so set that value.
- if (index == 0) {
+ if (attributeId.equals("ECOMPName")) {
policyAdapter.setEcompName(value);
}
// Component attributes are saved under Target here we are fetching them back.
- // One row is default so we are not adding dynamic componet at index 0.
+ // One row is default so we are not adding dynamic component at index 0.
if (index >= 1) {
Map<String, String> attribute = new HashMap<String, String>();
attribute.put("key", attributeId);
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
index 2fcf7939b..87b32206e 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
@@ -21,32 +21,36 @@
package org.openecomp.policy.controller;
+import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.model.PDPGroupContainer;
+import org.openecomp.policy.model.Roles;
+import org.openecomp.policy.xacml.api.XACMLErrorConstants;
+import org.openecomp.policy.xacml.api.pap.EcompPDPGroup;
+import org.openecomp.policy.xacml.std.pap.StdPDP;
+import org.openecomp.policy.xacml.std.pap.StdPDPGroup;
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.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-
-import org.openecomp.policy.xacml.api.XACMLErrorConstants;
-import org.openecomp.policy.xacml.api.pap.EcompPDPGroup;
-
import com.att.research.xacml.api.pap.PAPException;
-import org.openecomp.policy.xacml.std.pap.StdPDP;
-import org.openecomp.policy.xacml.std.pap.StdPDPGroup;
+import com.att.research.xacml.api.pap.PDPPolicy;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -59,16 +63,73 @@ public class PDPController extends RestrictedBaseController {
protected List<EcompPDPGroup> groups = Collections.synchronizedList(new ArrayList<EcompPDPGroup>());
private PDPGroupContainer container;
- public synchronized void refreshGroups() {
+ private static String SUPERADMIN = "super-admin";
+ private static String SUPEREDITOR = "super-editor";
+ private static String SUPERGUEST = "super-guest";
+
+ public synchronized void refreshGroups(HttpServletRequest request) {
synchronized(this.groups) {
this.groups.clear();
try {
- this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups());
+ Set<PDPPolicy> filteredPolicies = new HashSet<PDPPolicy>();
+ Set<String> scopes = null;
+ List<String> roles = null;
+ String userId = UserUtils.getUserSession(request).getOrgUserId();
+ List<Object> userRoles = PolicyController.getRoles(userId);
+ roles = new ArrayList<String>();
+ scopes = new HashSet<String>();
+ for(Object role: userRoles){
+ Roles userRole = (Roles) role;
+ roles.add(userRole.getRole());
+ if(userRole.getScope() != null){
+ if(userRole.getScope().contains(",")){
+ String[] multipleScopes = userRole.getScope().split(",");
+ for(int i =0; i < multipleScopes.length; i++){
+ scopes.add(multipleScopes[i]);
+ }
+ }else{
+ scopes.add(userRole.getScope());
+ }
+ }
+ }
+ if (roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST) ) {
+ this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups());
+ }else{
+ if(!userRoles.isEmpty()){
+ if(!scopes.isEmpty()){
+ this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups());
+ if(!groups.isEmpty()){
+ for(EcompPDPGroup group : groups){
+ Set<PDPPolicy> policies = group.getPolicies();
+ for(PDPPolicy policy : policies){
+ for(String scope : scopes){
+ scope = scope.replace(File.separator, ".");
+ String policyName = policy.getId();
+ if(policyName.contains(".Config_")){
+ policyName = policyName.substring(0, policyName.lastIndexOf(".Config_"));
+ }else if(policyName.contains(".Action_")){
+ policyName = policyName.substring(0, policyName.lastIndexOf(".Action_"));
+ }else if(policyName.contains(".Decision_")){
+ policyName = policyName.substring(0, policyName.lastIndexOf(".Decision_"));
+ }
+ if(policyName.startsWith(scope)){
+ filteredPolicies.add(policy);
+ }
+ }
+ }
+ groups.remove(group);
+ StdPDPGroup newGroup = (StdPDPGroup) group;
+ newGroup.setPolicies(filteredPolicies);
+ groups.add(newGroup);
+ }
+ }
+ }
+ }
+ }
} catch (PAPException e) {
String message = "Unable to retrieve Groups from server: " + e;
logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Pap Engine is Null" + message);
}
-
}
}
@@ -76,7 +137,7 @@ public class PDPController extends RestrictedBaseController {
public void getPDPGroupContainerData(HttpServletRequest request, HttpServletResponse response){
try{
ObjectMapper mapper = new ObjectMapper();
- refreshGroups();
+ refreshGroups(request);
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
JSONObject j = new JSONObject(msg);
response.getWriter().write(j.toString());
@@ -90,7 +151,7 @@ public class PDPController extends RestrictedBaseController {
public void getPDPGroupEntityData(HttpServletRequest request, HttpServletResponse response){
try{
ObjectMapper mapper = new ObjectMapper();
- refreshGroups();
+ refreshGroups(request);
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
JSONObject j = new JSONObject(msg);
response.getWriter().write(j.toString());
@@ -126,7 +187,7 @@ public class PDPController extends RestrictedBaseController {
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
- refreshGroups();
+ refreshGroups(request);
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
JSONObject j = new JSONObject(msg);
out.write(j.toString());
@@ -163,7 +224,7 @@ public class PDPController extends RestrictedBaseController {
PrintWriter out = response.getWriter();
- refreshGroups();
+ refreshGroups(request);
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
JSONObject j = new JSONObject(msg);
out.write(j.toString());
@@ -208,7 +269,7 @@ public class PDPController extends RestrictedBaseController {
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
- refreshGroups();
+ refreshGroups(request);
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
JSONObject j = new JSONObject(msg);
out.write(j.toString());
@@ -241,7 +302,7 @@ public class PDPController extends RestrictedBaseController {
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
- refreshGroups();
+ refreshGroups(request);
String responseString = mapper.writeValueAsString(groups);
JSONObject j = new JSONObject("{pdpEntityDatas: " + responseString + "}");
out.write(j.toString());
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java
index 7d8701ef4..a9eb40b4f 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java
@@ -303,7 +303,7 @@ public class PolicyController extends RestrictedBaseController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java
index 82090773c..9a4f52dbb 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java
@@ -31,6 +31,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.rest.dao.CommonClassDao;
import org.openecomp.policy.rest.jpa.PolicyEditorScopes;
import org.openecomp.policy.rest.jpa.PolicyRoles;
@@ -53,6 +55,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RequestMapping("/")
public class PolicyRolesController extends RestrictedBaseController{
+ private static final Logger LOGGER = FlexLogger.getLogger(PolicyRolesController.class);
+
@Autowired
CommonClassDao commonClassDao;
@@ -69,7 +73,7 @@ public class PolicyRolesController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -105,7 +109,7 @@ public class PolicyRolesController extends RestrictedBaseController{
out.write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
return null;
}
@@ -124,7 +128,7 @@ public class PolicyRolesController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java
index eb144cc18..d9d0fc97b 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java
@@ -48,6 +48,8 @@ import javax.xml.parsers.SAXParserFactory;
import org.apache.commons.lang.StringUtils;
import org.dom4j.util.XMLErrorHandler;
import org.json.JSONObject;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.rest.adapter.ClosedLoopFaultBody;
import org.openecomp.policy.rest.adapter.ClosedLoopPMBody;
import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
@@ -76,6 +78,8 @@ import com.google.common.base.Strings;
@RequestMapping("/")
public class PolicyValidationController extends RestrictedBaseController {
+ private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidationController.class);
+
public static final String CONFIG_POLICY = "Config";
public static final String ACTION_POLICY = "Action";
public static final String DECISION_POLICY = "Decision";
@@ -644,7 +648,7 @@ public class PolicyValidationController extends RestrictedBaseController {
JsonReader jsonReader = Json.createReader(stream);
System.out.println("Json Value is: " + jsonReader.read().toString() );
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
return false;
}
return true;
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/attributeDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/attributeDictGridController.js
index d7b4c2b01..554f6d08f 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/attributeDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/attributeDictGridController.js
@@ -160,7 +160,7 @@ app.controller('attributeDictGridController', function ($scope, PolicyAppService
var i;
if($scope.searchDatas.length > 0){
for(i = 0 ; i < $scope.searchDatas.length; i++){
- searchString += $scope.searchDatas[i].name + "\n";
+ searchString += $scope.searchDatas[i] + "\n";
}
}else{
searchString += "No Policies is Using this Value"
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/ecompNameDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/ecompNameDictGridController.js
index 1c356ec19..a7964158c 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/ecompNameDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/ecompNameDictGridController.js
@@ -133,26 +133,57 @@ app.controller('ecompNameDictGridController', function ($scope, PolicyAppService
};
$scope.deleteEcompName = function(data) {
- modalService.popupConfirmWin("Confirm","You are about to delete the Ecomp Name "+data.ecompName+". Do you want to continue?",
- function(){
- var uuu = "deleteDictionary/ecomp_dictionary/remove_ecomp";
- var postData={data: data};
- $.ajax({
- type : 'POST',
- url : uuu,
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify(postData),
- success : function(data){
- $scope.$apply(function(){$scope.ecompNameDictionaryDatas=data.ecompNameDictionaryDatas;});
- },
- error : function(data){
- console.log(data);
- modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
- }
- });
+ var uuu = "searchDictionary";
+ var postData={data: data, type: "ecompName"};
+ var searchString = "\n";
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(resultList){
+ $scope.$apply(function(){
+ $scope.list =resultList.result;});
+ $scope.searchData = JSON.stringify(resultList.result);
+ $scope.searchDatas = JSON.parse($scope.searchData);
+ $scope.success = true;
+ var i;
+ if($scope.searchDatas.length > 0){
+ for(i = 0 ; i < $scope.searchDatas.length; i++){
+ searchString += $scope.searchDatas[i] + "\n";
+ }
+ }else{
+ searchString += "No Policies is Using this Value"
+ }
- })
+ console.log($scope.list);
+ if($scope.success){
+ modalService.popupConfirmWin("Confirm","You are about to delete the Ecomp Name "+data.ecompName+".\n "+searchString+" \n Do you want to continue?",
+ function(){
+ var uuu = "deleteDictionary/ecomp_dictionary/remove_ecomp";
+ var postData={data: data};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){$scope.ecompNameDictionaryDatas=data.ecompNameDictionaryDatas;});
+ },
+ error : function(data){
+ console.log(data);
+ modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
+ }
+ });
+
+ })}
+ },
+ error : function(data){
+ alert("Error while Searching.");
+ }
+ });
};
}); \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html
index dedf4b414..fe822d4c3 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html
@@ -271,7 +271,6 @@
<div ng-include src="'app/policyApp/Windows/Dictionary/RiskTypeDictionary.html'"></div>
<div ng-include src="'app/policyApp/Windows/Dictionary/SafePolicyWarningDictionary.html'"></div>
- <div ng-include src="'app/policyApp/policy-models/Editor/PolicyTemplates/BRMSShowParamRuleModal.html'"></div>
<div ng-include src="'app/policyApp/Windows/PDPTabWindows/PdpStatusWindow.html'"></div>
<div ng-include src="'app/policyApp/Windows/Edit_Roles_Window.html'"></div>
<div ng-include src="'app/policyApp/Windows/PushtabWindow/removeGroupPoliciesWindow.html'"></div>
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
index ebec3a526..b37685739 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
@@ -121,7 +121,7 @@ angular.module('abs').controller('brmsParamPolicyController', ['$scope', '$windo
$scope.datarule = data.policyData;
var modalInstance = $modal.open({
backdrop: 'static', keyboard: false,
- templateUrl : 'brmsshowrule',
+ templateUrl : 'app/policyApp/policy-models/Editor/PolicyTemplates/BRMSShowParamRuleModal.html',
controller: 'showrulecontroller',
resolve: {
message: function () {
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSShowParamRuleModal.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSShowParamRuleModal.html
index 45e482454..2e6b593de 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSShowParamRuleModal.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSShowParamRuleModal.html
@@ -1,5 +1,4 @@
-<script type="text/ng-template" id="brmsshowrule">
-<div>
+<div class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
@@ -14,5 +13,4 @@
</div>
</div>
</div>
-</div>
-</script> \ No newline at end of file
+</div> \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js
index 83c3820a6..445309f4c 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js
@@ -171,7 +171,11 @@ app.controller('PolicySearchController', [
$scope.$apply(function(){
var searchdata = data.result;
if(searchdata.length > 0){
- $scope.policyNavigator.searchrefresh(searchdata);
+ if(searchdata[0] == "Elastic Search Server is down"){
+ alert("Elastic Search Server is down.");
+ }else{
+ $scope.policyNavigator.searchrefresh(searchdata);
+ }
}else{
Notification.info("No Matches Found with your Search");
}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_Dictionary.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_Dictionary.html
index 63429d3de..db490c400 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_Dictionary.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_Dictionary.html
@@ -30,6 +30,10 @@
margin-left: 10%;
margin-right: 10%;
}
+
+.modal-backdrop {
+ background-color: red;
+}
</style>
<div ng-app id="page-content" style="margin-bottom: 20px; width: 100%">
<div>