use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method getHostTrustSatusForPageNo.
/**
* Method is used to get trust status of host for selected page no.
* Method will get called when user choose any page no from pagination.
*
* @param req
* @param res
* @return
*/
public ModelAndView getHostTrustSatusForPageNo(HttpServletRequest req, HttpServletResponse res) {
log.info("DemoPortalDataController.getHostTrustSatusForPageNo >>");
ModelAndView responseView = new ModelAndView(new JSONView());
try {
//getting selected Page No.
int selectedPage = Integer.parseInt(req.getParameter("pageNo"));
boolean forceVerify = Boolean.parseBoolean(req.getParameter("force_verify"));
HttpSession session = req.getSession();
@SuppressWarnings("unchecked") Map<Integer, List<HostDetailsEntityVO>> //getting Map view of all Host stored into session while calling getDashBoardData().
mapOfData = (Map<Integer, List<HostDetailsEntityVO>>) session.getAttribute("HostVoList");
//calling into a Service layer to get trust status of Host for selected Page No.
responseView.addObject("hostVo", demoPortalServices.getTrustStatusForHost(mapOfData.get(selectedPage), getAttestationService(req, AttestationService.class), getTrustedCertificates(req), forceVerify));
responseView.addObject("noOfPages", mapOfData.size());
} catch (Exception e) {
log.error(e.toString());
e.printStackTrace();
responseView.addObject("hostVo", "");
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
return responseView;
}
responseView.addObject("result", true);
responseView.addObject("message", "");
log.info("DemoPortalDataController.getHostTrustSatusForPageNo <<");
return responseView;
}
use of com.intel.mountwilson.util.JSONView 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;
}
use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method deleteHostDetails.
/**
* @param req (HttpServletRequest Object)
* @param res (HttpServletResponse Object)
* @return
*/
public ModelAndView deleteHostDetails(HttpServletRequest req, HttpServletResponse res) {
log.info("DemoPortalDataController.deleteHostDetails >>");
ModelAndView responseView = new ModelAndView(new JSONView());
int selectedPage;
try {
selectedPage = Integer.parseInt(req.getParameter("selectedPageNo"));
boolean updateDone = demoPortalServices.deleteHostDetails(req.getParameter("hostID"), req.getParameter("hostName"), getAttestationService(req, AttestationService.class));
if (updateDone) {
Map<Integer, List<HostDetailsEntityVO>> mapOfData = getAllHostDetailsFromDB(req);
if (selectedPage > mapOfData.size()) {
selectedPage = mapOfData.size();
}
responseView.addObject("hostVo", mapOfData.get(selectedPage));
responseView.addObject("noOfPages", mapOfData.size());
responseView.addObject("result", updateDone);
} else {
log.error("Error Wile deleting OS Data. Server Error.");
responseView.addObject("result", false);
responseView.addObject("message", "Api Client return false.");
}
} catch (DemoPortalException e) {
log.error(e.toString());
e.printStackTrace();
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
return responseView;
}
responseView.addObject("message", "");
log.info("DemoPortalDataController.deleteHostDetails<<<");
return responseView;
}
use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method getAllHostForView.
/**
* Method to get Host list to for View Host page.
*
* @param req (HttpServletRequest Object)
* @param res (HttpServletResponse Object)
* @return
*/
public ModelAndView getAllHostForView(HttpServletRequest req, HttpServletResponse res) {
log.info("DemoPortalDataController.getAllHostForView >>");
Map<Integer, List<HostDetailsEntityVO>> map = null;
ModelAndView responseView = new ModelAndView(new JSONView());
try {
map = getAllHostDetailsFromDB(req);
responseView.addObject("hostVo", map.get(1));
responseView.addObject("noOfPages", map.size());
} catch (DemoPortalException e) {
log.error(e.toString());
e.printStackTrace();
responseView.addObject("hostVo", "");
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
return responseView;
}
responseView.addObject("result", true);
responseView.addObject("message", "");
log.info("DemoPortalDataController.getAllHostForView<<<");
return responseView;
}
use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method getHostTrustStatus.
/**
* @param req (HttpServletRequest Object)
* @param res (HttpServletResponse Object)
* @return
*/
public ModelAndView getHostTrustStatus(HttpServletRequest req, HttpServletResponse res) {
log.info("DemoPortalDataController.getHostTrustStatus >>");
ModelAndView responseView = new ModelAndView(new JSONView());
try {
boolean forceVerify = Boolean.parseBoolean(req.getParameter("force_verify"));
responseView.addObject("hostVo", demoPortalServices.getSingleHostTrust(req.getParameter("hostName"), getAttestationService(req, AttestationService.class), getTrustedCertificates(req), forceVerify));
} catch (DemoPortalException e) {
log.error("getHostTrustStatus: " + e.toString());
e.printStackTrace();
responseView.addObject("hostVo", "");
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
return responseView;
}
responseView.addObject("result", true);
responseView.addObject("message", "");
log.info("DemoPortalDataController.getHostTrustStatus <<<");
return responseView;
}
Aggregations