Search in sources :

Example 1 with MLEDataVO

use of com.intel.mountwilson.datamodel.MLEDataVO 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 2 with MLEDataVO

use of com.intel.mountwilson.datamodel.MLEDataVO in project OpenAttestation by OpenAttestation.

the class WLMDataController method getPartitionListOfAllMle.

/**
	 * Method to get a Map View for all MLE data from REST Services according to there page no.
	 * Return data is used in pagination.
	 * 
	 * @param req object of HttpServletRequest
	 * @return
	 * @throws WLMPortalException
	 */
private Map<Integer, List<MLEDataVO>> getPartitionListOfAllMle(HttpServletRequest req) throws WLMPortalException {
    Map<Integer, List<MLEDataVO>> map = new HashMap<Integer, List<MLEDataVO>>();
    //Get List of all MLE.
    List<MLEDataVO> dataVOs = mleClientService.getAllMLE(getWhitelistService(req));
    int no_row_per_page = WLMPConfig.getConfiguration().getInt("mtwilson.wlmp.pagingSize");
    //Divide List of all MLE into a subList based on the value of host per page.
    List<List<MLEDataVO>> list = Lists.partition(dataVOs, no_row_per_page);
    //Creating a Map view of MLE list based on the Page No.
    int i = 1;
    for (List<MLEDataVO> listForMap : list) {
        map.put(i, listForMap);
        i++;
    }
    //setting map into session attribute;
    HttpSession session = req.getSession();
    session.setAttribute("MleList", map);
    return map;
}
Also used : HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) MLEDataVO(com.intel.mountwilson.datamodel.MLEDataVO) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with MLEDataVO

use of com.intel.mountwilson.datamodel.MLEDataVO in project OpenAttestation by OpenAttestation.

the class WLMDataController method getViewOSForPageNo.

@SuppressWarnings("unchecked")
public ModelAndView getViewOSForPageNo(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getViewOSForPageNo >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        HttpSession session = req.getSession();
        Map<Integer, List<MLEDataVO>> map = (Map<Integer, List<MLEDataVO>>) session.getAttribute("OSList");
        responseView.addObject("OSDataVo", map.get(Integer.parseInt(req.getParameter("pageNo"))));
    } catch (Exception e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("OSDataVo", "");
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("WLMDataController.getViewOSForPageNo <<");
    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 4 with MLEDataVO

use of com.intel.mountwilson.datamodel.MLEDataVO in project OpenAttestation by OpenAttestation.

the class WLMDataController method deleteMLEData.

public ModelAndView deleteMLEData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.deleteMLEData>>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    MLEDataVO dataVO = new MLEDataVO();
    int selectedPage;
    try {
        selectedPage = Integer.parseInt(req.getParameter("selectedPageNo"));
        dataVO.setMleName(req.getParameter("mleName"));
        dataVO.setMleVersion(req.getParameter("mleVersion"));
        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.");
        return responseView;
    }
    try {
        boolean deleteDone = mleClientService.deleteMLE(dataVO, getWhitelistService(req));
        if (deleteDone) {
            Map<Integer, List<MLEDataVO>> mapOfData = getPartitionListOfAllMle(req);
            if (selectedPage > mapOfData.size()) {
                selectedPage = mapOfData.size();
            }
            responseView.addObject("MLEDataVo", mapOfData.get(selectedPage));
            responseView.addObject("noOfPages", mapOfData.size());
            responseView.addObject("result", true);
        }
    } catch (WLMPortalException e) {
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        log.error(e.toString());
        return responseView;
    }
    log.info("WLMDataController.deleteMLEData <<<");
    return responseView;
}
Also used : WLMPortalException(com.intel.mountwilson.common.WLMPortalException) JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) MLEDataVO(com.intel.mountwilson.datamodel.MLEDataVO) ArrayList(java.util.ArrayList) List(java.util.List) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 5 with MLEDataVO

use of com.intel.mountwilson.datamodel.MLEDataVO 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)

Aggregations

MLEDataVO (com.intel.mountwilson.datamodel.MLEDataVO)10 WLMPortalException (com.intel.mountwilson.common.WLMPortalException)8 JSONView (com.intel.mountwilson.util.JSONView)7 FileUploadException (org.apache.commons.fileupload.FileUploadException)7 ModelAndView (org.springframework.web.servlet.ModelAndView)7 ArrayList (java.util.ArrayList)5 List (java.util.List)5 HashMap (java.util.HashMap)4 HttpSession (javax.servlet.http.HttpSession)4 Map (java.util.Map)3 Gson (com.google.gson.Gson)1 MLESearchCriteria (com.intel.mtwilson.datatypes.MLESearchCriteria)1 Type (java.lang.reflect.Type)1