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

Kai Reinhard
29.22.2018 cdd5a70a92a808d063f32f1454e3584165beab53
borgbutler-core/src/main/java/de/micromata/borgbutler/jobs/AbstractCommandLineJob.java
@@ -18,7 +18,7 @@
 * A queue is important because Borg doesn't support parallel calls for one repository.
 * For each repository one single queue is allocated.
 */
public abstract class AbstractCommandLineJob extends AbstractJob<String> {
public abstract class AbstractCommandLineJob<T> extends AbstractJob<T> {
    private Logger log = LoggerFactory.getLogger(AbstractCommandLineJob.class);
    private ExecuteWatchdog watchdog;
    @Getter
@@ -53,7 +53,7 @@
    }
    @Override
    public String execute() {
    public JobResult<String> execute() {
        getCommandLineAsString();
        DefaultExecutor executor = new DefaultExecutor();
        if (workingDirectory != null) {
@@ -91,15 +91,17 @@
                : "Executing '" + commandLineAsString + "'...";
        log.info(msg);
        this.executeStarted = true;
        JobResult<String> result = new JobResult<>();
        try {
            executor.execute(commandLine, getEnvironment());
            afterSuccess();
            result.setStatus(JobResult.Status.OK);
            log.info(msg + " Done.");
        } catch (Exception ex) {
            result.setStatus(JobResult.Status.ERROR);
            failed();
            afterFailure(ex);
        }
        return outputStream.toString(Definitions.STD_CHARSET);
        result.setResultObject(outputStream.toString(Definitions.STD_CHARSET));
        return result;
    }
    @Override
@@ -112,12 +114,6 @@
        }
    }
    protected void afterSuccess() {
    }
    protected void afterFailure(Exception ex) {
    }
    protected Map<String, String> getEnvironment() throws IOException {
        return null;
    }