/**
 * Copyright (c) 2015, Yuriy Stul. All rights reserved
 */
package com.stulsoft.yscdutil;

import java.util.concurrent.ConcurrentNavigableMap;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.stulsoft.yscdcatalogue.data.DiskItemTree;
import com.stulsoft.yscdcatalogue.persistence.DBManagerDst;
import com.stulsoft.yscdcatalogue.persistence.DBManagerSrc;

/**
 * @author Yuriy Stul
 *
 */
public class YSCDUtilMain {
	private static Logger logger = LogManager.getLogger(YSCDUtilMain.class);

	/**
	 * @param args
	 *            input parameters
	 */
	public static void main(String[] args) {
		final String srcFolder = "d:\\My Documents D\\My Data\\YS Disks";
		final String dstFolder = "d:\\work\\YS Disks";
		logger.info("Copy DB from {} to {}", srcFolder, dstFolder);
		DBManagerSrc src = new DBManagerSrc(srcFolder);
		DBManagerDst dst = new DBManagerDst(dstFolder);

		try {
			dst.saveSoftItemTree(src.getSoftItemTree());
			final ConcurrentNavigableMap<String, String> diskItemTreeMap = src.getDiskItemTreeMap();
			logger.info("Source DB has {} disk item trees.", diskItemTreeMap.size());
			int count = 0;
			for(String json : diskItemTreeMap.values()){
				ObjectMapper mapper = new ObjectMapper();
				DiskItemTree tree = mapper.readValue(json, DiskItemTree.class);
				dst.saveDiskItemTree(tree);
				++count;
			}
			logger.info("{} disk item trees were copied.", count);
		}
		catch (Exception e) {
			final String message = "Failure: " + e.getMessage();
			logger.error(message);
			System.out.println(message);
		}
		
		logger.info("Completed.");
	}
}

@@ -89,24 +89,46 @@
 scdutil;%0D%0A%0D%0A
+import java.io.File;%0D%0A
 import java.
@@ -737,16 +737,72 @@
 rgs) %7B%0D%0A
+%09%09if (args.length != 2)%7B%0D%0A%09%09%09usage();%0D%0A%09%09%09return;%0D%0A%09%09%7D%0D%0A
 %09%09final 
@@ -815,24 +815,36 @@
  srcFolder =
+ args%5B0%5D;%09//
  %22d:%5C%5CMy Doc
@@ -900,16 +900,28 @@
 Folder =
+ args%5B1%5D;%09//
  %22d:%5C%5Cwo
@@ -991,32 +991,271 @@
 r, dstFolder);%0D%0A
+%09%09%0D%0A%09%09if (!(new File(srcFolder)).exists())%7B%0D%0A%09%09%09logger.error(%22Folder %7B%7D doesn't exist%22, srcFolder);%0D%0A%09%09%09return;%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09File dstFile = new File(dstFolder);%0D%0A%09%09if (dstFile.exists())%7B%0D%0A%09%09%09dstFile.delete();%0D%0A%09%09%7D%0D%0A%09%09dstFile.mkdirs();%0D%0A%09%09%0D%0A
 %09%09DBManagerSrc s
@@ -2057,11 +2057,130 @@
 );%0D%0A%09%7D%0D%0A
+%09%0D%0A%09private static void usage()%7B%0D%0A%09%09System.out.println(%22Usage java -jar YSCDUtil.jar %3Csrc folder%3E %3Cdst folder%3E%22);%0D%0A%09%7D%0D%0A
 %7D%0D%0A

Check src folder, recreate dst folder