borgbutler-core/build.gradle
@@ -1,5 +1,4 @@ plugins { id 'io.franzbecker.gradle-lombok' version '1.14' id 'java' } @@ -18,9 +17,6 @@ compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.8' compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.8' compileOnly "org.projectlombok:lombok:1.18.4" testCompileOnly "org.projectlombok:lombok:1.18.4" } repositories { @@ -28,11 +24,6 @@ jcenter() } lombok { version = '1.18.4' sha256 = "" // skip verifyLombok task } test { // set heap size for the test JVM(s) minHeapSize = "128m" borgbutler-core/lombok.config
File was deleted borgbutler-core/src/main/java/de/micromata/borgbutler/BorgCommand.java
@@ -1,9 +1,6 @@ package de.micromata.borgbutler; import de.micromata.borgbutler.config.BorgRepoConfig; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,33 +13,19 @@ public class BorgCommand { private Logger log = LoggerFactory.getLogger(BorgCommand.class); @Getter @Setter private File workingDir; @Getter private String[] args; @Getter private String[] params; @Getter @Setter private BorgRepoConfig repoConfig; @Getter @Setter private String command; @Getter @Setter private String archive; /** * For displaying and information purposes for the user only, when browsing the current command queue. */ @Setter @Getter private String description; /** * The result of the call will be written to this String. */ @Getter @Setter(AccessLevel.PACKAGE) private String response; BorgCommand setArgs(String... args) { @@ -72,4 +55,66 @@ public String getAbbreviatedResponse() { return StringUtils.abbreviate(response, 1000); } public File getWorkingDir() { return this.workingDir; } public String[] getArgs() { return this.args; } public String[] getParams() { return this.params; } public BorgRepoConfig getRepoConfig() { return this.repoConfig; } public String getCommand() { return this.command; } public String getArchive() { return this.archive; } public String getDescription() { return this.description; } public String getResponse() { return this.response; } public BorgCommand setWorkingDir(File workingDir) { this.workingDir = workingDir; return this; } public BorgCommand setRepoConfig(BorgRepoConfig repoConfig) { this.repoConfig = repoConfig; return this; } public BorgCommand setCommand(String command) { this.command = command; return this; } public BorgCommand setArchive(String archive) { this.archive = archive; return this; } public BorgCommand setDescription(String description) { this.description = description; return this; } BorgCommand setResponse(String response) { this.response = response; return this; } } borgbutler-core/src/main/java/de/micromata/borgbutler/BorgCommandResult.java
@@ -1,21 +1,14 @@ package de.micromata.borgbutler; import de.micromata.borgbutler.jobs.JobResult; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; /** * Holder of result object of borg commands. Holds the result object as well as error messages and status. */ public class BorgCommandResult<T> { @Getter @Setter(AccessLevel.PACKAGE) private T object; @Getter @Setter(AccessLevel.PACKAGE) private JobResult<String> jobResult; public JobResult.Status getStatus() { @@ -28,4 +21,22 @@ } return "Unkown error... (please refer the log files)"; } public T getObject() { return this.object; } public JobResult<String> getJobResult() { return this.jobResult; } BorgCommandResult<T> setObject(T object) { this.object = object; return this; } BorgCommandResult<T> setJobResult(JobResult<String> jobResult) { this.jobResult = jobResult; return this; } } borgbutler-core/src/main/java/de/micromata/borgbutler/BorgCommands.java
@@ -105,16 +105,16 @@ String resultJson = result.getJobResult().getResultObject(); BorgRepoInfo repoInfo = JsonUtils.fromJson(BorgRepoInfo.class, resultJson); BorgRepository borgRepository = repoInfo.getRepository(); Repository repository = new Repository() .setId(borgRepository.getId()) .setName(repoConfig.getRepo()) .setDisplayName(repoConfig.getDisplayName()) .setLastModified(DateUtils.format(borgRepository.getLastModified())) .setLocation(borgRepository.getLocation()) .setCache(repoInfo.getCache()) .setEncryption(repoInfo.getEncryption()) .setSecurityDir(repoInfo.getSecurityDir()) .setLastCacheRefresh(DateUtils.format(LocalDateTime.now())); Repository repository = new Repository(); repository.setId(borgRepository.getId()); repository.setName(repoConfig.getRepo()); repository.setDisplayName(repoConfig.getDisplayName()); repository.setLastModified(DateUtils.format(borgRepository.getLastModified())); repository.setLocation(borgRepository.getLocation()); repository.setCache(repoInfo.getCache()); repository.setEncryption(repoInfo.getEncryption()); repository.setSecurityDir(repoInfo.getSecurityDir()); repository.setLastCacheRefresh(DateUtils.format(LocalDateTime.now())); DemoRepos.repoWasRead(repoConfig, repository); return result.setObject(repository); } @@ -143,8 +143,8 @@ log.error("Can't load archives from repo '" + repository.getName() + "'."); return; } repository.setLastModified(DateUtils.format(repoList.getRepository().getLastModified())) .setLastCacheRefresh(DateUtils.format(LocalDateTime.now())); repository.setLastModified(DateUtils.format(repoList.getRepository().getLastModified())); repository.setLastCacheRefresh(DateUtils.format(LocalDateTime.now())); for (BorgArchive borgArchive : repoList.getArchives()) { Archive archive = new Archive() .setName(borgArchive.getArchive()) @@ -184,8 +184,8 @@ log.error("Archive '" + command.getRepoArchive() + "' not found."); return; } repository.setLastModified(DateUtils.format(archiveInfo.getRepository().getLastModified())) .setLastCacheRefresh(DateUtils.format(LocalDateTime.now())); repository.setLastModified(DateUtils.format(archiveInfo.getRepository().getLastModified())); repository.setLastCacheRefresh(DateUtils.format(LocalDateTime.now())); archive.setCache(archiveInfo.getCache()) .setEncryption(archiveInfo.getEncryption()); if (CollectionUtils.isEmpty(archiveInfo.getArchives())) { borgbutler-core/src/main/java/de/micromata/borgbutler/BorgJob.java
@@ -8,9 +8,6 @@ import de.micromata.borgbutler.jobs.JobResult; import de.micromata.borgbutler.json.JsonUtils; import de.micromata.borgbutler.json.borg.ProgressInfo; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.environment.EnvironmentUtils; import org.apache.commons.lang3.StringUtils; @@ -26,16 +23,12 @@ */ public class BorgJob<T> extends AbstractCommandLineJob implements Cloneable { private Logger log = LoggerFactory.getLogger(BorgJob.class); @Getter private BorgCommand command; /** * Some jobs may store here the result of the command (e. g. {@link BorgCommands#listArchiveContent(BorgRepoConfig, Archive)}). */ @Getter protected T payload; @Getter @Setter(AccessLevel.PROTECTED) private ProgressInfo progressInfo; public BorgJob(BorgCommand command) { @@ -141,4 +134,21 @@ super.cleanUp(); payload = null; } public BorgCommand getCommand() { return this.command; } public T getPayload() { return this.payload; } public ProgressInfo getProgressInfo() { return this.progressInfo; } protected BorgJob<T> setProgressInfo(ProgressInfo progressInfo) { this.progressInfo = progressInfo; return this; } } borgbutler-core/src/main/java/de/micromata/borgbutler/BorgQueueStatistics.java
@@ -1,19 +1,29 @@ package de.micromata.borgbutler; import lombok.Getter; /** * Statistics of all the job queues, especially the number of total queued and running jobs. * This is used e. g. by the client for showing a badge near to the menu entry "job monitor" with the number * of Jobs in the queues. */ public class BorgQueueStatistics { @Getter int numberOfRunningAndQueuedJobs = 0; @Getter int numberOfOldJobs = 0; @Getter int numberOfActiveQueues = 0; @Getter int totalNumberOfQueues = 0; public int getNumberOfRunningAndQueuedJobs() { return this.numberOfRunningAndQueuedJobs; } public int getNumberOfOldJobs() { return this.numberOfOldJobs; } public int getNumberOfActiveQueues() { return this.numberOfActiveQueues; } public int getTotalNumberOfQueues() { return this.totalNumberOfQueues; } } borgbutler-core/src/main/java/de/micromata/borgbutler/cache/ButlerCache.java
@@ -106,10 +106,10 @@ // Temporary id: repoConfig.setId("not_yet_loaded_" + notYetLoadedIdCounter++); } repository = new Repository() .setDisplayName(repoConfig.getDisplayName()) .setName(repoConfig.getRepo()) .setId(repoConfig.getId()); repository = new Repository(); repository.setDisplayName(repoConfig.getDisplayName()); repository.setName(repoConfig.getRepo()); repository.setId(repoConfig.getId()); } else if (repoConfig.getId() == null) { // On initial call, the repo id is not assigned to BorgRepoConfig for cached repositories: repoConfig.setId(repository.getId()); borgbutler-core/src/main/java/de/micromata/borgbutler/cache/JCSCache.java
@@ -1,7 +1,6 @@ package de.micromata.borgbutler.cache; import de.micromata.borgbutler.config.ConfigurationHandler; import lombok.Getter; import org.apache.commons.jcs.JCS; import org.apache.commons.jcs.access.CacheAccess; import org.slf4j.Logger; @@ -22,7 +21,6 @@ return instance; } @Getter private File cacheDir; public <K, V> CacheAccess<K, V> getJCSCache(String region) { @@ -49,4 +47,8 @@ //props.setProperty("jcs.auxiliary.DC2.attributes.MaxKeySize", String.valueOf(cacheMaxDiscSizeMB * 1000)); JCS.setConfigProperties(props); } public File getCacheDir() { return this.cacheDir; } } borgbutler-core/src/main/java/de/micromata/borgbutler/config/BorgRepoConfig.java
@@ -1,8 +1,6 @@ package de.micromata.borgbutler.config; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; @@ -12,23 +10,11 @@ /** * A name describing this config. Only used for displaying purposes. */ @Getter @Setter private String displayName; @Getter @Setter private String repo; @Getter @Setter private String rsh; @Getter @Setter private String passphrase; @Getter @Setter private String passwordCommand; @Getter @Setter private String id; @JsonIgnore @@ -59,4 +45,52 @@ this.passphrase = other.passphrase; this.passwordCommand = other.passwordCommand; } public String getDisplayName() { return this.displayName; } public String getRepo() { return this.repo; } public String getRsh() { return this.rsh; } public String getPassphrase() { return this.passphrase; } public String getPasswordCommand() { return this.passwordCommand; } public String getId() { return this.id; } public void setDisplayName(String displayName) { this.displayName = displayName; } public void setRepo(String repo) { this.repo = repo; } public void setRsh(String rsh) { this.rsh = rsh; } public void setPassphrase(String passphrase) { this.passphrase = passphrase; } public void setPasswordCommand(String passwordCommand) { this.passwordCommand = passwordCommand; } public void setId(String id) { this.id = id; } } borgbutler-core/src/main/java/de/micromata/borgbutler/config/Configuration.java
@@ -3,9 +3,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import de.micromata.borgbutler.demo.DemoRepos; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,29 +19,22 @@ private static final String RESTORE_DIRNAME = "restore"; @JsonIgnore @Setter(AccessLevel.PACKAGE) private File workingDir; /** * The path of the borg command to use. */ @Getter @Setter private String borgCommand; /** * Default is 100 MB (approximately). */ @Getter private int maxArchiveContentCacheCapacityMb = 100; @Getter @Setter private boolean showDemoRepos = true; /** * Default is restore inside BorgButler's home dir (~/.borgbutler/restore). */ @Getter @JsonProperty("restoreDir") private String restoreDirPath; @JsonIgnore @@ -114,4 +104,35 @@ List<BorgRepoConfig> getRepoConfigs() { return repoConfigs; } public String getBorgCommand() { return this.borgCommand; } public int getMaxArchiveContentCacheCapacityMb() { return this.maxArchiveContentCacheCapacityMb; } public boolean isShowDemoRepos() { return this.showDemoRepos; } public String getRestoreDirPath() { return this.restoreDirPath; } Configuration setWorkingDir(File workingDir) { this.workingDir = workingDir; return this; } public Configuration setBorgCommand(String borgCommand) { this.borgCommand = borgCommand; return this; } public Configuration setShowDemoRepos(boolean showDemoRepos) { this.showDemoRepos = showDemoRepos; return this; } } borgbutler-core/src/main/java/de/micromata/borgbutler/config/ConfigurationHandler.java
@@ -1,8 +1,6 @@ package de.micromata.borgbutler.config; import de.micromata.borgbutler.json.JsonUtils; import lombok.Getter; import lombok.Setter; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -19,13 +17,10 @@ private static final String BUTLER_HOME_DIR = ".borgbutler"; private static final String CONFIG_FILENAME = "borgbutler-config.json"; private static final String CONFIG_BACKUP_DIR = "backup"; @Getter private File configFile; private File configBackupDir; @Getter private File workingDir; private Configuration configuration; @Setter private static Class<? extends Configuration> configClazz = Configuration.class; public static ConfigurationHandler getInstance() { @@ -37,6 +32,10 @@ return getInstance().configuration; } public static void setConfigClazz(Class<? extends Configuration> configClazz) { ConfigurationHandler.configClazz = configClazz; } private void read() { log.info("Reading config file '" + configFile.getAbsolutePath() + "'"); try { @@ -112,4 +111,12 @@ } read(); } public File getConfigFile() { return this.configFile; } public File getWorkingDir() { return this.workingDir; } } borgbutler-core/src/main/java/de/micromata/borgbutler/data/Archive.java
@@ -4,8 +4,6 @@ import de.micromata.borgbutler.json.borg.BorgArchiveStats; import de.micromata.borgbutler.json.borg.BorgCache; import de.micromata.borgbutler.json.borg.BorgEncryption; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; import java.io.Serializable; @@ -18,81 +16,41 @@ /** * For convenience purposes for the client. */ @Getter @Setter private String repoName; /** * For convenience purposes for the client. */ @Getter @Setter private String repoDisplayName; /** * For convenience purposes for the client. */ @Getter @Setter private String repoId; @Getter @Setter private String name; @Getter @Setter private String id; @Getter @Setter private BorgCache cache; @Getter @Setter private BorgEncryption encryption; @Getter @Setter private int[] chunkerParams; /** * The command line used for creating this archive: borg create --filter... */ @Getter @Setter private String[] commandLine; @Getter @Setter private String comment; @Getter @Setter private String start; @Getter @Setter private String end; @Getter @Setter private String time; @Getter @Setter private String duration; @Getter @Setter private BorgArchiveStats stats; @Getter @Setter private BorgArchiveLimits limits; @Getter @Setter private String username; @Getter @Setter private String hostname; /** * For comparing functionality. */ @Getter @Setter private List<ArchiveShortInfo> archiveShortInfoList; /** * Is the file list of this archive loaded and available in Butler's cache. */ @Getter @Setter private boolean fileListAlreadyCached; /** @@ -123,4 +81,184 @@ // Reverse order: return StringUtils.compare(o.time, this.time); } public String getRepoName() { return this.repoName; } public String getRepoDisplayName() { return this.repoDisplayName; } public String getRepoId() { return this.repoId; } public String getName() { return this.name; } public String getId() { return this.id; } public BorgCache getCache() { return this.cache; } public BorgEncryption getEncryption() { return this.encryption; } public int[] getChunkerParams() { return this.chunkerParams; } public String[] getCommandLine() { return this.commandLine; } public String getComment() { return this.comment; } public String getStart() { return this.start; } public String getEnd() { return this.end; } public String getTime() { return this.time; } public String getDuration() { return this.duration; } public BorgArchiveStats getStats() { return this.stats; } public BorgArchiveLimits getLimits() { return this.limits; } public String getUsername() { return this.username; } public String getHostname() { return this.hostname; } public List<ArchiveShortInfo> getArchiveShortInfoList() { return this.archiveShortInfoList; } public boolean isFileListAlreadyCached() { return this.fileListAlreadyCached; } public Archive setRepoName(String repoName) { this.repoName = repoName; return this; } public Archive setRepoDisplayName(String repoDisplayName) { this.repoDisplayName = repoDisplayName; return this; } public Archive setRepoId(String repoId) { this.repoId = repoId; return this; } public Archive setName(String name) { this.name = name; return this; } public Archive setId(String id) { this.id = id; return this; } public Archive setCache(BorgCache cache) { this.cache = cache; return this; } public Archive setEncryption(BorgEncryption encryption) { this.encryption = encryption; return this; } public Archive setChunkerParams(int[] chunkerParams) { this.chunkerParams = chunkerParams; return this; } public Archive setCommandLine(String[] commandLine) { this.commandLine = commandLine; return this; } public Archive setComment(String comment) { this.comment = comment; return this; } public Archive setStart(String start) { this.start = start; return this; } public Archive setEnd(String end) { this.end = end; return this; } public Archive setTime(String time) { this.time = time; return this; } public Archive setDuration(String duration) { this.duration = duration; return this; } public Archive setStats(BorgArchiveStats stats) { this.stats = stats; return this; } public Archive setLimits(BorgArchiveLimits limits) { this.limits = limits; return this; } public Archive setUsername(String username) { this.username = username; return this; } public Archive setHostname(String hostname) { this.hostname = hostname; return this; } public Archive setArchiveShortInfoList(List<ArchiveShortInfo> archiveShortInfoList) { this.archiveShortInfoList = archiveShortInfoList; return this; } public Archive setFileListAlreadyCached(boolean fileListAlreadyCached) { this.fileListAlreadyCached = fileListAlreadyCached; return this; } } borgbutler-core/src/main/java/de/micromata/borgbutler/data/ArchiveShortInfo.java
@@ -1,7 +1,5 @@ package de.micromata.borgbutler.data; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; import java.io.Serializable; @@ -13,26 +11,14 @@ /** * For convenience purposes for the client. */ @Getter @Setter private String repoName; @Getter @Setter private String repoId; @Getter @Setter private String name; @Getter @Setter private String id; @Getter @Setter private String time; /** * Is the file list of this archive loaded and available in Butler's cache. */ @Getter @Setter private boolean fileListAlreadyCached; public ArchiveShortInfo() { @@ -58,4 +44,58 @@ // Reverse order: return StringUtils.compare(o.time, this.time); } public String getRepoName() { return this.repoName; } public String getRepoId() { return this.repoId; } public String getName() { return this.name; } public String getId() { return this.id; } public String getTime() { return this.time; } public boolean isFileListAlreadyCached() { return this.fileListAlreadyCached; } public ArchiveShortInfo setRepoName(String repoName) { this.repoName = repoName; return this; } public ArchiveShortInfo setRepoId(String repoId) { this.repoId = repoId; return this; } public ArchiveShortInfo setName(String name) { this.name = name; return this; } public ArchiveShortInfo setId(String id) { this.id = id; return this; } public ArchiveShortInfo setTime(String time) { this.time = time; return this; } public ArchiveShortInfo setFileListAlreadyCached(boolean fileListAlreadyCached) { this.fileListAlreadyCached = fileListAlreadyCached; return this; } } borgbutler-core/src/main/java/de/micromata/borgbutler/data/FileSystemFilter.java
@@ -1,8 +1,6 @@ package de.micromata.borgbutler.data; import de.micromata.borgbutler.json.borg.BorgFilesystemItem; import lombok.Getter; import lombok.Setter; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -13,37 +11,70 @@ public class FileSystemFilter { private Logger log = LoggerFactory.getLogger(FileSystemFilter.class); public String getSearchString() { return this.searchString; } public Mode getMode() { return this.mode; } public boolean isAutoChangeDirectoryToLeafItem() { return this.autoChangeDirectoryToLeafItem; } public String getCurrentDirectory() { return this.currentDirectory; } public int getMaxResultSize() { return this.maxResultSize; } public Integer getFileNumber() { return this.fileNumber; } public boolean isFinished() { return this.finished; } public FileSystemFilter setAutoChangeDirectoryToLeafItem(boolean autoChangeDirectoryToLeafItem) { this.autoChangeDirectoryToLeafItem = autoChangeDirectoryToLeafItem; return this; } public FileSystemFilter setMaxResultSize(int maxResultSize) { this.maxResultSize = maxResultSize; return this; } public FileSystemFilter setFileNumber(Integer fileNumber) { this.fileNumber = fileNumber; return this; } public enum Mode {FLAT, TREE} @Getter private String searchString; @Getter private Mode mode; /** * If true (default): Step in tree view automatically recursively into sub directory if only one sub directory exists in * current directory. If false, also a single directory of the current directory is displayed.<br> * Has no effect in flat mode. */ @Getter @Setter private boolean autoChangeDirectoryToLeafItem = true; @Getter private String currentDirectory; // For storing sub directories of the currentDirectory private Map<String, BorgFilesystemItem> subDirectories; @Getter @Setter private int maxResultSize = -1; /** * If given, only the file assigned to this number is searched and returned. */ @Getter @Setter private Integer fileNumber; private String[] searchKeyWords; private String[] blackListSearchKeyWords; private int counter = 0; @Getter private boolean finished; /** borgbutler-core/src/main/java/de/micromata/borgbutler/data/Repository.java
@@ -3,8 +3,6 @@ import de.micromata.borgbutler.config.BorgRepoConfig; import de.micromata.borgbutler.json.borg.BorgCache; import de.micromata.borgbutler.json.borg.BorgEncryption; import lombok.Getter; import lombok.Setter; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -27,8 +25,6 @@ * * @see BorgRepoConfig#getRepo() */ @Getter @Setter String name; /** * A name describing this config. Only used for displaying purposes. This is automatically set with the name @@ -36,42 +32,25 @@ * * @see BorgRepoConfig#getDisplayName() */ @Getter @Setter String displayName; @Getter @Setter private String id; /** * Date given by Borg server. */ @Getter @Setter private String lastModified; /** * Last date of getting this object from Borg server. */ @Getter @Setter private String lastCacheRefresh; @Getter @Setter private String location; @Getter @Setter private String securityDir; @Getter @Setter private BorgCache cache; @Getter @Setter private BorgEncryption encryption; /** * Might be null. */ @Setter private SortedSet<Archive> archives; public Repository add(Archive archive) { @@ -119,4 +98,80 @@ return Collections.unmodifiableSet(this.archives); } } public String getName() { return this.name; } public String getDisplayName() { return this.displayName; } public String getId() { return this.id; } public String getLastModified() { return this.lastModified; } public String getLastCacheRefresh() { return this.lastCacheRefresh; } public String getLocation() { return this.location; } public String getSecurityDir() { return this.securityDir; } public BorgCache getCache() { return this.cache; } public BorgEncryption getEncryption() { return this.encryption; } public void setName(String name) { this.name = name; } public void setDisplayName(String displayName) { this.displayName = displayName; } public void setId(String id) { this.id = id; } public void setLastModified(String lastModified) { this.lastModified = lastModified; } public void setLastCacheRefresh(String lastCacheRefresh) { this.lastCacheRefresh = lastCacheRefresh; } public void setLocation(String location) { this.location = location; } public void setSecurityDir(String securityDir) { this.securityDir = securityDir; } public void setCache(BorgCache cache) { this.cache = cache; } public void setEncryption(BorgEncryption encryption) { this.encryption = encryption; } public void setArchives(SortedSet<Archive> archives) { this.archives = archives; } } borgbutler-core/src/main/java/de/micromata/borgbutler/demo/DemoRepos.java
@@ -18,7 +18,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; import java.util.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Scanner; public class DemoRepos { private enum Type {FAST, SLOW, VERY_SLOW} @@ -35,7 +38,7 @@ * @param repositoryList * @return repo list including demo repos if configured. If not configured, the given list is returned (no op). */ public static List<BorgRepoConfig> getAllRepos(List<BorgRepoConfig> repositoryList) { public static List<BorgRepoConfig> getAllRepos(List<BorgRepoConfig> repositoryList) { if (!ConfigurationHandler.getConfiguration().isShowDemoRepos()) { return repositoryList; } @@ -145,15 +148,20 @@ } } demoRepos = new ArrayList<>(); demoRepos.add(new BorgRepoConfig() .setRepo(DEMO_IDENTIFIER + "-fast") .setDisplayName("Demo repository fast")); demoRepos.add(new BorgRepoConfig() .setRepo(DEMO_IDENTIFIER + "-slow") .setDisplayName("Demo repository slow")); demoRepos.add(new BorgRepoConfig() .setRepo(DEMO_IDENTIFIER + "-very-slow") .setDisplayName("Demo repository very-slow")); BorgRepoConfig config = new BorgRepoConfig(); config.setRepo(DEMO_IDENTIFIER + "-fast"); config.setDisplayName("Demo repository fast"); demoRepos.add(config); config = new BorgRepoConfig(); config.setRepo(DEMO_IDENTIFIER + "-slow"); config.setDisplayName("Demo repository slow"); demoRepos.add(config); config = new BorgRepoConfig(); config.setRepo(DEMO_IDENTIFIER + "-very-slow"); config.setDisplayName("Demo repository very-slow"); demoRepos.add(config); } } } borgbutler-core/src/main/java/de/micromata/borgbutler/jobs/AbstractCommandLineJob.java
@@ -1,9 +1,6 @@ package de.micromata.borgbutler.jobs; import de.micromata.borgbutler.config.Definitions; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import org.apache.commons.exec.*; import org.apache.commons.exec.environment.EnvironmentUtils; import org.apache.commons.io.output.ByteArrayOutputStream; @@ -22,20 +19,13 @@ public abstract class AbstractCommandLineJob extends AbstractJob<String> { private Logger log = LoggerFactory.getLogger(AbstractCommandLineJob.class); private ExecuteWatchdog watchdog; @Getter @Setter(AccessLevel.PROTECTED) private boolean executeStarted; private CommandLine commandLine; /** * The command line as string. This property is also used as ID for detecting multiple borg calls. */ @Setter(AccessLevel.PROTECTED) private String commandLineAsString; @Getter @Setter private File workingDirectory; @Getter @Setter private String description; protected ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); protected ByteArrayOutputStream errorOutputStream = new ByteArrayOutputStream(); @@ -177,4 +167,36 @@ outputStream = null; errorOutputStream = null; } public boolean isExecuteStarted() { return this.executeStarted; } public File getWorkingDirectory() { return this.workingDirectory; } public String getDescription() { return this.description; } protected AbstractCommandLineJob setExecuteStarted(boolean executeStarted) { this.executeStarted = executeStarted; return this; } protected AbstractCommandLineJob setCommandLineAsString(String commandLineAsString) { this.commandLineAsString = commandLineAsString; return this; } public AbstractCommandLineJob setWorkingDirectory(File workingDirectory) { this.workingDirectory = workingDirectory; return this; } public AbstractCommandLineJob setDescription(String description) { this.description = description; return this; } } borgbutler-core/src/main/java/de/micromata/borgbutler/jobs/AbstractJob.java
@@ -1,9 +1,6 @@ package de.micromata.borgbutler.jobs; import de.micromata.borgbutler.utils.DateUtils; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,30 +11,82 @@ public abstract class AbstractJob<T> { private Logger logger = LoggerFactory.getLogger(AbstractJob.class); public boolean isCancellationRequested() { return this.cancellationRequested; } public Status getStatus() { return this.status; } public String getTitle() { return this.title; } Future<JobResult<T>> getFuture() { return this.future; } public long getUniqueJobNumber() { return this.uniqueJobNumber; } public String getCreateTime() { return this.createTime; } public String getStartTime() { return this.startTime; } public String getStopTime() { return this.stopTime; } public AbstractJob<T> setCancellationRequested(boolean cancellationRequested) { this.cancellationRequested = cancellationRequested; return this; } public AbstractJob<T> setTitle(String title) { this.title = title; return this; } AbstractJob<T> setFuture(Future<JobResult<T>> future) { this.future = future; return this; } protected AbstractJob<T> setUniqueJobNumber(long uniqueJobNumber) { this.uniqueJobNumber = uniqueJobNumber; return this; } public AbstractJob<T> setCreateTime(String createTime) { this.createTime = createTime; return this; } public AbstractJob<T> setStartTime(String startTime) { this.startTime = startTime; return this; } public AbstractJob<T> setStopTime(String stopTime) { this.stopTime = stopTime; return this; } public enum Status {DONE, RUNNING, QUEUED, CANCELLED, FAILED} @Getter @Setter private boolean cancellationRequested; @Getter private Status status; @Getter @Setter private String title; @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) private Future<JobResult<T>> future; @Getter @Setter(AccessLevel.PROTECTED) private long uniqueJobNumber = -1; @Getter @Setter private String createTime; @Getter @Setter private String startTime; @Getter @Setter private String stopTime; protected AbstractJob<T> setStatus(Status status) { borgbutler-core/src/main/java/de/micromata/borgbutler/jobs/JobResult.java
@@ -1,17 +1,35 @@ package de.micromata.borgbutler.jobs; import lombok.Getter; import lombok.Setter; public class JobResult<T> { public Status getStatus() { return this.status; } public T getResultObject() { return this.resultObject; } public String getErrorString() { return this.errorString; } public JobResult<T> setStatus(Status status) { this.status = status; return this; } public JobResult<T> setResultObject(T resultObject) { this.resultObject = resultObject; return this; } public JobResult<T> setErrorString(String errorString) { this.errorString = errorString; return this; } public enum Status {OK, ERROR} @Getter @Setter private Status status; @Getter @Setter private T resultObject; @Getter @Setter private String errorString; } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgArchive.java
@@ -1,7 +1,6 @@ package de.micromata.borgbutler.json.borg; import de.micromata.borgbutler.json.JsonUtils; import lombok.Getter; import java.io.Serializable; @@ -10,21 +9,39 @@ */ public class BorgArchive implements Serializable { private static final long serialVersionUID = -7872260170265536732L; @Getter private String archive; @Getter private String barchive; @Getter private String id; @Getter private String name; @Getter private String start; @Getter private String time; public String toString() { return JsonUtils.toJson(this, true); } public String getArchive() { return this.archive; } public String getBarchive() { return this.barchive; } public String getId() { return this.id; } public String getName() { return this.name; } public String getStart() { return this.start; } public String getTime() { return this.time; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgArchive2.java
@@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import de.micromata.borgbutler.json.JsonUtils; import lombok.Getter; import java.io.Serializable; @@ -11,33 +10,63 @@ */ public class BorgArchive2 implements Serializable { private static final long serialVersionUID = 4734056884088174992L; @Getter @JsonProperty("chunker_params") private int[] chunkerParams; /** * The command line used for creating this archive: borg create --filter... */ @Getter @JsonProperty("command_line") private String[] commandLine; @Getter private String comment; @Getter private String start; @Getter private String end; @Getter private String duration; @Getter private BorgArchiveStats stats; @Getter private BorgArchiveLimits limits; @Getter private String hostname; @Getter private String username; public String toString() { return JsonUtils.toJson(this, true); } public int[] getChunkerParams() { return this.chunkerParams; } public String[] getCommandLine() { return this.commandLine; } public String getComment() { return this.comment; } public String getStart() { return this.start; } public String getEnd() { return this.end; } public String getDuration() { return this.duration; } public BorgArchiveStats getStats() { return this.stats; } public BorgArchiveLimits getLimits() { return this.limits; } public String getHostname() { return this.hostname; } public String getUsername() { return this.username; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgArchiveInfo.java
@@ -1,7 +1,5 @@ package de.micromata.borgbutler.json.borg; import lombok.Getter; import java.io.Serializable; import java.util.List; @@ -10,12 +8,24 @@ */ public class BorgArchiveInfo implements Serializable { private static final long serialVersionUID = -4200553322856662346L; @Getter private List<BorgArchive2> archives; @Getter private BorgCache cache; @Getter private BorgEncryption encryption; @Getter private BorgRepository repository; public List<BorgArchive2> getArchives() { return this.archives; } public BorgCache getCache() { return this.cache; } public BorgEncryption getEncryption() { return this.encryption; } public BorgRepository getRepository() { return this.repository; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgArchiveLimits.java
@@ -1,13 +1,15 @@ package de.micromata.borgbutler.json.borg; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import java.io.Serializable; public class BorgArchiveLimits implements Serializable { private static final long serialVersionUID = -3079958893130481516L; @JsonProperty("max_archive_size") @Getter private double maxArchiveSize; public double getMaxArchiveSize() { return this.maxArchiveSize; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgArchiveStats.java
@@ -1,21 +1,32 @@ package de.micromata.borgbutler.json.borg; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import java.io.Serializable; public class BorgArchiveStats implements Serializable { private static final long serialVersionUID = -7603297185652222010L; @Getter @JsonProperty("compressed_size") private long compressedSize; @Getter @JsonProperty("deduplicated_size") private long deduplicatedSize; @Getter private long nfiles; @Getter @JsonProperty("original_size") private long originalSize; public long getCompressedSize() { return this.compressedSize; } public long getDeduplicatedSize() { return this.deduplicatedSize; } public long getNfiles() { return this.nfiles; } public long getOriginalSize() { return this.originalSize; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgCache.java
@@ -1,13 +1,17 @@ package de.micromata.borgbutler.json.borg; import lombok.Getter; import java.io.Serializable; public class BorgCache implements Serializable { private static final long serialVersionUID = -1728825838475013561L; @Getter private String path; @Getter private BorgStats stats; public String getPath() { return this.path; } public BorgStats getStats() { return this.stats; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgEncryption.java
@@ -1,11 +1,12 @@ package de.micromata.borgbutler.json.borg; import lombok.Getter; import java.io.Serializable; public class BorgEncryption implements Serializable { private static final long serialVersionUID = -4867140003118289187L; @Getter private String mode; public String getMode() { return this.mode; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgFilesystemItem.java
@@ -1,7 +1,5 @@ package de.micromata.borgbutler.json.borg; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; @@ -14,6 +12,133 @@ private transient static Logger log = LoggerFactory.getLogger(BorgFilesystemItem.class); private static final long serialVersionUID = -5545350851640655468L; public String getType() { return this.type; } public String getMode() { return this.mode; } public String getUser() { return this.user; } public String getGroup() { return this.group; } public long getUid() { return this.uid; } public long getGid() { return this.gid; } public String getPath() { return this.path; } public String getDisplayPath() { return this.displayPath; } public boolean isHealthy() { return this.healthy; } public String getSource() { return this.source; } public String getLinktarget() { return this.linktarget; } public String getFlags() { return this.flags; } public String getMtime() { return this.mtime; } public long getSize() { return this.size; } public int getFileNumber() { return this.fileNumber; } public DiffStatus getDiffStatus() { return this.diffStatus; } public BorgFilesystemItem getDiffItem() { return this.diffItem; } public String getDifferences() { return this.differences; } public BorgFilesystemItem setType(String type) { this.type = type; return this; } public BorgFilesystemItem setMode(String mode) { this.mode = mode; return this; } public BorgFilesystemItem setUser(String user) { this.user = user; return this; } public BorgFilesystemItem setUid(long uid) { this.uid = uid; return this; } public BorgFilesystemItem setPath(String path) { this.path = path; return this; } public BorgFilesystemItem setDisplayPath(String displayPath) { this.displayPath = displayPath; return this; } public BorgFilesystemItem setMtime(String mtime) { this.mtime = mtime; return this; } public BorgFilesystemItem setSize(long size) { this.size = size; return this; } public BorgFilesystemItem setFileNumber(int fileNumber) { this.fileNumber = fileNumber; return this; } public BorgFilesystemItem setDiffStatus(DiffStatus diffStatus) { this.diffStatus = diffStatus; return this; } public BorgFilesystemItem setDiffItem(BorgFilesystemItem diffItem) { this.diffItem = diffItem; return this; } /** * If running in diff mode, this flag specifies the type of difference. Null represents unmodified. */ @@ -22,69 +147,40 @@ /** * d (directory), - (file) */ @Getter @Setter private String type; /** * Unix mode, e. g. <tt>drwxr-xr-x</tt> */ @Getter @Setter private String mode; @Getter @Setter private String user; @Getter private String group; @Getter @Setter private long uid; @Getter private long gid; @Getter @Setter private String path; @Setter @Getter private String displayPath; @Getter private boolean healthy; @Getter private String source; @Getter private String linktarget; @Getter private String flags; @Getter @Setter private String mtime; @Getter @Setter private long size; /** * Represents the number of the file in the archive (for downloading). This field is created and only known by BorgButler. */ @Getter @Setter private int fileNumber = -1; /** * If created by diff tool, this flag represents the type of difference. */ @Getter @Setter private DiffStatus diffStatus; /** * If created by diff tool, this object holds the file item of the other archive (diff archive). */ @Getter @Setter private BorgFilesystemItem diffItem; /** * If created by diff tool, this String contains all differences between current and other item for {@link DiffStatus#MODIFIED}. * This String may used for displaying. */ @Getter private String differences; @Override borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgRepoInfo.java
@@ -1,7 +1,6 @@ package de.micromata.borgbutler.json.borg; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import java.io.Serializable; @@ -10,13 +9,25 @@ */ public class BorgRepoInfo implements Serializable { private static final long serialVersionUID = -1588038325129799400L; @Getter @JsonProperty("security_dir") private String securityDir; @Getter private BorgCache cache; @Getter private BorgEncryption encryption; @Getter private BorgRepository repository; public String getSecurityDir() { return this.securityDir; } public BorgCache getCache() { return this.cache; } public BorgEncryption getEncryption() { return this.encryption; } public BorgRepository getRepository() { return this.repository; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgRepoList.java
@@ -1,7 +1,5 @@ package de.micromata.borgbutler.json.borg; import lombok.Getter; import java.io.Serializable; import java.util.List; @@ -10,10 +8,19 @@ */ public class BorgRepoList implements Serializable { private static final long serialVersionUID = 1006757749929526034L; @Getter private List<BorgArchive> archives; @Getter private BorgEncryption encryption; @Getter private BorgRepository repository; public List<BorgArchive> getArchives() { return this.archives; } public BorgEncryption getEncryption() { return this.encryption; } public BorgRepository getRepository() { return this.repository; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgRepository.java
@@ -1,7 +1,6 @@ package de.micromata.borgbutler.json.borg; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import java.io.Serializable; @@ -10,11 +9,20 @@ */ public class BorgRepository implements Serializable { private static final long serialVersionUID = 1278802519434516280L; @Getter private String id; @Getter @JsonProperty("last_modified") private String lastModified; @Getter private String location; public String getId() { return this.id; } public String getLastModified() { return this.lastModified; } public String getLocation() { return this.location; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/BorgStats.java
@@ -1,28 +1,45 @@ package de.micromata.borgbutler.json.borg; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import java.io.Serializable; public class BorgStats implements Serializable { private static final long serialVersionUID = 9141985857856734073L; @Getter @JsonProperty("total_chunks") private long totalChunks; @Getter @JsonProperty("total_csize") private long totalCSize; @Getter @JsonProperty("total_size") private long totalSize; @Getter @JsonProperty("total_unique_chunks") private long totalUniqueChunks; @Getter @JsonProperty("unique_csize") private long uniqueCSize; @Getter @JsonProperty("unique_size") private long uniqueSize; public long getTotalChunks() { return this.totalChunks; } public long getTotalCSize() { return this.totalCSize; } public long getTotalSize() { return this.totalSize; } public long getTotalUniqueChunks() { return this.totalUniqueChunks; } public long getUniqueCSize() { return this.uniqueCSize; } public long getUniqueSize() { return this.uniqueSize; } } borgbutler-core/src/main/java/de/micromata/borgbutler/json/borg/ProgressInfo.java
@@ -1,8 +1,5 @@ package de.micromata.borgbutler.json.borg; import lombok.Getter; import lombok.Setter; /** * Output of borg option <tt>--progress</tt>. * See https://borgbackup.readthedocs.io/en/stable/internals/frontends.html, @@ -12,41 +9,29 @@ /** * e. g. Calculating statistics... 5% */ @Getter @Setter private String message; /** * Current counter of total. */ @Getter @Setter private long current; @Getter @Setter private long total; /** * Array that describes the current item, may be null, contents depend on msgid. */ @Getter private String[] info; /** * unique, opaque integer ID of the operation. */ @Getter private int operation; @Getter private String msgid; /** * e. g. progress_percent */ @Getter private String type; @Getter private boolean finished; /** * Unix timestamp (float). */ @Getter private double time; public ProgressInfo incrementCurrent() { @@ -64,4 +49,55 @@ } return clone; } public String getMessage() { return this.message; } public long getCurrent() { return this.current; } public long getTotal() { return this.total; } public String[] getInfo() { return this.info; } public int getOperation() { return this.operation; } public String getMsgid() { return this.msgid; } public String getType() { return this.type; } public boolean isFinished() { return this.finished; } public double getTime() { return this.time; } public ProgressInfo setMessage(String message) { this.message = message; return this; } public ProgressInfo setCurrent(long current) { this.current = current; return this; } public ProgressInfo setTotal(long total) { this.total = total; return this; } } borgbutler-server/build.gradle
@@ -5,7 +5,6 @@ } plugins { id 'io.franzbecker.gradle-lombok' version '1.14' id 'java' } @@ -33,9 +32,6 @@ // https://mvnrepository.com/artifact/commons-cli/commons-cli compile group: 'commons-cli', name: 'commons-cli', version: '1.4' testCompile group: 'org.mockito', name: 'mockito-core', version: '2.21.0' compileOnly "org.projectlombok:lombok:1.18.4" testCompileOnly "org.projectlombok:lombok:1.18.4" } repositories { @@ -43,11 +39,6 @@ jcenter() } lombok { version = '1.18.4' sha256 = "" // skip verifyLombok task } apply plugin: 'application' mainClassName = "de.micromata.borgbutler.server.Main" @@ -108,4 +99,4 @@ distZip.dependsOn ':borgbutler-webapp:npmBuild' //distZip.dependsOn ':borgbutler-docs:buildWebDoc' task(dist).dependsOn distZip task(dist).dependsOn distZip borgbutler-server/lombok.config
File was deleted borgbutler-server/src/main/java/de/micromata/borgbutler/server/BorgInstallation.java
@@ -3,7 +3,6 @@ import de.micromata.borgbutler.BorgCommands; import de.micromata.borgbutler.config.Configuration; import de.micromata.borgbutler.config.ConfigurationHandler; import lombok.Getter; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; @@ -27,7 +26,6 @@ return instance; } @Getter private BorgVersion borgVersion = new BorgVersion(); public void initialize() { @@ -197,4 +195,8 @@ private BorgInstallation() { } public BorgVersion getBorgVersion() { return this.borgVersion; } } borgbutler-server/src/main/java/de/micromata/borgbutler/server/BorgVersion.java
@@ -1,40 +1,24 @@ package de.micromata.borgbutler.server; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; public class BorgVersion { @Getter private String binariesDownloadVersion = "1.1.8"; @Getter private String binariesDownloadUrl = "https://github.com/borgbackup/borg/releases/download/" + binariesDownloadVersion + "/"; @Getter private String[][] borgBinaries = { {"freebsd64", "FreeBSD 64"}, {"linux32", "Linux 32"}, {"linux64", "Linux 64"}, {"macosx64", "MacOS X 64"}}; @Getter private String minimumRequiredBorgVersion = "1.1.8"; /** * One of the values "macosx64", "linux64" etc. for using a binary provided by BorgButler or null / "manual" for * using a manual installed borg version. */ @Getter @Setter(AccessLevel.PACKAGE) private String borgBinary; @Getter @Setter(AccessLevel.PACKAGE) private boolean versionOK = false; @Getter @Setter(AccessLevel.PACKAGE) private String version; @Getter @Setter(AccessLevel.PACKAGE) private String statusMessage; public BorgVersion copyFrom(BorgVersion other) { @@ -44,4 +28,56 @@ this.statusMessage = other.statusMessage; return this; } public String getBinariesDownloadVersion() { return this.binariesDownloadVersion; } public String getBinariesDownloadUrl() { return this.binariesDownloadUrl; } public String[][] getBorgBinaries() { return this.borgBinaries; } public String getMinimumRequiredBorgVersion() { return this.minimumRequiredBorgVersion; } public String getBorgBinary() { return this.borgBinary; } public boolean isVersionOK() { return this.versionOK; } public String getVersion() { return this.version; } public String getStatusMessage() { return this.statusMessage; } BorgVersion setBorgBinary(String borgBinary) { this.borgBinary = borgBinary; return this; } BorgVersion setVersionOK(boolean versionOK) { this.versionOK = versionOK; return this; } BorgVersion setVersion(String version) { this.version = version; return this; } BorgVersion setStatusMessage(String statusMessage) { this.statusMessage = statusMessage; return this; } } borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/BorgRepoConfigsRest.java
@@ -42,6 +42,9 @@ if ("new".equals(newRepoConfig.getId())) { newRepoConfig.setId(null); ConfigurationHandler.getConfiguration().add(newRepoConfig); } else if ("init".equals(newRepoConfig.getId())) { newRepoConfig.setId(null); ConfigurationHandler.getConfiguration().add(newRepoConfig); } else { BorgRepoConfig repoConfig = ConfigurationHandler.getConfiguration().getRepoConfig(newRepoConfig.getId()); if (repoConfig == null) { borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/ConfigurationInfo.java
@@ -2,14 +2,26 @@ import de.micromata.borgbutler.server.BorgVersion; import de.micromata.borgbutler.server.ServerConfiguration; import lombok.Getter; import lombok.Setter; public class ConfigurationInfo { @Getter @Setter private ServerConfiguration serverConfiguration; @Getter @Setter private BorgVersion borgVersion; public ServerConfiguration getServerConfiguration() { return this.serverConfiguration; } public BorgVersion getBorgVersion() { return this.borgVersion; } public ConfigurationInfo setServerConfiguration(ServerConfiguration serverConfiguration) { this.serverConfiguration = serverConfiguration; return this; } public ConfigurationInfo setBorgVersion(BorgVersion borgVersion) { this.borgVersion = borgVersion; return this; } } borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/SystemInfo.java
@@ -2,8 +2,6 @@ import de.micromata.borgbutler.BorgQueueStatistics; import de.micromata.borgbutler.server.BorgVersion; import lombok.Getter; import lombok.Setter; /** * Statistics of all the job queues, especially the number of total queued and running jobs. @@ -11,15 +9,36 @@ * of Jobs in the queues. */ public class SystemInfo { @Getter @Setter private BorgQueueStatistics queueStatistics; @Getter @Setter private boolean configurationOK; @Getter @Setter private BorgVersion borgVersion; public BorgQueueStatistics getQueueStatistics() { return this.queueStatistics; } public boolean isConfigurationOK() { return this.configurationOK; } public BorgVersion getBorgVersion() { return this.borgVersion; } public SystemInfo setQueueStatistics(BorgQueueStatistics queueStatistics) { this.queueStatistics = queueStatistics; return this; } public SystemInfo setConfigurationOK(boolean configurationOK) { this.configurationOK = configurationOK; return this; } public SystemInfo setBorgVersion(BorgVersion borgVersion) { this.borgVersion = borgVersion; return this; } } borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/queue/JsonJob.java
@@ -5,47 +5,21 @@ import de.micromata.borgbutler.jobs.AbstractJob; import de.micromata.borgbutler.json.borg.ProgressInfo; import de.micromata.borgbutler.server.user.UserUtils; import lombok.Getter; import lombok.Setter; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; public class JsonJob { @Getter @Setter private boolean cancellationRequested; @Getter @Setter private AbstractJob.Status status; @Getter @Setter private String title; @Getter @Setter private String description; @Getter @Setter private String progressText; @Getter @Setter private ProgressInfo progressInfo; @Getter @Setter private String commandLineAsString; @Getter @Setter private long uniqueJobNumber; @Getter @Setter private String[] environmentVariables; @Getter @Setter private String createTime; @Getter @Setter private String startTime; @Getter @Setter private String stopTime; public JsonJob() { @@ -131,4 +105,112 @@ } return (short) value; } public boolean isCancellationRequested() { return this.cancellationRequested; } public AbstractJob.Status getStatus() { return this.status; } public String getTitle() { return this.title; } public String getDescription() { return this.description; } public String getProgressText() { return this.progressText; } public ProgressInfo getProgressInfo() { return this.progressInfo; } public String getCommandLineAsString() { return this.commandLineAsString; } public long getUniqueJobNumber() { return this.uniqueJobNumber; } public String[] getEnvironmentVariables() { return this.environmentVariables; } public String getCreateTime() { return this.createTime; } public String getStartTime() { return this.startTime; } public String getStopTime() { return this.stopTime; } public JsonJob setCancellationRequested(boolean cancellationRequested) { this.cancellationRequested = cancellationRequested; return this; } public JsonJob setStatus(AbstractJob.Status status) { this.status = status; return this; } public JsonJob setTitle(String title) { this.title = title; return this; } public JsonJob setDescription(String description) { this.description = description; return this; } public JsonJob setProgressText(String progressText) { this.progressText = progressText; return this; } public JsonJob setProgressInfo(ProgressInfo progressInfo) { this.progressInfo = progressInfo; return this; } public JsonJob setCommandLineAsString(String commandLineAsString) { this.commandLineAsString = commandLineAsString; return this; } public JsonJob setUniqueJobNumber(long uniqueJobNumber) { this.uniqueJobNumber = uniqueJobNumber; return this; } public JsonJob setEnvironmentVariables(String[] environmentVariables) { this.environmentVariables = environmentVariables; return this; } public JsonJob setCreateTime(String createTime) { this.createTime = createTime; return this; } public JsonJob setStartTime(String startTime) { this.startTime = startTime; return this; } public JsonJob setStopTime(String stopTime) { this.stopTime = stopTime; return this; } } borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/queue/JsonJobQueue.java
@@ -1,15 +1,26 @@ package de.micromata.borgbutler.server.rest.queue; import lombok.Getter; import lombok.Setter; import java.util.List; public class JsonJobQueue { @Getter @Setter private String repo; @Getter @Setter private List<JsonJob> jobs; public String getRepo() { return this.repo; } public List<JsonJob> getJobs() { return this.jobs; } public JsonJobQueue setRepo(String repo) { this.repo = repo; return this; } public JsonJobQueue setJobs(List<JsonJob> jobs) { this.jobs = jobs; return this; } } borgbutler-server/src/test/java/de/micromata/borgbutler/server/logging/FiFoBufferTest.java
@@ -1,6 +1,6 @@ package de.micromata.borgbutler.server.logging; import org.junit.Assert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -24,7 +24,7 @@ } } Assert.assertEquals(100000, counter.longValue()); Assertions.assertEquals(100000, counter.longValue()); } private void startProducerThread() { build.gradle
@@ -10,7 +10,7 @@ apply plugin: 'maven' group = 'de.micromata.borgbutler' version = '0.1-SNAPSHOT' version = '0.2-SNAPSHOT' } subprojects {