Search in sources :

Example 76 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method getHostForViewForPage.

/**
	 * Method to get Host list to for View Host Page for given page no.
	 * 
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView getHostForViewForPage(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.getHostForViewForPage >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        int selectedPage = Integer.parseInt(req.getParameter("pageNo"));
        HttpSession session = req.getSession();
        @SuppressWarnings("unchecked") Map<Integer, List<HostDetailsEntityVO>> mapOfData = (Map<Integer, List<HostDetailsEntityVO>>) session.getAttribute("HostVoList");
        responseView.addObject("hostVo", mapOfData.get(selectedPage));
    } 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.getHostForViewForPage<<<");
    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 77 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project OpenAttestation by OpenAttestation.

the class WLMDataController method logOutUser.

public ModelAndView logOutUser(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.logOutUser >>");
    ModelAndView responseView = new ModelAndView("Login");
    try {
        HttpSession session = req.getSession(false);
        if (session != null) {
            session.invalidate();
        }
    //res.sendRedirect(req.getContextPath()+"/login.htm");
    } catch (Exception e) {
        log.error(e.toString());
        e.printStackTrace();
    }
    log.info("WLMDataController.logOutUser <<");
    return responseView;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ModelAndView(org.springframework.web.servlet.ModelAndView) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 78 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project OpenAttestation by OpenAttestation.

the class WLMDataController method updateOEMData.

public ModelAndView updateOEMData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.updateOEMData >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    int selectedPage;
    try {
        selectedPage = Integer.parseInt(req.getParameter("selectedPageNo"));
        OEMDataVO dataVONew = new OEMDataVO();
        dataVONew.setOemName(req.getParameter("oemName"));
        dataVONew.setOemDescription(req.getParameter("inputDec"));
        boolean updateDone = oemClientService.updateOEMInfo(dataVONew, getWhitelistService(req));
        if (updateDone) {
            Map<Integer, List<OEMDataVO>> mapOfData = getPartitionListOfAllOEM(req);
            responseView.addObject("OEMDataVo", mapOfData.get(selectedPage));
            responseView.addObject("noOfPages", mapOfData.size());
            responseView.addObject("result", updateDone);
        }
    } catch (Exception e) {
        log.error("Error Wile Editing OEM Data. Root cause " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
    }
    log.info("WLMDataController.updateOEMData <<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) List(java.util.List) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException) OEMDataVO(com.intel.mountwilson.datamodel.OEMDataVO)

Example 79 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project OpenAttestation by OpenAttestation.

the class WLMDataController method addOEMData.

public ModelAndView addOEMData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.addOEMData>>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        OEMDataVO dataVONew = new OEMDataVO();
        dataVONew.setOemName(req.getParameter("oemName"));
        dataVONew.setOemDescription(req.getParameter("oemDescription"));
        System.out.println("New OEM data >>> " + dataVONew.toString());
        responseView.addObject("result", oemClientService.addOEMInfo(dataVONew, getWhitelistService(req)));
    } catch (WLMPortalException e) {
        log.error("Error Wile Adding OEM Data. Root cause " + e.getStackTrace());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
    }
    log.info("WLMDataController.addOEMData <<<");
    return responseView;
}
Also used : WLMPortalException(com.intel.mountwilson.common.WLMPortalException) JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) OEMDataVO(com.intel.mountwilson.datamodel.OEMDataVO)

Example 80 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project OpenAttestation by OpenAttestation.

the class WLMDataController method getHostOSForVMM.

public ModelAndView getHostOSForVMM(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getHostOSForVMM >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    List<VmmHostDataVo> list = new ArrayList<VmmHostDataVo>();
    VmmHostDataVo dataVo = null;
    List<String> VmmNames = getVMMNameList(WLMPConfig.getConfiguration().getString("mtwilson.wlmp.openSourceHypervisors"));
    try {
        List<OSDataVO> osList = osClientService.getAllOS(getWhitelistService(req));
        for (OSDataVO osDataVO : osList) {
            dataVo = new VmmHostDataVo();
            dataVo.setHostOS(osDataVO.getOsName());
            dataVo.setHostVersion(osDataVO.getOsVersion());
            dataVo.setVmmNames(VmmNames);
            dataVo.setAttestationType("PCR");
            list.add(dataVo);
        }
    } catch (WLMPortalException e) {
        log.error("Error While getting Host OS Data for VMM. Root cause " + e.getStackTrace());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("HostList", list);
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("WLMDataController.getHostOSForVMM <<<");
    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) VmmHostDataVo(com.intel.mountwilson.datamodel.VmmHostDataVo) OSDataVO(com.intel.mountwilson.datamodel.OSDataVO)

Aggregations

ModelAndView (org.springframework.web.servlet.ModelAndView)1576 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)669 Test (org.junit.jupiter.api.Test)195 Test (org.junit.Test)188 HashMap (java.util.HashMap)166 ArrayList (java.util.ArrayList)140 RedirectView (org.springframework.web.servlet.view.RedirectView)90 Map (java.util.Map)85 List (java.util.List)69 IOException (java.io.IOException)62 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)60 Date (java.util.Date)57 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)49 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)49 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)47 GetMapping (org.springframework.web.bind.annotation.GetMapping)45 HandlerMethod (org.springframework.web.method.HandlerMethod)45 IPerson (org.apereo.portal.security.IPerson)43 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)35