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

Fin Reinhard
22.51.2019 1c087fae322a1b07bb7bd554ee10ff473c47c727
borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/ConfigurationRest.java
@@ -3,6 +3,8 @@
import de.micromata.borgbutler.cache.ButlerCache;
import de.micromata.borgbutler.config.ConfigurationHandler;
import de.micromata.borgbutler.json.JsonUtils;
import de.micromata.borgbutler.server.BorgInstallation;
import de.micromata.borgbutler.server.BorgVersion;
import de.micromata.borgbutler.server.ServerConfiguration;
import de.micromata.borgbutler.server.user.UserData;
import de.micromata.borgbutler.server.user.UserManager;
@@ -17,14 +19,14 @@
public class ConfigurationRest {
    private Logger log = LoggerFactory.getLogger(ConfigurationRest.class);
    @GET
    @Path("config")
    @Produces(MediaType.APPLICATION_JSON)
    /**
     *
     * @param prettyPrinter If true then the json output will be in pretty format.
     * @see JsonUtils#toJson(Object, boolean)
     */
    @GET
    @Path("config")
    @Produces(MediaType.APPLICATION_JSON)
    public String getConfig(@QueryParam("prettyPrinter") boolean prettyPrinter) {
        String json = JsonUtils.toJson(ServerConfiguration.get(), prettyPrinter);
        return json;
@@ -37,18 +39,20 @@
        ConfigurationHandler configurationHandler = ConfigurationHandler.getInstance();
        ServerConfiguration config = (ServerConfiguration)configurationHandler.getConfiguration();
        ServerConfiguration srcConfig = JsonUtils.fromJson(ServerConfiguration.class, jsonConfig);
        BorgVersion oldBorgVersion = config.getBorgVersion();
        config.copyFrom(srcConfig);
        BorgInstallation.getInstance().configure(oldBorgVersion);
        configurationHandler.save();
    }
    @GET
    @Path("user")
    @Produces(MediaType.APPLICATION_JSON)
    /**
     *
     * @param prettyPrinter If true then the json output will be in pretty format.
     * @see JsonUtils#toJson(Object, boolean)
     */
    @GET
    @Path("user")
    @Produces(MediaType.APPLICATION_JSON)
    public String getUser(@QueryParam("prettyPrinter") boolean prettyPrinter) {
        UserData user = RestUtils.getUser();
        String json = JsonUtils.toJson(user, prettyPrinter);