From 04ff1b844c58f9f53558ff70594bf52ef6fba6ae Mon Sep 17 00:00:00 2001 From: Piotr Krysiak Date: Thu, 19 Jul 2018 09:07:10 +0200 Subject: ASDC dead code removal Issue-ID: SDC-1493 Change-Id: I74c1748eb2b1f478a0e44b07c174f95964fed667 Signed-off-by: Piotr Krysiak --- .../java/org/openecomp/sdc/asdctool/Utils.java | 4 - .../sdc/asdctool/impl/ArtifactUuidFix.java | 70 +++---------- .../sdc/asdctool/impl/GraphMLConverter.java | 115 ++++----------------- .../sdc/asdctool/impl/UpdatePropertyOnVertex.java | 4 - .../sdc/asdctool/main/ArtifactUUIDFixMenu.java | 1 - .../sdc/asdctool/main/ArtifactValidatorTool.java | 11 +- .../migration/tasks/mig1710/ExampleMigration.java | 27 ----- .../java/org/openecomp/sdc/asdctool/UtilsTest.java | 4 - .../sdc/asdctool/impl/GraphMLConverterTest.java | 19 ---- .../config/ValidationToolConfigurationTest.java | 36 ------- 10 files changed, 33 insertions(+), 258 deletions(-) delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/ExampleMigration.java 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 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 fixedIds = new HashSet<>(); - Component component; - String componentId = "86683566-20e8-4cc5-872d-12abca1d57f0";//"9f6a6976-18e3-488a-98a4-c1aade480739"; - Either 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 fixedIds = new HashSet<>(); - Component component; - String componentId = "86d50186-7b00-4bfc-abcb-9e4c6892f338";//"9f6a6976-18e3-488a-98a4-c1aade480739"; - Either 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 services = new ArrayList<>(); - services.add(toscaElement.left().value()); - this.fix(new ArrayList(), services, null, null, null); - - Either 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 edges = graph.getEdges(); - // Iterable edges = graph.query().edges(); Iterable edges = graph.query().edges(); - // Iterator iterator = edges.iterator(); Iterator 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 vertices = graph.getVertices(); - - // Iterator iteratorVertex = vertices.iterator(); Iterator iteratorVertex = graph.vertices(); while (iteratorVertex.hasNext()) { try { vertex = iteratorVertex.next(); - - // Iterable edges2 = - // vertex.getEdges(Direction.BOTH); - - // Iterator iterator2 = edges2.iterator(); Iterator iterator2 = vertex.edges(Direction.BOTH); if (false == iterator2.hasNext()) { @@ -439,54 +413,28 @@ public class GraphMLConverter { } } - // graph.rollback(); graph.tx().rollback(); } - // Iterable vertices2 = - // graph.getVertices(GraphPropertiesDictionary.HEALTH_CHECK.getProperty(), - // "GOOD"); Iterable 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 vertices = graph.query().vertices(); - - long erased = 0; - - if (vertices != null) { - Iterator 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> 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 diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/UtilsTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/UtilsTest.java index 020696c42d..8a9b1357ea 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/UtilsTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/UtilsTest.java @@ -12,10 +12,6 @@ import java.util.Map; public class UtilsTest { - /* - * private Utils createTestSubject() { return new Utils(); } - */ - @Test public void testBuildOkResponse() throws Exception { int status = 0; diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLConverterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLConverterTest.java index fb003e8012..5ade4faef8 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLConverterTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLConverterTest.java @@ -14,18 +14,6 @@ public class GraphMLConverterTest { return new GraphMLConverter(); } - /*@Before - public void createGraphTestSubject() { - converter = new GraphMLConverter(); - openGraph = converter.openGraph("src/main/resources/config/titan.properties"); - }*/ - - /*@After - public void destroyGraphTestSubject() { - converter = new GraphMLConverter(); - converter.clearGraph(openGraph); - }*/ - @Test public void testImportGraph() throws Exception { GraphMLConverter testSubject; @@ -130,13 +118,6 @@ public class GraphMLConverterTest { result = testSubject.findErrorInJsonGraph(graph, outputDirectory); } - @Test - public void testClearGraph() throws Exception { - TitanGraph graph = null; - - // default test - //GraphMLConverter.clearGraph("src/main/resources/config/titan.properties"); - } @Test(expected=NullPointerException.class) public void testExportUsers() throws Exception { diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java index ece89dbd21..0d91f1a29e 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java @@ -263,40 +263,4 @@ public class ValidationToolConfigurationTest { testSubject = createTestSubject(); result = testSubject.artifactToolBL(); } - - //TODO runs as single JUnit Fails on maven clean install - /*@Test(expected=NullPointerException.class) - public void testReportManager() throws Exception { - ValidationToolConfiguration testSubject; - ReportManager result; - - // default test - testSubject = createTestSubject(); - result = testSubject.reportManager(); - } -*/ - - //TODO runs as single JUnit Fails on maven clean install - /*@Test(expected=NullPointerException.class) - public void testTitanMigrationClient() throws Exception { - ValidationToolConfiguration testSubject; - TitanClientStrategy titanClientStrategy = null; - TitanGraphClient result; - - // default test - testSubject = createTestSubject(); - result = testSubject.titanMigrationClient(titanClientStrategy); - }*/ - - //TODO runs as single JUnit Fails on maven clean install - /*@Test(expected=NullPointerException.class) - public void testNodeTemplateOperation() throws Exception { - ValidationToolConfiguration testSubject; - NodeTemplateOperation result; - - // default test - testSubject = createTestSubject(); - System.out.println("ConfigurationManager Print" + ConfigurationManager.getConfigurationManager().getConfiguration().toString()); - result = testSubject.nodeTemplateOperation(); - }*/ } \ No newline at end of file -- cgit 1.2.3-korg