Exemple #1
0
  /**
   * Servico responsavel por atualizar o repositorio local com modificacoes que foram aplicadas ao
   * seu respectivo repositorio remoto. Consome XML padronizado (Command) que contem o caminho
   * absoluto do repositorio que se deseja atualizar. O repositorio deve possuir ligacao a um
   * repositorio remoto
   *
   * @param command
   * @return
   */
  @POST
  @Path("/receiveUpdates")
  @Consumes(MediaType.APPLICATION_XML)
  public Response receiveUpdates(Command command) throws Exception {

    Hidra hidra;
    String user = command.getUser();
    String password = command.getPassword();
    String path = command.getRepositoryPath();
    ResultMessage result = new ResultMessage();

    if (path.isEmpty()) {
      throw new DataNotFoundException("The absolute path of the repository has not been set");
    }
    if (!new File(path).exists()) {
      throw new IOException("Could not find the informed repository");
    }

    hidra = new Hidra(path);

    if (hidra.receiveUpdates(user, password)) {
      result.setMessage("Repository Updated");
      result.setStatusMessage(Status.OK);
      return Response.status(Status.OK).entity(result).build();
    }

    throw new Exception("Could not update");
  }
Exemple #2
0
  /**
   * Servico responsavel por criar uma copia local de um repositorio remoto atravez de autenticacao.
   * Consome um XML padronizado (Command) contendo artifact URL do repositorio que se deseja clonar
   * e tambem o caminho absoluto do diretorio destino e usuario e senha para acesso ao repositorio
   * remoto.
   *
   * @param command
   * @return
   * @throws java.io.IOException
   */
  @POST
  @Path("/startSynchronizedRepositoryAuthentication")
  @Consumes(MediaType.APPLICATION_XML)
  @Produces(MediaType.APPLICATION_XML)
  public Response startSynchronizedRepositoryAuthentication(Command command)
      throws IOException, Exception {

    Hidra hidra = new Hidra();
    String user = command.getUser();
    String password = command.getPassword();
    ResultMessage result = new ResultMessage();
    String remotePath = command.getRemoteRepository();
    String cloneToDirectory = command.getRepositoryLocalCopy();

    if (remotePath.isEmpty() || cloneToDirectory.isEmpty()) {
      throw new DataNotFoundException(
          "The absolute path of the remote repository Or the destiny has not been set");
    }
    if (user.isEmpty() || password.isEmpty()) {
      throw new DataNotFoundException("User or Password has not been set");
    }
    if (new File(cloneToDirectory).exists() && new File(cloneToDirectory).listFiles().length != 0) {
      throw new IOException("Destination already exists");
    }

    if (hidra.startSynchronizedRepository(cloneToDirectory, remotePath, user, password)) {
      result.setMessage("Repository successfully cloned in " + cloneToDirectory);
      result.setStatusMessage(Status.OK);
      return Response.status(Status.OK).entity(result).build();
    }

    throw new Exception("Could not clone remote repository: User or Password incorrect");
  }