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:mx.edu.um.mateo.rh.web.DiaFeriadoController.java
private void enviaCorreo(String tipo, List<DiaFeriado> diaFeriados, HttpServletRequest request) throws JRException, MessagingException { log.debug("Enviando correo {}", tipo); byte[] archivo = null; String tipoContenido = null;/*from www . j av a 2s. c o m*/ switch (tipo) { case "PDF": archivo = generaPdf(diaFeriados); tipoContenido = "application/pdf"; break; case "CSV": archivo = generaCsv(diaFeriados); tipoContenido = "text/csv"; break; case "XLS": archivo = generaXls(diaFeriados); tipoContenido = "application/vnd.ms-excel"; } MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setTo(ambiente.obtieneUsuario().getUsername()); String titulo = messageSource.getMessage("diaFeriado.lista.label", null, request.getLocale()); helper.setSubject(messageSource.getMessage("envia.correo.titulo.message", new String[] { titulo }, request.getLocale())); helper.setText(messageSource.getMessage("envia.correo.contenido.message", new String[] { titulo }, request.getLocale()), true); helper.addAttachment(titulo + "." + tipo, new ByteArrayDataSource(archivo, tipoContenido)); mailSender.send(message); }
From source file:fr.paris.lutece.plugins.extend.modules.comment.web.component.CommentResourceExtenderComponent.java
/** * {@inheritDoc}/* w w w. ja va2 s .c o m*/ */ @Override public String getConfigHtml(ResourceExtenderDTO resourceExtender, Locale locale, HttpServletRequest request) { ReferenceList listIdsMailingList = new ReferenceList(); listIdsMailingList.addItem(-1, I18nService .getLocalizedString(CommentConstants.PROPERTY_COMMENT_CONFIG_LABEL_NO_MAILING_LIST, locale)); listIdsMailingList.addAll(AdminMailingListService.getMailingLists(AdminUserService.getAdminUser(request))); Map<String, Object> model = new HashMap<String, Object>(); model.put(CommentConstants.MARK_COMMENT_CONFIG, _configService.find(resourceExtender.getIdExtender())); model.put(CommentConstants.MARK_LIST_IDS_MAILING_LIST, listIdsMailingList); model.put(CommentConstants.MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); model.put(CommentConstants.MARK_LOCALE, AdminUserService.getLocale(request)); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_COMMENT_CONFIG, request.getLocale(), model); return template.getHtml(); }
From source file:fr.paris.lutece.plugins.mydashboard.business.portlet.MyDashboardPortlet.java
/** * {@inheritDoc}/*from www .j a v a 2 s.co m*/ */ @Override public String getHtmlContent(HttpServletRequest request) { if (SecurityService.isAuthenticationEnable()) { LuteceUser user = SecurityService.getInstance().getRegisteredUser(request); if (user == null) { return StringUtils.EMPTY; } Map<String, Object> model = new HashMap<String, Object>(); List<IMyDashboardComponent> listDashboardComponents = MyDashboardService.getInstance() .getDashboardComponentListFromUser(user); List<String> listDashboardContent = new ArrayList<String>(listDashboardComponents.size()); for (IMyDashboardComponent dashboardComponent : listDashboardComponents) { if (dashboardComponent.isAvailable(user)) { listDashboardContent.add(dashboardComponent.getDashboardData(request)); } } model.put(MARK_LIST_DASHBOARDS_CONTENT, listDashboardContent); model.put(MARK_PORTLET, this); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_PORTLET_MY_DASHBOARDS, request.getLocale(), model); return template.getHtml(); } return StringUtils.EMPTY; }
From source file:mx.edu.um.mateo.rh.web.SolicitudVacacionesEmpleadoController.java
private void enviaCorreo(String tipo, List<SolicitudVacacionesEmpleado> vacacioness, HttpServletRequest request) throws JRException, MessagingException { log.debug("Enviando correo {}", tipo); byte[] archivo = null; String tipoContenido = null;/*from w w w . j a va 2s. co m*/ switch (tipo) { case "PDF": archivo = generaPdf(vacacioness); tipoContenido = "application/pdf"; break; case "CSV": archivo = generaCsv(vacacioness); tipoContenido = "text/csv"; break; case "XLS": archivo = generaXls(vacacioness); tipoContenido = "application/vnd.ms-excel"; } MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setTo(ambiente.obtieneUsuario().getUsername()); String titulo = messageSource.getMessage("vacaciones.lista.label", null, request.getLocale()); helper.setSubject(messageSource.getMessage("envia.correo.titulo.message", new String[] { titulo }, request.getLocale())); helper.setText(messageSource.getMessage("envia.correo.contenido.message", new String[] { titulo }, request.getLocale()), true); helper.addAttachment(titulo + "." + tipo, new ByteArrayDataSource(archivo, tipoContenido)); mailSender.send(message); }
From source file:mx.edu.um.mateo.rh.web.CategoriaController.java
private void enviaCorreo(String tipo, List<Categoria> categorias, HttpServletRequest request) throws JRException, MessagingException { log.debug("Enviando correo {}", tipo); byte[] archivo = null; String tipoContenido = null;//w w w. java2 s .c o m switch (tipo) { case "PDF": archivo = generaPdf(categorias); tipoContenido = "application/pdf"; break; case "CSV": archivo = generaCsv(categorias); tipoContenido = "text/csv"; break; case "XLS": archivo = generaXls(categorias); tipoContenido = "application/vnd.ms-excel"; } MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setTo(ambiente.obtieneUsuario().getUsername()); String titulo = messageSource.getMessage("categoria.lista.label", null, request.getLocale()); helper.setSubject(messageSource.getMessage("envia.correo.titulo.message", new String[] { titulo }, request.getLocale())); helper.setText(messageSource.getMessage("envia.correo.contenido.message", new String[] { titulo }, request.getLocale()), true); helper.addAttachment(titulo + "." + tipo, new ByteArrayDataSource(archivo, tipoContenido)); mailSender.send(message); }
From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.web.PDFProducerJspBean.java
/** * Copy a configuration/*w ww. j av a 2 s. c om*/ * @param request request * @return manage page */ public String doCopyConfigProducer(HttpServletRequest request) { String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); if (!isAuthorized(strIdDirectory)) { return getErrorPage(); } String strIdConfigProducer = request.getParameter(PARAMETER_ID_CONFIG_PRODUCER); _manageConfigProducerService.copyProducerConfig(getPlugin(), DirectoryUtils.convertStringToInt(strIdConfigProducer), request.getLocale()); return manageConfigProducer(request); }
From source file:mx.edu.um.mateo.rh.web.JefeSeccionController.java
private void enviaCorreo(String tipo, List<JefeSeccion> jefeSeccions, HttpServletRequest request) throws JRException, MessagingException { log.debug("Enviando correo {}", tipo); byte[] archivo = null; String tipoContenido = null;//www . ja v a 2s . c o m switch (tipo) { case "PDF": archivo = generaPdf(jefeSeccions); tipoContenido = "application/pdf"; break; case "CSV": archivo = generaCsv(jefeSeccions); tipoContenido = "text/csv"; break; case "XLS": archivo = generaXls(jefeSeccions); tipoContenido = "application/vnd.ms-excel"; } MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setTo(ambiente.obtieneUsuario().getUsername()); String titulo = messageSource.getMessage("jefeSeccion.lista.label", null, request.getLocale()); helper.setSubject(messageSource.getMessage("envia.correo.titulo.message", new String[] { titulo }, request.getLocale())); helper.setText(messageSource.getMessage("envia.correo.contenido.message", new String[] { titulo }, request.getLocale()), true); helper.addAttachment(titulo + "." + tipo, new ByteArrayDataSource(archivo, tipoContenido)); mailSender.send(message); }
From source file:alpha.portal.webapp.controller.CaseFormController.java
/** * Save case.// w w w . j a v a 2 s .c o m * * @param jspCase * the jsp case * @param errors * the errors * @param request * the request * @param response * the response * @return the string * @throws Exception * the exception */ @RequestMapping(method = RequestMethod.POST, params = { "saveCase" }) public String saveCase(final AlphaCase jspCase, final BindingResult errors, final HttpServletRequest request, final HttpServletResponse response) throws Exception { AlphaCase alphaCase = this.caseManager.get(jspCase.getCaseId()); if (!StringUtils.isBlank(jspCase.getName())) { alphaCase.setName(jspCase.getName()); alphaCase = this.caseManager.save(alphaCase); } final String cardPriority = request.getParameter(CaseFormController.CARD_PRIORITY_PARAM_NAME); if (!StringUtils.isBlank(cardPriority)) { this.caseManager.updateCardOrder(alphaCase, Arrays.asList(StringUtils.split(cardPriority, ';'))); } this.saveMessage(request, this.getText("case.updated", request.getLocale())); String redirect = "redirect:/caseform?caseId=" + alphaCase.getCaseId(); final String activeCardId = request.getParameter("activeCardId"); if (!StringUtils.isBlank(activeCardId)) { redirect += "&activeCardId=" + activeCardId; } return redirect; }
From source file:net.bull.javamelody.TestMonitoringFilter.java
/** Test. * @throws ServletException e// w ww . jav a 2 s . c o m * @throws IOException e */ @Test public void testDoFilterWithSession() throws ServletException, IOException { final HttpServletRequest request = createNiceMock(HttpServletRequest.class); final HttpSession session = createNiceMock(HttpSession.class); expect(request.getSession(false)).andReturn(session); expect(request.getLocale()).andReturn(Locale.FRANCE); replay(session); doFilter(request); verify(session); }
From source file:org.squale.squaleweb.applicationlayer.action.results.audit.AuditAction.java
/** * Consrtuit les grpahes reprsentant les statistiques par serveur sur le temps et la taille des audits * /* www .jav a 2 s . c om*/ * @param pRequest la requte * @param auditsList la liste des audits * @param serverName le nom du serveur * @return un tableau de GraphMaker deux lment : [TimeMaker, SizeMaker] * @throws IOException si erreur la transformation des graphes en image */ private GraphMaker[] buildStatGraphics(HttpServletRequest pRequest, List auditsList, String serverName) throws IOException { // Initialisation GraphMaker timeMaker = null; List durationList = new ArrayList(0); List fsSizeList = new ArrayList(0); GraphMaker sizeMaker = null; // ajoute les valeurs dj rcupres aux maps for (int i = 0; i < auditsList.size(); i++) { AuditForm form = (AuditForm) auditsList.get(i); if (serverName.equals(form.getServerName())) { String auditDate = SqualeWebActionUtils.getFormattedDate(pRequest.getLocale(), form.getDate(), "date.format.simple.short"); durationList.add(new Object[] { auditDate, form.getDuration(), form.getApplicationName() }); fsSizeList.add(new Object[] { auditDate, form.getMaxFileSystemSize(), form.getApplicationName() }); } } // construit le maker et lui passe les valeurs afin qu'il construise // les diffrentes courbes si il y a des donnes if (durationList.size() > 0) { AuditTimeMaker statsTimeMaker = new AuditTimeMaker(pRequest); statsTimeMaker.setValues(durationList); AuditsSizeMaker statsSizeMaker = new AuditsSizeMaker(pRequest); statsSizeMaker.addCurve(fsSizeList); JFreeChart timeChart = statsTimeMaker.getChart(); JFreeChart sizeChart = statsSizeMaker.getChart(); ChartRenderingInfo infoStats = new ChartRenderingInfo(new StandardEntityCollection()); // Initialisation des graphs String fileNameTime = ServletUtilities.saveChartAsPNG(timeChart, statsTimeMaker.getDefaultWidth(), statsTimeMaker.getDefaultHeight(), infoStats, pRequest.getSession()); timeMaker = new GraphMaker(pRequest, fileNameTime, infoStats); infoStats = new ChartRenderingInfo(new StandardEntityCollection()); String fileNameSize = ServletUtilities.saveChartAsPNG(sizeChart, statsSizeMaker.getDefaultWidth(), statsSizeMaker.getDefaultHeight(), infoStats, pRequest.getSession()); sizeMaker = new GraphMaker(pRequest, fileNameSize, infoStats); } return new GraphMaker[] { timeMaker, sizeMaker }; }