List of usage examples for javax.servlet.http HttpServletRequest getLocale
public Locale getLocale();
Locale
that the client will accept content in, based on the Accept-Language header. From source file:com.acentic.cloudservices.session.web.PublicActions.java
public String doLoginCasUser() { LOGGER.log(Level.TRACE, "do login cas user"); SystemUserBean systemUser = null;// ww w . ja v a 2 s .c o m try { HttpServletRequest request = (HttpServletRequest) ActionContext.getContext() .get(ServletActionContext.HTTP_REQUEST); AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal(); if (principal == null) { throw new Exception("principal is null"); } else { @SuppressWarnings("rawtypes") Map attributes = principal.getAttributes(); String uid = (String) attributes.get("uid"); Long lUid = Long.valueOf(uid); systemUser = (SystemUserBean) applicationContext.getBean(SpringUserBeansDef.SystemUserBean, lUid); if (!systemUser.isLoaded()) { LOGGER.log(Level.ERROR, "unable to login cas user with id " + lUid); return ERROR; } LOGGER.log(Level.DEBUG, "request with local=" + request.getLocale().toString()); } } catch (Exception e) { LOGGER.log(Level.ERROR, "unable to login cas user", e); return ERROR; } return SUCCESS; }
From source file:com.hp.avmon.config.web.AgentController.java
@RequestMapping("deleteIloHostByIps") public String deleteIloHostByIps(HttpServletResponse response, HttpServletRequest request) { String data = ""; Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); try {// ww w .ja v a2 s . c o m String agentId = request.getParameter("agentId"); String ampInstId = request.getParameter("ampInstId"); String ips = request.getParameter("ips"); agentManageService.deleteIloHostByIps(agentId, ampInstId, ips); data = "{success:true,msg:'" + bundle.getString("deleteSuccess") + "'}"; } catch (Exception e) { logger.error(this.getClass().getName() + " deleteIloHostByIps", e); data = "{success:false,msg:'" + bundle.getString("deleteFail") + "'}"; } return Utils.responsePrintWrite(response, data, null); }
From source file:com.hp.avmon.config.web.AgentController.java
/** * ""//from w w w.ja va2 s . co m * @param response * @param request * @return */ @RequestMapping("deleteVmHost") public String deleteVmHost(HttpServletResponse response, HttpServletRequest request) { String data = ""; Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); try { String agentId = request.getParameter("agentId"); String ampInstId = request.getParameter("ampInstId"); String objIds = request.getParameter("objIds"); agentManageService.deleteVmHost(agentId, ampInstId, objIds); data = "{success:true,msg:'" + bundle.getString("removeSuccess") + "'}"; } catch (Exception e) { logger.error(this.getClass().getName() + " deleteVmHost", e); data = "{success:false,msg:'" + bundle.getString("removeFail") + "'}"; } return Utils.responsePrintWrite(response, data, null); }
From source file:org.opentides.web.controller.BaseCrudController.java
/** * Handles all binding errors and return as json object for display to the * user.// w w w .j a v a2 s . co m * * @param e * @param request * @return */ @ExceptionHandler(Exception.class) public @ResponseBody Map<String, Object> handleBindException(Exception ex, HttpServletRequest request) throws Exception { Map<String, Object> response = new HashMap<String, Object>(); List<MessageResponse> messages = new ArrayList<MessageResponse>(); if (ex instanceof BindException) { BindException e = (BindException) ex; messages.addAll(CrudUtil.convertErrorMessage(e.getBindingResult(), request.getLocale(), messageSource)); if (_log.isDebugEnabled()) _log.debug("Bind error encountered.", e); } else { if (!request.getHeader("Accept").contains("application/json")) { throw ex; } MessageResponse message = new MessageResponse(Type.error, new String[] { "error.uncaught-exception" }, new Object[] { ex.getMessage() }); message.setMessage(messageSource.getMessage(message, request.getLocale())); messages.add(message); _log.error(ex, ex); } response.put("messages", messages); return response; }
From source file:com.hp.avmon.config.web.AgentController.java
/** * "??"/*from ww w . j av a 2 s .c o m*/ * @param response * @param request * @return */ @RequestMapping("saveVmSchedule") public String saveVmSchedule(HttpServletResponse response, HttpServletRequest request) { String data = ""; Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); String dispatchIssuedSuccess = bundle.getString("dispatchIssuedSuccess"); try { String agentId = request.getParameter("agentId"); String ampInstId = request.getParameter("ampInstId"); String schedule = request.getParameter("schedule"); Map map = agentManageService.saveVmSchedule(agentId, ampInstId, schedule, dispatchIssuedSuccess); if (map.get("msg").toString().indexOf(dispatchIssuedSuccess) != -1) map.put("msg", dispatchIssuedSuccess); //data="{success:true,msg:'??!'}"; data = JackJson.fromObjectToJson(map); } catch (Exception e) { logger.error(this.getClass().getName() + " saveVmSchedule", e); data = "{success:false,msg:'" + bundle.getString("saveFail") + "'}"; } return Utils.responsePrintWrite(response, data, null); }
From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.StockBilletterieReservationApp.java
/** * Send booking notification./*w w w . jav a 2 s.c o m*/ * * @param bookingList the booking list * @param request the request * @return the notification dto */ private NotificationDTO sendBookingNotification(List<ReservationDTO> bookingList, HttpServletRequest request) { //Generate mail content Map<String, Object> model = new HashMap<String, Object>(); model.put(PARAMETER_BOOKING_LIST, bookingList); model.put(MARK_BASE_URL, AppPathService.getBaseUrl(request)); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_DIR + TEMPLATE_NOTIFICATION_BOOKING, request.getLocale(), model); // Create mail object NotificationDTO notificationDTO = new NotificationDTO(); ReservationDTO reservation = bookingList.get(0); notificationDTO.setRecipientsTo(reservation.getEmailAgent()); notificationDTO.setSubject( getMessage(MESSAGE_NOTIFICATION_BOOKING_SUBJECT, request, reservation.getOffer().getName())); notificationDTO.setMessage(template.getHtml()); // Send it _notificationService.send(notificationDTO); return notificationDTO; }
From source file:fr.paris.lutece.plugins.crm.web.category.CategoryJspBean.java
/** * Returns the form to update info about a category * @param request The Http request/*from w w w . ja v a2 s .c om*/ * @return The HTML form to update info */ public String getModifyCategory(HttpServletRequest request) { setPageTitleProperty(CRMConstants.PROPERTY_PAGE_TITLE_MODIFY_CATEGORY); String strUrl = StringUtils.EMPTY; String strCategoryId = request.getParameter(CRMConstants.PARAMETER_CATEGORY_ID_CATEGORY); if (StringUtils.isNotBlank(strCategoryId) && StringUtils.isNumeric(strCategoryId)) { int nId = Integer.parseInt(strCategoryId); Category category = _categoryService.findByPrimaryKey(nId); Map<String, Object> model = new HashMap<String, Object>(); model.put(CRMConstants.MARK_CATEGORY, category); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MODIFY_CATEGORY, getLocale(), model); strUrl = getAdminPage(template.getHtml()); } else { throw new AppException(I18nService.getLocalizedString(CRMConstants.MESSAGE_ERROR, request.getLocale())); } return strUrl; }
From source file:com.hp.avmon.config.web.AgentController.java
/** * ?agentwindows//w ww . j a va 2 s . c o m * (agent???) * @param response * @param request * @return */ @RequestMapping("addAgentMo") public String addAgentMo(HttpServletResponse response, HttpServletRequest request) { String data = ""; Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); try { String agentId = request.getParameter("agentId"); String moId = request.getParameter("moId"); String result = agentManageService.addAgentMo(moId, agentId); if (result.startsWith("99")) { result = bundle.getString("unknownError"); } if (result.startsWith("00")) { //agent agentManageService.updateAgentMoId(agentId, moId); data = "{success:true,msg:'" + bundle.getString("operationFail") + "'}"; } else if ("1".endsWith(result)) { data = "{success:false,msg:'" + bundle.getString("monitoringObjectHasReachedTheMaximumLimit") + "'}"; } else if (result.startsWith("03")) { //agent agentManageService.updateAgentMoId(agentId, moId); data = "{success:true,msg:'" + bundle.getString("operationSuccess") + "'}"; } else { data = "{success:false,msg:'" + result + "'}"; } } catch (Exception e) { logger.error(this.getClass().getName() + " addAgentMo", e); String s = e.getMessage(); s = s.replaceAll("'", ""); data = "{success:false,msg:'" + bundle.getString("agentAddMonitorObjectFail") + "'}"; } return Utils.responsePrintWrite(response, data, null); }
From source file:com.haulmont.restapi.idp.IdpAuthController.java
@PostMapping(value = "/v2/idp/token") public ResponseEntity<OAuth2AccessToken> postAccessToken(Principal principal, @RequestParam Map<String, String> parameters, HttpServletRequest request) throws HttpRequestMethodNotSupportedException { if (!idpConfig.getIdpEnabled()) { log.debug("IDP authentication is disabled. Property cuba.rest.idp.enabled is false"); throw new InvalidGrantException("IDP is not supported"); }//from w w w . j ava 2 s . co m if (!(principal instanceof Authentication)) { throw new InsufficientAuthenticationException( "There is no client authentication. Try adding an appropriate authentication filter."); } // we cannot perform brute-force check here, since we don't know username String idpTicket = parameters.get("idp_ticket"); String ipAddress = request.getRemoteAddr(); OAuth2AccessTokenResult tokenResult = authenticate(idpTicket, request.getLocale(), ipAddress, parameters); return ResponseEntity.ok(tokenResult.getAccessToken()); }
From source file:org.n52.smartsensoreditor.controller.EditControllerSML.java
/** * This method creates the model map for the selectStates.jsp. * The values which can be selected in the boxes are created here. *///from w w w.j av a 2 s. c o m @Override protected Map<String, Object> createModelMap(HttpServletRequest request) { String status = getWorkflowManager().getStatus(getBackendService().getFileIdentifier()); String statusOperationSOS = ""; if (LOG.isDebugEnabled()) { LOG.debug("Document's file identifier is " + getBackendService().getFileIdentifier()); LOG.debug("Document's current status is " + status); } // default state if (status == null) { IState defaultState = (IState) getWorkflowManager().getDefaultState(); status = defaultState.getStateId(); // SOS operation IState defaultOperationSOS = (IState) getOperationSOSManager().getDefaultState(); statusOperationSOS = defaultOperationSOS.getStateId(); //if the metadata set has the status update, then set this as default if (getBackendService().isUpdate()) { defaultOperationSOS = (IState) getOperationSOSManager().getState("update", request.getLocale()); statusOperationSOS = defaultOperationSOS.getStateId(); } } List<IState> stateList = getWorkflowManager().getStates(getUserInfo().getTicket(), status, request.getLocale(), true); Map<String, Object> concurrentHashMap = new ConcurrentHashMap<String, Object>(); concurrentHashMap.put("transitionStates", stateList); IState lState = (IState) getWorkflowManager().getState(status, request.getLocale()); concurrentHashMap.put("currentStateName", lState.getStateName()); concurrentHashMap.put("currentStateId", lState.getStateId()); // SOS OperationList List<IState> stateListOperationSOS = getOperationSOSManager().getStates(getUserInfo().getTicket(), statusOperationSOS, request.getLocale(), true); concurrentHashMap.put("operationsSOS", stateListOperationSOS); IState lOperationsSOS = (IState) getOperationSOSManager().getState(statusOperationSOS, request.getLocale()); concurrentHashMap.put("currentOperationSOSName", lOperationsSOS.getStateName()); concurrentHashMap.put("currentOperationSOSId", lOperationsSOS.getStateId()); //Set the predefined values concurrentHashMap.put("procedureIdSOS", getBackendService().getFileIdentifier()); //procedureId==smlIdentifier==<gml:identifier(unique identifier) //Set the token and the serviceUrl within the concurrentHashMap to insert them in the selectStates.jsp file. BackendBean backendBean = getBackendService().getBackend(); if (backendBean instanceof BackendBeanSML) { BackendBeanSML backendBeanSML = ((BackendBeanSML) backendBean); String serviceUrl = backendBeanSML.getServiceURL(); LOG.debug("Predefined serviceUrl is set to '" + serviceUrl + "'"); if (serviceUrl != null) { concurrentHashMap.put("serviceURLSOS", serviceUrl); } String serviceTokenSOS = backendBeanSML.getServiceTokenSOS(); LOG.debug("Predefines token is set to '" + serviceTokenSOS + "'"); if (serviceTokenSOS != null) { concurrentHashMap.put("serviceTokenSOS", serviceTokenSOS); } } return concurrentHashMap; }