Search in sources :

Example 41 with HttpSession

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

the class WLMDataController method logOutUser.

public ModelAndView logOutUser(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.logOutUser >>");
    ModelAndView responseView = new ModelAndView("Login");
    try {
        HttpSession session = req.getSession(false);
        if (session != null) {
            session.invalidate();
        }
    //res.sendRedirect(req.getContextPath()+"/login.htm");
    } catch (Exception e) {
        log.error(e.toString());
        e.printStackTrace();
    }
    log.info("WLMDataController.logOutUser <<");
    return responseView;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ModelAndView(org.springframework.web.servlet.ModelAndView) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 42 with HttpSession

use of javax.servlet.http.HttpSession 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 43 with HttpSession

use of javax.servlet.http.HttpSession 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 44 with HttpSession

use of javax.servlet.http.HttpSession in project druid by alibaba.

the class AbstractWebStatImpl method getSessionId.

public String getSessionId(HttpServletRequest httpRequest) {
    String sessionId = null;
    HttpSession session = httpRequest.getSession(createSession);
    if (session != null) {
        sessionId = session.getId();
    }
    return sessionId;
}
Also used : HttpSession(javax.servlet.http.HttpSession)

Example 45 with HttpSession

use of javax.servlet.http.HttpSession in project dubbo by alibaba.

the class ServicePrivilegeCheckValve method invokeCheckServicePrivilege.

private void invokeCheckServicePrivilege(User user) {
    TurbineRunData rundata = getTurbineRunData(request);
    HttpSession session = request.getSession();
    @SuppressWarnings("unchecked") Map<String, String[]> requestMapping = request.getParameterMap();
    //记录上次操作到请求中
    String returnURL = "";
    if (session.getAttribute("returnURL") == null) {
        returnURL = request.getContextPath();
    } else {
        returnURL = (String) session.getAttribute("returnURL");
    }
    if (requestMapping.get("service").length > 0) {
        String service = ((String[]) requestMapping.get("service"))[0];
        String method = "index";
        if (requestMapping.get("_method").length > 0) {
            method = requestMapping.get("_method")[0];
        }
        boolean exclude = "index".equals(method) || "show".equals(method);
        if (!exclude) {
            if (user != null && !user.hasServicePrivilege(service)) {
                request.setAttribute("returnURL", returnURL);
                redirectToNoRight(rundata);
            }
        }
    }
    String type = requestMapping.get("_type").length == 0 ? null : requestMapping.get("_type")[0];
    if (!"noServicePrivilege".equals(type)) {
        session.setAttribute("returnURL", request.getRequestURI());
    }
    return;
}
Also used : TurbineRunData(com.alibaba.citrus.turbine.TurbineRunData) TurbineUtil.getTurbineRunData(com.alibaba.citrus.turbine.util.TurbineUtil.getTurbineRunData) HttpSession(javax.servlet.http.HttpSession)

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