Project

General

Profile

1
package eu.dnetlib.functionality.index.actors;
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.quartz.Job;
8
import org.quartz.JobExecutionContext;
9
import org.quartz.JobExecutionException;
10

    
11
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils;
12
import eu.dnetlib.enabling.resultset.rmi.ResultSetException;
13
import eu.dnetlib.enabling.resultset.rmi.ResultSetService;
14
import eu.dnetlib.enabling.tools.ServiceResolver;
15
import eu.dnetlib.functionality.index.action.BBParam;
16

    
17
public class ResultsetKeepAliveJob implements Job {
18

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

    
21
	public static final String JOB_NAME = "resultsetKeepaliveJob";
22

    
23
	public static final String JOB_GROUP = "keepalive";
24

    
25
	/**
26
	 * used to resolve the epr references to the service endpoint
27
	 */
28
	private ServiceResolver serviceResolver;
29

    
30
	private EPRUtils eprUtils;
31

    
32
	@Override
33
	public void execute(final JobExecutionContext context) throws JobExecutionException {
34

    
35
		final String rsEpr = (String) context.getTrigger().getJobDataMap().get(BBParam.RS_EPR);
36
		final W3CEndpointReference epr = eprUtils.getEpr(rsEpr);
37

    
38
		final ResultSetService resultSet = getServiceResolver().getService(ResultSetService.class, epr);
39
		final String rsId = serviceResolver.getResourceIdentifier(epr);
40

    
41
		try {
42
			log.debug("\n\n keepalive resultset: " + rsId + " triggerId: " + context.getTrigger().getJobKey().getName() + "\n\n");
43

    
44
			// TODO: change to a getRSStatus call, getNumberOfElements could be potentially slow (ticket #1569)
45
			resultSet.getNumberOfElements(rsId);
46
		} catch (ResultSetException e) {
47
			log.warn("couldn't invoke the resultset call to keep-it-alive");
48
			throw new RuntimeException(e);
49
		}
50
	}
51

    
52
	public void setServiceResolver(final ServiceResolver serviceResolver) {
53
		this.serviceResolver = serviceResolver;
54
	}
55

    
56
	public ServiceResolver getServiceResolver() {
57
		return serviceResolver;
58
	}
59

    
60
	public void setEprUtils(final EPRUtils eprUtils) {
61
		this.eprUtils = eprUtils;
62
	}
63

    
64
	public EPRUtils getEprUtils() {
65
		return eprUtils;
66
	}
67

    
68
}
(8-8/8)