/** * Servico responsavel por gravar as alteracoes no repositorio. Consome XML padronizado (Command) * contendo o caminho absoluto do repositorio que se deseja utilizar. * * @param command * @return * @throws java.io.IOException */ @POST @Path("/save") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) public Response save(Command command) throws IOException, Exception { Hidra hidra; ResultMessage result = new ResultMessage(); String path = command.getRepositoryPath(); String message = command.getSubmitMessage().isEmpty() ? DEFAULT_MESSAGE_SUBMIT : command.getSubmitMessage(); 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.save(command.getSubmitMessage())) { result.setMessage(message); result.setStatusMessage(Status.OK); return Response.status(Status.OK).entity(result).build(); } throw new Exception("Could not commit changes to the repository"); }