Revision 41480
Added by Michele Artini over 8 years ago
RegisterWorkflowFromTemplateJobNode.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import org.antlr.stringtemplate.StringTemplate; |
6 | 6 |
import org.apache.commons.io.IOUtils; |
7 |
import org.apache.commons.lang.StringEscapeUtils; |
|
8 |
import org.apache.commons.logging.Log; |
|
9 |
import org.apache.commons.logging.LogFactory; |
|
7 | 10 |
|
8 | 11 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
9 | 12 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
... | ... | |
15 | 18 |
public class RegisterWorkflowFromTemplateJobNode extends SimpleJobNode { |
16 | 19 |
|
17 | 20 |
private String wfName; |
18 |
private String wfFamily; |
|
19 |
private String wfStartMode; |
|
20 | 21 |
private String wfTemplate; |
21 | 22 |
|
23 |
private static final Log log = LogFactory.getLog(RegisterWorkflowFromTemplateJobNode.class); |
|
24 |
|
|
22 | 25 |
@Resource |
23 | 26 |
private UniqueServiceLocator serviceLocator; |
24 | 27 |
|
... | ... | |
30 | 33 |
this.wfName = wfName; |
31 | 34 |
} |
32 | 35 |
|
33 |
public String getWfFamily() { |
|
34 |
return this.wfFamily; |
|
35 |
} |
|
36 |
|
|
37 |
public void setWfFamily(final String wfFamily) { |
|
38 |
this.wfFamily = wfFamily; |
|
39 |
} |
|
40 |
|
|
41 |
public String getWfStartMode() { |
|
42 |
return this.wfStartMode; |
|
43 |
} |
|
44 |
|
|
45 |
public void setWfStartMode(final String wfStartMode) { |
|
46 |
this.wfStartMode = wfStartMode; |
|
47 |
} |
|
48 |
|
|
49 | 36 |
public String getWfTemplate() { |
50 | 37 |
return this.wfTemplate; |
51 | 38 |
} |
... | ... | |
56 | 43 |
|
57 | 44 |
@Override |
58 | 45 |
protected String execute(final Env env) throws Exception { |
46 |
final String dsId = env.getAttribute(WorkflowsConstants.DATASOURCE_ID, String.class); |
|
47 |
final String dsName = env.getAttribute(WorkflowsConstants.DATASOURCE_NAME, String.class); |
|
48 |
final String ifaceId = env.getAttribute(WorkflowsConstants.DATASOURCE_INTERFACE, String.class); |
|
49 |
|
|
59 | 50 |
final StringTemplate profTemplate = new StringTemplate(IOUtils.toString(getClass().getResourceAsStream(getWfTemplate()))); |
60 |
profTemplate.setAttribute("name", this.wfName); |
|
61 |
profTemplate.setAttribute("family", this.wfFamily); |
|
51 |
profTemplate.setAttribute("name", StringEscapeUtils.escapeXml(this.wfName)); |
|
62 | 52 |
profTemplate.setAttribute("priority", WorkflowsConstants.DEFAULT_WF_PRIORITY); |
63 |
profTemplate.setAttribute("startMode", this.wfStartMode); |
|
53 |
profTemplate.setAttribute("dsId", StringEscapeUtils.escapeXml(dsId)); |
|
54 |
profTemplate.setAttribute("dsName", StringEscapeUtils.escapeXml(dsName)); |
|
55 |
profTemplate.setAttribute("interface", StringEscapeUtils.escapeXml(ifaceId)); |
|
64 | 56 |
|
65 | 57 |
final String profId = this.serviceLocator.getService(ISRegistryService.class).registerProfile(profTemplate.toString()); |
66 | 58 |
|
67 | 59 |
env.setAttribute("repoWfId", profId); |
68 | 60 |
|
61 |
log.info("A new repo wf has been registered, id: " + profId); |
|
62 |
|
|
69 | 63 |
return Arc.DEFAULT_ARC; |
70 | 64 |
} |
71 | 65 |
|
Also available in: Unified diff
Repo HI