use of com.intel.mountwilson.datamodel.HostDetailsEntityVO in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method saveNewHostInfo.
public ModelAndView saveNewHostInfo(HttpServletRequest req, HttpServletResponse res) {
log.info("WLMDataController.saveNewHostInfo >>");
ModelAndView responseView = new ModelAndView(new JSONView());
String hostObject = null;
boolean newhost = false;
try {
hostObject = req.getParameter("hostObject");
newhost = Boolean.parseBoolean(req.getParameter("newhost"));
} catch (Exception e1) {
responseView.addObject("result", false);
responseView.addObject("message", e1.getMessage());
}
System.out.println(hostObject);
ObjectMapper mapper = new ObjectMapper();
HostDetailsEntityVO dataVO = new HostDetailsEntityVO();
try {
dataVO = mapper.readValue(hostObject, HostDetailsEntityVO.class);
} catch (JsonParseException e) {
log.error("Error While Parsing request parameters Data. " + e.getMessage());
responseView.addObject("result", false);
responseView.addObject("message", "Error While Parsing request parameters Data.");
return responseView;
} catch (JsonMappingException e) {
log.error("Error While Mapping request parameters to Mle Data Object. " + e.getMessage());
responseView.addObject("result", false);
responseView.addObject("message", "Error While Mapping request parameters to Mle Data Object.");
return responseView;
} catch (IOException e) {
log.error("IO Exception " + e.getMessage());
responseView.addObject("result", false);
responseView.addObject("message", "Error While Mapping request parameters to Mle Data Object.");
return responseView;
}
dataVO.setUpdatedOn(new Date(System.currentTimeMillis()));
try {
if (newhost) {
System.err.println("dataForNew : " + dataVO);
responseView.addObject("result", demoPortalServices.saveNewHostData(dataVO, getAttestationService(req, AttestationService.class)));
} else {
System.err.println("dataForOLD : " + dataVO);
responseView.addObject("result", demoPortalServices.updateHostData(dataVO, getAttestationService(req, AttestationService.class)));
}
} catch (DemoPortalException e) {
log.error(e.getMessage());
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
return responseView;
}
log.info("WLMDataController.saveNewHostInfo <<<");
return responseView;
}
Aggregations