use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalServicesImpl method getFailureReportData.
/**
* This method is used to get failure report for Host.
*
* @param hostName
* @param attestationService
* @return
* @throws DemoPortalException
* @throws Exception
*/
@Override
public List<PcrLogReport> getFailureReportData(String hostName, ApiClient attestationService) throws Exception {
log.info("DemoPortalServicesImpl.getFailureReportData >>");
AttestationReport report;
try {
report = attestationService.getAttestationReport(new Hostname(hostName));
} catch (Exception e) {
log.error(e.getMessage());
throw ConnectionUtil.handleException(e);
}
return report.getPcrLogs();
}
use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalServicesImpl method updateHostData.
/**
* This method is used to Update Host information, which was already configure.
*
* @param dataVO
* @param apiClientServices
* @return
* @throws DemoPortalException
*/
@Override
public boolean updateHostData(HostDetailsEntityVO dataVO, AttestationService apiClientServices) throws DemoPortalException {
boolean result = false;
try {
//Call to Services to Update pre-configure host information.
apiClientServices.updateHost(ConverterUtil.getTxtHostFromHostVO(dataVO));
// Updating the SAML host report
apiClientServices.getSamlForHost(new Hostname(dataVO.getHostName()), true);
result = true;
} catch (Exception e) {
log.error("Errror While Updating Host.");
throw ConnectionUtil.handleException(e);
}
return result;
}
use of com.intel.mountwilson.common.DemoPortalException 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.common.DemoPortalException 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.common.DemoPortalException 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;
}
Aggregations