use of org.mycore.datamodel.niofs.MCRAbstractFileStore in project mycore by MyCoRe-Org.
the class MCRIView2Tools method getFilePath.
public static String getFilePath(String derID, String derPath) throws IOException {
MCRPath mcrPath = MCRPath.getPath(derID, derPath);
Path physicalPath = mcrPath.toPhysicalPath();
for (FileStore fs : mcrPath.getFileSystem().getFileStores()) {
if (fs instanceof MCRAbstractFileStore) {
Path basePath = ((MCRAbstractFileStore) fs).getBaseDirectory();
if (physicalPath.startsWith(basePath)) {
return basePath.relativize(physicalPath).toString();
}
}
}
return physicalPath.toString();
}
use of org.mycore.datamodel.niofs.MCRAbstractFileStore in project mycore by MyCoRe-Org.
the class MCRMediaSourceProvider method getContentPath.
private static String getContentPath(String derivateId, String path) {
try {
MCRPath mcrPath = MCRPath.getPath(derivateId, path);
MCRAbstractFileStore fileStore = (MCRAbstractFileStore) Files.getFileStore(mcrPath);
java.nio.file.Path absolutePath = fileStore.getPhysicalPath(mcrPath);
java.nio.file.Path relativePath = fileStore.getBaseDirectory().relativize(absolutePath);
LogManager.getLogger().info("{} -> {} -> {}", mcrPath, absolutePath, relativePath);
return relativePath.toString();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations