Revision 54247
Added by Claudio Atzori over 5 years ago
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/deploy.info | ||
---|---|---|
1 |
{"type_source": "SVN", "goal": "package -U source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-directindex-api/branches/solr75", "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-directindex-api_solr75"} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/java/eu/dnetlib/msro/openaireplus/api/OpenAIRESubmitterUtilsTest.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.api; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
import java.util.Map.Entry; |
|
5 |
|
|
6 |
import org.junit.Test; |
|
7 |
|
|
8 |
import eu.dnetlib.openaire.directindex.api.OpenAIRESubmitterUtils; |
|
9 |
|
|
10 |
/** |
|
11 |
* Created by Alessia Bardi on 26/05/2017. |
|
12 |
* |
|
13 |
* @author Alessia Bardi |
|
14 |
*/ |
|
15 |
public class OpenAIRESubmitterUtilsTest { |
|
16 |
|
|
17 |
private OpenAIRESubmitterUtils utils = new OpenAIRESubmitterUtils(); |
|
18 |
|
|
19 |
final String fullProject = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"; |
|
20 |
final String minimalProject = "info:eu-repo/grantAgreement/EC/FP7/244909///WorkAble"; |
|
21 |
final String onlyId = "info:eu-repo/grantAgreement/EC/FP7/244909/"; |
|
22 |
final String onlyTitle = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work"; |
|
23 |
|
|
24 |
@Test |
|
25 |
public void testCalculateProjectInfoFull() { |
|
26 |
final Map<String, String> project = utils.calculateProjectInfo(fullProject); |
|
27 |
print(project); |
|
28 |
} |
|
29 |
|
|
30 |
@Test |
|
31 |
public void testCalculateProjectInfoOnlyId() { |
|
32 |
final Map<String, String> project = utils.calculateProjectInfo(onlyId); |
|
33 |
print(project); |
|
34 |
} |
|
35 |
|
|
36 |
@Test |
|
37 |
public void testCalculateProjectInfoMinimalAcro() { |
|
38 |
final Map<String, String> project = utils.calculateProjectInfo(minimalProject); |
|
39 |
print(project); |
|
40 |
} |
|
41 |
|
|
42 |
@Test |
|
43 |
public void testCalculateProjectInfoOnlyTitle() { |
|
44 |
final Map<String, String> project = utils.calculateProjectInfo(onlyTitle); |
|
45 |
print(project); |
|
46 |
} |
|
47 |
|
|
48 |
private void print(final Map<String, String> map) { |
|
49 |
for (final Entry e : map.entrySet()) { |
|
50 |
System.out.println(e.getKey() + " = " + e.getValue()); |
|
51 |
} |
|
52 |
} |
|
53 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/java/eu/dnetlib/msro/openaireplus/api/objects/ResultEntryTest.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.api.objects; |
|
2 |
|
|
3 |
import java.io.InputStreamReader; |
|
4 |
import java.io.StringReader; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Arrays; |
|
7 |
import java.util.Properties; |
|
8 |
|
|
9 |
import com.google.gson.Gson; |
|
10 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
11 |
import eu.dnetlib.openaire.directindex.api.DirecIndexApiException; |
|
12 |
import eu.dnetlib.openaire.directindex.objects.PidEntry; |
|
13 |
import eu.dnetlib.openaire.directindex.objects.ResultEntry; |
|
14 |
import org.apache.commons.lang3.StringEscapeUtils; |
|
15 |
import org.apache.velocity.app.VelocityEngine; |
|
16 |
import org.dom4j.Document; |
|
17 |
import org.dom4j.io.OutputFormat; |
|
18 |
import org.dom4j.io.SAXReader; |
|
19 |
import org.dom4j.io.XMLWriter; |
|
20 |
import org.junit.Before; |
|
21 |
import org.junit.Test; |
|
22 |
import org.junit.runner.RunWith; |
|
23 |
import org.mockito.Mock; |
|
24 |
import org.mockito.runners.MockitoJUnitRunner; |
|
25 |
|
|
26 |
import static org.mockito.Matchers.anyString; |
|
27 |
import static org.mockito.Mockito.when; |
|
28 |
|
|
29 |
/** |
|
30 |
* Created by michele on 14/12/15. |
|
31 |
*/ |
|
32 |
@RunWith(MockitoJUnitRunner.class) |
|
33 |
public class ResultEntryTest { |
|
34 |
|
|
35 |
private VelocityEngine ve; |
|
36 |
|
|
37 |
@Mock |
|
38 |
private ISLookUpService lookUpService; |
|
39 |
|
|
40 |
@Before |
|
41 |
public void setUp() throws Exception { |
|
42 |
|
|
43 |
final Properties props = new Properties(); |
|
44 |
props.setProperty("resource.loader", "class"); |
|
45 |
props.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); |
|
46 |
props.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.Log4JLogChute"); |
|
47 |
ve = new VelocityEngine(); |
|
48 |
ve.init(props); |
|
49 |
|
|
50 |
when(lookUpService.quickSearchProfile(anyString())).thenAnswer(invocation -> { |
|
51 |
final String query = invocation.getArguments()[0].toString(); |
|
52 |
if (query.contains("dnet:result_typologies")) { |
|
53 |
return Arrays.asList("publication @@@ publication", "dataset @@@ dataset", "software @@@ software", "other @@@ other"); |
|
54 |
} else if (query.contains("dnet:access_modes")) { |
|
55 |
return Arrays.asList("OPEN @@@ Open Access"); |
|
56 |
} else if (query.contains("dnet:publication_resource")) { |
|
57 |
return Arrays.asList("0001 @@@ Journal Article"); |
|
58 |
} else if (query.contains("dnet:pid_types")) { |
|
59 |
return Arrays.asList("oai @@@ Open Archive Initiative", "doi @@@ Digital object identifier"); |
|
60 |
} else if (query.contains("dnet:languages")) { |
|
61 |
return Arrays.asList("ita @@@ Italian"); |
|
62 |
} else if (query.contains("ContextDSResourceType")) { |
|
63 |
return Arrays.asList( |
|
64 |
"egi::classification::natsc::math::stats @@@ Statistics and Probability", |
|
65 |
"egi::classification::natsc::math::pure @@@ Pure Mathematics", |
|
66 |
"egi::classification::natsc::math @@@ Mathematics", |
|
67 |
"egi::classification::natsc @@@ Natural Sciences", |
|
68 |
"egi::classification @@@ EGI classification scheme", |
|
69 |
"egi @@@ EGI"); |
|
70 |
} else { |
|
71 |
return new ArrayList<String>(); |
|
72 |
} |
|
73 |
}); |
|
74 |
|
|
75 |
when(lookUpService.getResourceProfileByQuery(anyString())).thenAnswer(invocation -> "REPO NAME @@@ repo________"); |
|
76 |
} |
|
77 |
|
|
78 |
@Test |
|
79 |
public void testAsIndexRecord() throws Exception { |
|
80 |
final ResultEntry pub = new ResultEntry(); |
|
81 |
pub.setOriginalId("ORIG_ID_1234"); |
|
82 |
pub.setTitle("TEST TITLE <test>"); |
|
83 |
pub.getAuthors().add("Michele Artini"); |
|
84 |
pub.getAuthors().add("Claudio Atzori"); |
|
85 |
pub.getAuthors().add("Alessia Bardi"); |
|
86 |
pub.setPublisher("Test publisher"); |
|
87 |
pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION "); |
|
88 |
pub.setLanguage("ita"); |
|
89 |
pub.setLicenseCode("OPEN"); |
|
90 |
pub.setResourceType("0001"); |
|
91 |
pub.setUrl("http://test.it/a=1&b=2"); |
|
92 |
pub.getPids().add(new PidEntry("doi", "10.000/xyz-123")); |
|
93 |
pub.getPids().add(new PidEntry("oai", "oai:1234")); |
|
94 |
pub.setCollectedFromId("test________::zenodo"); |
|
95 |
pub.setHostedById("test________::UNKNOWN"); |
|
96 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus"); |
|
97 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"); |
|
98 |
pub.getContexts().add("egi::classification::natsc::math::pure"); |
|
99 |
pub.getContexts().add("egi::classification::natsc::math::stats"); |
|
100 |
final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd"); |
|
101 |
|
|
102 |
final Document doc = new SAXReader().read(new StringReader(xml)); |
|
103 |
|
|
104 |
final OutputFormat format = OutputFormat.createPrettyPrint(); |
|
105 |
|
|
106 |
final XMLWriter writer = new XMLWriter(System.out, format); |
|
107 |
|
|
108 |
writer.write(doc); |
|
109 |
|
|
110 |
/* writer.close(); */ |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
@Test |
|
115 |
public void testAsIndexRecordAccessRight() throws Exception { |
|
116 |
final ResultEntry pub = new ResultEntry(); |
|
117 |
pub.setOriginalId("ORIG_ID_1234"); |
|
118 |
pub.setTitle("TEST TITLE <test>"); |
|
119 |
pub.getAuthors().add("Michele Artini"); |
|
120 |
pub.getAuthors().add("Claudio Atzori"); |
|
121 |
pub.getAuthors().add("Alessia Bardi"); |
|
122 |
pub.setPublisher("Test publisher"); |
|
123 |
pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION "); |
|
124 |
pub.setLanguage("ita"); |
|
125 |
pub.setLicenseCode("CLOSED"); |
|
126 |
pub.setAccessRightCode("OPEN"); |
|
127 |
pub.setResourceType("0001"); |
|
128 |
pub.setUrl("http://test.it/a=1&b=2"); |
|
129 |
pub.getPids().add(new PidEntry("doi", "10.000/xyz-123")); |
|
130 |
pub.getPids().add(new PidEntry("oai", "oai:1234")); |
|
131 |
pub.setCollectedFromId("test________::zenodo"); |
|
132 |
pub.setHostedById("test________::UNKNOWN"); |
|
133 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus"); |
|
134 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"); |
|
135 |
pub.getContexts().add("egi::classification::natsc::math::pure"); |
|
136 |
pub.getContexts().add("egi::classification::natsc::math::stats"); |
|
137 |
final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd"); |
|
138 |
|
|
139 |
final Document doc = new SAXReader().read(new StringReader(xml)); |
|
140 |
|
|
141 |
final OutputFormat format = OutputFormat.createPrettyPrint(); |
|
142 |
|
|
143 |
final XMLWriter writer = new XMLWriter(System.out, format); |
|
144 |
|
|
145 |
writer.write(doc); |
|
146 |
|
|
147 |
/* writer.close(); */ |
|
148 |
|
|
149 |
} |
|
150 |
|
|
151 |
|
|
152 |
@Test |
|
153 |
public void testAsIndexRecord_json() throws Exception { |
|
154 |
testAsIndexRecord_json("test_record.json"); |
|
155 |
|
|
156 |
} |
|
157 |
|
|
158 |
@Test |
|
159 |
public void testAsIndexRecord_json_with_greek_chars() throws Exception { |
|
160 |
|
|
161 |
testAsIndexRecord_json("test_record_with_greek_chars.json"); |
|
162 |
|
|
163 |
} |
|
164 |
|
|
165 |
@Test |
|
166 |
public void testAsIndexRecord_openaireId() throws Exception { |
|
167 |
|
|
168 |
testAsIndexRecord_json("test_record_openaireId.json"); |
|
169 |
|
|
170 |
} |
|
171 |
|
|
172 |
@Test(expected = DirecIndexApiException.class) |
|
173 |
public void testAsIndexRecord_wrongOpenaireId() throws Exception { |
|
174 |
|
|
175 |
testAsIndexRecord_json("test_record_wrong_openaireId.json"); |
|
176 |
|
|
177 |
} |
|
178 |
|
|
179 |
@Test |
|
180 |
public void testAsIndexRecord_json_zenodo() throws Exception { |
|
181 |
|
|
182 |
testAsIndexRecord_json("test_zenodo.json"); |
|
183 |
|
|
184 |
} |
|
185 |
|
|
186 |
@Test |
|
187 |
public void testAsIndexRecord_json_zenodoWithAmpersand() throws Exception { |
|
188 |
|
|
189 |
testAsIndexRecord_json("test_zenodoAmpersandEverywhere.json"); |
|
190 |
|
|
191 |
} |
|
192 |
|
|
193 |
@Test |
|
194 |
public void testAsIndexRecord_json_software() throws Exception { |
|
195 |
|
|
196 |
testAsIndexRecord_json("test_record_software.json"); |
|
197 |
|
|
198 |
} |
|
199 |
|
|
200 |
@Test |
|
201 |
public void testAsIndexRecord_json_orp() throws Exception { |
|
202 |
|
|
203 |
testAsIndexRecord_json("test_record_orp.json"); |
|
204 |
|
|
205 |
} |
|
206 |
|
|
207 |
private void testAsIndexRecord_json(final String filename) throws Exception { |
|
208 |
final ResultEntry pub = |
|
209 |
new Gson().fromJson(new InputStreamReader(getClass().getResourceAsStream(filename)), ResultEntry.class); |
|
210 |
|
|
211 |
final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd"); |
|
212 |
System.out.println(xml); |
|
213 |
|
|
214 |
final Document doc = new SAXReader().read(new StringReader(xml)); |
|
215 |
|
|
216 |
final OutputFormat format = OutputFormat.createPrettyPrint(); |
|
217 |
|
|
218 |
final XMLWriter writer = new XMLWriter(System.out, format); |
|
219 |
|
|
220 |
writer.write(doc); |
|
221 |
|
|
222 |
/* writer.close(); */ |
|
223 |
} |
|
224 |
|
|
225 |
@Test |
|
226 |
public void testEscapeUnicode() { |
|
227 |
final String unicodeTxt = |
|
228 |
"i.e. closed curves of the form $t\ud835\udfc4 [0,2\u03c0] \u21a6 (\\cos t)u + (\\sin t)v$ for suitable orthogonal vectors $u$"; |
|
229 |
System.out.println(StringEscapeUtils.escapeXml11(unicodeTxt)); |
|
230 |
} |
|
231 |
|
|
232 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_software.json | ||
---|---|---|
1 |
{ |
|
2 |
"openaireId":"od_______278::d5b39693ac6c2197e8cf48008a982951", |
|
3 |
"originalId": "oai:rudar.ruc.dk:1800/24691", |
|
4 |
"type": "software", |
|
5 |
"title": "Software test", |
|
6 |
"authors": [ |
|
7 |
"Sloan, Patrick Alexander Raaby", |
|
8 |
"Strange, Gustav Valdemar" |
|
9 |
], |
|
10 |
"publisher": "", |
|
11 |
"description": "This is for testing software", |
|
12 |
"language": "eng", |
|
13 |
"pids": [], |
|
14 |
"licenseCode": "OPEN SOURCE", |
|
15 |
"resourceType": "0000", |
|
16 |
"url": "http://rudar.ruc.dk/handle/1800/24691", |
|
17 |
"collectedFromId": "opendoar____::278", |
|
18 |
"hostedById": "opendoar____::278", |
|
19 |
"linksToProjects": [], |
|
20 |
"contexts": [] |
|
21 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_wrong_openaireId.json | ||
---|---|---|
1 |
{ |
|
2 |
"openaireId":"dedup_wf_001::ab42e811", |
|
3 |
"originalId": "ORIG_ID_TEST", |
|
4 |
"type": "publication", |
|
5 |
"title": "TEST TITLE", |
|
6 |
"authors": [ |
|
7 |
"Michele Artini", |
|
8 |
"Claudio Atzori", |
|
9 |
"Alessia Bardi" |
|
10 |
], |
|
11 |
"publisher": "Test publisher", |
|
12 |
"description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION", |
|
13 |
"language": "ita", |
|
14 |
"pids": [ |
|
15 |
{ |
|
16 |
"type": "doi", |
|
17 |
"value": "10.000/xyz-123" |
|
18 |
}, |
|
19 |
{ |
|
20 |
"type": "oai", |
|
21 |
"value": "oai:1234" |
|
22 |
} |
|
23 |
], |
|
24 |
"licenseCode": "EMBARGO", |
|
25 |
"embargoEndDate": "2018-02-02", |
|
26 |
"resourceType": "0001", |
|
27 |
"url": "http://test.it/xyz", |
|
28 |
"collectedFromId": "opendoar____::2659", |
|
29 |
"hostedById": "opendoar____::2659", |
|
30 |
"linksToProjects": [ |
|
31 |
"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus", |
|
32 |
"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble" |
|
33 |
], |
|
34 |
"contexts": [ |
|
35 |
"egi::classification::natsc::math::pure", |
|
36 |
"egi::classification::natsc::math::stats" |
|
37 |
] |
|
38 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_openaireId.json | ||
---|---|---|
1 |
{ |
|
2 |
"openaireId":"dedup_wf_001::ab42e8116f4ae3c4021fb7c643a8167a", |
|
3 |
"originalId": "ORIG_ID_TEST", |
|
4 |
"type": "publication", |
|
5 |
"title": "TEST TITLE", |
|
6 |
"authors": [ |
|
7 |
"Michele Artini", |
|
8 |
"Claudio Atzori", |
|
9 |
"Alessia Bardi" |
|
10 |
], |
|
11 |
"publisher": "Test publisher", |
|
12 |
"description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION", |
|
13 |
"language": "ita", |
|
14 |
"pids": [ |
|
15 |
{ |
|
16 |
"type": "doi", |
|
17 |
"value": "10.000/xyz-123" |
|
18 |
}, |
|
19 |
{ |
|
20 |
"type": "oai", |
|
21 |
"value": "oai:1234" |
|
22 |
} |
|
23 |
], |
|
24 |
"accessRightCode": "EMBARGO", |
|
25 |
"licenseCode": "OPEN", |
|
26 |
"embargoEndDate": "2018-02-02", |
|
27 |
"resourceType": "0001", |
|
28 |
"url": "http://test.it/xyz", |
|
29 |
"collectedFromId": "opendoar____::2659", |
|
30 |
"hostedById": "opendoar____::2659", |
|
31 |
"linksToProjects": [ |
|
32 |
"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus", |
|
33 |
"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble" |
|
34 |
], |
|
35 |
"contexts": [ |
|
36 |
"egi::classification::natsc::math::pure", |
|
37 |
"egi::classification::natsc::math::stats" |
|
38 |
] |
|
39 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record.json | ||
---|---|---|
1 |
{ |
|
2 |
"originalId": "ORIG_ID_12345", |
|
3 |
"title": "TEST TITLE", |
|
4 |
"authors": [ |
|
5 |
"Michele Artini", |
|
6 |
"Claudio Atzori", |
|
7 |
"Alessia Bardi" |
|
8 |
], |
|
9 |
"publisher": "Test publisher", |
|
10 |
"description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION", |
|
11 |
"language": "ita", |
|
12 |
"pids": [ |
|
13 |
{ |
|
14 |
"type": "doi", |
|
15 |
"value": "10.000/xyz-123" |
|
16 |
}, |
|
17 |
{ |
|
18 |
"type": "oai", |
|
19 |
"value": "oai:1234" |
|
20 |
} |
|
21 |
], |
|
22 |
"accessRightCode": "OPEN", |
|
23 |
"resourceType": "0001", |
|
24 |
"url": "http://test.it/xyz", |
|
25 |
"collectedFromId": "opendoar____::2659", |
|
26 |
"hostedById": "opendoar____::2367", |
|
27 |
"linksToProjects": [ |
|
28 |
"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus", |
|
29 |
"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble" |
|
30 |
], |
|
31 |
"contexts": [ |
|
32 |
"egi::classification::natsc::math::pure", |
|
33 |
"egi::classification::natsc::math::stats" |
|
34 |
] |
|
35 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_orp.json | ||
---|---|---|
1 |
{ |
|
2 |
"openaireId":"od_______278::d5b39693ac6c2197e8cf48008a982951", |
|
3 |
"originalId": "oai:rudar.ruc.dk:1800/24691", |
|
4 |
"type": "other", |
|
5 |
"title": "Other test record", |
|
6 |
"authors": [ |
|
7 |
"Sloan, Patrick Alexander Raaby", |
|
8 |
"Strange, Gustav Valdemar" |
|
9 |
], |
|
10 |
"publisher": "", |
|
11 |
"description": "This is for testing software", |
|
12 |
"language": "eng", |
|
13 |
"pids": [], |
|
14 |
"licenseCode": "OPEN SOURCE", |
|
15 |
"resourceType": "0000", |
|
16 |
"url": "http://rudar.ruc.dk/handle/1800/24691", |
|
17 |
"collectedFromId": "opendoar____::278", |
|
18 |
"hostedById": "opendoar____::278", |
|
19 |
"linksToProjects": [], |
|
20 |
"contexts": [] |
|
21 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_zenodo.json | ||
---|---|---|
1 |
{ |
|
2 |
"authors":[ |
|
3 |
"Alouges, Fran\u00e7ois", |
|
4 |
"Di Fratta, Giovanni" |
|
5 |
], |
|
6 |
"collectedFromId":"opendoar____::2659", |
|
7 |
"description":"The paper is about the parking 3-sphere swimmer ($\\text{sPr}_3$). This is a low-Reynolds number model swimmer composed of three balls of equal radii. The three balls can move along three horizontal axes (supported in the same plane) that mutually meet at the center of $\\text{sPr}_3$ with angles of $120^{\u2218}$ . The governing dynamical system is introduced and the implications of its geometric symmetries revealed. It is then shown that, in the first order range of small strokes, optimal periodic strokes are ellipses embedded in 3d space, i.e. closed curves of the form $t\ud835\udfc4 [0,2\u03c0] \u21a6 (\\cos t)u + (\\sin t)v$ for suitable orthogonal vectors $u$ and $v$ of $\u211d^3$. A simple analytic expression for the vectors $u$ and $v$ is derived. The results of the paper are used in a second article where the real physical dynamics of $\\text{sPr}_3$ is analyzed in the asymptotic range of very long arms. ; Comment: 17 pages, 4 figures", |
|
8 |
"hostedById":"opendoar____::2659", |
|
9 |
"licenseCode":"OPEN", |
|
10 |
"originalId":"oai:zenodo.org:996201", |
|
11 |
"pids":[ |
|
12 |
{ |
|
13 |
"type":"oai", |
|
14 |
"value":"oai:zenodo.org:996201" |
|
15 |
}, |
|
16 |
{ |
|
17 |
"type":"doi", |
|
18 |
"value":"10.5281/zenodo.996201" |
|
19 |
} |
|
20 |
], |
|
21 |
"publisher":"Zenodo", |
|
22 |
"resourceType":"0020", |
|
23 |
"title":"Parking 3-sphere swimmer. I. Energy minimizing strokes", |
|
24 |
"type":"publication", |
|
25 |
"url":"https://zenodo.org/record/996201" |
|
26 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_zenodoAmpersandEverywhere.json | ||
---|---|---|
1 |
{ |
|
2 |
"authors": [ |
|
3 |
"Conradt, Tobias", |
|
4 |
"& members of the ISIMIP project (original data provision), cf. Hempel et al. 2013, https://doi.org/10.5194/esd-4-219-2013" |
|
5 |
], |
|
6 |
"collectedFromId": "re3data_____::r3d100010468", |
|
7 |
"description": "<p>ISIMIP-2a climate data cutout provided for Sardinia in the framework of SIM4NEXUS & X<\/p>", |
|
8 |
"hostedById": "re3data_____::r3d100010468", |
|
9 |
"licenseCode": "OPEN", |
|
10 |
"linksToProjects": ["info:eu-repo/grantAgreement/EC/H2020/689150//Sustainable Integrated Management FOR the NEXUS of water-land-food-energy-climate for a resource-efficient Europe & beyond/SIM4NEXUS"], |
|
11 |
"originalId": "10.5281/zenodo.1460665", |
|
12 |
"pids": [ |
|
13 |
{ |
|
14 |
"type": "oai", |
|
15 |
"value": "oai:zenodo.org:1460665" |
|
16 |
}, |
|
17 |
{ |
|
18 |
"type": "doi", |
|
19 |
"value": "10.5281/zenodo.1460665" |
|
20 |
} |
|
21 |
], |
|
22 |
"publisher": "Zenodo & Zenodo", |
|
23 |
"resourceType": "0021", |
|
24 |
"title": "sardinia_tasmax_MIROC-ESM-CHEM_rcp4p5_2006-2099_daily.nc4 & the title has && in it", |
|
25 |
"type": "dataset", |
|
26 |
"url": "https://zenodo.org/record/1460665" |
|
27 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_ariadne.json | ||
---|---|---|
1 |
{ |
|
2 |
"openaireId":"od_______278::d5b39693ac6c2197e8cf48008a982950", |
|
3 |
"originalId": "oai:rudar.ruc.dk:1800/24690", |
|
4 |
"type": "publication", |
|
5 |
"title": "Autofiktion", |
|
6 |
"authors": [ |
|
7 |
"Sloan, Patrick Alexander Raaby", |
|
8 |
"Strange, Gustav Valdemar", |
|
9 |
"Freund-Jensen, Sofie", |
|
10 |
"Canvin, Emilie Meistrup", |
|
11 |
"Faaborg, Ida Selvejer", |
|
12 |
"Kruse, Mikkel" |
|
13 |
], |
|
14 |
"publisher": "", |
|
15 |
"description": "The following paper is a project on the autofictional book Færdig med Eddy Bellegueule by Édouard Louis (2015). The main focus is to ascertain how the novel is an expression of the author’s effort to connect social life and literature, and what part autofiction as a genre plays in this process. A textual analysis will describe the narrator’s position, and the aesthetic grip of the novel. Furthermore, we will analyze the central themes in Louis’ novel with theories by sociologist Pierre Bourdieu, gender theorist Judith Butler and postcolonial theorist Gayatri Spivak. This includes symbolic violence, gender roles, language and suppression. With use of classic literary theory and the more recent and specific theory on autofiction, the paper concludes, that Færdig med Eddy Bellegueule is based on non-fictional events, but presents these events through a fictionalization that raise the story into a literary work of art. The genre autofiction encircles a current tendency to blend non-fictional events and characters into literature, and Færdig med Eddy Bellegueule writes itself perfectly into this twilight zone between fact and fiction.", |
|
16 |
"language": "eng", |
|
17 |
"pids": [], |
|
18 |
"licenseCode": "OPEN", |
|
19 |
"resourceType": "0006", |
|
20 |
"url": "http://rudar.ruc.dk/handle/1800/24690", |
|
21 |
"collectedFromId": "opendoar____::278", |
|
22 |
"hostedById": "opendoar____::278", |
|
23 |
"linksToProjects": [], |
|
24 |
"contexts": [] |
|
25 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/submit_test_record.sh | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
|
|
3 |
curl -H "Content-Type: application/json" --data @test_record.json "http://localhost:8280/app/mvc/api/publications/feedObject" |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_complete.json | ||
---|---|---|
1 |
{ |
|
2 |
"originalId": "ORIG_ID_TEST", |
|
3 |
"type": "publication", |
|
4 |
"title": "TEST TITLE", |
|
5 |
"authors": [ |
|
6 |
"Michele Artini", |
|
7 |
"Claudio Atzori", |
|
8 |
"Alessia Bardi" |
|
9 |
], |
|
10 |
"publisher": "Test publisher", |
|
11 |
"description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION", |
|
12 |
"language": "ita", |
|
13 |
"pids": [ |
|
14 |
{ |
|
15 |
"type": "doi", |
|
16 |
"value": "10.000/xyz-123" |
|
17 |
}, |
|
18 |
{ |
|
19 |
"type": "oai", |
|
20 |
"value": "oai:1234" |
|
21 |
} |
|
22 |
], |
|
23 |
"accessRightCode": "EMBARGO", |
|
24 |
"embargoEndDate": "2018-02-02", |
|
25 |
"resourceType": "0001", |
|
26 |
"url": "http://test.it/xyz", |
|
27 |
"collectedFromId": "opendoar____::2659", |
|
28 |
"hostedById": "opendoar____::2659", |
|
29 |
"linksToProjects": [ |
|
30 |
"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus", |
|
31 |
"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble" |
|
32 |
], |
|
33 |
"contexts": [ |
|
34 |
"egi::classification::natsc::math::pure", |
|
35 |
"egi::classification::natsc::math::stats" |
|
36 |
] |
|
37 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_with_greek_chars.json | ||
---|---|---|
1 |
{ |
|
2 |
"originalId": "ORIG_ID_12345", |
|
3 |
"title": "TEST TITLE WITH Greek Characters", |
|
4 |
"authors": [ |
|
5 |
"αβγδεζηθικλμ νξοπρσςτυφχψω", |
|
6 |
"ΑΒΓΔΕΖΗΘΙΚΛ ΜΝΞΟΠΡΣΤΥΦΧΨΩ" |
|
7 |
], |
|
8 |
"publisher": "âââââââ", |
|
9 |
"description": "Αν περιμένατε να βρίσκεται εδώ μια σελίδα και δεν υπάρχει, η σελίδα μπορεί να μην εμφανίζεται λόγω καθυστέρησης στην ανανέωση της βάσης δεδομένων, ή μπορεί να έχει διαγραφεί. (Δείτε την γρήγορη διαγραφή σελίδων για πιθανούς λόγους). Μπορείτε να δοκιμάστε την λειτουργία εκκαθάρισης, και να ελέγξετε το αρχείο διαγραφών.", |
|
10 |
"language": "ell", |
|
11 |
"pids": [ |
|
12 |
{ |
|
13 |
"type": "doi", |
|
14 |
"value": "10.000/xyz-123-gr" |
|
15 |
} |
|
16 |
], |
|
17 |
"licenseCode": "EMBARGO", |
|
18 |
"embargoEndDate": "2018-02-02", |
|
19 |
"resourceType": "0001", |
|
20 |
"url": "http://test.it/xyz", |
|
21 |
"collectedFromId": "opendoar____::2659", |
|
22 |
"hostedById": "opendoar____::2367", |
|
23 |
"linksToProjects": [ |
|
24 |
"info:eu-repo/grantAgreement/EC/FP7/123456/EU//Test" |
|
25 |
], |
|
26 |
"contexts": [ |
|
27 |
"egi::classification::natsc::math::stats" |
|
28 |
] |
|
29 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/test/resources/log4j.properties | ||
---|---|---|
1 |
### Root Level ### |
|
2 |
log4j.rootLogger=WARN, CONSOLE |
|
3 |
### Configuration for the CONSOLE appender ### |
|
4 |
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender |
|
5 |
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout |
|
6 |
log4j.appender.CONSOLE.layout.ConversionPattern=[%-5p] %d %c - %m%n |
|
7 |
org.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger |
|
8 |
### Application Level ### |
|
9 |
log4j.logger.eu.dnetlib=INFO |
|
10 |
log4j.logger.eu.dnetlib.msro.openaireplus.workflows.nodes.contexts=DEBUG |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/main/java/eu/dnetlib/openaire/directindex/utils/OafToIndexRecordFactory.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.utils; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
import java.io.StringWriter; |
|
6 |
import javax.annotation.Resource; |
|
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.ISLookUpDocumentNotFoundException; |
|
14 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
15 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
16 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
17 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
18 |
import org.apache.commons.io.IOUtils; |
|
19 |
import org.springframework.beans.factory.annotation.Required; |
|
20 |
import org.springframework.core.io.ClassPathResource; |
|
21 |
|
|
22 |
/** |
|
23 |
* Created by michele on 15/12/15. |
|
24 |
*/ |
|
25 |
public class OafToIndexRecordFactory { |
|
26 |
|
|
27 |
private ClassPathResource layoutToRecord; |
|
28 |
|
|
29 |
@Resource |
|
30 |
private UniqueServiceLocator serviceLocator; |
|
31 |
|
|
32 |
public ApplyXslt newTransformer(final String format) throws ISLookUpException, IOException, TransformerException { |
|
33 |
final TransformerFactory factory = TransformerFactory.newInstance(); |
|
34 |
final Transformer layoutTransformer = factory.newTransformer(readLayoutToRecord()); |
|
35 |
|
|
36 |
final StreamResult layoutToXsltXslt = new StreamResult(new StringWriter()); |
|
37 |
|
|
38 |
layoutTransformer.setParameter("format", format); |
|
39 |
layoutTransformer.transform(new StreamSource(new StringReader(getLayoutSource(format))), layoutToXsltXslt); |
|
40 |
|
|
41 |
return new ApplyXslt(layoutToXsltXslt.getWriter().toString()); |
|
42 |
} |
|
43 |
|
|
44 |
private StreamSource readLayoutToRecord() throws IOException { |
|
45 |
return new StreamSource(new StringReader(IOUtils.toString(layoutToRecord.getInputStream()))); |
|
46 |
} |
|
47 |
|
|
48 |
private String getLayoutSource(final String format) throws ISLookUpDocumentNotFoundException, ISLookUpException { |
|
49 |
return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery( |
|
50 |
"collection('/db/DRIVER/MDFormatDSResources/MDFormatDSResourceType')[.//NAME='" + format + "']//LAYOUT[@name='index']"); |
|
51 |
} |
|
52 |
|
|
53 |
public ClassPathResource getLayoutToRecord() { |
|
54 |
return layoutToRecord; |
|
55 |
} |
|
56 |
|
|
57 |
@Required |
|
58 |
public void setLayoutToRecord(final ClassPathResource layoutToRecord) { |
|
59 |
this.layoutToRecord = layoutToRecord; |
|
60 |
} |
|
61 |
|
|
62 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/main/java/eu/dnetlib/openaire/directindex/api/OpenaireResultSubmitter.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import com.google.gson.Gson; |
|
4 |
import eu.dnetlib.common.rmi.DNetRestDocumentation; |
|
5 |
import eu.dnetlib.data.index.CloudIndexClient; |
|
6 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
7 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
8 |
import eu.dnetlib.openaire.directindex.objects.ResultEntry; |
|
9 |
import eu.dnetlib.openaire.directindex.utils.OafToIndexRecordFactory; |
|
10 |
import org.apache.commons.lang.exception.ExceptionUtils; |
|
11 |
import org.apache.commons.logging.Log; |
|
12 |
import org.apache.commons.logging.LogFactory; |
|
13 |
import org.apache.velocity.app.VelocityEngine; |
|
14 |
import org.springframework.beans.factory.annotation.Value; |
|
15 |
import org.springframework.http.HttpStatus; |
|
16 |
import org.springframework.stereotype.Controller; |
|
17 |
import org.springframework.web.bind.annotation.*; |
|
18 |
|
|
19 |
import javax.annotation.Resource; |
|
20 |
import java.util.Map; |
|
21 |
|
|
22 |
/** |
|
23 |
* Created by michele on 11/11/15. |
|
24 |
*/ |
|
25 |
@Controller |
|
26 |
@DNetRestDocumentation |
|
27 |
public class OpenaireResultSubmitter { |
|
28 |
|
|
29 |
private static final Log log = LogFactory.getLog(OpenaireResultSubmitter.class); |
|
30 |
|
|
31 |
@Value(value = "oaf.schema.location") |
|
32 |
private String oafSchemaLocation; |
|
33 |
|
|
34 |
@Resource |
|
35 |
private UniqueServiceLocator serviceLocator; |
|
36 |
|
|
37 |
@Resource |
|
38 |
private OafToIndexRecordFactory oafToIndexRecordFactory; |
|
39 |
|
|
40 |
@Resource |
|
41 |
private RecentResultsQueue recentResultsQueue; |
|
42 |
|
|
43 |
@Resource(name = "openaireplusApisVelocityEngine") |
|
44 |
private VelocityEngine velocityEngine; |
|
45 |
|
|
46 |
@Resource |
|
47 |
private IndexClientMap clientMap; |
|
48 |
|
|
49 |
@Resource |
|
50 |
private ResultSubmitterService submitterService; |
|
51 |
|
|
52 |
@RequestMapping(value = { "/api/admin/autocommit/active" }, method = RequestMethod.GET) |
|
53 |
public @ResponseBody Boolean getAutocommit() throws DirecIndexApiException { |
|
54 |
return submitterService.isAutocommitactive(); |
|
55 |
} |
|
56 |
|
|
57 |
@RequestMapping(value = { "/api/admin/autocommit/active" }, method = RequestMethod.POST) |
|
58 |
public @ResponseBody Boolean setAutocommit(@RequestParam(value = "active", required = true) final Boolean active) throws DirecIndexApiException { |
|
59 |
submitterService.setAutocommitactive(active); |
|
60 |
log.info(String.format("automatic commit, active '%s', frequency '%s'", submitterService.isAutocommitactive(), submitterService.getCommitfrquency())); |
|
61 |
return submitterService.isAutocommitactive(); |
|
62 |
} |
|
63 |
|
|
64 |
@Deprecated |
|
65 |
@RequestMapping(value = { "/api/publications/feedJson", "/api/results/feedJson" }, method = RequestMethod.POST) |
|
66 |
public @ResponseBody String feedObjectJson(@RequestParam(value = "json", required = true) final String json, |
|
67 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws DirecIndexApiException { |
|
68 |
final ResultEntry pub = new Gson().fromJson(json, ResultEntry.class); |
|
69 |
return feedObject(pub, commit); |
|
70 |
} |
|
71 |
|
|
72 |
@RequestMapping(value = { "/api/results/feedObject" }, method = RequestMethod.POST) |
|
73 |
public @ResponseBody String feedResult(@RequestBody final ResultEntry pub, |
|
74 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) |
|
75 |
throws DirecIndexApiException { |
|
76 |
return feed(pub, commit); |
|
77 |
} |
|
78 |
|
|
79 |
@Deprecated |
|
80 |
@RequestMapping(value = { "/api/publications/feedObject" }, method = RequestMethod.POST) |
|
81 |
public @ResponseBody String feedObject(@RequestBody final ResultEntry pub, |
|
82 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) |
|
83 |
throws DirecIndexApiException { |
|
84 |
return feed(pub, commit); |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
@RequestMapping(value = "/api/result/{openaireId}", method = RequestMethod.DELETE) |
|
89 |
public @ResponseBody boolean deleteResultWithOpenaireId( |
|
90 |
@PathVariable(value = "openaireId") final String openaireId, |
|
91 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws DirecIndexApiException { |
|
92 |
|
|
93 |
return deleteResult(openaireId, commit); |
|
94 |
} |
|
95 |
|
|
96 |
@RequestMapping(value = "/api/results", method = RequestMethod.DELETE) |
|
97 |
public @ResponseBody boolean deleteResultWithOriginalId( |
|
98 |
@RequestParam(value = "originalId", required = true) final String originalId, |
|
99 |
@RequestParam(value = "collectedFromId", required = true) final String collectedFromId, |
|
100 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws Exception { |
|
101 |
|
|
102 |
final String openaireId = ResultEntry.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class)); |
|
103 |
return deleteResult(openaireId, commit); |
|
104 |
} |
|
105 |
|
|
106 |
@Deprecated |
|
107 |
@RequestMapping(value = { "/api/publications/deleteObject", "/api/results/delete" }, method = RequestMethod.POST) |
|
108 |
public @ResponseBody boolean deleteResultPost( |
|
109 |
@RequestParam(value = "originalId", required = true) final String originalId, |
|
110 |
@RequestParam(value = "collectedFromId", required = true) final String collectedFromId, |
|
111 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws Exception { |
|
112 |
|
|
113 |
final String openaireId = ResultEntry.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class)); |
|
114 |
return deleteResult(openaireId, commit); |
|
115 |
} |
|
116 |
|
|
117 |
@Deprecated |
|
118 |
private String feed(final ResultEntry pub, final boolean commit) throws DirecIndexApiException { |
|
119 |
return feed(pub); |
|
120 |
} |
|
121 |
|
|
122 |
private String feed(final ResultEntry pub) throws DirecIndexApiException { |
|
123 |
try { |
|
124 |
final String oafRecord = pub.asOafRecord(velocityEngine, serviceLocator.getService(ISLookUpService.class), oafSchemaLocation); |
|
125 |
|
|
126 |
for(Map.Entry<IndexDsInfo, CloudIndexClient> e : clientMap.getClients().entrySet()) { |
|
127 |
final IndexDsInfo idx = e.getKey(); |
|
128 |
final CloudIndexClient client = e.getValue(); |
|
129 |
client.feed(oafRecord, idx.getIndexDsId(), oafToIndexRecordFactory.newTransformer(idx.getFormat()), false); |
|
130 |
} |
|
131 |
|
|
132 |
recentResultsQueue.add(oafRecord); |
|
133 |
|
|
134 |
return pub.getOpenaireId(); |
|
135 |
} catch (final Throwable e) { |
|
136 |
log.error("Error saving record", e); |
|
137 |
log.debug(pub.toString()); |
|
138 |
throw new DirecIndexApiException("Error adding publication: " + e.getMessage(), e); |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
private boolean deleteResult(final String openaireId, final boolean commit) throws DirecIndexApiException { |
|
143 |
try { |
|
144 |
for(Map.Entry<IndexDsInfo, CloudIndexClient> e : clientMap.getClients().entrySet()) { |
|
145 |
final IndexDsInfo idx = e.getKey(); |
|
146 |
final CloudIndexClient client = e.getValue(); |
|
147 |
client.remove(openaireId, false); |
|
148 |
log.info("Deleted result with id: " + openaireId + " from: " + idx.getIndexBaseUrl()); |
|
149 |
} |
|
150 |
|
|
151 |
recentResultsQueue.remove(openaireId); |
|
152 |
return true; |
|
153 |
} catch (Throwable e) { |
|
154 |
throw new DirecIndexApiException("Error deleting publication: " + e.getMessage(), e); |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
@ExceptionHandler(Exception.class) |
|
159 |
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) |
|
160 |
public @ResponseBody ErrorMessage handleException(final Exception e) { |
|
161 |
log.error("Error in direct index API", e); |
|
162 |
return new ErrorMessage(e); |
|
163 |
} |
|
164 |
|
|
165 |
public class ErrorMessage { |
|
166 |
|
|
167 |
private final String message; |
|
168 |
private final String stacktrace; |
|
169 |
|
|
170 |
public ErrorMessage(final Exception e) { |
|
171 |
this(e.getMessage(), ExceptionUtils.getStackTrace(e)); |
|
172 |
} |
|
173 |
|
|
174 |
public ErrorMessage(final String message, final String stacktrace) { |
|
175 |
this.message = message; |
|
176 |
this.stacktrace = stacktrace; |
|
177 |
} |
|
178 |
|
|
179 |
public String getMessage() { |
|
180 |
return this.message; |
|
181 |
} |
|
182 |
|
|
183 |
public String getStacktrace() { |
|
184 |
return this.stacktrace; |
|
185 |
} |
|
186 |
|
|
187 |
} |
|
188 |
|
|
189 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/main/java/eu/dnetlib/openaire/directindex/api/OpenAIRESubmitterUtils.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import java.io.StringWriter; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import com.google.common.base.Function; |
|
10 |
import com.google.common.collect.Lists; |
|
11 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
12 |
import org.apache.commons.lang.StringUtils; |
|
13 |
|
|
14 |
/** |
|
15 |
* Created by michele on 15/01/16. |
|
16 |
*/ |
|
17 |
public class OpenAIRESubmitterUtils { |
|
18 |
|
|
19 |
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(OpenAIRESubmitterUtils.class); |
|
20 |
|
|
21 |
public Map<String, String> calculateProjectInfo(final String link) { |
|
22 |
final Map<String, String> info = new HashMap<String, String>(); |
|
23 |
final String[] arr = link.split("/"); |
|
24 |
// info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble |
|
25 |
|
|
26 |
if (arr.length > 4) { |
|
27 |
final String acronym = arr.length > 7 ? arr[7] : ""; |
|
28 |
final String title = arr.length > 6 ? StringUtils.isNotBlank(arr[6]) ? arr[6] : acronym : ""; |
|
29 |
final String jurisdiction = arr.length > 5 ? arr[5] : ""; |
|
30 |
final String funderId = calculateFunderId(arr[2], arr[3]); |
|
31 |
info.put("id", calculateProjectId(arr[2], arr[3], arr[4])); |
|
32 |
info.put("funderShortName", arr[2]); |
|
33 |
info.put("fundingName", arr[3]); |
|
34 |
info.put("code", arr[4]); |
|
35 |
info.put("jurisdiction", jurisdiction); |
|
36 |
info.put("title", title); |
|
37 |
info.put("acronym", acronym); |
|
38 |
info.put("funderId", funderId); |
|
39 |
info.put("funderName", calculateFunderName(arr[2])); |
|
40 |
info.put("fundingId", funderId + "::" + arr[3]); |
|
41 |
} |
|
42 |
return info; |
|
43 |
} |
|
44 |
|
|
45 |
protected String calculateFunderPrefix(final String funderShortName, final String funding){ |
|
46 |
switch(funderShortName.toLowerCase()){ |
|
47 |
case "conicyt": |
|
48 |
return "conicytf____::"; |
|
49 |
case "ec": |
|
50 |
if (funding.equalsIgnoreCase("fp7")) { |
|
51 |
return "corda_______::"; |
|
52 |
} else { |
|
53 |
return "corda__h2020::"; |
|
54 |
} |
|
55 |
case "hrzz": |
|
56 |
case "mzos": |
|
57 |
return "irb_hr______::"; |
|
58 |
case "tara": |
|
59 |
return "taraexp_____::"; |
|
60 |
case "tubitak": |
|
61 |
return "tubitakf____::"; |
|
62 |
default: |
|
63 |
String prefix = funderShortName.toLowerCase(); |
|
64 |
//ensure we have 12 chars |
|
65 |
while(prefix.length() < 12) prefix += "_"; |
|
66 |
return prefix +"::"; |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
protected String calculateProjectId(final String funderShortName, final String funding, final String code) { |
|
71 |
final String suffix = Hashing.md5(code); |
|
72 |
final String funderPrefix = calculateFunderPrefix(funderShortName, funding); |
|
73 |
return funderPrefix + suffix; |
|
74 |
} |
|
75 |
|
|
76 |
protected String calculateFunderId(final String funderShortName, final String funding) { |
|
77 |
switch (funderShortName.toLowerCase()) { |
|
78 |
case "ec": |
|
79 |
return "ec__________::EC"; |
|
80 |
default: |
|
81 |
String prefix = calculateFunderPrefix(funderShortName, funding); |
|
82 |
return prefix + funderShortName.toUpperCase(); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
|
|
87 |
protected String calculateFunderName(final String funderShortName) { |
|
88 |
|
|
89 |
switch (funderShortName.toLowerCase()) { |
|
90 |
case "aff": |
|
91 |
case "aka": |
|
92 |
return "Academy of Finland"; |
|
93 |
case "arc": |
|
94 |
return "Australian Research Council (ARC)"; |
|
95 |
case "conicyt": |
|
96 |
return "Comisión Nacional de Investigación Científica y Tecnológica"; |
|
97 |
case "ec": |
|
98 |
return "European Commission"; |
|
99 |
case "fct": |
|
100 |
return "Fundação para a Ciência e a Tecnologia, I.P."; |
|
101 |
case "fwf": |
|
102 |
return "Austrian Science Fund (FWF)"; |
|
103 |
case "hrzz": |
|
104 |
return "Croatian Science Foundation (CSF)"; |
|
105 |
case "mestd": |
|
106 |
return "Ministry of Education, Science and Technological Development of Republic of Serbia"; |
|
107 |
case "miur": |
|
108 |
return "Ministero dell'Istruzione dell'Università e della Ricerca"; |
|
109 |
case "mzos": |
|
110 |
return "Ministry of Science, Education and Sports of the Republic of Croatia (MSES)"; |
|
111 |
case "nhmrc": |
|
112 |
return "National Health and Medical Research Council (NHMRC)"; |
|
113 |
case "nih": |
|
114 |
return "National Institutes of Health"; |
|
115 |
case "nsf": |
|
116 |
return "National Science Foundation"; |
|
117 |
case "nwo": |
|
118 |
return "Netherlands Organisation for Scientific Research (NWO)"; |
|
119 |
case "rcuk": |
|
120 |
return "Research Council UK"; |
|
121 |
case "sfi": |
|
122 |
return "Science Foundation Ireland"; |
|
123 |
case "sgov": |
|
124 |
return "Gobierno de España"; |
|
125 |
case "snsf": |
|
126 |
return "Swiss National Science Foundation"; |
|
127 |
case "tara": |
|
128 |
return "Tara Expeditions Foundation"; |
|
129 |
case "tubitak": |
|
130 |
return "Türkiye Bilimsel ve Teknolojik Araştırma Kurumu"; |
|
131 |
case "wt": |
|
132 |
return "Wellcome Trust"; |
|
133 |
default: |
|
134 |
log.error("Funder short name '"+funderShortName+"' not managed"); |
|
135 |
return ""; |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
public List<ContextInfo> processContexts(final List<String> list) { |
|
140 |
return Lists.newArrayList(Lists.transform(list, new Function<String, ContextInfo>() { |
|
141 |
|
|
142 |
@Override |
|
143 |
public ContextInfo apply(final String s) { |
|
144 |
return createContextInfo(s.split("::"), 0); |
|
145 |
} |
|
146 |
|
|
147 |
private ContextInfo createContextInfo(final String[] arr, final int pos) { |
|
148 |
final StringWriter id = new StringWriter(); |
|
149 |
id.write(arr[0]); |
|
150 |
for (int i = 0; i < pos; i++) { |
|
151 |
id.write("::"); |
|
152 |
id.write(arr[i + 1]); |
|
153 |
} |
|
154 |
final String elem = (pos == 0) ? "context" : (pos == 1) ? "category" : "concept"; |
|
155 |
final ContextInfo info = new ContextInfo(elem, id.toString()); |
|
156 |
if ((pos + 1) < arr.length) { |
|
157 |
info.getChildren().add(createContextInfo(arr, pos + 1)); |
|
158 |
} |
|
159 |
return info; |
|
160 |
} |
|
161 |
})); |
|
162 |
|
|
163 |
} |
|
164 |
|
|
165 |
public class ContextInfo { |
|
166 |
|
|
167 |
private String elem; |
|
168 |
private String id; |
|
169 |
private List<ContextInfo> children = new ArrayList<ContextInfo>(); |
|
170 |
|
|
171 |
public ContextInfo(final String elem, |
|
172 |
final String id) { |
|
173 |
this.elem = elem; |
|
174 |
this.id = id; |
|
175 |
} |
|
176 |
|
|
177 |
public String getElem() { |
|
178 |
return elem; |
|
179 |
} |
|
180 |
|
|
181 |
public void setElem(final String elem) { |
|
182 |
this.elem = elem; |
|
183 |
} |
|
184 |
|
|
185 |
public String getId() { |
|
186 |
return id; |
|
187 |
} |
|
188 |
|
|
189 |
public void setId(final String id) { |
|
190 |
this.id = id; |
|
191 |
} |
|
192 |
|
|
193 |
public List<ContextInfo> getChildren() { |
|
194 |
return children; |
|
195 |
} |
|
196 |
|
|
197 |
public void setChildren(final List<ContextInfo> children) { |
|
198 |
this.children = children; |
|
199 |
} |
|
200 |
|
|
201 |
public boolean isRoot() { |
|
202 |
return elem.equals("context"); |
|
203 |
} |
|
204 |
} |
|
205 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/main/java/eu/dnetlib/openaire/directindex/api/IndexClientMap.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import com.google.common.collect.Lists; |
|
4 |
import com.google.common.collect.Maps; |
|
5 |
import eu.dnetlib.data.index.CloudIndexClient; |
|
6 |
import eu.dnetlib.data.index.CloudIndexClientException; |
|
7 |
import eu.dnetlib.data.index.CloudIndexClientFactory; |
|
8 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
9 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
10 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
11 |
import org.apache.commons.io.IOUtils; |
|
12 |
import org.apache.commons.logging.Log; |
|
13 |
import org.apache.commons.logging.LogFactory; |
|
14 |
import org.springframework.beans.factory.annotation.Value; |
|
15 |
import org.springframework.core.io.ClassPathResource; |
|
16 |
|
|
17 |
import javax.annotation.Resource; |
|
18 |
import java.io.IOException; |
|
19 |
import java.util.List; |
|
20 |
import java.util.Map; |
|
21 |
|
|
22 |
public class IndexClientMap { |
|
23 |
|
|
24 |
private static final Log log = LogFactory.getLog(IndexClientMap.class); |
|
25 |
|
|
26 |
@Value(value = "${openaire.api.directindex.findSolrIndexUrl.xquery}") |
|
27 |
private ClassPathResource findSolrIndexUrl; |
|
28 |
|
|
29 |
@Value(value = "${openaire.api.directindex.findIndexDsInfo.xquery}") |
|
30 |
private ClassPathResource findIndexDsInfo; |
|
31 |
|
|
32 |
@Resource |
|
33 |
private UniqueServiceLocator serviceLocator; |
|
34 |
|
|
35 |
private Map<IndexDsInfo, CloudIndexClient> clients = Maps.newHashMap(); |
|
36 |
|
|
37 |
public Map<IndexDsInfo, CloudIndexClient> getClients() throws DirecIndexApiException { |
|
38 |
try { |
|
39 |
final List<IndexDsInfo> idxList = calculateCurrentIndexDsInfo(); |
|
40 |
|
|
41 |
if (idxList == null || idxList.isEmpty()) { |
|
42 |
throw new DirecIndexApiException("cannot create index: no public Search Service found"); |
|
43 |
} |
|
44 |
if (idxList.size() > 1) { |
|
45 |
log.warn("found more than 1 public search service"); |
|
46 |
} |
|
47 |
|
|
48 |
for(IndexDsInfo i : idxList) { |
|
49 |
if (!clients.containsKey(i)) { |
|
50 |
clients.put(i, CloudIndexClientFactory.newIndexClient(i.getIndexBaseUrl(), i.getColl(), false)); |
|
51 |
} |
|
52 |
} |
|
53 |
return clients; |
|
54 |
|
|
55 |
} catch (IOException | ISLookUpException | CloudIndexClientException e) { |
|
56 |
throw new DirecIndexApiException(e); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
private List<IndexDsInfo> calculateCurrentIndexDsInfo() throws IOException, ISLookUpException { |
|
61 |
final List<IndexDsInfo> list = Lists.newArrayList(); |
|
62 |
|
|
63 |
final String queryUrl = IOUtils.toString(findSolrIndexUrl.getInputStream()); |
|
64 |
final String queryDs = IOUtils.toString(findIndexDsInfo.getInputStream()); |
|
65 |
|
|
66 |
final ISLookUpService lu = serviceLocator.getService(ISLookUpService.class); |
|
67 |
final String indexBaseUrl = lu.getResourceProfileByQuery(queryUrl); |
|
68 |
|
|
69 |
final List<String> idxDs = lu.quickSearchProfile(queryDs); |
|
70 |
for (final String idx : idxDs) { |
|
71 |
final String[] arr = idx.split("@@@"); |
|
72 |
list.add(new IndexDsInfo(indexBaseUrl, arr[0].trim(), arr[1].trim(), arr[2].trim())); |
|
73 |
} |
|
74 |
return list; |
|
75 |
} |
|
76 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/main/java/eu/dnetlib/openaire/directindex/api/DirecIndexApiException.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import eu.dnetlib.common.rmi.RMIException; |
|
4 |
|
|
5 |
public class DirecIndexApiException extends RMIException { |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
*/ |
|
10 |
private static final long serialVersionUID = -3888037031334809448L; |
|
11 |
|
|
12 |
public DirecIndexApiException(final String string) { |
|
13 |
super(string); |
|
14 |
} |
|
15 |
|
|
16 |
public DirecIndexApiException(final String string, final Throwable exception) { |
|
17 |
super(string, exception); |
|
18 |
} |
|
19 |
|
|
20 |
public DirecIndexApiException(final Throwable exception) { |
|
21 |
super(exception); |
|
22 |
} |
|
23 |
|
|
24 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/main/java/eu/dnetlib/openaire/directindex/api/RecentResultsQueue.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import com.mongodb.*; |
|
8 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
9 |
import org.apache.commons.logging.Log; |
|
10 |
import org.apache.commons.logging.LogFactory; |
|
11 |
import org.dom4j.io.SAXReader; |
|
12 |
import org.springframework.beans.factory.annotation.Required; |
|
13 |
|
|
14 |
/** |
|
15 |
* Created by michele on 11/11/15. |
|
16 |
*/ |
|
17 |
public class RecentResultsQueue implements Iterable<String> { |
|
18 |
|
|
19 |
private static final Log log = LogFactory.getLog(RecentResultsQueue.class); |
|
20 |
|
|
21 |
private DB db; |
|
22 |
private String collection; |
|
23 |
|
|
24 |
public void init() { |
|
25 |
if (!db.collectionExists(collection)) { |
|
26 |
log.info(String.format("creating collection %s", collection)); |
|
27 |
db.createCollection(collection, new BasicDBObject()); |
|
28 |
} |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public Iterator<String> iterator() { |
|
33 |
|
|
34 |
final DBCursor cursor = db.getCollection(collection).find(); |
|
35 |
|
|
36 |
return new Iterator<String>() { |
|
37 |
|
|
38 |
@Override |
|
39 |
public boolean hasNext() { |
|
40 |
return cursor.hasNext(); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public String next() { |
|
45 |
final DBObject obj = cursor.next(); |
|
46 |
return ((obj != null) && obj.containsField("record")) ? obj.get("record").toString() : ""; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public void remove() { |
|
51 |
throw new RuntimeException("NOT IMPLEMENTED"); |
|
52 |
} |
|
53 |
}; |
|
54 |
} |
|
55 |
|
|
56 |
synchronized public void add(final String oaf) throws Exception { |
|
57 |
final String id = (new SAXReader()).read(new StringReader(oaf)).valueOf("//*[local-name() = 'objIdentifier']"); |
|
58 |
|
|
59 |
log.info("Saving record " + id + " in db: " + db.getName() + ", coll: " + collection); |
|
60 |
|
|
61 |
final DBCollection coll = db.getCollection(collection); |
|
62 |
final DBObject obj = BasicDBObjectBuilder.start() |
|
63 |
.append("id", id) |
|
64 |
.append("record", oaf) |
|
65 |
.append("date", DateUtils.now()) |
|
66 |
.get(); |
|
67 |
coll.update(new BasicDBObject("id", id), obj, true, false); |
|
68 |
} |
|
69 |
|
|
70 |
public void remove(final List<String> list) { |
|
71 |
final DBCollection coll = db.getCollection(collection); |
|
72 |
for (final String id : list) { |
|
73 |
coll.remove(new BasicDBObject("id", id)); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
public void remove(final String... ids) { |
|
78 |
final DBCollection coll = db.getCollection(collection); |
|
79 |
for (final String id : ids) { |
|
80 |
coll.remove(new BasicDBObject("id", id)); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
public DB getDb() { |
|
85 |
return db; |
|
86 |
} |
|
87 |
|
|
88 |
@Required |
|
89 |
public void setDb(final DB db) { |
|
90 |
this.db = db; |
|
91 |
} |
|
92 |
|
|
93 |
public String getCollection() { |
|
94 |
return collection; |
|
95 |
} |
|
96 |
|
|
97 |
@Required |
|
98 |
public void setCollection(final String collection) { |
|
99 |
this.collection = collection; |
|
100 |
} |
|
101 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/main/java/eu/dnetlib/openaire/directindex/api/IndexDsInfo.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
public class IndexDsInfo { |
|
4 |
|
|
5 |
private final String indexBaseUrl; |
|
6 |
private final String indexDsId; |
|
7 |
private final String format; |
|
8 |
private final String coll; |
|
9 |
|
|
10 |
public IndexDsInfo(final String indexBaseUrl, final String indexDsId, final String format, final String coll) { |
|
11 |
this.indexBaseUrl = indexBaseUrl; |
|
12 |
this.indexDsId = indexDsId; |
|
13 |
this.format = format; |
|
14 |
this.coll = coll; |
|
15 |
} |
|
16 |
|
|
17 |
public String getIndexBaseUrl() { |
|
18 |
return indexBaseUrl; |
|
19 |
} |
|
20 |
|
|
21 |
public String getIndexDsId() { |
|
22 |
return indexDsId; |
|
23 |
} |
|
24 |
|
|
25 |
public String getFormat() { |
|
26 |
return format; |
|
27 |
} |
|
28 |
|
|
29 |
public String getColl() { |
|
30 |
return coll; |
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
public int hashCode() { |
|
35 |
return getColl().hashCode(); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public boolean equals(Object other) { |
|
40 |
if (!(other instanceof IndexDsInfo)) return false; |
|
41 |
|
|
42 |
return getColl().equals(((IndexDsInfo) other).getColl()); |
|
43 |
} |
|
44 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.5-solr75/src/main/java/eu/dnetlib/openaire/directindex/api/ResultSubmitterService.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import eu.dnetlib.data.index.CloudIndexClient; |
|
4 |
import eu.dnetlib.data.index.CloudIndexClientException; |
|
5 |
import org.apache.commons.logging.Log; |
|
6 |
import org.apache.commons.logging.LogFactory; |
|
7 |
import org.springframework.beans.factory.annotation.Value; |
|
8 |
|
|
9 |
import javax.annotation.Resource; |
|
10 |
import java.util.Map; |
|
11 |
import java.util.concurrent.Executors; |
|
12 |
import java.util.concurrent.ScheduledExecutorService; |
|
13 |
import java.util.concurrent.TimeUnit; |
|
14 |
|
|
15 |
public class ResultSubmitterService { |
|
16 |
|
|
17 |
private static final Log log = LogFactory.getLog(ResultSubmitterService.class); |
|
18 |
|
|
19 |
@Resource |
|
20 |
private IndexClientMap clientMap; |
|
21 |
|
|
22 |
/** |
|
23 |
* Autocommit feature activation flag |
|
24 |
*/ |
|
25 |
@Value(value = "${openaire.api.directindex.autocommit.active}") |
|
26 |
private boolean autocommitactive; |
|
27 |
|
|
28 |
/** |
|
29 |
* Autocommit frequency (Seconds) |
|
30 |
*/ |
|
31 |
@Value(value = "${openaire.api.directindex.autocommit.frequency}") |
|
32 |
private long commitfrquency = 60; |
|
33 |
|
|
34 |
private ScheduledExecutorService executor; |
|
35 |
|
|
36 |
public ResultSubmitterService() { |
|
37 |
executor = Executors.newSingleThreadScheduledExecutor(); |
|
38 |
updateCommitSchedule(); |
|
39 |
} |
|
40 |
|
|
41 |
private void updateCommitSchedule() { |
|
42 |
log.info("updating commit schedule"); |
|
43 |
|
|
44 |
executor.scheduleAtFixedRate(() -> { |
|
45 |
if (isAutocommitactive()) { |
|
46 |
try { |
|
47 |
for (Map.Entry<IndexDsInfo, CloudIndexClient> entry : clientMap.getClients().entrySet()) { |
|
48 |
final IndexDsInfo i = entry.getKey(); |
|
49 |
final CloudIndexClient client = entry.getValue(); |
|
50 |
|
|
51 |
log.info("performing commit on " + i.getColl()); |
|
52 |
try { |
|
53 |
client.commit(); |
|
54 |
} catch (CloudIndexClientException e) { |
|
55 |
log.error("error performing commit on " + i.getColl(), e); |
|
56 |
} |
|
57 |
} |
|
58 |
} catch (DirecIndexApiException e) { |
|
59 |
log.error(e); |
|
60 |
} |
|
61 |
} |
|
62 |
}, 0, getCommitfrquency(), TimeUnit.SECONDS); |
|
63 |
} |
|
64 |
|
|
65 |
public boolean isAutocommitactive() { |
|
66 |
return autocommitactive; |
|
67 |
} |
|
68 |
|
|
69 |
public synchronized void setAutocommitactive(boolean autocommitactive) { |
|
70 |
this.autocommitactive = autocommitactive; |
|
71 |
} |
|
72 |
|
|
73 |
public long getCommitfrquency() { |
|
74 |
return commitfrquency; |
|
75 |
} |
|
76 |
|
|
77 |
public synchronized void setCommitfrquency(long commitfrquency) { |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-directindex-api-2.1.5-solr75