summaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller
diff options
context:
space:
mode:
authorRavindra Bakkamanthala <rb7147@att.com>2017-05-23 14:56:12 -0400
committerRavindra Bakkamanthala <rb7147@att.com>2017-05-23 16:49:56 -0400
commit87c95be02a8a4d77e165dede90777e811b59dcae (patch)
tree4712199fc3520b530dda0c4d3b074c327df547f2 /POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller
parent7e547eaa55920dfbc9691eab33bb728395b50cf2 (diff)
Commit includes ControlLoopPolicy API and bugfixes
Change-Id: I3e18bb8b4c31a0d908bb0cff4c85e2a3fb450a63 Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
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/ActionPolicyController.java10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java16
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java341
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java103
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java16
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java14
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java20
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java23
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java6
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java6
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java20
16 files changed, 302 insertions, 295 deletions
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 b0bbaf9cf..2c68df65f 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
@@ -63,12 +63,12 @@ public class ActionPolicyController extends RestrictedBaseController{
private ArrayList<Object> attributeList;
protected LinkedList<Integer> ruleAlgoirthmTracker;
public static final String PERFORMER_ATTRIBUTEID = "performer";
- protected Map<String, String> performer = new HashMap<String, String>();
+ protected Map<String, String> performer = new HashMap<>();
private ArrayList<Object> ruleAlgorithmList;
public void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- attributeList = new ArrayList<Object>();
- ruleAlgorithmList = new ArrayList<Object>();
+ attributeList = new ArrayList<>();
+ ruleAlgorithmList = new ArrayList<>();
performer.put("PDP", "PDPAction");
performer.put("PEP", "PEPAction");
@@ -116,7 +116,7 @@ public class ActionPolicyController extends RestrictedBaseController{
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 component at index 0.
- Map<String, String> attribute = new HashMap<String, String>();
+ Map<String, String> attribute = new HashMap<>();
attribute.put("key", attributeId);
attribute.put("value", value);
attributeList.add(attribute);
@@ -137,7 +137,7 @@ public class ActionPolicyController extends RestrictedBaseController{
if (condition != null) {
int index = 0;
ApplyType actionApply = (ApplyType) condition.getExpression().getValue();
- ruleAlgoirthmTracker = new LinkedList<Integer>();
+ ruleAlgoirthmTracker = new LinkedList<>();
// Populating Rule Algorithms starting from compound.
prePopulateCompoundRuleAlgorithm(index, actionApply);
}
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 46fb2bbfe..6824101df 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
@@ -57,7 +57,7 @@ public class AdminTabController extends RestrictedBaseController{
@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{
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
model.put("lockdowndata", mapper.writeValueAsString(commonClassDao.getData(GlobalRoleSettings.class)));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
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 8751d735c..17e8f89f2 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
@@ -108,11 +108,11 @@ public class AutoPushController extends RestrictedBaseController{
List<String> roles = null;
data = new ArrayList<Object>();
String userId = UserUtils.getUserSession(request).getOrgUserId();
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
List<Object> userRoles = PolicyController.getRoles(userId);
- roles = new ArrayList<String>();
- scopes = new HashSet<String>();
+ roles = new ArrayList<>();
+ scopes = new HashSet<>();
for(Object role: userRoles){
Roles userRole = (Roles) role;
roles.add(userRole.getRole());
@@ -161,8 +161,8 @@ public class AutoPushController extends RestrictedBaseController{
@RequestMapping(value={"/auto_Push/PushPolicyToPDP.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public ModelAndView PushPolicyToPDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
- ArrayList<Object> selectedPDPS = new ArrayList<Object>();
- ArrayList<String> selectedPoliciesInUI = new ArrayList<String>();
+ ArrayList<Object> selectedPDPS = new ArrayList<>();
+ ArrayList<String> selectedPoliciesInUI = new ArrayList<>();
this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups());
ObjectMapper mapper = new ObjectMapper();
this.container = new PDPGroupContainer(PolicyController.getPapEngine());
@@ -185,8 +185,8 @@ public class AutoPushController extends RestrictedBaseController{
}
for (Object pdpDestinationGroupId : selectedPDPS) {
- Set<PDPPolicy> currentPoliciesInGroup = new HashSet<PDPPolicy>();
- Set<PDPPolicy> selectedPolicies = new HashSet<PDPPolicy>();
+ Set<PDPPolicy> currentPoliciesInGroup = new HashSet<>();
+ Set<PDPPolicy> selectedPolicies = new HashSet<>();
for (String policyId : selectedPoliciesInUI) {
logger.debug("Handlepolicies..." + pdpDestinationGroupId + policyId);
@@ -329,7 +329,7 @@ public class AutoPushController extends RestrictedBaseController{
String data = removePolicyData.get(i).toString();
AutoPushController.policyContainer.removeItem(data);
}
- Set<PDPPolicy> changedPolicies = new HashSet<PDPPolicy>();
+ Set<PDPPolicy> changedPolicies = new HashSet<>();
changedPolicies.addAll((Collection<PDPPolicy>) AutoPushController.policyContainer.getItemIds());
StdPDPGroup updatedGroupObject = new StdPDPGroup(group.getId(), group.isDefaultGroup(), group.getName(), group.getDescription(),null);
updatedGroupObject.setPolicies(changedPolicies);
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 265b7b7b2..daab6e378 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
@@ -88,7 +88,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
@RequestMapping(value={"/policyController/getBRMSTemplateData.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public ModelAndView getBRMSParamPolicyRuleData(HttpServletRequest request, HttpServletResponse response) throws Exception{
- dynamicLayoutMap = new HashMap<String, String>();
+ dynamicLayoutMap = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
@@ -211,8 +211,8 @@ public class CreateBRMSParamController extends RestrictedBaseController {
@SuppressWarnings("unchecked")
public void prePopulateBRMSParamPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- attributeList = new ArrayList<Object>();
- dynamicLayoutMap = new HashMap<String, String>();
+ attributeList = new ArrayList<>();
+ dynamicLayoutMap = new HashMap<>();
if (policyAdapter.getPolicyData() instanceof PolicyType) {
PolicyType policy = (PolicyType) policyAdapter.getPolicyData();
policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
@@ -235,7 +235,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
for( AdviceExpressionType adviceExpression: expressionTypes.getAdviceExpression()){
for(AttributeAssignmentExpressionType attributeAssignment: adviceExpression.getAttributeAssignmentExpression()){
if(attributeAssignment.getAttributeId().startsWith("key:")){
- Map<String, String> attribute = new HashMap<String, String>();
+ Map<String, String> attribute = new HashMap<>();
String key = attributeAssignment.getAttributeId().replace("key:", "");
attribute.put("key", key);
JAXBElement<AttributeValueType> attributevalue = (JAXBElement<AttributeValueType>) attributeAssignment.getExpression();
@@ -258,7 +258,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
// Get the target data under policy.
policyAdapter.setDynamicLayoutMap(dynamicLayoutMap);
if(policyAdapter.getDynamicLayoutMap().size() > 0){
- LinkedHashMap<String,String> drlRule = new LinkedHashMap<String, String>();
+ LinkedHashMap<String,String> drlRule = new LinkedHashMap<>();
for(Object keyValue: policyAdapter.getDynamicLayoutMap().keySet()){
drlRule.put(keyValue.toString(), policyAdapter.getDynamicLayoutMap().get(keyValue).toString());
}
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 b31f70297..67945e1b9 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
@@ -80,7 +80,7 @@ public class CreateBRMSRawController{
for( AdviceExpressionType adviceExpression: expressionTypes.getAdviceExpression()){
for(AttributeAssignmentExpressionType attributeAssignment: adviceExpression.getAttributeAssignmentExpression()){
if(attributeAssignment.getAttributeId().startsWith("key:")){
- Map<String, String> attribute = new HashMap<String, String>();
+ Map<String, String> attribute = new HashMap<>();
String key = attributeAssignment.getAttributeId().replace("key:", "");
attribute.put("key", key);
JAXBElement<AttributeValueType> attributevalue = (JAXBElement<AttributeValueType>) attributeAssignment.getExpression();
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 d2a2845e8..ccecf5d7f 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
@@ -83,11 +83,11 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
ClosedLoopGridJSONData policyJsonData = mapper.readValue(root.get("policyData").get("policy").toString(), ClosedLoopGridJSONData.class);
ClosedLoopFaultBody jsonBody = mapper.readValue(root.get("policyData").get("policy").get("jsonBodyData").toString(), ClosedLoopFaultBody.class);
- ArrayList<Object> trapSignatureDatas = new ArrayList<Object>();
+ ArrayList<Object> trapSignatureDatas = new ArrayList<>();
if(trapDatas.getTrap1() != null){
trapSignatureDatas.add(trapDatas);
}
- ArrayList<Object> faultSignatureDatas = new ArrayList<Object>();
+ ArrayList<Object> faultSignatureDatas = new ArrayList<>();
if(faultDatas.getTrap1() != null){
faultSignatureDatas.add(faultDatas);
}
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 ce6531f38..c3daf6d94 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
@@ -101,23 +101,23 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
@Controller
@RequestMapping("/")
public class CreateDcaeMicroServiceController extends RestrictedBaseController {
- private static final Logger logger = FlexLogger.getLogger(CreateDcaeMicroServiceController.class);
+ private static final Logger LOGGER = FlexLogger.getLogger(CreateDcaeMicroServiceController.class);
private static CommonClassDao commonClassDao;
private MicroServiceModels newModel;
private String newFile;
private String directory;
- private List<String> modelList = new ArrayList<String>();
- private List<String> dirDependencyList = new ArrayList<String>();
- private HashMap<String,MSAttributeObject > classMap = new HashMap<String,MSAttributeObject>();
+ private List<String> modelList = new ArrayList<>();
+ private List<String> dirDependencyList = new ArrayList<>();
+ private HashMap<String,MSAttributeObject > classMap = new HashMap<>();
//Tosca Model related Datastructure.
String referenceAttributes;
String attributeString;
String listConstraints;
String subAttributeString;
- HashMap<String, Object> retmap = new HashMap<String, Object>();
- Set<String> uniqueKeys= new HashSet<String>();
- Set<String> uniqueDataKeys= new HashSet<String>();
+ HashMap<String, Object> retmap = new HashMap<>();
+ Set<String> uniqueKeys= new HashSet<>();
+ Set<String> uniqueDataKeys= new HashSet<>();
@Autowired
private CreateDcaeMicroServiceController(CommonClassDao commonClassDao){
@@ -128,8 +128,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
protected PolicyRestAdapter policyAdapter = null;
private int priorityCount;
- private Map<String, String> attributesListRefMap = new HashMap<String, String>();
- private Map<String, LinkedList<String>> arrayTextList = new HashMap<String, LinkedList<String>>();
+ private Map<String, String> attributesListRefMap = new HashMap<>();
+ private Map<String, LinkedList<String>> arrayTextList = new HashMap<>();
public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) {
@@ -138,7 +138,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
jsonContent = decodeContent(root.get("policyJSON")).toString();
constructJson(policyData, jsonContent);
}catch(Exception e){
- logger.error("Error while decoding microservice content");
+ LOGGER.error("Error while decoding microservice content");
}
return policyData;
@@ -202,9 +202,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
try {
json = om.writeValueAsString(microServiceObject);
} catch (JsonProcessingException e) {
- logger.error("Error writing out the object");
+ LOGGER.error("Error writing out the object");
}
- logger.info(json);
+ LOGGER.info(json);
String cleanJson = cleanUPJson(json);
cleanJson = removeNullAttributes(cleanJson);
policyAdapter.setJsonBody(cleanJson);
@@ -232,7 +232,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
cleanJson = returnNode.toString();
}
} catch (IOException e) {
- logger.error("Error writing out the JsonNode");
+ LOGGER.error("Error writing out the JsonNode");
}
return cleanJson;
}
@@ -268,14 +268,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
try {
is = new FileInputStream(newConfiguration);
} catch (FileNotFoundException e) {
- logger.error(e);
+ LOGGER.error(e);
}
Yaml yaml = new Yaml();
@SuppressWarnings("unchecked")
Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(is);
StringBuilder sb = new StringBuilder();
- Map<String, String> settings = new HashMap<String, String>();
+ Map<String, String> settings = new HashMap<>();
if (yamlMap == null) {
return settings;
}
@@ -348,12 +348,11 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
public void parseTosca (String fileName){
- Map<String,String> map= new HashMap<String, String>();
+ Map<String,String> map= new HashMap<>();
try {
map=load(fileName);
for(String key:map.keySet()){
- if(key.contains("policy.nodes.Root"))
- {
+ if(key.contains("policy.nodes.Root")){
continue;
}
else if(key.contains("policy.nodes")){
@@ -369,21 +368,11 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
String subNodeString= key.substring(indexForPolicyNode+12, key.length());
stringBetweenDotsForDataFields(subNodeString,map.get(key));
- Iterator<String> itr= uniqueDataKeys.iterator();
- while(itr.hasNext()){
- logger.info(itr.next());
- }
}
}
- String attributeIndividualString="";
String userDefinedIndividualString="";
- String referenceIndividualAttributes="";
-
- String attributeString="";
String userDefinedString="";
- String referenceAttributes="";
- String listConstraints="";
for(String uniqueDataKey: uniqueDataKeys){
String[] uniqueDataKeySplit= uniqueDataKey.split("%");
@@ -405,7 +394,6 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
}
}
-
}
if(userDefinedString!=""){
userDefinedString=userDefinedString+","+userDefinedIndividualString;
@@ -414,9 +402,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
userDefinedIndividualString="";
}
- logger.info("userDefinedString :"+userDefinedString);
+ LOGGER.info("userDefinedString :"+userDefinedString);
- HashMap<String,ArrayList<String>> mapKey= new HashMap<String,ArrayList<String>>();
+ HashMap<String,ArrayList<String>> mapKeyUserdefined= new HashMap<>();
String secondPartString="";
String firstPartString="";
for(String value: userDefinedString.split(",")){
@@ -424,30 +412,27 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
secondPartString=splitWithEquals[0].substring(splitWithEquals[0].indexOf("%")+1);
firstPartString=splitWithEquals[0].substring(0, splitWithEquals[0].indexOf("%"));
ArrayList<String> list;
- if(mapKey.containsKey(firstPartString)){
- list = mapKey.get(firstPartString);
+ if(mapKeyUserdefined.containsKey(firstPartString)){
+ list = mapKeyUserdefined.get(firstPartString);
list.add(secondPartString+"<"+splitWithEquals[1]);
} else {
list = new ArrayList<String>();
list.add(secondPartString+"<"+splitWithEquals[1]);
- mapKey.put(firstPartString, list);
+ mapKeyUserdefined.put(firstPartString, list);
}
}
JSONObject mainObject= new JSONObject();;
JSONObject json;
- for(String s: mapKey.keySet()){
+ for(String s: mapKeyUserdefined.keySet()){
json= new JSONObject();
- List<String> value=mapKey.get(s);
+ List<String> value=mapKeyUserdefined.get(s);
for(String listValue:value){
String[] splitValue=listValue.split("<");
json.put(splitValue[0], splitValue[1]);
}
mainObject.put(s,json);
}
-
- logger.info(mainObject);
-
Iterator<String> keysItr = mainObject.keys();
while(keysItr.hasNext()) {
String key = keysItr.next();
@@ -455,138 +440,116 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
retmap.put(key, value);
}
- for(String str:retmap.keySet()){
- logger.info(str+":"+retmap.get(str));
- }
+ LOGGER.info("#############################################################################");
+ LOGGER.info(mainObject);
+ LOGGER.info("###############################################################################");
- String typeValueFromKey="";
- boolean userDefinedDataType=false;
- boolean isList=false;
+ HashMap<String,HashMap<String,String>> mapKey= new HashMap<>();
for(String uniqueKey: uniqueKeys){
- List<String> constraints= new ArrayList<String>();
- logger.info("====================");
- attributeIndividualString=attributeIndividualString+uniqueKey+"=";
- attributeIndividualString=attributeIndividualString+"#A:defaultValue-#B:required-#C:MANY-false";
+ HashMap<String,String> hm;
- logger.info("UniqueStrings: "+uniqueKey);
for(String key:map.keySet()){
- if(key.contains("policy.nodes.Root")||
- key.contains("policy.data"))
- {
- continue;
- }
- else if(key.contains("policy.nodes")){
- if(key.contains(uniqueKey)){
- int p=key.lastIndexOf(".");
- String firstLastOccurance=key.substring(0,p);
- int p1=firstLastOccurance.lastIndexOf(".");
- String secondLastOccurance= firstLastOccurance.substring(p1+1,firstLastOccurance.length());
- if(secondLastOccurance.equals(uniqueKey)){
- String checkTypeString= firstLastOccurance+".type";
- typeValueFromKey= map.get(checkTypeString);
- }//Its a list.
- else if (key.contains("entry_schema")){
- if(key.contains("constraints")){
- constraints.add(map.get(key));
- }
- if(key.contains("type")){
- isList=true;
- String value= map.get(key);
- if(! (value.contains("string")) ||
- (value.contains("integer")) ||
- (value.contains("boolean")) )
- {
- if(!key.contains("valid_values")){
- String trimValue=value.substring(value.lastIndexOf(".")+1);
- referenceIndividualAttributes=referenceIndividualAttributes+uniqueKey+"="+trimValue+":MANY-true";
- attributeIndividualString="";
- }
-
- }
- }
- }
-
- if(!(typeValueFromKey.equals("string")||
- typeValueFromKey.equals("integer") ||
- typeValueFromKey.equals("boolean")))
- {
- if(typeValueFromKey.equals("list")){
- isList=true;
- userDefinedDataType=false;
- }
- else{
- userDefinedDataType=true;
- }
- }
- if(userDefinedDataType==false && isList==false){
- if(key.contains("default")){
- attributeIndividualString=attributeIndividualString.replace("#B", map.get(key));
- }
- else if(key.contains("required")){
- attributeIndividualString=attributeIndividualString.replace("#C", map.get(key));
+ if(key.contains(uniqueKey)){
+ if(mapKey.containsKey(uniqueKey)){
+ hm = mapKey.get(uniqueKey);
+ String keyStr= key.substring(key.lastIndexOf(".")+1);
+ String valueStr= map.get(key);
+ if(keyStr.equals("type")){
+ if(!key.contains("entry_schema")){
+ hm.put(keyStr,valueStr);
}
- else if(key.contains("type")){
- String typeValue= map.get(key);
- attributeIndividualString=attributeIndividualString.replace("#A", typeValue);
- }
+ }else{
+ hm.put(keyStr,valueStr);
}
- else if(userDefinedDataType==true){
- String checkTypeAndUpdate=key.substring(p+1);
- if(checkTypeAndUpdate.equals("type")){
- String value=map.get(key);
- String trimValue=value.substring(value.lastIndexOf(".")+1);
- referenceIndividualAttributes=referenceIndividualAttributes+uniqueKey+"="+trimValue+":MANY-false";
+ } else {
+ hm = new HashMap<>();
+ String keyStr= key.substring(key.lastIndexOf(".")+1);
+ String valueStr= map.get(key);
+ if(keyStr.equals("type")){
+ if(!key.contains("entry_schema")){
+ hm.put(keyStr,valueStr);
}
- attributeIndividualString="";
+ }else{
+ hm.put(keyStr,valueStr);
}
+ mapKey.put(uniqueKey, hm);
}
}
}
+ }
+ StringBuilder attributeStringBuilder= new StringBuilder();
+ StringBuilder referenceStringBuilder= new StringBuilder();
+ StringBuilder listBuffer= new StringBuilder();
+
+ List<String> constraints= new ArrayList<>();
+ for(String keySetString: mapKey.keySet()){
+ HashMap<String,String> keyValues=mapKey.get(keySetString);
+ if(keyValues.get("type").equalsIgnoreCase("string")|| keyValues.get("type").equalsIgnoreCase("integer")){
+ StringBuilder attributeIndividualStringBuilder= new StringBuilder();
+ attributeIndividualStringBuilder.append(keySetString+"=");
+ attributeIndividualStringBuilder.append(keyValues.get("type")+":defaultValue-");
+ attributeIndividualStringBuilder.append(keyValues.get("default")+":required-");
+ attributeIndividualStringBuilder.append(keyValues.get("required")+":MANY-false");
+ attributeStringBuilder.append(attributeIndividualStringBuilder+",");
+ }
+ else if(keyValues.get("type").equalsIgnoreCase("list")){
+ //List Datatype
+ Set<String> keys= keyValues.keySet();
+ Iterator<String> itr=keys.iterator();
+ while(itr.hasNext()){
+ String key= itr.next().toString();
+ if((!key.equals("type"))){
+ String value= keyValues.get(key);
+ //The "." in the value determines if its a string or a user defined type.
+ if (!value.contains(".")){
+ //This is string
+ constraints.add(keyValues.get(key));
+ }else{
+ //This is user defined string
+ String trimValue=value.substring(value.lastIndexOf(".")+1);
+ StringBuilder referenceIndividualStringBuilder= new StringBuilder();
+ referenceIndividualStringBuilder.append(keySetString+"="+trimValue+":MANY-true");
+ referenceStringBuilder.append(referenceIndividualStringBuilder+",");
+ }
+ }
+ }
+ }else{
+ //User defined Datatype.
+ String value=keyValues.get("type");
+ String trimValue=value.substring(value.lastIndexOf(".")+1);
+ StringBuilder referenceIndividualStringBuilder= new StringBuilder();
+ referenceIndividualStringBuilder.append(keySetString+"="+trimValue+":MANY-false");
+ referenceStringBuilder.append(referenceIndividualStringBuilder+",");
+ }
if(constraints!=null &&constraints.isEmpty()==false){
//List handling.
- listConstraints=uniqueKey.toUpperCase()+"=[";
- isList=true;
+ listBuffer.append(keySetString.toUpperCase()+"=[");
for(String str:constraints){
- listConstraints=listConstraints+str+",";
+ listBuffer.append(str+",");
}
- listConstraints+="],";
- logger.info(listConstraints);
- attributeIndividualString="";
- referenceIndividualAttributes=referenceIndividualAttributes+uniqueKey+"="+uniqueKey.toUpperCase()+":MANY-false";
- constraints=null;
+ listBuffer.append("]#");
+ LOGGER.info(listBuffer);
- }
- if(userDefinedDataType==false && isList==false){
- if(attributeString!=""){
- attributeString=attributeString+","+attributeIndividualString;
- }else{
- attributeString=attributeString+attributeIndividualString;
- }
- }
- if(isList==true || userDefinedDataType==true){
- if(referenceAttributes!=""){
- referenceAttributes=referenceAttributes+","+referenceIndividualAttributes;
- }else{
- referenceAttributes=referenceAttributes+referenceIndividualAttributes;
- }
- logger.info("ReferenceAttributes: "+referenceAttributes);
- }
- logger.info("AttributeString: "+ attributeString);
- logger.info("ListConstraints is: "+listConstraints);
+ StringBuilder referenceIndividualStringBuilder= new StringBuilder();
+ referenceIndividualStringBuilder.append(keySetString+"="+keySetString.toUpperCase()+":MANY-false");
+ referenceStringBuilder.append(referenceIndividualStringBuilder+",");
+ constraints.clear();
+ }
+ }
- attributeIndividualString="";
- referenceIndividualAttributes="";
- userDefinedDataType=false;
- isList=false;
+ LOGGER.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
+ LOGGER.info("Whole attribute String is:"+attributeStringBuilder);
+ LOGGER.info("Whole reference String is:"+referenceStringBuilder);
+ LOGGER.info("List String is:"+listBuffer);
+ LOGGER.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
+ this.listConstraints=listBuffer.toString();
+ this.referenceAttributes=referenceStringBuilder.toString();
+ this.attributeString=attributeStringBuilder.toString();
- }
- this.listConstraints=listConstraints;
- this.referenceAttributes=referenceAttributes;
- this.attributeString=attributeString;
} catch (IOException e) {
- logger.error(e);
+ LOGGER.error(e);
}
}
@@ -611,7 +574,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
private JSONObject decodeContent(JsonNode jsonNode){
Iterator<JsonNode> jsonElements = jsonNode.elements();
Iterator<String> jsonKeys = jsonNode.fieldNames();
- Map<String,String> element = new TreeMap<String,String>();
+ Map<String,String> element = new TreeMap<>();
while(jsonElements.hasNext() && jsonKeys.hasNext()){
element.put(jsonKeys.next(), jsonElements.next().toString());
}
@@ -634,7 +597,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
presKey = key;
}
// first check if we are different from old.
- logger.info(key+"\n");
+ LOGGER.info(key+"\n");
if(jsonArray!=null && jsonArray.length()>0 && key.contains("@") && !key.contains(".") && oldValue!=null){
if(!oldValue.equals(key.substring(0,key.indexOf("@")))){
jsonResult.put(oldValue, jsonArray);
@@ -664,7 +627,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
isArray = true;
jsonArray = new JSONArray();
}
- if(arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){
+ if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){
jsonArray.put(decodeContent(node));
}
if(key.contains("@") && !arryKey.equals(key.substring(0,nodeKey.indexOf("@")))){
@@ -696,7 +659,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
isArray = true;
jsonArray = new JSONArray();
}
- if(arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){
+ if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){
jsonArray.put(decodeContent(node));
}
jsonResult.put(arryKey, jsonArray);
@@ -811,8 +774,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
@SuppressWarnings({ "unchecked", "rawtypes" })
private String createMicroSeriveJson(MicroServiceModels returnModel) {
- Map<String, String> attributeMap = new HashMap<String, String>();
- Map<String, String> refAttributeMap = new HashMap<String, String>();
+ Map<String, String> attributeMap = new HashMap<>();
+ Map<String, String> refAttributeMap = new HashMap<>();
String attribute = returnModel.getAttributes();
if(attribute != null){
attribute = attribute.trim();
@@ -882,7 +845,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
@SuppressWarnings("unchecked")
private JSONObject recursiveReference(String name, Map<String,String> subAttributeMap, String enumAttribute) {
JSONObject object = new JSONObject();
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
Object returnClass = subAttributeMap.get(name);
map = (Map<String, String>) returnClass;
JSONArray array = new JSONArray();
@@ -935,7 +898,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
private Set<String> getVersionList(String name) {
MicroServiceModels workingModel = new MicroServiceModels();
- Set<String> list = new HashSet<String>();
+ Set<String> list = new HashSet<>();
List<Object> microServiceModelsData = commonClassDao.getDataById(MicroServiceModels.class, "modelName", name);
for (int i = 0; i < microServiceModelsData.size(); i++) {
workingModel = (MicroServiceModels) microServiceModelsData.get(i);
@@ -972,9 +935,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
@RequestMapping(value={"/get_DCAEPriorityValues"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getDCAEPriorityValuesData(HttpServletRequest request, HttpServletResponse response){
try{
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
- List<String> priorityList = new ArrayList<String>();
+ List<String> priorityList = new ArrayList<>();
priorityCount = 10;
for (int i = 1; i < priorityCount; i++) {
priorityList.add(String.valueOf(i));
@@ -985,7 +948,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- logger.error(e);
+ LOGGER.error(e);
}
}
@@ -1079,7 +1042,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
public static Map<String, String> convert(String str, String split) {
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
for(final String entry : str.split(split)) {
String[] parts = entry.split("=");
map.put(parts[0], parts[1]);
@@ -1106,14 +1069,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
policyAdapter.setServiceType(msBody.getService());
}
if(msBody.getContent() != null){
- LinkedHashMap<String, Object> data = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> data = new LinkedHashMap<>();
LinkedHashMap<String, ?> map = (LinkedHashMap<String, ?>) msBody.getContent();
readRecursivlyJSONContent(map, data);
policyAdapter.setRuleData(data);
}
} catch (Exception e) {
- logger.error(e);
+ LOGGER.error(e);
}
}
@@ -1124,7 +1087,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
Object key = iterator.next();
Object value = map.get(key);
if(value instanceof LinkedHashMap<?, ?>){
- LinkedHashMap<String, Object> secondObjec = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> secondObjec = new LinkedHashMap<>();
readRecursivlyJSONContent((LinkedHashMap<String, ?>) value, secondObjec);
for(String objKey: secondObjec.keySet()){
data.put(key+"." +objKey, secondObjec.get(objKey));
@@ -1134,7 +1097,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
for(int i = 0; i < jsonArrayVal.size(); i++){
Object arrayvalue = jsonArrayVal.get(i);
if(arrayvalue instanceof LinkedHashMap<?, ?>){
- LinkedHashMap<String, Object> newData = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> newData = new LinkedHashMap<>();
readRecursivlyJSONContent((LinkedHashMap<String, ?>) arrayvalue, newData);
for(String objKey: newData.keySet()){
data.put(key+"@"+i+"." +objKey, newData.get(objKey));
@@ -1171,7 +1134,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
//Convert the map values and set into JSON body
public Map<String, String> convertMap(Map<String, String> attributesMap, Map<String, String> attributesRefMap) {
- Map<String, String> attribute = new HashMap<String, String>();
+ Map<String, String> attribute = new HashMap<>();
String temp = null;
String key;
String value;
@@ -1236,12 +1199,12 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
}catch(Exception e){
- logger.error("Upload error : " + e);
+ LOGGER.error("Upload error : " + e);
}
}
}
- List<File> fileList = new ArrayList<File>();;
+ List<File> fileList = new ArrayList<>();;
this.directory = "model";
if (zip){
extractFolder(this.newFile);
@@ -1256,7 +1219,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
if(yml==false){
modelType="xmi";
//Process Main Model file first
- classMap = new HashMap<String,MSAttributeObject>();
+ classMap = new HashMap<>();
for (File file : fileList) {
if(!file.isDirectory() && file.getName().endsWith(".xmi")){
retreiveDependency(file.toString(), true);
@@ -1274,25 +1237,30 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
MSAttributeObject msAttributes= new MSAttributeObject();
msAttributes.setClassName(className);
- HashMap<String, String> returnAttributeList =new HashMap<String, String>();
+ HashMap<String, String> returnAttributeList =new HashMap<>();
returnAttributeList.put(className, this.attributeString);
msAttributes.setAttribute(returnAttributeList);
msAttributes.setSubClass(this.retmap);
- HashMap<String, String> returnReferenceList =new HashMap<String, String>();
+ HashMap<String, String> returnReferenceList =new HashMap<>();
//String[] referenceArray=this.referenceAttributes.split("=");
returnReferenceList.put(className, this.referenceAttributes);
msAttributes.setRefAttribute(returnReferenceList);
if(this.listConstraints!=""){
- HashMap<String, String> enumList =new HashMap<String, String>();
- String[] listArray=this.listConstraints.split("=");
- enumList.put(listArray[0], listArray[1]);
+ HashMap<String, String> enumList =new HashMap<>();
+ String[] listArray=this.listConstraints.split("#");
+ for(String str:listArray){
+ String[] strArr= str.split("=");
+ if(strArr.length>1){
+ enumList.put(strArr[0], strArr[1]);
+ }
+ }
msAttributes.setEnumType(enumList);
}
- classMap=new HashMap<String,MSAttributeObject>();
+ classMap=new HashMap<>();
classMap.put(className, msAttributes);
}
@@ -1319,7 +1287,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
int BUFFER = 2048;
File file = new File(zipFile);
- ZipFile zip;
+ ZipFile zip = null;
try {
zip = new ZipFile(file);
String newPath = "model" + File.separator + zipFile.substring(0, zipFile.length() - 4);
@@ -1357,19 +1325,26 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
}
} catch (IOException e) {
- logger.error("Failed to unzip model file " + zipFile);
+ LOGGER.error("Failed to unzip model file " + zipFile);
+ }finally{
+ try {
+ if(zip != null)
+ zip.close();
+ } catch (IOException e) {
+ LOGGER.error("Exception Occured While closing zipfile " + e);
+ }
}
}
private void retreiveDependency(String workingFile, Boolean modelClass) {
MSModelUtils utils = new MSModelUtils(PolicyController.msEcompName, PolicyController.msPolicyName);
- HashMap<String, MSAttributeObject> tempMap = new HashMap<String, MSAttributeObject>();
+ HashMap<String, MSAttributeObject> tempMap = new HashMap<>();
tempMap = utils.processEpackage(workingFile, MODEL_TYPE.XMI);
classMap.putAll(tempMap);
- logger.info(tempMap);
+ LOGGER.info(tempMap);
return;
@@ -1377,7 +1352,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
private List<File> listModelFiles(String directoryName) {
File directory = new File(directoryName);
- List<File> resultList = new ArrayList<File>();
+ List<File> resultList = new ArrayList<>();
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isFile()) {
@@ -1395,7 +1370,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
try {
FileUtils.forceDelete(new File(path));
} catch (IOException e) {
- logger.error("Failed to delete folder " + path);
+ LOGGER.error("Failed to delete folder " + path);
}
}
}
@@ -1409,7 +1384,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
private List<String> createList() {
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
for (Entry<String, MSAttributeObject> cMap : classMap.entrySet()){
if (cMap.getValue().isPolicyTempalate()){
list.add(cMap.getKey());
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 1326aba7d..4aea6370b 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
@@ -41,6 +41,7 @@ import org.openecomp.policy.rest.adapter.AddressGroupJson;
import org.openecomp.policy.rest.adapter.AddressJson;
import org.openecomp.policy.rest.adapter.AddressMembers;
import org.openecomp.policy.rest.adapter.DeployNowJson;
+import org.openecomp.policy.rest.adapter.IdMap;
import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
import org.openecomp.policy.rest.adapter.PrefixIPList;
import org.openecomp.policy.rest.adapter.ServiceGroupJson;
@@ -51,6 +52,7 @@ import org.openecomp.policy.rest.adapter.TagDefines;
import org.openecomp.policy.rest.adapter.Tags;
import org.openecomp.policy.rest.adapter.Term;
import org.openecomp.policy.rest.adapter.TermCollector;
+import org.openecomp.policy.rest.adapter.VendorSpecificData;
import org.openecomp.policy.rest.dao.CommonClassDao;
import org.openecomp.policy.rest.jpa.AddressGroup;
import org.openecomp.policy.rest.jpa.FWTagPicker;
@@ -94,8 +96,8 @@ public class CreateFirewallController extends RestrictedBaseController {
private List<String> tagCollectorList;
private String jsonBody;
- List<String> expandablePrefixIPList = new ArrayList<String>();
- List<String> expandableServicesList= new ArrayList<String>();
+ List<String> expandablePrefixIPList = new ArrayList<>();
+ List<String> expandableServicesList= new ArrayList<>();
@Autowired
private CreateFirewallController(CommonClassDao commonClassDao){
CreateFirewallController.commonClassDao = commonClassDao;
@@ -122,9 +124,8 @@ public class CreateFirewallController extends RestrictedBaseController {
}
}
jsonBody = constructJson(policyData);
- if (jsonBody != null || jsonBody.equalsIgnoreCase("")) {
+ if (jsonBody != null && !jsonBody.equalsIgnoreCase("")) {
policyData.setJsonBody(jsonBody);
-
} else {
policyData.setJsonBody("{}");
}
@@ -136,7 +137,7 @@ public class CreateFirewallController extends RestrictedBaseController {
private List<String> mapping(String expandableList) {
String value = new String();
String desc = new String();
- List <String> valueDesc= new ArrayList<String>();
+ List <String> valueDesc= new ArrayList<>();
List<Object> prefixListData = commonClassDao.getData(PrefixList.class);
for (int i = 0; i< prefixListData.size(); i++) {
PrefixList prefixList = (PrefixList) prefixListData.get(i);
@@ -190,7 +191,7 @@ public class CreateFirewallController extends RestrictedBaseController {
}
public void prePopulateFWPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- attributeList = new ArrayList<Object>();
+ attributeList = new ArrayList<>();
if (policyAdapter.getPolicyData() instanceof PolicyType) {
Object policyData = policyAdapter.getPolicyData();
PolicyType policy = (PolicyType) policyData;
@@ -232,14 +233,15 @@ public class CreateFirewallController extends RestrictedBaseController {
}
Map<String, String> termTagMap=null;
-
- for(int i=0;i<tc1.getFirewallRuleList().size();i++){
- termTagMap = new HashMap<String, String>();
- String ruleName= tc1.getFirewallRuleList().get(i).getRuleName();
- String tagPickerName=tc1.getRuleToTag().get(i).getTagPickerName();
- termTagMap.put("key", ruleName);
- termTagMap.put("value", tagPickerName);
- attributeList.add(termTagMap);
+ if(tc1 != null){
+ for(int i=0;i<tc1.getFirewallRuleList().size();i++){
+ termTagMap = new HashMap<String, String>();
+ String ruleName= tc1.getFirewallRuleList().get(i).getRuleName();
+ String tagPickerName=tc1.getRuleToTag().get(i).getTagPickerName();
+ termTagMap.put("key", ruleName);
+ termTagMap.put("value", tagPickerName);
+ attributeList.add(termTagMap);
+ }
}
policyAdapter.setAttributes(attributeList);
// Get the target data under policy.
@@ -317,7 +319,7 @@ public class CreateFirewallController extends RestrictedBaseController {
@RequestMapping(value={"/policyController/ViewFWPolicyRule.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public ModelAndView setFWViewRule(HttpServletRequest request, HttpServletResponse response) throws Exception{
try {
- termCollectorList = new ArrayList<String>();
+ termCollectorList = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
@@ -336,7 +338,7 @@ public class CreateFirewallController extends RestrictedBaseController {
String ruleSrcPort=null;
String ruleDestPort=null;
String ruleAction=null;
- List <String> valueDesc= new ArrayList<String>();
+ List <String> valueDesc= new ArrayList<>();
StringBuffer displayString = new StringBuffer();
for (String id : termCollectorList) {
List<Object> tmList = commonClassDao.getDataById(TermList.class, "termName", id);
@@ -497,14 +499,14 @@ public class CreateFirewallController extends RestrictedBaseController {
String json = null;
- List<String> expandableList = new ArrayList<String>();
+ List<String> expandableList = new ArrayList<>();
TermList jpaTermList;
TermCollector tc = new TermCollector();
SecurityZone jpaSecurityZone;
- List<Term> termList = new ArrayList<Term>();
+ List<Term> termList = new ArrayList<>();
Tags tags=null;
- List<Tags>tagsList= new ArrayList<Tags>();
+ List<Tags>tagsList= new ArrayList<>();
TagDefines tagDefine= new TagDefines();
List<TagDefines> tagList=null;
@@ -519,7 +521,7 @@ public class CreateFirewallController extends RestrictedBaseController {
FWTagPicker jpaTagPickerList=(FWTagPicker) tagListData.get(tagCounter);
if (jpaTagPickerList.getTagPickerName().equals(tag) ){
String tagValues=jpaTagPickerList.getTagValues();
- tagList= new ArrayList<TagDefines>();
+ tagList= new ArrayList<>();
for(String val:tagValues.split("#")) {
int index=val.indexOf(":");
String keyToStore=val.substring(0,index);
@@ -561,46 +563,46 @@ public class CreateFirewallController extends RestrictedBaseController {
ruleFromZone=jpaTermList.getFromZone();
if ((ruleFromZone != null) && (!ruleFromZone.isEmpty())){
- fromZone_map = new HashMap<Integer, String>();
+ fromZone_map = new HashMap<>();
fromZone_map.put(tl, ruleFromZone);
}
ruleToZone=jpaTermList.getToZone();
if ((ruleToZone != null) && (!ruleToZone.isEmpty())){
- toZone_map = new HashMap<Integer, String>();
+ toZone_map = new HashMap<>();
toZone_map.put(tl, ruleToZone);
}
ruleSrcPrefixList=jpaTermList.getSrcIPList();
if ((ruleSrcPrefixList != null) && (!ruleSrcPrefixList.isEmpty())){
- srcIP_map = new HashMap<Integer, String>();
+ srcIP_map = new HashMap<>();
srcIP_map.put(tl, ruleSrcPrefixList);
}
ruleDestPrefixList= jpaTermList.getDestIPList();
if ((ruleDestPrefixList != null) && (!ruleDestPrefixList.isEmpty())){
- destIP_map = new HashMap<Integer, String>();
+ destIP_map = new HashMap<>();
destIP_map.put(tl, ruleDestPrefixList);
}
ruleSrcPort=jpaTermList.getSrcPortList();
if (ruleSrcPort != null && (!ruleSrcPort.isEmpty())){
- srcPort_map = new HashMap<Integer, String>();
+ srcPort_map = new HashMap<>();
srcPort_map.put(tl, ruleSrcPort);
}
ruleDestPort= jpaTermList.getDestPortList();
if (ruleDestPort!= null && (!jpaTermList.getDestPortList().isEmpty())){
- destPort_map = new HashMap<Integer, String>();
+ destPort_map = new HashMap<>();
destPort_map.put(tl, ruleDestPort);
}
ruleAction=jpaTermList.getAction();
if (( ruleAction!= null) && (!ruleAction.isEmpty())){
- action_map = new HashMap<Integer, String>();
+ action_map = new HashMap<>();
action_map.put(tl, ruleAction);
}
}
@@ -616,7 +618,7 @@ public class CreateFirewallController extends RestrictedBaseController {
//FromZone arrays
if(fromZone_map!=null){
- List<String> fromZone= new ArrayList<String>();
+ List<String> fromZone= new ArrayList<>();
for(String fromZoneStr:fromZone_map.get(tl).split(",") ){
fromZone.add(fromZoneStr);
}
@@ -625,7 +627,7 @@ public class CreateFirewallController extends RestrictedBaseController {
//ToZone arrays
if(toZone_map!=null){
- List<String> toZone= new ArrayList<String>();
+ List<String> toZone= new ArrayList<>();
for(String toZoneStr:toZone_map.get(tl).split(",") ){
toZone.add(toZoneStr);
}
@@ -634,7 +636,7 @@ public class CreateFirewallController extends RestrictedBaseController {
//Destination Services.
if(destPort_map!=null){
- Set<ServicesJson> destServicesJsonList= new HashSet<ServicesJson>();
+ Set<ServicesJson> destServicesJsonList= new HashSet<>();
for(String destServices:destPort_map.get(tl).split(",") ){
ServicesJson destServicesJson= new ServicesJson();
destServicesJson.setType("REFERENCE");
@@ -665,7 +667,7 @@ public class CreateFirewallController extends RestrictedBaseController {
if(srcIP_map!=null){
//Source List
- List<AddressJson> sourceListArrayJson= new ArrayList<AddressJson>();
+ List<AddressJson> sourceListArrayJson= new ArrayList<>();
for(String srcList:srcIP_map.get(tl).split(",") ){
AddressJson srcListJson= new AddressJson();
if(srcList.equals("ANY")){
@@ -686,7 +688,7 @@ public class CreateFirewallController extends RestrictedBaseController {
}
if(destIP_map!=null){
//Destination List
- List<AddressJson> destListArrayJson= new ArrayList<AddressJson>();
+ List<AddressJson> destListArrayJson= new ArrayList<>();
for(String destList:destIP_map.get(tl).split(",")){
AddressJson destListJson= new AddressJson();
if(destList.equals("ANY")){
@@ -727,25 +729,32 @@ public class CreateFirewallController extends RestrictedBaseController {
jpaSecurityZone = (SecurityZone) securityZoneData.get(j);
if (jpaSecurityZone.getZoneName().equals(policyData.getSecurityZone())){
tc.setSecurityZoneId(jpaSecurityZone.getZoneValue());
- //setParentSecurityZone(jpaSecurityZone.getZoneValue());//For storing the securityZone IDs to the DB
+ IdMap idMapInstance= new IdMap();
+ idMapInstance.setAstraId(jpaSecurityZone.getZoneValue());
+ idMapInstance.setVendorId("deviceGroup:dev");
+
+ List<IdMap> idMap = new ArrayList<IdMap>();
+ idMap.add(idMapInstance);
+
+ VendorSpecificData vendorStructure= new VendorSpecificData();
+ vendorStructure.setIdMap(idMap);
+ tc.setVendorSpecificData(vendorStructure);
break;
}
}
tc.setServiceTypeId("/v0/firewall/pan");
tc.setConfigName(policyData.getConfigName());
+ tc.setVendorServiceId("vipr");
- //Astra is rejecting the packet when it sees a new JSON field, so removing it for now.
- //tc.setTemplateVersion(XACMLProperties.getProperty(XACMLRestProperties.TemplateVersion_FW));
-
DeployNowJson deployNow= new DeployNowJson();
deployNow.setDeployNow(false);
tc.setDeploymentOption(deployNow);
- Set<ServiceListJson> servListArray = new HashSet<ServiceListJson>();
- Set<ServiceGroupJson> servGroupArray= new HashSet<ServiceGroupJson>();
- Set<AddressGroupJson> addrGroupArray= new HashSet<AddressGroupJson>();
+ Set<ServiceListJson> servListArray = new HashSet<>();
+ Set<ServiceGroupJson> servGroupArray= new HashSet<>();
+ Set<AddressGroupJson> addrGroupArray= new HashSet<>();
ServiceGroupJson targetSg= null;
AddressGroupJson addressSg=null;
@@ -801,7 +810,7 @@ public class CreateFirewallController extends RestrictedBaseController {
String name=sg.getGroupName();
//Removing the "Group_" prepending string before packing the JSON
targetSg.setName(name.substring(6,name.length()));
- List<ServiceMembers> servMembersList= new ArrayList<ServiceMembers>();
+ List<ServiceMembers> servMembersList= new ArrayList<>();
for(String groupString: sg.getServiceList().split(",")){
ServiceMembers serviceMembers= new ServiceMembers();
@@ -828,13 +837,13 @@ public class CreateFirewallController extends RestrictedBaseController {
}
}
- Set<PrefixIPList> prefixIPList = new HashSet<PrefixIPList>();
+ Set<PrefixIPList> prefixIPList = new HashSet<>();
for(String prefixList:expandablePrefixIPList){
for(String prefixIP: prefixList.split(",")){
if((!prefixIP.startsWith("Group_"))){
if(!prefixIP.equals("ANY")){
- List<AddressMembers> addMembersList= new ArrayList<AddressMembers>();
- List<String> valueDesc= new ArrayList<String>();
+ List<AddressMembers> addMembersList= new ArrayList<>();
+ List<String> valueDesc= new ArrayList<>();
PrefixIPList targetAddressList = new PrefixIPList();
AddressMembers addressMembers= new AddressMembers();
targetAddressList.setName(prefixIP);
@@ -866,9 +875,9 @@ public class CreateFirewallController extends RestrictedBaseController {
//Removing the "Group_" prepending string before packing the JSON
addressSg.setName(name.substring(6,name.length()));
- List<AddressMembers> addrMembersList= new ArrayList<AddressMembers>();
+ List<AddressMembers> addrMembersList= new ArrayList<>();
for(String groupString: ag.getPrefixList().split(",")){
- List<String> valueDesc= new ArrayList<String>();
+ List<String> valueDesc= new ArrayList<>();
AddressMembers addressMembers= new AddressMembers();
valueDesc= mapping (groupString);
if(valueDesc.size() > 0){
@@ -886,7 +895,7 @@ public class CreateFirewallController extends RestrictedBaseController {
}
}
- Set<Object> serviceGroup= new HashSet<Object>();
+ Set<Object> serviceGroup= new HashSet<>();
for(Object obj1:servGroupArray){
serviceGroup.add(obj1);
@@ -896,7 +905,7 @@ public class CreateFirewallController extends RestrictedBaseController {
serviceGroup.add(obj);
}
- Set<Object> addressGroup= new HashSet<Object>();
+ Set<Object> addressGroup= new HashSet<>();
for(Object addObj:prefixIPList){
addressGroup.add(addObj);
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 bca63eb0f..5049d2652 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
@@ -67,7 +67,7 @@ public class CreatePolicyController extends RestrictedBaseController{
}
public void prePopulateBaseConfigPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- attributeList = new ArrayList<Object>();
+ attributeList = new ArrayList<>();
if (policyAdapter.getPolicyData() instanceof PolicyType) {
Object policyData = policyAdapter.getPolicyData();
PolicyType policy = (PolicyType) policyData;
@@ -136,7 +136,7 @@ public class CreatePolicyController extends RestrictedBaseController{
// After Ecomp and Config it is optional to have attributes, so
// check weather dynamic values or there or not.
if (index >= 7) {
- Map<String, String> attribute = new HashMap<String, String>();
+ Map<String, String> attribute = new HashMap<>();
attribute.put("key", attributeId);
attribute.put("value", value);
attributeList.add(attribute);
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 7ba1e847c..707a65d62 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
@@ -91,7 +91,7 @@ public class DashboardController extends RestrictedBaseController{
@RequestMapping(value={"/get_DashboardLoggingData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getData(HttpServletRequest request, HttpServletResponse response){
try{
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
model.put("availableLoggingDatas", mapper.writeValueAsString(systemDAO.getLoggingData()));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -106,7 +106,7 @@ public class DashboardController extends RestrictedBaseController{
@RequestMapping(value={"/get_DashboardSystemAlertData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getSystemAlertData(HttpServletRequest request, HttpServletResponse response){
try{
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
model.put("systemAlertsTableDatas", mapper.writeValueAsString(systemDAO.getSystemAlertData()));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -121,7 +121,7 @@ public class DashboardController extends RestrictedBaseController{
@RequestMapping(value={"/get_DashboardPAPStatusData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getPAPStatusData(HttpServletRequest request, HttpServletResponse response){
try{
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
addPAPToTable();
@@ -138,7 +138,7 @@ public class DashboardController extends RestrictedBaseController{
@RequestMapping(value={"/get_DashboardPDPStatusData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getPDPStatusData(HttpServletRequest request, HttpServletResponse response){
try{
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
this.pdpConatiner = new PDPGroupContainer(PolicyController.getPapEngine());
@@ -156,7 +156,7 @@ public class DashboardController extends RestrictedBaseController{
@RequestMapping(value={"/get_DashboardPolicyActivityData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getPolicyActivityData(HttpServletRequest request, HttpServletResponse response){
try{
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
this.pdpConatiner = new PDPGroupContainer(PolicyController.getPapEngine());
@@ -175,7 +175,7 @@ public class DashboardController extends RestrictedBaseController{
* Add the PAP information to the PAP Table
*/
public void addPAPToTable(){
- papStatusData = new ArrayList<Object>();
+ papStatusData = new ArrayList<>();
String papStatus = null;
try {
Set<EcompPDPGroup> groups = PolicyController.getPapEngine().getEcompPDPGroups();
@@ -205,7 +205,7 @@ public class DashboardController extends RestrictedBaseController{
*/
public void addPDPToTable(){
pdpCount = 0;
- pdpStatusData = new ArrayList<Object>();
+ pdpStatusData = new ArrayList<>();
long naCount;
long denyCount = 0;
long permitCount = 0;
@@ -305,7 +305,7 @@ public class DashboardController extends RestrictedBaseController{
* Add the information to the Policy Table
*/
private void addPolicyToTable() {
- policyActivityData = new ArrayList<Object>();
+ policyActivityData = new ArrayList<>();
int i = 1;
String policyID = null;
int policyFireCount = 0;
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 82fc24b40..2fecd7eea 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
@@ -68,9 +68,9 @@ public class DecisionPolicyController extends RestrictedBaseController {
@SuppressWarnings("unchecked")
public void prePopulateDecisionPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- attributeList = new ArrayList<Object>();
- decisionList = new ArrayList<Object>();
- ruleAlgorithmList = new ArrayList<Object>();
+ attributeList = new ArrayList<>();
+ decisionList = new ArrayList<>();
+ ruleAlgorithmList = new ArrayList<>();
if (policyAdapter.getPolicyData() instanceof PolicyType) {
Object policyData = policyAdapter.getPolicyData();
PolicyType policy = (PolicyType) policyData;
@@ -121,7 +121,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
// Component attributes are saved under Target here we are fetching them back.
// 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>();
+ Map<String, String> attribute = new HashMap<>();
attribute.put("key", attributeId);
attribute.put("value", value);
attributeList.add(attribute);
@@ -165,7 +165,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
if (condition != null) {
ApplyType decisionApply = (ApplyType) condition.getExpression().getValue();
decisionApply = (ApplyType) decisionApply.getExpression().get(0).getValue();
- ruleAlgoirthmTracker = new LinkedList<Integer>();
+ ruleAlgoirthmTracker = new LinkedList<>();
if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals("GUARD_YAML")){
YAMLParams yamlParams = new YAMLParams();
for(int i=0; i<attributeList.size() ; i++){
@@ -201,7 +201,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
}
private void prePopulateDecisionRuleAlgorithms(int index, ApplyType decisionApply, List<JAXBElement<?>> jaxbDecisionTypes) {
- Map<String, String> ruleMap = new HashMap<String, String>();
+ Map<String, String> ruleMap = new HashMap<>();
ruleMap.put("id", "A" + (index +1));
Map<String, String> dropDownMap = PolicyController.getDropDownMap();
for (String key : dropDownMap.keySet()) {
@@ -262,7 +262,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
if (logger.isDebugEnabled()) {
logger.debug("Prepopulating Compound rule algorithm: " + index);
}
- Map<String, String> rule = new HashMap<String, String>();
+ Map<String, String> rule = new HashMap<>();
for (String key : PolicyController.getDropDownMap().keySet()) {
String keyValue = PolicyController.getDropDownMap().get(key);
if (keyValue.equals(decisionApply.getFunctionId())) {
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 87b32206e..80820c129 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
@@ -26,6 +26,7 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -71,13 +72,13 @@ public class PDPController extends RestrictedBaseController {
synchronized(this.groups) {
this.groups.clear();
try {
- Set<PDPPolicy> filteredPolicies = new HashSet<PDPPolicy>();
+ 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);
- roles = new ArrayList<String>();
- scopes = new HashSet<String>();
+ roles = new ArrayList<>();
+ scopes = new HashSet<>();
for(Object role: userRoles){
Roles userRole = (Roles) role;
roles.add(userRole.getRole());
@@ -98,8 +99,11 @@ public class PDPController extends RestrictedBaseController {
if(!userRoles.isEmpty()){
if(!scopes.isEmpty()){
this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups());
+ List<EcompPDPGroup> tempGroups = new ArrayList<EcompPDPGroup>();
if(!groups.isEmpty()){
- for(EcompPDPGroup group : groups){
+ Iterator<EcompPDPGroup> pdpGroup = groups.iterator();
+ while(pdpGroup.hasNext()){
+ EcompPDPGroup group = pdpGroup.next();
Set<PDPPolicy> policies = group.getPolicies();
for(PDPPolicy policy : policies){
for(String scope : scopes){
@@ -117,11 +121,13 @@ public class PDPController extends RestrictedBaseController {
}
}
}
- groups.remove(group);
+ pdpGroup.remove();
StdPDPGroup newGroup = (StdPDPGroup) group;
newGroup.setPolicies(filteredPolicies);
- groups.add(newGroup);
- }
+ tempGroups.add(newGroup);
+ }
+ groups.clear();
+ groups = tempGroups;
}
}
}
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 a9eb40b4f..42e4483ca 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
@@ -85,7 +85,7 @@ public class PolicyController extends RestrictedBaseController {
public static String logTableLimit;
public static String systemAlertTableLimit;
- protected static Map<String, String> dropDownMap = new HashMap<String, String>();
+ protected static Map<String, String> dropDownMap = new HashMap<>();
public static Map<String, String> getDropDownMap() {
return dropDownMap;
}
@@ -134,6 +134,10 @@ public class PolicyController extends RestrictedBaseController {
//MicroService Model Properties
public static String msEcompName;
public static String msPolicyName;
+
+ //WebApp directories
+ public static String configHome;
+ public static String actionHome;
@Autowired
private PolicyController(CommonClassDao commonClassDao){
@@ -179,6 +183,9 @@ public class PolicyController extends RestrictedBaseController {
//Micro Service Properties
msEcompName=prop.getProperty("xacml.policy.msEcompName");
msPolicyName=prop.getProperty("xacml.policy.msPolicyName");
+ //WebApp directories
+ configHome = prop.getProperty("xacml.rest.config.webapps") + "Config";
+ actionHome = prop.getProperty("xacml.rest.config.webapps") + "Action";
//Get the Property Values for Dashboard tab Limit
try{
logTableLimit = prop.getProperty("xacml.ecomp.dashboard.logTableLimit");
@@ -231,8 +238,8 @@ public class PolicyController extends RestrictedBaseController {
}
private static void buildFunctionMaps() {
- mapDatatype2Function = new HashMap<Datatype, List<FunctionDefinition>>();
- mapID2Function = new HashMap<String, FunctionDefinition>();
+ mapDatatype2Function = new HashMap<>();
+ mapID2Function = new HashMap<>();
List<Object> functiondefinitions = commonClassDao.getData(FunctionDefinition.class);
for (int i = 0; i < functiondefinitions.size(); i ++) {
FunctionDefinition value = (FunctionDefinition) functiondefinitions.get(i);
@@ -247,7 +254,7 @@ public class PolicyController extends RestrictedBaseController {
@RequestMapping(value={"/get_FunctionDefinitionDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getFunctionDefinitionData(HttpServletRequest request, HttpServletResponse response){
try{
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
model.put("functionDefinitionDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FunctionDefinition.class, "shortname")));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -267,7 +274,7 @@ public class PolicyController extends RestrictedBaseController {
}
public static Map<String, Roles> getUserRoles(String userId) {
- Map<String, Roles> scopes = new HashMap<String, Roles>();
+ Map<String, Roles> scopes = new HashMap<>();
List<Object> roles = commonClassDao.getDataById(Roles.class, "loginId", userId);
if (roles != null && roles.size() > 0) {
for (Object role : roles) {
@@ -295,7 +302,7 @@ public class PolicyController extends RestrictedBaseController {
public void getUserRolesEntityData(HttpServletRequest request, HttpServletResponse response){
try{
String userId = UserUtils.getUserSession(request).getOrgUserId();
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
model.put("userRolesDatas", mapper.writeValueAsString(getRolesOfUser(userId)));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -320,7 +327,7 @@ public class PolicyController extends RestrictedBaseController {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Exception Occured while loading PAP"+e);
}
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
return new ModelAndView("policy_Editor","model", model);
}
@@ -404,7 +411,7 @@ public class PolicyController extends RestrictedBaseController {
String[] splitDBCheckName = dbCheckName.split(":");
String query = "FROM PolicyEntity where policyName like'"+splitDBCheckName[1]+"%' and scope ='"+splitDBCheckName[0]+"'";
List<Object> policyEntity = commonClassDao.getDataByQuery(query);
- List<String> av = new ArrayList<String>();
+ List<String> av = new ArrayList<>();
for(Object entity : policyEntity){
PolicyEntity pEntity = (PolicyEntity) entity;
String removeExtension = pEntity.getPolicyName().replace(".xml", "");
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 b6899e041..68a65fc5e 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
@@ -101,7 +101,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
public void ExportPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
try{
String file = null;
- selectedPolicy = new ArrayList<String>();
+ selectedPolicy = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
@@ -196,8 +196,8 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
//Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = PolicyController.getRoles(userId);
- roles = new ArrayList<String>();
- scopes = new HashSet<String>();
+ roles = new ArrayList<>();
+ scopes = new HashSet<>();
for(Object role: userRoles){
Roles userRole = (Roles) role;
roles.add(userRole.getRole());
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 9a4f52dbb..219342063 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
@@ -65,7 +65,7 @@ public class PolicyRolesController extends RestrictedBaseController{
@RequestMapping(value={"/get_RolesData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getPolicyRolesEntityData(HttpServletRequest request, HttpServletResponse response){
try{
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
model.put("rolesDatas", mapper.writeValueAsString(commonClassDao.getUserRoles()));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -117,8 +117,8 @@ public class PolicyRolesController extends RestrictedBaseController{
@RequestMapping(value={"/get_PolicyRolesScopeData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getPolicyScopesEntityData(HttpServletRequest request, HttpServletResponse response){
try{
- scopelist = new ArrayList<String>();
- Map<String, Object> model = new HashMap<String, Object>();
+ scopelist = new ArrayList<>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
List<String> scopesData = commonClassDao.getDataByColumn(PolicyEditorScopes.class, "scopeName");
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 d9d0fc97b..ff91e9381 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
@@ -90,8 +90,8 @@ public class PolicyValidationController extends RestrictedBaseController {
private Pattern pattern;
private Matcher matcher;
- private static Map<String, String> rangeMap = new HashMap<String,String>();
- private static Map<String, String> mapAttribute = new HashMap<String,String>();
+ private static Map<String, String> rangeMap = new HashMap<>();
+ private static Map<String, String> mapAttribute = new HashMap<>();
private static final String EMAIL_PATTERN =
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
@@ -642,14 +642,24 @@ public class PolicyValidationController extends RestrictedBaseController {
// Validation for json.
protected static boolean isJSONValid(String data) {
+ InputStream stream = null;
+ JsonReader jsonReader = null;
try {
new JSONObject(data);
- InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
- JsonReader jsonReader = Json.createReader(stream);
- System.out.println("Json Value is: " + jsonReader.read().toString() );
+ stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
+ jsonReader = Json.createReader(stream);
} catch (Exception e) {
LOGGER.error("Exception Occured"+e);
return false;
+ }finally{
+ try {
+ if(stream != null && jsonReader != null){
+ jsonReader.close();
+ stream.close();
+ }
+ } catch (IOException e) {
+ LOGGER.error("Exception Occured while closing the input stream"+e);
+ }
}
return true;
}