diff --git a/src/main/java/org/gridsuite/ds/server/utils/Utils.java b/src/main/java/org/gridsuite/ds/server/utils/Utils.java index 7f62bc7..f72d7f8 100644 --- a/src/main/java/org/gridsuite/ds/server/utils/Utils.java +++ b/src/main/java/org/gridsuite/ds/server/utils/Utils.java @@ -21,9 +21,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; /** * @author Thang PHAM @@ -94,14 +93,13 @@ public static Property convertProperty(BasicProperty property) { public static byte[] zip(Path filePath) { try (InputStream is = Files.newInputStream(filePath); ByteArrayOutputStream os = new ByteArrayOutputStream(); - ZipOutputStream zipOs = new ZipOutputStream(os)) { - zipOs.putNextEntry(new ZipEntry(filePath.getFileName().toString())); + GZIPOutputStream zipOs = new GZIPOutputStream(os)) { byte[] buffer = new byte[1024]; int length; while ((length = is.read(buffer)) > 0) { zipOs.write(buffer, 0, length); } - zipOs.closeEntry(); + zipOs.finish(); return os.toByteArray(); } catch (IOException e) { throw new UncheckedIOException("Error occurred while zipping the file " + filePath.toAbsolutePath(), e); @@ -111,14 +109,11 @@ public static byte[] zip(Path filePath) { public static void unzip(byte[] zippedBytes, Path filePath) { try (ByteArrayInputStream is = new ByteArrayInputStream(zippedBytes); FileOutputStream fos = new FileOutputStream(new File(filePath.toUri())); - ZipInputStream zipIs = new ZipInputStream(is)) { - if (zipIs.getNextEntry() != null) { - byte[] buffer = new byte[1024]; - int length; - while ((length = zipIs.read(buffer)) > 0) { - fos.write(buffer, 0, length); - } - zipIs.closeEntry(); + GZIPInputStream zipIs = new GZIPInputStream(is)) { + byte[] buffer = new byte[1024]; + int length; + while ((length = zipIs.read(buffer)) > 0) { + fos.write(buffer, 0, length); } } catch (IOException e) { throw new UncheckedIOException("Error occurred while unzipping a zipped content to the file " + filePath.toAbsolutePath(), e); diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index fc9f1fa..c66e5d0 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -4,7 +4,6 @@ server: spring: rabbitmq: addresses: localhost - port: 5672 powsybl-ws: database: