org.springframework.data.rest.webmvc.ResourceNotFoundException Java Examples

The following examples show how to use org.springframework.data.rest.webmvc.ResourceNotFoundException. 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: StockProductServiceOfflineImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Transactional
public ChartStock gather(String userId, 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(userId, 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();
}
 
Example #2
Source File: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@ResponseBody
@RequestMapping(value = ENTITY_VERSION_MAPPING, method = RequestMethod.PUT)
public ResponseEntity<Resource<?>> version(RootResourceInformation repoInfo,
										   @PathVariable String repository,
										   @PathVariable String id,
										   @RequestBody VersionInfo info,
										   Principal principal,
										   PersistentEntityResourceAssembler assembler)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	Object domainObj = repoInfo.getInvoker().invokeFindById(id).get();

	domainObj = ReflectionUtils.invokeMethod(VERSION_METHOD, repositories.getRepositoryFor(domainObj.getClass()).get(), domainObj, info);

	if (domainObj != null) {
		return new ResponseEntity(assembler.toResource(domainObj), HttpStatus.OK);
	} else {
		return ResponseEntity.status(HttpStatus.CONFLICT).build();
	}
}
 
Example #3
Source File: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@ResponseBody
@RequestMapping(value = ENTITY_LOCK_MAPPING, method = RequestMethod.DELETE)
public ResponseEntity<Resource<?>> unlock(RootResourceInformation repoInfo,
										  @PathVariable String repository,
										  @PathVariable String id, Principal principal)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	Object domainObj = repoInfo.getInvoker().invokeFindById(id).get();

	domainObj = ReflectionUtils.invokeMethod(UNLOCK_METHOD, repositories.getRepositoryFor(domainObj.getClass()).get(), domainObj);

	if (domainObj != null) {
		return ResponseEntity.ok().build();
	} else {
		return ResponseEntity.status(HttpStatus.CONFLICT).build();
	}
}
 
Example #4
Source File: StockProductServiceOnlineImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Transactional
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();
}
 
Example #5
Source File: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@ResponseBody
@RequestMapping(value = ENTITY_LOCK_MAPPING, method = RequestMethod.PUT)
public ResponseEntity<Resource<?>> lock(RootResourceInformation repoInfo,
										@PathVariable String repository,
										@PathVariable String id, Principal principal)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	Object domainObj = repoInfo.getInvoker().invokeFindById(id).get();

	domainObj = ReflectionUtils.invokeMethod(LOCK_METHOD, repositories.getRepositoryFor(domainObj.getClass()).get(), domainObj);

	if (domainObj != null) {
		return ResponseEntity.ok().build();
	} else {
		return ResponseEntity.status(HttpStatus.CONFLICT).build();
	}
}
 
Example #6
Source File: TvSeriesController.java    From tutorial with MIT License 6 votes vote down vote up
/**
 * 删除资源的例子;如果方法圣母了HttpServletRequest request参数,spring会自动把当前的request传给方法。
 * 类似声明即可得到还有 HttpServletResponse,Authentication、Locale等
 * 
 * @RequestParam(value="delete_reason", required=false) String deleteReason 表示deleteReason参数的值
 * 来自Request的参数delete_reason(等同于request.getParameter("delete_reason"),可以是URL中Querystring,
 * 也可以是form post里的值),required=false表示不是必须的。默认是required=true,required=true时,如果请求
 * 没有传递这个参数,会被返回400错误。
 * 类似的注解还有@CookieValue @RequestHeader等。
 */
@DeleteMapping("/{id}")
public Map<String, String> deleteOne(@PathVariable int id, HttpServletRequest request, 
            @RequestParam(value="delete_reason", required=false) String deleteReason) throws Exception{
    if(log.isTraceEnabled()) {
        log.trace("deleteOne " + id);
    }
    Map<String, String> result = new HashMap<>();
    TvSeries ts = tvSeriesService.getTvSeriesById(id);
    if(ts != null) {
        throw new ResourceNotFoundException();
    }else {
        tvSeriesService.deleteTvSeries(id, deleteReason);
        result.put("message", "#" + id + "被" + request.getRemoteAddr() + "删除(原因:" + deleteReason + ")");
    }
    return result;
}
 
Example #7
Source File: TvSeriesController.java    From tutorial with MIT License 6 votes vote down vote up
/**
 * 
 * @param id
 * @param TvSeries
 * @return
 */
@PutMapping("/{id}")
public TvSeries updateOne(@PathVariable int id, @RequestBody TvSeries tvSeries){
    if(log.isTraceEnabled()) {
        log.trace("updateOne " + id);
    }
    TvSeries ts = tvSeriesService.getTvSeriesById(id);
    if(ts == null) {
        throw new ResourceNotFoundException();
    }
    ts.setSeasonCount(tvSeries.getSeasonCount());
    ts.setName(tvSeries.getName());
    ts.setOriginRelease(tvSeries.getOriginRelease());
    tvSeriesService.updateTvSeries(ts);
    return ts;
}
 
Example #8
Source File: TvSeriesController.java    From tutorial with MIT License 6 votes vote down vote up
/**
 * 
 * @param id
 * @param TvSeriesDto
 * @return
 */
@PutMapping("/{id}")
public TvSeriesDto updateOne(@PathVariable int id, @RequestBody TvSeriesDto tvSeries){
    if(log.isTraceEnabled()) {
        log.trace("updateOne " + id);
    }
    TvSeriesDto ts = tvSeriesService.getTvSeriesById(id);
    if(ts == null) {
        throw new ResourceNotFoundException();
    }
    ts.setSeasonCount(tvSeries.getSeasonCount());
    ts.setName(tvSeries.getName());
    ts.setOriginRelease(tvSeries.getOriginRelease());
    TvSeriesDto dto = tvSeriesService.updateTvSeries(ts);
    return dto;
}
 
Example #9
Source File: TvSeriesController.java    From tutorial with MIT License 6 votes vote down vote up
/**
 * 删除资源的例子;如果方法圣母了HttpServletRequest request参数,spring会自动把当前的request传给方法。
 * 类似声明即可得到还有 HttpServletResponse,Authentication、Locale等
 * 
 * @RequestParam(value="delete_reason", required=false) String deleteReason 表示deleteReason参数的值
 * 来自Request的参数delete_reason(等同于request.getParameter("delete_reason"),可以是URL中Querystring,
 * 也可以是form post里的值),required=false表示不是必须的。默认是required=true,required=true时,如果请求
 * 没有传递这个参数,会被返回400错误。
 * 类似的注解还有@CookieValue @RequestHeader等。
 */
@DeleteMapping("/{id}")
public Map<String, String> deleteOne(@PathVariable int id, HttpServletRequest request, 
            @RequestParam(value="delete_reason", required=false) String deleteReason) throws Exception{
    if(log.isTraceEnabled()) {
        log.trace("deleteOne " + id);
    }
    Map<String, String> result = new HashMap<>();
    TvSeriesDto ts = tvSeriesService.getTvSeriesById(id);
    if(ts != null) {
        throw new ResourceNotFoundException();
    }else {
        tvSeriesService.deleteTvSeries(id, deleteReason);
        result.put("message", "#" + id + "被" + request.getRemoteAddr() + "删除(原因:" + deleteReason + ")");
    }
    return result;
}
 
Example #10
Source File: TvSeriesController.java    From tutorial with MIT License 6 votes vote down vote up
/**
 * 删除资源的例子;如果方法圣母了HttpServletRequest request参数,spring会自动把当前的request传给方法。
 * 类似声明即可得到还有 HttpServletResponse,Authentication、Locale等
 * 
 * @RequestParam(value="delete_reason", required=false) String deleteReason 表示deleteReason参数的值
 * 来自Request的参数delete_reason(等同于request.getParameter("delete_reason"),可以是URL中Querystring,
 * 也可以是form post里的值),required=false表示不是必须的。默认是required=true,required=true时,如果请求
 * 没有传递这个参数,会被返回400错误。
 * 类似的注解还有@CookieValue @RequestHeader等。
 */
@DeleteMapping("/{id}")
public Map<String, String> deleteOne(@PathVariable int id, HttpServletRequest request, 
            @RequestParam(value="delete_reason", required=false) String deleteReason) throws Exception{
    if(log.isTraceEnabled()) {
        log.trace("deleteOne " + id);
    }
    Map<String, String> result = new HashMap<>();
    TvSeries ts = tvSeriesService.getTvSeriesById(id);
    if(ts != null) {
        throw new ResourceNotFoundException();
    }else {
        tvSeriesService.deleteTvSeries(id, deleteReason);
        result.put("message", "#" + id + "被" + request.getRemoteAddr() + "删除(原因:" + deleteReason + ")");
    }
    return result;
}
 
Example #11
Source File: TvSeriesController.java    From tutorial with MIT License 6 votes vote down vote up
/**
 * 删除资源的例子;如果方法圣母了HttpServletRequest request参数,spring会自动把当前的request传给方法。
 * 类似声明即可得到还有 HttpServletResponse,Authentication、Locale等
 * 
 * @RequestParam(value="delete_reason", required=false) String deleteReason 表示deleteReason参数的值
 * 来自Request的参数delete_reason(等同于request.getParameter("delete_reason"),可以是URL中Querystring,
 * 也可以是form post里的值),required=false表示不是必须的。默认是required=true,required=true时,如果请求
 * 没有传递这个参数,会被返回400错误。
 * 类似的注解还有@CookieValue @RequestHeader等。
 */
@DeleteMapping("/{id}")
public Map<String, String> deleteOne(@PathVariable int id, HttpServletRequest request, 
            @RequestParam(value="delete_reason", required=false) String deleteReason) throws Exception{
    if(log.isTraceEnabled()) {
        log.trace("deleteOne " + id);
    }
    Map<String, String> result = new HashMap<>();
    if(id == 101) {
        //TODO: 执行删除的代码
        result.put("message", "#101被" + request.getRemoteAddr() + "删除(原因:" + deleteReason + ")");
    }else if(id == 102) {
        //不能删除这个,RuntimeException不如org.springframework.security.access.AccessDeniedException更合适
        //但此处还没到spring security,所以暂先抛出RuntimeException异常
        throw new RuntimeException("#102不能删除");
    }else {
        //不存在
        throw new ResourceNotFoundException();
    }
    return result;
}
 
Example #12
Source File: TvSeriesController.java    From tutorial with MIT License 6 votes vote down vote up
/**
 * 
 * @param id
 * @param TvSeries
 * @return
 */
@PutMapping("/{id}")
public TvSeries updateOne(@PathVariable int id, @RequestBody TvSeries tvSeries){
    if(log.isTraceEnabled()) {
        log.trace("updateOne " + id);
    }
    TvSeries ts = tvSeriesService.getTvSeriesById(id);
    if(ts == null) {
        throw new ResourceNotFoundException();
    }
    ts.setSeasonCount(tvSeries.getSeasonCount());
    ts.setName(tvSeries.getName());
    ts.setOriginRelease(tvSeries.getOriginRelease());
    tvSeriesService.updateTvSeries(ts);
    return ts;
}
 
Example #13
Source File: IndexServiceOfflineImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Transactional
public ChartIndex gather(String userId, String indexId, ChartType type,
		ChartHistoSize histoSize, ChartHistoMovingAverage histoAverage,
		ChartHistoTimeSpan histoPeriod, Integer intradayWidth,
		Integer intradayHeight) throws ResourceNotFoundException {
	
	Preconditions.checkNotNull(type, "ChartType must not be null!");
	
	Index index = gather(userId, indexId);
	ChartIndex chartIndex = getChartIndex(index, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight);
	Integer ttl = Integer.parseInt(env.getProperty("yahoo.graphs."+type.name().toLowerCase()+".ttl.minutes"));

	if(chartIndex!=null && !chartIndex.isExpired(ttl)){
		log.debug("chartIndex!=null && !chartIndex.isExpired(ttl)");
		return chartIndex;
	}
	else if(AuthenticationUtil.userHasRole(Role.ROLE_OAUTH2)){
		log.debug("AuthenticationUtil.userHasRole(Role.ROLE_OAUTH2)");
		log.debug("updateChartIndexFromYahoo("+index+", "+type+", "+histoSize+", "+histoAverage+", "+histoPeriod+", "+intradayWidth+", "+intradayHeight+")");
		updateChartIndexFromYahoo(index, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight);
		return getChartIndex(index, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight);
	}
	else if(chartIndex != null){
		return chartIndex;
	}
	throw new ResourceNotFoundException();
}
 
Example #14
Source File: IndexServiceImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Index getIndex(String id) {
	Index index = indexRepository.findOne(id);
	if(index == null){
		throw new ResourceNotFoundException(bundle.getFormatted(I18N_INDICES_INDEX_NOT_FOUND, id));
	}
	return index;
}
 
Example #15
Source File: IndustryServiceImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Industry get(Long id) {
	Industry industry = industryRepository.findOne(id);
	if(industry == null){
		throw new ResourceNotFoundException("No industry has been found for the provided industry ID: "+id);
	}
	return industry;
}
 
Example #16
Source File: AdResourceController.java    From spring-rest-black-market with MIT License 5 votes vote down vote up
@RequestMapping(value = "/ads/{id}/expiration", method = RequestMethod.HEAD)
@ResponseBody
public void expirationHead(@PathVariable("id") Long id) {
    Ad ad = adService.findOne(id);
    if (ad == null || ad.getStatus() != Ad.Status.PUBLISHED) {
        throw new ResourceNotFoundException();
    }
}
 
Example #17
Source File: MarketServiceImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Market get(MarketId marketId) {
	Market market = marketRepository.findOne(marketId);
	if(market == null){
		logger.debug("The requested market " + marketId + " was not found");
		throw new ResourceNotFoundException("No market has been found for the provided market ID: "+marketId);
	}
	return market;
}
 
Example #18
Source File: CommunityServiceImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@Override
public UserDTO getUser(String username) {
	User user = userRepository.findOne(username);
	if(user == null){
		throw new ResourceNotFoundException();
	}
	UserDTO userDTO = new UserDTO(user);
	return hideSensitiveFieldsIfNecessary(userDTO);
}
 
Example #19
Source File: CommunityServiceImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@Override
public UserDTO findByLogin(String login) {
	User user = userRepository.findOne(login);
	if(user == null){
		throw new ResourceNotFoundException();
	}
	UserDTO userDTO = new UserDTO(user);
	return hideSensitiveFieldsIfNecessary(userDTO);
}
 
Example #20
Source File: IndexServiceOnlineImpl.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Transactional
public ChartIndex gather(String indexId, ChartType type,
		ChartHistoSize histoSize, ChartHistoMovingAverage histoAverage,
		ChartHistoTimeSpan histoPeriod, Integer intradayWidth,
		Integer intradayHeight) throws ResourceNotFoundException {
	
	Preconditions.checkNotNull(type, "ChartType must not be null!");
	
	Index index = gather(indexId);
	ChartIndex chartIndex = getChartIndex(index, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight);
	Integer ttl = Integer.parseInt(env.getProperty("yahoo.graphs."+type.name().toLowerCase()+".ttl.minutes"));

	if(chartIndex!=null && !chartIndex.isExpired(ttl)){
		log.debug("chartIndex!=null && !chartIndex.isExpired(ttl)");
		return chartIndex;
	}
	else if(AuthenticationUtil.userHasRole(Role.ROLE_OAUTH2)){
		log.debug("AuthenticationUtil.userHasRole(Role.ROLE_OAUTH2)");
		log.debug("updateChartIndexFromYahoo("+index+", "+type+", "+histoSize+", "+histoAverage+", "+histoPeriod+", "+intradayWidth+", "+intradayHeight+")");
		updateChartIndexFromYahoo(index, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight);
		return getChartIndex(index, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight);
	}
	else if(chartIndex != null){
		return chartIndex;
	}
	throw new ResourceNotFoundException();
}
 
Example #21
Source File: ChartStockController.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@RequestMapping(value="/{ticker:[a-zA-Z0-9.:-]+}{extension:\\.[a-z]+}", method=GET)
@ApiOperation(value = "Get chart for one stock", notes = "Return a chart from one stock")
public HttpEntity<byte[]> get(
		@ApiParam(value="StockProduct ID: QACL.HM") @PathVariable("ticker") String ticker,
		@ApiParam(value="Extension: json") @PathVariable(value="extension") String extension,
		@ApiParam(value="Histo chart period: 1y") @RequestParam(value="period", required=false) ChartHistoTimeSpan histoPeriod,
		@ApiParam(value="Moving average line: m50") @RequestParam(value="average", required=false) ChartHistoMovingAverage histoAverage,
		@ApiParam(value="Histo chart size: l/m/s") @RequestParam(value="size", required=false) ChartHistoSize histoSize,
		@ApiParam(value="Chart-type INTRADAY / HISTO") @RequestParam(value="type", defaultValue="INTRADAY", required=false) ChartType type,
		@ApiParam(value="Intraday chart width: 300") @RequestParam(value="width", defaultValue="300", required=false) Integer intradayWidth,
		@ApiParam(value="Intraday chart height: 160") @RequestParam(value="height", defaultValue="160", required=false) Integer intradayHeight,
		HttpServletResponse response) throws IOException{
	
	HttpHeaders headers = new HttpHeaders();
	byte[] bytes = null;
	
	try{
		ChartStock chartStock = stockProductService.gather(ticker, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight);
		bytes = Files.readAllBytes(Paths.get(chartStock.getPath()));
	}
	catch(ResourceNotFoundException e){
		response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    	String pathToYahooPicture = env.getProperty("user.home").concat(env.getProperty("pictures.yahoo.path").concat(File.separator+"graph_not_found.png"));
    	log.error("Resource not found: "+pathToYahooPicture, e);
		bytes = Files.readAllBytes(Paths.get(pathToYahooPicture));
	}

	return new HttpEntity<>(bytes, headers);
}
 
Example #22
Source File: AdResourceController.java    From spring-rest-black-market with MIT License 5 votes vote down vote up
@RequestMapping(value = "/ads/{id}/publishing", method = RequestMethod.HEAD)
@ResponseBody
public void publishHead(@PathVariable("id") Long id) {
    Ad ad = adService.findOne(id);
    if (ad == null || ad.getStatus() != Ad.Status.NEW) {
        throw new ResourceNotFoundException();
    }
}
 
Example #23
Source File: ResourceExceptionHandler.java    From acelera-dev-sp-2019 with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<StandardError> resourceNotFound(ResourceNotFoundException e, HttpServletRequest request)
{
	HttpStatus status = HttpStatus.NOT_FOUND;
	StandardError err = StandardError.builder()
			.timestamp(System.currentTimeMillis())
			.status(status.value())
			.error("Recurso não encontrado")
			.message(e.getMessage())
			.path(request.getRequestURI())
			.build();

	return ResponseEntity.status(status).body(err);
}
 
Example #24
Source File: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@ResponseBody
@RequestMapping(value = ENTITY_FINDALLLATESTVERSION_MAPPING, method = RequestMethod.GET)
public ResponseEntity<?> findAllLatestVersion(RootResourceInformation repoInfo,
											  PersistentEntityResourceAssembler assembler,
											  @PathVariable String repository)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	RepositoryInformation repositoryInfo = RepositoryUtils.findRepositoryInformation(repositories, repository);
	Class<?> domainType = repositoryInfo.getDomainType();

	List result = (List)ReflectionUtils.invokeMethod(FINDALLLATESTVERSION_METHOD, repositories.getRepositoryFor(domainType).get());

	return ResponseEntity.ok(toResources(result, assembler, this.pagedResourcesAssembler, domainType, null));
}
 
Example #25
Source File: TvSeriesController.java    From tutorial with MIT License 5 votes vote down vote up
@GetMapping("/{id}")
public TvSeries getOne(@PathVariable int id){
    if(log.isTraceEnabled()) {
        log.trace("getOne " + id);
    }
    TvSeries ts = tvSeriesService.getTvSeriesById(id);
    if(ts == null) {
        throw new ResourceNotFoundException();
    }
    return ts;
}
 
Example #26
Source File: TvSeriesController.java    From tutorial with MIT License 5 votes vote down vote up
@GetMapping("/{id}")
public TvSeries getOne(@PathVariable int id){
    if(log.isTraceEnabled()) {
        log.trace("getOne " + id);
    }
    TvSeries ts = tvSeriesService.getTvSeriesById(id);
    if(ts == null) {
        throw new ResourceNotFoundException();
    }
    return ts;
}
 
Example #27
Source File: TvSeriesController.java    From tutorial with MIT License 5 votes vote down vote up
/**
 * 
 * @param id
 * @param tvSeriesDto
 * @return
 */
@PutMapping("/{id}")
public TvSeriesDto updateOne(@PathVariable int id, @RequestBody TvSeriesDto tvSeriesDto){
    if(log.isTraceEnabled()) {
        log.trace("updateOne " + id);
    }
    if(id == 101 || id == 102) {
        //TODO: 根据tvSeriesDto的内容更新数据库,更新后返回新
        return createPoi();
    }else {
        throw new ResourceNotFoundException();
    }
}
 
Example #28
Source File: LockingAndVersioningRestController.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@ResponseBody
@RequestMapping(value = FINDALLVERSIONS_METHOD_MAPPING, method = RequestMethod.GET)
public ResponseEntity<?> findAllVersions(RootResourceInformation repoInfo,
										 PersistentEntityResourceAssembler assembler,
										 @PathVariable String repository,
										 @PathVariable String id)
		throws ResourceNotFoundException, HttpRequestMethodNotSupportedException {

	Object domainObj = repoInfo.getInvoker().invokeFindById(id).get();

	List result = (List)ReflectionUtils.invokeMethod(FINDALLVERSIONS_METHOD, repositories.getRepositoryFor(domainObj.getClass()).get(), domainObj);

	return ResponseEntity.ok(toResources(result, assembler, this.pagedResourcesAssembler, domainObj.getClass(), null));
}
 
Example #29
Source File: TvSeriesController.java    From tutorial with MIT License 5 votes vote down vote up
@GetMapping("/{id}")
public TvSeriesDto getOne(@PathVariable int id){
    if(log.isTraceEnabled()) {
        log.trace("getOne " + id);
    }
    if(id == 101) {
        return createWestWorld();
    }else if(id == 102) {
        return createPoi();
    }else {
        throw new ResourceNotFoundException();
    }
}
 
Example #30
Source File: TvSeriesController.java    From tutorial with MIT License 5 votes vote down vote up
@GetMapping("/{id}")
public TvSeriesDto getOne(@PathVariable int id){
    if(log.isTraceEnabled()) {
        log.trace("getOne " + id);
    }
    TvSeriesDto ts = tvSeriesService.getTvSeriesById(id);
    if(ts == null) {
        throw new ResourceNotFoundException();
    }
    return ts;
}