aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIndrijeet kumar <indriku1@in.ibm.com>2020-04-01 19:11:29 +0530
committerTschaen, Brendan <ctschaen@att.com>2020-04-29 14:17:52 -0400
commit1f3a99d09b6da12dffdc1c5538caa611be2cd248 (patch)
tree98df75aca3851d5624e127b1decc83fdf0cf3d86
parent3eaa50b92a0040da739eed7e9d47d9f1362e11a0 (diff)
some code smells removed
some code smells removed Issue-ID: PORTAL-869 Change-Id: I54235879743bbd31fa3b12df5c527b876c66ea00 Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
-rw-r--r--music-core/src/main/java/org/onap/music/datastore/jsonobjects/JsonTable.java33
-rw-r--r--music-core/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java11
2 files changed, 29 insertions, 15 deletions
diff --git a/music-core/src/main/java/org/onap/music/datastore/jsonobjects/JsonTable.java b/music-core/src/main/java/org/onap/music/datastore/jsonobjects/JsonTable.java
index 0a277e08..0ba1a7ef 100644
--- a/music-core/src/main/java/org/onap/music/datastore/jsonobjects/JsonTable.java
+++ b/music-core/src/main/java/org/onap/music/datastore/jsonobjects/JsonTable.java
@@ -166,8 +166,10 @@ public class JsonTable {
if (entry.getKey().equals("PRIMARY KEY")) {
primaryKey = entry.getValue(); // replaces primaryKey
primaryKey = primaryKey.trim();
- } else {
- if (counter == 0 ) fieldsString.append("" + entry.getKey() + " " + entry.getValue() + "");
+ }
+ else {
+ if (counter == 0 )
+ fieldsString.append("" + entry.getKey() + " " + entry.getValue() + "");
else fieldsString.append("," + entry.getKey() + " " + entry.getValue() + "");
}
@@ -209,7 +211,8 @@ public class JsonTable {
clusterKey=clusterKey.substring(1);
}
clusterKey = clusterKey.trim();
- if (clusterKey.equals(",") ) clusterKey=""; // print error if needed ( ... ),)
+ if (clusterKey.equals(",") )
+ clusterKey=""; // print error if needed ( ... ),)
}
if (!(partitionKey.isEmpty() || clusterKey.isEmpty())
@@ -226,12 +229,16 @@ public class JsonTable {
}
- if (partitionKey.isEmpty() ) primaryKey="";
- else if (clusterKey.isEmpty() ) primaryKey=" (" + partitionKey + ")";
- else primaryKey=" (" + partitionKey + ")," + clusterKey;
+ if (partitionKey.isEmpty() )
+ primaryKey="";
+ else if (clusterKey.isEmpty() )
+ primaryKey=" (" + partitionKey + ")";
+ else
+ primaryKey=" (" + partitionKey + ")," + clusterKey;
- if (primaryKey != null) fieldsString.append(", PRIMARY KEY (" + primaryKey + " )");
+ if (primaryKey != null)
+ fieldsString.append(", PRIMARY KEY (" + primaryKey + " )");
} else { // end of length > 0
@@ -248,11 +255,15 @@ public class JsonTable {
Status.BAD_REQUEST.getStatusCode());
}
- if (partitionKey.isEmpty() ) primaryKey="";
- else if (clusterKey.isEmpty() ) primaryKey=" (" + partitionKey + ")";
- else primaryKey=" (" + partitionKey + ")," + clusterKey;
+ if (partitionKey.isEmpty() )
+ primaryKey="";
+ else if (clusterKey.isEmpty() )
+ primaryKey=" (" + partitionKey + ")";
+ else
+ primaryKey=" (" + partitionKey + ")," + clusterKey;
- if (primaryKey != null) fieldsString.append(", PRIMARY KEY (" + primaryKey + " )");
+ if (primaryKey != null)
+ fieldsString.append(", PRIMARY KEY (" + primaryKey + " )");
}
fieldsString.append(")");
diff --git a/music-core/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java b/music-core/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
index f1e0e08b..0c5d39c8 100644
--- a/music-core/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
+++ b/music-core/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
@@ -467,8 +467,10 @@ public class CassaLockStore {
}
public boolean checkForDeadlock(String keyspace, String table, String lockName, LockType locktype, String owner, boolean forAcquire) throws MusicServiceException, MusicQueryException {
- if (locktype.equals(LockType.READ)) return false;
- if (owner==null || owner.length()==0) return false;
+ if (locktype.equals(LockType.READ))
+ return false;
+ if (owner==null || owner.length()==0)
+ return false;
String lockTable = table_prepend_name + table;
PreparedQueryObject queryObject = new PreparedQueryObject();
@@ -487,7 +489,8 @@ public class CassaLockStore {
ddu.setExisting(row.getString("key"), row.getString("owner"), ("0".equals(row.getString("acquiretime")))?OwnershipType.CREATED:OwnershipType.ACQUIRED);
}
boolean deadlock = ddu.checkForDeadlock(lockName, owner, forAcquire?OwnershipType.ACQUIRED:OwnershipType.CREATED);
- if (deadlock) logger.warn("Deadlock detected when " + owner + " tried to create lock on " + keyspace + "." + lockTable + "." + lockName);
+ if (deadlock)
+ logger.warn("Deadlock detected when " + owner + " tried to create lock on " + keyspace + "." + lockTable + "." + lockName);
return deadlock;
}
@@ -516,7 +519,7 @@ public class CassaLockStore {
}
public ReturnType promoteLock(String keyspace, String table, String key, String lockRef)
- throws MusicLockingException, MusicServiceException, MusicQueryException {
+ throws MusicServiceException, MusicQueryException {
String lockqtable = table_prepend_name + table;
String selectQuery = "select * from " + keyspace + "." + lockqtable + " where key=?;";