Search in sources :

Example 6 with MLEDataVO

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

the class WLMDataController method getAddMle.

@SuppressWarnings("serial")
public ModelAndView getAddMle(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getAddMle>>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    String mleOb = null;
    boolean newMle = false;
    try {
        mleOb = req.getParameter("mleObject");
        newMle = Boolean.parseBoolean(req.getParameter("newMle"));
    } catch (Exception e1) {
        log.error("Error While in request parameters Data. " + e1.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", "Error While request parameters are Null. Please check.");
    }
    System.out.println(mleOb);
    MLEDataVO dataVO = new MLEDataVO();
    try {
        Type mleDataType = new TypeToken<MLEDataVO>() {
        }.getType();
        dataVO = new Gson().fromJson(mleOb, mleDataType);
        for (Map<String, String> manifestMap : dataVO.getManifestList()) {
            for (Entry<String, String> manifest : manifestMap.entrySet()) {
                manifest.setValue(manifest.getValue().toUpperCase());
            }
        }
        System.out.println("dataVo >>" + dataVO);
        if (newMle) {
            responseView.addObject("result", mleClientService.addMLEInfo(dataVO, getWhitelistService(req)));
        } else {
            responseView.addObject("result", mleClientService.updateMLEInfo(dataVO, getWhitelistService(req)));
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    log.info("WLMDataController.getAddMle <<<");
    return responseView;
}
Also used : Type(java.lang.reflect.Type) JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) Gson(com.google.gson.Gson) MLEDataVO(com.intel.mountwilson.datamodel.MLEDataVO) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 7 with MLEDataVO

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

the class WLMDataController method getViewMleForPageNo.

@SuppressWarnings("unchecked")
public ModelAndView getViewMleForPageNo(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getViewMleForPageNo >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        HttpSession session = req.getSession();
        Map<Integer, List<MLEDataVO>> map = (Map<Integer, List<MLEDataVO>>) session.getAttribute("MleList");
        responseView.addObject("MLEDataVo", map.get(Integer.parseInt(req.getParameter("pageNo"))));
    } catch (Exception 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.getViewMleForPageNo <<");
    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 8 with MLEDataVO

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

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

the class ConverterUtil method getMleDataVoObject.

public static MLEDataVO getMleDataVoObject(MleData data) {
    MLEDataVO mleVo = new MLEDataVO();
    mleVo.setMleName(data.getName());
    mleVo.setMleVersion(data.getVersion());
    mleVo.setMleDescription(data.getDescription());
    mleVo.setOsName(data.getOsName());
    mleVo.setOsVersion(data.getOsVersion());
    mleVo.setAttestation_Type(data.getAttestationType());
    mleVo.setOemName(data.getOemName());
    mleVo.setManifestList(getManifestListFromApiClient(data.getManifestList()));
    mleVo.setMleType(data.getMleType());
    return mleVo;
}
Also used : MLEDataVO(com.intel.mountwilson.datamodel.MLEDataVO)

Example 10 with MLEDataVO

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

the class MLEClientServiceImpl method getSingleMleData.

/**
	 * Method to get Single MLE Details from a rest services.
	 * 
	 * @param dataVO
	 * @param apiClientServices
	 * @return
	 * @throws WLMPortalException
	 */
@Override
public MLEDataVO getSingleMleData(MLEDataVO dataVO, WhitelistService apiClientServices) throws WLMPortalException {
    log.info("MLEClientServiceImpl.getSingleMleData >>");
    MLEDataVO mleObject = null;
    try {
        MLESearchCriteria criteria = new MLESearchCriteria();
        criteria.mleName = dataVO.getMleName();
        criteria.mleVersion = dataVO.getMleVersion();
        if (dataVO.getOemName() != null) {
            criteria.oemName = dataVO.getOemName();
            criteria.osName = "";
            criteria.osVersion = "";
        } else {
            criteria.osName = dataVO.getOsName();
            criteria.osVersion = dataVO.getOsVersion();
            criteria.oemName = "";
        }
        mleObject = ConverterUtil.getMleDataVoObject(apiClientServices.getMLEManifest(criteria));
    } catch (Exception e) {
        throw ConnectionUtil.handleException(e);
    }
    log.info("MLEClientServiceImpl.getSingleMleData <<");
    return mleObject;
}
Also used : MLEDataVO(com.intel.mountwilson.datamodel.MLEDataVO) WLMPortalException(com.intel.mountwilson.common.WLMPortalException) MLESearchCriteria(com.intel.mtwilson.datatypes.MLESearchCriteria)

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