mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
16.20.2018 47b27687ea1e77e7d6ae26eb0e47ab85e90c5d50
borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/ReposRest.java
@@ -21,6 +21,23 @@
    private static Logger log = LoggerFactory.getLogger(ReposRest.class);
    @GET
    @Path("list")
    @Produces(MediaType.APPLICATION_JSON)
    /**
     *
     * @param prettyPrinter If true then the json output will be in pretty format.
     * @return A list of repositories of type {@link BorgRepository}.
     * @see JsonUtils#toJson(Object, boolean)
     */
    public String getList(@QueryParam("prettyPrinter") boolean prettyPrinter) {
        List<Repository> repositories = ButlerCache.getInstance().getAllRepositories();
        if (CollectionUtils.isEmpty(repositories)) {
            return "";
        }
        return JsonUtils.toJson(repositories, prettyPrinter);
    }
    @GET
    @Path("repo")
    @Produces(MediaType.APPLICATION_JSON)
    /**
@@ -72,25 +89,4 @@
        Archive archive = ButlerCache.getInstance().getArchive(repoName, archiveIdOrName, force);
        return JsonUtils.toJson(archive, prettyPrinter);
    }
    @GET
    @Path("list")
    @Produces(MediaType.APPLICATION_JSON)
    /**
     *
     * @param force If true, a reload of all repositories is forced.
     * @param prettyPrinter If true then the json output will be in pretty format.
     * @return A list of repositories of type {@link BorgRepository}.
     * @see JsonUtils#toJson(Object, boolean)
     */
    public String getList(@QueryParam("force") boolean force, @QueryParam("prettyPrinter") boolean prettyPrinter) {
        if (force) {
            ButlerCache.getInstance().clearRepoCacheAccess();
        }
        List<Repository> repositories = ButlerCache.getInstance().getAllRepositories();
        if (CollectionUtils.isEmpty(repositories)) {
            return "";
        }
        return JsonUtils.toJson(repositories, prettyPrinter);
    }
}