From 8a5cbe7b183bbf6de16a032464dfa405303a45a6 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 25 Dec 2023 15:51:11 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=81=AE=E3=83=91=E3=83=BC=E3=82=B9=E5=87=A6=E7=90=86=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../processor/impl/DocumentProcessorImpl.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java b/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java index 08dd0d02..19ebcd78 100644 --- a/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java +++ b/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java @@ -2,7 +2,9 @@ package one.nem.lacerta.processor.impl; import android.graphics.Bitmap; +import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.UUID; import javax.inject.Inject; @@ -44,6 +46,34 @@ public class DocumentProcessorImpl implements DocumentProcessor{ logger.debug("init", "called"); // XMLメタデータの取得/生成 FileManager fileManager = fileManagerFactory.create(documentDetail.getPath().getFullPath()); + if(fileManager.getList().contains(documentDetail.getPath().getFullPath().resolve("meta.xml"))) { + logger.debug("init", "meta.xml found"); + try { + xmlMetaModel = xmlMetaParser.parse(new String(Files.readAllBytes(documentDetail.getPath().getFullPath().resolve("meta.xml")))); + logger.debug("init", "parsed"); + } catch (Exception e) { + logger.debug("init", "parse failed"); + e.printStackTrace(); + } + } else { + logger.debug("init", "meta.xml not found"); + // Create new + xmlMetaModel = new XmlMetaModel(); + xmlMetaModel.setTitle(this.documentDetail.getMeta().getTitle()); + xmlMetaModel.setAuthor(this.documentDetail.getAuthor()); + xmlMetaModel.setDescription(""); + xmlMetaModel.setDefaultBranch("master"); + xmlMetaModel.setPages(new ArrayList<>()); + + // Save + try { + Files.write(documentDetail.getPath().getFullPath().resolve("meta.xml"), xmlMetaParser.serialize(xmlMetaModel).getBytes()); + logger.debug("init", "saved"); + } catch (Exception e) { + logger.debug("init", "save failed"); + e.printStackTrace(); + } + } } @Override