Search in sources :

Example 36 with ZipFile

use of net.lingala.zip4j.core.ZipFile in project apex-core by apache.

the class StramTestSupport method createConfigPackageFile.

/**
 * Create an confPackage zip using the sample confPackage located in
 * src/test/resources/testConfPackage/testConfPackageSrc.
 *
 * @param file The file whose path will be used to create the confPackage zip
 * @return The File object that can be used in the ConfigPackage constructor.
 * @throws net.lingala.zip4j.exception.ZipException
 */
public static File createConfigPackageFile(File file) throws net.lingala.zip4j.exception.ZipException {
    ZipFile zipFile = new ZipFile(file);
    ZipParameters zipParameters = new ZipParameters();
    zipParameters.setIncludeRootFolder(false);
    zipFile.createZipFileFromFolder("src/test/resources/testConfigPackage/testConfigPackageSrc", zipParameters, false, Long.MAX_VALUE);
    return file;
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) ZipParameters(net.lingala.zip4j.model.ZipParameters)

Example 37 with ZipFile

use of net.lingala.zip4j.core.ZipFile in project vertexium by visallo.

the class ElasticsearchResource method expandVertexiumPlugin.

private void expandVertexiumPlugin(File vertexiumPluginDir) {
    InputStream zipIn = getClass().getResourceAsStream("/vertexium-elasticsearch5-plugin.zip");
    File pluginZip = new File(vertexiumPluginDir.getParentFile(), "vertexium-elasticsearch5-plugin.zip");
    try (OutputStream zipOut = new FileOutputStream(pluginZip)) {
        IOUtils.copy(zipIn, zipOut);
    } catch (Exception ex) {
        throw new VertexiumException("Could not write plugin zip file", ex);
    }
    try {
        ZipFile zipFile = new ZipFile(pluginZip);
        zipFile.extractFile("elasticsearch/plugin-descriptor.properties", vertexiumPluginDir.getAbsolutePath(), null, "plugin-descriptor.properties");
    } catch (Exception ex) {
        throw new VertexiumException("Could not extract plugin", ex);
    }
    pluginZip.delete();
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) ZipFile(net.lingala.zip4j.core.ZipFile) VertexiumException(org.vertexium.VertexiumException) VertexiumException(org.vertexium.VertexiumException)

Example 38 with ZipFile

use of net.lingala.zip4j.core.ZipFile in project collect by openforis.

the class CollectEarthProjectFileCreatorImpl method create.

@Override
public File create(CollectSurvey survey, String language) throws Exception {
    // create output zip file
    File outputFile = File.createTempFile("openforis-collect-earth-temp", ".zip");
    // prevent exception creating zip file with zip4j
    outputFile.delete();
    // create placemark
    File placemarkFile = createPlacemark(survey);
    File projectProperties = generateProjectProperties(survey, language);
    File balloon = generateBalloon(survey, language);
    File cube = generateCube(survey, language);
    File kmlTemplate = generateKMLTemplate(survey);
    File testPlotsCSVFile = new CollectEarthGridTemplateGenerator().generateTemplateCSVFile(survey);
    File readmeFile = getFileFromResouces(README_FILE_PATH);
    ZipFile zipFile = new ZipFile(outputFile);
    ZipParameters zipParameters = new ZipParameters();
    // COMP_DEFLATE is for compression
    // COMp_STORE no compression
    zipParameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    // DEFLATE_LEVEL_ULTRA = maximum compression
    zipParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_ULTRA);
    Zip4jFiles.addFile(zipFile, projectProperties, PROJECT_PROPERTIES_FILE_NAME, zipParameters);
    Zip4jFiles.addFile(zipFile, placemarkFile, PLACEMARK_FILE_NAME, zipParameters);
    Zip4jFiles.addFile(zipFile, balloon, BALLOON_FILE_NAME, zipParameters);
    Zip4jFiles.addFile(zipFile, cube, CUBE_FILE_NAME, zipParameters);
    Zip4jFiles.addFile(zipFile, kmlTemplate, KML_TEMPLATE_FILE_NAME, zipParameters);
    Zip4jFiles.addFile(zipFile, readmeFile, README_FILE, zipParameters);
    Zip4jFiles.addFile(zipFile, testPlotsCSVFile, TEST_PLOTS_FILE_NAME, zipParameters);
    addCodeListImages(zipFile, survey, zipParameters);
    includeSurveyFiles(zipFile, survey, zipParameters);
    includeEarthFiles(zipFile, zipParameters);
    return outputFile;
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) SurveyFile(org.openforis.collect.model.SurveyFile) ZipFile(net.lingala.zip4j.core.ZipFile) File(java.io.File) ZipParameters(net.lingala.zip4j.model.ZipParameters)

Aggregations

ZipFile (net.lingala.zip4j.core.ZipFile)38 File (java.io.File)20 ZipException (net.lingala.zip4j.exception.ZipException)16 ZipParameters (net.lingala.zip4j.model.ZipParameters)13 IOException (java.io.IOException)9 FileHeader (net.lingala.zip4j.model.FileHeader)8 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Nonnull (javax.annotation.Nonnull)4 WorldException (com.voxelgameslib.voxelgameslib.exception.WorldException)3 ByteArrayOutputStream (com.codeforces.commons.io.ByteArrayOutputStream)2 Map (com.voxelgameslib.voxelgameslib.map.Map)2 FileOutputStream (java.io.FileOutputStream)2 FileMeta (org.molgenis.data.file.model.FileMeta)2 CommandPermission (co.aikar.commands.annotation.CommandPermission)1 Subcommand (co.aikar.commands.annotation.Subcommand)1 Syntax (co.aikar.commands.annotation.Syntax)1 com.codeforces.commons.io (com.codeforces.commons.io)1 Math.max (com.codeforces.commons.math.Math.max)1 Patterns (com.codeforces.commons.text.Patterns)1