package org.fugerit.java.github.issue.export;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class GithubIssueConfig {

	public static final String CONFIG_FOLDER = ".github-issue-export";
	
	public static final String MAIN_CONFIG_FILE = "saved-config.properties";
		
	private static final GithubIssueConfig INSTANCE = new GithubIssueConfig();
	
	public static final String FIELD_ASSIGN_DATE = "assign_date"; 
	
	public static GithubIssueConfig getInstance() {
		return INSTANCE;
	}
	
	public File getBaseConfigPath() {
		File file = new File( System.getProperty( "user.home" ), CONFIG_FOLDER );
		return file;
	}
	
	public File getMainConfigFile() {
		return new File( getBaseConfigPath(), MAIN_CONFIG_FILE );
	}
	
	public File getCacheFileForRepo( String owner, String repo ) {
		String baseName = "cache-"+owner+"-"+repo+".properties";
		return new File( getBaseConfigPath(), baseName );
	}
	
	public Properties loadCachePropForRepo( String owner, String repo ) throws IOException {
		Properties cache = new Properties();
		File file = this.getCacheFileForRepo(owner, repo);
		if ( file.exists() ) {
			FileInputStream fis = new FileInputStream( file );
			cache.load( fis );
			fis.close();	
		}
		return cache;
	}
	
	public void saveCachePropForRepo( Properties cache, String owner, String repo ) throws IOException {
		FileOutputStream fos = new FileOutputStream( this.getCacheFileForRepo(owner, repo) );
		cache.store( fos , "cache file for repo : "+owner+"/"+repo );
		fos.close();
	}
	
}

@@ -196,42 +196,197 @@
 %0D%0A%0D%0A
-public class GithubIssueConfig %7B%0D%0A
+import org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory;%0D%0A%0D%0Apublic class GithubIssueConfig %7B%0D%0A%0D%0A%09private static final Logger logger = LoggerFactory.getLogger( GithubIssueConfig.class );%0D%0A%09
 %0D%0A%09p
@@ -1122,30 +1122,35 @@
 erties%22;%0D%0A%09%09
-return
+File file =
  new File( g
@@ -1178,24 +1178,191 @@
 aseName );%0D%0A
+%09%09if ( !file.getParentFile().exists() ) %7B%0D%0A%09%09%09logger.info( %22create config dir : %22+file.getAbsolutePath()+%22 -%3E %22+file.getParentFile().mkdirs() );%0D%0A%09%09%7D%0D%0A%09%09return file;%0D%0A
 %09%7D%0D%0A%09%0D%0A%09publ

Fix to configuration save issue