aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller
diff options
context:
space:
mode:
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller')
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java19
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java41
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java269
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java49
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java20
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java366
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java412
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java13
8 files changed, 787 insertions, 402 deletions
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 6824101df..650b5872f 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
@@ -51,9 +51,25 @@ public class AdminTabController extends RestrictedBaseController{
private static final Logger LOGGER = FlexLogger.getLogger(AdminTabController.class);
+ private static CommonClassDao commonClassDao;
+
+ public static CommonClassDao getCommonClassDao() {
+ return commonClassDao;
+ }
+
+ public static void setCommonClassDao(CommonClassDao commonClassDao) {
+ AdminTabController.commonClassDao = commonClassDao;
+ }
+
@Autowired
- CommonClassDao commonClassDao;
+ private AdminTabController(CommonClassDao commonClassDao){
+ AdminTabController.commonClassDao = commonClassDao;
+ }
+ public AdminTabController() {
+ //default constructor
+ }
+
@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{
@@ -92,6 +108,7 @@ public class AdminTabController extends RestrictedBaseController{
return null;
}
catch (Exception e){
+ LOGGER.error("Exception Occured"+e);
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
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 17e8f89f2..a4387d19a 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
@@ -83,8 +83,16 @@ public class AutoPushController extends RestrictedBaseController{
private PDPGroupContainer container;
protected List<EcompPDPGroup> groups = Collections.synchronizedList(new ArrayList<EcompPDPGroup>());
- private static PDPPolicyContainer policyContainer;
- Set<PDPPolicy> selectedPolicies;
+ private PDPPolicyContainer policyContainer;
+
+ private PolicyController policyController;
+ public PolicyController getPolicyController() {
+ return policyController;
+ }
+
+ public void setPolicyController(PolicyController policyController) {
+ this.policyController = policyController;
+ }
private List<Object> data;
@@ -92,7 +100,8 @@ public class AutoPushController extends RestrictedBaseController{
synchronized(this.groups) {
this.groups.clear();
try {
- this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups());
+ PolicyController controller = getPolicyControllerInstance();
+ this.groups.addAll(controller.getPapEngine().getEcompPDPGroups());
} catch (PAPException e) {
String message = "Unable to retrieve Groups from server: " + e;
logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message);
@@ -101,6 +110,10 @@ public class AutoPushController extends RestrictedBaseController{
}
}
+ private PolicyController getPolicyControllerInstance(){
+ return policyController != null ? getPolicyController() : new PolicyController();
+ }
+
@RequestMapping(value={"/get_AutoPushPoliciesContainerData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getPolicyGroupContainerData(HttpServletRequest request, HttpServletResponse response){
try{
@@ -110,7 +123,8 @@ public class AutoPushController extends RestrictedBaseController{
String userId = UserUtils.getUserSession(request).getOrgUserId();
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
- List<Object> userRoles = PolicyController.getRoles(userId);
+ PolicyController controller = policyController != null ? getPolicyController() : new PolicyController();
+ List<Object> userRoles = controller.getRoles(userId);
roles = new ArrayList<>();
scopes = new HashSet<>();
for(Object role: userRoles){
@@ -163,12 +177,13 @@ public class AutoPushController extends RestrictedBaseController{
try {
ArrayList<Object> selectedPDPS = new ArrayList<>();
ArrayList<String> selectedPoliciesInUI = new ArrayList<>();
- this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups());
+ PolicyController controller = getPolicyControllerInstance();
+ this.groups.addAll(controller.getPapEngine().getEcompPDPGroups());
ObjectMapper mapper = new ObjectMapper();
- this.container = new PDPGroupContainer(PolicyController.getPapEngine());
+ this.container = new PDPGroupContainer(controller.getPapEngine());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- AutoPushTabAdapter adapter = (AutoPushTabAdapter) mapper.readValue(root.get("pushTabData").toString(), AutoPushTabAdapter.class);
+ AutoPushTabAdapter adapter = mapper.readValue(root.get("pushTabData").toString(), AutoPushTabAdapter.class);
for (Object pdpGroupId : adapter.getPdpDatas()) {
LinkedHashMap<?, ?> selectedPDP = (LinkedHashMap<?, ?>)pdpGroupId;
for(EcompPDPGroup pdpGroup : this.groups){
@@ -220,10 +235,8 @@ public class AutoPushController extends RestrictedBaseController{
}else if(dbCheckName.contains("Decision_")){
dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
}
- PolicyController controller = new PolicyController();
String[] split = dbCheckName.split(":");
String query = "FROM PolicyEntity where policyName = '"+split[1]+"' and scope ='"+split[0]+"'";
- System.out.println(query);
List<Object> queryData = controller.getDataByQuery(query);
PolicyEntity policyEntity = (PolicyEntity) queryData.get(0);
File temp = new File(name);
@@ -237,7 +250,6 @@ public class AutoPushController extends RestrictedBaseController{
selectedPolicy = new StdPDPPolicy(name, true, id, selectedURI);
} catch (IOException e) {
logger.error("Unable to create policy '" + name + "': "+ e.getMessage());
- //AdminNotification.warn("Unable to create policy '" + id + "': " + e.getMessage());
}
StdPDPGroup selectedGroup = (StdPDPGroup) pdpDestinationGroupId;
if (selectedPolicy != null) {
@@ -249,7 +261,7 @@ public class AutoPushController extends RestrictedBaseController{
}
// copy policy to PAP
try {
- PolicyController.getPapEngine().copyPolicy(selectedPolicy, (StdPDPGroup) pdpDestinationGroupId);
+ controller.getPapEngine().copyPolicy(selectedPolicy, (StdPDPGroup) pdpDestinationGroupId);
} catch (PAPException e) {
logger.error("Exception Occured"+e);
return null;
@@ -317,7 +329,8 @@ public class AutoPushController extends RestrictedBaseController{
@RequestMapping(value={"/auto_Push/remove_GroupPolicies.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
- this.container = new PDPGroupContainer(PolicyController.getPapEngine());
+ PolicyController controller = getPolicyControllerInstance();
+ this.container = new PDPGroupContainer(controller.getPapEngine());
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
@@ -327,10 +340,10 @@ public class AutoPushController extends RestrictedBaseController{
if(removePolicyData.size() > 0){
for(int i = 0 ; i < removePolicyData.size(); i++){
String data = removePolicyData.get(i).toString();
- AutoPushController.policyContainer.removeItem(data);
+ this.policyContainer.removeItem(data);
}
Set<PDPPolicy> changedPolicies = new HashSet<>();
- changedPolicies.addAll((Collection<PDPPolicy>) AutoPushController.policyContainer.getItemIds());
+ changedPolicies.addAll((Collection<PDPPolicy>) this.policyContainer.getItemIds());
StdPDPGroup updatedGroupObject = new StdPDPGroup(group.getId(), group.isDefaultGroup(), group.getName(), group.getDescription(),null);
updatedGroupObject.setPolicies(changedPolicies);
updatedGroupObject.setEcompPdps(group.getEcompPdps());
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 daab6e378..68dff19bd 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
@@ -70,7 +70,7 @@ import org.openecomp.policy.common.logging.flexlogger.Logger;
@Controller
@RequestMapping("/")
public class CreateBRMSParamController extends RestrictedBaseController {
- private static final Logger logger = FlexLogger.getLogger(CreateBRMSParamController.class);
+ private static final Logger policyLogger = FlexLogger.getLogger(CreateBRMSParamController.class);
private static CommonClassDao commonClassDao;
@@ -80,10 +80,12 @@ public class CreateBRMSParamController extends RestrictedBaseController {
}
public CreateBRMSParamController(){}
- protected PolicyRestAdapter policyAdapter = null;
- private ArrayList<Object> attributeList;
+ protected PolicyRestAdapter policyAdapter = null;
private HashMap<String, String> dynamicLayoutMap;
+
+ private static String brmsTemplateVlaue = "<$%BRMSParamTemplate=";
+ private static String String = "String";
@RequestMapping(value={"/policyController/getBRMSTemplateData.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
@@ -92,11 +94,11 @@ public class CreateBRMSParamController extends RestrictedBaseController {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- String rule = findRule(root.get("policyData").toString().replaceAll("^\"|\"$", ""));
+ String rule = findRule(root.get(PolicyController.getPolicydata()).toString().replaceAll("^\"|\"$", ""));
generateUI(rule);
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(PolicyController.getCharacterencoding());
+ response.setContentType(PolicyController.getContenttype());
+ request.setCharacterEncoding(PolicyController.getCharacterencoding());
PrintWriter out = response.getWriter();
String responseString = mapper.writeValueAsString(dynamicLayoutMap);
@@ -119,7 +121,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
protected void generateUI(String rule) {
if(rule!=null){
try {
- String params = "";
+ StringBuilder params = new StringBuilder("");
Boolean flag = false;
Boolean comment = false;
String lines[] = rule.split("\n");
@@ -142,6 +144,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
line = line.split("\\/\\*")[0]
+ line.split("\\*\\/")[1].replace("*/", "");
} catch (Exception e) {
+ policyLogger.info("Just for Logging"+e);
line = line.split("\\/\\*")[0];
}
} else {
@@ -153,6 +156,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
try {
line = line.split("\\*\\/")[1].replace("*/", "");
} catch (Exception e) {
+ policyLogger.info("Just for Logging"+e);
line = "";
}
}
@@ -160,38 +164,38 @@ public class CreateBRMSParamController extends RestrictedBaseController {
continue;
}
if (flag) {
- params = params + line;
+ params.append(line);
}
if (line.contains("declare Params")) {
- params = params + line;
+ params.append(line);
flag = true;
}
if (line.contains("end") && flag) {
break;
}
}
- params = params.replace("declare Params", "").replace("end", "")
- .replaceAll("\\s+", "");
- String[] components = params.split(":");
+ params = new StringBuilder(params.toString().replace("declare Params", "").replace("end", "").replaceAll("\\s+", ""));
+ String[] components = params.toString().split(":");
String caption = "";
for (int i = 0; i < components.length; i++) {
String type = "";
if (i == 0) {
caption = components[i];
}
- if(caption.equals("")){
+ if("".equals(caption)){
break;
}
String nextComponent = "";
try {
nextComponent = components[i + 1];
} catch (Exception e) {
+ policyLogger.info("Just for Logging"+e);
nextComponent = components[i];
}
- if (nextComponent.startsWith("String")) {
+ if (nextComponent.startsWith(String)) {
type = "String";
createField(caption, type);
- caption = nextComponent.replace("String", "");
+ caption = nextComponent.replace(String, "");
} else if (nextComponent.startsWith("int")) {
type = "int";
createField(caption, type);
@@ -199,7 +203,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
}
}
} catch (Exception e) {
- logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+ policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
}
}
}
@@ -208,10 +212,11 @@ public class CreateBRMSParamController extends RestrictedBaseController {
dynamicLayoutMap.put(caption, type);
}
-
- @SuppressWarnings("unchecked")
+ /*
+ * When the User Click Edit or View Policy the following method will get invoked for setting the data to PolicyRestAdapter.
+ * Which is used to bind the data in GUI
+ */
public void prePopulateBRMSParamPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- attributeList = new ArrayList<>();
dynamicLayoutMap = new HashMap<>();
if (policyAdapter.getPolicyData() instanceof PolicyType) {
PolicyType policy = (PolicyType) policyAdapter.getPolicyData();
@@ -219,101 +224,116 @@ public class CreateBRMSParamController extends RestrictedBaseController {
// policy name value is the policy name without any prefix and
// Extensions.
String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("BRMS_Param_") + 11);
- if (logger.isDebugEnabled()) {
- logger.debug("Prepopulating form data for BRMS RAW Policy selected:" + policyAdapter.getPolicyName());
+ if (policyLogger.isDebugEnabled()) {
+ policyLogger.debug("Prepopulating form data for BRMS RAW Policy selected:" + policyAdapter.getPolicyName());
}
policyAdapter.setPolicyName(policyNameValue);
String description = "";
try{
description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
}catch(Exception e){
+ policyLogger.info("Just for Logging"+e);
description = policy.getDescription();
}
policyAdapter.setPolicyDescription(description);
- // Set Attributes.
- AdviceExpressionsType expressionTypes = ((RuleType)policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().get(0)).getAdviceExpressions();
- for( AdviceExpressionType adviceExpression: expressionTypes.getAdviceExpression()){
- for(AttributeAssignmentExpressionType attributeAssignment: adviceExpression.getAttributeAssignmentExpression()){
- if(attributeAssignment.getAttributeId().startsWith("key:")){
- Map<String, String> attribute = new HashMap<>();
- String key = attributeAssignment.getAttributeId().replace("key:", "");
- attribute.put("key", key);
- JAXBElement<AttributeValueType> attributevalue = (JAXBElement<AttributeValueType>) attributeAssignment.getExpression();
- String value = (String) attributevalue.getValue().getContent().get(0);
- attribute.put("value", value);
- attributeList.add(attribute);
- }else if(attributeAssignment.getAttributeId().startsWith("dependencies:")){
- ArrayList<String> dependencies = new ArrayList<String>(Arrays.asList(attributeAssignment.getAttributeId().replace("dependencies:", "").split(",")));
- if(dependencies.contains("")){
- dependencies.remove("");
- }
- policyAdapter.setBrmsDependency(dependencies);
- }else if(attributeAssignment.getAttributeId().startsWith("controller:")){
- policyAdapter.setBrmsController(attributeAssignment.getAttributeId().replace("controller:", ""));
- }
- }
- policyAdapter.setAttributes(attributeList);
- }
+ setDataAdapterFromAdviceExpressions(policy, policyAdapter);
paramUIGenerate(policyAdapter, entity);
// Get the target data under policy.
policyAdapter.setDynamicLayoutMap(dynamicLayoutMap);
if(policyAdapter.getDynamicLayoutMap().size() > 0){
LinkedHashMap<String,String> drlRule = new LinkedHashMap<>();
for(Object keyValue: policyAdapter.getDynamicLayoutMap().keySet()){
- drlRule.put(keyValue.toString(), policyAdapter.getDynamicLayoutMap().get(keyValue).toString());
+ drlRule.put(keyValue.toString(), policyAdapter.getDynamicLayoutMap().get(keyValue));
}
policyAdapter.setRuleData(drlRule);
}
TargetType target = policy.getTarget();
if (target != null) {
- // Under target we have AnyOFType
- List<AnyOfType> anyOfList = target.getAnyOf();
- if (anyOfList != null) {
- Iterator<AnyOfType> iterAnyOf = anyOfList.iterator();
- while (iterAnyOf.hasNext()) {
- AnyOfType anyOf = iterAnyOf.next();
- // Under AnyOFType we have AllOFType
- List<AllOfType> allOfList = anyOf.getAllOf();
- if (allOfList != null) {
- Iterator<AllOfType> iterAllOf = allOfList.iterator();
- while (iterAllOf.hasNext()) {
- AllOfType allOf = iterAllOf.next();
- // Under AllOFType we have Match
- List<MatchType> matchList = allOf.getMatch();
- if (matchList != null) {
- Iterator<MatchType> iterMatch = matchList.iterator();
- while (iterMatch.hasNext()) {
- MatchType match = iterMatch.next();
- //
- // 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 (attributeId.equals("RiskType")){
- policyAdapter.setRiskType(value);
- }
- if (attributeId.equals("RiskLevel")){
- policyAdapter.setRiskLevel(value);
- }
- if (attributeId.equals("guard")){
- policyAdapter.setGuard(value);
- }
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
- String newDate = convertDate(value, true);
- policyAdapter.setTtlDate(newDate);
- }
- }
- }
- }
+ setDataToAdapterFromTarget(target, policyAdapter);
+ }
+ }
+ }
+
+ private void setDataAdapterFromAdviceExpressions(PolicyType policy, PolicyRestAdapter policyAdapter){
+ ArrayList<Object> attributeList = new ArrayList<>();
+ // Set Attributes.
+ AdviceExpressionsType expressionTypes = ((RuleType)policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().get(0)).getAdviceExpressions();
+ for( AdviceExpressionType adviceExpression: expressionTypes.getAdviceExpression()){
+ for(AttributeAssignmentExpressionType attributeAssignment: adviceExpression.getAttributeAssignmentExpression()){
+ if(attributeAssignment.getAttributeId().startsWith("key:")){
+ Map<String, String> attribute = new HashMap<>();
+ String key = attributeAssignment.getAttributeId().replace("key:", "");
+ attribute.put("key", key);
+ @SuppressWarnings("unchecked")
+ JAXBElement<AttributeValueType> attributevalue = (JAXBElement<AttributeValueType>) attributeAssignment.getExpression();
+ String value = (String) attributevalue.getValue().getContent().get(0);
+ attribute.put("value", value);
+ attributeList.add(attribute);
+ }else if(attributeAssignment.getAttributeId().startsWith("dependencies:")){
+ ArrayList<String> dependencies = new ArrayList<>(Arrays.asList(attributeAssignment.getAttributeId().replace("dependencies:", "").split(",")));
+ if(dependencies.contains("")){
+ dependencies.remove("");
+ }
+ policyAdapter.setBrmsDependency(dependencies);
+ }else if(attributeAssignment.getAttributeId().startsWith("controller:")){
+ policyAdapter.setBrmsController(attributeAssignment.getAttributeId().replace("controller:", ""));
+ }
+ }
+ policyAdapter.setAttributes(attributeList);
+ }
+ }
+
+ private void setDataToAdapterFromTarget(TargetType target, PolicyRestAdapter policyAdapter){
+ // Under target we have AnyOFType
+ List<AnyOfType> anyOfList = target.getAnyOf();
+ if (anyOfList != null) {
+ Iterator<AnyOfType> iterAnyOf = anyOfList.iterator();
+ while (iterAnyOf.hasNext()) {
+ AnyOfType anyOf = iterAnyOf.next();
+ // Under AnyOFType we have AllOFType
+ List<AllOfType> allOfList = anyOf.getAllOf();
+ if (allOfList != null) {
+ Iterator<AllOfType> iterAllOf = allOfList.iterator();
+ while (iterAllOf.hasNext()) {
+ AllOfType allOf = iterAllOf.next();
+ // Under AllOFType we have Match
+ List<MatchType> matchList = allOf.getMatch();
+ if (matchList != null) {
+ setDataToAdapterFromMatchList(matchList, policyAdapter);
}
}
}
}
- }
+ }
+ }
+
+ private void setDataToAdapterFromMatchList(List<MatchType> matchList, PolicyRestAdapter policyAdapter){
+ Iterator<MatchType> iterMatch = matchList.iterator();
+ while (iterMatch.hasNext()) {
+ MatchType match = iterMatch.next();
+ //
+ // 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 ("RiskType".equals(attributeId)){
+ policyAdapter.setRiskType(value);
+ }
+ if ("RiskLevel".equals(attributeId)){
+ policyAdapter.setRiskLevel(value);
+ }
+ if ("guard".equals(attributeId)){
+ policyAdapter.setGuard(value);
+ }
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
+ String newDate = convertDate(value, true);
+ policyAdapter.setTtlDate(newDate);
+ }
+ }
}
private String convertDate(String dateTTL, boolean portalType) {
@@ -336,26 +356,24 @@ public class CreateBRMSParamController extends RestrictedBaseController {
String data = entity.getConfigurationData().getConfigBody();
if(data != null){
try {
- String params = "";
+ StringBuilder params = new StringBuilder("");
Boolean flag = false;
Boolean comment = false;
for (String line : data.split("\n")) {
if (line.isEmpty() || line.startsWith("//")) {
continue;
}
- if(line.contains("<$%BRMSParamTemplate=")){
+ if(line.contains(brmsTemplateVlaue)){
String value = line.substring(line.indexOf("<$%"),line.indexOf("%$>"));
- value = value.replace("<$%BRMSParamTemplate=", "");
+ value = value.replace(brmsTemplateVlaue, "");
policyAdapter.setRuleName(value);
}
if (line.startsWith("/*")) {
comment = true;
continue;
}
- if (line.contains("//")) {
- if(!(line.contains("http://") || line.contains("https://"))){
- line = line.split("\\/\\/")[0];
- }
+ if ((line.contains("//"))&&(!(line.contains("http://") || line.contains("https://")))){
+ line = line.split("\\/\\/")[0];
}
if (line.contains("/*")) {
comment = true;
@@ -366,6 +384,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
+ line.split("\\*\\/")[1].replace(
"*/", "");
} catch (Exception e) {
+ policyLogger.info("Just for Logging"+e);
line = line.split("\\/\\*")[0];
}
} else {
@@ -378,6 +397,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
line = line.split("\\*\\/")[1]
.replace("*/", "");
} catch (Exception e) {
+ policyLogger.info("Just for Logging"+e);
line = "";
}
}
@@ -385,26 +405,27 @@ public class CreateBRMSParamController extends RestrictedBaseController {
continue;
}
if (flag) {
- params = params + line;
+ params.append(line);
}
if (line.contains("rule") && line.contains(".Params\"")) {
- params = params + line;
+ params.append(line);
flag = true;
}
if (line.contains("end") && flag) {
break;
}
}
- params = params.substring(params.indexOf(".Params\"")+ 8);
- params = params.replaceAll("\\s+", "").replace("salience1000whenthenParamsparams=newParams();","")
+ params = new StringBuilder(params.substring(params.indexOf(".Params\"")+ 8));
+ params = new StringBuilder(params.toString().replaceAll("\\s+", "").replace("salience1000whenthenParamsparams=newParams();","")
.replace("insert(params);end", "")
- .replace("params.set", "");
- String[] components = params.split(";");
+ .replace("params.set", ""));
+ String[] components = params.toString().split("\\);");
if(components!= null && components.length > 0){
for (int i = 0; i < components.length; i++) {
String value = null;
+ components[i] = components[i]+")";
String caption = components[i].substring(0,
- components[i].indexOf("("));
+ components[i].indexOf('('));
caption = caption.substring(0, 1).toLowerCase() + caption.substring(1);
if (components[i].contains("(\"")) {
value = components[i]
@@ -413,8 +434,8 @@ public class CreateBRMSParamController extends RestrictedBaseController {
.replace("(\"", "").replace("\")", "");
} else {
value = components[i]
- .substring(components[i].indexOf("("),
- components[i].indexOf(")"))
+ .substring(components[i].indexOf('('),
+ components[i].indexOf(')'))
.replace("(", "").replace(")", "");
}
dynamicLayoutMap.put(caption, value);
@@ -422,7 +443,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
}
}
} catch (Exception e) {
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage());
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage() + e);
}
}
@@ -436,37 +457,37 @@ public class CreateBRMSParamController extends RestrictedBaseController {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- PolicyRestAdapter policyData = (PolicyRestAdapter)mapper.readValue(root.get("policyData").get("policy").toString(), PolicyRestAdapter.class);
- policyData.setDomainDir(root.get("policyData").get("model").get("name").toString().replace("\"", ""));
- if(root.get("policyData").get("model").get("type").toString().replace("\"", "").equals("file")){
- policyData.isEditPolicy = true;
+ PolicyRestAdapter policyData = mapper.readValue(root.get(PolicyController.getPolicydata()).get("policy").toString(), PolicyRestAdapter.class);
+ policyData.setDomainDir(root.get(PolicyController.getPolicydata()).get("model").get("name").toString().replace("\"", ""));
+ if(root.get(PolicyController.getPolicydata()).get("model").get("type").toString().replace("\"", "").equals(PolicyController.getFile())){
+ policyData.setEditPolicy(true);
}
String body = "";
body = "/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose. \n\t " +
- "<$%BRMSParamTemplate=" + policyData.getRuleName() + "%$> \n */ \n";
+ brmsTemplateVlaue + policyData.getRuleName() + "%$> \n */ \n";
body = body + findRule((String) policyData.getRuleName()) + "\n";
- String generatedRule = "rule \""+ policyData.getDomainDir().replace("\\", ".") +".Config_BRMS_Param_" + policyData.getPolicyName()+".Params\" \n\tsalience 1000 \n\twhen\n\tthen\n\t\tParams params = new Params();";
+ StringBuilder generatedRule = new StringBuilder();
+ generatedRule.append("rule \""+ policyData.getDomainDir().replace("\\", ".") +".Config_BRMS_Param_" + policyData.getPolicyName()+".Params\" \n\tsalience 1000 \n\twhen\n\tthen\n\t\tParams params = new Params();");
if(policyData.getRuleData().size() > 0){
for(Object keyValue: policyData.getRuleData().keySet()){
String key = keyValue.toString().substring(0, 1).toUpperCase() + keyValue.toString().substring(1);
- if (keyValue.equals("String")) {
- generatedRule = generatedRule + "\n\t\tparams.set"
+ if (String.equals(keyValue)) {
+ generatedRule.append("\n\t\tparams.set"
+ key + "(\""
- + policyData.getRuleData().get(keyValue).toString() + "\");";
+ + policyData.getRuleData().get(keyValue).toString() + "\");");
} else {
- generatedRule = generatedRule + "\n\t\tparams.set"
+ generatedRule.append("\n\t\tparams.set"
+ key + "("
- + policyData.getRuleData().get(keyValue).toString() + ");";
+ + policyData.getRuleData().get(keyValue).toString() + ");");
}
}
}
- generatedRule = generatedRule
- + "\n\t\tinsert(params);\nend";
- logger.info("New rule generated with :" + generatedRule);
- body = body + generatedRule;
+ generatedRule.append("\n\t\tinsert(params);\nend");
+ policyLogger.info("New rule generated with :" + generatedRule.toString());
+ body = body + generatedRule.toString();
// Expand the body.
Map<String,String> copyMap=new HashMap<>();
copyMap.putAll((Map<? extends String, ? extends String>) policyData.getRuleData());
@@ -499,7 +520,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
out.write(j.toString());
return null;
} catch (Exception e) {
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
+ policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
}
return null;
}
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 c3daf6d94..f3e313144 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
@@ -104,6 +104,15 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
private static final Logger LOGGER = FlexLogger.getLogger(CreateDcaeMicroServiceController.class);
private static CommonClassDao commonClassDao;
+
+ public static CommonClassDao getCommonClassDao() {
+ return commonClassDao;
+ }
+
+ public static void setCommonClassDao(CommonClassDao commonClassDao) {
+ CreateDcaeMicroServiceController.commonClassDao = commonClassDao;
+ }
+
private MicroServiceModels newModel;
private String newFile;
private String directory;
@@ -238,7 +247,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
// Second index of dot should be returned.
- public void stringBetweenDots(String str,String value){
+ public int stringBetweenDots(String str,String value){
String stringToSearch=str;
String[]ss=stringToSearch.split("\\.");
if(ss!=null){
@@ -247,6 +256,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
uniqueKeys.add(ss[2]);
}
}
+
+ return uniqueKeys.size();
}
public void stringBetweenDotsForDataFields(String str,String value){
@@ -1338,7 +1349,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
private void retreiveDependency(String workingFile, Boolean modelClass) {
- MSModelUtils utils = new MSModelUtils(PolicyController.msEcompName, PolicyController.msPolicyName);
+ MSModelUtils utils = new MSModelUtils(PolicyController.getMsEcompName(), PolicyController.getMsPolicyName());
HashMap<String, MSAttributeObject> tempMap = new HashMap<>();
tempMap = utils.processEpackage(workingFile, MODEL_TYPE.XMI);
@@ -1402,23 +1413,31 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
return list;
}
+ public Map<String, String> getAttributesListRefMap() {
+ return attributesListRefMap;
+ }
+
+ public Map<String, LinkedList<String>> getArrayTextList() {
+ return arrayTextList;
+ }
+
}
class DCAEMicroServiceObject {
- public String service;
- public String location;
- public String uuid;
- public String policyName;
- public String description;
- public String configName;
- public String templateVersion;
- public String version;
- public String priority;
- public String policyScope;
- public String riskType;
- public String riskLevel;
- public String guard = null;
+ private String service;
+ private String location;
+ private String uuid;
+ private String policyName;
+ private String description;
+ private String configName;
+ private String templateVersion;
+ private String version;
+ private String priority;
+ private String policyScope;
+ private String riskType;
+ private String riskLevel;
+ private String guard = null;
public String getGuard() {
return guard;
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 707a65d62..56ff637e9 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
@@ -86,7 +86,18 @@ public class DashboardController extends RestrictedBaseController{
private ArrayList<Object> papStatusData;
private ArrayList<Object> policyActivityData;
+ private PolicyController policyController;
+ public PolicyController getPolicyController() {
+ return policyController;
+ }
+ public void setPolicyController(PolicyController policyController) {
+ this.policyController = policyController;
+ }
+
+ private PolicyController getPolicyControllerInstance(){
+ return policyController != null ? getPolicyController() : new PolicyController();
+ }
@RequestMapping(value={"/get_DashboardLoggingData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getData(HttpServletRequest request, HttpServletResponse response){
@@ -141,7 +152,8 @@ public class DashboardController extends RestrictedBaseController{
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
- this.pdpConatiner = new PDPGroupContainer(PolicyController.getPapEngine());
+ PolicyController controller = getPolicyControllerInstance();
+ this.pdpConatiner = new PDPGroupContainer(controller.getPapEngine());
addPDPToTable();
model.put("pdpTableDatas", mapper.writeValueAsString(pdpStatusData));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -159,7 +171,8 @@ public class DashboardController extends RestrictedBaseController{
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
- this.pdpConatiner = new PDPGroupContainer(PolicyController.getPapEngine());
+ PolicyController controller = getPolicyControllerInstance();
+ this.pdpConatiner = new PDPGroupContainer(controller.getPapEngine());
addPolicyToTable();
model.put("policyActivityTableDatas", mapper.writeValueAsString(policyActivityData));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -178,7 +191,8 @@ public class DashboardController extends RestrictedBaseController{
papStatusData = new ArrayList<>();
String papStatus = null;
try {
- Set<EcompPDPGroup> groups = PolicyController.getPapEngine().getEcompPDPGroups();
+ PolicyController controller = getPolicyControllerInstance();
+ Set<EcompPDPGroup> groups = controller.getPapEngine().getEcompPDPGroups();
if (groups == null) {
papStatus = "UNKNOWN";
throw new PAPException("PAP not running");
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 80820c129..2e9771ec8 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
@@ -60,23 +60,37 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RequestMapping({"/"})
public class PDPController extends RestrictedBaseController {
private static final Logger logger = FlexLogger.getLogger(PDPController.class);
-
+
protected List<EcompPDPGroup> groups = Collections.synchronizedList(new ArrayList<EcompPDPGroup>());
private PDPGroupContainer container;
-
+
private static String SUPERADMIN = "super-admin";
private static String SUPEREDITOR = "super-editor";
private static String SUPERGUEST = "super-guest";
-
+
+ private Set<EcompPDPGroup> groupsData;
+
+ private boolean junit = false;
+
+ private PolicyController policyController;
+ public PolicyController getPolicyController() {
+ return policyController;
+ }
+
+ public void setPolicyController(PolicyController policyController) {
+ this.policyController = policyController;
+ }
+
public synchronized void refreshGroups(HttpServletRequest request) {
synchronized(this.groups) {
this.groups.clear();
try {
+ PolicyController controller = getPolicyControllerInstance();
Set<PDPPolicy> filteredPolicies = new HashSet<>();
Set<String> scopes = null;
List<String> roles = null;
- String userId = UserUtils.getUserSession(request).getOrgUserId();
- List<Object> userRoles = PolicyController.getRoles(userId);
+ String userId = isJunit() ? "Test" : UserUtils.getUserSession(request).getOrgUserId();
+ List<Object> userRoles = controller.getRoles(userId);
roles = new ArrayList<>();
scopes = new HashSet<>();
for(Object role: userRoles){
@@ -94,12 +108,16 @@ public class PDPController extends RestrictedBaseController {
}
}
if (roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST) ) {
- this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups());
+ if(!junit){
+ this.groups.addAll(controller.getPapEngine().getEcompPDPGroups());
+ }else{
+ this.groups.addAll(this.getGroupsData());
+ }
}else{
if(!userRoles.isEmpty()){
if(!scopes.isEmpty()){
- this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups());
- List<EcompPDPGroup> tempGroups = new ArrayList<EcompPDPGroup>();
+ this.groups.addAll(controller.getPapEngine().getEcompPDPGroups());
+ List<EcompPDPGroup> tempGroups = new ArrayList<>();
if(!groups.isEmpty()){
Iterator<EcompPDPGroup> pdpGroup = groups.iterator();
while(pdpGroup.hasNext()){
@@ -138,21 +156,7 @@ public class PDPController extends RestrictedBaseController {
}
}
}
-
- @RequestMapping(value={"/get_PDPGroupContainerData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
- public void getPDPGroupContainerData(HttpServletRequest request, HttpServletResponse response){
- try{
- ObjectMapper mapper = new ObjectMapper();
- refreshGroups(request);
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
- JSONObject j = new JSONObject(msg);
- response.getWriter().write(j.toString());
- }
- catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while retrieving the PDP Group Container data" + e);
- }
- }
-
+
@RequestMapping(value={"/get_PDPGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getPDPGroupEntityData(HttpServletRequest request, HttpServletResponse response){
try{
@@ -166,164 +170,188 @@ public class PDPController extends RestrictedBaseController {
logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while retrieving the PDP Group data" + e);
}
}
-
+
@RequestMapping(value={"/pdp_Group/save_pdp_group"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView savePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception{
- try {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
- this.container = new PDPGroupContainer(PolicyController.getPapEngine());
- StdPDPGroup pdpGroupData = mapper.readValue(root.get("pdpGroupData").toString().replace("groupName", "name"), StdPDPGroup.class);
- try {
- if(pdpGroupData.getId() == null){
- this.container.addNewGroup(pdpGroupData.getName(), pdpGroupData.getDescription());
- }else{
- this.container.updateGroup(pdpGroupData);
- }
-
+ public ModelAndView savePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ PolicyController controller = getPolicyControllerInstance();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ JsonNode root = mapper.readTree(request.getReader());
+ this.container = new PDPGroupContainer(controller.getPapEngine());
+ StdPDPGroup pdpGroupData = mapper.readValue(root.get("pdpGroupData").toString().replace("groupName", "name"), StdPDPGroup.class);
+ try {
+ if(pdpGroupData.getId() == null){
+ this.container.addNewGroup(pdpGroupData.getName(), pdpGroupData.getDescription());
+ }else{
+ this.container.updateGroup(pdpGroupData);
+ }
+
} catch (Exception e) {
String message = "Unable to create Group. Reason:\n" + e.getMessage();
logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while creating the PDP Group" + message);
}
-
-
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
-
- PrintWriter out = response.getWriter();
- refreshGroups(request);
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
- JSONObject j = new JSONObject(msg);
- out.write(j.toString());
-
- return null;
- }
- catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Saving the PDP Group" + e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(e.getMessage());
- }
- return null;
- }
-
- @RequestMapping(value={"/pdp_Group/remove_pdp_group"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
- try{
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
- this.container = new PDPGroupContainer(PolicyController.getPapEngine());
- StdPDPGroup pdpGroupData = mapper.readValue(root.get("pdpGroupData").toString(), StdPDPGroup.class);
- if(pdpGroupData.getName().equals("Default")) {
+
+
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application / json");
+ request.setCharacterEncoding("UTF-8");
+
+ PrintWriter out = response.getWriter();
+ refreshGroups(request);
+ JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
+ JSONObject j = new JSONObject(msg);
+ out.write(j.toString());
+
+ return null;
+ }
+ catch (Exception e){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Saving the PDP Group" + e);
+ response.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding("UTF-8");
+ PrintWriter out = response.getWriter();
+ out.write(e.getMessage());
+ }
+ return null;
+ }
+
+ @RequestMapping(value={"/pdp_Group/remove_pdp_group"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
+ public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ JsonNode root = mapper.readTree(request.getReader());
+ PolicyController controller = getPolicyControllerInstance();
+ this.container = new PDPGroupContainer(controller.getPapEngine());
+ StdPDPGroup pdpGroupData = mapper.readValue(root.get("pdpGroupData").toString(), StdPDPGroup.class);
+ if(pdpGroupData.getName().equals("Default")) {
throw new UnsupportedOperationException("You can't remove the Default Group.");
}else{
this.container.removeGroup(pdpGroupData, null);
}
-
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
-
- PrintWriter out = response.getWriter();
-
- refreshGroups(request);
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
- JSONObject j = new JSONObject(msg);
- out.write(j.toString());
-
- return null;
- }
- catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing the PDP Group" + e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(e.getMessage());
- }
- return null;
- }
-
- @RequestMapping(value={"/pdp_Group/save_pdpTogroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView savePDPToGroup(HttpServletRequest request, HttpServletResponse response) throws Exception{
- try {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
- this.container = new PDPGroupContainer(PolicyController.getPapEngine());
- String update = root.get("update").toString();
- PdpData pdpGroupData = (PdpData)mapper.readValue(root.get("pdpInGroup").toString(), PdpData.class);
- StdPDPGroup activeGroupData = mapper.readValue(root.get("activePDP").toString(), StdPDPGroup.class);
- try {
-
- if(update.contains("false")){
- this.container.addNewPDP(pdpGroupData.getId(), activeGroupData, pdpGroupData.getName(), pdpGroupData.getDescription(), pdpGroupData.getJmxPort());
- }else{
- this.container.updateGroup(activeGroupData);
- }
+
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application / json");
+ request.setCharacterEncoding("UTF-8");
+
+ PrintWriter out = response.getWriter();
+
+ refreshGroups(request);
+ JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
+ JSONObject j = new JSONObject(msg);
+ out.write(j.toString());
+
+ return null;
+ }
+ catch (Exception e){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing the PDP Group" + e);
+ response.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding("UTF-8");
+ PrintWriter out = response.getWriter();
+ out.write(e.getMessage());
+ }
+ return null;
+ }
+
+ @RequestMapping(value={"/pdp_Group/save_pdpTogroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
+ public ModelAndView savePDPToGroup(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ JsonNode root = mapper.readTree(request.getReader());
+ PolicyController controller = getPolicyControllerInstance();
+ this.container = new PDPGroupContainer(controller.getPapEngine());
+ String update = root.get("update").toString();
+ PdpData pdpGroupData = (PdpData)mapper.readValue(root.get("pdpInGroup").toString(), PdpData.class);
+ StdPDPGroup activeGroupData = mapper.readValue(root.get("activePDP").toString(), StdPDPGroup.class);
+ try {
+
+ if(update.contains("false")){
+ this.container.addNewPDP(pdpGroupData.getId(), activeGroupData, pdpGroupData.getName(), pdpGroupData.getDescription(), pdpGroupData.getJmxPort());
+ }else{
+ this.container.updateGroup(activeGroupData);
+ }
} catch (Exception e) {
String message = "Unable to create Group. Reason:\n" + e.getMessage();
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + message);
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + message);
}
-
-
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
-
- PrintWriter out = response.getWriter();
- refreshGroups(request);
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
- JSONObject j = new JSONObject(msg);
- out.write(j.toString());
-
- return null;
- }
- catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(e.getMessage());
- }
- return null;
- }
-
- @RequestMapping(value={"/pdp_Group/remove_pdpFromGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removePDPFromGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
- try{
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
- this.container = new PDPGroupContainer(PolicyController.getPapEngine());
- StdPDP deletePdp = mapper.readValue(root.get("data").toString(), StdPDP.class);
- StdPDPGroup activeGroupData = mapper.readValue(root.get("activePDP").toString(), StdPDPGroup.class);
-
- this.container.removePDP(deletePdp, activeGroupData);
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
-
- PrintWriter out = response.getWriter();
- refreshGroups(request);
- String responseString = mapper.writeValueAsString(groups);
- JSONObject j = new JSONObject("{pdpEntityDatas: " + responseString + "}");
- out.write(j.toString());
-
- return null;
- }
- catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing Pdp from PDP Group" + e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(e.getMessage());
- }
- return null;
- }
+
+
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application / json");
+ request.setCharacterEncoding("UTF-8");
+
+ PrintWriter out = response.getWriter();
+ refreshGroups(request);
+ JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
+ JSONObject j = new JSONObject(msg);
+ out.write(j.toString());
+
+ return null;
+ }
+ catch (Exception e){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + e);
+ response.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding("UTF-8");
+ PrintWriter out = response.getWriter();
+ out.write(e.getMessage());
+ }
+ return null;
+ }
+
+ @RequestMapping(value={"/pdp_Group/remove_pdpFromGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
+ public ModelAndView removePDPFromGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ JsonNode root = mapper.readTree(request.getReader());
+ PolicyController controller = getPolicyControllerInstance();
+ this.container = new PDPGroupContainer(controller.getPapEngine());
+ StdPDP deletePdp = mapper.readValue(root.get("data").toString(), StdPDP.class);
+ StdPDPGroup activeGroupData = mapper.readValue(root.get("activePDP").toString(), StdPDPGroup.class);
+
+ this.container.removePDP(deletePdp, activeGroupData);
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application / json");
+ request.setCharacterEncoding("UTF-8");
+
+ PrintWriter out = response.getWriter();
+ refreshGroups(request);
+ String responseString = mapper.writeValueAsString(groups);
+ JSONObject j = new JSONObject("{pdpEntityDatas: " + responseString + "}");
+ out.write(j.toString());
+
+ return null;
+ }
+ catch (Exception e){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing Pdp from PDP Group" + e);
+ response.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding("UTF-8");
+ PrintWriter out = response.getWriter();
+ out.write(e.getMessage());
+ }
+ return null;
+ }
+
+ private PolicyController getPolicyControllerInstance(){
+ return policyController != null ? getPolicyController() : new PolicyController();
+ }
+
+ public boolean isJunit() {
+ return junit;
+ }
+
+ public void setJunit(boolean junit) {
+ this.junit = junit;
+ }
+
+ public Set<EcompPDPGroup> getGroupsData() {
+ return groupsData;
+ }
+
+ public void setGroupsData(Set<EcompPDPGroup> groupsData) {
+ this.groupsData = groupsData;
+ }
}
class PdpData{
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 42e4483ca..f89687493 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
@@ -72,9 +72,10 @@ import org.openecomp.policy.common.logging.flexlogger.Logger;
@Controller
@RequestMapping("/")
public class PolicyController extends RestrictedBaseController {
- private static final Logger LOGGER = FlexLogger.getLogger(PolicyController.class);
+ private static final Logger policyLogger = FlexLogger.getLogger(PolicyController.class);
private static CommonClassDao commonClassDao;
+
// Our authorization object
//
XacmlAdminAuthorization authorizer = new XacmlAdminAuthorization();
@@ -83,8 +84,8 @@ public class PolicyController extends RestrictedBaseController {
//
private static PAPPolicyEngine papEngine;
- public static String logTableLimit;
- public static String systemAlertTableLimit;
+ private static String logTableLimit;
+ private static String systemAlertTableLimit;
protected static Map<String, String> dropDownMap = new HashMap<>();
public static Map<String, String> getDropDownMap() {
return dropDownMap;
@@ -102,42 +103,47 @@ public class PolicyController extends RestrictedBaseController {
private static Map<Datatype, List<FunctionDefinition>> mapDatatype2Function = null;
private static Map<String, FunctionDefinition> mapID2Function = null;
-
+ //Constant variables used across Policy-sdk
+ private static final String policyData = "policyData";
+ private static final String characterEncoding = "UTF-8";
+ private static final String contentType = "application/json";
+ private static final String file = "file";
+
//Smtp Java Mail Properties
- public static String smtpHost = null;
- public static String smtpPort = null;
- public static String smtpUsername = null;
- public static String smtpPassword = null;
- public static String smtpApplicationName = null;
- public static String smtpEmailExtension = null;
+ private static String smtpHost = null;
+ private static String smtpPort = null;
+ private static String smtpUsername = null;
+ private static String smtpPassword = null;
+ private static String smtpApplicationName = null;
+ private static String smtpEmailExtension = null;
//log db Properties
- public static String logdbDriver = null;
- public static String logdbUrl = null;
- public static String logdbUserName = null;
- public static String logdbPassword = null;
- public static String logdbDialect = null;
+ private static String logdbDriver = null;
+ private static String logdbUrl = null;
+ private static String logdbUserName = null;
+ private static String logdbPassword = null;
+ private static String logdbDialect = null;
//Xacml db properties
- public static String xacmldbUrl = null;
- public static String xacmldbUserName = null;
- public static String xacmldbPassword = null;
+ private static String xacmldbUrl = null;
+ private static String xacmldbUserName = null;
+ private static String xacmldbPassword = null;
//AutoPush feature.
- public static String autoPushAvailable;
- public static String autoPushDSClosedLoop;
- public static String autoPushDSFirewall;
- public static String autoPushDSMicroservice;
- public static String autoPushPDPGroup;
+ private static String autoPushAvailable;
+ private static String autoPushDSClosedLoop;
+ private static String autoPushDSFirewall;
+ private static String autoPushDSMicroservice;
+ private static String autoPushPDPGroup;
//papURL
- public static String papUrl;
+ private static String papUrl;
//MicroService Model Properties
- public static String msEcompName;
- public static String msPolicyName;
+ private static String msEcompName;
+ private static String msPolicyName;
//WebApp directories
- public static String configHome;
- public static String actionHome;
+ private static String configHome;
+ private static String actionHome;
@Autowired
private PolicyController(CommonClassDao commonClassDao){
@@ -156,54 +162,54 @@ public class PolicyController extends RestrictedBaseController {
// load a properties file
prop.load(input);
//pap url
- papUrl = prop.getProperty("xacml.rest.pap.url");
+ setPapUrl(prop.getProperty("xacml.rest.pap.url"));
// get the property values
- smtpHost = prop.getProperty("ecomp.smtp.host");
- smtpPort = prop.getProperty("ecomp.smtp.port");
- smtpUsername = prop.getProperty("ecomp.smtp.userName");
- smtpPassword = prop.getProperty("ecomp.smtp.password");
- smtpApplicationName = prop.getProperty("ecomp.application.name");
- smtpEmailExtension = prop.getProperty("ecomp.smtp.emailExtension");
+ setSmtpHost(prop.getProperty("ecomp.smtp.host"));
+ setSmtpPort(prop.getProperty("ecomp.smtp.port"));
+ setSmtpUsername(prop.getProperty("ecomp.smtp.userName"));
+ setSmtpPassword(prop.getProperty("ecomp.smtp.password"));
+ setSmtpApplicationName(prop.getProperty("ecomp.application.name"));
+ setSmtpEmailExtension(prop.getProperty("ecomp.smtp.emailExtension"));
//Log Database Properties
- logdbDriver = prop.getProperty("xacml.log.db.driver");
- logdbUrl = prop.getProperty("xacml.log.db.url");
- logdbUserName = prop.getProperty("xacml.log.db.user");
- logdbPassword = prop.getProperty("xacml.log.db.password");
- logdbDialect = prop.getProperty("ecomp.dialect");
+ setLogdbDriver(prop.getProperty("xacml.log.db.driver"));
+ setLogdbUrl(prop.getProperty("xacml.log.db.url"));
+ setLogdbUserName(prop.getProperty("xacml.log.db.user"));
+ setLogdbPassword(prop.getProperty("xacml.log.db.password"));
+ setLogdbDialect(prop.getProperty("ecomp.dialect"));
//Xacml Database Properties
- xacmldbUrl = prop.getProperty("javax.persistence.jdbc.url");
- xacmldbUserName = prop.getProperty("javax.persistence.jdbc.user");
- xacmldbPassword = prop.getProperty("javax.persistence.jdbc.password");
+ setXacmldbUrl(prop.getProperty("javax.persistence.jdbc.url"));
+ setXacmldbUserName(prop.getProperty("javax.persistence.jdbc.user"));
+ setXacmldbPassword(prop.getProperty("javax.persistence.jdbc.password"));
//AutoPuh
- autoPushAvailable=prop.getProperty("xacml.automatic.push");
- autoPushDSClosedLoop=prop.getProperty("xacml.autopush.closedloop");
- autoPushDSFirewall=prop.getProperty("xacml.autopush.firewall");
- autoPushDSMicroservice=prop.getProperty("xacml.autopush.microservice");
- autoPushPDPGroup=prop.getProperty("xacml.autopush.pdpGroup");
+ setAutoPushAvailable(prop.getProperty("xacml.automatic.push"));
+ setAutoPushDSClosedLoop(prop.getProperty("xacml.autopush.closedloop"));
+ setAutoPushDSFirewall(prop.getProperty("xacml.autopush.firewall"));
+ setAutoPushDSMicroservice(prop.getProperty("xacml.autopush.microservice"));
+ setAutoPushPDPGroup(prop.getProperty("xacml.autopush.pdpGroup"));
//Micro Service Properties
- msEcompName=prop.getProperty("xacml.policy.msEcompName");
- msPolicyName=prop.getProperty("xacml.policy.msPolicyName");
+ setMsEcompName(prop.getProperty("xacml.policy.msEcompName"));
+ setMsPolicyName(prop.getProperty("xacml.policy.msPolicyName"));
//WebApp directories
- configHome = prop.getProperty("xacml.rest.config.webapps") + "Config";
- actionHome = prop.getProperty("xacml.rest.config.webapps") + "Action";
+ setConfigHome(prop.getProperty("xacml.rest.config.webapps") + "Config");
+ setActionHome(prop.getProperty("xacml.rest.config.webapps") + "Action");
//Get the Property Values for Dashboard tab Limit
try{
- logTableLimit = prop.getProperty("xacml.ecomp.dashboard.logTableLimit");
- systemAlertTableLimit = prop.getProperty("xacml.ecomp.dashboard.systemAlertTableLimit");
+ setLogTableLimit(prop.getProperty("xacml.ecomp.dashboard.logTableLimit"));
+ setSystemAlertTableLimit(prop.getProperty("xacml.ecomp.dashboard.systemAlertTableLimit"));
}catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Dashboard tab Property fields are missing" +e);
- logTableLimit = "5000";
- systemAlertTableLimit = "2000";
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Dashboard tab Property fields are missing" +e);
+ setLogTableLimit("5000");
+ setSystemAlertTableLimit("2000");
}
System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.admin.properties");
} catch (IOException ex) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured while reading the Smtp properties from xacml.admin.properties file" +ex);
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured while reading the Smtp properties from xacml.admin.properties file" +ex);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured while Closing the xacml.admin.properties file" +e);
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured while Closing the xacml.admin.properties file" +e);
}
}
}
@@ -211,7 +217,7 @@ public class PolicyController extends RestrictedBaseController {
//Initialize the FunctionDefinition table at Server Start up
Map<Datatype, List<FunctionDefinition>> functionMap = getFunctionDatatypeMap();
for (Datatype id : functionMap.keySet()) {
- List<FunctionDefinition> functionDefinations = (List<FunctionDefinition>) functionMap.get(id);
+ List<FunctionDefinition> functionDefinations = functionMap.get(id);
for (FunctionDefinition functionDef : functionDefinations) {
dropDownMap.put(functionDef.getShortname(),functionDef.getXacmlid());
}
@@ -244,7 +250,7 @@ public class PolicyController extends RestrictedBaseController {
for (int i = 0; i < functiondefinitions.size(); i ++) {
FunctionDefinition value = (FunctionDefinition) functiondefinitions.get(i);
mapID2Function.put(value.getXacmlid(), value);
- if (mapDatatype2Function.containsKey(value.getDatatypeBean()) == false) {
+ if (!mapDatatype2Function.containsKey(value.getDatatypeBean())) {
mapDatatype2Function.put(value.getDatatypeBean(), new ArrayList<FunctionDefinition>());
}
mapDatatype2Function.get(value.getDatatypeBean()).add(value);
@@ -262,21 +268,20 @@ public class PolicyController extends RestrictedBaseController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- LOGGER.equals(XACMLErrorConstants.ERROR_DATA_ISSUE +"Error while retriving the Function Definition data"+e);
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE +"Error while retriving the Function Definition data"+e);
}
}
public PolicyEntity getPolicyEntityData(String scope, String policyName){
String key = scope + ":" + policyName;
List<Object> data = commonClassDao.getDataById(PolicyEntity.class, "scope:policyName", key);
- PolicyEntity entity = (PolicyEntity) data.get(0);
- return entity;
+ return (PolicyEntity) data.get(0);
}
public static Map<String, Roles> getUserRoles(String userId) {
Map<String, Roles> scopes = new HashMap<>();
List<Object> roles = commonClassDao.getDataById(Roles.class, "loginId", userId);
- if (roles != null && roles.size() > 0) {
+ if (roles != null && !roles.isEmpty()) {
for (Object role : roles) {
scopes.put(((Roles) role).getScope(), (Roles) role);
}
@@ -284,8 +289,8 @@ public class PolicyController extends RestrictedBaseController {
return scopes;
}
- public static List<String> getRolesOfUser(String userId) {
- List<String> rolesList = new ArrayList<String>();
+ public List<String> getRolesOfUser(String userId) {
+ List<String> rolesList = new ArrayList<>();
List<Object> roles = commonClassDao.getDataById(Roles.class, "loginId", userId);
for (Object role: roles) {
rolesList.add(((Roles) role).getRole());
@@ -293,7 +298,7 @@ public class PolicyController extends RestrictedBaseController {
return rolesList;
}
- public static List<Object> getRoles(String userId) {
+ public List<Object> getRoles(String userId) {
return commonClassDao.getDataById(Roles.class, "loginId", userId);
}
@@ -310,7 +315,7 @@ public class PolicyController extends RestrictedBaseController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- LOGGER.error("Exception Occured"+e);
+ policyLogger.error("Exception Occured"+e);
}
}
@@ -325,13 +330,13 @@ public class PolicyController extends RestrictedBaseController {
setPapEngine((PAPPolicyEngine) new RESTfulPAPEngine(myRequestURL));
new PDPGroupContainer((PAPPolicyEngine) new RESTfulPAPEngine(myRequestURL));
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Exception Occured while loading PAP"+e);
+ policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Exception Occured while loading PAP"+e);
}
Map<String, Object> model = new HashMap<>();
return new ModelAndView("policy_Editor","model", model);
}
- public static PAPPolicyEngine getPapEngine() {
+ public PAPPolicyEngine getPapEngine() {
return papEngine;
}
@@ -374,8 +379,7 @@ public class PolicyController extends RestrictedBaseController {
}
public PolicyVersion getPolicyEntityFromPolicyVersion(String query){
- PolicyVersion policyVersionEntity = (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", query);
- return policyVersionEntity;
+ return (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", query);
}
public List<Object> getDataByQuery(String query){
@@ -394,7 +398,7 @@ public class PolicyController extends RestrictedBaseController {
try {
email.sendMail(entity, policyName, mode, commonClassDao);
} catch (MessagingException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Excepton Occured while Renaming/Deleting a Policy or Scope" + e);
+ policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Excepton Occured while Renaming/Deleting a Policy or Scope" + e);
}
}
@@ -428,5 +432,265 @@ public class PolicyController extends RestrictedBaseController {
el.put("highestVersion", entity.getHigherVersion());
return el;
}
+
+ public static String getLogTableLimit() {
+ return logTableLimit;
+ }
+
+ public static void setLogTableLimit(String logTableLimit) {
+ PolicyController.logTableLimit = logTableLimit;
+ }
+
+ public static String getSystemAlertTableLimit() {
+ return systemAlertTableLimit;
+ }
+
+ public static void setSystemAlertTableLimit(String systemAlertTableLimit) {
+ PolicyController.systemAlertTableLimit = systemAlertTableLimit;
+ }
+
+ public static CommonClassDao getCommonClassDao() {
+ return commonClassDao;
+ }
+
+ public static void setCommonClassDao(CommonClassDao commonClassDao) {
+ PolicyController.commonClassDao = commonClassDao;
+ }
+
+ public XacmlAdminAuthorization getAuthorizer() {
+ return authorizer;
+ }
+
+ public void setAuthorizer(XacmlAdminAuthorization authorizer) {
+ this.authorizer = authorizer;
+ }
+
+ public static Map<Datatype, List<FunctionDefinition>> getMapDatatype2Function() {
+ return mapDatatype2Function;
+ }
+
+ public static void setMapDatatype2Function(Map<Datatype, List<FunctionDefinition>> mapDatatype2Function) {
+ PolicyController.mapDatatype2Function = mapDatatype2Function;
+ }
+
+ public static Map<String, FunctionDefinition> getMapID2Function() {
+ return mapID2Function;
+ }
+
+ public static void setMapID2Function(Map<String, FunctionDefinition> mapID2Function) {
+ PolicyController.mapID2Function = mapID2Function;
+ }
+
+ public static String getSmtpHost() {
+ return smtpHost;
+ }
+
+ public static void setSmtpHost(String smtpHost) {
+ PolicyController.smtpHost = smtpHost;
+ }
+
+ public static String getSmtpPort() {
+ return smtpPort;
+ }
+
+ public static void setSmtpPort(String smtpPort) {
+ PolicyController.smtpPort = smtpPort;
+ }
+
+ public static String getSmtpUsername() {
+ return smtpUsername;
+ }
+
+ public static void setSmtpUsername(String smtpUsername) {
+ PolicyController.smtpUsername = smtpUsername;
+ }
+
+ public static String getSmtpPassword() {
+ return smtpPassword;
+ }
+
+ public static void setSmtpPassword(String smtpPassword) {
+ PolicyController.smtpPassword = smtpPassword;
+ }
+
+ public static String getSmtpApplicationName() {
+ return smtpApplicationName;
+ }
+
+ public static void setSmtpApplicationName(String smtpApplicationName) {
+ PolicyController.smtpApplicationName = smtpApplicationName;
+ }
+
+ public static String getSmtpEmailExtension() {
+ return smtpEmailExtension;
+ }
+
+ public static void setSmtpEmailExtension(String smtpEmailExtension) {
+ PolicyController.smtpEmailExtension = smtpEmailExtension;
+ }
+
+ public static String getLogdbDriver() {
+ return logdbDriver;
+ }
+
+ public static void setLogdbDriver(String logdbDriver) {
+ PolicyController.logdbDriver = logdbDriver;
+ }
+
+ public static String getLogdbUrl() {
+ return logdbUrl;
+ }
+
+ public static void setLogdbUrl(String logdbUrl) {
+ PolicyController.logdbUrl = logdbUrl;
+ }
+
+ public static String getLogdbUserName() {
+ return logdbUserName;
+ }
+
+ public static void setLogdbUserName(String logdbUserName) {
+ PolicyController.logdbUserName = logdbUserName;
+ }
+
+ public static String getLogdbPassword() {
+ return logdbPassword;
+ }
+
+ public static void setLogdbPassword(String logdbPassword) {
+ PolicyController.logdbPassword = logdbPassword;
+ }
+
+ public static String getLogdbDialect() {
+ return logdbDialect;
+ }
+
+ public static void setLogdbDialect(String logdbDialect) {
+ PolicyController.logdbDialect = logdbDialect;
+ }
+
+ public static String getXacmldbUrl() {
+ return xacmldbUrl;
+ }
+
+ public static void setXacmldbUrl(String xacmldbUrl) {
+ PolicyController.xacmldbUrl = xacmldbUrl;
+ }
+
+ public static String getXacmldbUserName() {
+ return xacmldbUserName;
+ }
+
+ public static void setXacmldbUserName(String xacmldbUserName) {
+ PolicyController.xacmldbUserName = xacmldbUserName;
+ }
+
+ public static String getXacmldbPassword() {
+ return xacmldbPassword;
+ }
+
+ public static void setXacmldbPassword(String xacmldbPassword) {
+ PolicyController.xacmldbPassword = xacmldbPassword;
+ }
+
+ public static String getAutoPushAvailable() {
+ return autoPushAvailable;
+ }
+
+ public static void setAutoPushAvailable(String autoPushAvailable) {
+ PolicyController.autoPushAvailable = autoPushAvailable;
+ }
+
+ public static String getAutoPushDSClosedLoop() {
+ return autoPushDSClosedLoop;
+ }
+
+ public static void setAutoPushDSClosedLoop(String autoPushDSClosedLoop) {
+ PolicyController.autoPushDSClosedLoop = autoPushDSClosedLoop;
+ }
+
+ public static String getAutoPushDSFirewall() {
+ return autoPushDSFirewall;
+ }
+
+ public static void setAutoPushDSFirewall(String autoPushDSFirewall) {
+ PolicyController.autoPushDSFirewall = autoPushDSFirewall;
+ }
+
+ public static String getAutoPushDSMicroservice() {
+ return autoPushDSMicroservice;
+ }
+
+ public static void setAutoPushDSMicroservice(String autoPushDSMicroservice) {
+ PolicyController.autoPushDSMicroservice = autoPushDSMicroservice;
+ }
+
+ public static String getAutoPushPDPGroup() {
+ return autoPushPDPGroup;
+ }
+
+ public static void setAutoPushPDPGroup(String autoPushPDPGroup) {
+ PolicyController.autoPushPDPGroup = autoPushPDPGroup;
+ }
+
+ public static String getPapUrl() {
+ return papUrl;
+ }
+
+ public static void setPapUrl(String papUrl) {
+ PolicyController.papUrl = papUrl;
+ }
+
+ public static String getMsEcompName() {
+ return msEcompName;
+ }
+
+ public static void setMsEcompName(String msEcompName) {
+ PolicyController.msEcompName = msEcompName;
+ }
+
+ public static String getMsPolicyName() {
+ return msPolicyName;
+ }
+
+ public static void setMsPolicyName(String msPolicyName) {
+ PolicyController.msPolicyName = msPolicyName;
+ }
+
+ public static String getConfigHome() {
+ return configHome;
+ }
+
+ public static void setConfigHome(String configHome) {
+ PolicyController.configHome = configHome;
+ }
+
+ public static String getActionHome() {
+ return actionHome;
+ }
+
+ public static void setActionHome(String actionHome) {
+ PolicyController.actionHome = actionHome;
+ }
+
+ public static Object getMapaccess() {
+ return mapAccess;
+ }
+
+ public static String getPolicydata() {
+ return policyData;
+ }
+
+ public static String getCharacterencoding() {
+ return characterEncoding;
+ }
+
+ public static String getContenttype() {
+ return contentType;
+ }
+
+ public static String getFile() {
+ return file;
+ }
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java
index 68a65fc5e..bf2a148e6 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java
@@ -89,6 +89,15 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
private Workbook workbook;
private HSSFWorkbook workBook2;
+
+ private PolicyController policyController;
+ public PolicyController getPolicyController() {
+ return policyController;
+ }
+
+ public void setPolicyController(PolicyController policyController) {
+ this.policyController = policyController;
+ }
@Autowired
private PolicyExportAndImportController(CommonClassDao commonClassDao){
@@ -190,12 +199,12 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
String configName = null;
String scope = null;
boolean finalColumn = false;
- PolicyController controller = new PolicyController();
+ PolicyController controller = policyController != null ? getPolicyController() : new PolicyController();
String userId = UserUtils.getUserSession(request).getOrgUserId();
UserInfo userInfo = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", userId);
//Check if the Role and Scope Size are Null get the values from db.
- List<Object> userRoles = PolicyController.getRoles(userId);
+ List<Object> userRoles = controller.getRoles(userId);
roles = new ArrayList<>();
scopes = new HashSet<>();
for(Object role: userRoles){