1
|
package eu.dnetlib.msro.workflows.nodes.repohi;
|
2
|
|
3
|
import java.io.StringReader;
|
4
|
import javax.annotation.Resource;
|
5
|
|
6
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
7
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
8
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
9
|
import eu.dnetlib.msro.workflows.procs.Env;
|
10
|
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
|
11
|
import eu.dnetlib.rmi.enabling.ISLookUpService;
|
12
|
import org.dom4j.Document;
|
13
|
import org.dom4j.Node;
|
14
|
import org.dom4j.io.SAXReader;
|
15
|
|
16
|
public class RetrieveInterfaceInfoJobNode extends SimpleJobNode {
|
17
|
|
18
|
@Resource
|
19
|
private UniqueServiceLocator serviceLocator;
|
20
|
|
21
|
@Override
|
22
|
protected String execute(final Env env) throws Exception {
|
23
|
|
24
|
final String datasourceId = env.getAttribute(WorkflowsConstants.LOG_DATASOURCE_ID, String.class);
|
25
|
final String interfaceID = env.getAttribute(WorkflowsConstants.LOG_DATASOURCE_INTERFACE, String.class);
|
26
|
final String profile = this.serviceLocator.getService(ISLookUpService.class).getResourceProfile(datasourceId);
|
27
|
final Document doc = new SAXReader().read(new StringReader(profile));
|
28
|
final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id='" + interfaceID + "']");
|
29
|
|
30
|
final String contentDescription = ifcNode.valueOf("./@contentDescription");
|
31
|
env.setAttribute("objectStoreContentDescription", contentDescription);
|
32
|
|
33
|
final Node acProtNode = doc.selectSingleNode("//INTERFACE[@id='" + interfaceID + "']/ACCESS_PROTOCOL");
|
34
|
|
35
|
final String basePath = acProtNode.valueOf("./@basePath");
|
36
|
env.setAttribute("objectStoreBasePath", basePath);
|
37
|
|
38
|
return Arc.DEFAULT_ARC;
|
39
|
}
|
40
|
|
41
|
}
|