1
|
package eu.dnetlib.msro.workflows.nodes.mdstore;
|
2
|
|
3
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
4
|
|
5
|
import org.apache.commons.logging.Log;
|
6
|
import org.apache.commons.logging.LogFactory;
|
7
|
import org.springframework.beans.factory.annotation.Required;
|
8
|
|
9
|
import com.googlecode.sarasvati.Arc;
|
10
|
import com.googlecode.sarasvati.NodeToken;
|
11
|
|
12
|
import eu.dnetlib.data.mdstore.MDStoreService;
|
13
|
import eu.dnetlib.enabling.tools.ServiceLocator;
|
14
|
import eu.dnetlib.msro.rmi.MSROException;
|
15
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
16
|
|
17
|
public class FetchMDStoreRecordsJobNode extends SimpleJobNode {
|
18
|
|
19
|
private static final Log log = LogFactory.getLog(FetchMDStoreRecordsJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
20
|
|
21
|
private ServiceLocator<MDStoreService> mdstoreLocator;
|
22
|
|
23
|
private String mdId;
|
24
|
private String mdFormat;
|
25
|
private String eprParam;
|
26
|
|
27
|
@Override
|
28
|
protected String execute(final NodeToken token) throws Exception {
|
29
|
if (getMdId() == null) {
|
30
|
setMdId(token.getEnv().getAttribute("mdId"));
|
31
|
}
|
32
|
if (getMdFormat() == null) {
|
33
|
setMdFormat(token.getEnv().getAttribute("mdFormat"));
|
34
|
}
|
35
|
|
36
|
log.info("getting MDRecords from: " + getMdId());
|
37
|
final W3CEndpointReference epr = mdstoreLocator.getService().deliverMDRecords(getMdId(), "", "", "");
|
38
|
if (epr == null) throw new MSROException("unable to read MDRecords from: " + getMdId());
|
39
|
token.getEnv().setAttribute(getEprParam(), epr.toString());
|
40
|
return Arc.DEFAULT_ARC;
|
41
|
}
|
42
|
|
43
|
public ServiceLocator<MDStoreService> getMdstoreLocator() {
|
44
|
return mdstoreLocator;
|
45
|
}
|
46
|
|
47
|
@Required
|
48
|
public void setMdstoreLocator(final ServiceLocator<MDStoreService> mdstoreLocator) {
|
49
|
this.mdstoreLocator = mdstoreLocator;
|
50
|
}
|
51
|
|
52
|
public String getMdId() {
|
53
|
return mdId;
|
54
|
}
|
55
|
|
56
|
public void setMdId(final String mdId) {
|
57
|
this.mdId = mdId;
|
58
|
}
|
59
|
|
60
|
public String getMdFormat() {
|
61
|
return mdFormat;
|
62
|
}
|
63
|
|
64
|
public void setMdFormat(final String mdFormat) {
|
65
|
this.mdFormat = mdFormat;
|
66
|
}
|
67
|
|
68
|
public String getEprParam() {
|
69
|
return eprParam;
|
70
|
}
|
71
|
|
72
|
public void setEprParam(final String eprParam) {
|
73
|
this.eprParam = eprParam;
|
74
|
}
|
75
|
}
|