Search in sources :

Example 71 with ModelAndView

use of org.springframework.web.servlet.ModelAndView 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)

Example 72 with ModelAndView

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

the class WLMDataController method getViewMle.

/*
	 * Method to get All MLE Data for Pagination
	 */
public ModelAndView getViewMle(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getViewMle >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        Map<Integer, List<MLEDataVO>> map = getPartitionListOfAllMle(req);
        responseView.addObject("MLEDataVo", map.get(1));
        responseView.addObject("noOfPages", map.size());
    } catch (WLMPortalException e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("MLEDataVo", "");
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("WLMDataController.getViewMle <<");
    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)

Example 73 with ModelAndView

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

the class WLMDataController method getWhiteListForMle.

public ModelAndView getWhiteListForMle(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getWhiteListForMle>>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    MLEDataVO dataVO = new MLEDataVO();
    try {
        dataVO.setMleName(req.getParameter("mleName"));
        dataVO.setMleVersion(req.getParameter("mleVersion"));
        dataVO.setAttestation_Type(req.getParameter("attestation_Type"));
        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.");
    }
    log.info("WLMDataController.getWhiteListForMle <<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) MLEDataVO(com.intel.mountwilson.datamodel.MLEDataVO) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 74 with ModelAndView

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

the class WLMDataController method getAllOEMList.

/*Methods to get data for pagination for OEM Component */
public ModelAndView getAllOEMList(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getAllOEMList >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        Map<Integer, List<OEMDataVO>> map = getPartitionListOfAllOEM(req);
        responseView.addObject("OEMDataVo", map.get(1));
        responseView.addObject("noOfPages", map.size());
    } catch (WLMPortalException 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.getAllOEMList <<");
    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)

Example 75 with ModelAndView

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

the class DemoPortalDataController method getOSVMMInfo.

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

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