1
|
package eu.dnetlib.msro.workflows.nodes.objectstore;
|
2
|
|
3
|
import java.io.File;
|
4
|
|
5
|
import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
|
6
|
import eu.dnetlib.rmi.data.ObjectStoreFile;
|
7
|
import eu.dnetlib.rmi.data.Protocols;
|
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
|
final String inputname = this.input.next().getCanonicalPath();
|
19
|
final String[] values = inputname.split("/");
|
20
|
if (values.length > 1) {
|
21
|
final ObjectStoreFile info = new ObjectStoreFile();
|
22
|
final String fileName = values[values.length - 1].replace(".xml", "");
|
23
|
info.setAccessProtocol(Protocols.None);
|
24
|
// String value = "oai:europepmc.org:" + fileName;
|
25
|
final String value = this.oaiPrefix + fileName;
|
26
|
final String resultID = this.repositoryPrefix + "::" + DnetXsltFunctions.md5(value);
|
27
|
info.setObjectID(resultID);
|
28
|
info.setMimeType("pdf");
|
29
|
info.setURI(inputname);
|
30
|
return info.toJSON();
|
31
|
}
|
32
|
} catch (final Exception e) {
|
33
|
return null;
|
34
|
}
|
35
|
return null;
|
36
|
}
|
37
|
|
38
|
}
|