Search in sources :

Example 21 with JSONView

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;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) HttpSession(javax.servlet.http.HttpSession) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 22 with JSONView

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;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) ModelAndView(org.springframework.web.servlet.ModelAndView) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Date(java.util.Date)

Example 23 with JSONView

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;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) AttestationService(com.intel.mtwilson.AttestationService) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 24 with JSONView

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;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 25 with JSONView

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;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

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