1
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.stats;
|
2
|
|
3
|
import com.googlecode.sarasvati.NodeToken;
|
4
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
5
|
import eu.dnetlib.msro.rmi.MSROException;
|
6
|
import org.apache.commons.lang.StringUtils;
|
7
|
import org.apache.commons.logging.Log;
|
8
|
import org.apache.commons.logging.LogFactory;
|
9
|
|
10
|
/**
|
11
|
* Ask the StatsManagerService to copy a cache of a portal to another portal cache.
|
12
|
* <p>
|
13
|
* The source portal is specified in the BB parameter <code>StatsManagerServiceBBAction.MIGRATE_CACHE.getSourcePortalParamName()</code>.
|
14
|
* </p>
|
15
|
* <p>
|
16
|
* The target portal is specified in the BB parameter <code>StatsManagerServiceBBAction.MIGRATE_CACHE.getTargetPortalParamName()</code>
|
17
|
* </p>
|
18
|
*
|
19
|
* @author alessia
|
20
|
*/
|
21
|
public class MigrateStatsCacheJobNode extends AbstractStatsJobNode {
|
22
|
|
23
|
private static final Log log = LogFactory.getLog(MigrateStatsCacheJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
24
|
|
25
|
/**
|
26
|
* BB parameter defining which is the portal with the source cache to migrate.
|
27
|
*/
|
28
|
private String sourcePortal;
|
29
|
|
30
|
@Override
|
31
|
protected void prepareJob(final BlackboardJob job, final NodeToken token) throws Exception {
|
32
|
job.setAction(StatsManagerServiceBBAction.MIGRATE_CACHE.action());
|
33
|
if (StringUtils.isBlank(sourcePortal)) throw new MSROException("Parameter sourcePortal required to migrate the cache");
|
34
|
job.getParameters().put(StatsManagerServiceBBAction.MIGRATE_CACHE.getSourcePortalParamName(), sourcePortal);
|
35
|
String targetPortal = getPortalName(token);
|
36
|
if (StringUtils.isNotBlank(targetPortal)) {
|
37
|
job.getParameters().put(StatsManagerServiceBBAction.MIGRATE_CACHE.getTargetPortalParamName(), targetPortal);
|
38
|
} else {
|
39
|
log.warn(StatsManagerServiceBBAction.MIGRATE_CACHE.getTargetPortalParamName() + " not set. The StatsManagerService will use its default.");
|
40
|
}
|
41
|
|
42
|
}
|
43
|
|
44
|
public String getSourcePortal() {
|
45
|
return sourcePortal;
|
46
|
}
|
47
|
|
48
|
public void setSourcePortal(final String sourcePortal) {
|
49
|
this.sourcePortal = sourcePortal;
|
50
|
}
|
51
|
}
|