Search in sources :

Example 1 with ZipEntryWithData

use of permafrost.tundra.zip.ZipEntryWithData in project Tundra by Permafrost.

the class zip method decompress.

public static final void decompress(IData pipeline) throws ServiceException {
    // --- <<IS-START(decompress)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] object:0:optional $contents.zip
    // [i] field:0:optional $encoding
    // [i] field:0:optional $mode {"stream","bytes","string","base64"}
    // [o] record:1:optional $contents
    // [o] - field:0:required name
    // [o] - object:0:required content
    IDataCursor cursor = pipeline.getCursor();
    try {
        Object input = IDataHelper.get(cursor, "$contents.zip");
        Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
        ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
        ZipEntryWithData[] entries = ZipHelper.decompress(InputStreamHelper.normalize(input, charset));
        IDataHelper.put(cursor, "$contents", ZipEntryWithData.toIDataArray(entries, charset, mode), false);
    } catch (IOException ex) {
        ExceptionHelper.raise(ex);
    } finally {
        cursor.destroy();
    }
// --- <<IS-END>> ---
}
Also used : ZipEntryWithData(permafrost.tundra.zip.ZipEntryWithData) ObjectConvertMode(permafrost.tundra.lang.ObjectConvertMode) Charset(java.nio.charset.Charset) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Charset (java.nio.charset.Charset)1 ObjectConvertMode (permafrost.tundra.lang.ObjectConvertMode)1 ZipEntryWithData (permafrost.tundra.zip.ZipEntryWithData)1