diff options
author | Piotr Krysiak <piotr.krysiak@nokia.com> | 2018-07-19 09:07:10 +0200 |
---|---|---|
committer | Tal Gitelman <tg851x@intl.att.com> | 2018-08-06 10:19:04 +0000 |
commit | 04ff1b844c58f9f53558ff70594bf52ef6fba6ae (patch) | |
tree | f79b0037f37b5c2e7f2bfdf153d69f5c8b99fae9 /asdctool/src/main/java/org/openecomp | |
parent | c63a3402b0054642bfe07465278dc80246b0321b (diff) |
ASDC dead code removal
Issue-ID: SDC-1493
Change-Id: I74c1748eb2b1f478a0e44b07c174f95964fed667
Signed-off-by: Piotr Krysiak <piotr.krysiak@nokia.com>
Diffstat (limited to 'asdctool/src/main/java/org/openecomp')
7 files changed, 33 insertions, 199 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java index e13f40fe29..ff0f84787d 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java @@ -44,7 +44,6 @@ public class Utils { /* * ResponseFormat errorResponseWrapper, */int status, Object entity, Map<String, String> additionalHeaders) { - // int status = errorResponseWrapper.getStatus(); ResponseBuilder responseBuilder = Response.status(status); if (entity != null) { log.trace("returned entity is {}", entity.toString()); @@ -93,13 +92,10 @@ public class Utils { } } - // if (false == leftValue instanceof Map && false == leftValue - // instanceof List) { if (false == leftValue.equals(rightValue)) { log.trace("The value of key {} is differnet between properties. {} vs {}",key,leftValue,rightValue); return false; } - // } } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java index a4ee8d8a2c..9b45d93bc5 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java @@ -45,8 +45,19 @@ import org.openecomp.sdc.common.util.GeneralUtility; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; -import java.io.*; -import java.util.*; +import java.io.BufferedWriter; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; @org.springframework.stereotype.Component("artifactUuidFix") @@ -1325,61 +1336,6 @@ public class ArtifactUuidFix { return Either.left(vfModules); } - - /*public boolean manualFix() { - - Set<String> fixedIds = new HashSet<>(); - Component component; - String componentId = "86683566-20e8-4cc5-872d-12abca1d57f0";//"9f6a6976-18e3-488a-98a4-c1aade480739"; - Either<Resource, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaFullElement(componentId); - if (toscaElement.isRight()) { - log.info("Failed to fetch resources {} {}", componentId, toscaElement.right().value()); - - } - boolean res = generateToscaPerComponent(fixedIds, toscaElement.left().value()); - log.info("Fix component return res {} ", res); - titanDao.commit(); - - return res; - } - - - public boolean manualCheck() { - - Set<String> fixedIds = new HashSet<>(); - Component component; - String componentId = "86d50186-7b00-4bfc-abcb-9e4c6892f338";//"9f6a6976-18e3-488a-98a4-c1aade480739"; - Either<Service, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaFullElement(componentId); - if (toscaElement.isRight()) { - log.info("Failed to fetch resources {} {}", componentId, toscaElement.right().value()); - - } - boolean res = true; - try { - res = isProblematicService(toscaElement.left().value(), toscaElement.left().value().getName()); - if(res){ - List<Service> services = new ArrayList<>(); - services.add(toscaElement.left().value()); - this.fix(new ArrayList<Resource>(), services, null, null, null); - - Either<Service, StorageOperationStatus> toscaElementNew = toscaOperationFacade.getToscaFullElement(componentId); - if (toscaElement.isRight()) { - log.info("Failed to fetch resources {} {}", componentId, toscaElementNew.right().value()); - - } - res = isProblematicService(toscaElementNew.left().value(), toscaElementNew.left().value().getName()); - } - titanDao.commit(); - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - log.info("Fix component return res {} ", res); - - return res; -}*/ - } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java index 0ec7af4906..bcb6a0a283 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java @@ -21,7 +21,11 @@ package org.openecomp.sdc.asdctool.impl; import com.google.gson.Gson; -import com.thinkaurelius.titan.core.*; +import com.thinkaurelius.titan.core.TitanEdge; +import com.thinkaurelius.titan.core.TitanFactory; +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.core.TitanGraphQuery; +import com.thinkaurelius.titan.core.TitanVertex; import org.apache.commons.configuration.BaseConfiguration; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.tinkerpop.gremlin.structure.*; @@ -35,8 +39,20 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.common.log.wrappers.Logger; -import java.io.*; -import java.util.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; public class GraphMLConverter { @@ -154,7 +170,6 @@ public class GraphMLConverter { return false; } finally { if (graph != null) { - // graph.shutdown(); graph.close(); } } @@ -174,25 +189,18 @@ public class GraphMLConverter { String result = null; - // GraphMLWriter graphMLWriter = new GraphMLWriter(graph); - String outputFile = outputDirectory + File.separator + "exportGraph." + System.currentTimeMillis() + ".json"; OutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(outputFile)); - // GraphSONWriter.outputGraph(graph, outputFile); final GraphSONWriter.Builder builder = GraphSONWriter.build(); final GraphSONMapper mapper = newGraphSONMapper(graph); builder.mapper(mapper); final GraphSONWriter writer = builder.create(); writer.writeGraph(out, graph); - // GraphSONWriter create = GraphSONWriter.build(). create(); - // create.writeGraph(out, graph); - - // graph.commit(); graph.tx().commit(); result = outputFile; @@ -232,8 +240,6 @@ public class GraphMLConverter { private static GraphSONMapper newGraphSONMapper(final Graph graph) { final GraphSONMapper.Builder builder = graph.io(IoCore.graphson()).mapper(); - // Different failure with embedded type info. - // builder.embedTypes(true); return builder.create(); } @@ -271,11 +277,9 @@ public class GraphMLConverter { is = new BufferedInputStream(new FileInputStream(graphJsonFile)); System.out.println("Before importing file " + graphJsonFile); - // GraphSONReader.inputGraph(graph, graphJsonFile); GraphSONReader create = GraphSONReader.build().create(); create.readGraph(is, graph); - // graph.commit(); graph.tx().commit(); result = true; @@ -306,8 +310,6 @@ public class GraphMLConverter { String result = null; - // GraphMLWriter graphMLWriter = new GraphMLWriter(graph); - String outputFile = outputDirectory + File.separator + "exportGraph." + System.currentTimeMillis() + ".json"; OutputStream out = null; @@ -320,10 +322,7 @@ public class GraphMLConverter { Vertex vertexTo = null; Edge edge = null; - // Iterable<Edge> edges = graph.getEdges(); - // Iterable<Edge> edges = graph.query().edges(); Iterable<TitanEdge> edges = graph.query().edges(); - // Iterator<Edge> iterator = edges.iterator(); Iterator<TitanEdge> iterator = edges.iterator(); while (iterator.hasNext()) { @@ -331,8 +330,6 @@ public class GraphMLConverter { edge = iterator.next(); - // vertexFrom = edge.getVertex(Direction.OUT); - // vertexTo = edge.getVertex(Direction.IN); vertexFrom = edge.outVertex(); vertexTo = edge.inVertex(); @@ -341,35 +338,21 @@ public class GraphMLConverter { TitanGraph openGraph = Utils.openGraph(conf); TitanVertex addVertexFrom = openGraph.addVertex(); - // ElementHelper.setProperties(addVertexFrom, - // ElementHelper.getProperties(vertexFrom)); Utils.setProperties(addVertexFrom, Utils.getProperties(vertexFrom)); TitanVertex addVertexTo = openGraph.addVertex(); - // ElementHelper.setProperties(addVertexTo, - // ElementHelper.getProperties(vertexTo)); Utils.setProperties(addVertexTo, Utils.getProperties(vertexTo)); - // Edge addEdge = openGraph.addEdge(null, addVertexFrom, - // addVertexTo, edge.getLabel()); - - // Edge edge = tGraph.addEdge(null, - // fromV.left().value(), toV.left().value(), type); - Edge addEdge = addVertexFrom.addEdge(edge.label(), addVertexTo); - // ElementHelper.setProperties(addEdge, - // ElementHelper.getProperties(edge)); Utils.setProperties(addEdge, Utils.getProperties(edge)); log.info("fromVertex={}", Utils.getProperties(vertexFrom)); log.info("toVertex={}", Utils.getProperties(vertexTo)); log.info("edge={} {} ",edge.label(),Utils.getProperties(edge)); - // GraphSONWriter.outputGraph(openGraph, outputFile); GraphSONWriter create = GraphSONWriter.build().create(); create.writeGraph(out, openGraph); - // openGraph.rollback(); openGraph.tx().rollback(); } catch (Exception e) { @@ -384,7 +367,6 @@ public class GraphMLConverter { } } - // graph.rollback(); graph.tx().rollback(); } @@ -392,20 +374,12 @@ public class GraphMLConverter { if (runVertexScan) { Vertex vertex = null; - // Iterable<Vertex> vertices = graph.getVertices(); - - // Iterator<Vertex> iteratorVertex = vertices.iterator(); Iterator<Vertex> iteratorVertex = graph.vertices(); while (iteratorVertex.hasNext()) { try { vertex = iteratorVertex.next(); - - // Iterable<Edge> edges2 = - // vertex.getEdges(Direction.BOTH); - - // Iterator<Edge> iterator2 = edges2.iterator(); Iterator<Edge> iterator2 = vertex.edges(Direction.BOTH); if (false == iterator2.hasNext()) { @@ -439,54 +413,28 @@ public class GraphMLConverter { } } - // graph.rollback(); graph.tx().rollback(); } - // Iterable<Vertex> vertices2 = - // graph.getVertices(GraphPropertiesDictionary.HEALTH_CHECK.getProperty(), - // "GOOD"); Iterable<TitanVertex> vertices2 = graph.query() .has(GraphPropertiesDictionary.HEALTH_CHECK.getProperty(), "GOOD").vertices(); ; - Vertex next = vertices2.iterator().next(); BaseConfiguration conf = new BaseConfiguration(); conf.setProperty("storage.backend", "inmemory"); - TitanGraph openGraph = Utils.openGraph(conf); - - // TitanVertex addVertexFrom = openGraph.addVertex(); - // - // addVertexFrom.setProperty(GraphPropertiesDictionary.HEALTH_CHECK.getProperty(), - // "GOOD"); - // addVertexFrom.setProperty("healthcheck", - // next.getProperty("healthcheck")); - // - // //next.remove(); - // - // next.removeProperty("healthcheck"); - // next.removeProperty("healthcheckis"); - // - // next.remove(); - - // GraphSONWriter.outputGraph(openGraph, outputFile); - for (NodeTypeEnum nodeTypeEnum : NodeTypeEnum.values()) { removeNodesByLabel(graph, nodeTypeEnum.getName()); } - // GraphSONWriter.outputGraph(graph, outputFile); GraphSONWriter create = GraphSONWriter.build().create(); create.writeGraph(out, graph); - // graph.rollback(); graph.tx().rollback(); } catch (Exception e) { log.info("find Error In Json Graph failed - {}" , e); - // graph.rollback(); graph.tx().rollback(); } finally { try { @@ -511,35 +459,11 @@ public class GraphMLConverter { } } - public static void clearGraph(TitanGraph graph) { - - Iterable<TitanVertex> vertices = graph.query().vertices(); - - long erased = 0; - - if (vertices != null) { - Iterator<TitanVertex> iterator = vertices.iterator(); - while (iterator.hasNext()) { - Vertex vertex = iterator.next(); - // graph.removeVertex(vertex); - vertex.remove(); - erased++; - } - - } - - System.out.println("After erasing " + erased + " vertices."); - // graph.commit(); - graph.tx().commit(); - } - public String exportUsers(TitanGraph graph, String outputDirectory) { List<Map<String, Object>> users = new ArrayList<>(); String result = null; - // GraphMLWriter graphMLWriter = new GraphMLWriter(graph); - String outputFile = outputDirectory + File.separator + "users." + System.currentTimeMillis() + ".json"; FileWriter fileWriter = null; @@ -623,7 +547,6 @@ public class GraphMLConverter { return false; } finally { if (graph != null) { - // graph.shutdown(); graph.close(); } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java index a5e0449b6b..774af480ee 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java @@ -94,21 +94,18 @@ public class UpdatePropertyOnVertex { } - // graph.commit(); graph.tx().commit(); return numberOfUpdatedVertexes; } catch (Exception e) { log.info("update Property On Service At Least Certified failed -{}" , e); - // graph.rollback(); graph.tx().rollback(); return null; } finally { if (graph != null) { - // graph.shutdown(); graph.close(); } } @@ -144,7 +141,6 @@ public class UpdatePropertyOnVertex { String key = entry.getKey(); Object value = entry.getValue(); - // vertex.setProperty(key, value); vertex.property(key, value); if (log.isDebugEnabled()){ diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactUUIDFixMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactUUIDFixMenu.java index def9ed2c8a..70043633f4 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactUUIDFixMenu.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactUUIDFixMenu.java @@ -17,7 +17,6 @@ public class ArtifactUUIDFixMenu { } String fixServices = args[1]; String runMode = args[2]; - // String fixTosca = args[3]; log.info("Start fixing artifact UUID after 1707 migration with arguments run with configuration [{}] , for [{}] services", runMode, fixServices); String appConfigDir = args[0]; ConfigurationUploader.uploadConfigurationFiles(appConfigDir); diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactValidatorTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactValidatorTool.java index 2e84923188..daded28ab7 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactValidatorTool.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactValidatorTool.java @@ -3,16 +3,10 @@ package org.openecomp.sdc.asdctool.main; import org.openecomp.sdc.asdctool.impl.validator.ArtifactToolBL; import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager; import org.openecomp.sdc.asdctool.impl.validator.config.ValidationToolConfiguration; -import org.openecomp.sdc.be.config.ConfigurationManager; -import org.openecomp.sdc.common.api.ConfigurationSource; -import org.openecomp.sdc.common.impl.ExternalConfiguration; -import org.openecomp.sdc.common.impl.FSConfigurationSource; -import org.openecomp.sdc.common.log.wrappers.Logger; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class ArtifactValidatorTool { - private static Logger log = Logger.getLogger(ValidationTool.class.getName()); - + public static void main(String[] args) { String outputPath = args[0]; @@ -25,7 +19,6 @@ public class ArtifactValidatorTool { System.out.println("Start ArtifactValidation Tool"); Boolean result = validationToolBL.validateAll(); - // ReportManager.reportEndOfToolRun(); if (result) { System.out.println("ArtifactValidation finished successfully"); System.exit(0); @@ -36,8 +29,6 @@ public class ArtifactValidatorTool { } private static AnnotationConfigApplicationContext initContext(String appConfigDir) { - ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir); - ConfigurationManager configurationManager = new ConfigurationManager(configurationSource); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ValidationToolConfiguration.class); return context; } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/ExampleMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/ExampleMigration.java deleted file mode 100644 index 1302dc26a8..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/ExampleMigration.java +++ /dev/null @@ -1,27 +0,0 @@ -//package org.openecomp.sdc.asdctool.migration.tasks.mig1710;//package org.openecomp.sdc.migration.tasks.mig1710; -// -//import org.openecomp.sdc.asdctool.migration.core.DBVersion; -//import org.openecomp.sdc.asdctool.migration.core.task.Migration; -//import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult; -//import org.springframework.stereotype.Component; -// -//@Component -//public class ExampleMigration implements Migration { -// -// @Override -// public String description() { -// return "some description"; -// } -// -// @Override -// public DBVersion getVersion() { -// return DBVersion.fromString("1710.0"); -// } -// -// @Override -// public MigrationResult migrate() { -// MigrationResult migrationResult = new MigrationResult(); -// migrationResult.setMigrationStatus(MigrationResult.MigrationStatus.COMPLETED); -// return migrationResult; -// } -//}
\ No newline at end of file |