Skip to content

Commit

Permalink
- Fix throwing an error when the storage directory already exists.
Browse files Browse the repository at this point in the history
- Add the "testCustomInputOutputWithIdDocFileNames" test.
- Update dependencies.
- Code polishing.
  • Loading branch information
LSmyrnaios committed Nov 27, 2023
1 parent 4edfd67 commit 905872c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<configuration>
<!--<excludes>
<exclude>some test to exclude here</exclude>
Expand Down Expand Up @@ -120,7 +120,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.13.0</version>
<version>3.14.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
Expand All @@ -141,7 +141,7 @@
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.5.6</version>
<version>8.5.7</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
Expand Down Expand Up @@ -178,7 +178,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.0</version>
<version>5.10.1</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class PublicationsRetriever
public static Instant startTime = null;
public static String targetUrlType = "docOrDatasetUrl"; // docUrl, documentUrl, docOrDatasetUrl ; this is set by the args-parser, and it's used when outputting data.

public static DecimalFormat df = new DecimalFormat("0.00");
public static final DecimalFormat df = new DecimalFormat("0.00");

public static ExecutorService executor;
public static int workerThreadsCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,21 @@ public static void handleStoreDocFileDirectory()

// If the directory doesn't exist, try to (re)create it.
try {
if ( !dir.mkdirs() ) { // Try to create the directory(-ies) if they don't exist.
String errorMessage;
if ( PublicationsRetriever.docFilesStorageGivenByUser )
errorMessage = "Problem when creating the \"storeDocFilesDir\": \"" + FileUtils.storeDocFilesDir + "\"."
+ "\nPlease give a valid Directory-path.";
else // User has left the storageDir to be the default one.
errorMessage = "Problem when creating the default \"storeDocFilesDir\": \"" + FileUtils.storeDocFilesDir + "\"."
+ "\nPlease verify you have the necessary privileges in the directory you are running the program from or specify the directory you want to save the files to."
+ "\nIf the above is not an option, then you can set to retrieve just the " + PublicationsRetriever.targetUrlType + "s and download the full-texts later (on your own).";
System.err.println(errorMessage);
logger.error(errorMessage);
FileUtils.closeIO();
System.exit(-3);
if ( !dir.exists() ) {
if ( !dir.mkdirs() ) { // Try to create the directory(-ies) if they don't exist. If they exist OR if sth went wrong, the result os the same: "false".
String errorMessage;
if ( PublicationsRetriever.docFilesStorageGivenByUser )
errorMessage = "Problem when creating the \"storeDocFilesDir\": \"" + FileUtils.storeDocFilesDir + "\"."
+ "\nPlease give a valid Directory-path.";
else // User has left the storageDir to be the default one.
errorMessage = "Problem when creating the default \"storeDocFilesDir\": \"" + FileUtils.storeDocFilesDir + "\"."
+ "\nPlease verify you have the necessary privileges in the directory you are running the program from or specify the directory you want to save the files to."
+ "\nIf the above is not an option, then you can set to retrieve just the " + PublicationsRetriever.targetUrlType + "s and download the full-texts later (on your own).";
System.err.println(errorMessage);
logger.error(errorMessage);
FileUtils.closeIO();
System.exit(-3);
}
}
} catch (SecurityException se) {
logger.error(se.getMessage(), se);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
import eu.openaire.publications_retriever.util.url.LoaderAndChecker;
import eu.openaire.publications_retriever.util.url.UrlUtils;
import org.apache.commons.io.FileDeleteStrategy;
import org.jsoup.Jsoup;
import org.apache.commons.lang3.StringUtils;

import org.jsoup.Jsoup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ public void testCustomInputOutputWithOriginalDocFileNames()
}


@Disabled
@Test
public void testCustomInputOutputWithIdDocFileNames()
{
String[] args = new String[7];
args[0] = "-retrieveDataType";
args[1] = "document"; // "document" OR "dataset" OR "all"
args[2] = "-downloadDocFiles";
args[3] = "-docFileNameType";
args[4] = "idName";
args[5] = "-docFilesStorage";
args[6] = "docFiles";
main(args);
}


@Disabled
@Test
public void testCustomInputOutputWithIdDocFileNamesToS3()
Expand Down

0 comments on commit 905872c

Please sign in to comment.