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