1 |
26600
|
sandro.lab
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.objectStore;
|
2 |
|
|
|
3 |
|
|
import java.io.File;
|
4 |
|
|
|
5 |
|
|
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
|
6 |
|
|
import eu.dnetlib.data.objectstore.rmi.Protocols;
|
7 |
|
|
import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
|
8 |
|
|
|
9 |
|
|
public class RepositoryNoURLIterator extends IteratorRepository {
|
10 |
|
|
|
11 |
|
|
public RepositoryNoURLIterator(final Iterable<File> input, final String repositoryPrefix, final String oaiPrefix) {
|
12 |
|
|
super(input, repositoryPrefix, oaiPrefix);
|
13 |
|
|
}
|
14 |
|
|
|
15 |
|
|
@Override
|
16 |
|
|
String generateNextElement() {
|
17 |
|
|
try {
|
18 |
|
|
String inputname = input.next().getCanonicalPath();
|
19 |
|
|
String[] values = inputname.split("/");
|
20 |
|
|
if (values.length > 1) {
|
21 |
|
|
ObjectStoreFile info = new ObjectStoreFile();
|
22 |
|
|
String fileName = values[values.length - 1].replace(".xml", "");
|
23 |
|
|
info.setAccessProtocol(Protocols.None);
|
24 |
|
|
// String value = "oai:europepmc.org:" + fileName;
|
25 |
|
|
String value = oaiPrefix + fileName;
|
26 |
|
|
String resultID = repositoryPrefix + "::" + DnetXsltFunctions.md5(value);
|
27 |
|
|
info.setObjectID(resultID);
|
28 |
|
|
info.setMimeType("pdf");
|
29 |
|
|
info.setURI(inputname);
|
30 |
|
|
return info.toJSON();
|
31 |
|
|
}
|
32 |
|
|
} catch (Exception e) {
|
33 |
|
|
return null;
|
34 |
|
|
}
|
35 |
|
|
return null;
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
}
|