Search in sources :

Example 6 with HostDetailsEntityVO

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

the class DemoPortalDataController method saveNewHostInfo.

public ModelAndView saveNewHostInfo(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.saveNewHostInfo >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    String hostObject = null;
    boolean newhost = false;
    try {
        hostObject = req.getParameter("hostObject");
        newhost = Boolean.parseBoolean(req.getParameter("newhost"));
    } catch (Exception e1) {
        responseView.addObject("result", false);
        responseView.addObject("message", e1.getMessage());
    }
    System.out.println(hostObject);
    ObjectMapper mapper = new ObjectMapper();
    HostDetailsEntityVO dataVO = new HostDetailsEntityVO();
    try {
        dataVO = mapper.readValue(hostObject, HostDetailsEntityVO.class);
    } catch (JsonParseException e) {
        log.error("Error While Parsing request parameters Data. " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", "Error While Parsing request parameters Data.");
        return responseView;
    } catch (JsonMappingException e) {
        log.error("Error While Mapping request parameters to Mle Data Object. " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", "Error While Mapping request parameters to Mle Data Object.");
        return responseView;
    } catch (IOException e) {
        log.error("IO Exception " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", "Error While Mapping request parameters to Mle Data Object.");
        return responseView;
    }
    dataVO.setUpdatedOn(new Date(System.currentTimeMillis()));
    try {
        if (newhost) {
            System.err.println("dataForNew : " + dataVO);
            responseView.addObject("result", demoPortalServices.saveNewHostData(dataVO, getAttestationService(req, AttestationService.class)));
        } else {
            System.err.println("dataForOLD : " + dataVO);
            responseView.addObject("result", demoPortalServices.updateHostData(dataVO, getAttestationService(req, AttestationService.class)));
        }
    } catch (DemoPortalException e) {
        log.error(e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    log.info("WLMDataController.saveNewHostInfo <<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) ModelAndView(org.springframework.web.servlet.ModelAndView) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Date(java.util.Date)

Aggregations

HostDetailsEntityVO (com.intel.mountwilson.datamodel.HostDetailsEntityVO)6 DemoPortalException (com.intel.mountwilson.common.DemoPortalException)4 IOException (java.io.IOException)4 JSONView (com.intel.mountwilson.util.JSONView)3 HashMap (java.util.HashMap)3 List (java.util.List)3 HttpSession (javax.servlet.http.HttpSession)3 JsonParseException (org.codehaus.jackson.JsonParseException)3 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 Map (java.util.Map)2 TrustedHostVO (com.intel.mountwilson.datamodel.TrustedHostVO)1 ApiException (com.intel.mtwilson.ApiException)1 AttestationService (com.intel.mtwilson.AttestationService)1 HostTrustResponse (com.intel.mtwilson.datatypes.HostTrustResponse)1 TxtHostRecord (com.intel.mtwilson.datatypes.TxtHostRecord)1 TrustAssertion (com.intel.mtwilson.saml.TrustAssertion)1 HostTrustAssertion (com.intel.mtwilson.saml.TrustAssertion.HostTrustAssertion)1 Hostname (com.intel.mtwilson.util.net.Hostname)1 SignatureException (java.security.SignatureException)1