| | |
| | | package de.micromata.borgbutler.jobs; |
| | | |
| | | import de.micromata.borgbutler.config.Definitions; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import org.apache.commons.exec.*; |
| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.nio.charset.Charset; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | private File workingDirectory; |
| | | @Setter |
| | | private String description; |
| | | protected ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | protected ByteArrayOutputStream errorOutputStream = new ByteArrayOutputStream(); |
| | | |
| | | protected abstract CommandLine buildCommandLine(); |
| | | |
| | |
| | | @Override |
| | | public String execute() { |
| | | getCommandLineAsString(); |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | ByteArrayOutputStream errorOutputStream = new ByteArrayOutputStream(); |
| | | DefaultExecutor executor = new DefaultExecutor(); |
| | | if (workingDirectory != null) { |
| | | executor.setWorkingDirectory(workingDirectory); |
| | |
| | | failed(); |
| | | afterFailure(ex); |
| | | } |
| | | return outputStream.toString(Charset.forName("UTF-8")); |
| | | return outputStream.toString(Definitions.STD_CHARSET); |
| | | } |
| | | |
| | | @Override |