summaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-01-29 11:59:40 -0500
committerPamela Dragosh <pdragosh@research.att.com>2018-01-29 13:30:49 -0500
commitb65e96826d7339ce29ddb73e3ed6775bd4f54753 (patch)
treede19c06846e0b1acb5095647a16848431f92a349 /POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
parent38261bb20e49c39f710aef47b5415dcdf14a1729 (diff)
Reduce technical debt
Focusing on easy try-with-resources changes. Plus some other minor items. I did not get all of them yet, as some have some heavy refactoring. These try-with-resources seem to be fairly harmless. * Utilize try-with-resources * Remove unnecessary parenthesis * Merging simple if statements * Remove useless assignment * Moving string literals to left hand side Issue-ID: POLICY-482 Change-Id: If519ec8ea96f6b90bf82ac2676ffea9cd0cd2daf Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java')
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
index e62c87839..3be7de30a 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
@@ -314,8 +314,8 @@ public class PolicyManagerServlet extends HttpServlet {
}
private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) {
- Set<String> scopes = null;
- List<String> roles = null;
+ Set<String> scopes;
+ List<String> roles;
List<Object> policyData = new ArrayList<>();
JSONArray policyList = null;
if(params.has("policyList")){
@@ -442,7 +442,7 @@ public class PolicyManagerServlet extends HttpServlet {
policyName = removeExtension.substring(0, removeExtension.lastIndexOf('.'));
}
- String activePolicy = null;
+ String activePolicy;
PolicyController controller = getPolicyControllerInstance();
if(params.toString().contains("activeVersion")){
String activeVersion = params.getString("activeVersion");
@@ -659,7 +659,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
private List<Object> queryPolicyEditorScopes(String scopeName){
- String scopeNamequery = "";
+ String scopeNamequery;
SimpleBindings params = new SimpleBindings();
if(scopeName == null){
scopeNamequery = "from PolicyEditorScopes";
@@ -668,7 +668,7 @@ public class PolicyManagerServlet extends HttpServlet {
params.put("scopeName", scopeName + "%");
}
PolicyController controller = getPolicyControllerInstance();
- List<Object> scopesList = null;
+ List<Object> scopesList;
if(PolicyController.isjUnit()){
scopesList = controller.getDataByQuery(scopeNamequery, null);
}else{
@@ -692,8 +692,8 @@ public class PolicyManagerServlet extends HttpServlet {
SimpleBindings params = new SimpleBindings();
params.put("scopeName", scopeName + "%");
- List<Object> activePolicies = null;
- List<Object> scopesList = null;
+ List<Object> activePolicies;
+ List<Object> scopesList;
if(PolicyController.isjUnit()){
activePolicies = controller.getDataByQuery(query, null);
scopesList = controller.getDataByQuery(scopeNamequery, null);
@@ -727,7 +727,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
}
}
- String scopeNameCheck = null;
+ String scopeNameCheck;
for (Object list : activePolicies) {
PolicyVersion policy = (PolicyVersion) list;
String scopeNameValue = policy.getPolicyName().substring(0, policy.getPolicyName().lastIndexOf(File.separator));
@@ -862,7 +862,7 @@ public class PolicyManagerServlet extends HttpServlet {
private JSONObject policyRename(String oldPath, String newPath, String userId) throws ServletException {
try {
- PolicyEntity entity = null;
+ PolicyEntity entity;
PolicyController controller = getPolicyControllerInstance();
String policyVersionName = newPath.replace(".xml", "");
@@ -1004,7 +1004,7 @@ public class PolicyManagerServlet extends HttpServlet {
private JSONObject cloneRecord(String newpolicyName, String oldScope, String removeoldPolicyExtension, String newScope, String removenewPolicyExtension, PolicyEntity entity, String userId) throws ServletException{
FileWriter fw = null;
- String queryEntityName = null;
+ String queryEntityName;
PolicyController controller = getPolicyControllerInstance();
PolicyEntity cloneEntity = new PolicyEntity();
cloneEntity.setPolicyName(newpolicyName);
@@ -1174,7 +1174,7 @@ public class PolicyManagerServlet extends HttpServlet {
path = path.substring(path.indexOf('/')+1);
String policyNamewithExtension = path.replace("/", File.separator);
String policyVersionName = policyNamewithExtension.replace(".xml", "");
- String query = "";
+ String query;
SimpleBindings policyParams = new SimpleBindings();
if(path.endsWith(".xml")){
policyNamewithoutExtension = policyVersionName.substring(0, policyVersionName.lastIndexOf('.'));
@@ -1413,7 +1413,7 @@ public class PolicyManagerServlet extends HttpServlet {
SimpleBindings peParams = new SimpleBindings();
peParams.put("split_1", split[1]);
peParams.put("split_0", split[0]);
- List<Object> queryData = null;
+ List<Object> queryData;
if(PolicyController.isjUnit()){
queryData = controller.getDataByQuery(query, null);
}else{