Search in sources :

Example 21 with KeyValue

use of com.fo0.robot.model.KeyValue in project Robot by fo0.

the class ChainActionItem method sevenZip.

public EChainResponse sevenZip(List<KeyValue> list) throws Exception {
    List<KeyValue> zipList = list;
    KeyValue zipSrc = zipList.stream().filter(e -> e.getKey().equals(CONSTANTS_PATTERN.SOURCE)).findFirst().orElse(null);
    KeyValue zipDest = zipList.stream().filter(e -> e.getKey().equals(CONSTANTS_PATTERN.DESTINATION)).findFirst().orElse(KeyValue.builder().build());
    ctx.addToLog(type, "SRC: " + zipSrc.getValue());
    ctx.addToLog(type, "DST: " + zipDest.getValue());
    // old method
    // ZipUtils.zip(zipSrc.getValue(), zipDest.getValue());
    Archiver zipArchive = ArchiverFactory.createArchiver(ArchiveFormat.SEVEN_Z);
    zipArchive.create(new File(zipDest.getValue()).getName(), new File(zipDest.getValue()).getParentFile(), new File(zipSrc.getValue()));
    return EChainResponse.Continue;
}
Also used : KeyValue(com.fo0.robot.model.KeyValue) Archiver(org.rauschig.jarchivelib.Archiver) File(java.io.File)

Example 22 with KeyValue

use of com.fo0.robot.model.KeyValue in project Robot by fo0.

the class ChainActionItem method untar.

public EChainResponse untar(List<KeyValue> list) throws Exception {
    List<KeyValue> unzipList = list;
    KeyValue unzipSrc = unzipList.stream().filter(e -> e.getKey().equals(CONSTANTS_PATTERN.SOURCE)).findFirst().orElse(null);
    KeyValue unzipDst = unzipList.stream().filter(e -> e.getKey().equals(CONSTANTS_PATTERN.DESTINATION)).findFirst().orElse(KeyValue.builder().build());
    ctx.addToLog(type, "SRC: " + unzipSrc.getValue());
    ctx.addToLog(type, "DST: " + unzipDst.getValue());
    Archiver unzipArchive = ArchiverFactory.createArchiver(ArchiveFormat.TAR);
    unzipArchive.extract(new File(unzipSrc.getValue()), new File(unzipDst.getValue()));
    return EChainResponse.Continue;
}
Also used : KeyValue(com.fo0.robot.model.KeyValue) Archiver(org.rauschig.jarchivelib.Archiver) File(java.io.File)

Aggregations

KeyValue (com.fo0.robot.model.KeyValue)22 File (java.io.File)9 Archiver (org.rauschig.jarchivelib.Archiver)8 Test (org.junit.Test)5 ActionItem (com.fo0.robot.model.ActionItem)3 Commander (com.fo0.robot.commander.Commander)2 FileTransferData (com.fo0.robot.model.FileTransferData)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 FTPClient (com.fo0.robot.connector.FTPClient)1 SCPClient (com.fo0.robot.connector.SCPClient)1 SimpleSSHClient (com.fo0.robot.connector.SimpleSSHClient)1 Stopwatch (com.google.common.base.Stopwatch)1 URL (java.net.URL)1