aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java8
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java16
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java63
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java6
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java13
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java14
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java6
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java6
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java77
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java7
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java11
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java6
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java1
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java33
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java17
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/model/Roles.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyContainer.java17
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyItemSetChangeNotifier.java1
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java8
27 files changed, 161 insertions, 177 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
index 7ac9ca310..49eb80802 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
@@ -50,14 +50,14 @@ public class CheckPDP {
private static HashMap<String, String> pdpMap = null;
private static final Logger LOGGER = FlexLogger.getLogger(CheckPDP.class);
+ private CheckPDP(){
+ //default constructor
+ }
+
public static Map<String, String> getPdpMap() {
return pdpMap;
}
- public CheckPDP(){
- //default constructor
- }
-
public static boolean validateID(String id) {
// ReadFile
try {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
index a15eb5882..545143a22 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
@@ -47,27 +47,27 @@ public class PolicyAdapter {
return;
}
if(policyAdapter.getPolicyName().startsWith("Config_PM")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf("_"));
+ policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "ClosedLoop_PM";
}else if(policyAdapter.getPolicyName().startsWith("Config_Fault")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf("_"));
+ policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "ClosedLoop_Fault";
}else if(policyAdapter.getPolicyName().startsWith("Config_FW")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf("_"));
+ policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "Firewall Config";
}else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Raw")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf("_"));
+ policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "BRMS_Raw";
}else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Param")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf("_"));
+ policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "BRMS_Param";
}else if(policyAdapter.getPolicyName().startsWith("Config_MS")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf("_"));
+ policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "Micro Service";
}else if(policyAdapter.getPolicyName().startsWith("Action") || policyAdapter.getPolicyName().startsWith("Decision") ){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf("_"));
+ policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
}else{
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf("_"));
+ policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "Base";
}
if (policyNameValue != null) {
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 2c67b451e..91f82932e 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
@@ -103,7 +103,7 @@ public class PolicyManagerServlet extends HttpServlet {
return policyController;
}
- public synchronized static void setPolicyController(PolicyController policyController) {
+ public static synchronized void setPolicyController(PolicyController policyController) {
PolicyManagerServlet.policyController = policyController;
}
@@ -375,8 +375,8 @@ public class PolicyManagerServlet extends HttpServlet {
if(policyList!= null){
for(int i = 0; i < policyList.length(); i++){
String policyName = policyList.get(i).toString().replace(".xml", "");
- String version = policyName.substring(policyName.lastIndexOf(".")+1);
- policyName = policyName.substring(0, policyName.lastIndexOf(".")).replace(".", File.separator);
+ String version = policyName.substring(policyName.lastIndexOf('.')+1);
+ policyName = policyName.substring(0, policyName.lastIndexOf('.')).replace(".", File.separator);
if(policyName.contains("\\")){
policyName = policyName.replace("\\", "\\\\");
}
@@ -450,9 +450,9 @@ public class PolicyManagerServlet extends HttpServlet {
String policyName;
String removeExtension = path.replace(".xml", "");
if(path.startsWith("/")){
- policyName = removeExtension.substring(1, removeExtension.lastIndexOf("."));
+ policyName = removeExtension.substring(1, removeExtension.lastIndexOf('.'));
}else{
- policyName = removeExtension.substring(0, removeExtension.lastIndexOf("."));
+ policyName = removeExtension.substring(0, removeExtension.lastIndexOf('.'));
}
String activePolicy = null;
@@ -520,7 +520,7 @@ public class PolicyManagerServlet extends HttpServlet {
String policyName = null;
if(path.startsWith("/")){
path = path.substring(1);
- policyName = path.substring(path.lastIndexOf("/") +1);
+ policyName = path.substring(path.lastIndexOf('/') +1);
path = path.replace("/", ".");
}else{
path = path.replace("/", ".");
@@ -657,7 +657,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
}else{
try{
- String scopeName = path.substring(path.indexOf("/") +1);
+ String scopeName = path.substring(path.indexOf('/') +1);
activePolicyList(scopeName, resultList, roles, scopes, onlyFolders);
} catch (Exception ex) {
LOGGER.error("Error Occured While reading Policy Files List"+ex );
@@ -793,8 +793,8 @@ public class PolicyManagerServlet extends HttpServlet {
String userId = UserUtils.getUserSession(request).getOrgUserId();
String oldPath = params.getString("path");
String newPath = params.getString("newPath");
- oldPath = oldPath.substring(oldPath.indexOf("/")+1);
- newPath = newPath.substring(newPath.indexOf("/")+1);
+ oldPath = oldPath.substring(oldPath.indexOf('/')+1);
+ newPath = newPath.substring(newPath.indexOf('/')+1);
if(oldPath.endsWith(".xml")){
JSONObject result = policyRename(oldPath, newPath, userId);
if(!(Boolean)(result.getJSONObject("result").get("success"))){
@@ -826,7 +826,7 @@ public class PolicyManagerServlet extends HttpServlet {
if(!(Boolean)(result.getJSONObject("result").get("success"))){
isActive = true;
policyActiveInPDP.add(policyOldPath);
- String scope = policyOldPath.substring(0, policyOldPath.lastIndexOf("/"));
+ String scope = policyOldPath.substring(0, policyOldPath.lastIndexOf('/'));
scopeOfPolicyActiveInPDP.add(scope.replace("/", File.separator));
}
}
@@ -837,7 +837,7 @@ public class PolicyManagerServlet extends HttpServlet {
UserInfo userInfo = new UserInfo();
userInfo.setUserLoginId(userId);
- if(policyActiveInPDP.size() == 0){
+ if(policyActiveInPDP.isEmpty()){
renameScope(scopesList, scopeName, newScopeName, controller);
}else if(rename){
renameScope(scopesList, scopeName, newScopeName, controller);
@@ -879,10 +879,10 @@ public class PolicyManagerServlet extends HttpServlet {
PolicyController controller = getPolicyControllerInstance();
String policyVersionName = newPath.replace(".xml", "");
- String policyName = policyVersionName.substring(0, policyVersionName.lastIndexOf(".")).replace("/", File.separator);
+ String policyName = policyVersionName.substring(0, policyVersionName.lastIndexOf('.')).replace("/", File.separator);
String oldpolicyVersionName = oldPath.replace(".xml", "");
- String oldpolicyName = oldpolicyVersionName.substring(0, oldpolicyVersionName.lastIndexOf(".")).replace("/", File.separator);
+ String oldpolicyName = oldpolicyVersionName.substring(0, oldpolicyVersionName.lastIndexOf('.')).replace("/", File.separator);
String newpolicyName = newPath.replace("/", ".");
String newPolicyCheck = newpolicyName;
@@ -918,7 +918,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
//Query the Policy Entity with oldPolicy Name
- String policyEntityCheck = oldPolicySplit[1].substring(0, oldPolicySplit[1].indexOf("."));
+ String policyEntityCheck = oldPolicySplit[1].substring(0, oldPolicySplit[1].indexOf('.'));
String oldpolicyEntityquery = "FROM PolicyEntity where policyName like :policyEntityCheck and scope = :oldPolicySplit_0";
SimpleBindings params = new SimpleBindings();
params.put("policyEntityCheck", policyEntityCheck + "%");
@@ -939,7 +939,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
groupQuery = groupQuery + ")";
List<Object> groupEntityData = controller.getDataByQuery(groupQuery, geParams);
- if(groupEntityData.size() > 0){
+ if(! groupEntityData.isEmpty()){
return error("Policy rename failed. Since the policy or its version is active in PDP Groups.");
}
for(int i=0; i<oldEntityData.size(); i++){
@@ -967,8 +967,8 @@ public class PolicyManagerServlet extends HttpServlet {
String oldPolicyNameWithoutExtension = removeoldPolicyExtension;
String newPolicyNameWithoutExtension = removenewPolicyExtension;
if(removeoldPolicyExtension.endsWith(".xml")){
- oldPolicyNameWithoutExtension = oldPolicyNameWithoutExtension.substring(0, oldPolicyNameWithoutExtension.indexOf("."));
- newPolicyNameWithoutExtension = newPolicyNameWithoutExtension.substring(0, newPolicyNameWithoutExtension.indexOf("."));
+ oldPolicyNameWithoutExtension = oldPolicyNameWithoutExtension.substring(0, oldPolicyNameWithoutExtension.indexOf('.'));
+ newPolicyNameWithoutExtension = newPolicyNameWithoutExtension.substring(0, newPolicyNameWithoutExtension.indexOf('.'));
}
entity.setPolicyName(entity.getPolicyName().replace(oldPolicyNameWithoutExtension, newPolicyNameWithoutExtension));
entity.setPolicyData(entity.getPolicyData().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
@@ -1090,12 +1090,12 @@ public class PolicyManagerServlet extends HttpServlet {
String userId = UserUtils.getUserSession(request).getOrgUserId();
String oldPath = params.getString("path");
String newPath = params.getString("newPath");
- oldPath = oldPath.substring(oldPath.indexOf("/")+1);
- newPath = newPath.substring(newPath.indexOf("/")+1);
+ oldPath = oldPath.substring(oldPath.indexOf('/')+1);
+ newPath = newPath.substring(newPath.indexOf('/')+1);
String policyVersionName = newPath.replace(".xml", "");
- String version = policyVersionName.substring(policyVersionName.indexOf(".")+1);
- String policyName = policyVersionName.substring(0, policyVersionName.lastIndexOf(".")).replace("/", File.separator);
+ String version = policyVersionName.substring(policyVersionName.indexOf('.')+1);
+ String policyName = policyVersionName.substring(0, policyVersionName.lastIndexOf('.')).replace("/", File.separator);
String newpolicyName = newPath.replace("/", ".");
@@ -1184,13 +1184,13 @@ public class PolicyManagerServlet extends HttpServlet {
if(params.has("deleteVersion")){
deleteVersion = params.getString("deleteVersion");
}
- path = path.substring(path.indexOf("/")+1);
+ path = path.substring(path.indexOf('/')+1);
String policyNamewithExtension = path.replace("/", File.separator);
String policyVersionName = policyNamewithExtension.replace(".xml", "");
String query = "";
SimpleBindings policyParams = new SimpleBindings();
if(path.endsWith(".xml")){
- policyNamewithoutExtension = policyVersionName.substring(0, policyVersionName.lastIndexOf("."));
+ policyNamewithoutExtension = policyVersionName.substring(0, policyVersionName.lastIndexOf('.'));
policyNamewithoutExtension = policyNamewithoutExtension.replace(File.separator, ".");
String splitPolicyName = null;
if(policyNamewithoutExtension.contains("Config_")){
@@ -1216,14 +1216,13 @@ public class PolicyManagerServlet extends HttpServlet {
boolean pdpCheck = false;
if(path.endsWith(".xml")){
policyNamewithoutExtension = policyNamewithoutExtension.replace(".", File.separator);
- int version = Integer.parseInt(policyVersionName.substring(policyVersionName.indexOf(".")+1));
+ int version = Integer.parseInt(policyVersionName.substring(policyVersionName.indexOf('.')+1));
if("ALL".equals(deleteVersion)){
if(!policyEntityobjects.isEmpty()){
for(Object object : policyEntityobjects){
policyEntity = (PolicyEntity) object;
String groupEntityquery = "from PolicyGroupEntity where policyid ='"+policyEntity.getPolicyId()+"'";
SimpleBindings pgeParams = new SimpleBindings();
- //pgeParams.put("policyIdValue", policyEntity.getPolicyId());
List<Object> groupobject = controller.getDataByQuery(groupEntityquery, pgeParams);
if(!groupobject.isEmpty()){
pdpCheck = true;
@@ -1252,7 +1251,7 @@ public class PolicyManagerServlet extends HttpServlet {
if(pdpCheck){
//Delete from policyVersion table
String getActivePDPPolicyVersion = activePolicyName.replace(".xml", "");
- getActivePDPPolicyVersion = getActivePDPPolicyVersion.substring(getActivePDPPolicyVersion.lastIndexOf(".")+1);
+ getActivePDPPolicyVersion = getActivePDPPolicyVersion.substring(getActivePDPPolicyVersion.lastIndexOf('.')+1);
String policyVersionQuery = "update PolicyVersion set active_version='"+getActivePDPPolicyVersion+"' , highest_version='"+getActivePDPPolicyVersion+"' where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
if(policyVersionQuery != null){
controller.executeQuery(policyVersionQuery);
@@ -1303,7 +1302,7 @@ public class PolicyManagerServlet extends HttpServlet {
for(Object object : policyEntityobjects){
policyEntity = (PolicyEntity) object;
String policyEntityName = policyEntity.getPolicyName().replace(".xml", "");
- int policyEntityVersion = Integer.parseInt(policyEntityName.substring(policyEntityName.lastIndexOf(".")+1));
+ int policyEntityVersion = Integer.parseInt(policyEntityName.substring(policyEntityName.lastIndexOf('.')+1));
if(policyEntityVersion > highestVersion && policyEntityVersion != version){
highestVersion = policyEntityVersion;
}
@@ -1371,8 +1370,8 @@ public class PolicyManagerServlet extends HttpServlet {
//Add Active Policies List to PolicyVersionTable
for(int i =0; i < activePoliciesInPDP.size(); i++){
String activePDPPolicyName = activePoliciesInPDP.get(i).replace(".xml", "");
- int activePDPPolicyVersion = Integer.parseInt(activePDPPolicyName.substring(activePDPPolicyName.lastIndexOf(".")+1));
- activePDPPolicyName = activePDPPolicyName.substring(0, activePDPPolicyName.lastIndexOf(".")).replace(".", File.separator);
+ int activePDPPolicyVersion = Integer.parseInt(activePDPPolicyName.substring(activePDPPolicyName.lastIndexOf('.')+1));
+ activePDPPolicyName = activePDPPolicyName.substring(0, activePDPPolicyName.lastIndexOf('.')).replace(".", File.separator);
PolicyVersion insertactivePDPVersion = new PolicyVersion();
insertactivePDPVersion.setPolicyName(activePDPPolicyName);
insertactivePDPVersion.setHigherVersion(activePDPPolicyVersion);
@@ -1408,7 +1407,7 @@ public class PolicyManagerServlet extends HttpServlet {
String path = params.getString("path");
LOGGER.debug("editFile path: {}"+ path);
- String domain = path.substring(1, path.lastIndexOf("/"));
+ String domain = path.substring(1, path.lastIndexOf('/'));
domain = domain.replace("/", ".");
path = path.substring(1);
@@ -1452,8 +1451,8 @@ public class PolicyManagerServlet extends HttpServlet {
policyAdapter.setDomainDir(domain);
policyAdapter.setPolicyData(policy);
String policyName = path.replace(".xml", "");
- policyName = policyName.substring(0, policyName.lastIndexOf("."));
- policyAdapter.setPolicyName(policyName.substring(policyName.lastIndexOf(".")+1));
+ policyName = policyName.substring(0, policyName.lastIndexOf('.'));
+ policyAdapter.setPolicyName(policyName.substring(policyName.lastIndexOf('.')+1));
PolicyAdapter setpolicyAdapter = PolicyAdapter.getInstance();
setpolicyAdapter.configure(policyAdapter,entity);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
index 67d9c8813..36e94c2ca 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
@@ -109,14 +109,14 @@ public class PolicyNotificationMail{
String policyFileName = entityItem.getPolicyName();
String checkPolicyName = policyName;
if(checkPolicyName.endsWith(".xml") || checkPolicyName.contains(".")){
- checkPolicyName = checkPolicyName.substring(0, checkPolicyName.indexOf("."));
+ checkPolicyName = checkPolicyName.substring(0, checkPolicyName.indexOf('.'));
}
if(policyFileName.contains("/")){
- policyFileName = policyFileName.substring(0, policyFileName.indexOf("/"));
+ policyFileName = policyFileName.substring(0, policyFileName.indexOf('/'));
policyFileName = policyFileName.replace("/", File.separator);
}
if(policyFileName.contains("\\")){
- policyFileName = policyFileName.substring(0, policyFileName.indexOf("\\"));
+ policyFileName = policyFileName.substring(0, policyFileName.indexOf('\\'));
policyFileName = policyFileName.replace("\\", "\\\\");
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
index 64b88134b..672177d9b 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
@@ -131,7 +131,7 @@ public class PolicyRestController extends RestrictedBaseController{
policyData.setDomainDir(dirName + root.get(PolicyController.getPolicydata()).get(modal).get("name").toString().replace("\"", ""));
}
}else{
- String domain = root.get(PolicyController.getPolicydata()).get("model").get("name").toString();
+ String domain = root.get(PolicyController.getPolicydata()).get(modal).get("name").toString();
if(domain.contains("/")){
domain = domain.substring(0, domain.lastIndexOf('/')).replace("/", File.separator);
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
index 234d28f10..40917bc81 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
@@ -139,7 +139,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
@Override
public void newGroup(String name, String description)
- throws PAPException, NullPointerException {
+ throws PAPException {
String escapedName = null;
String escapedDescription = null;
try {
@@ -190,7 +190,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
@Override
public void removeGroup(OnapPDPGroup group, OnapPDPGroup newGroup)
- throws PAPException, NullPointerException {
+ throws PAPException {
String moveToGroupString = null;
if (newGroup != null) {
moveToGroupString = "movePDPsToGroupId=" + newGroup.getId();
@@ -214,8 +214,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
}
@Override
- public void newPDP(String id, OnapPDPGroup group, String name, String description, int jmxport) throws PAPException,
- NullPointerException {
+ public void newPDP(String id, OnapPDPGroup group, String name, String description, int jmxport) throws PAPException {
StdPDP newPDP = new StdPDP(id, name, description, jmxport);
sendToPAP("PUT", newPDP, null, null, groupID + group.getId(), "pdpId=" + id);
return;
@@ -467,10 +466,10 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
final CollectionType javaType =
mapper.getTypeFactory().constructCollectionType(collectionTypeClass, responseContentClass);
- return (Object)mapper.readValue(json, javaType);
+ return mapper.readValue(json, javaType);
} else {
// single value object expected
- return (Object)mapper.readValue(json, responseContentClass);
+ return mapper.readValue(json, responseContentClass);
}
}
@@ -481,7 +480,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
LOGGER.error("No Location header to redirect to when response code="+connection.getResponseCode());
throw new IOException("No redirect Location header when response code="+connection.getResponseCode());
}
- int qIndex = newURL.indexOf("?");
+ int qIndex = newURL.indexOf('?');
if (qIndex > 0) {
newURL = newURL.substring(0, qIndex);
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
index 7c60ecfdf..aa9ec7ab9 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
@@ -131,7 +131,7 @@ public class HumanPolicyComponent{
return null;
}
- private static String processPolicy() throws IllegalArgumentException {
+ private static String processPolicy() {
if (LOGGER.isTraceEnabled())
LOGGER.trace("ENTER");
@@ -209,8 +209,7 @@ class HtmlProcessor extends SimpleCallback {
private final String policyName;
private final Object rootPolicyObject;
- public HtmlProcessor(File policyFile, Object policyObject)
- throws IllegalArgumentException {
+ public HtmlProcessor(File policyFile, Object policyObject) {
if (LOGGER.isTraceEnabled())
LOGGER.trace("ENTER");
@@ -409,7 +408,7 @@ class HtmlProcessor extends SimpleCallback {
if (policySet.getTarget() == null ||
policySet.getTarget().getAnyOf() == null ||
- policySet.getTarget().getAnyOf().size() <= 0) {
+ policySet.getTarget().getAnyOf().isEmpty()) {
htmlOut.println("<p>This policy set applies to all requests.</p>");
} else {
htmlOut.print("<p>");
@@ -494,7 +493,7 @@ class HtmlProcessor extends SimpleCallback {
if (policy.getTarget() == null ||
policy.getTarget().getAnyOf() == null ||
- policy.getTarget().getAnyOf().size() <= 0) {
+ policy.getTarget().getAnyOf().isEmpty()) {
htmlOut.println("<p>This policy applies to all requests.</p>");
} else {
htmlOut.print("<p>");
@@ -566,7 +565,7 @@ class HtmlProcessor extends SimpleCallback {
if (rule.getTarget() == null ||
rule.getTarget().getAnyOf() == null ||
- rule.getTarget().getAnyOf().size() <= 0) {
+ rule.getTarget().getAnyOf().isEmpty()) {
htmlOut.print(" for all requests");
} else {
List<AnyOfType> anyOf_s = rule.getTarget().getAnyOf();
@@ -855,7 +854,7 @@ class HtmlProcessor extends SimpleCallback {
}
List<JAXBElement<?>> exps = apply.getExpression();
- if (exps == null || exps.size() == 0)
+ if (exps == null || exps.isEmpty())
return "";
else {
String forResult = "";
@@ -865,7 +864,6 @@ class HtmlProcessor extends SimpleCallback {
LOGGER.debug("one-and-only children: " + v);
}
if (v != null) {
- // C: return stringifyExpression(v, result);
forResult += stringifyExpression(v);
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java
index 2f3c91476..88cb2e265 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java
@@ -77,7 +77,7 @@ public class ActionPolicyController extends RestrictedBaseController {
PolicyType policy = (PolicyType) policyData;
policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
String policyNameValue = policyAdapter.getPolicyName()
- .substring(policyAdapter.getPolicyName().indexOf("_") + 1);
+ .substring(policyAdapter.getPolicyName().indexOf('_') + 1);
policyAdapter.setPolicyName(policyNameValue);
String description = "";
try {
@@ -210,7 +210,7 @@ public class ActionPolicyController 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(actionApply.getFunctionId())) {
@@ -231,7 +231,7 @@ public class ActionPolicyController extends RestrictedBaseController {
}
private void prePopulateRuleAlgorithms(int index, ApplyType actionApply, List<JAXBElement<?>> jaxbActionTypes) {
- Map<String, String> ruleMap = new HashMap<String, String>();
+ Map<String, String> ruleMap = new HashMap<>();
ruleMap.put("id", "A" + (index + 1));
// Populate combo box
Map<String, String> dropDownMap = PolicyController.getDropDownMap();
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java
index 50b9d6923..9ade81d17 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java
@@ -120,7 +120,7 @@ public class AutoPushController extends RestrictedBaseController{
try{
Set<String> scopes = null;
List<String> roles = null;
- data = new ArrayList<Object>();
+ data = new ArrayList<>();
String userId = UserUtils.getUserSession(request).getOrgUserId();
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
@@ -230,7 +230,7 @@ public class AutoPushController extends RestrictedBaseController{
String id = name;
if (id.endsWith(".xml")) {
id = id.replace(".xml", "");
- id = id.substring(0, id.lastIndexOf("."));
+ id = id.substring(0, id.lastIndexOf('.'));
}
// Default policy to be Root policy; user can change to deferred
@@ -348,7 +348,7 @@ public class AutoPushController extends RestrictedBaseController{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- StdPDPGroup group = (StdPDPGroup)mapper.readValue(root.get("activePdpGroup").toString(), StdPDPGroup.class);
+ StdPDPGroup group = mapper.readValue(root.get("activePdpGroup").toString(), StdPDPGroup.class);
JsonNode removePolicyData = root.get("data");
String userId = UserUtils.getUserSession(request).getOrgUserId();
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java
index 33c58837e..e578d9108 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java
@@ -131,7 +131,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
StringBuilder params = new StringBuilder("");
Boolean flag = false;
Boolean comment = false;
- String lines[] = rule.split("\n");
+ String[] lines = rule.split("\n");
for(String line : lines){
if (line.isEmpty() || line.startsWith("//")) {
continue;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java
index b08761b84..e93fbf4e5 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java
@@ -57,7 +57,7 @@ public class CreateBRMSRawController{
@SuppressWarnings("unchecked")
public void prePopulateBRMSRawPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- attributeList = new ArrayList<Object>();
+ attributeList = new ArrayList<>();
if (policyAdapter.getPolicyData() instanceof PolicyType) {
PolicyType policy = (PolicyType) policyAdapter.getPolicyData();
policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
@@ -89,7 +89,7 @@ public class CreateBRMSRawController{
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(",")));
+ ArrayList<String> dependencies = new ArrayList<>(Arrays.asList(attributeAssignment.getAttributeId().replace("dependencies:", "").split(",")));
if(dependencies.contains("")){
dependencies.remove("");
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
index a40b48aa2..e9a121b97 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
@@ -740,7 +740,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
}
- if(constraints!=null &&constraints.isEmpty()==false){
+ if(constraints!=null && ! constraints.isEmpty()){
//List handling.
listBuffer.append(keySetString.toUpperCase()+"=[");
for(String str:constraints){
@@ -833,16 +833,16 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
String presKey = null;
for(String key: element.keySet()){
if(key.contains(".")){
- presKey = key.substring(0,key.indexOf("."));
+ presKey = key.substring(0,key.indexOf('.'));
}else if(key.contains("@")){
- presKey = key.substring(0,key.indexOf("@"));
+ presKey = key.substring(0,key.indexOf('@'));
}else{
presKey = key;
}
// first check if we are different from old.
LOGGER.info(key+"\n");
if(jsonArray!=null && jsonArray.length()>0 && key.contains("@") && !key.contains(".") && oldValue!=null){
- if(!oldValue.equals(key.substring(0,key.indexOf("@")))){
+ if(!oldValue.equals(key.substring(0,key.indexOf('@')))){
jsonResult.put(oldValue, jsonArray);
jsonArray = new JSONArray();
}
@@ -856,55 +856,55 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
//
if(key.contains(".")){
if(nodeKey==null){
- nodeKey = key.substring(0,key.indexOf("."));
+ nodeKey = key.substring(0,key.indexOf('.'));
}
- if(nodeKey.equals(key.substring(0,key.indexOf(".")))){
- node.put(key.substring(key.indexOf(".")+1), element.get(key));
+ if(nodeKey.equals(key.substring(0,key.indexOf('.')))){
+ node.put(key.substring(key.indexOf('.')+1), element.get(key));
}else{
if(node.size()!=0){
if(nodeKey.contains("@")){
if(arryKey==null){
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
if(nodeKey.endsWith("@0")){
isArray = true;
jsonArray = new JSONArray();
}
- if(jsonArray != null && 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("@")))) || !key.contains("@")){
+ if((key.contains("@") && !arryKey.equals(key.substring(0,nodeKey.indexOf('@')))) || !key.contains("@")){
jsonResult.put(arryKey, jsonArray);
jsonArray = new JSONArray();
}
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}else{
isArray = false;
jsonResult.put(nodeKey, decodeContent(node));
}
node = nodeFactory.objectNode();
}
- nodeKey = key.substring(0,key.indexOf("."));
+ nodeKey = key.substring(0,key.indexOf('.'));
if(nodeKey.contains("@")){
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
- node.put(key.substring(key.indexOf(".")+1), element.get(key));
+ node.put(key.substring(key.indexOf('.')+1), element.get(key));
}
}else if(node.size()!=0){
if(nodeKey.contains("@")){
if(arryKey==null){
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
if(nodeKey.endsWith("@0")){
isArray = true;
jsonArray = new JSONArray();
}
- if(jsonArray != null && 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);
jsonArray = new JSONArray();
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}else{
isArray = false;
jsonResult.put(nodeKey, decodeContent(node));
@@ -920,18 +920,18 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
if(isArray){
if(oldValue==null){
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}
if(oldValue!=prevKey){
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}
- if(oldValue.equals(key.substring(0,key.indexOf("@")))){
+ if(oldValue.equals(key.substring(0,key.indexOf('@')))){
jsonArray.put(element.get(key));
}else{
jsonResult.put(oldValue, jsonArray);
jsonArray = new JSONArray();
}
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}else{
jsonResult.put(key, element.get(key));
}
@@ -946,18 +946,18 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
if(isArray){
if(oldValue==null){
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}
if(oldValue!=prevKey){
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}
- if(oldValue.equals(key.substring(0,key.indexOf("@")))){
+ if(oldValue.equals(key.substring(0,key.indexOf('@')))){
jsonArray.put(element.get(key));
}else{
jsonResult.put(oldValue, jsonArray);
jsonArray = new JSONArray();
}
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}else{
jsonResult.put(key, element.get(key));
}
@@ -969,7 +969,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
jsonArray = new JSONArray();
}
if(arryKey==null){
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
jsonArray.put(decodeContent(node));
jsonResult.put(arryKey, jsonArray);
@@ -991,10 +991,10 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
JsonNode root = mapper.readTree(request.getReader());
String value = root.get("policyData").toString().replaceAll("^\"|\"$", "");
- String servicename = value.toString().split("-v")[0];
+ String servicename = value.split("-v")[0];
String version = null;
- if (value.toString().contains("-v")){
- version = value.toString().split("-v")[1];
+ if (value.contains("-v")){
+ version = value.split("-v")[1];
}
MicroServiceModels returnModel = getAttributeObject(servicename, version);
@@ -1510,12 +1510,12 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
for (Entry<String, String> entryRef : attributesRefMap.entrySet()) {
key = entryRef.getKey();
- value = entryRef.getValue().toString();
+ value = entryRef.getValue();
attribute.put(key, value);
}
for (Entry<String, String> entryList : attributesListRefMap.entrySet()) {
key = entryList.getKey();
- value = entryList.getValue().toString();
+ value = entryList.getValue();
attribute.put(key, value);
}
for (Entry<String, LinkedList<String>> arrayList : arrayTextList.entrySet()){
@@ -1557,18 +1557,18 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
IOUtils.copy(item.getInputStream(), outputStream);
outputStream.close();
this.newFile = file.toString();
- this.newModel.setModelName(this.newFile.toString().split("-v")[0]);
+ this.newModel.setModelName(this.newFile.split("-v")[0]);
- if (this.newFile.toString().contains("-v")){
+ if (this.newFile.contains("-v")){
if (item.getName().endsWith(".zip")){
- this.newModel.setVersion(this.newFile.toString().split("-v")[1].replace(".zip", ""));
+ this.newModel.setVersion(this.newFile.split("-v")[1].replace(".zip", ""));
zip = true;
}else if(item.getName().endsWith(".yml")){
- this.newModel.setVersion(this.newFile.toString().split("-v")[1].replace(".yml", ""));
+ this.newModel.setVersion(this.newFile.split("-v")[1].replace(".yml", ""));
yml = true;
}
else {
- this.newModel.setVersion(this.newFile.toString().split("-v")[1].replace(".xmi", ""));
+ this.newModel.setVersion(this.newFile.split("-v")[1].replace(".xmi", ""));
}
}
}catch(Exception e){
@@ -1598,14 +1598,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
if (zip){
extractFolder(this.newFile);
fileList = listModelFiles(this.directory);
- }else if (yml==true){
+ }else if (yml){
parseTosca(this.newFile);
}else {
File file = new File(this.newFile);
fileList.add(file);
}
String modelType= "";
- if(yml==false){
+ if(! yml){
modelType="xmi";
//Process Main Model file first
classMap = new HashMap<>();
@@ -1633,7 +1633,6 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
msAttributes.setSubClass(this.retmap);
HashMap<String, String> returnReferenceList =new HashMap<>();
- //String[] referenceArray=this.referenceAttributes.split("=");
returnReferenceList.put(className, this.referenceAttributes);
msAttributes.setRefAttribute(returnReferenceList);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
index a4b758924..5b34db455 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
@@ -548,7 +548,6 @@ public class CreateFirewallController extends RestrictedBaseController {
for (int tl = 0 ; tl< termCollectorList.size(); tl++) {
expandableList.add(termCollectorList.get(tl));
Term targetTerm = new Term();
- //targetSl= new ServiceListJson();
targetTerm.setRuleName(termCollectorList.get(tl));
List<Object> termListData = commonClassDao.getData(TermList.class);
for (int j =0; j < termListData.size(); j++) {
@@ -882,7 +881,6 @@ public class CreateFirewallController extends RestrictedBaseController {
addressMembers.setName(groupString);
addrMembersList.add(addressMembers);
//Expand the group Name
- PrefixIPList expandGroupPrefix;
addressMembersJson= new AddressMembers();
valueDesc= mapping (groupString);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java
index dba79e1bb..901b5929f 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java
@@ -415,16 +415,15 @@ public class DashboardController extends RestrictedBaseController{
}
private static String urnPolicyID(String line){
- String[] splitLine = line.toString().split("=");
+ String[] splitLine = line.split("=");
String removeSpaces = splitLine[0].replaceAll("\\s+", "");
return removeSpaces.replace("{", "");
}
private static Integer countPolicyID(String line){
- String[] splitLine = line.toString().split("=");
+ String[] splitLine = line.split("=");
String sCount = splitLine[1].replace("}", "");
- int intCount = Integer.parseInt(sCount);
- return intCount;
+ return Integer.parseInt(sCount);
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java
index 8427797e8..46d24b207 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java
@@ -60,7 +60,9 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
public class DecisionPolicyController extends RestrictedBaseController {
private static final Logger policyLogger = FlexLogger.getLogger(DecisionPolicyController.class);
- public DecisionPolicyController(){}
+ public DecisionPolicyController(){
+ // This constructor is empty
+ }
protected PolicyRestAdapter policyAdapter = null;
private ArrayList<Object> attributeList;
@@ -186,12 +188,12 @@ public class DecisionPolicyController extends RestrictedBaseController {
// get the condition data under the rule for rule Algorithms.
if(((RuleType) object).getEffect().equals(EffectType.DENY)) {
if(((RuleType) object).getAdviceExpressions()!=null){
- if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().toString().equalsIgnoreCase("AAF")){
+ if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().equalsIgnoreCase("AAF")){
policyAdapter.setRuleProvider("AAF");
break;
- }else if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().toString().equalsIgnoreCase("GUARD_YAML")){
+ }else if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().equalsIgnoreCase("GUARD_YAML")){
policyAdapter.setRuleProvider("GUARD_YAML");
- }else if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().toString().equalsIgnoreCase("GUARD_BL_YAML")){
+ }else if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().equalsIgnoreCase("GUARD_BL_YAML")){
policyAdapter.setRuleProvider("GUARD_BL_YAML");
}
}else{
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
index c0344d337..e5ed3122e 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
@@ -294,7 +294,7 @@ public class PDPController extends RestrictedBaseController {
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);
+ PdpData pdpGroupData = mapper.readValue(root.get("pdpInGroup").toString(), PdpData.class);
StdPDPGroup activeGroupData = mapper.readValue(root.get("activePDP").toString(), StdPDPGroup.class);
String userId = UserUtils.getUserSession(request).getOrgUserId();
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
index bd8c8287c..46510ba4f 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
@@ -447,7 +447,7 @@ public class PolicyController extends RestrictedBaseController {
for(Object entity : policyEntity){
PolicyEntity pEntity = (PolicyEntity) entity;
String removeExtension = pEntity.getPolicyName().replace(".xml", "");
- String version = removeExtension.substring(removeExtension.lastIndexOf(".")+1);
+ String version = removeExtension.substring(removeExtension.lastIndexOf('.')+1);
av.add(version);
}
if(policyName.contains("/")){
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java
index 78a8c5ad1..5978f145e 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java
@@ -195,7 +195,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
- String successMap = file.toString().substring(file.toString().lastIndexOf("webapps")+8);
+ String successMap = file.substring(file.lastIndexOf("webapps")+8);
String responseString = mapper.writeValueAsString(successMap);
JSONObject j = new JSONObject("{data: " + responseString + "}");
out.write(j.toString());
@@ -316,7 +316,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
}else{
//1. if Role contains admin, then check if parent scope has role admin, if not don't create a scope and add to list.
if(roles.contains(ADMIN)){
- String scopeCheck = scope.substring(0, scope.lastIndexOf("."));
+ String scopeCheck = scope.substring(0, scope.lastIndexOf('.'));
if(scopes.contains(scopeCheck)){
PolicyEditorScopes policyEditorScopeEntity = new PolicyEditorScopes();
policyEditorScopeEntity.setScopeName(scope);
@@ -383,8 +383,8 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
policyVersion = new PolicyVersion();
String policyName = policyEntity.getPolicyName().replace(".xml", "");
- int version = Integer.parseInt(policyName.substring(policyName.lastIndexOf(".")+1));
- policyName = policyName.substring(0, policyName.lastIndexOf("."));
+ int version = Integer.parseInt(policyName.substring(policyName.lastIndexOf('.')+1));
+ policyName = policyName.substring(0, policyName.lastIndexOf('.'));
policyVersion.setPolicyName(scope.replace(".", File.separator) + File.separator + policyName);
policyVersion.setActiveVersion(version);
@@ -400,7 +400,6 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
//return the column header name value
private String getCellHeaderName(Cell cell){
- String cellHeaderName = cell.getSheet().getRow(0).getCell(cell.getColumnIndex()).getRichStringCellValue().toString();
- return cellHeaderName;
+ return cell.getSheet().getRow(0).getCell(cell.getColumnIndex()).getRichStringCellValue().toString();
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java
index 798a39d4d..a30acc383 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java
@@ -142,7 +142,7 @@ class ReadScopes{
private int id;
private UserInfo loginId;
private String role;
- private ArrayList<String> scope;
+ private List<String> scope;
public int getId() {
return id;
@@ -162,10 +162,10 @@ class ReadScopes{
public void setRole(String role) {
this.role = role;
}
- public ArrayList<String> getScope() {
+ public List<String> getScope() {
return scope;
}
- public void setScope(ArrayList<String> scope) {
+ public void setScope(List<String> scope) {
this.scope = scope;
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
index 81db14c2f..b9eb5ed15 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
@@ -43,7 +43,6 @@ import org.onap.policy.rest.jpa.PolicyRoles;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
@Service("CommonClassDao")
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java
index c96da506f..1727f47c0 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java
@@ -75,7 +75,7 @@ public class SystemLogDbDaoImpl implements SystemLogDbDao {
@SuppressWarnings("unchecked")
@Override
public List<SystemLogDB> getSystemAlertData() {
- Session session = HibernateSession.getSession();;
+ Session session = HibernateSession.getSession();
Transaction tx = session.beginTransaction();
List<SystemLogDB> system = null;
try {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
index 3b3f11957..5952761eb 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
@@ -113,10 +113,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
}
public boolean isSupported(Object itemId) {
- if (itemId instanceof OnapPDPGroup) {
- return true;
- }
- return false;
+ return (itemId instanceof OnapPDPGroup);
}
public synchronized void refreshGroups() {
@@ -250,25 +247,25 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("containsId: " + itemId);
}
- if (this.isSupported(itemId) == false) {
+ if (! this.isSupported(itemId)) {
return false;
}
return this.groups.contains(itemId);
}
@Override
- public Object addItem() throws UnsupportedOperationException {
+ public Object addItem() {
throw new UnsupportedOperationException("PDP Container cannot add a given item.");
}
- public void addNewGroup(String name, String description) throws NullPointerException, PAPException {
+ public void addNewGroup(String name, String description) throws PAPException {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("addNewGroup " + name + " " + description);
}
this.papEngine.newGroup(name, description);
}
- public void addNewPDP(String id, OnapPDPGroup group, String name, String description, int jmxport) throws NullPointerException, PAPException {
+ public void addNewPDP(String id, OnapPDPGroup group, String name, String description, int jmxport) throws PAPException {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("addNewPDP " + id + " " + name + " " + description + " " + jmxport);
}
@@ -286,17 +283,17 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
}
@Override
- public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException {
+ public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) {
throw new UnsupportedOperationException("Cannot add a container property.");
}
@Override
- public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException {
+ public boolean removeContainerProperty(Object propertyId) {
throw new UnsupportedOperationException("Cannot remove a container property.");
}
@Override
- public boolean removeAllItems() throws UnsupportedOperationException {
+ public boolean removeAllItems() {
throw new UnsupportedOperationException("PDP Container cannot remove all items. You must have at least the Default group.");
}
@@ -310,7 +307,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
@Override
public Object nextItemId(Object itemId) {
- if (this.isSupported(itemId) == false) {
+ if (! this.isSupported(itemId)) {
return null;
}
int index = this.groups.indexOf(itemId);
@@ -337,7 +334,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
@Override
public Object prevItemId(Object itemId) {
- if (this.isSupported(itemId) == false) {
+ if (! this.isSupported(itemId)) {
return null;
}
int index = this.groups.indexOf(itemId);
@@ -403,7 +400,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
}
@Override
- public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException {
+ public Object addItemAfter(Object previousItemId) {
throw new UnsupportedOperationException("Cannot addItemAfter, there really is no real ordering.");
}
@@ -429,22 +426,22 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
}
@Override
- public Object addItemAt(int index) throws UnsupportedOperationException {
+ public Object addItemAt(int index) {
throw new UnsupportedOperationException("Cannot addItemAt");
}
@Override
- public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ public boolean removeItem(Object itemId) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("removeItem: " + itemId);
}
- if (this.isSupported(itemId) == false) {
+ if (! this.isSupported(itemId)) {
return false;
}
//
// You cannot remove the default group
//
- if ("Default".equals(((OnapPDPGroup) itemId).getId())) {
+ if (PROPERTY_DEFAULT.equals(((OnapPDPGroup) itemId).getId())) {
throw new UnsupportedOperationException("You can't remove the Default Group.");
}
//
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java
index a3e3e28ad..27fe71959 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java
@@ -166,8 +166,7 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
}
@Override
- public Object addItemAfter(Object previousItemId)
- throws UnsupportedOperationException {
+ public Object addItemAfter(Object previousItemId) {
return null;
}
@@ -221,13 +220,12 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
}
@Override
- public Object addItem() throws UnsupportedOperationException {
+ public Object addItem() {
throw new UnsupportedOperationException("Cannot add an empty policy.");
}
@Override
- public boolean removeItem(Object itemId)
- throws UnsupportedOperationException {
+ public boolean removeItem(Object itemId) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("removeItem: " + itemId);
}
@@ -249,18 +247,17 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
@Override
public boolean addContainerProperty(Object propertyId, Class<?> type,
- Object defaultValue) throws UnsupportedOperationException {
+ Object defaultValue) {
return false;
}
@Override
- public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException {
+ public boolean removeContainerProperty(Object propertyId) {
return false;
}
@Override
- public boolean removeAllItems() throws UnsupportedOperationException {
+ public boolean removeAllItems() {
return false;
}
@@ -292,7 +289,7 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
}
@Override
- public Object addItemAt(int index) throws UnsupportedOperationException {
+ public Object addItemAt(int index) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("addItemAt: " + index);
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/Roles.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/Roles.java
index 51e78d0e5..2f051f7b4 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/Roles.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/Roles.java
@@ -54,7 +54,7 @@ public class Roles implements Serializable{
private String role;
public Roles(){
-
+ // Empty constructor
}
public int getId() {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyContainer.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyContainer.java
index d014af031..08f477f38 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyContainer.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyContainer.java
@@ -37,18 +37,16 @@ public interface PolicyContainer extends Serializable{
public boolean containsId(Object itemId);
- public Object addItem() throws UnsupportedOperationException;
+ public Object addItem();
- public boolean removeItem(Object itemId)
- throws UnsupportedOperationException;
+ public boolean removeItem(Object itemId);
public boolean addContainerProperty(Object propertyId, Class<?> type,
- Object defaultValue) throws UnsupportedOperationException;
+ Object defaultValue);
- public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException;
+ public boolean removeContainerProperty(Object propertyId);
- public boolean removeAllItems() throws UnsupportedOperationException;
+ public boolean removeAllItems();
public interface Ordered extends PolicyContainer {
@@ -64,8 +62,7 @@ public interface PolicyContainer extends Serializable{
public boolean isLastId(Object itemId);
- public Object addItemAfter(Object previousItemId)
- throws UnsupportedOperationException;
+ public Object addItemAfter(Object previousItemId);
}
@@ -78,7 +75,7 @@ public interface PolicyContainer extends Serializable{
public List<?> getItemIds(int startIndex, int numberOfItems);
- public Object addItemAt(int index) throws UnsupportedOperationException;
+ public Object addItemAt(int index);
public interface ItemAddEvent extends ItemSetChangeEvent {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyItemSetChangeNotifier.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyItemSetChangeNotifier.java
index 92764aa4f..61b51cc92 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyItemSetChangeNotifier.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/PolicyItemSetChangeNotifier.java
@@ -37,6 +37,7 @@ public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChang
private PolicyContainer container = null;
public PolicyItemSetChangeNotifier() {
+ // Empty constructor
}
protected void setContainer(PolicyContainer c) {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java
index f3e72cb92..0fc293e5a 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java
@@ -56,6 +56,10 @@ import org.onap.policy.common.logging.flexlogger.Logger;
*/
public class XACMLPolicyWriterWithPapNotify{
private static final Logger LOGGER = FlexLogger.getLogger(XACMLPolicyWriterWithPapNotify.class);
+
+ private XACMLPolicyWriterWithPapNotify() {
+ // Add private constructor to hide the implicit public one
+ }
/**
* Helper static class that does the work to write a policy set to a file on disk and notify PAP
@@ -295,8 +299,6 @@ public class XACMLPolicyWriterWithPapNotify{
String encoding = encoder.encodeToString((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)+":"+XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)).getBytes(StandardCharsets.UTF_8));
HttpURLConnection connection = null;
UUID requestID = UUID.randomUUID();
- //loggingContext.setRequestID(requestID.toString());
- //loggingContext.transactionStarted();
String papUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
if(papUrl == null){
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE +
@@ -397,8 +399,6 @@ public class XACMLPolicyWriterWithPapNotify{
String encoding = encoder.encodeToString((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)+":"+XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)).getBytes(StandardCharsets.UTF_8));
HttpURLConnection connection = null;
UUID requestID = UUID.randomUUID();
- //loggingContext.setRequestID(requestID.toString());
- //loggingContext.transactionStarted();
URL url;
try {
url = new URL(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL)+"?policyToCreateUpdate="+ URLEncoder.encode(policyToCreateUpdate, "UTF-8"));