Revision 59479
Added by Claudio Atzori over 3 years ago
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/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/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-directindex-api"} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/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 |
"http://beta.services.openaire.eu/openaire/community/" |
|
19 |
); |
|
20 |
|
|
21 |
final String fullProject = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"; |
|
22 |
final String minimalProject = "info:eu-repo/grantAgreement/EC/FP7/244909///WorkAble"; |
|
23 |
final String onlyId = "info:eu-repo/grantAgreement/EC/FP7/244909/"; |
|
24 |
final String onlyTitle = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work"; |
|
25 |
|
|
26 |
@Test |
|
27 |
public void testCalculateProjectInfoFull() { |
|
28 |
final Map<String, String> project = utils.calculateProjectInfo(fullProject); |
|
29 |
print(project); |
|
30 |
} |
|
31 |
|
|
32 |
@Test |
|
33 |
public void testCalculateProjectInfoOnlyId() { |
|
34 |
final Map<String, String> project = utils.calculateProjectInfo(onlyId); |
|
35 |
print(project); |
|
36 |
} |
|
37 |
|
|
38 |
@Test |
|
39 |
public void testCalculateProjectInfoMinimalAcro() { |
|
40 |
final Map<String, String> project = utils.calculateProjectInfo(minimalProject); |
|
41 |
print(project); |
|
42 |
} |
|
43 |
|
|
44 |
@Test |
|
45 |
public void testCalculateProjectInfoOnlyTitle() { |
|
46 |
final Map<String, String> project = utils.calculateProjectInfo(onlyTitle); |
|
47 |
print(project); |
|
48 |
} |
|
49 |
|
|
50 |
@Test |
|
51 |
public void testJerusalem(){ |
|
52 |
String s = "info:eu-repo/grantAgreement/EC/FP7/337895/EU/Opening Jerusalem Archives: For a connected History of ‘Citadinité’ in the Holy City (1840-1940)/OPEN-JERUSALEM"; |
|
53 |
final Map<String, String> project = utils.calculateProjectInfo(s); |
|
54 |
print(project); |
|
55 |
} |
|
56 |
|
|
57 |
private void print(final Map<String, String> map) { |
|
58 |
for (final Entry e : map.entrySet()) { |
|
59 |
System.out.println(e.getKey() + " = " + e.getValue()); |
|
60 |
} |
|
61 |
} |
|
62 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/src/test/java/eu/dnetlib/msro/openaireplus/api/objects/ResultEntryTest.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.api.objects; |
|
2 |
|
|
3 |
import com.google.gson.Gson; |
|
4 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
5 |
import eu.dnetlib.openaire.directindex.api.DirecIndexApiException; |
|
6 |
import eu.dnetlib.openaire.directindex.objects.PidEntry; |
|
7 |
import eu.dnetlib.openaire.directindex.objects.ResultEntry; |
|
8 |
import org.apache.commons.lang3.StringEscapeUtils; |
|
9 |
import org.apache.velocity.app.VelocityEngine; |
|
10 |
import org.dom4j.Document; |
|
11 |
import org.dom4j.io.OutputFormat; |
|
12 |
import org.dom4j.io.SAXReader; |
|
13 |
import org.dom4j.io.XMLWriter; |
|
14 |
import org.junit.Before; |
|
15 |
import org.junit.Test; |
|
16 |
import org.junit.runner.RunWith; |
|
17 |
import org.mockito.Mock; |
|
18 |
import org.mockito.runners.MockitoJUnitRunner; |
|
19 |
|
|
20 |
import java.io.InputStreamReader; |
|
21 |
import java.io.StringReader; |
|
22 |
import java.util.ArrayList; |
|
23 |
import java.util.Arrays; |
|
24 |
import java.util.Properties; |
|
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 |
private final String community_api = "https://dev-openaire.d4science.org/openaire/community/"; |
|
38 |
|
|
39 |
@Mock |
|
40 |
private ISLookUpService lookUpService; |
|
41 |
|
|
42 |
@Before |
|
43 |
public void setUp() throws Exception { |
|
44 |
|
|
45 |
final Properties props = new Properties(); |
|
46 |
props.setProperty("resource.loader", "class"); |
|
47 |
props.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); |
|
48 |
props.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.Log4JLogChute"); |
|
49 |
ve = new VelocityEngine(); |
|
50 |
ve.init(props); |
|
51 |
|
|
52 |
when(lookUpService.quickSearchProfile(anyString())).thenAnswer(invocation -> { |
|
53 |
final String query = invocation.getArguments()[0].toString(); |
|
54 |
if (query.contains("dnet:result_typologies")) { |
|
55 |
return Arrays.asList("publication @@@ publication", "dataset @@@ dataset", "software @@@ software", "other @@@ other"); |
|
56 |
} else if (query.contains("dnet:access_modes")) { |
|
57 |
return Arrays.asList("OPEN @@@ Open Access"); |
|
58 |
} else if (query.contains("dnet:publication_resource")) { |
|
59 |
return Arrays.asList("0001 @@@ Journal Article"); |
|
60 |
} else if (query.contains("dnet:pid_types")) { |
|
61 |
return Arrays.asList("oai @@@ Open Archive Initiative", "doi @@@ Digital object identifier"); |
|
62 |
} else if (query.contains("dnet:languages")) { |
|
63 |
return Arrays.asList("ita @@@ Italian"); |
|
64 |
} else if (query.contains("ContextDSResourceType")) { |
|
65 |
return Arrays.asList( |
|
66 |
"egi::classification::natsc::math::stats @@@ Statistics and Probability", |
|
67 |
"egi::classification::natsc::math::pure @@@ Pure Mathematics", |
|
68 |
"egi::classification::natsc::math @@@ Mathematics", |
|
69 |
"egi::classification::natsc @@@ Natural Sciences", |
|
70 |
"egi::classification @@@ EGI classification scheme", |
|
71 |
"egi @@@ EGI"); |
|
72 |
} else { |
|
73 |
return new ArrayList<String>(); |
|
74 |
} |
|
75 |
}); |
|
76 |
|
|
77 |
when(lookUpService.getResourceProfileByQuery(anyString())).thenAnswer(invocation -> "REPO NAME @@@ repo________"); |
|
78 |
} |
|
79 |
|
|
80 |
@Test |
|
81 |
public void testAsIndexRecord() throws Exception { |
|
82 |
final ResultEntry pub = new ResultEntry(); |
|
83 |
pub.setOriginalId("ORIG_ID_1234"); |
|
84 |
pub.setTitle("TEST TITLE <test>"); |
|
85 |
pub.getAuthors().add("Michele Artini"); |
|
86 |
pub.getAuthors().add("Claudio Atzori"); |
|
87 |
pub.getAuthors().add("Alessia Bardi"); |
|
88 |
pub.setPublisher("Test publisher"); |
|
89 |
pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION "); |
|
90 |
pub.setLanguage("ita"); |
|
91 |
pub.setLicenseCode("OPEN"); |
|
92 |
pub.setResourceType("0001"); |
|
93 |
pub.setUrl("http://test.it/a=1&b=2"); |
|
94 |
pub.getPids().add(new PidEntry("doi", "10.000/xyz-123")); |
|
95 |
pub.getPids().add(new PidEntry("oai", "oai:1234")); |
|
96 |
pub.setCollectedFromId("test________::zenodo"); |
|
97 |
pub.setHostedById("test________::UNKNOWN"); |
|
98 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus"); |
|
99 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"); |
|
100 |
pub.getContexts().add("egi::classification::natsc::math::pure"); |
|
101 |
pub.getContexts().add("egi::classification::natsc::math::stats"); |
|
102 |
final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd",community_api); |
|
103 |
|
|
104 |
final Document doc = new SAXReader().read(new StringReader(xml)); |
|
105 |
|
|
106 |
final OutputFormat format = OutputFormat.createPrettyPrint(); |
|
107 |
|
|
108 |
final XMLWriter writer = new XMLWriter(System.out, format); |
|
109 |
|
|
110 |
writer.write(doc); |
|
111 |
|
|
112 |
/* writer.close(); */ |
|
113 |
|
|
114 |
} |
|
115 |
|
|
116 |
@Test |
|
117 |
public void testAsIndexRecordAccessRight() throws Exception { |
|
118 |
final ResultEntry pub = new ResultEntry(); |
|
119 |
pub.setOriginalId("ORIG_ID_1234"); |
|
120 |
pub.setTitle("TEST TITLE <test>"); |
|
121 |
pub.getAuthors().add("Michele Artini"); |
|
122 |
pub.getAuthors().add("Claudio Atzori"); |
|
123 |
pub.getAuthors().add("Alessia Bardi"); |
|
124 |
pub.setPublisher("Test publisher"); |
|
125 |
pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION "); |
|
126 |
pub.setLanguage("ita"); |
|
127 |
pub.setLicenseCode("CLOSED"); |
|
128 |
pub.setAccessRightCode("OPEN"); |
|
129 |
pub.setResourceType("0001"); |
|
130 |
pub.setUrl("http://test.it/a=1&b=2"); |
|
131 |
pub.getPids().add(new PidEntry("doi", "10.000/xyz-123")); |
|
132 |
pub.getPids().add(new PidEntry("oai", "oai:1234")); |
|
133 |
pub.setCollectedFromId("test________::zenodo"); |
|
134 |
pub.setHostedById("test________::UNKNOWN"); |
|
135 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus"); |
|
136 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"); |
|
137 |
pub.getContexts().add("egi::classification::natsc::math::pure"); |
|
138 |
pub.getContexts().add("egi::classification::natsc::math::stats"); |
|
139 |
final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd",community_api); |
|
140 |
|
|
141 |
final Document doc = new SAXReader().read(new StringReader(xml)); |
|
142 |
|
|
143 |
final OutputFormat format = OutputFormat.createPrettyPrint(); |
|
144 |
|
|
145 |
final XMLWriter writer = new XMLWriter(System.out, format); |
|
146 |
|
|
147 |
writer.write(doc); |
|
148 |
|
|
149 |
/* writer.close(); */ |
|
150 |
|
|
151 |
} |
|
152 |
|
|
153 |
@Test |
|
154 |
public void testAsORP() throws Exception { |
|
155 |
final ResultEntry pub = new ResultEntry(); |
|
156 |
pub.setOriginalId("ORIG_ID_1234"); |
|
157 |
pub.setTitle("TEST TITLE <test>"); |
|
158 |
pub.getAuthors().add("Michele Artini"); |
|
159 |
pub.getAuthors().add("Claudio Atzori"); |
|
160 |
pub.getAuthors().add("Alessia Bardi"); |
|
161 |
pub.setPublisher("Test publisher"); |
|
162 |
pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION "); |
|
163 |
pub.setLanguage("ita"); |
|
164 |
pub.setLicenseCode("CLOSED"); |
|
165 |
pub.setAccessRightCode("OPEN"); |
|
166 |
pub.setResourceType("0020"); |
|
167 |
pub.setType("other"); |
|
168 |
pub.setUrl("http://test.it/a=1&b=2"); |
|
169 |
pub.getPids().add(new PidEntry("doi", "10.000/xyz-123")); |
|
170 |
pub.getPids().add(new PidEntry("oai", "oai:1234")); |
|
171 |
pub.setCollectedFromId("test________::zenodo"); |
|
172 |
pub.setHostedById("test________::UNKNOWN"); |
|
173 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus"); |
|
174 |
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"); |
|
175 |
pub.getContexts().add("egi::classification::natsc::math::pure"); |
|
176 |
pub.getContexts().add("egi::classification::natsc::math::stats"); |
|
177 |
final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd",community_api); |
|
178 |
|
|
179 |
final Document doc = new SAXReader().read(new StringReader(xml)); |
|
180 |
|
|
181 |
final OutputFormat format = OutputFormat.createPrettyPrint(); |
|
182 |
|
|
183 |
final XMLWriter writer = new XMLWriter(System.out, format); |
|
184 |
|
|
185 |
writer.write(doc); |
|
186 |
|
|
187 |
/* writer.close(); */ |
|
188 |
|
|
189 |
} |
|
190 |
|
|
191 |
@Test |
|
192 |
public void testAsIndexRecord_json() throws Exception { |
|
193 |
testAsIndexRecord_json("test_record.json"); |
|
194 |
|
|
195 |
} |
|
196 |
|
|
197 |
@Test |
|
198 |
public void testAsIndexRecord_json_with_greek_chars() throws Exception { |
|
199 |
|
|
200 |
testAsIndexRecord_json("test_record_with_greek_chars.json"); |
|
201 |
|
|
202 |
} |
|
203 |
|
|
204 |
@Test |
|
205 |
public void testAsIndexRecord_openaireId() throws Exception { |
|
206 |
|
|
207 |
testAsIndexRecord_json("test_record_openaireId.json"); |
|
208 |
|
|
209 |
} |
|
210 |
|
|
211 |
@Test(expected = DirecIndexApiException.class) |
|
212 |
public void testAsIndexRecord_wrongOpenaireId() throws Exception { |
|
213 |
|
|
214 |
testAsIndexRecord_json("test_record_wrong_openaireId.json"); |
|
215 |
|
|
216 |
} |
|
217 |
|
|
218 |
@Test |
|
219 |
public void testAsIndexRecord_json_zenodo() throws Exception { |
|
220 |
|
|
221 |
testAsIndexRecord_json("test_zenodo.json"); |
|
222 |
|
|
223 |
} |
|
224 |
|
|
225 |
@Test |
|
226 |
public void testAsIndexRecord_json_zenodoWithAmpersand() throws Exception { |
|
227 |
|
|
228 |
testAsIndexRecord_json("test_zenodoAmpersandEverywhere.json"); |
|
229 |
|
|
230 |
} |
|
231 |
|
|
232 |
@Test |
|
233 |
public void testAsIndexRecord_json_software() throws Exception { |
|
234 |
|
|
235 |
testAsIndexRecord_json("test_record_software.json"); |
|
236 |
|
|
237 |
} |
|
238 |
|
|
239 |
@Test |
|
240 |
public void testAsIndexRecord_json_orp() throws Exception { |
|
241 |
|
|
242 |
testAsIndexRecord_json("test_record_orp.json"); |
|
243 |
|
|
244 |
} |
|
245 |
|
|
246 |
private void testAsIndexRecord_json(final String filename) throws Exception { |
|
247 |
final ResultEntry pub = |
|
248 |
new Gson().fromJson(new InputStreamReader(getClass().getResourceAsStream(filename)), ResultEntry.class); |
|
249 |
|
|
250 |
|
|
251 |
final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd",community_api); |
|
252 |
//System.out.println(xml); |
|
253 |
|
|
254 |
final Document doc = new SAXReader().read(new StringReader(xml)); |
|
255 |
|
|
256 |
final OutputFormat format = OutputFormat.createPrettyPrint(); |
|
257 |
|
|
258 |
final XMLWriter writer = new XMLWriter(System.out, format); |
|
259 |
|
|
260 |
writer.write(doc); |
|
261 |
|
|
262 |
/* writer.close(); */ |
|
263 |
} |
|
264 |
|
|
265 |
@Test |
|
266 |
public void testAsIndexRecord_json_zenodocommunities()throws Exception{ |
|
267 |
testAsIndexRecord_json("test_zenodo_community.json"); |
|
268 |
} |
|
269 |
|
|
270 |
@Test |
|
271 |
public void testAsIndexRecordFromSandbox_json_zenodocommunities()throws Exception{ |
|
272 |
testAsIndexRecord_json("test_zenodo_community2.json"); |
|
273 |
} |
|
274 |
|
|
275 |
@Test |
|
276 |
public void testEscapeUnicode() { |
|
277 |
final String unicodeTxt = |
|
278 |
"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$"; |
|
279 |
System.out.println(StringEscapeUtils.escapeXml11(unicodeTxt)); |
|
280 |
} |
|
281 |
|
|
282 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/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.16/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.16/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.16/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.16/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.16/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.16/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.16/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.16/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_zenodo_problems.json | ||
---|---|---|
1 |
{ |
|
2 |
"authors": ["Milanese, Alessio", "Mende, Daniel", "Zeller, Georg", "Sunagawa, Shinichi"], |
|
3 |
"collectedFromId": "re3data_____::r3d100010468", |
|
4 |
"description": "<p>We simulated ten human gut metagenomic samples to assess the taxonomic quantification accuracy of the mOTUs tool (<a href=\"http: \// motu-tool.org \/\">link</a>). In this directory you can find the metagenomic samples, the gold standard (used to produce them) and the profiles obtained with four metagenomic profiler tools.</p>\\n\\n<p>Check README.txt for more information.</p>", |
|
5 |
"hostedById": "re3data_____::r3d100010468", |
|
6 |
"licenseCode": "OPEN", |
|
7 |
"originalId": "10.5281/zenodo.1473645", |
|
8 |
"pids": [ |
|
9 |
{"type": "oai", "value": "oai:zenodo.org:1473645"}, |
|
10 |
{"type": "doi", "value": "10.5281/zenodo.1473645"} |
|
11 |
], |
|
12 |
"publisher": "Zenodo", |
|
13 |
"resourceType": "0021", |
|
14 |
"title": "Simulated Human gut metagenomic samples to benchmark mOTUs v2", |
|
15 |
"type": "dataset", |
|
16 |
"url": "https://zenodo.org/record/1473645", |
|
17 |
"version": "2" |
|
18 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/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.16/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_zenodo_community.json | ||
---|---|---|
1 |
{"authors": ["Dag Haug", "Marius J\xf8hndal"], |
|
2 |
"collectedFromId": "re3data_____::r3d100010468", |
|
3 |
"contexts": ["https://sandbox.zenodo.org/communities/oac-ni","pippo"], |
|
4 |
"description": "<p>Official releases of the PROIEL treebank of ancient Indo-European languages</p>", |
|
5 |
"hostedById": "re3data_____::r3d100010468", |
|
6 |
"licenseCode": "OPEN", |
|
7 |
"originalId": "10.5281/zenodo.11003", |
|
8 |
"pids": [{"type": "oai", "value": "oai:zenodo.org:11003"}, |
|
9 |
{"type": "doi", "value": "10.5281/zenodo.11003"}], |
|
10 |
"publisher": "Zenodo", |
|
11 |
"resourceType": "0021", |
|
12 |
"title": "proiel-treebank: 20140723 version", |
|
13 |
"type": "dataset", |
|
14 |
"url": "https://zenodo.org/record/11003"} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_zenodo_community2.json | ||
---|---|---|
1 |
{"authors":["test"], |
|
2 |
"collectedFromId":"re3data_____::r3d100010468", |
|
3 |
"contexts":["https://zenodo.org/communities/oac-ni"], |
|
4 |
"description":"<p>test</p>", |
|
5 |
"hostedById":"re3data_____::r3d100010468", |
|
6 |
"licenseCode":"OPEN", |
|
7 |
"originalId":"oai:zenodo.org:315784", |
|
8 |
"pids":[{"type":"oai","value":"oai:zenodo.org:315784"}, |
|
9 |
{"type":"doi","value":"10.5072/zenodo.315784"}],"resourceType":"0020","title":"test","type":"other","url":"https://zenodo.org/record/315784"} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/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.16/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.16/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.16/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.16/src/main/java/eu/dnetlib/openaire/directindex/api/OpenaireResultSubmitter.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import java.text.SimpleDateFormat; |
|
4 |
import java.util.Date; |
|
5 |
import java.util.Map; |
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import com.google.gson.Gson; |
|
9 |
import eu.dnetlib.common.rmi.DNetRestDocumentation; |
|
10 |
import eu.dnetlib.data.index.CloudIndexClient; |
|
11 |
import eu.dnetlib.data.index.CloudIndexClientException; |
|
12 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
13 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
14 |
import eu.dnetlib.functionality.index.solr.feed.StreamingInputDocumentFactory; |
|
15 |
import eu.dnetlib.miscutils.datetime.HumanTime; |
|
16 |
import eu.dnetlib.miscutils.functional.UnaryFunction; |
|
17 |
import eu.dnetlib.openaire.directindex.objects.ResultEntry; |
|
18 |
import eu.dnetlib.openaire.directindex.utils.OafToIndexRecordFactory; |
|
19 |
import org.apache.commons.lang.exception.ExceptionUtils; |
|
20 |
import org.apache.commons.logging.Log; |
|
21 |
import org.apache.commons.logging.LogFactory; |
|
22 |
import org.apache.solr.client.solrj.impl.CloudSolrClient; |
|
23 |
import org.apache.solr.client.solrj.response.UpdateResponse; |
|
24 |
import org.apache.solr.common.SolrInputDocument; |
|
25 |
import org.apache.velocity.app.VelocityEngine; |
|
26 |
import org.springframework.beans.factory.annotation.Autowired; |
|
27 |
import org.springframework.beans.factory.annotation.Value; |
|
28 |
import org.springframework.http.HttpStatus; |
|
29 |
import org.springframework.stereotype.Controller; |
|
30 |
import org.springframework.web.bind.annotation.*; |
|
31 |
|
|
32 |
/** |
|
33 |
* Created by michele on 11/11/15. |
|
34 |
*/ |
|
35 |
@Controller |
|
36 |
@DNetRestDocumentation |
|
37 |
public class OpenaireResultSubmitter { |
|
38 |
|
|
39 |
private static final Log log = LogFactory.getLog(OpenaireResultSubmitter.class); |
|
40 |
|
|
41 |
@Value(value = "${openaire.api.community}") |
|
42 |
private String community_api; |
|
43 |
|
|
44 |
@Value(value = "oaf.schema.location") |
|
45 |
private String oafSchemaLocation; |
|
46 |
|
|
47 |
@Resource |
|
48 |
private UniqueServiceLocator serviceLocator; |
|
49 |
|
|
50 |
@Resource |
|
51 |
private OafToIndexRecordFactory oafToIndexRecordFactory; |
|
52 |
|
|
53 |
@Resource |
|
54 |
private RecentResultsQueue recentResultsQueue; |
|
55 |
|
|
56 |
@Resource(name = "openaireplusApisVelocityEngine") |
|
57 |
private VelocityEngine velocityEngine; |
|
58 |
|
|
59 |
@Resource(name = "indexClientManager") |
|
60 |
private IndexClientManager clientManager; |
|
61 |
|
|
62 |
@Resource(name = "resultSubmitterService") |
|
63 |
private ResultSubmitterService submitterService; |
|
64 |
|
|
65 |
@Autowired |
|
66 |
private IndexDSRetriever indexDSRetriever; |
|
67 |
|
|
68 |
@RequestMapping(value = { "/api/admin/autocommit/active" }, method = RequestMethod.GET) |
|
69 |
public @ResponseBody Boolean getAutocommit() throws DirecIndexApiException { |
|
70 |
return submitterService.isAutocommitactive(); |
|
71 |
} |
|
72 |
|
|
73 |
@RequestMapping(value = { "/api/admin/autocommit/active" }, method = RequestMethod.POST) |
|
74 |
public @ResponseBody Boolean setAutocommit(@RequestParam(value = "active", required = true) final Boolean active) throws DirecIndexApiException { |
|
75 |
submitterService.setAutocommitactive(active); |
|
76 |
log.info(String.format("automatic commit, active '%s', frequency '%s'", submitterService.isAutocommitactive(), submitterService.getCommitfrquency())); |
|
77 |
return submitterService.isAutocommitactive(); |
|
78 |
} |
|
79 |
|
|
80 |
@RequestMapping(value="/api/admin/evictCache", method=RequestMethod.GET) |
|
81 |
@ResponseStatus(value = HttpStatus.OK) |
|
82 |
public void evictCache(){ |
|
83 |
indexDSRetriever.evictCache(); |
|
84 |
} |
|
85 |
|
|
86 |
@Deprecated |
|
87 |
@RequestMapping(value = { "/api/publications/feedJson", "/api/results/feedJson" }, method = RequestMethod.POST) |
|
88 |
public @ResponseBody String feedObjectJson(@RequestParam(value = "json", required = true) final String json, |
|
89 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws DirecIndexApiException { |
|
90 |
final ResultEntry pub = new Gson().fromJson(json, ResultEntry.class); |
|
91 |
return feedObject(pub, commit); |
|
92 |
} |
|
93 |
|
|
94 |
|
|
95 |
@RequestMapping(value = { "/api/results/feedObject" }, method = RequestMethod.POST) |
|
96 |
public @ResponseBody String feedResult(@RequestBody final ResultEntry pub, |
|
97 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) |
|
98 |
throws DirecIndexApiException { |
|
99 |
return feed(pub,commit); |
|
100 |
|
|
101 |
} |
|
102 |
|
|
103 |
@Deprecated |
|
104 |
@RequestMapping(value = { "/api/publications/feedObject" }, method = RequestMethod.POST) |
|
105 |
public @ResponseBody String feedObject(@RequestBody final ResultEntry pub, |
|
106 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) |
|
107 |
throws DirecIndexApiException { |
|
108 |
return feed(pub, commit); |
|
109 |
} |
|
110 |
|
|
111 |
|
|
112 |
@RequestMapping(value = "/api/result/{openaireId}", method = RequestMethod.DELETE) |
|
113 |
public @ResponseBody boolean deleteResultWithOpenaireId( |
|
114 |
@PathVariable(value = "openaireId") final String openaireId, |
|
115 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws DirecIndexApiException { |
|
116 |
|
|
117 |
return deleteResult(openaireId, commit); |
|
118 |
} |
|
119 |
|
|
120 |
@RequestMapping(value = "/api/results", method = RequestMethod.DELETE) |
|
121 |
public @ResponseBody boolean deleteResultWithOriginalId( |
|
122 |
@RequestParam(value = "originalId", required = true) final String originalId, |
|
123 |
@RequestParam(value = "collectedFromId", required = true) final String collectedFromId, |
|
124 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws Exception { |
|
125 |
|
|
126 |
final String openaireId = ResultEntry.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class)); |
|
127 |
return deleteResult(openaireId, commit); |
|
128 |
} |
|
129 |
|
|
130 |
@Deprecated |
|
131 |
@RequestMapping(value = { "/api/publications/deleteObject", "/api/results/delete" }, method = RequestMethod.POST) |
|
132 |
public @ResponseBody boolean deleteResultPost( |
|
133 |
@RequestParam(value = "originalId", required = true) final String originalId, |
|
134 |
@RequestParam(value = "collectedFromId", required = true) final String collectedFromId, |
|
135 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws Exception { |
|
136 |
|
|
137 |
final String openaireId = ResultEntry.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class)); |
|
138 |
return deleteResult(openaireId, commit); |
|
139 |
} |
|
140 |
|
|
141 |
@Deprecated |
|
142 |
private String feed(final ResultEntry pub, final boolean commit) throws DirecIndexApiException { |
|
143 |
return feed(pub); |
|
144 |
} |
|
145 |
|
|
146 |
private String feed(final ResultEntry pub) throws DirecIndexApiException { |
|
147 |
try { |
|
148 |
final IndexDsInfo info = indexDSRetriever.calculateCurrentIndexDsInfo(); |
|
149 |
final String oafRecord = pub.asOafRecord(velocityEngine, serviceLocator.getService(ISLookUpService.class), oafSchemaLocation, community_api); |
|
150 |
final SolrInputDocument solrDocument = prepareSolrDocument(oafRecord, info.getIndexDsId(), oafToIndexRecordFactory.newTransformer(info.getFormat())); |
|
151 |
|
|
152 |
clientManager.getClient(info).add(solrDocument); |
|
153 |
recentResultsQueue.add(oafRecord); |
|
154 |
|
|
155 |
return pub.getOpenaireId(); |
|
156 |
} catch (final Throwable e) { |
|
157 |
log.error("Error saving record", e); |
|
158 |
log.debug(pub.toString()); |
|
159 |
throw new DirecIndexApiException("Error adding publication: " + e.getMessage(), e); |
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
private SolrInputDocument prepareSolrDocument(String record, String indexDsId, UnaryFunction<String, String> toIndexRecord) throws CloudIndexClientException { |
|
164 |
try { |
|
165 |
StreamingInputDocumentFactory documentFactory = new StreamingInputDocumentFactory(); |
|
166 |
String version = (new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'")).format(new Date()); |
|
167 |
String indexRecord = (String)toIndexRecord.evaluate(record); |
|
168 |
if (log.isDebugEnabled()) { |
|
169 |
log.debug("***************************************\nSubmitting index record:\n" + indexRecord + "\n***************************************\n"); |
|
170 |
} |
|
171 |
|
|
172 |
return documentFactory.parseDocument(version, indexRecord, indexDsId, "dnetResult"); |
|
173 |
} catch (Throwable e) { |
|
174 |
throw new CloudIndexClientException("Error creating solr document", e); |
|
175 |
} |
|
176 |
} |
|
177 |
|
|
178 |
private boolean deleteResult(final String openaireId, final boolean commit) throws DirecIndexApiException { |
|
179 |
try { |
|
180 |
IndexDsInfo info = indexDSRetriever.calculateCurrentIndexDsInfo(); |
|
181 |
String query = String.format("objidentifier:\"%s\" OR resultdupid:\"%s\"", openaireId, openaireId); |
|
182 |
final CloudSolrClient client = clientManager.getClient(info); |
|
183 |
client.deleteByQuery(info.getColl(), query); |
|
184 |
log.info("Deleted result with id: " + openaireId + " from: " + info.getIndexBaseUrl()); |
|
185 |
if (commit) { |
|
186 |
client.commit(); |
|
187 |
} |
|
188 |
|
|
189 |
recentResultsQueue.remove(openaireId); |
|
190 |
return true; |
|
191 |
} catch (Throwable e) { |
|
192 |
throw new DirecIndexApiException("Error deleting publication: " + e.getMessage(), e); |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
@ExceptionHandler(Exception.class) |
|
197 |
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) |
|
198 |
public @ResponseBody ErrorMessage handleException(final Exception e) { |
|
199 |
log.error("Error in direct index API", e); |
|
200 |
return new ErrorMessage(e); |
|
201 |
} |
|
202 |
|
|
203 |
public class ErrorMessage { |
|
204 |
|
|
205 |
private final String message; |
|
206 |
private final String stacktrace; |
|
207 |
|
|
208 |
public ErrorMessage(final Exception e) { |
|
209 |
this(e.getMessage(), ExceptionUtils.getStackTrace(e)); |
|
210 |
} |
|
211 |
|
|
212 |
public ErrorMessage(final String message, final String stacktrace) { |
|
213 |
this.message = message; |
|
214 |
this.stacktrace = stacktrace; |
|
215 |
} |
|
216 |
|
|
217 |
public String getMessage() { |
|
218 |
return this.message; |
|
219 |
} |
|
220 |
|
|
221 |
public String getStacktrace() { |
|
222 |
return this.stacktrace; |
|
223 |
} |
|
224 |
|
|
225 |
} |
|
226 |
|
|
227 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/src/main/java/eu/dnetlib/openaire/directindex/api/IndexClientManager.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import eu.dnetlib.functionality.index.utils.ZkServers; |
|
4 |
import org.apache.commons.logging.Log; |
|
5 |
import org.apache.commons.logging.LogFactory; |
|
6 |
import org.apache.solr.client.solrj.impl.CloudSolrClient; |
|
7 |
|
|
8 |
public class IndexClientManager { |
|
9 |
|
|
10 |
private static final Log log = LogFactory.getLog(IndexClientManager.class); |
|
11 |
|
|
12 |
private CloudSolrClient client = null; |
|
13 |
|
|
14 |
public CloudSolrClient getClient(IndexDsInfo info) { |
|
15 |
|
|
16 |
if (client == null) { |
|
17 |
log.info(String.format("Initializing solr client (%s) with collection %s", info.getIndexBaseUrl(), info.getColl())); |
|
18 |
ZkServers zk = ZkServers.newInstance(info.getIndexBaseUrl()); |
|
19 |
CloudSolrClient.Builder builder = new CloudSolrClient.Builder(zk.getHosts(), zk.getChroot()).withParallelUpdates(true); |
|
20 |
client = builder.build(); |
|
21 |
} |
|
22 |
client.setDefaultCollection(info.getColl()); |
|
23 |
return client; |
|
24 |
} |
|
25 |
|
|
26 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/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.*; |
|
5 |
import java.util.stream.Collectors; |
|
6 |
import java.util.stream.Collectors; |
|
7 |
|
|
8 |
import com.google.common.base.Function; |
|
9 |
import com.google.common.collect.Lists; |
|
10 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
11 |
import eu.dnetlib.openaire.directindex.objects.ZenodoContextList; |
|
12 |
import org.apache.commons.lang.StringUtils; |
|
13 |
import org.springframework.web.client.RestClientException; |
|
14 |
import org.springframework.web.client.RestTemplate; |
|
15 |
|
|
16 |
/** |
|
17 |
* Created by michele on 15/01/16. |
|
18 |
*/ |
|
19 |
public class OpenAIRESubmitterUtils { |
|
20 |
|
|
21 |
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(OpenAIRESubmitterUtils.class); |
|
22 |
private static final String ZENODO_COMMUNITY = "zenodo.org/communities/"; |
|
23 |
private String community_api; |
|
24 |
public OpenAIRESubmitterUtils(String community_api){ |
|
25 |
this.community_api = community_api; |
|
26 |
} |
|
27 |
|
|
28 |
public Map<String, String> calculateProjectInfo(final String link) { |
|
29 |
final Map<String, String> info = new HashMap<String, String>(); |
|
30 |
final String[] arr = link.split("/"); |
|
31 |
// info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble |
|
32 |
|
|
33 |
if (arr.length > 4) { |
|
34 |
final String acronym = arr.length > 7 ? arr[7] : ""; |
|
35 |
final String title = arr.length > 6 ? StringUtils.isNotBlank(arr[6]) ? arr[6] : acronym : ""; |
|
36 |
final String jurisdiction = arr.length > 5 ? arr[5] : ""; |
|
37 |
final String funderId = calculateFunderId(arr[2], arr[3]); |
|
38 |
info.put("id", calculateProjectId(arr[2], arr[3], arr[4])); |
|
39 |
info.put("funderShortName", arr[2]); |
|
40 |
info.put("fundingName", arr[3]); |
|
41 |
info.put("code", arr[4]); |
|
42 |
info.put("jurisdiction", jurisdiction); |
|
43 |
info.put("title", title); |
|
44 |
info.put("acronym", acronym); |
|
45 |
info.put("funderId", funderId); |
|
46 |
info.put("funderName", calculateFunderName(arr[2])); |
|
47 |
info.put("fundingId", funderId + "::" + arr[3]); |
|
48 |
} |
|
49 |
return info; |
|
50 |
} |
|
51 |
|
|
52 |
protected String calculateFunderPrefix(final String funderShortName, final String funding){ |
|
53 |
switch(funderShortName.toLowerCase()){ |
|
54 |
case "conicyt": |
|
55 |
return "conicytf____::"; |
|
56 |
case "dfg": |
|
57 |
return "dfgf________::"; |
|
58 |
case "ec": |
|
59 |
if (funding.equalsIgnoreCase("fp7")) { |
|
60 |
return "corda_______::"; |
|
61 |
} else { |
|
62 |
return "corda__h2020::"; |
|
63 |
} |
|
64 |
case "eea": |
|
65 |
return "euenvagency_::"; |
|
66 |
case "hrzz": |
|
67 |
case "mzos": |
|
68 |
return "irb_hr______::"; |
|
69 |
case "tara": |
|
70 |
return "taraexp_____::"; |
|
71 |
case "tubitak": |
|
72 |
return "tubitakf____::"; |
|
73 |
default: |
|
74 |
String prefix = funderShortName.toLowerCase(); |
|
75 |
//ensure we have 12 chars |
|
76 |
while(prefix.length() < 12) prefix += "_"; |
|
77 |
return prefix +"::"; |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
protected String calculateProjectId(final String funderShortName, final String funding, final String code) { |
|
82 |
final String suffix = Hashing.md5(code); |
|
83 |
final String funderPrefix = calculateFunderPrefix(funderShortName, funding); |
|
84 |
return funderPrefix + suffix; |
|
85 |
} |
|
86 |
|
|
87 |
protected String calculateFunderId(final String funderShortName, final String funding) { |
|
88 |
switch (funderShortName.toLowerCase()) { |
|
89 |
case "ec": |
|
90 |
return "ec__________::EC"; |
|
91 |
default: |
|
92 |
String prefix = calculateFunderPrefix(funderShortName, funding); |
|
93 |
return prefix + funderShortName.toUpperCase(); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
|
|
98 |
protected String calculateFunderName(final String funderShortName) { |
|
99 |
|
|
100 |
switch (funderShortName.toLowerCase()) { |
|
101 |
case "aff": |
|
102 |
case "aka": |
|
103 |
return "Academy of Finland"; |
|
104 |
case "anr": |
|
105 |
return "French National Research Agency (ANR)"; |
|
106 |
case "arc": |
|
107 |
return "Australian Research Council (ARC)"; |
|
108 |
case "cihr": |
|
109 |
return "Canadian Institutes of Health Research"; |
|
110 |
case "conicyt": |
|
111 |
return "Comisión Nacional de Investigación Científica y Tecnológica"; |
|
112 |
case "dfg": |
|
113 |
return "Deutsche Forschungsgemeinschaft"; |
|
114 |
case "ec": |
|
115 |
return "European Commission"; |
|
116 |
case "eea": |
|
117 |
return "European Environment Agency"; |
|
118 |
case "fct": |
|
119 |
return "Fundação para a Ciência e a Tecnologia, I.P."; |
|
120 |
case "fwf": |
|
121 |
return "Austrian Science Fund (FWF)"; |
|
122 |
case "gsrt": |
|
123 |
return "General Secretariat of Research and Technology (GSRT)"; |
|
124 |
case "hrzz": |
|
125 |
return "Croatian Science Foundation (CSF)"; |
|
126 |
case "innoviris": |
|
127 |
return "INNOVIRIS"; |
|
128 |
case "mestd": |
|
129 |
return "Ministry of Education, Science and Technological Development of Republic of Serbia"; |
|
130 |
case "miur": |
|
131 |
return "Ministero dell'Istruzione dell'Università e della Ricerca"; |
|
132 |
case "mzos": |
|
133 |
return "Ministry of Science, Education and Sports of the Republic of Croatia (MSES)"; |
|
134 |
case "nhmrc": |
|
135 |
return "National Health and Medical Research Council (NHMRC)"; |
|
136 |
case "nih": |
|
137 |
return "National Institutes of Health"; |
|
138 |
case "nsf": |
|
139 |
return "National Science Foundation"; |
|
140 |
case "nserc": |
|
141 |
return "Natural Sciences and Engineering Research Council of Canada"; |
|
142 |
case "nwo": |
|
143 |
return "Netherlands Organisation for Scientific Research (NWO)"; |
|
144 |
case "rcuk": |
|
145 |
return "Research Council UK"; |
|
146 |
case "rif": |
|
147 |
case "rpf": |
|
148 |
return "Research and Innovation Foundation"; |
|
149 |
case "rsf": |
|
150 |
return "Russian Science Foundation"; |
|
151 |
case "sfi": |
|
152 |
return "Science Foundation Ireland"; |
|
153 |
case "sgov": |
|
154 |
return "Gobierno de España"; |
|
155 |
case "snsf": |
|
156 |
return "Swiss National Science Foundation"; |
|
157 |
case "sshrc": |
|
158 |
return "Social Sciences and Humanities Research Council"; |
|
159 |
case "tara": |
|
160 |
return "Tara Expeditions Foundation"; |
|
161 |
case "tubitak": |
|
162 |
return "Türkiye Bilimsel ve Teknolojik Araştırma Kurumu"; |
|
163 |
case "wt": |
|
164 |
return "Wellcome Trust"; |
|
165 |
default: |
|
166 |
log.error("Funder short name '"+funderShortName+"' not managed"); |
|
167 |
return ""; |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
private List<String> filterContexts(List<String> contexts){ |
|
172 |
|
|
173 |
List<String> zenodoContexts |
|
174 |
= contexts.stream() |
|
175 |
.map(c -> { |
|
176 |
if(c.contains(ZENODO_COMMUNITY)) |
|
177 |
return c.substring(c.lastIndexOf("/")+1); |
|
178 |
return null; |
|
179 |
}).collect(Collectors.toList()); |
|
180 |
|
|
181 |
if (zenodoContexts.size()>0){ |
|
182 |
contexts = contexts.stream().filter(c -> !c.contains(ZENODO_COMMUNITY)).collect(Collectors.toList()); |
|
183 |
RestTemplate rt = new RestTemplate(); |
|
184 |
Set<String> zenodoOpenAIRE = new HashSet<>(); |
|
185 |
for (String context: zenodoContexts){ |
|
186 |
//String ct = context.substring(context.lastIndexOf("/")+1); |
|
187 |
try{ |
|
188 |
zenodoOpenAIRE.addAll(rt.getForObject(community_api +context+"/openairecommunities", ZenodoContextList.class).getOpenAirecommunitylist()); |
|
189 |
}catch(RestClientException rce){ |
|
190 |
log.error("Unable to get object for " + community_api +context+"/openairecommunities"); |
|
191 |
} |
|
192 |
|
|
193 |
|
|
194 |
} |
|
195 |
contexts.addAll(zenodoOpenAIRE); |
|
196 |
} |
|
197 |
|
|
198 |
return contexts; |
|
199 |
|
|
200 |
} |
|
201 |
public List<ContextInfo> processContexts(final List<String> list) { |
|
202 |
filterContexts(list); |
|
203 |
return Lists.newArrayList(Lists.transform(filterContexts(list), new Function<String, ContextInfo>() { |
|
204 |
|
|
205 |
@Override |
|
206 |
public ContextInfo apply(final String s) { |
|
207 |
return createContextInfo(s.split("::"), 0); |
|
208 |
} |
|
209 |
|
|
210 |
private ContextInfo createContextInfo(final String[] arr, final int pos) { |
|
211 |
final StringWriter id = new StringWriter(); |
|
212 |
id.write(arr[0]); |
|
213 |
for (int i = 0; i < pos; i++) { |
|
214 |
id.write("::"); |
|
215 |
id.write(arr[i + 1]); |
|
216 |
} |
|
217 |
final String elem = (pos == 0) ? "context" : (pos == 1) ? "category" : "concept"; |
|
218 |
final ContextInfo info = new ContextInfo(elem, id.toString()); |
|
219 |
if ((pos + 1) < arr.length) { |
|
220 |
info.getChildren().add(createContextInfo(arr, pos + 1)); |
|
221 |
} |
|
222 |
return info; |
|
223 |
} |
|
224 |
})); |
|
225 |
|
|
226 |
} |
|
227 |
|
|
228 |
public class ContextInfo { |
|
229 |
|
|
230 |
private String elem; |
|
231 |
private String id; |
|
232 |
private List<ContextInfo> children = new ArrayList<ContextInfo>(); |
|
233 |
|
|
234 |
public ContextInfo(final String elem, |
|
235 |
final String id) { |
|
236 |
this.elem = elem; |
|
237 |
this.id = id; |
|
238 |
} |
|
239 |
|
|
240 |
public String getElem() { |
|
241 |
return elem; |
|
242 |
} |
|
243 |
|
|
244 |
public void setElem(final String elem) { |
|
245 |
this.elem = elem; |
|
246 |
} |
|
247 |
|
|
248 |
public String getId() { |
|
249 |
return id; |
|
250 |
} |
|
251 |
|
|
252 |
public void setId(final String id) { |
|
253 |
this.id = id; |
|
254 |
} |
|
255 |
|
|
256 |
public List<ContextInfo> getChildren() { |
|
257 |
return children; |
|
258 |
} |
|
259 |
|
|
260 |
public void setChildren(final List<ContextInfo> children) { |
|
261 |
this.children = children; |
|
262 |
} |
|
263 |
|
|
264 |
public boolean isRoot() { |
|
265 |
return elem.equals("context"); |
|
266 |
} |
|
267 |
} |
|
268 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/src/main/java/eu/dnetlib/openaire/directindex/api/IndexDSRetriever.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
4 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
5 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
6 |
import org.apache.commons.io.IOUtils; |
|
7 |
import org.apache.commons.logging.Log; |
|
8 |
import org.apache.commons.logging.LogFactory; |
|
9 |
import org.springframework.beans.factory.annotation.Value; |
|
10 |
import org.springframework.cache.annotation.CacheEvict; |
|
11 |
import org.springframework.cache.annotation.Cacheable; |
|
12 |
import org.springframework.core.io.ClassPathResource; |
|
13 |
|
|
14 |
import javax.annotation.Resource; |
|
15 |
import java.io.IOException; |
|
16 |
|
|
17 |
public class IndexDSRetriever { |
|
18 |
|
|
19 |
private static final Log log = LogFactory.getLog(IndexDSRetriever.class); |
|
20 |
@Value(value = "${openaire.api.directindex.findSolrIndexUrl.xquery}") |
|
21 |
private ClassPathResource findSolrIndexUrl; |
|
22 |
|
|
23 |
@Value(value = "${openaire.api.directindex.findIndexDsInfo.xquery}") |
|
24 |
private ClassPathResource findIndexDsInfo; |
|
25 |
|
|
26 |
@Resource |
|
27 |
private UniqueServiceLocator serviceLocator; |
|
28 |
|
|
29 |
@Cacheable("indexDsInfo") |
|
30 |
public IndexDsInfo calculateCurrentIndexDsInfo() throws IOException, ISLookUpException { |
|
31 |
|
|
32 |
log.info("Not using cache"); |
|
33 |
|
|
34 |
final String queryUrl = IOUtils.toString(findSolrIndexUrl.getInputStream()); |
|
35 |
final String queryDs = IOUtils.toString(findIndexDsInfo.getInputStream()); |
|
36 |
|
|
37 |
final ISLookUpService lu = serviceLocator.getService(ISLookUpService.class); |
|
38 |
final String indexBaseUrl = lu.getResourceProfileByQuery(queryUrl); |
|
39 |
|
|
40 |
final String idxDs = lu.getResourceProfileByQuery(queryDs); |
|
41 |
|
|
42 |
if (idxDs.isEmpty()) { |
|
43 |
throw new IllegalStateException(queryDs + "\n\nreturned no results, check IS profiles"); |
|
44 |
} |
|
45 |
|
|
46 |
final String[] arr = idxDs.split("@@@"); |
|
47 |
return new IndexDsInfo(indexBaseUrl, arr[0].trim(), arr[1].trim(), arr[2].trim()); |
|
48 |
} |
|
49 |
|
|
50 |
@CacheEvict(value="indexDsInfo", allEntries = true) |
|
51 |
public void evictCache(){ |
|
52 |
log.info("Evicting indexDsInfo cache"); |
|
53 |
} |
|
54 |
} |
modules/dnet-directindex-api/tags/dnet-directindex-api-2.1.16/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.16/src/main/java/eu/dnetlib/openaire/directindex/api/RecentResultsQueue.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.directindex.api; |
|
2 |
|
|
3 |
import java.io.StringReader; |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-directindex-api-2.1.16