Revision 48017
Added by Claudio Atzori over 6 years ago
modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java | ||
---|---|---|
6 | 6 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile; |
7 | 7 |
import eu.dnetlib.data.objectstore.rmi.Protocols; |
8 | 8 |
import eu.dnetlib.miscutils.functional.UnaryFunction; |
9 |
import org.apache.commons.lang.StringUtils; |
|
9 | 10 |
import org.apache.commons.logging.Log; |
10 | 11 |
import org.apache.commons.logging.LogFactory; |
11 | 12 |
|
... | ... | |
29 | 30 |
newFile.setAccessProtocol(Protocols.HTTP); |
30 | 31 |
newFile.setMimeType((String) metadata.get("mime")); |
31 | 32 |
newFile.setMd5Sum((String) metadata.get("md5Sum")); |
32 |
try{ |
|
33 |
try {
|
|
33 | 34 |
newFile.setFileSizeKB(Long.parseLong(metadata.get("size").toString()) / KB_SIZE); |
34 | 35 |
} catch (Throwable e) { |
35 |
log.error("Error on getting size",e);
|
|
36 |
log.error("Error on getting file size", e);
|
|
36 | 37 |
} |
37 | 38 |
if (originalFile != null) { |
38 | 39 |
newFile.setMetadataRelatedID(original.getMetadataRelatedID()); |
39 |
if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
|
|
40 |
if (StringUtils.isBlank(original.getDownloadedURL())) {
|
|
40 | 41 |
newFile.setDownloadedURL(original.getURI()); |
41 | 42 |
} else { |
42 | 43 |
newFile.setDownloadedURL(original.getDownloadedURL()); |
... | ... | |
51 | 52 |
} |
52 | 53 |
|
53 | 54 |
public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) { |
54 |
return new UnaryFunction<String, DBObject>() { |
|
55 |
|
|
56 |
@Override |
|
57 |
public String evaluate(final DBObject input) { |
|
58 |
return build(input, baseURI, objectStoreID, basePath).toJSON(); |
|
59 |
|
|
60 |
} |
|
61 |
}; |
|
55 |
return input -> build(input, baseURI, objectStoreID, basePath).toJSON(); |
|
62 | 56 |
} |
63 | 57 |
} |
Also available in: Unified diff
integrated latest changes from dnet40