Skip to content

Commit

Permalink
Merge branch 'master' into snyk-fix-1822fc1f5d2cfd6d3cb771fa818325a6
Browse files Browse the repository at this point in the history
  • Loading branch information
hmiguim authored Jan 15, 2025
2 parents e4f9e70 + 881934f commit ec5ea8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java_version>17</java_version>
<version.jackson>2.17.1</version.jackson>
<version.jackson>2.17.2</version.jackson>
</properties>

<profiles>
Expand Down Expand Up @@ -333,12 +333,12 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>gov.loc</groupId>
Expand Down Expand Up @@ -371,7 +371,7 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.12.7</version>
<version>2.13.0</version>
</dependency>

<!-- CLI dependecies -->
Expand Down
34 changes: 18 additions & 16 deletions src/main/java/org/roda_project/commons_ip2/utils/ZIPUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,29 @@ private ZIPUtils() {
* file extension (e.g. .zip)
*/
public static Path extractIPIfInZipFormat(final Path source, Path destinationDirectory) throws ParseException {
if (Files.isDirectory(source)) {
return source;
}

Path ipFolderPath = destinationDirectory;
if (!Files.isDirectory(source)) {
try {
ZIPUtils.unzip(source, destinationDirectory);

// 20161111 hsilva: see if the IP extracted has a folder which contains
// the content of the IP (for being compliant with previous way of
// creating SIP in ZIP format, this test/adjustment is needed)
if (Files.exists(destinationDirectory) && !Files.exists(destinationDirectory.resolve(IPConstants.METS_FILE))) {
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(destinationDirectory)) {
for (Path path : directoryStream) {
if (Files.isDirectory(path) && Files.exists(path.resolve(IPConstants.METS_FILE))) {
ipFolderPath = path;
break;
}
try {
ZIPUtils.unzip(source, destinationDirectory);

// 20161111 hsilva: see if the IP extracted has a folder which contains
// the content of the IP (for being compliant with previous way of
// creating SIP in ZIP format, this test/adjustment is needed)
if (Files.exists(destinationDirectory) && !Files.exists(destinationDirectory.resolve(IPConstants.METS_FILE))) {
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(destinationDirectory)) {
for (Path path : directoryStream) {
if (Files.isDirectory(path) && Files.exists(path.resolve(IPConstants.METS_FILE))) {
ipFolderPath = path;
break;
}
}
}
} catch (IOException e) {
throw new ParseException("Error unzipping file", e);
}
} catch (IOException e) {
throw new ParseException("Error unzipping file", e);
}

return ipFolderPath;
Expand Down

0 comments on commit ec5ea8a

Please sign in to comment.