Search in sources :

Example 11 with WLMPortalException

use of com.intel.mountwilson.common.WLMPortalException 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 12 with WLMPortalException

use of com.intel.mountwilson.common.WLMPortalException in project OpenAttestation by OpenAttestation.

the class WLMDataController method getWhitelistService.

/**
     * This method will return a WhitelistService Object from a Session.
     * This object is stored into Session at time of user login.
     * Check CheckLoginController.java for more Clarification.
     * 
     * @param req
     * @return
     * @throws WLMPortalException
     */
private WhitelistService getWhitelistService(HttpServletRequest req) throws WLMPortalException {
    //getting already created session object by passing false while calling into getSession();
    HttpSession session = req.getSession(false);
    WhitelistService service = null;
    if (session != null) {
        try {
            //getting WhitelistService Object from Session, stored while log-in time.  
            service = (WhitelistService) session.getAttribute("apiClientObject");
        } catch (Exception e) {
            log.error("Error while creating ApiCliennt Object. " + e.getMessage());
            throw new WLMPortalException("Error while creating ApiCliennt Object. " + e.getMessage(), e);
        }
    }
    return service;
}
Also used : WhitelistService(com.intel.mtwilson.WhitelistService) WLMPortalException(com.intel.mountwilson.common.WLMPortalException) HttpSession(javax.servlet.http.HttpSession) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 13 with WLMPortalException

use of com.intel.mountwilson.common.WLMPortalException in project OpenAttestation by OpenAttestation.

the class WLMDataController method getAllOSList.

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

use of com.intel.mountwilson.common.WLMPortalException in project OpenAttestation by OpenAttestation.

the class WLMDataController method viewSingleMLEData.

public ModelAndView viewSingleMLEData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.viewSingleMLEData>>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    MLEDataVO dataVO = new MLEDataVO();
    MLEDataVO detailMLEVO = null;
    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.");
    }
    try {
        // TODO: Had to temporarily store the detailed MLE object so that it can be reused to retrieve the mleSource details.
        // The MleData object expects the MLE_Type detail to be present to get the OS/OEM details. Need to fix this
        detailMLEVO = mleClientService.getSingleMleData(dataVO, getWhitelistService(req));
        responseView.addObject("dataVo", detailMLEVO);
        responseView.addObject("result", true);
    } catch (WLMPortalException e) {
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        log.error(e.toString());
    }
    // was used for white listing this MLE.
    try {
        responseView.addObject("mleSource", mleClientService.getMleSourceHost(detailMLEVO, getWhitelistService(req)));
    } catch (WLMPortalException e) {
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        log.error(e.toString());
    }
    log.info("WLMDataController.viewSingleMLEData <<<");
    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) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 15 with WLMPortalException

use of com.intel.mountwilson.common.WLMPortalException in project OpenAttestation by OpenAttestation.

the class MLEClientServiceImpl method getMleSourceHost.

/**
         * Retries the name of the host that was used for white listing the MLE.
         * 
         * @param dataVO : Object containing the details of the MLE for which the host information needs to be retrieved.
         * @param apiClientServices: ApiClient object
         * @return : Name of the host
         * @throws WLMPortalException 
         */
@Override
public String getMleSourceHost(MLEDataVO dataVO, WhitelistService apiClientServices) throws WLMPortalException {
    log.info("MLEClientServiceImpl.getMleSourceHost >>");
    String hostName;
    try {
        MleData mleDataObj = ConverterUtil.getMleApiClientObject(dataVO);
        if (dataVO.getOemName() != null) {
            mleDataObj.setOemName(dataVO.getOemName());
            mleDataObj.setOsName("");
            mleDataObj.setOsVersion("");
        } else {
            mleDataObj.setOsName(dataVO.getOsName());
            mleDataObj.setOsVersion(dataVO.getOsVersion());
            mleDataObj.setOemName("");
        }
        hostName = apiClientServices.getMleSource(mleDataObj);
    } catch (Exception e) {
        throw ConnectionUtil.handleException(e);
    }
    log.info("MLEClientServiceImpl.getMleSourceHost <<");
    return hostName;
}
Also used : MleData(com.intel.mtwilson.datatypes.MleData) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Aggregations

WLMPortalException (com.intel.mountwilson.common.WLMPortalException)17 JSONView (com.intel.mountwilson.util.JSONView)11 ModelAndView (org.springframework.web.servlet.ModelAndView)11 ArrayList (java.util.ArrayList)7 List (java.util.List)6 OSDataVO (com.intel.mountwilson.datamodel.OSDataVO)4 MLEDataVO (com.intel.mountwilson.datamodel.MLEDataVO)3 FileUploadException (org.apache.commons.fileupload.FileUploadException)3 OEMDataVO (com.intel.mountwilson.datamodel.OEMDataVO)2 MLESearchCriteria (com.intel.mtwilson.datatypes.MLESearchCriteria)2 OemData (com.intel.mtwilson.datatypes.OemData)2 VmmHostDataVo (com.intel.mountwilson.datamodel.VmmHostDataVo)1 WhitelistService (com.intel.mtwilson.WhitelistService)1 MleData (com.intel.mtwilson.datatypes.MleData)1 HttpSession (javax.servlet.http.HttpSession)1