Project

General

Profile

1
package eu.dnetlib.msro.workflows.nodes.mdstore;
2

    
3
import javax.annotation.Resource;
4
import javax.xml.ws.wsaddressing.W3CEndpointReference;
5

    
6
import eu.dnetlib.data.mdstore.MDStoreService;
7
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
8
import eu.dnetlib.msro.rmi.MSROException;
9
import eu.dnetlib.msro.workflows.graph.Arc;
10
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
11
import eu.dnetlib.msro.workflows.procs.Env;
12
import org.apache.commons.logging.Log;
13
import org.apache.commons.logging.LogFactory;
14

    
15
public class FetchMDStoreRecordsJobNode extends SimpleJobNode {
16

    
17
	private static final Log log = LogFactory.getLog(FetchMDStoreRecordsJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
18

    
19
	@Resource
20
	private UniqueServiceLocator serviceLocator;
21

    
22
	private String mdId;
23
	private String mdFormat;
24
	private String eprParam;
25

    
26
	@Override
27
	protected String execute(final Env env) throws Exception {
28
		if (getMdId() == null) {
29
			setMdId(env.getAttribute("mdId", String.class));
30
		}
31
		if (getMdFormat() == null) {
32
			setMdFormat(env.getAttribute("mdFormat", String.class));
33
		}
34

    
35
		log.info("getting MDRecords from: " + getMdId());
36
		final W3CEndpointReference epr = serviceLocator.getService(MDStoreService.class, getMdId()).deliverMDRecords(getMdId(), "", "", "");
37
		if (epr == null) { throw new MSROException("unable to read MDRecords from: " + getMdId()); }
38
		env.setAttribute(getEprParam(), epr.toString());
39
		return Arc.DEFAULT_ARC;
40
	}
41

    
42
	public String getMdId() {
43
		return mdId;
44
	}
45

    
46
	public void setMdId(final String mdId) {
47
		this.mdId = mdId;
48
	}
49

    
50
	public String getMdFormat() {
51
		return mdFormat;
52
	}
53

    
54
	public void setMdFormat(final String mdFormat) {
55
		this.mdFormat = mdFormat;
56
	}
57

    
58
	public String getEprParam() {
59
		return eprParam;
60
	}
61

    
62
	public void setEprParam(final String eprParam) {
63
		this.eprParam = eprParam;
64
	}
65
}
(1-1/5)