Search in sources :

Example 36 with HttpSession

use of javax.servlet.http.HttpSession in project MSEC by Tencent.

the class ReleaseStepsGO method doStep5.

private ReleaseStepsGOResponse doStep5(ReleasePlan request) {
    ReleaseStepsGOResponse response = new ReleaseStepsGOResponse();
    //把计划保存到session里
    HttpSession session = getHttpRequest().getSession();
    ReleasePlan plan = (ReleasePlan) session.getAttribute("plan");
    if (plan == null) {
        response.setMessage("can NOT find the session, it maybe timeout.");
        response.setStatus(100);
        return response;
    }
    //System.out.println("plan id in session:"+plan.getPlan_id());
    if (request.getSharedobject_tag() == null || request.getSharedobject_tag().length() < 1) {
        response.setMessage("idl tag is empty!");
        response.setStatus(100);
        return response;
    }
    plan.setSharedobject_tag(request.getSharedobject_tag());
    plan.setMemo(request.getMemo());
    //跳过第三步:选择IDL文件版本,所以在这里设置一下
    plan.setIdl_tag("");
    //check if saved
    ReleasePlan plan2 = (ReleasePlan) session.getAttribute("plan");
    //System.out.println("so tag:"+plan2.getSharedobject_tag());
    // Commit Plan
    String commitResult = CommitPlan(plan2);
    if (commitResult == null || !commitResult.equals("success")) {
        response.setMessage("commit failed:" + (commitResult == null ? "" : commitResult));
        response.setStatus(100);
        return response;
    }
    response.setPlanDetail(plan2);
    response.setMessage("success");
    response.setStatus(0);
    return response;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ReleaseStepsGOResponse(beans.response.ReleaseStepsGOResponse) ReleasePlan(beans.request.ReleasePlan)

Example 37 with HttpSession

use of javax.servlet.http.HttpSession in project MSEC by Tencent.

the class ReleaseStepsGO method doStep3.

private ReleaseStepsGOResponse doStep3(ReleasePlan request) {
    ReleaseStepsGOResponse response = new ReleaseStepsGOResponse();
    //把计划保存到session里
    HttpSession session = getHttpRequest().getSession();
    ReleasePlan plan = (ReleasePlan) session.getAttribute("plan");
    if (plan == null) {
        response.setMessage("can NOT find the session, it maybe timeout.");
        response.setStatus(100);
        return response;
    }
    //System.out.println("plan id in session:" + plan.getPlan_id());
    if (request.getIdl_tag() == null || request.getIdl_tag().length() < 1) {
        response.setMessage("idl tag is empty!");
        response.setStatus(100);
        return response;
    }
    plan.setIdl_tag(request.getIdl_tag());
    //check if saved
    ReleasePlan plan2 = (ReleasePlan) session.getAttribute("plan");
    //System.out.println("idl tag:" + plan2.getIdl_tag());
    response.setMessage("success");
    response.setStatus(0);
    return response;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ReleaseStepsGOResponse(beans.response.ReleaseStepsGOResponse) ReleasePlan(beans.request.ReleasePlan)

Example 38 with HttpSession

use of javax.servlet.http.HttpSession in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method getAttestationService.

/**
     * This method will return a AttestationService/ApiClient Object from a Session.
     * This object is stored into Session at time of user login.
     * Check CheckLoginController.java for more Clarification.
     * 
     * @param req
     * @return 
     * @return AttestationService
     * @throws DemoPortalException
     */
@SuppressWarnings("unchecked")
private <T> T getAttestationService(HttpServletRequest req, Class<T> type) throws DemoPortalException {
    //getting already created session object by passing false while calling into getSession();
    HttpSession session = req.getSession(false);
    T service = null;
    if (session != null) {
        try {
            //getting ApiClient Object from Session and downcast that object to Type T.  
            service = (T) session.getAttribute("apiClientObject");
        } catch (Exception e) {
            log.error("Error while creating ApiCliennt Object. " + e.getMessage());
            throw new DemoPortalException("Error while creating ApiCliennt Object. " + e.getMessage(), e);
        }
    }
    return service;
}
Also used : HttpSession(javax.servlet.http.HttpSession) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 39 with HttpSession

use of javax.servlet.http.HttpSession in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method getTrustedCertificates.

/**
     * This method will return a X509Certificate Object from a Request Session.
     * This object is stored into Session at time of user login.
     * Check CheckLoginController.java for more Clarification.
     * 
     * @param req
     * @return
     * @throws DemoPortalException
     */
private X509Certificate[] getTrustedCertificates(HttpServletRequest req) throws DemoPortalException {
    HttpSession session = req.getSession(false);
    X509Certificate[] trustedCertificate;
    if (session != null) {
        try {
            //getting Object from Session and downcast that object to X509Certificate. 
            trustedCertificate = (X509Certificate[]) session.getAttribute("trustedCertificates");
        } catch (Exception e) {
            log.error("Error while creating ApiCliennt Object. " + e.getMessage());
            throw new DemoPortalException("Error while creating ApiCliennt Object. " + e.getMessage(), e);
        }
    } else {
        return null;
    }
    return trustedCertificate;
}
Also used : HttpSession(javax.servlet.http.HttpSession) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) X509Certificate(java.security.cert.X509Certificate) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 40 with HttpSession

use of javax.servlet.http.HttpSession in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method getHostForViewForPage.

/**
	 * Method to get Host list to for View Host Page for given page no.
	 * 
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView getHostForViewForPage(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.getHostForViewForPage >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        int selectedPage = Integer.parseInt(req.getParameter("pageNo"));
        HttpSession session = req.getSession();
        @SuppressWarnings("unchecked") Map<Integer, List<HostDetailsEntityVO>> mapOfData = (Map<Integer, List<HostDetailsEntityVO>>) session.getAttribute("HostVoList");
        responseView.addObject("hostVo", mapOfData.get(selectedPage));
    } catch (Exception e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("hostVo", "");
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("DemoPortalDataController.getHostForViewForPage<<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) HttpSession(javax.servlet.http.HttpSession) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException)

Aggregations

HttpSession (javax.servlet.http.HttpSession)730 HttpServletRequest (javax.servlet.http.HttpServletRequest)151 Test (org.junit.Test)110 IOException (java.io.IOException)80 HttpServletResponse (javax.servlet.http.HttpServletResponse)80 ServletException (javax.servlet.ServletException)75 ArrayList (java.util.ArrayList)65 RequestDispatcher (javax.servlet.RequestDispatcher)59 HashMap (java.util.HashMap)48 Map (java.util.Map)44 Locale (java.util.Locale)39 Properties (java.util.Properties)39 PrintWriter (java.io.PrintWriter)38 Cookie (javax.servlet.http.Cookie)27 List (java.util.List)24 SQLException (java.sql.SQLException)23 WebUser (org.compiere.util.WebUser)23 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)20 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)20 ModelAndView (org.springframework.web.servlet.ModelAndView)20