Mercurial > hg > Database > jungle-network
changeset 122:cef245f71053
Implemented NetworkJungleBulletinBoard.checkAndCreateLogDirectory method
author | one |
---|---|
date | Fri, 27 Dec 2013 19:17:07 +0900 |
parents | 26bf85f69e4f |
children | 495ac60d7f5f |
files | src/main/java/app/bbs/NetworkJungleBulletinBoard.java src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java |
diffstat | 2 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Wed Dec 25 20:29:47 2013 +0900 +++ b/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Fri Dec 27 19:17:07 2013 +0900 @@ -31,6 +31,7 @@ { private final Jungle jungle; private final PersistentJournal journal; + private final String LOG_DIR = "./log"; public NetworkJungleBulletinBoard(String _uuid) throws FileNotFoundException { @@ -40,11 +41,24 @@ } public void init() throws IOException { + checkAndCreateLogDirectory(); commitLogRecover(); } + public void checkAndCreateLogDirectory() { + File logFile = new File(LOG_DIR); + if(!logFile.exists()) { + logFile.mkdir(); + return; + } + if (logFile.isFile()) { + logFile.delete(); + logFile.mkdir(); + } + } + public void commitLogRecover() throws IOException { - File[] logFiles = new File("./log/").listFiles(); + File[] logFiles = new File(LOG_DIR).listFiles(); for(File logFile : logFiles) { commitLogRecover(logFile); logFile.delete();
--- a/src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java Wed Dec 25 20:29:47 2013 +0900 +++ b/src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java Fri Dec 27 19:17:07 2013 +0900 @@ -38,13 +38,12 @@ } public void run() { - System.out.println("StartBBSCodeSegment"); String name = host.asString(); - System.out.println("name : "+ name); Matcher matcher = pattern.matcher(name); matcher.find(); // String type = matcher.group(1); + System.out.println("log loading..."); NetworkJungleBulletinBoard cassaBBS = null; try { cassaBBS = new NetworkJungleBulletinBoard(name); @@ -56,6 +55,8 @@ e.printStackTrace(); } + System.out.println("StartBBSCodeSegment"); + System.out.println("name : "+ name); /* Jetty registration */ String createBoardMessagePath = "/createBoardMessage"; String createBoardPath = "/createBoard";