List of usage examples for org.springframework.web.context.request WebRequest getParameter
@Nullable String getParameter(String paramName);
From source file:com.seajas.search.profiler.controller.DownloadController.java
/** * Handle the request./* ww w . j a va 2 s . c o m*/ * * @param model * @param request * @param response * @return ModelAndView * @throws IOException */ @RequestMapping(method = RequestMethod.GET) public ModelAndView handleRequest(final ModelMap model, final WebRequest request, final HttpServletResponse response) throws IOException { String documentPath = request.getParameter(PARAM_DOCUMENT); if (!StringUtils.isEmpty(documentPath)) { RepositoryContent content = repositoryService.getResource(documentPath); if (content != null && content.getInputStream() != null) { try { String filename = documentPath.lastIndexOf("/") != -1 ? documentPath.substring(documentPath.lastIndexOf('/') + 1) : documentPath; // Add extensions for some common MIME types if (content.getMimeType() != null) { response.addHeader("Content-Type", content.getMimeType()); if (content.getMimeType().equals("text/html") || content.getMimeType().equals("application/xhtml+xml")) filename += ".html"; else if (content.getMimeType().equals("application/pdf")) filename += ".pdf"; else if (content.getMimeType().equals("application/msword")) filename += ".doc"; else if (content.getMimeType().equals("application/vnd.ms-excel")) filename += ".xls"; else if (content.getMimeType().equals("application/vnd.ms-powerpoint")) filename += ".ppt"; else if (content.getMimeType() .equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) filename += ".docx"; else if (content.getMimeType() .equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) filename += ".xlsx"; else if (content.getMimeType().equals( "application/vnd.openxmlformats-officedocument.presentationml.presentation")) filename += ".pptx"; else if (content.getMimeType().equals("application/vnd.oasis.opendocument.text")) filename += ".odt"; else if (content.getMimeType().equals("application/vnd.oasis.opendocument.spreadsheet")) filename += ".ods"; else if (content.getMimeType().equals("application/vnd.oasis.opendocument.presentation")) filename += ".odp"; } // And then add the disposition header response.addHeader("Content-Disposition", "attachment; filename=" + filename); // Copy the input stream content over to the servlet's output stream IOUtils.copy(content.getInputStream(), response.getOutputStream()); } finally { IOUtils.closeQuietly(content.getInputStream()); } } else response.getWriter().print("The requested document could not be retrieved for downloading."); } else response.getWriter().print("No document was specified for downloading."); return null; }
From source file:com.seajas.search.profiler.controller.ModifierController.java
/** * Render the submit action in the same way as a regular page view is rendered. * //from ww w . j av a 2 s . co m * @param command * @param result * @param model * @param request * @return String */ @RequestMapping(method = RequestMethod.POST) public String processSubmit(@ModelAttribute("modifierCommand") final ModifierCommand command, final BindingResult result, final ModelMap model, final WebRequest request) { if (request.getParameter("isEnabled") == null) command.setIsEnabled(false); if (request.getParameter("filterAsExpression") == null) command.setFilterAsExpression(false); validator.validate(command, result); if (!result.hasErrors()) { // Modifiers if (command.getAction() != null) { if (command.getAction().equals("add")) profilerService.addModifier(command.getUrlExpression(), command.getUrlType(), command.getTestFeed(), command.getIsEnabled()); else if (command.getAction().equals("edit")) profilerService.modifyModifier(command.getId(), command.getUrlExpression(), command.getUrlType(), command.getTestFeed(), command.getIsEnabled()); else if (command.getAction().equals("delete")) profilerService.deleteModifier(command.getId()); } // Filters if (command.getFilterAction() != null) { if (command.getFilterAction().equals("add-filter")) profilerService.addModifierFilter(command.getFilterModifierId(), command.getFilterStart(), command.getFilterEnd(), command.getFilterAsExpression()); else if (command.getFilterAction().equals("edit-filter")) profilerService.modifyModifierFilter(command.getFilterId(), command.getFilterModifierId(), command.getFilterStart(), command.getFilterEnd(), command.getFilterAsExpression()); else if (command.getFilterAction().equals("delete-filter")) profilerService.deleteModifierFilter(command.getFilterId()); } // Scripts if (command.getScriptAction() != null) { if (command.getScriptAction().equals("add-script")) profilerService.addModifierScript(command.getScriptModifierId(), command.getScriptLanguage(), command.getScriptContent()); else if (command.getScriptAction().equals("edit-script")) profilerService.modifyModifierScript(command.getScriptId(), command.getScriptModifierId(), command.getScriptLanguage(), command.getScriptContent()); else if (command.getScriptAction().equals("delete-script")) profilerService.deleteModifierScript(command.getScriptId()); } // Re-populate the data model.put("data", populateData()); command.clear(); } return "modifiers"; }
From source file:com.cami.web.controller.UserController.java
/** * * @param model//from w w w . jav a 2 s.c o m * @param webRequest * @return */ @RequestMapping(method = RequestMethod.GET) public String indexAction(final ModelMap model, final WebRequest webRequest) { final String nom = webRequest.getParameter("querynom") != null ? webRequest.getParameter("querynom") : ""; final Integer page = webRequest.getParameter("page") != null ? Integer.valueOf(webRequest.getParameter("page")) : 0; final Integer size = webRequest.getParameter("size") != null ? Integer.valueOf(webRequest.getParameter("size")) : 55; System.out.println("querynom = " + nom); final User user = new User(); user.setNom(nom); final Role role = new Role(); role.setUser(user); final Page<Role> resultPage = roleService.retrieveUsers(nom, page, size); System.out.println("taille users =" + resultPage.getContent().size()); model.addAttribute("page", page); model.addAttribute("user", role); model.addAttribute("Totalpage", resultPage.getTotalPages()); model.addAttribute("size", size); model.addAttribute("users", resultPage.getContent()); return "user/index"; }
From source file:com.seajas.search.codex.controller.IdentityController.java
/** * Render the submit action in the same way as a regular page view is rendered. * /*from ww w . j av a 2 s .c o m*/ * @param command * @param result * @param model * @param request * @return String * @throws Exception */ @RequestMapping(method = RequestMethod.POST) public String processSubmit(@ModelAttribute("identityCommand") final IdentityCommand command, final BindingResult result, final ModelMap model, final WebRequest request) throws Exception { // Update the enabled attribute if (request.getParameter("isEnabled") == null) command.setIsEnabled(false); if (request.getParameter("isPoolable") != null) command.setIsPoolable(true); validator.validate(command, result); // XXX: For now, we only support the (default) application language anyway if (!StringUtils.hasText(command.getNotifierLanguage())) command.setNotifierLanguage(codexService.getDefaultApplicationLanguage()); if (!result.hasErrors()) { // Identity if (StringUtils.hasText(command.getAction())) { if (command.getAction().equals("add")) codexService.addIdentity(command.getName(), command.getDescription(), command.getNotifierEmail(), command.getNotifierLanguage(), command.getIsPoolable(), command.getIsEnabled()); else if (command.getAction().equals("edit")) codexService.modifyIdentity(command.getId(), command.getName(), command.getDescription(), command.getNotifierEmail(), command.getNotifierLanguage(), command.getIsPoolable(), command.getIsEnabled()); else if (command.getAction().equals("delete")) codexService.deleteIdentity(command.getId()); } else if (StringUtils.hasText(command.getAccountAction())) { if (command.getAccountAction().equals("add-account")) codexService.addIdentityAccount(command.getId(), command.getType(), command.getUsername(), command.getPassword()); else if (command.getAccountAction().equals("edit-account")) codexService.modifyIdentityAccount(command.getAccountId(), command.getType(), command.getUsername(), command.getPassword()); else if (command.getAccountAction().equals("delete-account")) codexService.deleteIdentityAccount(command.getAccountId()); } else if (StringUtils.hasText(command.getAccountTokenAction())) { if (command.getAccountTokenAction().equals("delete-account-token")) codexService.deleteIdentityAccountToken(command.getAccountTokenId()); } // Re-populate the data model.put("data", populateData()); command.clear(); } return "identities"; }
From source file:org.gvsig.framework.web.controllers.OGCInfoController.java
/** * Get supported crs of WMTS server indicated by url parameter * * @param request the {@code HttpServletRequest}. * @return List of crs supported/*from w w w. jav a 2 s. c o m*/ */ @RequestMapping(params = "findSupportedCrsWmts", headers = "Accept=application/json", produces = { "application/json; charset=UTF-8" }) @ResponseBody public ResponseEntity<List<String>> findSupportedCrsWmtsByAjax(WebRequest request) { String urlServer = request.getParameter("url"); List<String> listCrs = null; if (StringUtils.isNotEmpty(urlServer)) { listCrs = ogcInfoServ.getCRSSupportedByWMTS(urlServer); } return new ResponseEntity<List<String>>(listCrs, HttpStatus.OK); }
From source file:com.seajas.search.profiler.controller.ReindexController.java
/** * Handle the request.// ww w . j av a 2s.c o m * * @param model * @param request * @return String */ @RequestMapping(method = RequestMethod.GET) public String handleRequest(final ModelMap model, final WebRequest request) { if (!StringUtils.isEmpty(request.getParameter(PARAM_ACTION)) && request.getParameter(PARAM_ACTION).equals(ACTION_REINDEX)) { Map<String, Object> data = new HashMap<String, Object>(); data.put("initialized", true); // Retrieve the collection if (!StringUtils.isEmpty(request.getParameter(PARAM_COLLECTION))) data.put("collection", request.getParameter(PARAM_COLLECTION)); if (!StringUtils.isEmpty(request.getParameter(PARAM_TAXONOMY_MATCH))) data.put("taxonomyMatch", request.getParameter(PARAM_TAXONOMY_MATCH)); // Retrieve the start and end dates String startDateValue = !StringUtils.isEmpty(request.getParameter(PARAM_START_DATE)) ? request.getParameter(PARAM_START_DATE) : null; String endDateValue = !StringUtils.isEmpty(request.getParameter(PARAM_END_DATE)) ? request.getParameter(PARAM_END_DATE) : null; Date startDate = null, endDate = null; if (startDateValue != null || endDateValue != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); if (startDateValue != null) try { startDate = dateFormat.parse(startDateValue); } catch (ParseException e) { startDate = null; } if (endDateValue != null) try { endDate = dateFormat.parse(endDateValue); } catch (ParseException e) { endDate = null; } } if (startDate != null) data.put("startDate", startDate); if (endDate != null) data.put("endDate", endDate); // Retrieve an optional attribute String requestParameterName = !StringUtils.isEmpty(request.getParameter(PARAM_REQUEST_PARAMETER_NAME)) ? request.getParameter(PARAM_REQUEST_PARAMETER_NAME) : null; String requestParameterValue = !StringUtils.isEmpty(request.getParameter(PARAM_REQUEST_PARAMETER_VALUE)) ? request.getParameter(PARAM_REQUEST_PARAMETER_VALUE) : null; if (requestParameterName != null && requestParameterValue != null) { data.put("requestParameterName", requestParameterName); data.put("requestParameterValue", requestParameterValue); } // Retrieve the feed and page numbers Integer sourceId; try { sourceId = Integer.valueOf(!StringUtils.isEmpty(request.getParameter(PARAM_SOURCE)) ? request.getParameter(PARAM_SOURCE) : null); } catch (NumberFormatException e) { sourceId = null; } if (sourceId != null) data.put("sourceId", sourceId); profilerService.setReindexState(data); taskService.startSchedulerJob("reindexInjection", null); } return "reindex"; }
From source file:org.gvsig.framework.web.controllers.OGCInfoController.java
/** * Get information and layers of WMS server indicated by url parameter * * @param request the {@code HttpServletRequest}. * @return ResponseEntity with wmsInfo//from ww w . ja v a 2 s .co m */ @RequestMapping(params = "findWmsCapabilities", headers = "Accept=application/json", produces = { "application/json; charset=UTF-8" }) @ResponseBody public ResponseEntity<WMSInfo> findWmsCapabilitiesByAjax(WebRequest request) { String urlServer = request.getParameter("url"); String format = request.getParameter("format"); boolean isCalledByWizard = Boolean.parseBoolean(request.getParameter("wizard")); WMSInfo wmsInfo = null; String crsParam = request.getParameter("crs"); TreeSet<String> listCrs = new TreeSet<String>(); if (StringUtils.isNotEmpty(crsParam)) { Collections.addAll(listCrs, crsParam.split(",")); } if (StringUtils.isNotEmpty(urlServer)) { wmsInfo = ogcInfoServ.getCapabilitiesFromWMS(urlServer, listCrs, format, isCalledByWizard); } return new ResponseEntity<WMSInfo>(wmsInfo, HttpStatus.OK); }
From source file:org.gvsig.framework.web.controllers.OGCInfoController.java
/** * Get information and layers of WMTS server indicated by url parameter * * @param request the {@code HttpServletRequest}. * @return ResponseEntity with wmtsInfo/*from w w w.ja va2s . com*/ */ @RequestMapping(params = "findWmtsCapabilities", headers = "Accept=application/json", produces = { "application/json; charset=UTF-8" }) @ResponseBody public ResponseEntity<WMTSInfo> findWmtsCapabilitiesByAjax(WebRequest request) { String urlServer = request.getParameter("url"); boolean useCrsSelected = Boolean.parseBoolean(request.getParameter("useCrsSelected")); String crsParam = request.getParameter("crs"); TreeSet<String> listCrs = new TreeSet<String>(); if (StringUtils.isNotEmpty(crsParam)) { Collections.addAll(listCrs, crsParam.split(",")); } WMTSInfo wmtsInfo = null; if (StringUtils.isNotEmpty(urlServer)) { wmtsInfo = ogcInfoServ.getCapabilitiesFromWMTS(urlServer, listCrs, useCrsSelected); } return new ResponseEntity<WMTSInfo>(wmtsInfo, HttpStatus.OK); }
From source file:org.gvsig.framework.web.controllers.OGCInfoController.java
/** * Get layer metadata of service WMTS and show it in page * * @param request the {@code HttpServletRequest}. * @param uiModel the {@code Model}./*from w ww. j a v a 2s .co m*/ * @return ResponseEntity with metadata info of wmts server ({@code ServiceMetadata}) */ @RequestMapping(params = "getWmtsMetadata", headers = "Accept=application/json") public String getWmtsMetadata(WebRequest request, Model uiModel) { String urlServer = request.getParameter("url"); ServiceMetadata serviceMetadata = null; if (StringUtils.isNotEmpty(urlServer)) { serviceMetadata = ogcInfoServ.getMetadataInfoFromWMTS(urlServer); } uiModel.addAttribute("srvMetadata", serviceMetadata); return "ogcinfo/showMetadata"; }
From source file:org.gvsig.framework.web.controllers.OGCInfoController.java
/** * Get layer metadata of service WMS and show it in page * * @param request the {@code HttpServletRequest}. * @param uiModel the {@code Model}./* ww w . j a v a2 s . c om*/ * @return ResponseEntity with metadata info of wms server ({@code ServiceMetadata}) */ @RequestMapping(params = "getWmsMetadata", headers = "Accept=application/json") public String getWmsMetadata(WebRequest request, Model uiModel) { String urlServer = request.getParameter("url"); ServiceMetadata serviceMetadata = null; if (StringUtils.isNotEmpty(urlServer)) { serviceMetadata = ogcInfoServ.getMetadataInfoFromWMS(urlServer); } uiModel.addAttribute("srvMetadata", serviceMetadata); return "ogcinfo/showMetadata"; }