package com.mokona.properties;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import com.mokona.exception.MokonaException;

public final class MokonaProperties {

    private static final String PROPERTIES_FILE_NAME = "mokona-internal.properties";
    private static final String USER_PROPERTIES_FILE_NAME = "mokona.properties";

    public Map<String, String> loadInternalPropertiesFile() {
        try {
            ClassLoader classLoader = getClass().getClassLoader();
            String file = classLoader.getResource(PROPERTIES_FILE_NAME).getFile();
            FileInputStream inputStream = new FileInputStream(file);
            return loadProperties(inputStream);
        } catch (IOException e) {
            throw new MokonaException("Unexpected error", e);
        }
    }

    public Map<String, String> loadUserPropertiesFile() {
        try {
            FileInputStream inputStream = new FileInputStream(USER_PROPERTIES_FILE_NAME);
            return loadProperties(inputStream);
        } catch (IOException e) {
            throw new MokonaException("Mokona configuration file not found", e);
        }
    }

    private Map<String, String> loadProperties(FileInputStream inputStream) throws IOException {
        Properties prop = new Properties();
        prop.load(inputStream);

        Map<String, String> properties = new HashMap<String, String>();

        for (String property : prop.stringPropertyNames()) {
            properties.put(property, prop.getProperty(property));
        }

        return properties;
    }

}

@@ -85,16 +85,44 @@
 eption;%0A
+import java.io.InputStream;%0A
 import j
@@ -135,24 +135,24 @@
 il.HashMap;%0A
-
 import java.
@@ -328,24 +328,25 @@
 ILE_NAME = %22
+/
 mokona-inter
@@ -536,100 +536,40 @@
     
-ClassLoader classLoader = getClass().getClassLoader();%0A            String file = classLoader
+InputStream is = this.getClass()
 .get
@@ -576,16 +576,24 @@
 Resource
+AsStream
 (PROPERT
@@ -610,87 +610,8 @@
 AME)
-.getFile();%0A            FileInputStream inputStream = new FileInputStream(file)
 ;%0A  
@@ -639,34 +639,25 @@
 Properties(i
-nputStream
+s
 );%0A        %7D
@@ -1098,24 +1098,24 @@
    %7D%0A    %7D%0A%0A
+
     private 
@@ -1149,20 +1149,16 @@
 perties(
-File
 InputStr

Fix load of properties