diff --git a/org.eclipse.winery.repository/pom.xml b/org.eclipse.winery.repository/pom.xml
index 78dc4149ff..60237ba9aa 100644
--- a/org.eclipse.winery.repository/pom.xml
+++ b/org.eclipse.winery.repository/pom.xml
@@ -52,18 +52,6 @@
${com.fasterxml.jackson.core.jackson-annotations}
compile
-
- org.apache.commons
- commons-compress
- 1.6
- compile
-
-
- org.tukaani
- xz
-
-
-
org.tukaani
diff --git a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/consistencycheck/ConsistencyChecker.java b/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/consistencycheck/ConsistencyChecker.java
index 54ab872f6d..b276fd1f20 100644
--- a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/consistencycheck/ConsistencyChecker.java
+++ b/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/consistencycheck/ConsistencyChecker.java
@@ -66,7 +66,6 @@
import org.eclipse.winery.repository.exceptions.RepositoryCorruptException;
import org.eclipse.winery.repository.export.CsarExporter;
-import org.apache.commons.compress.archivers.ArchiveException;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
@@ -421,10 +420,6 @@ private void checkCsar(DefinitionsChildId id, Path tempCsar) {
try (OutputStream outputStream = Files.newOutputStream(tempCsar, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
try {
exporter.writeCsar(RepositoryFactory.getRepository(), id, outputStream, exportConfiguration);
- } catch (ArchiveException e) {
- LOGGER.debug("Error during checking ZIP", e);
- printAndAddError(id, "Invalid zip file: " + e.getMessage());
- return;
} catch (JAXBException e) {
LOGGER.debug("Error during checking ZIP", e);
printAndAddError(id, "Some XML could not be parsed: " + e.getMessage() + " " + e.toString());
diff --git a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/filebased/FilebasedRepository.java b/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/filebased/FilebasedRepository.java
index 5bc8aaa70d..b9b27f6613 100644
--- a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/filebased/FilebasedRepository.java
+++ b/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/filebased/FilebasedRepository.java
@@ -68,10 +68,6 @@
import org.eclipse.winery.repository.configuration.FileBasedRepositoryConfiguration;
import org.eclipse.winery.repository.exceptions.WineryRepositoryException;
-import org.apache.commons.compress.archivers.ArchiveException;
-import org.apache.commons.compress.archivers.ArchiveOutputStream;
-import org.apache.commons.compress.archivers.ArchiveStreamFactory;
-import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
@@ -773,23 +769,21 @@ public void getZippedContents(final GenericId id, OutputStream out) throws Winer
SortedSet containedFiles = this.getContainedFiles(id);
- try (final ArchiveOutputStream zos = new ArchiveStreamFactory().createArchiveOutputStream("zip", out)) {
+ try (final ZipOutputStream zos = new ZipOutputStream(out)) {
for (RepositoryFileReference ref : containedFiles) {
- ZipArchiveEntry zipArchiveEntry;
+ ZipEntry zipArchiveEntry;
final Optional subDirectory = ref.getSubDirectory();
if (subDirectory.isPresent()) {
- zipArchiveEntry = new ZipArchiveEntry(subDirectory.get().resolve(ref.getFileName()).toString());
+ zipArchiveEntry = new ZipEntry(subDirectory.get().resolve(ref.getFileName()).toString());
} else {
- zipArchiveEntry = new ZipArchiveEntry(ref.getFileName());
+ zipArchiveEntry = new ZipEntry(ref.getFileName());
}
- zos.putArchiveEntry(zipArchiveEntry);
+ zos.putNextEntry(zipArchiveEntry);
try (InputStream is = RepositoryFactory.getRepository().newInputStream(ref)) {
IOUtils.copy(is, zos);
}
- zos.closeArchiveEntry();
+ zos.closeEntry();
}
- } catch (ArchiveException e) {
- throw new WineryRepositoryException("Internal error while generating archive", e);
} catch (IOException e) {
throw new WineryRepositoryException("I/O exception during export", e);
}
diff --git a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/export/CsarExporter.java b/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/export/CsarExporter.java
index 25edbd8982..9d909b843f 100644
--- a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/export/CsarExporter.java
+++ b/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/export/CsarExporter.java
@@ -32,6 +32,8 @@
import java.util.Objects;
import java.util.SortedSet;
import java.util.concurrent.CompletableFuture;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
import javax.xml.bind.JAXBException;
import javax.xml.transform.Transformer;
@@ -73,11 +75,6 @@
import org.eclipse.winery.repository.datatypes.ids.elements.ServiceTemplateSelfServiceFilesDirectoryId;
import org.eclipse.winery.repository.exceptions.RepositoryCorruptException;
-import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.ArchiveException;
-import org.apache.commons.compress.archivers.ArchiveOutputStream;
-import org.apache.commons.compress.archivers.ArchiveStreamFactory;
-import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.io.IOUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -126,7 +123,7 @@ private static String getDefinitionsPathInsideCSAR(IGenericRepository repository
}
public CompletableFuture writeCsarAndSaveManifestInProvenanceLayer(IRepository repository, DefinitionsChildId entryId, OutputStream out)
- throws IOException, JAXBException, RepositoryCorruptException, ArchiveException, ProvenanceException {
+ throws IOException, JAXBException, RepositoryCorruptException, ProvenanceException {
Map exportConfiguration = new HashMap<>();
exportConfiguration.put(CsarExportConfiguration.INCLUDE_HASHES.name(), true);
exportConfiguration.put(CsarExportConfiguration.INCLUDE_PROVENANCE.name(), true);
@@ -145,13 +142,13 @@ public CompletableFuture writeCsarAndSaveManifestInProvenanceLayer(IRepo
* @param out the output stream to write to
*/
public String writeCsar(IRepository repository, DefinitionsChildId entryId, OutputStream out, Map exportConfiguration)
- throws ArchiveException, IOException, JAXBException, RepositoryCorruptException {
+ throws IOException, JAXBException, RepositoryCorruptException {
CsarExporter.LOGGER.trace("Starting CSAR export with {}", entryId.toString());
Map refMap = new HashMap<>();
Collection definitionNames = new ArrayList<>();
- try (final ArchiveOutputStream zos = new ArchiveStreamFactory().createArchiveOutputStream("zip", out)) {
+ try (final ZipOutputStream zos = new ZipOutputStream(out)) {
ToscaExportUtil exporter = new ToscaExportUtil();
ExportedState exportedState = new ExportedState();
@@ -162,10 +159,10 @@ public String writeCsar(IRepository repository, DefinitionsChildId entryId, Outp
CsarContentProperties definitionsFileProperties = new CsarContentProperties(definitionsPathInsideCSAR);
definitionNames.add(definitionsFileProperties);
- zos.putArchiveEntry(new ZipArchiveEntry(definitionsPathInsideCSAR));
+ zos.putNextEntry(new ZipEntry(definitionsPathInsideCSAR));
Collection referencedIds;
referencedIds = exporter.exportTOSCA(repository, currentId, definitionsFileProperties, zos, refMap, exportConfiguration);
- zos.closeArchiveEntry();
+ zos.closeEntry();
// for each entryId add license and readme files (if they exist) to the refMap
addLicenseAndReadmeFiles(repository, currentId, refMap);
@@ -226,7 +223,7 @@ public String writeCsar(IRepository repository, DefinitionsChildId entryId, Outp
* @param fileProperties Describing the path to the file inside the archive
* @throws IOException thrown when the temporary directory can not be created
*/
- private void addArtifactTemplateToZipFile(ArchiveOutputStream zos, IGenericRepository repository, RepositoryFileReference ref,
+ private void addArtifactTemplateToZipFile(ZipOutputStream zos, IGenericRepository repository, RepositoryFileReference ref,
CsarContentProperties fileProperties, Map exportConfiguration) throws IOException {
GitInfo gitInfo = BackendUtils.getGitInformation((DirectoryId) ref.getParent());
@@ -266,7 +263,7 @@ private void addArtifactTemplateToZipFile(ArchiveOutputStream zos, IGenericRepos
* @param ref Reference to the file that should be added to the archive
* @param csarContentProperties Describing the path inside the archive to the file
*/
- private void addFileToZipArchive(ArchiveOutputStream zos, IGenericRepository repository, RepositoryFileReference ref,
+ private void addFileToZipArchive(ZipOutputStream zos, IGenericRepository repository, RepositoryFileReference ref,
CsarContentProperties csarContentProperties, Map exportConfiguration) {
if (exportConfiguration.containsKey(CsarExportConfiguration.INCLUDE_HASHES.toString())) {
try (InputStream is = repository.newInputStream(ref)) {
@@ -277,10 +274,9 @@ private void addFileToZipArchive(ArchiveOutputStream zos, IGenericRepository rep
}
}
try (InputStream is = repository.newInputStream(ref)) {
- ArchiveEntry archiveEntry = new ZipArchiveEntry(csarContentProperties.getPathInsideCsar());
- zos.putArchiveEntry(archiveEntry);
+ zos.putNextEntry(new ZipEntry(csarContentProperties.getPathInsideCsar()));
IOUtils.copy(is, zos);
- zos.closeArchiveEntry();
+ zos.closeEntry();
} catch (Exception e) {
CsarExporter.LOGGER.error("Could not copy file content to ZIP outputstream", e);
}
@@ -295,12 +291,12 @@ private void addFileToZipArchive(ArchiveOutputStream zos, IGenericRepository rep
* @param ref The dummy document that should be exported as an archive
* @param fileProperties The output path of the archive
*/
- private void addDummyRepositoryFileReferenceForGeneratedXSD(ArchiveOutputStream zos, Transformer transformer,
+ private void addDummyRepositoryFileReferenceForGeneratedXSD(ZipOutputStream zos, Transformer transformer,
DummyRepositoryFileReferenceForGeneratedXSD ref,
CsarContentProperties fileProperties,
Map exportConfiguration) throws IOException {
- ArchiveEntry archiveEntry = new ZipArchiveEntry(fileProperties.getPathInsideCsar());
- zos.putArchiveEntry(archiveEntry);
+ ZipEntry archiveEntry = new ZipEntry(fileProperties.getPathInsideCsar());
+ zos.putNextEntry(archiveEntry);
CsarExporter.LOGGER.trace("Special treatment for generated XSDs");
Document document = ref.getDocument();
@@ -318,7 +314,7 @@ private void addDummyRepositoryFileReferenceForGeneratedXSD(ArchiveOutputStream
}
zos.write(bytes);
- zos.closeArchiveEntry();
+ zos.closeEntry();
} catch (TransformerException e) {
CsarExporter.LOGGER.debug("Could not serialize generated xsd", e);
} catch (NoSuchAlgorithmException e) {
@@ -358,7 +354,7 @@ private void deleteDirectory(Path path) {
* @param rootDir The root of the working tree
* @param archivePath The path inside the archive to the working tree
*/
- private void addWorkingTreeToArchive(ArchiveOutputStream zos, TArtifactTemplate template, Path rootDir, String archivePath) {
+ private void addWorkingTreeToArchive(ZipOutputStream zos, TArtifactTemplate template, Path rootDir, String archivePath) {
addWorkingTreeToArchive(rootDir.toFile(), zos, template, rootDir, archivePath);
}
@@ -371,7 +367,7 @@ private void addWorkingTreeToArchive(ArchiveOutputStream zos, TArtifactTemplate
* @param rootDir The root of the working tree
* @param archivePath The path inside the archive to the working tree
*/
- private void addWorkingTreeToArchive(File file, ArchiveOutputStream zos, TArtifactTemplate template, Path rootDir, String archivePath) {
+ private void addWorkingTreeToArchive(File file, ZipOutputStream zos, TArtifactTemplate template, Path rootDir, String archivePath) {
if (file.isDirectory()) {
if (file.getName().equals(".git")) {
return;
@@ -415,10 +411,10 @@ private void addWorkingTreeToArchive(File file, ArchiveOutputStream zos, TArtifa
if ((!foundInclude || included) && !excluded) {
try (InputStream is = new FileInputStream(file)) {
- ArchiveEntry archiveEntry = new ZipArchiveEntry(archivePath + rootDir.relativize(Paths.get(file.getAbsolutePath())));
- zos.putArchiveEntry(archiveEntry);
+ ZipEntry archiveEntry = new ZipEntry(archivePath + rootDir.relativize(Paths.get(file.getAbsolutePath())));
+ zos.putNextEntry(archiveEntry);
IOUtils.copy(is, zos);
- zos.closeArchiveEntry();
+ zos.closeEntry();
} catch (Exception e) {
CsarExporter.LOGGER.error("Could not copy file to ZIP outputstream", e);
}
@@ -554,10 +550,10 @@ private void addSelfServiceFiles(IRepository repository, ServiceTemplateId servi
}
private String addManifest(IRepository repository, DefinitionsChildId id, Collection definitionNames,
- Map refMap, ArchiveOutputStream out, Map exportConfiguration) throws IOException {
+ Map refMap, ZipOutputStream out, Map exportConfiguration) throws IOException {
String entryDefinitionsReference = CsarExporter.getDefinitionsPathInsideCSAR(repository, id);
- out.putArchiveEntry(new ZipArchiveEntry("TOSCA-Metadata/TOSCA.meta"));
+ out.putNextEntry(new ZipEntry("TOSCA-Metadata/TOSCA.meta"));
StringBuilder stringBuilder = new StringBuilder();
// Setting Versions
@@ -615,7 +611,7 @@ private String addManifest(IRepository repository, DefinitionsChildId id, Collec
String manifestString = stringBuilder.toString();
out.write(manifestString.getBytes());
- out.closeArchiveEntry();
+ out.closeEntry();
return manifestString;
}
diff --git a/org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/export/CsarExporterTest.java b/org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/export/CsarExporterTest.java
index c6deb46008..9217e42205 100644
--- a/org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/export/CsarExporterTest.java
+++ b/org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/export/CsarExporterTest.java
@@ -33,7 +33,7 @@
import org.eclipse.winery.repository.TestWithGitBackedRepository;
import org.eclipse.winery.repository.backend.RepositoryFactory;
-import org.apache.commons.compress.utils.IOUtils;
+import org.apache.commons.io.IOUtils;
import org.eclipse.virgo.util.parser.manifest.ManifestContents;
import org.eclipse.virgo.util.parser.manifest.RecoveringManifestParser;
import org.junit.jupiter.api.Test;