diff options
Diffstat (limited to 'asdctool/src/main/java/org/openecomp')
20 files changed, 323 insertions, 328 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java index 2b63193a1e..ebd548202b 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,31 +27,29 @@ import org.springframework.beans.factory.annotation.Autowired; import java.util.List; public class ArtifactToolBL { - - private static Logger log = Logger.getLogger(ValidationToolBL.class.getName()); - - protected List<IArtifactValidatorExecuter> validators; - - private boolean allValid = true; - - @Autowired - public ArtifactToolBL( - List<IArtifactValidatorExecuter> validators) { - this.validators = validators; - } - - public boolean validateAll() { - for (IArtifactValidatorExecuter validatorExec: validators) { - log.debug("ValidatorExecuter "+validatorExec.getName()+" started"); - if (!validatorExec.executeValidations()) { - allValid = false; - log.debug("ValidatorExecuter "+validatorExec.getName()+" finished with warnings"); - } - else { - log.debug("ValidatorExecuter "+validatorExec.getName()+" finished successfully"); - } - } - return allValid; - } + private static Logger log = Logger.getLogger(ValidationToolBL.class.getName()); + + protected List<IArtifactValidatorExecuter> validators; + + private boolean allValid = true; + + @Autowired + public ArtifactToolBL( + List<IArtifactValidatorExecuter> validators) { + this.validators = validators; + } + + public boolean validateAll(String outputFilePath) { + for (IArtifactValidatorExecuter validatorExec : validators) { + log.debug("ValidatorExecuter " + validatorExec.getName() + " started"); + if (!validatorExec.executeValidations(outputFilePath)) { + allValid = false; + log.debug("ValidatorExecuter " + validatorExec.getName() + " finished with warnings"); + } else { + log.debug("ValidatorExecuter " + validatorExec.getName() + " finished successfully"); + } + } + return allValid; + } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java index ae25c3106e..c73e4d4c03 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java @@ -45,10 +45,10 @@ public class ValidationToolBL { this.validators = validators; } - public boolean validateAll() { + public boolean validateAll(String outputFilePath) { for (ValidatorExecuter validatorExec: validators) { log.debug("ValidatorExecuter "+validatorExec.getName()+" started"); - if (!validatorExec.executeValidations()) { + if (!validatorExec.executeValidations(outputFilePath)) { allValid = false; log.debug("ValidatorExecuter "+validatorExec.getName()+" finished with warnings"); } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java index 3c09a54735..6178fe3f60 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java @@ -26,32 +26,21 @@ package org.openecomp.sdc.asdctool.impl.validator.config; import java.util.function.Supplier; -public class ValidationConfigManager { +public final class ValidationConfigManager { + private static final String REPORT_OUTPUT_FILE_NAME = "/reportOutput.txt"; private static final String CSV_FILE_PREFIX = "/csvSummary_"; private static final String CSV_EXT = ".csv"; public static final String DEFAULT_CSV_PATH = "summary.csv"; - private static String outputFullFilePath; - private static String outputFilePath; - private ValidationConfigManager() { } - public static String csvReportFilePath(String outputPath, Supplier<Long> getTime) { - return outputPath + CSV_FILE_PREFIX + getTime.get() + CSV_EXT; - } - - public static String getOutputFullFilePath() { - return outputFullFilePath; + public static String txtReportFilePath(String outputPath) { + return outputPath + REPORT_OUTPUT_FILE_NAME; } - public static String getOutputFilePath() { - return outputFilePath; - } - - public static void setOutputFullFilePath(String outputPath) { - ValidationConfigManager.outputFilePath = outputPath; - ValidationConfigManager.outputFullFilePath = outputPath + "/reportOutput.txt"; + public static String csvReportFilePath(String outputPath, Supplier<Long> getTime) { + return outputPath + CSV_FILE_PREFIX + getTime.get() + CSV_EXT; } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java index a5e7d7873b..9007d8ce05 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -49,111 +49,116 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -public class ArtifactValidatorExecuter{ - - protected JanusGraphDao janusGraphDao; - protected ToscaOperationFacade toscaOperationFacade; - - public ArtifactValidatorExecuter(JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade) { - this.janusGraphDao = janusGraphDao; - this.toscaOperationFacade = toscaOperationFacade; - } - - private static Logger log = Logger.getLogger(ArtifactValidatorExecuter.class.getName()); - - protected String name; - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - - - public Map<String, List<Component>> getVerticesToValidate(VertexTypeEnum type, Map<GraphPropertyEnum, Object> hasProps){ - Map<String, List<Component>> result = new HashMap<>(); - Either<List<GraphVertex>, JanusGraphOperationStatus> resultsEither = janusGraphDao - .getByCriteria(type, hasProps); - if (resultsEither.isRight()) { - log.error("getVerticesToValidate failed "+ resultsEither.right().value()); - return result; - } - System.out.println("getVerticesToValidate: "+resultsEither.left().value().size()+" vertices to scan"); - List<GraphVertex> componentsList = resultsEither.left().value(); - componentsList.forEach(vertex -> { - String ivariantUuid = (String)vertex.getMetadataProperty(GraphPropertyEnum.INVARIANT_UUID); - if(!result.containsKey(ivariantUuid)){ - List<Component> compList = new ArrayList<Component>(); - result.put(ivariantUuid, compList); - } - List<Component> compList = result.get(ivariantUuid); - - ComponentParametersView filter = new ComponentParametersView(true); - filter.setIgnoreArtifacts(false); - - Either<Component, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaElement(vertex.getUniqueId(), filter); - if (toscaElement.isRight()) { - log.error("getVerticesToValidate: failed to find element"+ vertex.getUniqueId()+" staus is" + toscaElement.right().value()); - }else{ - compList.add(toscaElement.left().value()); - } - - }); - - return result; - } - - public boolean validate( Map<String, List<Component>> vertices) { - boolean result = true; - long time = System.currentTimeMillis(); - String fileName = ValidationConfigManager.getOutputFilePath() + this.getName() + "_"+ time + ".csv"; - try(Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { - writer.write("name, UUID, invariantUUID, state, version\n"); - Collection<List<Component>> collection = vertices.values(); - for(List<Component> compList: collection ){ - Set<String> artifactEsId = new HashSet<>(); - for(Component component: compList ){ - Map<String, ArtifactDefinition> toscaArtifacts = component.getToscaArtifacts(); - Optional<ArtifactDefinition> op = toscaArtifacts.values(). - stream().filter(a -> artifactEsId.contains(a.getEsId())).findAny(); - if(op.isPresent()){ - result = false; - writeModuleResultToFile(writer, compList); - writer.flush(); - break; - }else{ - artifactEsId.addAll(toscaArtifacts.values().stream().map(ArtifactDefinition::getEsId).collect(Collectors.toList())) ; - } - } - - } - - } catch (Exception e) { - log.error("Failed to fetch vf resources ", e); - return false; - } finally { - janusGraphDao.commit(); - } - return result; - } - - private void writeModuleResultToFile(Writer writer, List<Component> components) { - try { - // "service name, service id, state, version - for(Component component: components ){ - StringBuffer sb = new StringBuffer(component.getName()); - sb.append(",").append(component.getUniqueId()).append(",").append(component.getInvariantUUID()).append(",").append(component.getLifecycleState()).append(",").append(component.getVersion()); - - sb.append("\n"); - writer.write(sb.toString()); - } - } catch (IOException e) { - log.error("Failed to write module result to file ", e); - } - } +public class ArtifactValidatorExecuter { + + protected JanusGraphDao janusGraphDao; + protected ToscaOperationFacade toscaOperationFacade; + + public ArtifactValidatorExecuter(JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade) { + this.janusGraphDao = janusGraphDao; + this.toscaOperationFacade = toscaOperationFacade; + } + + private static Logger log = Logger.getLogger(ArtifactValidatorExecuter.class.getName()); + + protected String name; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + + public Map<String, List<Component>> getVerticesToValidate(VertexTypeEnum type, + Map<GraphPropertyEnum, Object> hasProps) { + Map<String, List<Component>> result = new HashMap<>(); + Either<List<GraphVertex>, JanusGraphOperationStatus> resultsEither = janusGraphDao + .getByCriteria(type, hasProps); + if (resultsEither.isRight()) { + log.error("getVerticesToValidate failed " + resultsEither.right().value()); + return result; + } + System.out.println("getVerticesToValidate: " + resultsEither.left().value().size() + " vertices to scan"); + List<GraphVertex> componentsList = resultsEither.left().value(); + componentsList.forEach(vertex -> { + String ivariantUuid = (String) vertex.getMetadataProperty(GraphPropertyEnum.INVARIANT_UUID); + if (!result.containsKey(ivariantUuid)) { + List<Component> compList = new ArrayList<Component>(); + result.put(ivariantUuid, compList); + } + List<Component> compList = result.get(ivariantUuid); + + ComponentParametersView filter = new ComponentParametersView(true); + filter.setIgnoreArtifacts(false); + + Either<Component, StorageOperationStatus> toscaElement = toscaOperationFacade + .getToscaElement(vertex.getUniqueId(), filter); + if (toscaElement.isRight()) { + log.error( + "getVerticesToValidate: failed to find element" + vertex.getUniqueId() + " staus is" + toscaElement + .right().value()); + } else { + compList.add(toscaElement.left().value()); + } + + }); + + return result; + } + + public boolean validate(Map<String, List<Component>> vertices, String outputFilePath) { + boolean result = true; + long time = System.currentTimeMillis(); + String fileName = outputFilePath + this.getName() + "_" + time + ".csv"; + try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) { + writer.write("name, UUID, invariantUUID, state, version\n"); + Collection<List<Component>> collection = vertices.values(); + for (List<Component> compList : collection) { + Set<String> artifactEsId = new HashSet<>(); + for (Component component : compList) { + Map<String, ArtifactDefinition> toscaArtifacts = component.getToscaArtifacts(); + Optional<ArtifactDefinition> op = toscaArtifacts.values(). + stream().filter(a -> artifactEsId.contains(a.getEsId())).findAny(); + if (op.isPresent()) { + result = false; + writeModuleResultToFile(writer, compList); + writer.flush(); + break; + } else { + artifactEsId.addAll(toscaArtifacts.values().stream().map(ArtifactDefinition::getEsId) + .collect(Collectors.toList())); + } + } + + } + + } catch (Exception e) { + log.error("Failed to fetch vf resources ", e); + return false; + } finally { + janusGraphDao.commit(); + } + return result; + } + + private void writeModuleResultToFile(Writer writer, List<Component> components) { + try { + // "service name, service id, state, version + for (Component component : components) { + StringBuffer sb = new StringBuffer(component.getName()); + sb.append(",").append(component.getUniqueId()).append(",").append(component.getInvariantUUID()) + .append(",").append(component.getLifecycleState()).append(",").append(component.getVersion()); + + sb.append("\n"); + writer.write(sb.toString()); + } + } catch (IOException e) { + log.error("Failed to write module result to file ", e); + } + } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecuter.java index a0d700c67d..1b3c0375e7 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecuter.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,9 +21,8 @@ package org.openecomp.sdc.asdctool.impl.validator.executers; public interface IArtifactValidatorExecuter { - boolean executeValidations(); + + boolean executeValidations(String outputFilePath); + String getName(); - - - } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java index 9fa92200ac..6a52e07dd2 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,34 +32,33 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class NodeToscaArtifactsValidatorExecuter extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter{ - protected String name; - - public NodeToscaArtifactsValidatorExecuter(JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade) { - super(janusGraphDao, toscaOperationFacade); - setName("RESOURCE_TOSCA_ARTIFACTS"); - } - @Override - public boolean executeValidations() { - - Map<GraphPropertyEnum, Object> hasProps = new HashMap<>(); - hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name()); - hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); - - Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.NODE_TYPE, hasProps); - return validate(vertices); - - } +public class NodeToscaArtifactsValidatorExecuter extends ArtifactValidatorExecuter implements + IArtifactValidatorExecuter { - @Override - public String getName() { - return name; - } - + protected String name; - public void setName(String name) { - this.name = name; - } + public NodeToscaArtifactsValidatorExecuter(JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade) { + super(janusGraphDao, toscaOperationFacade); + setName("RESOURCE_TOSCA_ARTIFACTS"); + } + @Override + public boolean executeValidations(String outputFilePath) { + Map<GraphPropertyEnum, Object> hasProps = new HashMap<>(); + hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name()); + hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); + + Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.NODE_TYPE, hasProps); + return validate(vertices, outputFilePath); + } + + @Override + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java index aad803e672..21a8065dff 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,33 +34,32 @@ import java.util.List; import java.util.Map; @org.springframework.stereotype.Component -public class ServiceToscaArtifactsValidatorExecutor extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter{ - - @Autowired - public ServiceToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade) { - super(janusGraphDao, toscaOperationFacade); - setName("SERVICE_TOSCA_ARTIFACTS"); - } +public class ServiceToscaArtifactsValidatorExecutor extends ArtifactValidatorExecuter implements + IArtifactValidatorExecuter { - @Override - public boolean executeValidations() { - Map<GraphPropertyEnum, Object> hasProps = new HashMap<>(); - hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name()); - hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); - - Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps); - return validate(vertices); - } + @Autowired + public ServiceToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade) { + super(janusGraphDao, toscaOperationFacade); + setName("SERVICE_TOSCA_ARTIFACTS"); + } - @Override - public String getName() { - return name; - } - + @Override + public boolean executeValidations(String outputFilePath) { + Map<GraphPropertyEnum, Object> hasProps = new HashMap<>(); + hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name()); + hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); - public void setName(String name) { - this.name = name; - } + Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps); + return validate(vertices, outputFilePath); + } + @Override + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java index a52fb370d5..6d580d0bb4 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java @@ -45,9 +45,9 @@ public class ServiceValidatorExecuter extends TopologyTemplateValidatorExecuter } @Override - public boolean executeValidations() { + public boolean executeValidations(String outputFilePath) { List<GraphVertex> vertices = getVerticesToValidate(ComponentTypeEnum.SERVICE); - return validate(tasks, vertices); + return validate(tasks, vertices, outputFilePath); } @Override diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java index ca027cb3ed..b7195dec09 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -68,34 +68,35 @@ public class TopologyTemplateValidatorExecuter { protected List<GraphVertex> getVerticesToValidate(ComponentTypeEnum type) { Map<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class); props.put(GraphPropertyEnum.COMPONENT_TYPE, type.name()); - if(type.equals(ComponentTypeEnum.RESOURCE)) { + if (type.equals(ComponentTypeEnum.RESOURCE)) { props.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF); } Either<List<GraphVertex>, JanusGraphOperationStatus> results = janusGraphDao .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, props); if (results.isRight()) { - log.error("getVerticesToValidate failed "+ results.right().value()); + log.error("getVerticesToValidate failed " + results.right().value()); return new ArrayList<>(); } - log.info("getVerticesToValidate: "+results.left().value().size()+" vertices to scan"); + log.info("getVerticesToValidate: " + results.left().value().size() + " vertices to scan"); return results.left().value(); } - protected boolean validate(List<? extends TopologyTemplateValidationTask> tasks, List<GraphVertex> vertices) { - ReportManager.reportStartValidatorRun(getName(), vertices.size()); + protected boolean validate(List<? extends TopologyTemplateValidationTask> tasks, List<GraphVertex> vertices, + String outputFilePath) { + ReportManager.reportStartValidatorRun(getName(), vertices.size(), outputFilePath); Set<String> failedTasks = new HashSet<>(); Set<String> successTasks = new HashSet<>(); boolean successAllVertices = true; int vertexNum = 0; int verticesSize = vertices.size(); - for (GraphVertex vertex: vertices) { + for (GraphVertex vertex : vertices) { vertexNum++; boolean successAllTasks = true; - for (TopologyTemplateValidationTask task: tasks) { - ReportManager.reportStartTaskRun(vertex, task.getTaskName()); - VertexResult result = task.validate(vertex); + for (TopologyTemplateValidationTask task : tasks) { + ReportManager.reportStartTaskRun(vertex, task.getTaskName(), outputFilePath); + VertexResult result = task.validate(vertex, outputFilePath); if (!result.getStatus()) { failedTasks.add(task.getTaskName()); successAllVertices = false; @@ -103,13 +104,13 @@ public class TopologyTemplateValidatorExecuter { } else if (successAllTasks && vertexNum == verticesSize) { successTasks.add(task.getTaskName()); } - ReportManager.printValidationTaskStatus(vertex, task.getTaskName(), result.getStatus()); + ReportManager.printValidationTaskStatus(vertex, task.getTaskName(), result.getStatus(), outputFilePath); ReportManager.reportTaskEnd(vertex.getUniqueId(), task.getTaskName(), result); } - String componentScanStatus = successAllTasks? "success" : "failed"; - log.info("Topology Template "+vertex.getUniqueId()+" Validation finished with "+componentScanStatus); + String componentScanStatus = successAllTasks ? "success" : "failed"; + log.info("Topology Template " + vertex.getUniqueId() + " Validation finished with " + componentScanStatus); } - ReportManager.reportValidatorTypeSummary(getName(), failedTasks, successTasks); + ReportManager.reportValidatorTypeSummary(getName(), failedTasks, successTasks, outputFilePath); return successAllVertices; } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java index f1c9af681c..b5347a2579 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,35 +33,32 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class VFToscaArtifactValidatorExecutor extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter{ - - public VFToscaArtifactValidatorExecutor(JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade) { - super(janusGraphDao, toscaOperationFacade); - setName("VF_TOSCA_ARTIFACTS"); - } - @Override - public boolean executeValidations() { - - Map<GraphPropertyEnum, Object> hasProps = new HashMap<>(); - hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name()); - hasProps.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF); - hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); - - Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps); - return validate( vertices); - - } +public class VFToscaArtifactValidatorExecutor extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter { - @Override - public String getName() { - return name; - } - + public VFToscaArtifactValidatorExecutor(JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade) { + super(janusGraphDao, toscaOperationFacade); + setName("VF_TOSCA_ARTIFACTS"); + } - public void setName(String name) { - this.name = name; - } - + @Override + public boolean executeValidations(String outputFilePath) { + Map<GraphPropertyEnum, Object> hasProps = new HashMap<>(); + hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name()); + hasProps.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF); + hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); + Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps); + return validate(vertices, outputFilePath); + + } + + @Override + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java index 3164b6c625..db41cb57a8 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java @@ -25,6 +25,6 @@ package org.openecomp.sdc.asdctool.impl.validator.executers; */ public interface ValidatorExecuter { - boolean executeValidations(); + boolean executeValidations(String outputFilePath); String getName(); } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java index 181495ad44..dc4ebabf5c 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java @@ -43,9 +43,9 @@ public class VfValidatorExecuter extends TopologyTemplateValidatorExecuter imple } @Override - public boolean executeValidations() { + public boolean executeValidations(String outputFilePath) { List<GraphVertex> vertices = getVerticesToValidate(ComponentTypeEnum.RESOURCE); - return validate(tasks, vertices); + return validate(tasks, vertices, outputFilePath); } @Override diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java index ee05d586f9..576848dcdc 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java @@ -27,7 +27,7 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; * Created by chaya on 7/5/2017. */ public interface TopologyTemplateValidationTask { - VertexResult validate(GraphVertex vertex); + VertexResult validate(GraphVertex vertex, String outputFilePath); String getTaskName(); String getTaskResultStatus(); void setTaskResultStatus(String status); diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java index 11c80eae70..6da79cf681 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java @@ -60,13 +60,14 @@ public class ArtifactValidationUtils { this.topologyTemplateOperation = topologyTemplateOperation; } - public ArtifactsVertexResult validateArtifactsAreInCassandra(GraphVertex vertex, String taskName, List<ArtifactDataDefinition> artifacts) { + public ArtifactsVertexResult validateArtifactsAreInCassandra(GraphVertex vertex, String taskName, + List<ArtifactDataDefinition> artifacts, String outputFilePath) { ArtifactsVertexResult result = new ArtifactsVertexResult(true); - for(ArtifactDataDefinition artifact:artifacts) { + for (ArtifactDataDefinition artifact : artifacts) { boolean isArtifactExist = isArtifactInCassandra(artifact.getEsId()); String status = isArtifactExist ? "Artifact " + artifact.getEsId() + " is in Cassandra" : - "Artifact " + artifact.getEsId() + " doesn't exist in Cassandra"; - ReportManager.writeReportLineToFile(status); + "Artifact " + artifact.getEsId() + " doesn't exist in Cassandra"; + ReportManager.writeReportLineToFile(status, outputFilePath); if (!isArtifactExist) { ReportManager.addFailedVertex(taskName, vertex.getUniqueId()); result.setStatus(false); @@ -97,13 +98,15 @@ public class ArtifactValidationUtils { return artifacts; } - public ArtifactsVertexResult validateTopologyTemplateArtifacts(GraphVertex vertex, String taskName) { + public ArtifactsVertexResult validateTopologyTemplateArtifacts(GraphVertex vertex, String taskName, + String outputFilePath) { ArtifactsVertexResult result = new ArtifactsVertexResult(); ComponentParametersView paramView = new ComponentParametersView(); paramView.disableAll(); paramView.setIgnoreArtifacts(false); paramView.setIgnoreComponentInstances(false); - Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation.getToscaElement(vertex.getUniqueId(), paramView); + Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation + .getToscaElement(vertex.getUniqueId(), paramView); if (toscaElementEither.isRight()) { result.setStatus(false); return result; @@ -123,14 +126,14 @@ public class ArtifactValidationUtils { if (instanceArtifacts != null) { instanceArtifacts.forEach((key, artifactMap) -> - allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition()))); + allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition()))); } if (instanceDeploymentArtifacts != null) { instanceDeploymentArtifacts.forEach((key, artifactMap) -> - allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition()))); + allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition()))); } - return validateArtifactsAreInCassandra(vertex, taskName, allArtifacts); + return validateArtifactsAreInCassandra(vertex, taskName, allArtifacts, outputFilePath); } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java index 3b47a81c40..7caaa3cfa4 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java @@ -39,7 +39,7 @@ public class ServiceArtifactValidationTask extends ServiceValidationTask { } @Override - public ArtifactsVertexResult validate(GraphVertex vertex) { - return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName()); + public ArtifactsVertexResult validate(GraphVertex vertex, String outputFilePath) { + return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName(), outputFilePath); } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java index c445521f53..eb65b0c04c 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java @@ -40,7 +40,7 @@ public class VfArtifactValidationTask extends VfValidationTask { } @Override - public VertexResult validate(GraphVertex vertex) { - return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName()); + public VertexResult validate(GraphVertex vertex, String outputFilePath) { + return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName(), outputFilePath); } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java index d45c896799..47f00dc421 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -59,7 +59,7 @@ public class ModuleJsonTask extends ServiceValidationTask { } @Override - public VertexResult validate(GraphVertex vertex) { + public VertexResult validate(GraphVertex vertex, String outputFilePath) { if (!isAfterSubmitForTesting(vertex)) { return new VertexResult(true); } @@ -69,7 +69,8 @@ public class ModuleJsonTask extends ServiceValidationTask { paramView.setIgnoreArtifacts(false); paramView.setIgnoreGroups(false); paramView.setIgnoreComponentInstances(false); - Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation.getToscaElement(vertex.getUniqueId(), paramView); + Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation + .getToscaElement(vertex.getUniqueId(), paramView); if (toscaElementEither.isRight()) { return new VertexResult(false); } @@ -77,42 +78,47 @@ public class ModuleJsonTask extends ServiceValidationTask { Map<String, MapGroupsDataDefinition> instGroups = element.getInstGroups(); Map<String, MapArtifactDataDefinition> instDeploymentArtifacts = element.getInstDeploymentArtifacts(); - for (Map.Entry<String, MapGroupsDataDefinition> pair : Optional.ofNullable(instGroups).orElse(Collections.emptyMap()).entrySet()) { + for (Map.Entry<String, MapGroupsDataDefinition> pair : Optional.ofNullable(instGroups) + .orElse(Collections.emptyMap()).entrySet()) { MapGroupsDataDefinition groups = pair.getValue(); if (groups != null && !groups.getMapToscaDataDefinition().isEmpty()) { - return new VertexResult(findCoordinateModuleJson(pair, instDeploymentArtifacts, vertex)); + return new VertexResult(findCoordinateModuleJson(pair, instDeploymentArtifacts, vertex, outputFilePath)); } return new VertexResult(true); } return new VertexResult(true); } - private boolean findCoordinateModuleJson(Map.Entry<String, MapGroupsDataDefinition> pair, Map<String, MapArtifactDataDefinition> instDeploymentArtifacts, GraphVertex vertex) { + private boolean findCoordinateModuleJson(Map.Entry<String, MapGroupsDataDefinition> pair, + Map<String, MapArtifactDataDefinition> instDeploymentArtifacts, GraphVertex vertex, String outputFilePath) { String groupKey = pair.getKey(); String[] split = groupKey.split("\\."); - String instanceName = split[split.length-1]; + String instanceName = split[split.length - 1]; MapArtifactDataDefinition deploymentsArtifacts = instDeploymentArtifacts.get(groupKey); if (deploymentsArtifacts != null && !deploymentsArtifacts.getMapToscaDataDefinition().isEmpty()) { - List<ArtifactDataDefinition> moduleJsonArtifacts = deploymentsArtifacts.getMapToscaDataDefinition().values().stream().filter(artifact -> { - String artifactName = artifact.getArtifactName(); - if (artifactName.startsWith(instanceName) && artifactName.endsWith("modules.json")) { - return true; - } - return false; - }).collect(Collectors.toList()); + List<ArtifactDataDefinition> moduleJsonArtifacts = deploymentsArtifacts.getMapToscaDataDefinition().values() + .stream().filter(artifact -> { + String artifactName = artifact.getArtifactName(); + if (artifactName.startsWith(instanceName) && artifactName.endsWith("modules.json")) { + return true; + } + return false; + }).collect(Collectors.toList()); if (moduleJsonArtifacts.size() > 0) { - String status = "Instance "+instanceName+" has a corresponding modules.json file: "+moduleJsonArtifacts.get(0).getArtifactName(); - ReportManager.writeReportLineToFile(status); + String status = + "Instance " + instanceName + " has a corresponding modules.json file: " + moduleJsonArtifacts.get(0) + .getArtifactName(); + ReportManager.writeReportLineToFile(status, outputFilePath); return true; } } - String status = "Instance "+instanceName+" doesn't have a corresponding modules.json file"; - ReportManager.writeReportLineToFile(status); + String status = "Instance " + instanceName + " doesn't have a corresponding modules.json file"; + ReportManager.writeReportLineToFile(status, outputFilePath); ReportManager.addFailedVertex(getTaskName(), vertex.getUniqueId()); return false; } - private boolean isAfterSubmitForTesting(GraphVertex vertex){ + private boolean isAfterSubmitForTesting(GraphVertex vertex) { List allowedStates = new ArrayList<>(Arrays.asList(LifecycleStateEnum.CERTIFIED.name())); return allowedStates.contains(vertex.getMetadataProperty(GraphPropertyEnum.STATE)); } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java index feef9eaf01..78910df439 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java @@ -22,7 +22,6 @@ package org.openecomp.sdc.asdctool.impl.validator.utils; import org.apache.commons.lang.text.StrBuilder; -import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,28 +39,27 @@ import java.util.Set; public class ReportManager { private static Logger log = LoggerFactory.getLogger(ReportManager.class); - private static String reportOutputFilePath; + private static final Map<String, Set<String>> failedVerticesPerTask = new HashMap<>(); private static final Map<String, Map<String, VertexResult>> resultsPerVertex = new HashMap<>(); - public static ReportManager make(String csvReportFilePath) { - return new ReportManager(csvReportFilePath); + public static ReportManager make(String csvReportFilePath, String txtReportFilePath) { + return new ReportManager(csvReportFilePath, txtReportFilePath); } - private ReportManager(String csvReportFilePath) { + private ReportManager(String csvReportFilePath, String txtReportFilePath) { try { initCsvFile(csvReportFilePath); - initReportFile(); + initReportFile(txtReportFilePath); } catch (IOException e) { log.info("Init file failed - {}", e.getClass().getSimpleName(), e); } } - private void initReportFile() throws IOException { - reportOutputFilePath = ValidationConfigManager.getOutputFullFilePath(); + private void initReportFile(String txtReportFilePath) throws IOException { StrBuilder sb = new StrBuilder(); sb.appendln("-----------------------Validation Tool Results:-------------------------"); - Files.write(Paths.get(reportOutputFilePath), sb.toString().getBytes()); + Files.write(Paths.get(txtReportFilePath), sb.toString().getBytes()); } private void initCsvFile(String csvReportFilePath) throws IOException { @@ -87,51 +85,52 @@ public class ReportManager { failedVerticesPerTask.put(taskName, failedVertices); } - public static void printValidationTaskStatus(GraphVertex vertexScanned, String taskName, boolean success) { + public static void printValidationTaskStatus(GraphVertex vertexScanned, String taskName, boolean success, + String outputFilePath) { String successStatus = success ? "success" : "failed"; String line = "-----------------------Vertex: " + vertexScanned.getUniqueId() + ", Task " + taskName + " " + successStatus + "-----------------------"; StrBuilder sb = new StrBuilder(); sb.appendln(line); - writeReportLineToFile(line); + writeReportLineToFile(line, outputFilePath); } - public static void writeReportLineToFile(String message) { + public static void writeReportLineToFile(String message, String outputFilePath) { try { - Files.write(Paths.get(reportOutputFilePath), new StrBuilder().appendNewLine().toString().getBytes(), + Files.write(Paths.get(outputFilePath), new StrBuilder().appendNewLine().toString().getBytes(), StandardOpenOption.APPEND); - Files.write(Paths.get(reportOutputFilePath), message.getBytes(), StandardOpenOption.APPEND); + Files.write(Paths.get(outputFilePath), message.getBytes(), StandardOpenOption.APPEND); } catch (IOException e) { log.info("write to file failed - {}", e.getClass().getSimpleName(), e); } } public static void reportValidatorTypeSummary(String validatorName, Set<String> failedTasksNames, - Set<String> successTasksNames) { + Set<String> successTasksNames, String outputFilePath) { StrBuilder sb = new StrBuilder(); sb.appendln( "-----------------------ValidatorExecuter " + validatorName + " Validation Summary-----------------------"); sb.appendln("Failed tasks: " + failedTasksNames); sb.appendln("Success tasks: " + successTasksNames); - writeReportLineToFile(sb.toString()); + writeReportLineToFile(sb.toString(), outputFilePath); } - public static void reportStartValidatorRun(String validatorName, int componenentsNum) { + public static void reportStartValidatorRun(String validatorName, int componenentsNum, String outputFilePath) { StrBuilder sb = new StrBuilder(); sb.appendln("------ValidatorExecuter " + validatorName + " Validation Started, on " + componenentsNum + " components---------"); - writeReportLineToFile(sb.toString()); + writeReportLineToFile(sb.toString(), outputFilePath); } - public static void reportStartTaskRun(GraphVertex vertex, String taskName) { + public static void reportStartTaskRun(GraphVertex vertex, String taskName, String outputFilePath) { StrBuilder sb = new StrBuilder(); sb.appendln("-----------------------Vertex: " + vertex.getUniqueId() + ", Task " + taskName + " Started-----------------------"); - writeReportLineToFile(sb.toString()); + writeReportLineToFile(sb.toString(), outputFilePath); } - public static void reportEndOfToolRun(String csvReportFilePath) { + public static void reportEndOfToolRun(String csvReportFilePath, String outputFilePath) { StrBuilder sb = new StrBuilder(); sb.appendln("-----------------------------------Validator Tool Summary-----------------------------------"); failedVerticesPerTask.forEach((taskName, failedVertices) -> { @@ -140,7 +139,7 @@ public class ReportManager { sb.append("FailedVertices: " + failedVertices); sb.appendNewLine(); }); - writeReportLineToFile(sb.toString()); + writeReportLineToFile(sb.toString(), outputFilePath); printAllResults(csvReportFilePath); } 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 063f3f6a29..0978f4ebd7 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 @@ -31,14 +31,14 @@ public class ArtifactValidatorTool { public static void main(String[] args) { String outputPath = args[0]; - ValidationConfigManager.setOutputFullFilePath(outputPath); + String txtReportFilePath = ValidationConfigManager.txtReportFilePath(outputPath); String appConfigDir = args[1]; AnnotationConfigApplicationContext context = initContext(appConfigDir); ArtifactToolBL validationToolBL = context.getBean(ArtifactToolBL.class); System.out.println("Start ArtifactValidation Tool"); - Boolean result = validationToolBL.validateAll(); + Boolean result = validationToolBL.validateAll(txtReportFilePath); if (result) { System.out.println("ArtifactValidation finished successfully"); System.exit(0); diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java index 23b9c18d3f..d98a26b7ed 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java @@ -41,7 +41,7 @@ public class ValidationTool { public static void main(String[] args) { String outputPath = args[0]; - ValidationConfigManager.setOutputFullFilePath(outputPath); + String txtReportFilePath = ValidationConfigManager.txtReportFilePath(outputPath); String csvReportFilePath = ValidationConfigManager.csvReportFilePath(outputPath, System::currentTimeMillis); String appConfigDir = args[1]; @@ -49,8 +49,8 @@ public class ValidationTool { ValidationToolBL validationToolBL = context.getBean(ValidationToolBL.class); log.info("Start Validation Tool"); - boolean result = validationToolBL.validateAll(); - ReportManager.reportEndOfToolRun(csvReportFilePath); + boolean result = validationToolBL.validateAll(txtReportFilePath); + ReportManager.reportEndOfToolRun(csvReportFilePath, txtReportFilePath); if (result) { log.info("Validation finished successfully"); System.exit(0); |