Java Code Examples for org.springframework.web.bind.ServletRequestUtils#getIntParameter()
The following examples show how to use
org.springframework.web.bind.ServletRequestUtils#getIntParameter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
private VideoTranscodingSettings createVideoTranscodingSettings(MediaFile file, HttpServletRequest request) throws ServletRequestBindingException { Integer existingWidth = file.getWidth(); Integer existingHeight = file.getHeight(); Integer maxBitRate = ServletRequestUtils.getIntParameter(request, "maxBitRate"); int timeOffset = ServletRequestUtils.getIntParameter(request, "timeOffset", 0); double defaultDuration = file.getDuration() == null ? Double.MAX_VALUE : file.getDuration() - timeOffset; double duration = ServletRequestUtils.getDoubleParameter(request, "duration", defaultDuration); boolean hls = ServletRequestUtils.getBooleanParameter(request, "hls", false); Dimension dim = getRequestedVideoSize(request.getParameter("size")); if (dim == null) { dim = getSuitableVideoSize(existingWidth, existingHeight, maxBitRate); } return new VideoTranscodingSettings(dim.width, dim.height, timeOffset, duration, hls); }
Example 2
Source File: StreamController.java From airsonic with GNU General Public License v3.0 | 6 votes |
private VideoTranscodingSettings createVideoTranscodingSettings(MediaFile file, HttpServletRequest request) throws ServletRequestBindingException { Integer existingWidth = file.getWidth(); Integer existingHeight = file.getHeight(); Integer maxBitRate = ServletRequestUtils.getIntParameter(request, "maxBitRate"); int timeOffset = ServletRequestUtils.getIntParameter(request, "timeOffset", 0); int defaultDuration = file.getDurationSeconds() == null ? Integer.MAX_VALUE : file.getDurationSeconds() - timeOffset; int duration = ServletRequestUtils.getIntParameter(request, "duration", defaultDuration); boolean hls = ServletRequestUtils.getBooleanParameter(request, "hls", false); Dimension dim = getRequestedVideoSize(request.getParameter("size")); if (dim == null) { dim = getSuitableVideoSize(existingWidth, existingHeight, maxBitRate); } return new VideoTranscodingSettings(dim.width, dim.height, timeOffset, duration, hls); }
Example 3
Source File: CaptchaValidateCodeGenerator.java From codeway_service with GNU General Public License v3.0 | 5 votes |
@Override public Captcha generate(ServletWebRequest request) { int width = ServletRequestUtils.getIntParameter(request.getRequest(), "width", securityProperties.getCode().getImage().getWidth()); int height = ServletRequestUtils.getIntParameter(request.getRequest(), "height", securityProperties.getCode().getImage().getHeight()); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); Random random = new Random(); g.setColor(getRandColor(200, 250)); g.fillRect(0, 0, width, height); g.setFont(new Font("Times New Roman", Font.ITALIC, 20)); g.setColor(getRandColor(160, 200)); for (int i = 0; i < 155; i++) { int x = random.nextInt(width); int y = random.nextInt(height); int xl = random.nextInt(12); int yl = random.nextInt(12); g.drawLine(x, y, x + xl, y + yl); } String sRand = ""; for (int i = 0; i < securityProperties.getCode().getImage().getLength(); i++) { String rand = String.valueOf(random.nextInt(10)); sRand += rand; g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); g.drawString(rand, 30 * i + 6, 23); } g.dispose(); return new Captcha(image, sRand, securityProperties.getCode().getImage().getExpireIn()); }
Example 4
Source File: ShareManagementController.java From airsonic with GNU General Public License v3.0 | 5 votes |
private List<MediaFile> getMediaFiles(HttpServletRequest request) throws Exception { Integer id = ServletRequestUtils.getIntParameter(request, "id"); Integer playerId = ServletRequestUtils.getIntParameter(request, "player"); Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist"); List<MediaFile> result = new ArrayList<>(); if (id != null) { MediaFile album = mediaFileService.getMediaFile(id); int[] indexes = ServletRequestUtils.getIntParameters(request, "i"); if (indexes.length == 0) { return Arrays.asList(album); } List<MediaFile> children = mediaFileService.getChildrenOf(album, true, false, true); for (int index : indexes) { result.add(children.get(index)); } } else if (playerId != null) { Player player = playerService.getPlayerById(playerId); PlayQueue playQueue = player.getPlayQueue(); result = playQueue.getFiles(); } else if (playlistId != null) { result = playlistService.getFilesInPlaylist(playlistId); } return result; }
Example 5
Source File: UserSettingsController.java From airsonic with GNU General Public License v3.0 | 5 votes |
private User getUser(HttpServletRequest request) throws ServletRequestBindingException { Integer userIndex = ServletRequestUtils.getIntParameter(request, "userIndex"); if (userIndex != null) { List<User> allUsers = securityService.getAllUsers(); if (userIndex >= 0 && userIndex < allUsers.size()) { return allUsers.get(userIndex); } } return null; }
Example 6
Source File: PodcastReceiverAdminController.java From airsonic with GNU General Public License v3.0 | 5 votes |
@RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }) 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")); } if (request.getParameter("downloadEpisode") != null && channelId != null) { download(StringUtil.parseInts(request.getParameter("downloadEpisode"))); return new ModelAndView(new RedirectView("podcastChannel.view?id=" + channelId)); } if (request.getParameter("deleteChannel") != null && channelId != 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")); }
Example 7
Source File: PostController.java From mblog with GNU General Public License v3.0 | 5 votes |
@RequestMapping("/list") public String list(String title, ModelMap model, HttpServletRequest request) { long id = ServletRequestUtils.getLongParameter(request, "id", Consts.ZERO); int channelId = ServletRequestUtils.getIntParameter(request, "channelId", Consts.ZERO); Pageable pageable = wrapPageable(Sort.by(Sort.Direction.DESC, "weight", "created")); Page<PostVO> page = postService.paging4Admin(pageable, channelId, title); model.put("page", page); model.put("title", title); model.put("id", id); model.put("channelId", channelId); model.put("channels", channelService.findAll(Consts.IGNORE)); return "/admin/post/list"; }
Example 8
Source File: CaptchaValidateCodeGenerator.java From codeway_service with GNU General Public License v3.0 | 5 votes |
@Override public Captcha generate(ServletWebRequest request) { int width = ServletRequestUtils.getIntParameter(request.getRequest(), "width", securityProperties.getCode().getImage().getWidth()); int height = ServletRequestUtils.getIntParameter(request.getRequest(), "height", securityProperties.getCode().getImage().getHeight()); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); Random random = new Random(); g.setColor(getRandColor(200, 250)); g.fillRect(0, 0, width, height); g.setFont(new Font("Times New Roman", Font.ITALIC, 20)); g.setColor(getRandColor(160, 200)); for (int i = 0; i < 155; i++) { int x = random.nextInt(width); int y = random.nextInt(height); int xl = random.nextInt(12); int yl = random.nextInt(12); g.drawLine(x, y, x + xl, y + yl); } String sRand = ""; for (int i = 0; i < securityProperties.getCode().getImage().getLength(); i++) { String rand = String.valueOf(random.nextInt(10)); sRand += rand; g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); g.drawString(rand, 30 * i + 6, 23); } g.dispose(); return new Captcha(image, sRand, securityProperties.getCode().getImage().getExpireIn()); }
Example 9
Source File: ValidateCodeServiceImpl.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
@Override public ImageCode generate(ServletWebRequest request) { int width = ServletRequestUtils.getIntParameter(request.getRequest(), "width", securityProperties.getCode().getImage().getWidth()); int height = ServletRequestUtils.getIntParameter(request.getRequest(), "height", securityProperties.getCode().getImage().getHeight()); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); Random random = new Random(); g.setColor(getRandColor(200, 250)); g.fillRect(0, 0, width, height); g.setFont(new Font("Times New Roman", Font.ITALIC, 20)); g.setColor(getRandColor(160, 200)); for (int i = 0; i < 155; i++) { int x = random.nextInt(width); int y = random.nextInt(height); int xl = random.nextInt(12); int yl = random.nextInt(12); g.drawLine(x, y, x + xl, y + yl); } String sRand = ""; for (int i = 0; i < securityProperties.getCode().getImage().getLength(); i++) { String rand = String.valueOf(random.nextInt(10)); sRand += rand; g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); g.drawString(rand, 13 * i + 6, 16); } g.dispose(); return new ImageCode(image, sRand, securityProperties.getCode().getImage().getExpireIn()); }
Example 10
Source File: StreamController.java From airsonic with GNU General Public License v3.0 | 5 votes |
private MediaFile getSingleFile(HttpServletRequest request) throws ServletRequestBindingException { String path = request.getParameter("path"); if (path != null) { return mediaFileService.getMediaFile(path); } Integer id = ServletRequestUtils.getIntParameter(request, "id"); if (id != null) { return mediaFileService.getMediaFile(id); } return null; }
Example 11
Source File: BaseController.java From EasyEE with MIT License | 5 votes |
/** * 获得分页对象,自动封装客户端提交的分页参数 * * @return */ @SuppressWarnings("rawtypes") public PageBean getPageBean() { PageBean pb = new PageBean(); /* * EasyUI Pagination parameter EasyUI Sort parameter */ int page = ServletRequestUtils.getIntParameter(request, "page", 1); int rows = ServletRequestUtils.getIntParameter(request, "rows", 10); String sort = ServletRequestUtils.getStringParameter(request, "sort", ""); String order = ServletRequestUtils.getStringParameter(request, "order", ""); pb.setPageNo(page); pb.setRowsPerPage(rows); // 分页排序 // 防止SQL注入过滤 sort = StringUtils.filterSQLCondition(sort); // 防止SQL注入过滤 order = StringUtils.filterSQLCondition(order); if (isNotNullAndEmpty(sort)) { pb.setSort(sort); } if (isNotNullAndEmpty(order)) { pb.setSortOrder(order); } return pb; }
Example 12
Source File: BaseController.java From mblog with GNU General Public License v3.0 | 5 votes |
protected PageRequest wrapPageable(Sort sort) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); int pageSize = ServletRequestUtils.getIntParameter(request, "pageSize", 10); int pageNo = ServletRequestUtils.getIntParameter(request, "pageNo", 1); if (null == sort) { sort = Sort.unsorted(); } return PageRequest.of(pageNo - 1, pageSize, sort); }
Example 13
Source File: HLSController.java From subsonic with GNU General Public License v3.0 | 5 votes |
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setHeader("Access-Control-Allow-Origin", "*"); int id = ServletRequestUtils.getIntParameter(request, "id"); MediaFile mediaFile = mediaFileService.getMediaFile(id); Player player = playerService.getPlayer(request, response); String username = player.getUsername(); if (mediaFile == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Media file not found: " + id); return null; } if (username != null && !securityService.isFolderAccessAllowed(mediaFile, username)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "Access to file " + mediaFile.getId() + " is forbidden for user " + username); return null; } Integer duration = mediaFile.getDurationSeconds(); if (duration == null || duration == 0) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unknown duration for media file: " + id); return null; } response.setContentType("application/vnd.apple.mpegurl"); response.setCharacterEncoding(StringUtil.ENCODING_UTF8); List<Pair<Integer, Dimension>> bitRates = parseBitRates(request); PrintWriter writer = response.getWriter(); if (bitRates.size() > 1) { generateVariantPlaylist(request, id, player, bitRates, writer); } else { generateNormalPlaylist(request, id, player, bitRates.size() == 1 ? bitRates.get(0) : null, duration, writer); } return null; }
Example 14
Source File: SetRatingController.java From subsonic with GNU General Public License v3.0 | 5 votes |
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; } MediaFile mediaFile = mediaFileService.getMediaFile(id); String username = securityService.getCurrentUsername(request); ratingService.setRatingForUser(username, mediaFile, rating); return new ModelAndView(new RedirectView("main.view?id=" + id)); }
Example 15
Source File: LeftController.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
private boolean saveSelectedMusicFolder(HttpServletRequest request) throws Exception { Integer musicFolderId = ServletRequestUtils.getIntParameter(request, "musicFolderId"); if (musicFolderId == null) { return false; } // Note: UserSettings.setChanged() is intentionally not called. This would break browser caching // of the left frame. UserSettings settings = settingsService.getUserSettings(securityService.getCurrentUsername(request)); settings.setSelectedMusicFolderId(musicFolderId); settingsService.updateUserSettings(settings); return true; }
Example 16
Source File: UploadController.java From mblog with GNU General Public License v3.0 | 4 votes |
@PostMapping("/upload") @ResponseBody public UploadResult upload(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request) throws IOException { UploadResult result = new UploadResult(); String crop = request.getParameter("crop"); int size = ServletRequestUtils.getIntParameter(request, "size", siteOptions.getIntegerValue(Consts.STORAGE_MAX_WIDTH)); // 检查空 if (null == file || file.isEmpty()) { return result.error(errorInfo.get("NOFILE")); } String fileName = file.getOriginalFilename(); // 检查类型 if (!FileKit.checkFileType(fileName)) { return result.error(errorInfo.get("TYPE")); } // 检查大小 String limitSize = siteOptions.getValue(Consts.STORAGE_LIMIT_SIZE); if (StringUtils.isBlank(limitSize)) { limitSize = "2"; } if (file.getSize() > (Long.parseLong(limitSize) * 1024 * 1024)) { return result.error(errorInfo.get("SIZE")); } // 保存图片 try { String path; if (StringUtils.isNotBlank(crop)) { Integer[] imageSize = siteOptions.getIntegerArrayValue(crop, Consts.SEPARATOR_X); int width = ServletRequestUtils.getIntParameter(request, "width", imageSize[0]); int height = ServletRequestUtils.getIntParameter(request, "height", imageSize[1]); path = storageFactory.get().storeScale(file, Consts.thumbnailPath, width, height); } else { path = storageFactory.get().storeScale(file, Consts.thumbnailPath, size); } result.ok(errorInfo.get("SUCCESS")); result.setName(fileName); result.setPath(path); result.setSize(file.getSize()); } catch (Exception e) { result.error(errorInfo.get("UNKNOWN")); e.printStackTrace(); } return result; }
Example 17
Source File: ShareManagementController.java From airsonic with GNU General Public License v3.0 | 4 votes |
private String getDescription(HttpServletRequest request) throws ServletRequestBindingException { Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist"); return playlistId == null ? null : playlistService.getPlaylist(playlistId).getName(); }
Example 18
Source File: DownloadController.java From subsonic with GNU General Public License v3.0 | 4 votes |
private MediaFile getMediaFile(HttpServletRequest request) throws ServletRequestBindingException { Integer id = ServletRequestUtils.getIntParameter(request, "id"); return id == null ? null : mediaFileService.getMediaFile(id); }
Example 19
Source File: PageHelper.java From TinyMooc with Apache License 2.0 | 4 votes |
public static int getCurPage() { int curPage = ServletRequestUtils.getIntParameter(ServletUtil.getRequest(), "curPage", 1); if (curPage < 1) curPage = 1; return curPage; }
Example 20
Source File: PageHelper.java From TinyMooc with Apache License 2.0 | 4 votes |
public static int getPageSize() { return ServletRequestUtils.getIntParameter(ServletUtil.getRequest(), "pageSize", 10); }