1
|
package eu.dnetlib.parthenos.workflows.nodes;
|
2
|
|
3
|
import java.net.URI;
|
4
|
|
5
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
6
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
7
|
import eu.dnetlib.msro.workflows.procs.Env;
|
8
|
import org.apache.commons.logging.Log;
|
9
|
import org.apache.commons.logging.LogFactory;
|
10
|
import org.apache.http.HttpResponse;
|
11
|
import org.apache.http.client.HttpClient;
|
12
|
import org.apache.http.client.methods.HttpGet;
|
13
|
import org.apache.http.client.utils.URIBuilder;
|
14
|
import org.apache.http.impl.client.HttpClients;
|
15
|
import org.apache.http.util.EntityUtils;
|
16
|
|
17
|
public class UnpublishVirtuosoJobNode extends SimpleJobNode {
|
18
|
|
19
|
private static final Log log = LogFactory.getLog(UnpublishVirtuosoJobNode.class);
|
20
|
|
21
|
private String datasourceInterface;
|
22
|
private String publisherEndpoint;
|
23
|
|
24
|
@Override
|
25
|
protected String execute(final Env env) throws Exception {
|
26
|
URI getURI = new URIBuilder(getPublisherEndpoint()).addParameter("datasourceApi", getDatasourceInterface()).addParameter("parthenosTarget", "VIRTUOSO").build();
|
27
|
HttpClient c = HttpClients.createDefault();
|
28
|
HttpResponse res = c.execute(new HttpGet(getURI));
|
29
|
String nTriples = EntityUtils.toString(res.getEntity());
|
30
|
|
31
|
log.info("Deleted " + nTriples + " triples in Virtuoso server");
|
32
|
|
33
|
env.setAttribute("triples", nTriples);
|
34
|
return Arc.DEFAULT_ARC;
|
35
|
|
36
|
}
|
37
|
|
38
|
public String getDatasourceInterface() {
|
39
|
return datasourceInterface;
|
40
|
}
|
41
|
|
42
|
public void setDatasourceInterface(final String datasourceInterface) {
|
43
|
this.datasourceInterface = datasourceInterface;
|
44
|
}
|
45
|
|
46
|
public String getPublisherEndpoint() {
|
47
|
return publisherEndpoint;
|
48
|
}
|
49
|
|
50
|
public void setPublisherEndpoint(final String publisherEndpoint) {
|
51
|
this.publisherEndpoint = publisherEndpoint;
|
52
|
}
|
53
|
}
|