Revision 43652
Added by Claudio Atzori over 7 years ago
ObjectStoreFileUtility.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.objectstore.filesystem; |
2 | 2 |
|
3 | 3 |
import java.io.UnsupportedEncodingException; |
4 |
import java.net.URLEncoder; |
|
5 | 4 |
|
6 | 5 |
import com.mongodb.DBObject; |
7 | 6 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile; |
... | ... | |
21 | 20 |
/** The Constant log. */ |
22 | 21 |
private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class); |
23 | 22 |
|
24 |
public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) { |
|
23 |
public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
|
|
25 | 24 |
|
26 | 25 |
String originalFile = (String) metadata.get("originalObject"); |
27 | 26 |
ObjectStoreFile original = ObjectStoreFile.createObject(originalFile); |
... | ... | |
44 | 43 |
} |
45 | 44 |
} |
46 | 45 |
try { |
47 |
newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId=" |
|
48 |
+ URLEncoder.encode(newFile.getObjectID(), "UTF-8")); |
|
46 |
newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID())); |
|
49 | 47 |
} catch (UnsupportedEncodingException e) { |
50 | 48 |
log.error("Error on Build objectStoreFile ", e); |
51 | 49 |
} |
52 | 50 |
return newFile; |
53 | 51 |
} |
54 | 52 |
|
55 |
public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) { |
|
53 |
public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
|
|
56 | 54 |
return new UnaryFunction<String, DBObject>() { |
57 | 55 |
|
58 | 56 |
@Override |
59 | 57 |
public String evaluate(final DBObject input) { |
60 |
return build(input, baseURI, objectStoreID).toJSON(); |
|
58 |
return build(input, baseURI, objectStoreID, basePath).toJSON();
|
|
61 | 59 |
|
62 | 60 |
} |
63 | 61 |
}; |
Also available in: Unified diff
objectStore rest controller doesn't use mongodb anymore to discover the basePath, it is instead passed and http parameter.