From 5ce2da3100483eb505876b428c7c490ff445ba5c Mon Sep 17 00:00:00 2001 From: JulienBe Date: Tue, 19 Jan 2021 10:54:52 +0100 Subject: Remove dead code Remove unused variables Remove unnecessary statements Issue-ID: SDC-3428 Signed-off-by: JulienBe Change-Id: Iddc8ffdc141edd409d50f90c03cb6612f6ebf042 Signed-off-by: JulienBe --- .../sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java | 6 ++---- .../sdc/be/dao/janusgraph/JanusGraphGenericDao.java | 15 +++++---------- .../org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java | 6 ++---- 3 files changed, 9 insertions(+), 18 deletions(-) (limited to 'catalog-dao/src') diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java index 03c08baf92..503ae856ca 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java @@ -76,7 +76,6 @@ public class SdcSchemaBuilder { * @return true if the create operation was successful */ public boolean createSchema() { - boolean res = false; try(Cluster cluster = sdcSchemaUtils.createCluster(); Session session = cluster.connect()) { log.info("creating Schema for Cassandra."); @@ -99,12 +98,11 @@ public class SdcSchemaBuilder { Map> keyspaceMetadate = cassndraMetadata.get(keyspace.getKey()); createTables(keyspace.getValue(), keyspaceMetadate, session,metadataTablesStructure.get(keyspace.getKey())); } - res = true; + return true; } catch (Exception e) { log.error(EcompLoggerErrorCode.SCHEMA_ERROR, "creating Schema for Cassandra", "Cassandra", e.getLocalizedMessage()); - res = false; + return false; } - return res; } public boolean deleteSchema() { diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java index 2174c8d295..8d2f24e6fa 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java @@ -1257,8 +1257,6 @@ public class JanusGraphGenericDao { } private JanusGraphOperationStatus lockNode(String lockId) { - JanusGraphOperationStatus status = JanusGraphOperationStatus.OK; - GraphNodeLock lockNode = new GraphNodeLock(lockId); Either lockNodeNew = createNode(lockNode, GraphNodeLock.class); @@ -1271,19 +1269,17 @@ public class JanusGraphGenericDao { JanusGraph tGraph = graph.left().value(); Either vertex = getVertexByProperty(lockNode.getUniqueIdKey(), lockNode.getUniqueId()); if (vertex.isLeft()) { - status = relockNode(lockNode, lockNodeNew, tGraph, vertex); + return relockNode(lockNode, lockNodeNew, tGraph, vertex); } else { - status = vertex.right().value(); + return vertex.right().value(); } } else { - status = graph.right().value(); + return graph.right().value(); } } - return status; } private JanusGraphOperationStatus relockNode(GraphNodeLock lockNode, Either lockNodeNew, JanusGraph tGraph, Either vertex) { - JanusGraphOperationStatus status = JanusGraphOperationStatus.OK; Long time = vertex.left().value().value(GraphPropertiesDictionary.CREATION_DATE.getProperty()); Long lockTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphLockTimeout(); if (time + lockTimeout * 1000 < System.currentTimeMillis()) { @@ -1296,14 +1292,13 @@ public class JanusGraphGenericDao { } else { log.debug("Failed Lock node for {} . Commit transacton for deleted previous vertex .", lockNode.getUniqueIdKey()); janusGraphClient.commit(); - status = checkLockError(lockNode.getUniqueIdKey(), lockNodeNew); + return checkLockError(lockNode.getUniqueIdKey(), lockNodeNew); } } else { log.debug("Failed Lock node for {} rollback transacton", lockNode.getUniqueIdKey()); janusGraphClient.rollback(); - status = checkLockError(lockNode.getUniqueIdKey(), lockNodeNew); + return checkLockError(lockNode.getUniqueIdKey(), lockNodeNew); } - return status; } public Either>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class clazz, boolean withEdges) { diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java index 3624bb353c..729d3c57da 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java @@ -985,18 +985,16 @@ public class JanusGraphDao { public JanusGraphOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) { - JanusGraphOperationStatus result = null; Iterator prevEdgeIter = toVertex.edges(Direction.IN, prevLabel.name()); if (prevEdgeIter == null || !prevEdgeIter.hasNext()) { CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty())); - result = JanusGraphOperationStatus.NOT_FOUND; + return JanusGraphOperationStatus.NOT_FOUND; } else { - result = replaceEdgeLabel(fromVertex, toVertex, prevEdgeIter.next(), prevLabel, newLabel); + return replaceEdgeLabel(fromVertex, toVertex, prevEdgeIter.next(), prevLabel, newLabel); } - return result; } /** -- cgit 1.2.3-korg