1
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.repohi;
|
2
|
|
3
|
import java.io.StringReader;
|
4
|
import javax.annotation.Resource;
|
5
|
|
6
|
import com.googlecode.sarasvati.Arc;
|
7
|
import com.googlecode.sarasvati.NodeToken;
|
8
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
9
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
10
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
11
|
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
|
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 NodeToken token) throws Exception {
|
23
|
|
24
|
String datasourceId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ID);
|
25
|
String interfaceID = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE);
|
26
|
final String profile = 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
|
String contentDescription = ifcNode.valueOf("./@contentDescription");
|
31
|
token.getEnv().setAttribute("objectStoreContentDescription", contentDescription);
|
32
|
|
33
|
final Node acProtNode = doc.selectSingleNode("//INTERFACE[@id='" + interfaceID + "']/ACCESS_PROTOCOL");
|
34
|
|
35
|
String basePath = acProtNode.valueOf("./@basePath");
|
36
|
token.getEnv().setAttribute("objectStoreBasePath", basePath);
|
37
|
|
38
|
return Arc.DEFAULT_ARC;
|
39
|
}
|
40
|
|
41
|
}
|