Revision 43652
Added by Claudio Atzori over 7 years ago
FileSystemUtility.java | ||
---|---|---|
6 | 6 |
import java.io.FileInputStream; |
7 | 7 |
import java.io.IOException; |
8 | 8 |
import java.io.InputStream; |
9 |
import java.nio.file.FileVisitResult; |
|
10 |
import java.nio.file.Files; |
|
11 |
import java.nio.file.Path; |
|
12 |
import java.nio.file.SimpleFileVisitor; |
|
9 |
import java.nio.file.*; |
|
13 | 10 |
import java.nio.file.attribute.BasicFileAttributes; |
14 | 11 |
|
15 | 12 |
import eu.dnetlib.miscutils.collections.Pair; |
13 |
import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions; |
|
14 |
import org.apache.commons.lang.StringUtils; |
|
16 | 15 |
import org.apache.commons.logging.Log; |
17 | 16 |
import org.apache.commons.logging.LogFactory; |
18 | 17 |
|
... | ... | |
70 | 69 |
return true; |
71 | 70 |
} |
72 | 71 |
|
72 |
public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) { |
|
73 |
final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId); |
|
74 |
final String md5id = DnetXsltFunctions.md5(objectIdentifier); |
|
75 |
final String firstLevel = StringUtils.substring(md5id, 0, 2); |
|
76 |
final String secondLevel = StringUtils.substring(md5id, 2, 4); |
|
77 |
final String fileName = StringUtils.substring(md5id, 4) + ".obj"; |
|
78 |
return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName); |
|
79 |
} |
|
73 | 80 |
|
74 |
|
|
75 | 81 |
} |
Also available in: Unified diff
objectStore rest controller doesn't use mongodb anymore to discover the basePath, it is instead passed and http parameter.