// Path: core/src/main/java/de/niklaskiefer/bnclCore/BnclToXmlWriter.java
// public class BnclToXmlWriter {
// 
//     private String fileName;
//     private static final Logger logger = Logger.getLogger(BnclToXmlWriter.class.getName());
// 
//     public BnclToXmlWriter() {
//         logger.setLevel(Level.INFO);
//         fileName = "test_process";
//     }
// 
//     public void createBPMNFile(String bncl) throws Exception {
//         BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
// 
//         File fileBPMN = new File(fileName + ".bpmn");
//         File fileXML = new File(fileName + ".xml");
//         Bpmn.writeModelToFile(fileBPMN, bpmnModelInstance);
//         Bpmn.writeModelToFile(fileXML, bpmnModelInstance);
// 
//         logger.info("Successfully save bpmn file to " + fileName);
//     }
// 
//     public void createBPMNFileFromFile(String file) throws Exception {
//         String bncl = getStringFromFileReaderAndClose(file);
//         createBPMNFile(bncl);
//     }
// 
//     public String convertBnclToXML(String bncl) throws Exception {
//         BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
//         String xmlString = Bpmn.convertToString(bpmnModelInstance);
// 
//         logger.info("Successfully convert bncl statement to xml");
//         return xmlString;
//     }
// 
//     public String convertBnclFileToXML(String fileName) throws Exception {
//         String bncl = getStringFromFileReaderAndClose(fileName);
//         return convertBnclToXML(bncl);
//     }
// 
//     private BpmnModelInstance createBPMModelInstance(String bncl) throws Exception {
//         BnclParser parser = new BnclParser();
//         BpmnModelInstance modelInstance;
//         modelInstance = parser.parseBncl(bncl);
//         return modelInstance;
//     }
// 
//     private String getStringFromFileReaderAndClose(String fileName) throws Exception {
//         StringBuilder result = new StringBuilder();
//         BufferedReader reader = null;
//         try {
//             reader = new BufferedReader(new FileReader(fileName));
//             while (reader.ready()) {
//                 result.append(reader.readLine());
//             }
//         } finally {
//             if (reader != null) {
//                 reader.close();
//             }
//         }
// 
//         return result.toString();
//     }
// }


import de.niklaskiefer.bnclCore.BnclToXmlWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
package de.niklaskiefer.bnclWeb;



@RestController
public class ApiController {
    private static final Logger LOGGER = LoggerFactory.getLogger(MainController.class);

    @RequestMapping(value = "/api/convert", method = RequestMethod.POST)
    public String convert(@RequestBody String bncl) throws Exception {
       return convertBnclToXML(bncl);
    }

// Path: core/src/main/java/de/niklaskiefer/bnclCore/BnclToXmlWriter.java
// public class BnclToXmlWriter {
// 
//     private String fileName;
//     private static final Logger logger = Logger.getLogger(BnclToXmlWriter.class.getName());
// 
//     public BnclToXmlWriter() {
//         logger.setLevel(Level.INFO);
//         fileName = "test_process";
//     }
// 
//     public void createBPMNFile(String bncl) throws Exception {
//         BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
// 
//         File fileBPMN = new File(fileName + ".bpmn");
//         File fileXML = new File(fileName + ".xml");
//         Bpmn.writeModelToFile(fileBPMN, bpmnModelInstance);
//         Bpmn.writeModelToFile(fileXML, bpmnModelInstance);
// 
//         logger.info("Successfully save bpmn file to " + fileName);
//     }
// 
//     public void createBPMNFileFromFile(String file) throws Exception {
//         String bncl = getStringFromFileReaderAndClose(file);
//         createBPMNFile(bncl);
//     }
// 
//     public String convertBnclToXML(String bncl) throws Exception {
//         BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
//         String xmlString = Bpmn.convertToString(bpmnModelInstance);
// 
//         logger.info("Successfully convert bncl statement to xml");
//         return xmlString;
//     }
// 
//     public String convertBnclFileToXML(String fileName) throws Exception {
//         String bncl = getStringFromFileReaderAndClose(fileName);
//         return convertBnclToXML(bncl);
//     }
// 
//     private BpmnModelInstance createBPMModelInstance(String bncl) throws Exception {
//         BnclParser parser = new BnclParser();
//         BpmnModelInstance modelInstance;
//         modelInstance = parser.parseBncl(bncl);
//         return modelInstance;
//     }
// 
//     private String getStringFromFileReaderAndClose(String fileName) throws Exception {
//         StringBuilder result = new StringBuilder();
//         BufferedReader reader = null;
//         try {
//             reader = new BufferedReader(new FileReader(fileName));
//             while (reader.ready()) {
//                 result.append(reader.readLine());
//             }
//         } finally {
//             if (reader != null) {
//                 reader.close();
//             }
//         }
// 
//         return result.toString();
//     }
// }


// Path: web/src/main/java/de/niklaskiefer/bnclWeb/ApiController.java
import de.niklaskiefer.bnclCore.BnclToXmlWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

package de.niklaskiefer.bnclWeb;



@RestController
public class ApiController {
    private static final Logger LOGGER = LoggerFactory.getLogger(MainController.class);

    @RequestMapping(value = "/api/convert", method = RequestMethod.POST)
    public String convert(@RequestBody String bncl) throws Exception {
       return convertBnclToXML(bncl);
    }

    private String convertBnclToXML(String bncl) throws Exception {