X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fakraino%2Fvalidation%2Fui%2Fservice%2FIntegratedResultService.java;h=1a707a99c311d86ee22e354f2d8883f46f67e4f6;hb=c4f35d65a835e53a7847524eea61cb172a2433f5;hp=965a78cbbd4f2ee663eaa5d57182e9924898bb66;hpb=3ff5d7028b19a649f6b80c476ff45ced1fdd67dc;p=validation.git diff --git a/ui/src/main/java/org/akraino/validation/ui/service/IntegratedResultService.java b/ui/src/main/java/org/akraino/validation/ui/service/IntegratedResultService.java index 965a78c..1a707a9 100644 --- a/ui/src/main/java/org/akraino/validation/ui/service/IntegratedResultService.java +++ b/ui/src/main/java/org/akraino/validation/ui/service/IntegratedResultService.java @@ -16,8 +16,6 @@ package org.akraino.validation.ui.service; import java.io.IOException; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -45,8 +43,6 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.UniformInterfaceException; @Service @Transactional @@ -63,9 +59,7 @@ public class IntegratedResultService { @Autowired DbAdapter dbAdapter; - public List getLabsFromNexus() - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, IOException, IllegalArgumentException, ParseException { + public List getLabsFromNexus() throws IndexOutOfBoundsException, HttpException, NullPointerException { List labs = new ArrayList(); for (String cLabSilo : nexusService.getResource(null)) { for (LabInfo labInfo : dbAdapter.getLabs()) { @@ -78,31 +72,25 @@ public class IntegratedResultService { } public List getBlueprintNamesOfLabFromNexus(@Nonnull String lab) - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, IOException, IllegalArgumentException, ParseException { + throws IndexOutOfBoundsException, HttpException, NullPointerException, IllegalArgumentException { LabInfo labInfo = dbAdapter.getLab(lab); if (labInfo == null) { throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString()); } List rNames = new ArrayList(); - try { - List cNames = nexusService.getResource(dbAdapter.getLab(lab).getSilo() + "/bluval_results"); - for (String cName : cNames) { - if (cName.equals("family") || cName.equals("ta") || cName.equals("job")) { - continue; - } - rNames.add(cName); + List cNames = nexusService.getResource(dbAdapter.getLab(lab).getSilo() + "/bluval_results"); + for (String cName : cNames) { + if (cName.equals("family") || cName.equals("ta") || cName.equals("job")) { + continue; } - } catch (HttpException ex) { - LOGGER.warn(EELFLoggerDelegate.auditLogger, - "Error when retrieving blueprint names from nexus" + UserUtils.getStackTrace(ex)); + rNames.add(cName); } + return rNames; } public List getBlueprintVersionsFromNexus(@Nonnull String name, @Nonnull String lab) - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, IOException, IllegalArgumentException, ParseException { + throws IndexOutOfBoundsException, HttpException, NullPointerException, IllegalArgumentException { LabInfo labInfo = dbAdapter.getLab(lab); if (labInfo == null) { throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString()); @@ -111,26 +99,20 @@ public class IntegratedResultService { } public List getBlueprintTimeStampsFromNexus(@Nonnull String name, @Nonnull String version, - @Nonnull String lab) throws JsonParseException, JsonMappingException, KeyManagementException, - ClientHandlerException, UniformInterfaceException, NoSuchAlgorithmException, IOException, ParseException { + @Nonnull String lab) + throws IndexOutOfBoundsException, HttpException, NullPointerException, IllegalArgumentException { LabInfo labInfo = dbAdapter.getLab(lab); if (labInfo == null) { throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString()); } List timestamps = new ArrayList(); - try { - timestamps = nexusService.getResource(labInfo.getSilo() + "/bluval_results", name, version); - } catch (HttpException ex) { - LOGGER.warn(EELFLoggerDelegate.auditLogger, - "Error when retrieving blueprint names from nexus" + UserUtils.getStackTrace(ex)); - } + timestamps = nexusService.getResource(labInfo.getSilo() + "/bluval_results", name, version); return timestamps; } public List getResultsFromNexus(@Nonnull String name, @Nonnull String version, @Nonnull String lab, int noTimestamps) - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, IOException, IllegalArgumentException, ParseException { + throws IndexOutOfBoundsException, HttpException, NullPointerException, IllegalArgumentException { LabInfo labInfo = dbAdapter.getLab(lab); if (labInfo == null) { throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString()); @@ -139,66 +121,62 @@ public class IntegratedResultService { } public ValidationDbTestResult getResultFromNexus(@Nonnull String name, @Nonnull String version, @Nonnull String lab, - @Nonnull String timestamp) throws JsonParseException, JsonMappingException, IOException, - KeyManagementException, ClientHandlerException, UniformInterfaceException, NoSuchAlgorithmException, - NullPointerException, ParseException { + @Nonnull String timestamp) + throws IndexOutOfBoundsException, HttpException, NullPointerException, IllegalArgumentException { LabInfo labInfo = dbAdapter.getLab(lab); if (labInfo == null) { throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString()); } ValidationDbTestResult vNexusResult = nexusService.getResult(name, version, labInfo.getSilo(), timestamp); - if (!dbAdapter.checkValidityOfNexusResult(vNexusResult)) { - return null; + if (vNexusResult != null && dbAdapter.checkValidityOfNexusResult(vNexusResult)) { + vNexusResult.setLab(labInfo); + return vNexusResult; } - vNexusResult.setLab(labInfo); - return vNexusResult; + return null; } public ValidationDbTestResult getLastResultBasedOnOutcomeFromNexus(@Nonnull String name, @Nonnull String version, @Nonnull String lab, Boolean allLayers, Boolean optional, boolean outcome) - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, NullPointerException, IOException, ParseException { + throws IndexOutOfBoundsException, HttpException, NullPointerException, IllegalArgumentException { LabInfo labInfo = dbAdapter.getLab(lab); if (labInfo == null) { throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString()); } ValidationDbTestResult vNexusResult = nexusService.getLastResultBasedOnOutcome(name, version, labInfo.getSilo(), allLayers, optional, outcome); - if (!dbAdapter.checkValidityOfNexusResult(vNexusResult)) { - return null; + if (vNexusResult != null && dbAdapter.checkValidityOfNexusResult(vNexusResult)) { + vNexusResult.setLab(labInfo); + return vNexusResult; } - vNexusResult.setLab(labInfo); - return vNexusResult; + return null; } public ValidationDbTestResult getLastResultBasedOnOutcomeFromNexus(@Nonnull String name, @Nonnull String version, @Nonnull String lab, @Nonnull List layers, Boolean optional, boolean outcome) - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, NullPointerException, IOException, ParseException { + throws IndexOutOfBoundsException, HttpException, NullPointerException, IllegalArgumentException { LabInfo labInfo = dbAdapter.getLab(lab); if (labInfo == null) { throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString()); } ValidationDbTestResult vNexusResult = nexusService.getLastResultBasedOnOutcome(name, version, labInfo.getSilo(), layers, optional, outcome); - if (!dbAdapter.checkValidityOfNexusResult(vNexusResult)) { - return null; + if (vNexusResult != null && dbAdapter.checkValidityOfNexusResult(vNexusResult)) { + vNexusResult.setLab(labInfo); + return vNexusResult; } - vNexusResult.setLab(labInfo); - return vNexusResult; + return null; } public List getBasedOnDateFromNexus(@Nonnull String name, @Nonnull String version, - @Nonnull String lab, @Nonnull Date date) - throws JsonParseException, JsonMappingException, IOException, ParseException, KeyManagementException, - ClientHandlerException, UniformInterfaceException, NoSuchAlgorithmException, NullPointerException { + @Nonnull String lab, @Nonnull Date date) throws IndexOutOfBoundsException, HttpException, + NullPointerException, IllegalArgumentException, ParseException { LabInfo labInfo = dbAdapter.getLab(lab); if (labInfo == null) { throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString()); } List vNexusResults = new ArrayList(); List vResults = nexusService.getResults(name, version, labInfo.getSilo(), date); - if (vResults != null && vResults.size() > 1) { + if (vResults != null && vResults.size() >= 1) { for (ValidationDbTestResult vNexusResult : vResults) { if (dbAdapter.checkValidityOfNexusResult(vNexusResult)) { vNexusResult.setLab(labInfo); @@ -230,9 +208,8 @@ public class IntegratedResultService { return blueprintVersions; } - public ValidationDbTestResult getResults(@Nonnull String submissionId) - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, IOException, NullPointerException, ParseException { + public ValidationDbTestResult getResults(@Nonnull String submissionId) throws IndexOutOfBoundsException, + NullPointerException, JsonParseException, JsonMappingException, IOException { Submission submission = submissionService.getSubmission(submissionId); ValidationDbTestResult vDbResult = dbAdapter.readResultFromDb(submissionId); return vDbResult == null ? this.getResultFromNexus( @@ -243,9 +220,8 @@ public class IntegratedResultService { } public ValidationDbTestResult getResult(@Nonnull String name, @Nonnull String version, @Nonnull String lab, - @Nonnull String timestamp) - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, NullPointerException, IOException, ParseException { + @Nonnull String timestamp) throws IndexOutOfBoundsException, NullPointerException, JsonParseException, + JsonMappingException, IOException { LabInfo actualLabInfo = dbAdapter.getLab(lab); if (actualLabInfo == null) { return null; @@ -255,9 +231,8 @@ public class IntegratedResultService { } public ValidationDbTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version, - @Nonnull String lab, Boolean allLayers, Boolean optional, boolean outcome) - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, IOException, NullPointerException, ParseException { + @Nonnull String lab, Boolean allLayers, Boolean optional, boolean outcome) throws IndexOutOfBoundsException, + NullPointerException, JsonParseException, JsonMappingException, IOException { LabInfo actualLabInfo = dbAdapter.getLab(lab); if (actualLabInfo == null) { return null; @@ -287,8 +262,8 @@ public class IntegratedResultService { public ValidationDbTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version, @Nonnull String lab, List layers, Boolean optional, boolean outcome) - throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException, - UniformInterfaceException, NoSuchAlgorithmException, IOException, NullPointerException, ParseException { + throws IndexOutOfBoundsException, NullPointerException, JsonParseException, JsonMappingException, + IOException { LabInfo actualLabInfo = dbAdapter.getLab(lab); if (actualLabInfo == null) { return null;