// Path: src/main/java/org/broadinstitute/macarthurlab/matchbox/config/MatchMakerNodeConfig.java
// @Configuration
// public class MatchMakerNodeConfig {
// 
//     private static final Logger logger = LoggerFactory.getLogger(MatchMakerNodeConfig.class);
// 
//     @Autowired
//     private Environment environment;
// 
//     @Bean
//     public List<Node> matchMakerNodes() {
//         String nodeFile = environment.getProperty("matchbox.connected-nodes");
//         logger.info("Reading MME nodes from {}", nodeFile);
// 
//         StringBuilder nodeJson = new StringBuilder();
//         try (BufferedReader r = Files.newBufferedReader(Paths.get(nodeFile))) {
//             String line;
//             while ((line = r.readLine()) != null) {
//                 nodeJson.append(line);
//             }
//         } catch (Exception e) {
//             logger.error("error reading node config file:" + nodeFile + " : " + e);
//             //This is bad. Really bad. Don't start the server without these either.
//             throw new RuntimeException(e);
//         }
// 
//         List<Node> matchMakerNodes = new ArrayList<>();
//         JSONParser parser = new JSONParser();
//         JSONObject jsonObject = null;
//         try {
//             jsonObject = (JSONObject) parser.parse(nodeJson.toString());
//         } catch (ParseException e) {
//             logger.error("{}", e);
//             throw new RuntimeException(e);
//         }
//         JSONArray nodes = (JSONArray) jsonObject.get("nodes");
// 
//         for (int i = 0; i < nodes.size(); i++) {
//             JSONObject node = (JSONObject) nodes.get(i);
//             matchMakerNodes.add(new MatchmakerNode((String) node.get("name"),
//                     (String) node.get("token"),
//                     (String) node.get("url"),
//                     (String) node.get("acceptHeader"),
//                     (String) node.get("contentTypeHeader"),
//                     (String) node.get("contentLanguage"),
//                     (boolean) node.get("selfSignedCertificate")));
//         }
// 
//         logger.info("Connected Nodes:");
//         matchMakerNodes.forEach(node -> logger.info("{}", node));
// 
//         return matchMakerNodes;
//     }
// 
// }


import java.io.IOException;
import org.broadinstitute.macarthurlab.matchbox.config.MatchMakerNodeConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;
package org.broadinstitute.macarthurlab.matchbox;




/**
 * Entry point to application.
 *
 */
@SpringBootApplication
@ImportResource("file:config/config.xml")
public class MatchBox {
// Path: src/main/java/org/broadinstitute/macarthurlab/matchbox/config/MatchMakerNodeConfig.java
// @Configuration
// public class MatchMakerNodeConfig {
// 
//     private static final Logger logger = LoggerFactory.getLogger(MatchMakerNodeConfig.class);
// 
//     @Autowired
//     private Environment environment;
// 
//     @Bean
//     public List<Node> matchMakerNodes() {
//         String nodeFile = environment.getProperty("matchbox.connected-nodes");
//         logger.info("Reading MME nodes from {}", nodeFile);
// 
//         StringBuilder nodeJson = new StringBuilder();
//         try (BufferedReader r = Files.newBufferedReader(Paths.get(nodeFile))) {
//             String line;
//             while ((line = r.readLine()) != null) {
//                 nodeJson.append(line);
//             }
//         } catch (Exception e) {
//             logger.error("error reading node config file:" + nodeFile + " : " + e);
//             //This is bad. Really bad. Don't start the server without these either.
//             throw new RuntimeException(e);
//         }
// 
//         List<Node> matchMakerNodes = new ArrayList<>();
//         JSONParser parser = new JSONParser();
//         JSONObject jsonObject = null;
//         try {
//             jsonObject = (JSONObject) parser.parse(nodeJson.toString());
//         } catch (ParseException e) {
//             logger.error("{}", e);
//             throw new RuntimeException(e);
//         }
//         JSONArray nodes = (JSONArray) jsonObject.get("nodes");
// 
//         for (int i = 0; i < nodes.size(); i++) {
//             JSONObject node = (JSONObject) nodes.get(i);
//             matchMakerNodes.add(new MatchmakerNode((String) node.get("name"),
//                     (String) node.get("token"),
//                     (String) node.get("url"),
//                     (String) node.get("acceptHeader"),
//                     (String) node.get("contentTypeHeader"),
//                     (String) node.get("contentLanguage"),
//                     (boolean) node.get("selfSignedCertificate")));
//         }
// 
//         logger.info("Connected Nodes:");
//         matchMakerNodes.forEach(node -> logger.info("{}", node));
// 
//         return matchMakerNodes;
//     }
// 
// }


// Path: src/main/java/org/broadinstitute/macarthurlab/matchbox/MatchBox.java
import java.io.IOException;
import org.broadinstitute.macarthurlab.matchbox.config.MatchMakerNodeConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;

package org.broadinstitute.macarthurlab.matchbox;




/**
 * Entry point to application.
 *
 */
@SpringBootApplication
@ImportResource("file:config/config.xml")
public class MatchBox {
	private static final Logger logger = LoggerFactory.getLogger(MatchMakerNodeConfig.class);