+ }
+
+ public String getBaseUrl() {
+ return this.baseurl;
+ }
+
+ public List<String> getResource(String endpoint)
+ throws ClientHandlerException, UniformInterfaceException, JsonParseException, JsonMappingException,
+ IOException, KeyManagementException, NoSuchAlgorithmException, ParseException {
+ List<String> resources = new ArrayList<String>();
+ String nexusUrl = this.baseurl;
+ if (endpoint != null) {
+ nexusUrl = this.baseurl + "/" + endpoint;
+ }
+ LOGGER.info(EELFLoggerDelegate.applicationLogger, "Trying to get nexus resource: " + nexusUrl);
+ WebResource webResource = this.client.resource(nexusUrl + "/");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "Request URI of get: " + webResource.getURI().toString());
+ ClientResponse response = webResource.get(ClientResponse.class);
+ if (response.getStatus() != 200) {
+ throw new HttpException("Could not retrieve nexus resource " + nexusUrl + ". HTTP error code : "
+ + response.getStatus() + " and message: " + response.getEntity(String.class));
+ }
+ Document document = Jsoup.parse(response.getEntity(String.class));
+ List<Element> elements = document.getElementsByTag("body").get(0).getElementsByTag("table").get(0)
+ .getElementsByTag("tbody").get(0).getElementsByTag("tr");
+ for (int i = 2; i < elements.size(); i++) {
+ String resource = elements.get(i).getElementsByTag("td").get(0).getElementsByTag("a").get(0).text();
+ resource = resource.substring(0, resource.length() - 1);
+ resources.add(resource);
+ }
+ return resources;
+ }
+
+ public List<String> getResource(@Nonnull String endpoint1, @Nonnull String endpoint2)
+ throws ClientHandlerException, UniformInterfaceException, JsonParseException, JsonMappingException,
+ IOException, KeyManagementException, NoSuchAlgorithmException, ParseException {
+ String endpoint = endpoint1 + "/" + endpoint2;
+ return this.getResource(endpoint);
+ }
+
+ public List<String> getResource(@Nonnull String endpoint1, @Nonnull String endpoint2, @Nonnull String endpoint3)
+ throws ClientHandlerException, UniformInterfaceException, JsonParseException, JsonMappingException,
+ IOException, KeyManagementException, NoSuchAlgorithmException, ParseException {
+ String endpoint = endpoint1 + "/" + endpoint2 + "/" + endpoint3;
+ return this.getResource(endpoint);
+ }
+
+ public ValidationDbTestResult getResult(@Nonnull String name, @Nonnull String version, @Nonnull String siloText,
+ @Nonnull String timestamp)
+ throws ClientHandlerException, UniformInterfaceException, JsonParseException, JsonMappingException,
+ IOException, KeyManagementException, NoSuchAlgorithmException, ParseException, NullPointerException {
+ String nexusUrl = this.baseurl + "/" + siloText + "/" + "bluval_results/" + name + "/" + version;
+ LOGGER.info(EELFLoggerDelegate.applicationLogger, "Trying to get validation nexus test result");
+ WebResource webResource = this.client.resource(nexusUrl + "/");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "Request URI of get: " + webResource.getURI().toString());
+ ClientResponse response = webResource.get(ClientResponse.class);
+ if (response.getStatus() != 200) {
+ throw new HttpException("Could not retrieve validation nexus test result. HTTP error code : "
+ + response.getStatus() + " and message: " + response.getEntity(String.class));
+ }
+ Document document = Jsoup.parse(response.getEntity(String.class));
+ List<Element> elements = document.getElementsByTag("body").get(0).getElementsByTag("table").get(0)
+ .getElementsByTag("tbody").get(0).getElementsByTag("tr");
+ Element element = findElementByTimestamp(elements.subList(2, elements.size()), timestamp);
+ if (element == null) {
+ return null;
+ }
+ ValidationDbTestResult vDbResult = new ValidationDbTestResult();
+ Blueprint blueprint = new Blueprint();
+ blueprint.setBlueprintName(name);
+ BlueprintInstance blueInst = new BlueprintInstance();
+ blueInst.setBlueprint(blueprint);
+ blueInst.setVersion(version);
+ vDbResult.setBlueprintInstance(blueInst);
+ LabInfo lab = new LabInfo();
+ lab.setSilo(siloText);
+ vDbResult.setLab(lab);
+ vDbResult.setTimestamp(timestamp);
+ String lastModified = element.getElementsByTag("td").get(1).text();
+ vDbResult.setDateStorage(lastModified);
+ TestInfoYaml testInfo = getTestInfo(webResource.getURI().toString() + timestamp);
+ if (testInfo != null) {
+ if (testInfo.gettest_info().getLayer().equals("all")) {
+ vDbResult.setAllLayers(true);
+ } else {
+ vDbResult.setAllLayers(false);