List of usage examples for org.springframework.web.bind ServletRequestUtils getIntParameter
@Nullable public static Integer getIntParameter(ServletRequest request, String name) throws ServletRequestBindingException
From source file:org.openmrs.module.patientflags.web.DeleteTagController.java
@RequestMapping("/module/patientflags/deleteTag.form") ModelAndView processDelete(HttpServletRequest request) throws ServletRequestBindingException { Integer tagId = ServletRequestUtils.getIntParameter(request, "tagId"); Context.getService(FlagService.class).purgeTag(tagId); return new ModelAndView("redirect:/module/patientflags/manageTags.list"); }
From source file:org.openmrs.module.patientflags.web.DeleteFlagController.java
@RequestMapping("/module/patientflags/deleteFlag.form") ModelAndView processDelete(HttpServletRequest request) throws ServletRequestBindingException { Integer flagId = ServletRequestUtils.getIntParameter(request, "flagId"); Context.getService(FlagService.class).purgeFlag(flagId); return new ModelAndView("redirect:/module/patientflags/manageFlags.form"); }
From source file:org.openmrs.module.patientflags.web.DeletePriorityController.java
@RequestMapping("/module/patientflags/deletePriority.form") ModelAndView processDelete(HttpServletRequest request) throws ServletRequestBindingException { Integer priorityId = ServletRequestUtils.getIntParameter(request, "priorityId"); //try{//from ww w . ja v a2s . co m Context.getService(FlagService.class).purgePriority(priorityId); //} // catch(APIException e){ // if there's an exception, it's probably because tried to delete an "in-use" flag // ModelMap map = new ModelMap(); //String error = "Can't delete"; //map.addAttribute("error",error); //return new ModelAndView("redirect:/module/patientflags/managePriorities.list", map); //} return new ModelAndView("redirect:/module/patientflags/managePriorities.list"); }
From source file:net.sourceforge.subsonic.controller.SetHotController.java
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Integer id = ServletRequestUtils.getIntParameter(request, "id"); Integer flag = ServletRequestUtils.getIntParameter(request, "flag"); MediaFile mediaFile = mediaFileService.getMediaFile(id); String username = securityService.getCurrentUsername(request); if (flag == 1) { hotService.setAlbumHotFlag(username, mediaFile); } else {//from w w w . j ava2 s . c o m hotService.deleteAlbumHotFlag(mediaFile); } String url = "main.view?id=" + id; return new ModelAndView(new RedirectView(url)); }
From source file:net.sourceforge.subsonic.controller.SetMediaFileController.java
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Integer id = ServletRequestUtils.getIntParameter(request, "id"); String action = request.getParameter("action"); String strmediaType = request.getParameter("mediatype"); MediaType mediaType = null;/*from w ww. j a v a 2 s .co m*/ MediaFile mediaFile = mediaFileService.getMediaFile(id); if ("setmediatype".equals(action)) { if ("MULTIARTIST".equals(strmediaType)) { mediaType = MediaType.MULTIARTIST; } if ("ARTIST".equals(strmediaType)) { mediaType = MediaType.ARTIST; } if ("ALBUMSET".equals(strmediaType)) { mediaType = MediaType.ALBUMSET; } if ("ALBUM".equals(strmediaType)) { mediaType = MediaType.ALBUM; } if ("DIRECTORY".equals(strmediaType)) { mediaType = MediaType.DIRECTORY; } if ("AUTO".equals(strmediaType)) { mediaFile.setMediaTypeOverride(false); } else { mediaFile.setMediaType(mediaType); mediaFile.setMediaTypeOverride(true); } mediaFileService.updateMediaFile(mediaFile); } String url = "main.view?id=" + id; return new ModelAndView(new RedirectView(url)); }
From source file:com.opencredo.servlet.BookDisplayCoverController.java
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws IllegalStateException, IOException { // set the content type response.setContentType(CONTENT_TYPE); // get the ID of the book -- set "bad request" if its not a valid integer Integer id;//from www. j av a 2 s . c om try { id = ServletRequestUtils.getIntParameter(request, "book"); if (id == null) throw new IllegalStateException("must specify the book id"); } catch (Exception e) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "invalid book"); return null; } // get the book from the service Book book = bookService.getBook(id); // if the book doesn't exist then set "not found" if (book == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "no such book"); return null; } // if the book doesn't have a picture, set "not found" if (book.getCoverPng() == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "book has no image"); return null; } if (logger.isDebugEnabled()) logger.debug("returning cover for book " + book.getKey() + " '" + book.getTitle() + "'" + " size: " + book.getCoverPng().length + " bytes"); // send the image response.setContentLength(book.getCoverPng().length); response.getOutputStream().write(book.getCoverPng()); response.getOutputStream().flush(); // we already handled the response return null; }
From source file:net.sourceforge.subsonic.controller.SetRatingController.java
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { int id = ServletRequestUtils.getRequiredIntParameter(request, "id"); Integer rating = ServletRequestUtils.getIntParameter(request, "rating"); if (rating == 0) { rating = null;//from ww w . j a v a2 s . c o m } MediaFile mediaFile = mediaFileService.getMediaFile(id); String username = securityService.getCurrentUsername(request); ratingService.setRatingForUser(username, mediaFile, rating); return new ModelAndView(new RedirectView("main.view?id=" + id)); }
From source file:net.sourceforge.subsonic.controller.PodcastReceiverAdminController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Integer channelId = ServletRequestUtils.getIntParameter(request, "channelId"); if (request.getParameter("add") != null) { String url = StringUtils.trim(request.getParameter("add")); podcastService.createChannel(url); return new ModelAndView(new RedirectView("podcastChannels.view")); }/* w ww . j a va 2s . co m*/ if (request.getParameter("downloadEpisode") != null) { download(StringUtil.parseInts(request.getParameter("downloadEpisode"))); return new ModelAndView(new RedirectView("podcastChannel.view?id=" + channelId)); } if (request.getParameter("deleteChannel") != null) { podcastService.deleteChannel(channelId); return new ModelAndView(new RedirectView("podcastChannels.view")); } if (request.getParameter("deleteEpisode") != null) { for (int episodeId : StringUtil.parseInts(request.getParameter("deleteEpisode"))) { podcastService.deleteEpisode(episodeId, true); } return new ModelAndView(new RedirectView("podcastChannel.view?id=" + channelId)); } if (request.getParameter("refresh") != null) { if (channelId != null) { podcastService.refreshChannel(channelId, true); return new ModelAndView(new RedirectView("podcastChannel.view?id=" + channelId)); } else { podcastService.refreshAllChannels(true); return new ModelAndView(new RedirectView("podcastChannels.view")); } } return new ModelAndView(new RedirectView("podcastChannels.view")); }
From source file:org.openmrs.web.controller.report.ReportSchemaXmlFormController.java
/** * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) *//*from w w w. j a v a2s . c o m*/ @Override protected Object formBackingObject(HttpServletRequest request) throws Exception { ReportService reportService = (ReportService) Context.getService(ReportService.class); Integer reportSchemaId = ServletRequestUtils.getIntParameter(request, "reportSchemaId"); log.debug("Getting report schema xml with schema id: " + reportSchemaId); if (reportSchemaId != null) { // fetch the desired reportSchemaXml from the database ReportSchemaXml reportSchemaXml = reportService.getReportSchemaXml(reportSchemaId); // update the stored xml with the reportSchemaId that is in the reportSchemaXml.reportSchemaId column reportSchemaXml.updateXmlFromAttributes(); return reportSchemaXml; } else return new ReportSchemaXml(); }
From source file:no.dusken.aranea.web.control.IssueController.java
public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws PageNotFoundException { // this content does not change that often, allow two hours cache response.setHeader("Cache-Control", "max-age=72000"); Map<String, Object> map = new HashMap<String, Object>(); map.put("baseImageDir", "/images"); // LinkedHashMap maintains order... Map<Integer, Collection> issueMap = new LinkedHashMap<Integer, Collection>(); int year = 0; List<Issue> issues;//from www . j av a 2 s .c o m if (request.getParameter("year") != null) { try { year = ServletRequestUtils.getIntParameter(request, "year"); issues = issueService.getIssuesPublished(year); if (issues == null || issues.size() == 0) { //Throwing exception so this can be threated as a 404 error on a higher level throw new PageNotFoundException("Issue in year " + year); } issueMap.put(year, issues); } catch (ServletRequestBindingException e) { log.info("Unable to get section name from request", e); } } else { // defaulting to all years year = (new GregorianCalendar()).get(GregorianCalendar.YEAR); issues = issueService.getIssuesPublished(year); issueMap.put(year, issues); // get all previous years do { year = year - 1; issues = issueService.getIssuesPublished(year); if (issues != null && issues.size() > 0) { issueMap.put(year, issues); } } while (issues != null && issues.size() > 0); } map.put("issueMap", issueMap); map.put("year", year); return new ModelAndView("no/dusken/aranea/base/web/pdf/view", map); }