Report Resource
Report Resource
rest;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URL;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.projectS.tools.model.Report;
import com.projectS.tools.service.ReportService;
import com.projectS.tools.util.Json2Json;
@RestController
@RequestMapping("/api")
public class ReportResource {
private final Logger logger = LoggerFactory.getLogger(ReportResource.class);
@Autowired
private ReportService reportService;
@PostMapping("/saveReport")
public void saveReport(@RequestParam("file") MultipartFile file, String type)
{
//reportService.saveReport(report);
logger.info("start treat nodes ...");
logger.info("message You successfully uploaded {} ",
file.getOriginalFilename() );
if (!file.isEmpty()) {
try {
/**
* Try switch origin report and get appropriate template
*/
URL resource =
getClass().getClassLoader().getResource("ws_template.json");
JsonNode jsonNode = JsonLoader.fromURL(resource);
logger.info("saveReport(), template : {}",
jsonNode.toString());
logger.info("saveReport(), input : {} ", file.gecomame());
} catch (IOException e) {
e.printStackTrace();
}
}
}
}