Search in sources :

Example 26 with JSONView

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

the class DemoPortalDataController method getAllOemInfo.

/**
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView getAllOemInfo(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.getAllOemInfo >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        responseView.addObject("oemInfo", demoPortalServices.getAllOemInfo(getAttestationService(req, ApiClient.class)));
    } catch (DemoPortalException e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("oemInfo", "");
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("DemoPortalDataController.getAllOemInfo <<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 27 with JSONView

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

the class DemoPortalDataController method getInfoForHostID.

/**
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView getInfoForHostID(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.getInfoForHostID >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        String hostName = req.getParameter("hostName");
        responseView.addObject("hostData", demoPortalServices.getSingleHostDetailFromDB(hostName, getAttestationService(req, AttestationService.class)));
    } catch (Exception e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("oemInfo", "");
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("DemoPortalDataController.getInfoForHostID <<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 28 with JSONView

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

the class DemoPortalDataController method getDashBoardData.

/**
	 * Method is used to get Trust Status for Hosts to show on Home Screen.
	 * 
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView getDashBoardData(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.getDashBoardData >>");
    Map<Integer, List<HostDetailsEntityVO>> map = null;
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        boolean forceVerify = Boolean.parseBoolean(req.getParameter("force_verify"));
        //Get map view for All Host based on the value of Page_NO(this values is available from TDPConfig) 
        map = getAllHostDetailsFromDB(req);
        //calling into a Service layer to get trust status for Host on Page No 1(using map.get(1)).
        //responseView.addObject("hostVo",demoPortalServices.getTrustStatusForHost(map.get(1),getAttestationService(req,AttestationService.class),getTrustedCertificates(req)));
        responseView.addObject("hostVo", demoPortalServices.getTrustStatusForHost(map.get(1), getAttestationService(req, AttestationService.class), getTrustedCertificates(req), forceVerify));
        //setting no of page required to show all Host data while applying pagination in JSP
        responseView.addObject("noOfPages", map.size());
    } catch (Exception e) {
        log.error("getDashBoardData exception: " + e.toString());
        responseView.addObject("hostVo", "");
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        if (e.getMessage().toLowerCase().contains("currently there are no hosts configured")) {
            responseView.addObject("noHosts", true);
        }
        return responseView;
    }
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("DemoPortalDataController.getDashBoardData <<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 29 with JSONView

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

the class WLMDataController method getViewOEMForPageNo.

@SuppressWarnings("unchecked")
public ModelAndView getViewOEMForPageNo(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getViewOEMForPageNo >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        HttpSession session = req.getSession();
        Map<Integer, List<MLEDataVO>> map = (Map<Integer, List<MLEDataVO>>) session.getAttribute("OEMList");
        responseView.addObject("OEMDataVo", map.get(Integer.parseInt(req.getParameter("pageNo"))));
    } catch (Exception e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("OEMDataVo", "");
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("WLMDataController.getViewOEMForPageNo <<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) HttpSession(javax.servlet.http.HttpSession) ModelAndView(org.springframework.web.servlet.ModelAndView) MLEDataVO(com.intel.mountwilson.datamodel.MLEDataVO) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 30 with JSONView

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

the class WLMDataController method getAddMle.

@SuppressWarnings("serial")
public ModelAndView getAddMle(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getAddMle>>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    String mleOb = null;
    boolean newMle = false;
    try {
        mleOb = req.getParameter("mleObject");
        newMle = Boolean.parseBoolean(req.getParameter("newMle"));
    } catch (Exception e1) {
        log.error("Error While in request parameters Data. " + e1.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", "Error While request parameters are Null. Please check.");
    }
    System.out.println(mleOb);
    MLEDataVO dataVO = new MLEDataVO();
    try {
        Type mleDataType = new TypeToken<MLEDataVO>() {
        }.getType();
        dataVO = new Gson().fromJson(mleOb, mleDataType);
        for (Map<String, String> manifestMap : dataVO.getManifestList()) {
            for (Entry<String, String> manifest : manifestMap.entrySet()) {
                manifest.setValue(manifest.getValue().toUpperCase());
            }
        }
        System.out.println("dataVo >>" + dataVO);
        if (newMle) {
            responseView.addObject("result", mleClientService.addMLEInfo(dataVO, getWhitelistService(req)));
        } else {
            responseView.addObject("result", mleClientService.updateMLEInfo(dataVO, getWhitelistService(req)));
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    log.info("WLMDataController.getAddMle <<<");
    return responseView;
}
Also used : Type(java.lang.reflect.Type) JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) Gson(com.google.gson.Gson) MLEDataVO(com.intel.mountwilson.datamodel.MLEDataVO) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

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