public static void main(String[] args) {
    JenkinsServer jenkins = null;
    try {
      jenkins = new JenkinsServer(new URI("http://130.211.189.253"), "", "");
      jenkins.createJob(
          "ProgramaticJob", inputStream2String(new FileInputStream(new File("config.xml"))));
    } catch (URISyntaxException | IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    //
    //        try {
    //
    //            // jenkins.createJob(jobName, jobXml);
    //            Map<String, Job> jobs = jenkins.getJobs();
    //            for (String s : jobs.keySet()) {
    //                // System.out.println(s);
    //                System.out.println(jobs.get(s).details().details());
    //            }
    //        } catch (IOException e) {
    //            // TODO Auto-generated catch block
    //            e.printStackTrace();
    //        }

  }
Example #2
0
 // Opens default browser and loads this projects github page.
 public static void openGit() {
   try {
     Desktop.getDesktop().browse(new URL("https://github.com/skelegon/Vidor").toURI());
   } catch (URISyntaxException | IOException ex) {
     ex.printStackTrace();
   }
 }
Example #3
0
  @Override
  public Suggestions getSuggestions(
      final RequestInfo requestInfo,
      final String selection,
      final String dependent,
      @Nullable final ResponseAction responseAction) {
    try {
      final URL url = getUrl(requestInfo, selection, dependent);

      Invocation.Builder requestBuilder =
          client
              .target(url.toURI())
              .request()
              .accept(MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON);

      if (requestInfo.getAuthentication() != null) {
        requestBuilder =
            requestBuilder
                .property(
                    HttpAuthenticationFeature.HTTP_AUTHENTICATION_USERNAME,
                    requestInfo.getAuthentication().getUsername())
                .property(
                    HttpAuthenticationFeature.HTTP_AUTHENTICATION_PASSWORD,
                    requestInfo.getAuthentication().getPassword());
      }

      if (responseAction == null) {
        // response does not require transformation
        return requestBuilder.get(Suggestions.class);
      } else {
        // we need to transform the custom XML or JSON response into Suggestions format
        final Response response = requestBuilder.get();
        try (final InputStream is = response.readEntity(InputStream.class)) {
          final MediaType mediaType = response.getMediaType();
          final Path transformation = responseAction.getTransformation();
          if (mediaType != null && mediaType.isCompatible(MediaType.APPLICATION_XML_TYPE)
              || mediaType.isCompatible(MediaType.TEXT_XML_TYPE)) {
            // custom XML response
            LOGGER.debug("Transforming XML response from: {} using: {}", url, transformation);
            return transformXmlResponse(is, transformation);
          } else if (mediaType != null && mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE)) {
            LOGGER.debug("Transforming JSON response from: {} using: {}", url, transformation);
            // custom JSON response
            return transformJsonResponse(is, transformation);
          } else {
            LOGGER.error(
                "Response from {} has unsupported Content-Type: {}",
                url,
                mediaType); // TODO(AR) maybe something more visible to the user
            return new Suggestions();
          }
        }
      }
    } catch (final URISyntaxException | IOException | TransformationException e) {
      LOGGER.error(e.getMessage(), e); // TODO(AR) maybe something more visible to the user
      return new Suggestions();
    }
  }