package org.jboss.pnc.common.json;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author Pavel Slegr
 * @author Jakub Bartecek &lt;jbartece@redhat.com&gt;
 */
public class ConfigurationJSONParser {

    /**
     * Loads JSON configuration to the module configuration object
     *
     * @param configContent Configuration in JSON
     * @param classType Class for the requested configuration
     * @return Loaded configuration
     * @throws ConfigurationParseException Thrown if configuration string is malformed
     */
    public <T extends AbstractModuleConfig> T parseJSONConfig(
            String configContent, Class<T> classType) throws ConfigurationParseException {
        try {
            ObjectMapper mapper = new ObjectMapper();
            ModuleConfigJson jsonConfig = mapper.readValue(configContent, ModuleConfigJson.class);

            for (AbstractModuleConfig config : jsonConfig.getConfigs()) {
                if (config.getClass().isAssignableFrom(classType)) {
                    return (T) config;
                }
            }
            throw new ConfigurationParseException("Config could not be parsed");
        } catch (Exception e) {
            e.printStackTrace();
            throw new ConfigurationParseException("Config could not be parsed", e);
        }
    }
}

@@ -29,16 +29,50 @@
 .json;%0A%0A
+import org.jboss.logging.Logger;%0A%0A
 import c
@@ -239,16 +239,102 @@
 Parser %7B
+%0A    public final static Logger log = Logger.getLogger(ConfigurationJSONParser.class);
 %0A%0A    /*
@@ -1317,27 +1317,33 @@
     
-e.printStackTrac
+log.error(e.getMessag
 e()
+)
 ;%0A  

fix exception logging