use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.
the class WLMDataController method updateOSData.
/**
* Method to Update previously add OS Data into a REST Services.
*
*@param req (HttpServletRequest Object)
* @param res (HttpServletResponse Object)
* @return
*/
public ModelAndView updateOSData(HttpServletRequest req, HttpServletResponse res) {
log.info("WLMDataController.updateOSData >>");
ModelAndView responseView = new ModelAndView(new JSONView());
int selectedPage;
try {
//Get Current select page no used in pagination.
selectedPage = Integer.parseInt(req.getParameter("selectedPageNo"));
//Get updated OS data from req object and create OSDataVO Object from it.
OSDataVO dataVONew = new OSDataVO();
dataVONew.setOsName(req.getParameter("osName"));
dataVONew.setOsVersion(req.getParameter("osVer"));
dataVONew.setOsDescription(req.getParameter("inputDec"));
//Calling into Service Layer(OSClientServiceImpl) to update OS Data.
boolean updateDone = osClientService.updateOSInfo(dataVONew, getWhitelistService(req));
// Once OS data is updated, get List of all OS for a current page to show while pagination.
if (updateDone) {
//Get map view of OS data from Services based on there page no.
Map<Integer, List<OSDataVO>> mapOfData = getPartitionListOfAllOS(req);
responseView.addObject("OSDataVo", mapOfData.get(selectedPage));
responseView.addObject("noOfPages", mapOfData.size());
responseView.addObject("result", updateDone);
} else {
log.error("Error Wile Editing OS Data. Api Client return false.");
responseView.addObject("result", false);
responseView.addObject("message", "Error Wile Editing OS Data. Api Client return false.");
}
} catch (WLMPortalException e) {
log.error("Error Wile Editing OS Data. Root cause " + e.getMessage());
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
}
log.info("WLMDataController.updateOSData <<<");
return responseView;
}
use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.
the class WLMDataController method getHostOSForBios.
public ModelAndView getHostOSForBios(HttpServletRequest req, HttpServletResponse res) {
log.info("WLMDataController.getHostOSForBios >>");
ModelAndView responseView = new ModelAndView(new JSONView());
List<OEMDataVO> list = null;
try {
list = oemClientService.getAllOEM(getWhitelistService(req));
responseView.addObject("result", true);
} catch (WLMPortalException e) {
log.error("Error While getting Host OS Data for BIOS. Root cause " + e.getStackTrace());
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
}
responseView.addObject("HostList", list);
responseView.addObject("message", "");
log.info("WLMDataController.getHostOSForBios <<<");
return responseView;
}
use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.
the class WLMDataController method uploadManifest.
public ModelAndView uploadManifest(HttpServletRequest req, HttpServletResponse res) {
log.info("WLMDataController.uploadManifest >>");
req.getSession().removeAttribute("manifestValue");
ModelAndView responseView = new ModelAndView(new JSONView());
List<Map<String, String>> manifestValue = new ArrayList<Map<String, String>>();
// Check that we have a file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(req);
System.out.println(isMultipart);
if (!isMultipart) {
responseView.addObject("result", false);
return responseView;
}
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Parse the request
try {
@SuppressWarnings("unchecked") List<FileItem> items = upload.parseRequest(req);
// Process the uploaded items
Iterator<FileItem> iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (!item.isFormField()) {
String[] lines = item.getString().split("\\r?\\n");
for (String values : lines) {
if (values.length() > 2) {
String[] val = values.split(":");
if (val.length == 2) {
Map<String, String> manifest = new HashMap<String, String>();
manifest.put(val[0], val[1]);
manifestValue.add(manifest);
} else {
responseView.addObject("result", false);
return responseView;
}
}
}
}
}
log.info("Uploaded Content :: " + manifestValue.toString());
req.getSession().setAttribute("manifestValue", manifestValue);
/*responseView.addObject("manifestValue",manifestValue);*/
responseView.addObject("result", manifestValue.size() > 0 ? true : false);
} catch (FileUploadException e) {
e.printStackTrace();
responseView.addObject("result", false);
} catch (Exception e) {
e.printStackTrace();
responseView.addObject("result", false);
}
log.info("WLMDataController.uploadManifest <<<");
return responseView;
}
use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.
the class WLMDataController method deleteMLEData.
public ModelAndView deleteMLEData(HttpServletRequest req, HttpServletResponse res) {
log.info("WLMDataController.deleteMLEData>>");
ModelAndView responseView = new ModelAndView(new JSONView());
MLEDataVO dataVO = new MLEDataVO();
int selectedPage;
try {
selectedPage = Integer.parseInt(req.getParameter("selectedPageNo"));
dataVO.setMleName(req.getParameter("mleName"));
dataVO.setMleVersion(req.getParameter("mleVersion"));
String mleType = req.getParameter("mleType");
if (mleType != null && mleType.equalsIgnoreCase("VMM")) {
dataVO.setOsName(req.getParameter("osName"));
dataVO.setOsVersion(req.getParameter("osVersion"));
} else {
dataVO.setOemName(req.getParameter("oemName"));
}
} catch (Exception e) {
log.error("Error While in request parameters Data. " + e.getMessage());
responseView.addObject("result", false);
responseView.addObject("message", "Error While request parameters are Null. Please check.");
return responseView;
}
try {
boolean deleteDone = mleClientService.deleteMLE(dataVO, getWhitelistService(req));
if (deleteDone) {
Map<Integer, List<MLEDataVO>> mapOfData = getPartitionListOfAllMle(req);
if (selectedPage > mapOfData.size()) {
selectedPage = mapOfData.size();
}
responseView.addObject("MLEDataVo", mapOfData.get(selectedPage));
responseView.addObject("noOfPages", mapOfData.size());
responseView.addObject("result", true);
}
} catch (WLMPortalException e) {
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
log.error(e.toString());
return responseView;
}
log.info("WLMDataController.deleteMLEData <<<");
return responseView;
}
use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method getFailurereportForHost.
public ModelAndView getFailurereportForHost(HttpServletRequest req, HttpServletResponse res) {
log.info("DemoPortalDataController.getFailurereportForHost >>");
ModelAndView responseView = new ModelAndView(new JSONView());
try {
responseView.addObject("reportdata", demoPortalServices.getFailureReportData(req.getParameter("hostName"), getAttestationService(req, ApiClient.class)));
responseView.addObject("result", true);
} catch (Exception e) {
log.error(e.getMessage());
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
return responseView;
}
responseView.addObject("message", "");
log.info("DemoPortalDataController.getFailurereportForHost <<");
return responseView;
}
Aggregations