when IRI created from periodo url is wrong, wf has to fail

This commit is contained in:
Enrico Ottonello 2020-10-30 17:08:46 +01:00
parent 7044bcdca4
commit 529151828f
1 changed files with 26 additions and 23 deletions

View File

@ -2,6 +2,7 @@ package eu.dnetlib.ariadneplus.graphdb;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -302,31 +303,33 @@ public class GraphDBClient {
} }
public String feedFromURL(final String dataUrl, final String context) throws AriadnePlusPublisherException{ public String feedFromURL(final String dataUrl, final String context) throws AriadnePlusPublisherException{
try { String result = "";
String result = ""; RemoteRepositoryManager manager = new RemoteRepositoryManager(this.graphDBServerUrl);
RemoteRepositoryManager manager = new RemoteRepositoryManager(this.graphDBServerUrl); manager.init();
manager.init(); manager.setUsernameAndPassword(getWriterUser(), getWriterPwd());
manager.setUsernameAndPassword(getWriterUser(), getWriterPwd()); Repository repository = manager.getRepository(getRepository());
Repository repository = manager.getRepository(getRepository()); ValueFactory factory = repository.getValueFactory();
ValueFactory factory = repository.getValueFactory(); try (RepositoryConnection con = repository.getConnection()) {
try (RepositoryConnection con = repository.getConnection()) { con.begin();
con.begin(); IRI contextIRI = factory.createIRI(getGraphDBBaseURI(), context);
IRI contextIRI = factory.createIRI(getGraphDBBaseURI(), context); log.debug("adding data from IRI: "+contextIRI.toString());
con.add(new URL(dataUrl), null, RDFFormat.TURTLE, contextIRI); con.add(new URL(dataUrl), null, RDFFormat.TURTLE, contextIRI);
result.concat("data added from url: "+dataUrl+" into graph "+context); result.concat("data added from url: "+dataUrl+" into graph "+context);
con.commit(); con.commit();
log.debug("add data from Url executed"); log.debug("add data from Url executed");
} }
catch (RDF4JException e) { catch (RDF4JException | MalformedURLException e) {
log.error("error executing query ...", e); log.error("error executing query ...", e);
} throw new AriadnePlusPublisherException(e);
repository.shutDown(); } catch (IOException e) {
manager.shutDown(); log.error("error executing query ...", e);
return result;
}catch(Throwable e){
log.error(e);
throw new AriadnePlusPublisherException(e); throw new AriadnePlusPublisherException(e);
} }
finally {
repository.shutDown();
manager.shutDown();
}
return result;
} }
public RunSPARQLQueryService getRunSPQRLQuery() { public RunSPARQLQueryService getRunSPQRLQuery() {