Search in sources :

Example 1 with JSONView

use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method getHostsReport.

/**
	 * Method to Bulk Update trust status for selected host.
	 * 
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView getHostsReport(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.getHostsReport >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    String[] list = req.getParameterValues("selectedHost");
    if (list == null) {
        responseView.addObject("message", "No hosts were selected for reports.");
        log.info("DemoPortalDataController.getHostsReport<<<");
        return responseView;
    }
    List<String> hosts = Arrays.asList(list);
    try {
        responseView.addObject("reports", demoPortalServices.getHostTrustReport(hosts, getAttestationService(req, ApiClient.class)));
        responseView.addObject("result", true);
    } catch (DemoPortalException e) {
        log.error(e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("message", "");
    log.info("DemoPortalDataController.getHostsReport<<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 2 with JSONView

use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method trustVerificationDetailsXML.

/**
	 * Method to get Trust Verification Details using SAML.
	 * 
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView trustVerificationDetailsXML(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.trustVerificationDetailsXML >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    String hostName = req.getParameter("hostName");
    try {
        responseView.addObject("trustSamlDetails", demoPortalServices.trustVerificationDetails(hostName, getAttestationService(req, AttestationService.class), getTrustedCertificates(req)));
        responseView.addObject("hostName", hostName);
        responseView.addObject("result", true);
    } catch (DemoPortalException e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        e.printStackTrace();
        return responseView;
    }
    responseView.addObject("message", "");
    responseView.addObject("result", true);
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 3 with JSONView

use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.

the class WLMDataController method addOSData.

/**
	 * Method to add OS Data into REST Services.
	 * 
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView addOSData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.addOSData >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        OSDataVO dataVONew = new OSDataVO();
        //Getting OS data from request parameter
        dataVONew.setOsName(req.getParameter("osName"));
        dataVONew.setOsVersion(req.getParameter("osVersion"));
        dataVONew.setOsDescription(req.getParameter("osDescription"));
        //Calling into Service Layer(OSClientServiceImpl) to add OS Data.
        responseView.addObject("result", osClientService.addOSInfo(dataVONew, getWhitelistService(req)));
    } catch (WLMPortalException e) {
        log.error("Error Wile Adding OS Data. Root cause " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
    }
    log.info("WLMDataController.addOSData <<<");
    return responseView;
}
Also used : WLMPortalException(com.intel.mountwilson.common.WLMPortalException) JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) OSDataVO(com.intel.mountwilson.datamodel.OSDataVO)

Example 4 with JSONView

use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.

the class WLMDataController method getUploadedMenifestFile.

public ModelAndView getUploadedMenifestFile(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getUploadedMenifestFile >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    Object manifest = req.getSession().getAttribute("manifestValue");
    boolean result = false;
    if (manifest != null) {
        result = true;
        responseView.addObject("manifestValue", manifest);
    }
    responseView.addObject("result", result);
    log.info("WLMDataController.getUploadedMenifestFile <<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 5 with JSONView

use of com.intel.mountwilson.util.JSONView in project OpenAttestation by OpenAttestation.

the class WLMDataController method deleteOSData.

/**
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView deleteOSData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.deleteOSData >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    int selectedPage;
    try {
        selectedPage = Integer.parseInt(req.getParameter("selectedPageNo"));
        OSDataVO dataVONew = new OSDataVO();
        dataVONew.setOsName(req.getParameter("osName"));
        dataVONew.setOsVersion(req.getParameter("osVer"));
        dataVONew.setOsDescription(req.getParameter("inputDec"));
        boolean updateDone = osClientService.deleteOS(dataVONew, getWhitelistService(req));
        if (updateDone) {
            Map<Integer, List<OSDataVO>> mapOfData = getPartitionListOfAllOS(req);
            if (selectedPage > mapOfData.size()) {
                selectedPage = mapOfData.size();
            }
            responseView.addObject("OSDataVo", 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 (WLMPortalException e) {
        log.error("Error Wile deleting OS Data. Root cause " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
    }
    log.info("WLMDataController.deleteOSData <<<");
    return responseView;
}
Also used : WLMPortalException(com.intel.mountwilson.common.WLMPortalException) JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) List(java.util.List) OSDataVO(com.intel.mountwilson.datamodel.OSDataVO)

Aggregations

JSONView (com.intel.mountwilson.util.JSONView)34 ModelAndView (org.springframework.web.servlet.ModelAndView)34 WLMPortalException (com.intel.mountwilson.common.WLMPortalException)19 List (java.util.List)16 DemoPortalException (com.intel.mountwilson.common.DemoPortalException)13 ArrayList (java.util.ArrayList)13 FileUploadException (org.apache.commons.fileupload.FileUploadException)10 MLEDataVO (com.intel.mountwilson.datamodel.MLEDataVO)7 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 JsonParseException (org.codehaus.jackson.JsonParseException)6 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)6 HttpSession (javax.servlet.http.HttpSession)5 OEMDataVO (com.intel.mountwilson.datamodel.OEMDataVO)4 OSDataVO (com.intel.mountwilson.datamodel.OSDataVO)4 HostDetailsEntityVO (com.intel.mountwilson.datamodel.HostDetailsEntityVO)3 Gson (com.google.gson.Gson)1 VmmHostDataVo (com.intel.mountwilson.datamodel.VmmHostDataVo)1 AttestationService (com.intel.mtwilson.AttestationService)1