Improved error management
This commit is contained in:
parent
4f831f19d7
commit
ce30732166
|
@ -3,6 +3,7 @@ package org.gcube.common.software.analyser;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -115,7 +116,7 @@ public class SoftwareConceptAnalyser {
|
||||||
concept.put(SoftwareConcept.DOI_URL_PROPERTY_NAME, doiURL.toString());
|
concept.put(SoftwareConcept.DOI_URL_PROPERTY_NAME, doiURL.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Thread.sleep(TimeUnit.SECONDS.toMillis(2));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
for(int j=i+1; j<versions.size(); j++) {
|
for(int j=i+1; j<versions.size(); j++) {
|
||||||
|
|
|
@ -160,23 +160,36 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
|
||||||
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
|
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add depositionFiles
|
try {
|
||||||
addFilesToDeposition(files);
|
//Add depositionFiles
|
||||||
|
addFilesToDeposition(files);
|
||||||
//Update deposit metadata
|
|
||||||
updateMetadata();
|
//Update deposit metadata
|
||||||
|
updateMetadata();
|
||||||
// Publish the version
|
|
||||||
publishToZenodo();
|
// Publish the version
|
||||||
|
publishToZenodo();
|
||||||
for(File file : files) {
|
}finally {
|
||||||
if(!file.exists()) {
|
for(File file : files) {
|
||||||
throw new RuntimeException(file.getAbsolutePath() + "does not exist");
|
if(!file.exists()) {
|
||||||
}
|
throw new RuntimeException(file.getAbsolutePath() + " does not exist");
|
||||||
try {
|
}
|
||||||
while(!file.delete()) {}
|
try {
|
||||||
}catch (Exception e) {
|
int i = 0;
|
||||||
logger.error("Unable to delete ", file.getAbsolutePath());
|
while(!file.delete() && i<10) {
|
||||||
|
int millis = 100;
|
||||||
|
logger.warn("File {} not deleted at the attemp {}. Retrying in {} milliseconds.", file.getAbsolutePath(), i+1, millis);
|
||||||
|
++i;
|
||||||
|
Thread.sleep(millis);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i==10) {
|
||||||
|
logger.warn("After {} attemps the file {} was not deleted. Trying using deleteOnExit().", i, file.getAbsolutePath());
|
||||||
|
file.deleteOnExit();
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("Unable to delete {}", file.getAbsolutePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue