예제 #1
0
 /**
  * uploads a file to repository using the pre-configured client.
  *
  * @param client .
  * @param file .
  * @param displayer .
  * @return the returned upload key
  * @throws RestClientException .
  * @throws CLIException .
  */
 public static String uploadToRepo(
     final RestClient client, final File file, final CLIEventsDisplayer displayer)
     throws RestClientException, CLIException {
   if (file != null) {
     if (!file.isFile()) {
       throw new CLIException(file.getAbsolutePath() + " is not a file or is missing");
     }
     displayer.printEvent("Uploading " + file.getAbsolutePath());
     return client.upload(null, file).getUploadKey();
   }
   return null;
 }
  /**
   * Gets the latest events of this deployment id. Events are sorted by event index.
   *
   * @return A list of events. If this is the first time events are requested, all events are
   *     retrieved. Otherwise, only new events (that were not reported earlier) are retrieved.
   * @throws RestClientException Indicates a failure to get events from the server.
   */
  public List<String> getLatestEvents() throws RestClientException {

    List<String> eventsStrings = new ArrayList<String>();

    DeploymentEvents events = restClient.getDeploymentEvents(deploymentId, lastEventIndex + 1, -1);
    if (events == null || events.getEvents().isEmpty()) {
      return eventsStrings;
    }

    for (DeploymentEvent event : events.getEvents()) {
      eventsStrings.add(event.getDescription());
    }
    lastEventIndex = events.getEvents().get(events.getEvents().size() - 1).getIndex();
    return eventsStrings;
  }