PublicPathを生成するメソッド作成

This commit is contained in:
ろむねこ 2024-01-22 20:22:51 +09:00
parent f7d07b0ec3
commit da8d4fb4fc
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
2 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType; import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.LibraryItemPage; import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.PublicPath;
import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.model.document.DocumentDetail;
public interface LacertaLibrary { public interface LacertaLibrary {
@ -22,4 +23,7 @@ public interface LacertaLibrary {
// Create Folder // Create Folder
CompletableFuture<String> createFolder(String path, String name); CompletableFuture<String> createFolder(String path, String name);
// Get Public Path
CompletableFuture<PublicPath> getPublicPath(String itemId, ListItemType itemType);
} }

View File

@ -148,16 +148,20 @@ public class LacertaLibraryImpl implements LacertaLibrary {
if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) { if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
DocumentEntity documentEntity = database.documentDao().findById(itemId); DocumentEntity documentEntity = database.documentDao().findById(itemId);
if (documentEntity == null) { if (documentEntity == null) {
logger.warn("LacertaLibraryImpl", itemId + " is not found.");
return null; 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) { } else if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
FolderEntity folderEntity = database.folderDao().findById(itemId); FolderEntity folderEntity = database.folderDao().findById(itemId);
if (folderEntity == null) { if (folderEntity == null) {
return null; return null;
} }
return new PublicPath().resolve(folderEntity.publicPath); return recursiveResolve(folderEntity.id);
} else { } else {
logger.warn("LacertaLibraryImpl", "Unknown ListItemType: " + itemType);
return null; return null;
} }
}); });