diff --git a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java index eda15fce..1269d255 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java @@ -7,6 +7,7 @@ import one.nem.lacerta.model.ListItem; import one.nem.lacerta.model.ListItemType; import one.nem.lacerta.model.LibraryItemPage; +import one.nem.lacerta.model.PublicPath; import one.nem.lacerta.model.document.DocumentDetail; public interface LacertaLibrary { @@ -22,4 +23,7 @@ public interface LacertaLibrary { // Create Folder CompletableFuture createFolder(String path, String name); + // Get Public Path + CompletableFuture getPublicPath(String itemId, ListItemType itemType); + } diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java index 46b8dc23..16a9235c 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java @@ -148,16 +148,20 @@ public class LacertaLibraryImpl implements LacertaLibrary { if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) { DocumentEntity documentEntity = database.documentDao().findById(itemId); if (documentEntity == null) { + logger.warn("LacertaLibraryImpl", itemId + " is not found."); return null; } - return new PublicPath().resolve(documentEntity.publicPath); + PublicPath publicPath = recursiveResolve(documentEntity.parentId); + publicPath.resolve(documentEntity.title); + return publicPath; } else if (itemType == ListItemType.ITEM_TYPE_FOLDER) { FolderEntity folderEntity = database.folderDao().findById(itemId); if (folderEntity == null) { return null; } - return new PublicPath().resolve(folderEntity.publicPath); + return recursiveResolve(folderEntity.id); } else { + logger.warn("LacertaLibraryImpl", "Unknown ListItemType: " + itemType); return null; } });