summaryrefslogtreecommitdiffstats
path: root/BRMSGateway
diff options
context:
space:
mode:
authorrama-huawei <rama.subba.reddy.s@huawei.com>2017-09-20 16:49:00 +0530
committerRama SubbaReddy <rama.subba.reddy.s@huawei.com>2017-09-21 12:36:39 +0000
commitd87fa780642ccad71006af55e21c7dcaee5c8385 (patch)
tree2b8e216f7d2926db5dc7babc77cb38916352d127 /BRMSGateway
parent24c50314f750c01ae2e37249f2053b30442ca82c (diff)
Used entrySet instead of keySet
Removed useless assignment to the local variables and useless parenthesis Moved string literal on the left side of the actual string comparison. Issue-ID: POLICY-239 Change-Id: Ie66c92dac548a17d73a976bf0bc57039fd99a5b6 Signed-off-by: rama-huawei <rama.subba.reddy.s@huawei.com>
Diffstat (limited to 'BRMSGateway')
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java3
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java34
2 files changed, 19 insertions, 18 deletions
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
index 43031861b..a11e8b4b7 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
@@ -95,7 +95,7 @@ public class BRMSHandler implements BackUpHandler{
}
}
}
- Boolean failureFlag = false;
+ Boolean failureFlag;
int i = 0;
do{
failureFlag = false;
@@ -118,6 +118,7 @@ public class BRMSHandler implements BackUpHandler{
* (non-Javadoc)
* @see org.onap.policy.utils.BackUpHandler#runOnNotification(org.onap.policy.api.PDPNotification)
*/
+ @Override
public void runOnNotification(PDPNotification notification){
if(notification.getNotificationType().equals(NotificationType.REMOVE)){
removedPolicies(notification.getRemovedPolicies());
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
index c923c3c34..6e8588acb 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
@@ -388,11 +388,11 @@ public class BRMSPush {
selectedName = responseAttributes.get(key);
}
// kmodule configurations
- else if (key.equals("kSessionName")) {
+ else if ("kSessionName".equals(key)) {
kSessionName = responseAttributes.get(key);
}
// Check User Specific values.
- if (key.equals("$controller:")) {
+ if ("$controller:".equals(key)) {
try {
PEDependency dependency = PolicyUtils.jsonStringToObject(responseAttributes.get(key),
PEDependency.class);
@@ -402,7 +402,7 @@ public class BRMSPush {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Controller: " + e);
}
- } else if (key.equals("$dependency$")) {
+ } else if ("$dependency$".equals(key)) {
String value = responseAttributes.get(key);
if (value.startsWith("[") && value.endsWith("]")) {
value = value.substring(1, value.length() - 1).trim();
@@ -500,7 +500,7 @@ public class BRMSPush {
List<?> pList = query.getResultList();
boolean createFlag = false;
BRMSPolicyInfo brmsPolicyInfo = new BRMSPolicyInfo();
- if (pList.size() > 0) {
+ if (!pList.isEmpty()) {
// Already exists.
brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
if (!brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {
@@ -514,7 +514,7 @@ public class BRMSPush {
query.setParameter("cn", controllerName);
List<?> bList = query.getResultList();
BRMSGroupInfo brmsGroupInfo = new BRMSGroupInfo();
- if (bList.size() > 0) {
+ if (!bList.isEmpty()) {
brmsGroupInfo = (BRMSGroupInfo) bList.get(0);
}
brmsPolicyInfo.setPolicyName(policyName);
@@ -528,7 +528,7 @@ public class BRMSPush {
private void syncProject(String selectedName) {
boolean projectExists = checkProject(selectedName);
if (projectExists) {
- String version = null;
+ String version;
version = getVersion(selectedName);
if (version == null) {
LOGGER.error("Error getting local version for the given Controller Name:" + selectedName
@@ -599,7 +599,6 @@ public class BRMSPush {
}
fos.close();
is.close();
- f = null;
LOGGER.info(fileName + " Created..");
}
}
@@ -641,7 +640,7 @@ public class BRMSPush {
private boolean checkRemoteSync(String selectedName, String version) {
List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, version);
- return (artifacts.size() == 0) ? false : true;
+ return artifacts.isEmpty() ? false : true;
}
private List<NexusArtifact> getArtifactFromNexus(String selectedName, String version) {
@@ -690,7 +689,7 @@ public class BRMSPush {
if (artifact != null) {
newVersion = incrementVersion(artifact.getVersion());
}
- if (newVersion.equals("0.1.0")) {
+ if ("0.1.0".equals(newVersion)) {
createFlag = true;
}
setVersion(newVersion, selectedName);
@@ -736,8 +735,9 @@ public class BRMSPush {
}
if (!modifiedGroups.isEmpty()) {
Boolean flag = false;
- for (String group : modifiedGroups.keySet()) {
+ for (Map.Entry<String, String> entry : modifiedGroups.entrySet()) {
InvocationResult result = null;
+ String group = entry.getKey();
try {
InvocationRequest request = new DefaultInvocationRequest();
setVersion(group);
@@ -761,7 +761,7 @@ public class BRMSPush {
if (createFlag) {
addNotification(group, "create");
} else {
- addNotification(group, modifiedGroups.get(group));
+ addNotification(group, entry.getValue());
}
flag = true;
} else {
@@ -795,7 +795,7 @@ public class BRMSPush {
return policyMap.get(name);
} else {
syncGroupInfo();
- return (policyMap.containsKey(name)) ? policyMap.get(name) : null;
+ return policyMap.containsKey(name) ? policyMap.get(name) : null;
}
}
@@ -869,7 +869,7 @@ public class BRMSPush {
pub.send("MyPartitionKey", message);
final List<?> stuck = pub.close(uebDelay, TimeUnit.SECONDS);
- if (stuck.size() > 0) {
+ if (!stuck.isEmpty()) {
LOGGER.error(stuck.size() + " messages unsent");
} else {
LOGGER.debug("Clean exit; Message Published on UEB : " + uebList + "for Topic: " + pubTopic);
@@ -1018,7 +1018,7 @@ public class BRMSPush {
}
private void readGroups(Properties config) throws PolicyException {
- String[] groupNames = null;
+ String[] groupNames;
if (!config.containsKey("groupNames") || config.getProperty("groupNames")==null){
throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE
+ "groupNames property is missing or empty from the property file ");
@@ -1069,7 +1069,7 @@ public class BRMSPush {
query.setParameter("cn", name);
List<?> groupList = query.getResultList();
BRMSGroupInfo brmsGroupInfo = null;
- if (groupList.size() > 0) {
+ if (!groupList.isEmpty()) {
LOGGER.info("Controller name already Existing in DB. Will be updating the DB Values" + name);
brmsGroupInfo = (BRMSGroupInfo) groupList.get(0);
}
@@ -1122,8 +1122,8 @@ public class BRMSPush {
Query query = em.createQuery("select b from BRMSPolicyInfo as b where b.policyName = :pn");
query.setParameter("pn", policyName);
List<?> pList = query.getResultList();
- BRMSPolicyInfo brmsPolicyInfo = new BRMSPolicyInfo();
- if (pList.size() > 0) {
+ BRMSPolicyInfo brmsPolicyInfo;
+ if (!pList.isEmpty()) {
// Already exists.
brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
if (brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {