List of usage examples for org.springframework.data.rest.webmvc ResourceNotFoundException ResourceNotFoundException
public ResourceNotFoundException()
From source file:org.ng200.openolympus.Assertions.java
public static void resourceExists(final Object contest) { if (contest == null) { throw new ResourceNotFoundException(); }/*w w w .j a v a 2 s.co m*/ }
From source file:org.ng200.openolympus.controller.task.ArchiveTaskListController.java
@RequestMapping(value = "/archive", method = RequestMethod.GET) public String listTasks(@RequestParam(value = "page", defaultValue = "1") final Integer pageNumber, final Model model, final Principal principal) { if (pageNumber < 1) { throw new ResourceNotFoundException(); }//from w w w .j a v a 2 s.c om this.assertSuperuserOrNoRestrictionMode(principal); final PageRequest request = new PageRequest(pageNumber - 1, ArchiveTaskListController.PAGE_SIZE, Sort.Direction.DESC, "timeAdded"); model.addAttribute("tasks", this.taskRepository.findAll(request)); model.addAttribute("numberOfPages", Math.max((this.taskRepository.count() + ArchiveTaskListController.PAGE_SIZE - 1) / ArchiveTaskListController.PAGE_SIZE, 1)); model.addAttribute("currentPage", pageNumber); model.addAttribute("pagePrefix", "/archive?page="); return "archive/archive"; }
From source file:org.ng200.openolympus.controller.admin.UserListController.java
@RequestMapping(value = "/admin/users", method = RequestMethod.GET) public String listTasks(@RequestParam(value = "page", defaultValue = "1") final Integer pageNumber, final Model model, final Principal principal) { if (pageNumber < 1) { throw new ResourceNotFoundException(); }// ww w .j a v a 2s . c om this.assertSuperuserOrNoRestrictionMode(principal); final PageRequest request = new PageRequest(pageNumber - 1, UserListController.PAGE_SIZE, Sort.Direction.DESC, "firstNameMain"); model.addAttribute("users", this.userRepository.findAll(request)); model.addAttribute("numberOfPages", Math.max( (this.userRepository.count() + UserListController.PAGE_SIZE - 1) / UserListController.PAGE_SIZE, 1)); model.addAttribute("currentPage", pageNumber); model.addAttribute("pagePrefix", "/admin/users?page="); return "admin/users"; }
From source file:org.ng200.openolympus.controller.contest.ContestListController.java
@RequestMapping(value = "/contests", method = RequestMethod.GET) public String contestList(@RequestParam(value = "page", defaultValue = "1") final Integer pageNumber, @RequestParam(value = "message", required = false) final String message, final Model model, final Principal principal) { if (pageNumber < 1) { throw new ResourceNotFoundException(); }//from www . ja v a2s . c om final PageRequest request = new PageRequest(pageNumber - 1, ContestListController.PAGE_SIZE, Direction.DESC, "startTime"); model.addAttribute("contests", this.contestRepository.findAll(request)); model.addAttribute("numberOfPages", Math.max((this.contestRepository.count() + ContestListController.PAGE_SIZE - 1) / ContestListController.PAGE_SIZE, 1)); model.addAttribute("currentPage", pageNumber); model.addAttribute("pagePrefix", "/contests?page="); model.addAttribute("message", message); return "contest/contests"; }
From source file:org.lightadmin.core.web.RepositoryFilePropertyController.java
@RequestMapping(value = BASE_MAPPING + "/file", method = GET) public void filePropertyOfEntity(RootResourceInformation repoRequest, ServletResponse response, @BackendId Serializable id, @PathVariable String property) throws Exception { PersistentEntity<?, ?> persistentEntity = repoRequest.getPersistentEntity(); RepositoryInvoker invoker = repoRequest.getInvoker(); Object domainObj = invoker.invokeFindOne(id); if (null == domainObj) { throw new ResourceNotFoundException(); }//from w w w .ja v a 2 s.c o m PersistentProperty<?> prop = persistentEntity.getPersistentProperty(property); if (null == prop) { throw new ResourceNotFoundException(); } if (isOfFileType(prop)) { fileResourceLoader().downloadFile(domainObj, prop, (HttpServletResponse) response); } }
From source file:org.magnum.mobilecloud.video.AFilledController.java
@RequestMapping(value = VIDEO_LIKEDBY_PATH, method = RequestMethod.GET) public @ResponseBody Set<String> likedbyVideo(@PathVariable(VIDEO_ID) long id) { Video v = videos.findOne(id);//ww w . j a v a2 s . co m if (v == null) { throw new ResourceNotFoundException(); } return v.getLikedUsers(); }
From source file:org.lightadmin.core.web.RepositoryFilePropertyController.java
@RequestMapping(value = BASE_MAPPING + "/binary", method = GET) public ResponseEntity<?> filePropertyValueOfEntity(RootResourceInformation repoRequest, @BackendId Serializable id, @PathVariable String property) throws Exception { PersistentEntity<?, ?> persistentEntity = repoRequest.getPersistentEntity(); RepositoryInvoker invoker = repoRequest.getInvoker(); Object domainObj = invoker.invokeFindOne(id); if (null == domainObj) { throw new ResourceNotFoundException(); }// w ww.j a v a 2 s .co m PersistentProperty<?> prop = persistentEntity.getPersistentProperty(property); if (null == prop) { throw new ResourceNotFoundException(); } if (isOfFileType(prop)) { return toResponseEntity(OK, new HttpHeaders(), new Resource<FilePropertyValue>(evaluateFilePropertyValue(domainObj, prop))); } return toEmptyResponse(METHOD_NOT_ALLOWED); }
From source file:org.lightadmin.core.web.RepositoryFilePropertyController.java
@RequestMapping(value = BASE_MAPPING + "/file", method = DELETE) public ResponseEntity<?> deleteFileOfPropertyOfEntity(RootResourceInformation repoRequest, @BackendId Serializable id, @PathVariable String property) throws Exception { PersistentEntity<?, ?> persistentEntity = repoRequest.getPersistentEntity(); RepositoryInvoker invoker = repoRequest.getInvoker(); Object domainObj = invoker.invokeFindOne(id); if (null == domainObj) { throw new ResourceNotFoundException(); }/*from w ww . jav a 2 s . co m*/ PersistentProperty<?> prop = persistentEntity.getPersistentProperty(property); if (null == prop) { throw new ResourceNotFoundException(); } if (!isOfFileType(prop)) { return toEmptyResponse(METHOD_NOT_ALLOWED); } fileResourceStorage().delete(domainObj, prop); invoker.invokeSave(domainObj); return toEmptyResponse(OK); }
From source file:edu.zipcloud.cloudstreetmarket.api.services.StockProductServiceOnlineImpl.java
@Override @Transactional//w w w. j av a 2 s . c om public ChartStock gather(String stockProductId, ChartType type, ChartHistoSize histoSize, ChartHistoMovingAverage histoAverage, ChartHistoTimeSpan histoPeriod, Integer intradayWidth, Integer intradayHeight) throws ResourceNotFoundException { Preconditions.checkNotNull(type, "ChartType must not be null!"); StockProduct stock = gather(stockProductId); ChartStock chartStock = getChartStock(stock, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight); if (AuthenticationUtil.userHasRole(Role.ROLE_OAUTH2)) { updateChartStockFromYahoo(stock, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight); return getChartStock(stock, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight); } else if (chartStock != null) { return chartStock; } throw new ResourceNotFoundException(); }