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;
}
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();
}
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;
}
Aggregations