ファイルマネージャーを共用するように

This commit is contained in:
r-ca 2024-01-08 14:37:10 +09:00
parent bc5d0edd68
commit e54cc07e9d
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -25,9 +25,12 @@ public class DocumentProcessorImpl implements DocumentProcessor{
// Magic Numbers // Magic Numbers
private static final String DEFAULT_SAVE_DIR = "raw"; private static final String DEFAULT_SAVE_DIR = "raw";
// Variables
private final DocumentDetail documentDetail; private final DocumentDetail documentDetail;
private XmlMetaModel xmlMetaModel; private XmlMetaModel xmlMetaModel;
private Path documentRootPath; private Path documentRootPath;
private FileManager fileManager;
// Injection // Injection
private final FileManagerFactory fileManagerFactory; private final FileManagerFactory fileManagerFactory;
@ -51,19 +54,19 @@ public class DocumentProcessorImpl implements DocumentProcessor{
this.documentRootPath = documentDetail.getPath().getFullPath(); this.documentRootPath = documentDetail.getPath().getFullPath();
logger.debug("init", "documentRootPath: " + this.documentRootPath); logger.debug("init", "documentRootPath: " + this.documentRootPath);
FileManager fileManager = fileManagerFactory.create(this.documentRootPath); //Initialize FileManager this.fileManager = fileManagerFactory.create(this.documentRootPath); //Initialize FileManager
logger.debug("init", "fileManager created"); logger.debug("init", "fileManager created");
fileManager.autoCreateDir(this.documentRootPath); this.fileManager.autoCreateDir(this.documentRootPath);
// rawディレクトリInit // rawディレクトリInit
fileManager.autoCreateDir(DEFAULT_SAVE_DIR); this.fileManager.autoCreateDir(DEFAULT_SAVE_DIR);
// xmlファイルの読み込み // xmlファイルの読み込み
if (fileManager.isExist("meta.xml")) { if (fileManager.isExist("meta.xml")) {
logger.debug("init", "meta.xml found"); logger.debug("init", "meta.xml found");
try { try {
xmlMetaModel = xmlMetaParser.deserialize(fileManager.loadDocument("meta.xml")); xmlMetaModel = xmlMetaParser.deserialize(this.fileManager.loadDocument("meta.xml"));
} catch (Exception e) { } catch (Exception e) {
logger.debug("init", "meta.xml parse failed"); logger.debug("init", "meta.xml parse failed");
logger.trace("init", e.getMessage()); logger.trace("init", e.getMessage());
@ -79,7 +82,7 @@ public class DocumentProcessorImpl implements DocumentProcessor{
xmlMetaModel.setPages(new ArrayList<>()); xmlMetaModel.setPages(new ArrayList<>());
try { try {
fileManager.saveDocument(xmlMetaParser.serialize(xmlMetaModel), "meta.xml"); this.fileManager.saveDocument(xmlMetaParser.serialize(xmlMetaModel), "meta.xml");
logger.debug("init", "meta.xml saved"); logger.debug("init", "meta.xml saved");
} catch (Exception e) { } catch (Exception e) {
logger.error("init", "meta.xml save failed"); logger.error("init", "meta.xml save failed");