Revision 55260
Added by Alessia Bardi almost 5 years ago
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/deploy.info | ||
---|---|---|
1 |
{"type_source": "SVN", "goal": "package -U source:jar", |
|
2 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-msro-service/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-msro-service"} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/java/eu/dnetlib/enabling/resultset/ResultSetClientTest.java | ||
---|---|---|
1 |
package eu.dnetlib.enabling.resultset; |
|
2 |
|
|
3 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
4 |
|
|
5 |
import eu.dnetlib.data.mdstore.MDStoreService; |
|
6 |
import eu.dnetlib.data.mdstore.MDStoreServiceException; |
|
7 |
import eu.dnetlib.enabling.resultset.client.IterableResultSetClient; |
|
8 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
9 |
import eu.dnetlib.enabling.tools.ServiceResolver; |
|
10 |
import junit.framework.Assert; |
|
11 |
import org.apache.commons.lang.StringUtils; |
|
12 |
import org.apache.commons.logging.Log; |
|
13 |
import org.apache.commons.logging.LogFactory; |
|
14 |
import org.junit.Before; |
|
15 |
import org.junit.Ignore; |
|
16 |
import org.junit.Test; |
|
17 |
import org.junit.runner.RunWith; |
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
|
19 |
import org.springframework.test.context.ContextConfiguration; |
|
20 |
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|
21 |
|
|
22 |
/** |
|
23 |
* Created by claudio on 15/11/2016. |
|
24 |
*/ |
|
25 |
@RunWith(SpringJUnit4ClassRunner.class) |
|
26 |
@ContextConfiguration(locations = { "/eu/dnetlib/enabling/resultset/applicationContext-test-locators.xml"}) |
|
27 |
public class ResultSetClientTest { |
|
28 |
|
|
29 |
private static final Log log = LogFactory.getLog(ResultSetClientTest.class); |
|
30 |
public static final String MDID = "9f6d4071-ffa5-407d-a3d6-8eba1aa12cbc_TURTdG9yZURTUmVzb3VyY2VzL01EU3RvcmVEU1Jlc291cmNlVHlwZQ=="; |
|
31 |
|
|
32 |
private ResultSetClientFactory rsClientFactory; |
|
33 |
|
|
34 |
@Autowired |
|
35 |
private MDStoreService mdStoreService; |
|
36 |
|
|
37 |
@Autowired |
|
38 |
private ServiceResolver serviceResolver; |
|
39 |
|
|
40 |
@Before |
|
41 |
public void setUp() { |
|
42 |
rsClientFactory = new ResultSetClientFactory(); |
|
43 |
rsClientFactory.setTimeout(12000); |
|
44 |
rsClientFactory.setConnectTimeout(5000); |
|
45 |
rsClientFactory.setServiceResolver(serviceResolver); |
|
46 |
} |
|
47 |
|
|
48 |
@Ignore |
|
49 |
@Test |
|
50 |
public void testMDStore() throws MDStoreServiceException { |
|
51 |
|
|
52 |
final W3CEndpointReference epr = mdStoreService.deliverMDRecords(MDID, null, null, null); |
|
53 |
final IterableResultSetClient client = rsClientFactory.getClient(epr); |
|
54 |
|
|
55 |
for(String xml : client) { |
|
56 |
Assert.assertTrue(StringUtils.isNotBlank(xml)); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/java/eu/dnetlib/AppTest.java | ||
---|---|---|
1 |
package eu.dnetlib; |
|
2 |
|
|
3 |
import static org.junit.Assert.assertEquals; |
|
4 |
|
|
5 |
import java.io.StringReader; |
|
6 |
import java.io.StringWriter; |
|
7 |
import java.io.UnsupportedEncodingException; |
|
8 |
import java.net.URLEncoder; |
|
9 |
|
|
10 |
import org.dom4j.Document; |
|
11 |
import org.dom4j.DocumentException; |
|
12 |
import org.dom4j.io.SAXReader; |
|
13 |
import org.junit.Test; |
|
14 |
import org.w3c.dom.Node; |
|
15 |
import org.w3c.dom.NodeList; |
|
16 |
|
|
17 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
18 |
|
|
19 |
/** |
|
20 |
* Unit test for simple App. |
|
21 |
*/ |
|
22 |
public class AppTest { |
|
23 |
|
|
24 |
@Test |
|
25 |
public void testXslt() { |
|
26 |
String res = new ApplyXslt(getXslt()).evaluate(getXml()); |
|
27 |
System.out.println("******************"); |
|
28 |
System.out.println(res); |
|
29 |
System.out.println("******************"); |
|
30 |
} |
|
31 |
|
|
32 |
@Test |
|
33 |
public void testXpath() throws DocumentException { |
|
34 |
SAXReader reader = new SAXReader(); |
|
35 |
Document doc = reader.read(new StringReader("<a><b>test</b></a>")); |
|
36 |
assertEquals("", doc.valueOf("//c")); |
|
37 |
assertEquals("test", doc.valueOf("//b")); |
|
38 |
} |
|
39 |
|
|
40 |
public static String javaMethod(final NodeList list) { |
|
41 |
System.out.println("******************"); |
|
42 |
System.out.println("TYPE : " + list.toString()); |
|
43 |
System.out.println("LENGTH : " + list.getLength()); |
|
44 |
for (int i = 0; i < list.getLength(); i++) { |
|
45 |
Node node = list.item(i); |
|
46 |
|
|
47 |
System.out.println("ELEM " + i + ": " + node.getLocalName()); |
|
48 |
} |
|
49 |
|
|
50 |
System.out.println("******************"); |
|
51 |
return "ACUS"; |
|
52 |
} |
|
53 |
|
|
54 |
private String getXml() { |
|
55 |
final StringWriter sw = new StringWriter(); |
|
56 |
sw.append("<?xml version='1.0' encoding='UTF-8'?>\n"); |
|
57 |
sw.append("<record>\n"); |
|
58 |
sw.append("<metadata>\n"); |
|
59 |
sw.append("<a>A text value</a>\n"); |
|
60 |
sw.append("<b attr='attribute value'/>\n"); |
|
61 |
sw.append("</metadata>\n"); |
|
62 |
sw.append("</record>\n"); |
|
63 |
|
|
64 |
return sw.toString(); |
|
65 |
} |
|
66 |
|
|
67 |
private String getXslt() { |
|
68 |
final StringWriter sw = new StringWriter(); |
|
69 |
|
|
70 |
sw.append("<?xml version='1.0' encoding='UTF-8'?>\n"); |
|
71 |
sw.append("<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:dnet='eu.dnetlib.AppTest' exclude-result-prefixes='xsl dnet'>\n"); |
|
72 |
sw.append("<xsl:output omit-xml-declaration='yes' indent='yes'/>\n"); |
|
73 |
sw.append("<xsl:template match='/*'>\n"); |
|
74 |
sw.append("<xsl:variable name='metadata' select=\"//*[local-name()='metadata']/*\" />\n"); |
|
75 |
sw.append("<ROWS>\n"); |
|
76 |
sw.append("<xsl:value-of select='dnet:javaMethod($metadata)'/>\n"); |
|
77 |
sw.append("</ROWS>\n"); |
|
78 |
sw.append("</xsl:template>\n"); |
|
79 |
sw.append("</xsl:stylesheet>\n"); |
|
80 |
return sw.toString(); |
|
81 |
} |
|
82 |
|
|
83 |
@Test |
|
84 |
public void encodetest() throws UnsupportedEncodingException { |
|
85 |
String theUrl = "http://europepmc.org/GrantLookup/grants.php?&f%5B%5D=WT&range=all&format=xml&output=export"; |
|
86 |
String encoded = URLEncoder.encode(theUrl, "UTF-8"); |
|
87 |
System.out.println(encoded); |
|
88 |
} |
|
89 |
|
|
90 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/java/eu/dnetlib/msro/cron/ScheduledWorkflowLauncherTest.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.cron; |
|
2 |
|
|
3 |
import static org.junit.Assert.assertFalse; |
|
4 |
import static org.junit.Assert.assertTrue; |
|
5 |
|
|
6 |
import java.util.Date; |
|
7 |
|
|
8 |
import org.junit.Test; |
|
9 |
|
|
10 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
11 |
|
|
12 |
public class ScheduledWorkflowLauncherTest { |
|
13 |
|
|
14 |
private ScheduledWorkflowLauncher launcher = new ScheduledWorkflowLauncher(); |
|
15 |
|
|
16 |
private static final String WF_ID = "wf-1234567890"; |
|
17 |
private static final String CRON_EXPR = "0 15 9 ? * SAT"; |
|
18 |
private static final int ALMOST_TWO_WEEKS = 20000; |
|
19 |
|
|
20 |
private static final DateUtils dateUtils = new DateUtils(); |
|
21 |
private static final Date date = dateUtils.parse("2016-10-29T09:16:00+02:00"); // Saturday |
|
22 |
private static final Date oneDayBefore = dateUtils.parse("2016-10-28T09:16:00+02:00"); |
|
23 |
private static final Date oneWeekBefore = dateUtils.parse("2016-10-22T09:16:00+02:00"); |
|
24 |
private static final Date twoWeekBefore = dateUtils.parse("2016-10-15T09:16:00+02:00"); |
|
25 |
private static final Date tenMinutesAfter = dateUtils.parse("2016-10-29T09:26:00+02:00"); |
|
26 |
private static final Date oneHourAfter = dateUtils.parse("2016-10-29T10:16:00+02:00"); |
|
27 |
|
|
28 |
@Test |
|
29 |
public void testVerifyScheduled() { |
|
30 |
assertTrue(launcher.isReady(WF_ID, CRON_EXPR, ALMOST_TWO_WEEKS, null, date)); |
|
31 |
assertTrue(launcher.isReady(WF_ID, CRON_EXPR, ALMOST_TWO_WEEKS, twoWeekBefore, date)); |
|
32 |
assertTrue(launcher.isReady(WF_ID, CRON_EXPR, ALMOST_TWO_WEEKS, null, tenMinutesAfter)); |
|
33 |
assertTrue(launcher.isReady(WF_ID, CRON_EXPR, ALMOST_TWO_WEEKS, twoWeekBefore, tenMinutesAfter)); |
|
34 |
|
|
35 |
assertFalse(launcher.isReady(WF_ID, CRON_EXPR, ALMOST_TWO_WEEKS, null, oneDayBefore)); |
|
36 |
assertFalse(launcher.isReady(WF_ID, CRON_EXPR, ALMOST_TWO_WEEKS, oneDayBefore, date)); |
|
37 |
assertFalse(launcher.isReady(WF_ID, CRON_EXPR, ALMOST_TWO_WEEKS, oneWeekBefore, date)); |
|
38 |
|
|
39 |
assertFalse(launcher.isReady(WF_ID, CRON_EXPR, ALMOST_TWO_WEEKS, null, oneHourAfter)); |
|
40 |
assertFalse(launcher.isReady(WF_ID, CRON_EXPR, ALMOST_TWO_WEEKS, twoWeekBefore, oneHourAfter)); |
|
41 |
} |
|
42 |
|
|
43 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/java/eu/dnetlib/msro/notification/EmailDispatcherTest.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.notification; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.antlr.stringtemplate.StringTemplate; |
|
7 |
import org.apache.commons.io.IOUtils; |
|
8 |
import org.junit.Before; |
|
9 |
import org.junit.Test; |
|
10 |
|
|
11 |
import com.google.common.collect.Maps; |
|
12 |
|
|
13 |
public class EmailDispatcherTest { |
|
14 |
|
|
15 |
private String successTemplatePath = "/eu/dnetlib/msro/mail/wf_success.mail.st"; |
|
16 |
private String failureTemplatePath = "/eu/dnetlib/msro/mail/wf_failed.mail.st"; |
|
17 |
private EmailDispatcher dispatcher; |
|
18 |
|
|
19 |
@Before |
|
20 |
public void setUp() throws Exception { |
|
21 |
dispatcher = new EmailDispatcher(); |
|
22 |
dispatcher.setBaseUrl("http://the.base.url"); |
|
23 |
dispatcher.setInfrastructure("container.hostname"); |
|
24 |
} |
|
25 |
|
|
26 |
@Test |
|
27 |
public void testPrepareMessageSuccess() throws IOException { |
|
28 |
|
|
29 |
final String template = IOUtils.toString(getClass().getResourceAsStream(successTemplatePath)); |
|
30 |
final Map<String, Object> map = Maps.newHashMap(); |
|
31 |
map.put("wfId", "WF_ID"); |
|
32 |
map.put("wfName", "WF_NAME"); |
|
33 |
map.put("procId", "PROC_ID"); |
|
34 |
|
|
35 |
StringTemplate st = dispatcher.prepareMessage(template, map); |
|
36 |
System.out.println(st.toString()); |
|
37 |
} |
|
38 |
|
|
39 |
@Test |
|
40 |
public void testPrepareMessageFailure() throws IOException { |
|
41 |
|
|
42 |
final String template = IOUtils.toString(getClass().getResourceAsStream(failureTemplatePath)); |
|
43 |
final Map<String, Object> map = Maps.newHashMap(); |
|
44 |
map.put("wfId", "WF_ID"); |
|
45 |
map.put("wfName", "WF_NAME"); |
|
46 |
map.put("procId", "PROC_ID"); |
|
47 |
|
|
48 |
StringTemplate st = dispatcher.prepareMessage(template, map); |
|
49 |
System.out.println(st.toString()); |
|
50 |
} |
|
51 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/java/eu/dnetlib/msro/workflows/nodes/SuccessFailureNodeTest.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes; |
|
2 |
|
|
3 |
import org.junit.Test; |
|
4 |
|
|
5 |
/** |
|
6 |
* Created by Alessia Bardi on 23/10/2017. |
|
7 |
* |
|
8 |
* @author Alessia Bardi |
|
9 |
*/ |
|
10 |
public class SuccessFailureNodeTest { |
|
11 |
|
|
12 |
private SuccessFailureNode node = new SuccessFailureNode(); |
|
13 |
|
|
14 |
@Test |
|
15 |
public void testEscape(){ |
|
16 |
String val = "This is open {. This is closed }."; |
|
17 |
System.out.println(node.escape(val)); |
|
18 |
} |
|
19 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/java/eu/dnetlib/msro/workflows/xslt/LayoutToRecordStylesheetTest.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.xslt; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.InputStream; |
|
5 |
import java.io.StringReader; |
|
6 |
import java.io.StringWriter; |
|
7 |
import javax.xml.transform.Transformer; |
|
8 |
import javax.xml.transform.TransformerException; |
|
9 |
import javax.xml.transform.TransformerFactory; |
|
10 |
import javax.xml.transform.stream.StreamResult; |
|
11 |
import javax.xml.transform.stream.StreamSource; |
|
12 |
|
|
13 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
14 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
15 |
import eu.dnetlib.miscutils.functional.xml.IndentXmlString; |
|
16 |
import org.apache.commons.io.IOUtils; |
|
17 |
import org.junit.Test; |
|
18 |
import org.springframework.core.io.ClassPathResource; |
|
19 |
|
|
20 |
import static org.junit.Assert.assertFalse; |
|
21 |
import static org.junit.Assert.assertNotNull; |
|
22 |
|
|
23 |
public class LayoutToRecordStylesheetTest { |
|
24 |
|
|
25 |
private static final String LAYOUT_TO_RECORD_STYLESHEET_XSL = "/eu/dnetlib/msro/workflows/xslt/layoutToRecordStylesheet.xsl"; |
|
26 |
|
|
27 |
private static final String MDFORMAT_FIELDS = "/eu/dnetlib/msro/workflows/xslt/fields.xml"; |
|
28 |
|
|
29 |
private static final String OAF_RECORD = "/eu/dnetlib/msro/workflows/xslt/exampleRecord.xml"; |
|
30 |
|
|
31 |
@Test |
|
32 |
public void test1() throws ISLookUpException, IOException, TransformerException { |
|
33 |
String xsl = prepareXslt("DMF"); |
|
34 |
assertNotNull(xsl); |
|
35 |
assertFalse(xsl.isEmpty()); |
|
36 |
|
|
37 |
System.out.println(xsl); |
|
38 |
|
|
39 |
ApplyXslt xslt = new ApplyXslt(xsl); |
|
40 |
|
|
41 |
String indexRecord = xslt.evaluate(readFromClasspath(OAF_RECORD)); |
|
42 |
|
|
43 |
assertNotNull(indexRecord); |
|
44 |
assertFalse(indexRecord.isEmpty()); |
|
45 |
|
|
46 |
System.out.println(IndentXmlString.apply(indexRecord)); |
|
47 |
|
|
48 |
// StreamingInputDocumentFactory factory = new StreamingInputDocumentFactory(); |
|
49 |
// |
|
50 |
// SolrInputDocument doc = factory.parseDocument(DateUtils.now_ISO8601(), indexRecord, "dsId", "dnetResult"); |
|
51 |
// assertNotNull(doc); |
|
52 |
// assertFalse(doc.isEmpty()); |
|
53 |
|
|
54 |
// System.out.println(doc); |
|
55 |
|
|
56 |
} |
|
57 |
|
|
58 |
protected String prepareXslt(final String format) throws ISLookUpException, IOException, TransformerException { |
|
59 |
|
|
60 |
final TransformerFactory factory = TransformerFactory.newInstance(); |
|
61 |
|
|
62 |
final Transformer layoutTransformer = factory.newTransformer(streamSource(LAYOUT_TO_RECORD_STYLESHEET_XSL)); |
|
63 |
|
|
64 |
final StreamResult layoutToXsltXslt = new StreamResult(new StringWriter()); |
|
65 |
|
|
66 |
layoutTransformer.setParameter("format", format); |
|
67 |
layoutTransformer.transform(streamSource(MDFORMAT_FIELDS), layoutToXsltXslt); |
|
68 |
|
|
69 |
String layoutToXsltXsltString = layoutToXsltXslt.getWriter().toString(); |
|
70 |
System.out.println(IndentXmlString.apply(layoutToXsltXsltString) + "\n\n\n"); |
|
71 |
|
|
72 |
return layoutToXsltXsltString; |
|
73 |
} |
|
74 |
|
|
75 |
private StreamSource streamSource(final String s) throws IOException { |
|
76 |
return new StreamSource(new StringReader(readFromClasspath(s))); |
|
77 |
} |
|
78 |
|
|
79 |
private String readFromClasspath(final String s) throws IOException { |
|
80 |
ClassPathResource resource = new ClassPathResource(s); |
|
81 |
InputStream inputStream = resource.getInputStream(); |
|
82 |
return IOUtils.toString(inputStream); |
|
83 |
} |
|
84 |
|
|
85 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/resources/eu/dnetlib/enabling/resultset/applicationContext-test-locators.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
4 |
xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing" |
|
5 |
xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration" |
|
6 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
|
7 |
http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd |
|
8 |
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd |
|
9 |
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd |
|
10 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> |
|
11 |
|
|
12 |
<!-- common service resolution chain --> |
|
13 |
<bean id="serviceResolver" class="eu.dnetlib.enabling.tools.ServiceResolverChain"> |
|
14 |
<property name="resolvers"> |
|
15 |
<list> |
|
16 |
<bean id="jaxwsServiceResolver" class="eu.dnetlib.enabling.tools.JaxwsServiceResolverImpl" /> |
|
17 |
</list> |
|
18 |
</property> |
|
19 |
</bean> |
|
20 |
|
|
21 |
<bean id="jobScheduler" |
|
22 |
class="org.springframework.scheduling.quartz.SchedulerFactoryBean" |
|
23 |
destroy-method="destroy"> |
|
24 |
<property name="jobFactory"> |
|
25 |
<bean id="jobSchedulerFactory" |
|
26 |
class="org.springframework.scheduling.quartz.SpringBeanJobFactory" /> |
|
27 |
</property> |
|
28 |
</bean> |
|
29 |
|
|
30 |
<jaxws:client id="mdStoreService" |
|
31 |
serviceClass="eu.dnetlib.data.mdstore.MDStoreService" |
|
32 |
address="http://localhost:8280/app/services/mdStore" /> |
|
33 |
|
|
34 |
<bean id="uuidGenerator" class="eu.dnetlib.enabling.tools.UniqueIdentifierGeneratorImpl" /> |
|
35 |
|
|
36 |
<alias name="cxfEndpointReferenceBuilder" alias="eprBuilder" /> |
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
</beans> |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/resources/eu/dnetlib/msro/workflows/xslt/fields.xml | ||
---|---|---|
1 |
<LAYOUT name="index"> |
|
2 |
<FIELDS> |
|
3 |
<FIELD indexable="true" name="objIdentifier" result="false" stat="false" tokenizable="false" xpath="//dri:objIdentifier"/> |
|
4 |
<FIELD indexable="true" name="CobjContentSynthesis" result="true" stat="false" xpath="//dr:CobjContentSynthesis"/> |
|
5 |
<FIELD indexable="true" name="CobjTypology" result="true" stat="false" tokenizable="false" xpath="//dr:CobjTypology"/> |
|
6 |
<FIELD indexable="true" name="CobjIdentifier" result="true" stat="false" tokenizable="false" xpath="//dr:CobjIdentifier"/> |
|
7 |
<FIELD indexable="true" name="CobjModel" result="true" stat="false" tokenizable="false" xpath="//dr:CobjModel"/> |
|
8 |
<FIELD indexable="true" name="CobjMDFormats" result="true" stat="false" tokenizable="false" xpath="//dr:CobjMDFormats"/> |
|
9 |
<FIELD indexable="true" name="CobjDescriptionSynthesis" result="true" stat="false" xpath="//dr:CobjDescriptionSynthesis"/> |
|
10 |
<FIELD indexable="true" name="aggregatorName" result="true" stat="false" xpath="//dr:aggregatorName"/> |
|
11 |
<FIELD indexable="true" name="aggregatorInstitution" result="true" stat="false" xpath="//dr:aggregatorInstitution"/> |
|
12 |
<FIELD indexable="true" name="repositoryName" tokenizable="true" result="true" stat="true" xpath="//dr:repositoryName"/> |
|
13 |
<FIELD indexable="true" name="repositoryLink" result="true" stat="false" tokenizable="false" xpath="//dr:repositoryLink"/> |
|
14 |
<FIELD indexable="true" name="repositoryCountry" result="true" stat="false" tokenizable="false" xpath="//dr:repositoryCountry"/> |
|
15 |
<FIELD indexable="true" name="repositoryInstitution" result="true" stat="false" xpath="//dr:repositoryInstitution"/> |
|
16 |
<FIELD indexable="true" name="repositoryId" result="false" stat="false" xpath="//dri:repositoryId"/> |
|
17 |
<FIELD indexable="true" name="creator" result="true" stat="false" xpath="//dc:creator"/> |
|
18 |
<FIELD indexable="true" name="title" result="true" stat="false" xpath="//dc:title"/> |
|
19 |
<FIELD indexable="true" name="subject" tokenizable="true" result="true" stat="true" xpath="//dc:subject"/> |
|
20 |
<FIELD indexable="true" name="CobjCategory" result="true" stat="false" tokenizable="false" xpath="//dr:CobjCategory"/> |
|
21 |
<FIELD indexable="true" name="language" result="true" stat="false" tokenizable="false" xpath="//dc:language"/> |
|
22 |
<FIELD indexable="true" name="dateAccepted" result="true" stat="false" tokenizable="false" xpath="//*[local-name()='dateAccepted']"/> |
|
23 |
<FIELD indexable="true" name="identifier" result="true" stat="false" tokenizable="false" xpath="//dc:identifier"/> |
|
24 |
<FIELD indexable="true" name="publisher" tokenizable="true" result="true" stat="true" xpath="//dc:publisher"/> |
|
25 |
<FIELD indexable="true" name="source" tokenizable="true" result="true" stat="true" xpath="//dc:source | //dc:source2"/> |
|
26 |
<FIELD indexable="true" name="contributor" tokenizable="true" result="true" stat="true" xpath="//dc:contributor"/> |
|
27 |
<FIELD indexable="true" name="relation" result="true" stat="false" tokenizable="false" xpath="//dc:relation"/> |
|
28 |
<FIELD indexable="true" name="description" result="true" stat="false" xpath="//dc:description"/> |
|
29 |
<!-- Browsing Fields --> |
|
30 |
<FIELD indexable="true" name="subjectforbrowsing" browsingAliasFor="subject" tokenizable="false" result="false" stat="false" xpath="//dc:subject"/> |
|
31 |
<FIELD indexable="true" name="contributorforbrowsing" browsingAliasFor="contributor" tokenizable="false" result="false" stat="false" xpath="//dc:contributor"/> |
|
32 |
<FIELD indexable="true" name="publisherforbrowsing" browsingAliasFor="publisher" tokenizable="false" result="false" stat="false" xpath="//dc:publisher"/> |
|
33 |
<FIELD indexable="true" name="sourceforbrowsing" browsingAliasFor="source" tokenizable="false" result="false" stat="false" xpath="//dc:source"/> |
|
34 |
<FIELD indexable="true" name="repositorynameforbrowsing" browsingAliasFor="repositoryName" tokenizable="false" result="false" stat="false" xpath="//dr:repositoryName"/> |
|
35 |
</FIELDS> |
|
36 |
</LAYOUT> |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/resources/eu/dnetlib/msro/workflows/xslt/exampleRecord.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<record xmlns:dc="http://purl.org/dc/elements/1.1/" |
|
3 |
xmlns:dr="http://www.driver-repository.eu/namespace/dr" |
|
4 |
xmlns:dri="http://www.driver-repository.eu/namespace/dri" |
|
5 |
xmlns:oaf="http://namespace.openaire.eu/oaf" |
|
6 |
xmlns:prov="http://www.openarchives.org/OAI/2.0/provenance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
7 |
<header xmlns="http://namespace.openaire.eu/"> |
|
8 |
<dri:objIdentifier>PUMA::017b981f757dec43ff5d691bed64f36f</dri:objIdentifier> |
|
9 |
<dri:recordIdentifier>oai:pumaoai.isti.cnr.it:cnr.isti/cnr.cnuce/1975-B4-019</dri:recordIdentifier> |
|
10 |
<dri:dateOfCollection/> |
|
11 |
<dri:mdFormat/> |
|
12 |
<dri:mdFormatInterpretation/> |
|
13 |
<dri:repositoryId>2c8bf258-251a-4cdc-b735-bbb4e651cae9_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=</dri:repositoryId> |
|
14 |
<dr:objectIdentifier/> |
|
15 |
<dr:dateOfCollection>2014-11-18T11:22:35Z</dr:dateOfCollection> |
|
16 |
</header> |
|
17 |
<metadata xmlns="http://namespace.openaire.eu/"> |
|
18 |
<dc:creator>Bracci, Edoardo</dc:creator> |
|
19 |
<dc:creator>Medves, Riccardo</dc:creator> |
|
20 |
<dc:title>Foo</dc:title> |
|
21 |
<dc:date>1975-07-01</dc:date> |
|
22 |
<dc:description>No abstract available.</dc:description> |
|
23 |
<dc:identifier>http://puma.isti.cnr.it/dfdownloadnew.php?ident=cnr.isti/cnr.cnuce/1975-B4-019</dc:identifier> |
|
24 |
<dc:identifier>http://puma.isti.cnr.it/rmydownload.php?filename=cnr.isti/cnr.cnuce/1975-B4-019/1975-B4-019.pdf</dc:identifier> |
|
25 |
<dc:language>it</dc:language> |
|
26 |
<dc:source>Internal note CNUCE-Manuali-91-1975, 1975.</dc:source> |
|
27 |
<dc:source>X</dc:source> |
|
28 |
<dc:source2>Y</dc:source2> |
|
29 |
<dc:subject>Utilities</dc:subject> |
|
30 |
<dr:CobjCategory>Otro</dr:CobjCategory> |
|
31 |
<oaf:dateAccepted>1975-07-01</oaf:dateAccepted> |
|
32 |
<oaf:collectedDatasourceid/> |
|
33 |
<oaf:accessrights>OPEN</oaf:accessrights> |
|
34 |
<oaf:hostedBy id="" name="PUblication MAnagement"/> |
|
35 |
<oaf:collectedFrom id="" name="PUblication MAnagement"/> |
|
36 |
</metadata> |
|
37 |
</record> |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/test/resources/log4j.properties | ||
---|---|---|
1 |
### Root Level ### |
|
2 |
log4j.rootLogger=WARN, CONSOLE |
|
3 |
|
|
4 |
### Configuration for the CONSOLE appender ### |
|
5 |
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender |
|
6 |
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout |
|
7 |
log4j.appender.CONSOLE.layout.ConversionPattern=[%-5p] %d %c - %m%n |
|
8 |
|
|
9 |
org.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger |
|
10 |
|
|
11 |
|
|
12 |
org.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger |
|
13 |
|
|
14 |
### Application Level ### |
|
15 |
log4j.logger.eu.dnetlib=INFO |
|
16 |
eu.dnetlib.enabling.resultset.ResultSetClientTest=DEBUG |
|
17 |
|
|
18 |
### Spring ### |
|
19 |
log4j.logger.org.springframework=ERROR |
|
20 |
|
|
21 |
|
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/cron/ScheduledWorkflowLauncher.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.cron; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
import javax.annotation.Resource; |
|
6 |
|
|
7 |
import org.apache.commons.lang.StringUtils; |
|
8 |
import org.apache.commons.lang.math.NumberUtils; |
|
9 |
import org.apache.commons.logging.Log; |
|
10 |
import org.apache.commons.logging.LogFactory; |
|
11 |
import org.quartz.CronExpression; |
|
12 |
import org.springframework.beans.factory.annotation.Required; |
|
13 |
|
|
14 |
import com.googlecode.sarasvati.GraphProcess; |
|
15 |
|
|
16 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
17 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
18 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
19 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
20 |
import eu.dnetlib.msro.workflows.sarasvati.loader.WorkflowExecutor; |
|
21 |
import eu.dnetlib.msro.workflows.sarasvati.registry.GraphProcessRegistry; |
|
22 |
|
|
23 |
public class ScheduledWorkflowLauncher { |
|
24 |
|
|
25 |
private static final Log log = LogFactory.getLog(ScheduledWorkflowLauncher.class); |
|
26 |
|
|
27 |
private static final DateUtils dateUtils = new DateUtils(); |
|
28 |
|
|
29 |
private WorkflowExecutor workflowExecutor; |
|
30 |
|
|
31 |
private GraphProcessRegistry graphProcessRegistry; |
|
32 |
|
|
33 |
private int windowSize = 1800000; // 30 minutes |
|
34 |
|
|
35 |
private final static int millisInMinute = 60000; |
|
36 |
|
|
37 |
@Resource |
|
38 |
private UniqueServiceLocator serviceLocator; |
|
39 |
|
|
40 |
public void verifySheduledWorkflows() { |
|
41 |
log.debug("Verifying scheduled workflows - START"); |
|
42 |
|
|
43 |
final String query = "for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType') " + |
|
44 |
"where $x//CONFIGURATION/@status='EXECUTABLE' " + |
|
45 |
"and $x//SCHEDULING/@enabled='true' " + |
|
46 |
"return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x//SCHEDULING/CRON, ' @@@ ', $x//SCHEDULING/MININTERVAL)"; |
|
47 |
|
|
48 |
try { |
|
49 |
final int defaultMinInterval = windowSize / millisInMinute; |
|
50 |
for (final String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query)) { |
|
51 |
final String[] arr = s.split("@@@"); |
|
52 |
final String id = arr[0].trim(); |
|
53 |
final String cron = arr[1].trim(); |
|
54 |
final int minInterval = Math.max(NumberUtils.toInt(arr[2].trim(), 0), defaultMinInterval); |
|
55 |
final Date lastExecutionDate = calculateLastExecutionDate(id); |
|
56 |
|
|
57 |
if (isReady(id, cron, minInterval, lastExecutionDate, new Date()) && !isAlreadyRunning(id)) { |
|
58 |
try { |
|
59 |
workflowExecutor.startMetaWorkflow(id, false); |
|
60 |
} catch (final Exception e) { |
|
61 |
log.debug("Error launching scheduled wf: " + id, e); |
|
62 |
} |
|
63 |
} |
|
64 |
} |
|
65 |
} catch (final ISLookUpException e) { |
|
66 |
log.error("Error executing query " + query); |
|
67 |
} |
|
68 |
|
|
69 |
log.debug("Verifying scheduled workflows - END"); |
|
70 |
} |
|
71 |
|
|
72 |
protected boolean isReady(final String id, final String cron, final int minInterval, final Date lastExecutionDate, final Date now) { |
|
73 |
if (CronExpression.isValidExpression(cron)) { |
|
74 |
final int minIntervalMillis = minInterval * 60000; // minutes to millis; |
|
75 |
|
|
76 |
final boolean res; |
|
77 |
if (lastExecutionDate != null) { |
|
78 |
final int elapsed = Math.round(now.getTime() - lastExecutionDate.getTime()); |
|
79 |
res = (elapsed > minIntervalMillis) && verifyCron(cron, now); |
|
80 |
} else { |
|
81 |
res = verifyCron(cron, now); |
|
82 |
} |
|
83 |
|
|
84 |
if (log.isDebugEnabled()) { |
|
85 |
log.debug("**************************************************************"); |
|
86 |
log.debug("META WORKFLOW ID : " + id); |
|
87 |
log.debug("NOW : " + now); |
|
88 |
log.debug("LAST EXECUTION DATE : " + lastExecutionDate); |
|
89 |
log.debug("MIN INTERVAL (minutes) : " + minInterval); |
|
90 |
log.debug("REAL MIN INTERVAL (ms) : " + minIntervalMillis); |
|
91 |
log.debug("WINDOW SIZE (ms) : " + windowSize); |
|
92 |
log.debug("MUST BE EXECUTED : " + res); |
|
93 |
log.debug("**************************************************************"); |
|
94 |
} |
|
95 |
|
|
96 |
return res; |
|
97 |
} |
|
98 |
|
|
99 |
return false; |
|
100 |
} |
|
101 |
|
|
102 |
private boolean verifyCron(final String cronExpression, final Date now) { |
|
103 |
try { |
|
104 |
final CronExpression cron = new CronExpression(cronExpression); |
|
105 |
|
|
106 |
final Date date = new Date(now.getTime() - windowSize); |
|
107 |
|
|
108 |
final Date cronDate = cron.getNextValidTimeAfter(date); |
|
109 |
|
|
110 |
if (log.isDebugEnabled()) { |
|
111 |
log.debug("NEXT EXECUTION DATE: " + cronDate); |
|
112 |
log.debug("FIRED : " + (cronDate.getTime() < now.getTime())); |
|
113 |
} |
|
114 |
return cronDate.getTime() < now.getTime(); |
|
115 |
} catch (final Exception e) { |
|
116 |
log.error("Error calculating next cron event: " + cronExpression, e); |
|
117 |
return false; |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
private boolean isAlreadyRunning(final String metaWfId) { |
|
122 |
final String query = "doc('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType/" + StringUtils.substringBefore(metaWfId, "_") |
|
123 |
+ "')//WORKFLOW/@id/string()"; |
|
124 |
|
|
125 |
try { |
|
126 |
for (final String profileId : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query)) { |
|
127 |
if (profileId.length() > 0) { |
|
128 |
for (final GraphProcess p : graphProcessRegistry.findProcessesByResource(profileId)) { |
|
129 |
switch (p.getState()) { |
|
130 |
case Created: |
|
131 |
return true; |
|
132 |
case Executing: |
|
133 |
return true; |
|
134 |
default: |
|
135 |
break; |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
} |
|
140 |
} catch (final ISLookUpException e) { |
|
141 |
log.error("Error executing query " + query); |
|
142 |
} |
|
143 |
return false; |
|
144 |
} |
|
145 |
|
|
146 |
private Date calculateLastExecutionDate(final String id) { |
|
147 |
final String query = "for $id in doc('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType/" + StringUtils.substringBefore(id, "_") |
|
148 |
+ "')//WORKFLOW/@id/string() " + |
|
149 |
"for $x in doc(concat('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType/', substring-before($id, '_'))) " + |
|
150 |
"where $x//LAST_EXECUTION_STATUS = 'SUCCESS' " + |
|
151 |
"return $x//LAST_EXECUTION_DATE/text() "; |
|
152 |
|
|
153 |
long time = 0; |
|
154 |
try { |
|
155 |
for (final String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query)) { |
|
156 |
if (s.length() > 0) { |
|
157 |
final Date d = dateUtils.parse(s); |
|
158 |
if (time < d.getTime()) { |
|
159 |
time = d.getTime(); |
|
160 |
} |
|
161 |
} |
|
162 |
} |
|
163 |
} catch (final ISLookUpException e) { |
|
164 |
log.error("Error executing query " + query); |
|
165 |
} catch (final Exception e) { |
|
166 |
log.error("Error calculating date", e); |
|
167 |
} |
|
168 |
|
|
169 |
return time > 0 ? new Date(time) : null; |
|
170 |
} |
|
171 |
|
|
172 |
public WorkflowExecutor getWorkflowExecutor() { |
|
173 |
return workflowExecutor; |
|
174 |
} |
|
175 |
|
|
176 |
@Required |
|
177 |
public void setWorkflowExecutor(final WorkflowExecutor workflowExecutor) { |
|
178 |
this.workflowExecutor = workflowExecutor; |
|
179 |
} |
|
180 |
|
|
181 |
public GraphProcessRegistry getGraphProcessRegistry() { |
|
182 |
return graphProcessRegistry; |
|
183 |
} |
|
184 |
|
|
185 |
@Required |
|
186 |
public void setGraphProcessRegistry(final GraphProcessRegistry graphProcessRegistry) { |
|
187 |
this.graphProcessRegistry = graphProcessRegistry; |
|
188 |
} |
|
189 |
|
|
190 |
public int getWindowSize() { |
|
191 |
return windowSize; |
|
192 |
} |
|
193 |
|
|
194 |
@Required |
|
195 |
public void setWindowSize(final int windowSize) { |
|
196 |
this.windowSize = windowSize; |
|
197 |
} |
|
198 |
|
|
199 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/MSROServiceImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.msro; |
|
2 |
|
|
3 |
import javax.jws.WebService; |
|
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 eu.dnetlib.enabling.tools.AbstractBaseService; |
|
10 |
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler; |
|
11 |
import eu.dnetlib.msro.rmi.MSROService; |
|
12 |
import eu.dnetlib.msro.workflows.sarasvati.registry.GraphProcessRegistry; |
|
13 |
|
|
14 |
@WebService(targetNamespace = "http://services.dnetlib.eu/") |
|
15 |
public class MSROServiceImpl extends AbstractBaseService implements MSROService { |
|
16 |
|
|
17 |
/** |
|
18 |
* logger. |
|
19 |
*/ |
|
20 |
private static final Log log = LogFactory.getLog(MSROServiceImpl.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
21 |
|
|
22 |
/** |
|
23 |
* notification handler. |
|
24 |
*/ |
|
25 |
private NotificationHandler notificationHandler; |
|
26 |
|
|
27 |
/** |
|
28 |
* graph process registry. |
|
29 |
*/ |
|
30 |
private GraphProcessRegistry processRegistry; |
|
31 |
|
|
32 |
@Override |
|
33 |
public void notify(final String subscriptionId, final String topic, final String isId, final String message) { |
|
34 |
super.notify(subscriptionId, topic, isId, message); |
|
35 |
|
|
36 |
log.debug("got notification: " + topic); |
|
37 |
|
|
38 |
getNotificationHandler().notified(subscriptionId, topic, isId, message); |
|
39 |
} |
|
40 |
|
|
41 |
@Required |
|
42 |
public void setNotificationHandler(final NotificationHandler notHandler) { |
|
43 |
this.notificationHandler = notHandler; |
|
44 |
} |
|
45 |
|
|
46 |
public NotificationHandler getNotificationHandler() { |
|
47 |
return notificationHandler; |
|
48 |
} |
|
49 |
|
|
50 |
@Required |
|
51 |
public void setProcessRegistry(final GraphProcessRegistry processRegistry) { |
|
52 |
this.processRegistry = processRegistry; |
|
53 |
} |
|
54 |
|
|
55 |
public GraphProcessRegistry getProcessRegistry() { |
|
56 |
return processRegistry; |
|
57 |
} |
|
58 |
|
|
59 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/notification/WfDependencyLauncherNotificationHandler.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.notification; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.Map; |
|
5 |
import java.util.Set; |
|
6 |
|
|
7 |
import javax.annotation.Resource; |
|
8 |
|
|
9 |
import org.apache.commons.logging.Log; |
|
10 |
import org.apache.commons.logging.LogFactory; |
|
11 |
import org.dom4j.Document; |
|
12 |
import org.dom4j.DocumentException; |
|
13 |
import org.dom4j.Node; |
|
14 |
import org.dom4j.io.SAXReader; |
|
15 |
|
|
16 |
import com.google.common.base.Splitter; |
|
17 |
import com.google.common.collect.Maps; |
|
18 |
import com.google.common.collect.Sets; |
|
19 |
|
|
20 |
import eu.dnetlib.enabling.actions.AbstractSubscriptionAction; |
|
21 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
22 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
23 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
24 |
import eu.dnetlib.msro.workflows.metawf.WorkflowStartModeEnum; |
|
25 |
import eu.dnetlib.msro.workflows.sarasvati.loader.WorkflowExecutor; |
|
26 |
|
|
27 |
public class WfDependencyLauncherNotificationHandler extends AbstractSubscriptionAction { |
|
28 |
|
|
29 |
@Resource |
|
30 |
private UniqueServiceLocator serviceLocator; |
|
31 |
|
|
32 |
@Resource |
|
33 |
private WorkflowExecutor workflowExecutor; |
|
34 |
|
|
35 |
@Resource |
|
36 |
private EmailDispatcher emailDispatcher; |
|
37 |
|
|
38 |
private static final Log log = LogFactory.getLog(WorkflowExecutor.class); |
|
39 |
|
|
40 |
@Override |
|
41 |
public void notified(final String subscrId, final String topic, final String rsId, final String profile) { |
|
42 |
|
|
43 |
final SAXReader reader = new SAXReader(); |
|
44 |
try { |
|
45 |
final Document doc = reader.read(new StringReader(profile)); |
|
46 |
|
|
47 |
final Set<String> emails = calculateEmails(rsId); |
|
48 |
final String procId = doc.valueOf("//LAST_EXECUTION_ID"); |
|
49 |
final String wfName = doc.valueOf("//WORKFLOW_NAME"); |
|
50 |
final boolean success = doc.valueOf("//LAST_EXECUTION_STATUS").equals("SUCCESS"); |
|
51 |
final Map<String, String> responses = Maps.newHashMap(); |
|
52 |
|
|
53 |
for (Object o : doc.selectNodes("//LAST_EXECUTION_OUTPUT")) { |
|
54 |
Node n = (Node) o; |
|
55 |
responses.put(n.valueOf("@name"), n.getText()); |
|
56 |
} |
|
57 |
|
|
58 |
if (!success) { |
|
59 |
log.info("Last execution of " + rsId + " failed, dependencies NOT STARTED"); |
|
60 |
} |
|
61 |
|
|
62 |
final String query = "for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType')//WORKFLOW[@id='" + rsId |
|
63 |
+ "']/WORKFLOW let $y := /RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = $x/@id] " |
|
64 |
+ "where $y//CONFIGURATION/@start != 'disabled' return concat ($x/@id , ' @@@ ', $x/@name , ' @@@ ', $y//CONFIGURATION/@start)"; |
|
65 |
|
|
66 |
try { |
|
67 |
final Map<String, String> pendingWfs = Maps.newHashMap(); |
|
68 |
|
|
69 |
for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query)) { |
|
70 |
final String[] arr = s.split("@@@"); |
|
71 |
final String id = arr[0].trim(); |
|
72 |
final String name = arr[1].trim(); |
|
73 |
final boolean manual = arr[2].trim().equalsIgnoreCase(WorkflowStartModeEnum.manual.toString()); |
|
74 |
if (success && !manual) { |
|
75 |
try { |
|
76 |
String pid = workflowExecutor.startProcess(id); |
|
77 |
log.info("PROC " + pid + " of WF " + id + " STARTED AS CHILD OF " + rsId); |
|
78 |
} catch (Exception e) { |
|
79 |
log.error("Error starting wf: " + id); |
|
80 |
} |
|
81 |
} else { |
|
82 |
pendingWfs.put(id, name); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
if (!emails.isEmpty()) { |
|
87 |
if (success) { |
|
88 |
emailDispatcher.sendSuccessMail(emails, rsId, procId, wfName, pendingWfs, responses); |
|
89 |
} else { |
|
90 |
final String error = doc.valueOf("//LAST_EXECUTION_ERROR"); |
|
91 |
emailDispatcher.sendFailedMail(emails, rsId, procId, wfName, pendingWfs, responses, error); |
|
92 |
} |
|
93 |
} |
|
94 |
} catch (ISLookUpException e) { |
|
95 |
log.error("Error executing xquery: " + query, e); |
|
96 |
} |
|
97 |
} catch (DocumentException e) { |
|
98 |
log.error("Error parsing profile with id " + rsId + ": " + profile); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
private Set<String> calculateEmails(final String id) { |
|
103 |
final Set<String> list = Sets.newHashSet(); |
|
104 |
try { |
|
105 |
for (String val : serviceLocator.getService(ISLookUpService.class).quickSearchProfile("//ADMIN_EMAIL[..//WORKFLOW/@id='" + id + "']/text()")) { |
|
106 |
for (String s : Splitter.on(",").trimResults().omitEmptyStrings().split(val)) { |
|
107 |
list.add(s); |
|
108 |
} |
|
109 |
} |
|
110 |
} catch (Exception e) { |
|
111 |
log.error("Error searching email adresses", e); |
|
112 |
} |
|
113 |
return list; |
|
114 |
} |
|
115 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/notification/EmailDispatcher.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.notification; |
|
2 |
|
|
3 |
import java.util.Arrays; |
|
4 |
import java.util.Date; |
|
5 |
import java.util.Map; |
|
6 |
import java.util.Properties; |
|
7 |
import java.util.Set; |
|
8 |
import java.util.concurrent.BlockingQueue; |
|
9 |
import java.util.concurrent.LinkedBlockingQueue; |
|
10 |
|
|
11 |
import javax.mail.Authenticator; |
|
12 |
import javax.mail.Message; |
|
13 |
import javax.mail.MessagingException; |
|
14 |
import javax.mail.PasswordAuthentication; |
|
15 |
import javax.mail.Session; |
|
16 |
import javax.mail.Transport; |
|
17 |
import javax.mail.internet.InternetAddress; |
|
18 |
import javax.mail.internet.MimeMessage; |
|
19 |
|
|
20 |
import org.antlr.stringtemplate.StringTemplate; |
|
21 |
import org.apache.commons.io.IOUtils; |
|
22 |
import org.apache.commons.logging.Log; |
|
23 |
import org.apache.commons.logging.LogFactory; |
|
24 |
import org.springframework.beans.factory.annotation.Required; |
|
25 |
|
|
26 |
import com.google.common.base.Splitter; |
|
27 |
import com.google.common.collect.Maps; |
|
28 |
|
|
29 |
public class EmailDispatcher { |
|
30 |
|
|
31 |
private String from; |
|
32 |
private String fromName; |
|
33 |
private String cc; |
|
34 |
private String smtpHost; |
|
35 |
private int smtpPort = 587; |
|
36 |
private String smtpUser; |
|
37 |
private String smtpPassword; |
|
38 |
private String baseUrl; |
|
39 |
private String infrastructure; |
|
40 |
|
|
41 |
private static final Log log = LogFactory.getLog(EmailDispatcher.class); |
|
42 |
|
|
43 |
private final BlockingQueue<Message> queue = new LinkedBlockingQueue<Message>(); |
|
44 |
|
|
45 |
public StringTemplate prepareMessage(final String template, final Map<String, Object> tmplParams) { |
|
46 |
final StringTemplate st = new StringTemplate(template); |
|
47 |
st.setAttributes(tmplParams); |
|
48 |
st.setAttribute("baseUrl", baseUrl); |
|
49 |
st.setAttribute("infrastructure", infrastructure); |
|
50 |
return st; |
|
51 |
} |
|
52 |
|
|
53 |
public void sendMail(final Set<String> to, final String subject, final String template, final Map<String, Object> tmplParams) { |
|
54 |
try { |
|
55 |
final StringTemplate st = prepareMessage(template, tmplParams); |
|
56 |
|
|
57 |
final Session session = Session.getInstance(obtainProperties(), obtainAuthenticator()); |
|
58 |
|
|
59 |
final MimeMessage message = new MimeMessage(session); |
|
60 |
message.setFrom(new InternetAddress(from, fromName)); |
|
61 |
message.setSubject(subject); |
|
62 |
message.setContent(st.toString(), "text/html; charset=utf-8"); |
|
63 |
message.setSentDate(new Date()); |
|
64 |
|
|
65 |
for (String s : to) { |
|
66 |
message.addRecipient(Message.RecipientType.TO, new InternetAddress(s)); |
|
67 |
} |
|
68 |
if ((cc != null) && !cc.isEmpty()) { |
|
69 |
for (String aCC : Splitter.on(",").omitEmptyStrings().trimResults().split(getCc())) { |
|
70 |
message.addRecipient(Message.RecipientType.CC, new InternetAddress(aCC)); |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
queue.add(message); |
|
75 |
|
|
76 |
log.info("Mail to " + Arrays.toString(to.toArray()) + " in queue"); |
|
77 |
} catch (Exception e) { |
|
78 |
log.error("Error sending mail", e); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
public void processMailQueue() { |
|
83 |
while (true) { |
|
84 |
final Message message = queue.poll(); |
|
85 |
if (message == null) return; |
|
86 |
else { |
|
87 |
try { |
|
88 |
log.info("Sending mail..."); |
|
89 |
Transport.send(message); |
|
90 |
log.info("...sent"); |
|
91 |
} catch (MessagingException e) { |
|
92 |
log.error("Error sending email", e); |
|
93 |
queue.add(message); |
|
94 |
return; |
|
95 |
} |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
private void sendWfStatusMail(final boolean success, |
|
101 |
final Set<String> to, |
|
102 |
final String wfId, |
|
103 |
final String procId, |
|
104 |
final String wfName, |
|
105 |
final Map<String, String> pendingWfs, |
|
106 |
final Map<String, String> responses, |
|
107 |
final String error) { |
|
108 |
try { |
|
109 |
final Map<String, Object> map = Maps.newHashMap(); |
|
110 |
map.put("wfId", wfId); |
|
111 |
map.put("wfName", wfName); |
|
112 |
map.put("procId", procId); |
|
113 |
if ((pendingWfs != null) && !pendingWfs.isEmpty()) { |
|
114 |
map.put("pendingWfs", pendingWfs); |
|
115 |
} |
|
116 |
if ((responses != null) && !responses.isEmpty()) { |
|
117 |
map.put("responses", responses); |
|
118 |
} |
|
119 |
if ((error != null) && !error.isEmpty()) { |
|
120 |
map.put("error", error); |
|
121 |
} |
|
122 |
|
|
123 |
String subject = success ? "[D-NET WORKFLOW] -- SUCCESS: " : "WF FAILURE: "; |
|
124 |
subject += wfName + " on " + infrastructure; |
|
125 |
final String tmplName = success ? "wf_success.mail.st" : "wf_failed.mail.st"; |
|
126 |
final String template = IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/msro/mail/" + tmplName)); |
|
127 |
|
|
128 |
sendMail(to, subject, template, map); |
|
129 |
} catch (Exception e) { |
|
130 |
log.error("Error generating success-mail", e); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
public void sendSuccessMail(final Set<String> to, |
|
135 |
final String wfId, |
|
136 |
final String procId, |
|
137 |
final String wfName, |
|
138 |
final Map<String, String> pendingWfs, |
|
139 |
final Map<String, String> responses) { |
|
140 |
sendWfStatusMail(true, to, wfId, procId, wfName, pendingWfs, responses, ""); |
|
141 |
} |
|
142 |
|
|
143 |
public void sendFailedMail(final Set<String> to, |
|
144 |
final String wfId, |
|
145 |
final String procId, |
|
146 |
final String wfName, |
|
147 |
final Map<String, String> pendingWfs, |
|
148 |
final Map<String, String> responses, |
|
149 |
final String error) { |
|
150 |
sendWfStatusMail(false, to, wfId, procId, wfName, pendingWfs, responses, error); |
|
151 |
} |
|
152 |
|
|
153 |
private Properties obtainProperties() { |
|
154 |
final Properties props = new Properties(); |
|
155 |
props.put("mail.transport.protocol", "smtp"); |
|
156 |
props.put("mail.smtp.host", smtpHost); |
|
157 |
props.put("mail.smtp.port", smtpPort); |
|
158 |
props.put("mail.smtp.auth", Boolean.toString((smtpUser != null) && !smtpUser.isEmpty())); |
|
159 |
return props; |
|
160 |
} |
|
161 |
|
|
162 |
private Authenticator obtainAuthenticator() { |
|
163 |
if ((smtpUser == null) || smtpUser.isEmpty()) return null; |
|
164 |
|
|
165 |
return new Authenticator() { |
|
166 |
|
|
167 |
private final PasswordAuthentication authentication = new PasswordAuthentication(smtpUser, smtpPassword); |
|
168 |
|
|
169 |
@Override |
|
170 |
protected PasswordAuthentication getPasswordAuthentication() { |
|
171 |
return authentication; |
|
172 |
} |
|
173 |
|
|
174 |
}; |
|
175 |
} |
|
176 |
|
|
177 |
public String getFrom() { |
|
178 |
return from; |
|
179 |
} |
|
180 |
|
|
181 |
@Required |
|
182 |
public void setFrom(final String from) { |
|
183 |
this.from = from; |
|
184 |
} |
|
185 |
|
|
186 |
public String getFromName() { |
|
187 |
return fromName; |
|
188 |
} |
|
189 |
|
|
190 |
@Required |
|
191 |
public void setFromName(final String fromName) { |
|
192 |
this.fromName = fromName; |
|
193 |
} |
|
194 |
|
|
195 |
public String getCc() { |
|
196 |
return cc; |
|
197 |
} |
|
198 |
|
|
199 |
@Required |
|
200 |
public void setCc(final String cc) { |
|
201 |
this.cc = cc; |
|
202 |
} |
|
203 |
|
|
204 |
public String getSmtpHost() { |
|
205 |
return smtpHost; |
|
206 |
} |
|
207 |
|
|
208 |
@Required |
|
209 |
public void setSmtpHost(final String smtpHost) { |
|
210 |
this.smtpHost = smtpHost; |
|
211 |
} |
|
212 |
|
|
213 |
public int getSmtpPort() { |
|
214 |
return smtpPort; |
|
215 |
} |
|
216 |
|
|
217 |
public void setSmtpPort(final int smtpPort) { |
|
218 |
this.smtpPort = smtpPort; |
|
219 |
} |
|
220 |
|
|
221 |
public String getSmtpUser() { |
|
222 |
return smtpUser; |
|
223 |
} |
|
224 |
|
|
225 |
public void setSmtpUser(final String smtpUser) { |
|
226 |
this.smtpUser = smtpUser; |
|
227 |
} |
|
228 |
|
|
229 |
public String getSmtpPassword() { |
|
230 |
return smtpPassword; |
|
231 |
} |
|
232 |
|
|
233 |
public void setSmtpPassword(final String smtpPassword) { |
|
234 |
this.smtpPassword = smtpPassword; |
|
235 |
} |
|
236 |
|
|
237 |
public String getBaseUrl() { |
|
238 |
return baseUrl; |
|
239 |
} |
|
240 |
|
|
241 |
@Required |
|
242 |
public void setBaseUrl(final String baseUrl) { |
|
243 |
this.baseUrl = baseUrl; |
|
244 |
} |
|
245 |
|
|
246 |
public String getInfrastructure() { |
|
247 |
return infrastructure; |
|
248 |
} |
|
249 |
|
|
250 |
@Required |
|
251 |
public void setInfrastructure(final String infrastructure) { |
|
252 |
this.infrastructure = infrastructure; |
|
253 |
} |
|
254 |
|
|
255 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/workflows/metawf/WorkflowStartModeEnum.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.metawf; |
|
2 |
|
|
3 |
public enum WorkflowStartModeEnum { |
|
4 |
auto, manual, disabled |
|
5 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/workflows/metawf/DatasourceMetaWorkflowFactory.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.metawf; |
|
2 |
|
|
3 |
import org.springframework.context.ApplicationContext; |
|
4 |
import org.springframework.context.ApplicationContextAware; |
|
5 |
|
|
6 |
public class DatasourceMetaWorkflowFactory implements ApplicationContextAware { |
|
7 |
|
|
8 |
private transient ApplicationContext applicationContext; |
|
9 |
|
|
10 |
public DatasourceMetaWorkflow newMetaWorkflow(final String beanName) { |
|
11 |
final DatasourceMetaWorkflow prototypeMetaWf = (DatasourceMetaWorkflow) applicationContext.getBean(beanName, DatasourceMetaWorkflow.class); |
|
12 |
|
|
13 |
if (prototypeMetaWf != null) { |
|
14 |
return prototypeMetaWf; |
|
15 |
} else { |
|
16 |
throw new IllegalArgumentException("cannot find bean " + beanName); |
|
17 |
} |
|
18 |
} |
|
19 |
|
|
20 |
@Override |
|
21 |
public void setApplicationContext(final ApplicationContext context) { |
|
22 |
this.applicationContext = context; |
|
23 |
} |
|
24 |
|
|
25 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/workflows/metawf/WorkflowTree.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.metawf; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringWriter; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
|
|
8 |
import javax.annotation.Resource; |
|
9 |
|
|
10 |
import org.apache.commons.lang.StringEscapeUtils; |
|
11 |
import org.springframework.beans.factory.annotation.Required; |
|
12 |
|
|
13 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException; |
|
14 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
15 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
16 |
|
|
17 |
public class WorkflowTree { |
|
18 |
|
|
19 |
private String id; |
|
20 |
|
|
21 |
private String name; |
|
22 |
|
|
23 |
private WorkflowStartModeEnum start = WorkflowStartModeEnum.auto; |
|
24 |
|
|
25 |
private List<WorkflowTree> children; |
|
26 |
|
|
27 |
private org.springframework.core.io.Resource template; |
|
28 |
|
|
29 |
@Resource |
|
30 |
private UniqueServiceLocator serviceLocator; |
|
31 |
|
|
32 |
public void populateMetaWfXml(final StringWriter sw) { |
|
33 |
sw.append("<WORKFLOW id='" + StringEscapeUtils.escapeXml(id) + "' name='" + StringEscapeUtils.escapeXml(name) + "'"); |
|
34 |
|
|
35 |
if (children == null || children.isEmpty()) { |
|
36 |
sw.append(" />"); |
|
37 |
} else { |
|
38 |
sw.append(">"); |
|
39 |
for (WorkflowTree child : children) { |
|
40 |
child.populateMetaWfXml(sw); |
|
41 |
} |
|
42 |
sw.append("</WORKFLOW>"); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
public int registerAllWorkflows(final Map<String, String> params) throws ISRegistryException, IOException { |
|
47 |
int count = 0; |
|
48 |
|
|
49 |
if (this.id == null || this.id.isEmpty()) { |
|
50 |
final String profile = WorkflowProfileCreator.generateProfile(name, "aggregator", start, params, template); |
|
51 |
this.id = serviceLocator.getService(ISRegistryService.class).registerProfile(profile); |
|
52 |
count++; |
|
53 |
} |
|
54 |
|
|
55 |
if (children != null) { |
|
56 |
for (WorkflowTree child : children) { |
|
57 |
count += child.registerAllWorkflows(params); |
|
58 |
} |
|
59 |
} |
|
60 |
return count; |
|
61 |
} |
|
62 |
|
|
63 |
public String getId() { |
|
64 |
return id; |
|
65 |
} |
|
66 |
|
|
67 |
public List<WorkflowTree> getChildren() { |
|
68 |
return children; |
|
69 |
} |
|
70 |
|
|
71 |
public void setChildren(final List<WorkflowTree> children) { |
|
72 |
this.children = children; |
|
73 |
} |
|
74 |
|
|
75 |
public String getName() { |
|
76 |
return name; |
|
77 |
} |
|
78 |
|
|
79 |
@Required |
|
80 |
public void setName(final String name) { |
|
81 |
this.name = name; |
|
82 |
} |
|
83 |
|
|
84 |
public org.springframework.core.io.Resource getTemplate() { |
|
85 |
return template; |
|
86 |
} |
|
87 |
|
|
88 |
@Required |
|
89 |
public void setTemplate(final org.springframework.core.io.Resource template) { |
|
90 |
this.template = template; |
|
91 |
} |
|
92 |
|
|
93 |
public WorkflowStartModeEnum getStart() { |
|
94 |
return start; |
|
95 |
} |
|
96 |
|
|
97 |
public void setStart(final WorkflowStartModeEnum start) { |
|
98 |
this.start = start; |
|
99 |
} |
|
100 |
|
|
101 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/workflows/metawf/WorkflowProfileCreator.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.metawf; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.antlr.stringtemplate.StringTemplate; |
|
7 |
import org.apache.commons.io.IOUtils; |
|
8 |
import org.apache.commons.lang.StringEscapeUtils; |
|
9 |
import org.springframework.core.io.ClassPathResource; |
|
10 |
import org.springframework.core.io.Resource; |
|
11 |
|
|
12 |
import com.google.common.base.Function; |
|
13 |
import com.google.common.collect.Maps; |
|
14 |
|
|
15 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
16 |
|
|
17 |
public class WorkflowProfileCreator { |
|
18 |
|
|
19 |
private static final Resource wfTemplate = new ClassPathResource("/eu/dnetlib/msro/workflows/templates/workflow.xml.st"); |
|
20 |
|
|
21 |
public static String generateProfile(final String name, |
|
22 |
final String type, |
|
23 |
final WorkflowStartModeEnum startMode, |
|
24 |
final Map<String, String> params, |
|
25 |
final Resource confTemplate) |
|
26 |
throws IOException { |
|
27 |
|
|
28 |
final StringTemplate conf = new StringTemplate(IOUtils.toString(confTemplate.getInputStream())); |
|
29 |
conf.setAttribute("params", Maps.transformValues(params, new Function<String, String>() { |
|
30 |
|
|
31 |
@Override |
|
32 |
public String apply(final String s) { |
|
33 |
return StringEscapeUtils.escapeXml(s); |
|
34 |
} |
|
35 |
})); |
|
36 |
|
|
37 |
final StringTemplate profile = new StringTemplate(IOUtils.toString(wfTemplate.getInputStream())); |
|
38 |
profile.setAttribute("name", name); |
|
39 |
profile.setAttribute("type", type); |
|
40 |
profile.setAttribute("priority", WorkflowsConstants.DEFAULT_WF_PRIORITY); |
|
41 |
profile.setAttribute("conf", conf.toString()); |
|
42 |
profile.setAttribute("startMode", startMode); |
|
43 |
|
|
44 |
return profile.toString(); |
|
45 |
} |
|
46 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/workflows/metawf/DatasourceMetaWorkflow.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.metawf; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringWriter; |
|
5 |
import java.util.Map; |
|
6 |
|
|
7 |
import org.springframework.beans.factory.annotation.Required; |
|
8 |
import org.springframework.core.io.Resource; |
|
9 |
|
|
10 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException; |
|
11 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
12 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
13 |
|
|
14 |
public class DatasourceMetaWorkflow { |
|
15 |
|
|
16 |
private WorkflowTree tree; |
|
17 |
|
|
18 |
private Resource destroyWorkflowTemplate; |
|
19 |
|
|
20 |
@javax.annotation.Resource |
|
21 |
private UniqueServiceLocator serviceLocator; |
|
22 |
|
|
23 |
public int registerAllWorkflows(final Map<String, String> params) throws ISRegistryException, IOException { |
|
24 |
return tree.registerAllWorkflows(params); |
|
25 |
} |
|
26 |
|
|
27 |
public String registerDestroyWorkflow(final Map<String, String> params) throws ISRegistryException, IOException { |
|
28 |
final String profile = WorkflowProfileCreator.generateProfile("Repo BYE", "REPO_BYE", WorkflowStartModeEnum.auto, params, destroyWorkflowTemplate); |
|
29 |
return serviceLocator.getService(ISRegistryService.class).registerProfile(profile); |
|
30 |
} |
|
31 |
|
|
32 |
public String asXML() { |
|
33 |
final StringWriter sw = new StringWriter(); |
|
34 |
tree.populateMetaWfXml(sw); |
|
35 |
return sw.toString(); |
|
36 |
} |
|
37 |
|
|
38 |
public WorkflowTree getTree() { |
|
39 |
return tree; |
|
40 |
} |
|
41 |
|
|
42 |
@Required |
|
43 |
public void setTree(final WorkflowTree tree) { |
|
44 |
this.tree = tree; |
|
45 |
} |
|
46 |
|
|
47 |
public Resource getDestroyWorkflowTemplate() { |
|
48 |
return destroyWorkflowTemplate; |
|
49 |
} |
|
50 |
|
|
51 |
@Required |
|
52 |
public void setDestroyWorkflowTemplate(final Resource destroyWorkflowTemplate) { |
|
53 |
this.destroyWorkflowTemplate = destroyWorkflowTemplate; |
|
54 |
} |
|
55 |
|
|
56 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.2.5/src/main/java/eu/dnetlib/msro/workflows/nodes/unpack/UnpackJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.unpack; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.Queue; |
|
6 |
import java.util.concurrent.PriorityBlockingQueue; |
|
7 |
|
|
8 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
9 |
|
|
10 |
import org.apache.commons.logging.Log; |
|
11 |
import org.apache.commons.logging.LogFactory; |
|
12 |
import org.dom4j.Document; |
|
13 |
import org.dom4j.Node; |
|
14 |
import org.dom4j.io.SAXReader; |
|
15 |
import org.springframework.beans.factory.annotation.Required; |
|
16 |
|
|
17 |
import com.googlecode.sarasvati.Arc; |
|
18 |
import com.googlecode.sarasvati.NodeToken; |
|
19 |
|
|
20 |
import eu.dnetlib.enabling.resultset.IterableResultSetFactory; |
|
21 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
22 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
23 |
|
|
24 |
public class UnpackJobNode extends SimpleJobNode { |
|
25 |
|
|
26 |
/** |
|
27 |
* logger. |
|
28 |
*/ |
|
29 |
private static final Log log = LogFactory.getLog(UnpackJobNode.class); |
|
30 |
|
|
31 |
private String inputEprParam; |
|
32 |
private String outputEprParam; |
|
33 |
private String xpath; |
|
34 |
|
|
35 |
private IterableResultSetFactory iterableResultSetFactory; |
|
36 |
private ResultSetClientFactory resultSetClientFactory; |
|
37 |
|
|
38 |
@Override |
|
39 |
protected String execute(final NodeToken token) throws Exception { |
|
40 |
final Iterator<String> client = resultSetClientFactory.getClient(token.getEnv().getAttribute(inputEprParam)).iterator(); |
|
41 |
final Queue<String> queue = new PriorityBlockingQueue<String>(); |
|
42 |
|
|
43 |
while (queue.isEmpty() && client.hasNext()) { |
|
44 |
populateQueue(queue, client.next(), xpath); |
|
45 |
} |
|
46 |
|
|
47 |
final W3CEndpointReference epr = iterableResultSetFactory.createIterableResultSet(new Iterable<String>() { |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-msro-service-3.2.5