List of usage examples for javax.servlet.http HttpServletRequest getAttribute
public Object getAttribute(String name);
Object
, or null
if no attribute of the given name exists. From source file:com.persistent.cloudninja.controller.TenantUsageController.java
/** * List the tenant Metering information. * @param cookie containing tenant ID/*from ww w .ja v a 2 s . co m*/ * @throws SystemException * @return ModelAndView mapped to Tenant Metering List */ @RequestMapping("{tenantId}/showTenantMeteringPage.htm") public ModelAndView showTenantMeteringPage(HttpServletRequest request, @CookieValue(value = "CLOUDNINJAAUTH", required = false) String cookie, Model model) throws SystemException { if (cookie == null) { cookie = request.getAttribute("cookieNameAttr").toString(); } String tenantId = AuthFilterUtils.getFieldValueFromCookieString(CloudNinjaConstants.COOKIE_TENANTID_PREFIX, cookie); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); int month = calendar.get(Calendar.MONTH) + 1; int year = calendar.get(Calendar.YEAR); List<Metering> list = meteringService.getMeteringService(tenantId, month, year); MeteringListDTO meteringDTO = new MeteringListDTO(); meteringDTO.setMeteringList(list); return new ModelAndView("tenantMeteringPage", "meteringDTO", meteringDTO); }
From source file:uk.co.caprica.bootlace.security.web.filter.AngularJsCsrfHeaderFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { logger.debug("doFilterInternal()"); CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); if (csrf != null) { Cookie cookie = WebUtils.getCookie(request, CSRF_COOKIE_NAME); String token = csrf.getToken(); if (cookie == null || token != null && !token.equals(cookie.getValue())) { logger.debug("Setting new CSRF cookie"); cookie = new Cookie(CSRF_COOKIE_NAME, token); cookie.setPath(request.getServletContext().getContextPath() + "/"); response.addCookie(cookie);/* w w w . ja va 2s. c o m*/ } } filterChain.doFilter(request, response); }
From source file:com.liferay.portlet.polls.action.ViewChartAction.java
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {/*w ww .j a v a 2 s . com*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long questionId = ParamUtil.getLong(request, "questionId"); String chartType = ParamUtil.getString(request, "chartType", "pie"); CategoryDataset dataset = PollsUtil.getVotesDataset(questionId); String chartName = themeDisplay.translate("vote-results"); String xName = themeDisplay.translate("choice"); String yName = themeDisplay.translate("votes"); JFreeChart chart = null; if (chartType.equals("area")) { chart = ChartFactory.createAreaChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("horizontal_bar")) { chart = ChartFactory.createBarChart(chartName, xName, yName, dataset, PlotOrientation.HORIZONTAL, true, false, false); } else if (chartType.equals("line")) { chart = ChartFactory.createLineChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("vertical_bar")) { chart = ChartFactory.createBarChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else { PieDataset pieData = DatasetUtilities.createPieDatasetForRow(dataset, 0); chart = ChartFactory.createPieChart(chartName, pieData, true, false, false); } response.setContentType(ContentTypes.IMAGE_JPEG); OutputStream os = response.getOutputStream(); ChartUtilities.writeChartAsJPEG(os, chart, 400, 400); return null; } catch (Exception e) { PortalUtil.sendError(e, request, response); return null; } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.phd.PhdProcessDA.java
/** * First read value from request attribute to allow overriding of processId * value//w w w . j a v a2 s. c om */ protected PhdProgramProcess getProcess(HttpServletRequest request) { final String processIdAttribute = (String) request.getAttribute("processId"); return FenixFramework.getDomainObject( processIdAttribute != null ? processIdAttribute : (String) request.getParameter("processId")); }
From source file:com.mirantis.cachemod.filter.CacheFilter.java
public boolean isFragment(HttpServletRequest request) { switch (conf.getFragment()) { case AUTO:// w ww.j a va 2 s. co m return request.getAttribute("javax.servlet.include.request_uri") != null; case NO: return false; case YES: return true; } return request.getAttribute("javax.servlet.include.request_uri") != null; }
From source file:com.osafe.events.CheckOutEvents.java
public static String redeemMemberLoyaltyPoints(HttpServletRequest request, HttpServletResponse response) { Delegator delegator = (Delegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); ShoppingCart sc = org.ofbiz.order.shoppingcart.ShoppingCartEvents.getCartObject(request); String orderId = sc.getOrderId(); HttpSession session = request.getSession(); List orderAdjustmentAttributeList = (List) session.getAttribute("orderAdjustmentAttributeList"); String result = "success"; if (UtilValidate.isNotEmpty(orderId) && UtilValidate.isNotEmpty(orderAdjustmentAttributeList)) { //Call service to reduce user Loyatly points in Users Account Map serviceContext = FastMap.newInstance(); serviceContext.put("orderId", orderId); serviceContext.put("orderAdjustmentAttributeList", orderAdjustmentAttributeList); try {// ww w.j a v a2 s . com dispatcher.runSync("redeemLoyaltyPoints", serviceContext); } catch (Exception e) { String errMsg = "Error attempting to redeem loyalty points :" + e.toString(); Debug.logError(e, errMsg, module); return "error"; } session.removeAttribute("orderAdjustmentAttributeList"); } return "success"; }
From source file:net.shopxx.plugin.qqLogin.QqLoginPlugin.java
@Override public String getOpenId(HttpServletRequest request) { Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("access_token", request.getAttribute("accessToken")); String content = WebUtils.get("https://graph.qq.com/oauth2.0/me", parameterMap); Matcher matcher = OPEN_ID_PATTERN.matcher(content); if (matcher.find()) { String openId = matcher.group(1); request.setAttribute("openId", openId); return openId; }// w ww . ja v a2 s. com return null; }
From source file:com.acc.storefront.controllers.cms.AbstractCMSComponentController.java
@RequestMapping public String handleGet(final HttpServletRequest request, final HttpServletResponse response, final Model model) throws Exception { T component = (T) request.getAttribute(COMPONENT); if (component != null) { // Add the component to the model model.addAttribute("component", component); // Allow subclasses to handle the component return handleComponent(request, response, model, component); }/*from w w w . j a v a2 s . c om*/ String componentUid = (String) request.getAttribute(COMPONENT_UID); if (StringUtils.isEmpty(componentUid)) { componentUid = request.getParameter(COMPONENT_UID); } if (StringUtils.isEmpty(componentUid)) { LOG.error("No component specified in [" + COMPONENT_UID + "]"); throw new AbstractPageController.HttpNotFoundException(); } try { component = getCmsComponentService().getAbstractCMSComponent(componentUid); if (component == null) { LOG.error("Component with UID [" + componentUid + "] is null"); throw new AbstractPageController.HttpNotFoundException(); } else { // Add the component to the model model.addAttribute("component", component); // Allow subclasses to handle the component return handleComponent(request, response, model, component); } } catch (final CMSItemNotFoundException e) { LOG.error("Could not find component with UID [" + componentUid + "]"); throw new AbstractPageController.HttpNotFoundException(e); } }
From source file:com.exxonmobile.ace.hybris.storefront.controllers.cms.AbstractCMSComponentController.java
@RequestMapping public String handleGet(final HttpServletRequest request, final HttpServletResponse response, final Model model) throws Exception { T component = (T) request.getAttribute(COMPONENT); if (component != null) { // Add the component to the model model.addAttribute("component", component); // Allow subclasses to handle the component return handleComponent(request, response, model, component); }//from w w w . ja va2 s.c om String componentUid = (String) request.getAttribute(COMPONENT_UID); if (StringUtils.isEmpty(componentUid)) { componentUid = request.getParameter(COMPONENT_UID); } if (StringUtils.isEmpty(componentUid)) { LOG.error("No component specified in [" + COMPONENT_UID + "]"); throw new AbstractPageController.HttpNotFoundException(); } try { component = (T) getCmsComponentService().getAbstractCMSComponent(componentUid); if (component == null) { LOG.error("Component with UID [" + componentUid + "] is null"); throw new AbstractPageController.HttpNotFoundException(); } else { // Add the component to the model model.addAttribute("component", component); // Allow subclasses to handle the component return handleComponent(request, response, model, component); } } catch (final CMSItemNotFoundException e) { LOG.error("Could not find component with UID [" + componentUid + "]"); throw new AbstractPageController.HttpNotFoundException(e); } }
From source file:org.hdiv.web.servlet.support.HdivRequestDataValueProcessor.java
/** * Extra hidden fields with the HDIV state value. * //from ww w. j a v a 2s . c o m * @param request * request object * @return hidden field name/value */ public Map<String, String> getExtraHiddenFields(HttpServletRequest request) { IDataComposer dataComposer = (IDataComposer) request.getAttribute(HDIVUtil.DATACOMPOSER_REQUEST_KEY); Map<String, String> extraFields = new HashMap<String, String>(); if (dataComposer == null || dataComposer.isRequestStarted() == false) { return extraFields; } String requestId = dataComposer.endRequest(); if (requestId != null && requestId.length() > 0) { String hdivStateParam = (String) request.getSession().getAttribute(Constants.HDIV_PARAMETER); extraFields.put(hdivStateParam, requestId); } return extraFields; }