本文整理汇总了Java中org.springframework.http.HttpStatus.NOT_FOUND属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.NOT_FOUND属性的具体用法?Java HttpStatus.NOT_FOUND怎么用?Java HttpStatus.NOT_FOUND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.NOT_FOUND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: linkSprintIdWithStoryId
@JsonView(JsonViews.Basique.class)
@RequestMapping(value = "/api/sprint/{idSprint}/story/{idStory}", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity<Sprint> linkSprintIdWithStoryId(@PathVariable Long idSprint, @PathVariable Long idStory)
{
LOGGER.debug("ApiController - linkSprintIdWithStoryId");
Story story = storyService.findOneByIdWithAll(idStory);
Sprint sprint = sprintService.findOneByIdWithAll(idSprint);
if(null==sprint ||null ==story)
{
return new ResponseEntity<Sprint>(sprint, HttpStatus.NOT_FOUND);
}
story.setStorySprint(sprint);
story = storyService.save(story);
sprint = sprintService.findOneByIdWithAll(idSprint);
return new ResponseEntity<Sprint>(sprint, HttpStatus.CREATED);
}
示例2: exception
@CrossOrigin
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
public MessageDTO exception(NotFoundException e) {
return new MessageDTO(e.getMessage());
}
示例3: handleNotFound
@ResponseStatus(HttpStatus.NOT_FOUND)
// 404
@ExceptionHandler(FlowableObjectNotFoundException.class)
@ResponseBody
public ErrorInfo handleNotFound(FlowableObjectNotFoundException e) {
LOGGER.error("Not found", e);
return new ErrorInfo("Not found", e);
}
示例4: getBook
@GetMapping("/books/{ISBN}")
public ResponseEntity getBook(@PathVariable long ISBN) {
Book book = bookDAO.getBook(ISBN);
if (null == book) {
return new ResponseEntity<Book>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity(book, HttpStatus.OK);
}
示例5: getUser
@RequestMapping(value = "/users/{id}", method = RequestMethod.GET)
public ResponseEntity<?> getUser(@PathVariable("id") long id) {
logger.info("Fetching User with id {}", id);
User user = userService.getById(id);
if (user == null) {
logger.error("User with id {} not found.", id);
return new ResponseEntity(new CustomErrorType("User with id " + id
+ " not found"), HttpStatus.NOT_FOUND);
}
user.setAnswers(null);
user.setQuestions(null);
user.setPassword(null);
return new ResponseEntity<User>(user, HttpStatus.OK);
}
示例6: updateEngine
/**
* Updates the Engine configuration for a bot.
*
* @param user the authenticated user making the request.
* @param engineConfig the Engine config to update.
* @param botId the id of the Bot to update the Engine config for.
* @return 200 'Ok' HTTP status code with updated Engine config if update successful, some other HTTP status code otherwise.
*/
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(value = "/{botId}" + ENGINE_RESOURCE_PATH, method = RequestMethod.PUT)
public ResponseEntity<?> updateEngine(@AuthenticationPrincipal User user, @RequestBody EngineConfig engineConfig,
@PathVariable String botId) {
LOG.info("PUT " + CONFIG_ENDPOINT_BASE_URI + botId + ENGINE_RESOURCE_PATH + " - updateEngine() "); //- caller: " + user.getUsername());
LOG.info("Request: " + engineConfig);
final EngineConfig updatedConfig = engineConfigService.updateEngineConfig(botId, engineConfig);
return updatedConfig == null
? new ResponseEntity<>(HttpStatus.NOT_FOUND)
: buildResponseEntity(updatedConfig, HttpStatus.OK);
}
示例7: getUpdatedDate
public Date getUpdatedDate() {
try {
return restTemplate.getForObject(mirrorGateUrl + MIRROR_GATE_COLLECTOR_ENDPOINT, Date.class, appName);
}
catch (final HttpClientErrorException e) {
if(e.getStatusCode() == HttpStatus.NOT_FOUND) {
LOGGER.info("Not previous execution date found. Running from the very beginning so this could take a while");
return null;
} else {
LOGGER.error("Error requesting previous collector status", e);
throw e;
}
}
}
示例8: getBucket
@RequestMapping(value = "/api/buckets/{bucketName}", method = RequestMethod.GET)
public
@ResponseBody
ResponseEntity<BucketDto> getBucket(@PathVariable("bucketName") String bucketName)
{
BucketDto bucket = this.consumeBucketBusinessService.consume(bucketName);
if (bucket == null)
{
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(bucket, HttpStatus.OK);
}
示例9: settingsPictureTokenGet
@Override
public ResponseEntity<Object> settingsPictureTokenGet(@RequestParam(value = "token", required = false) String token) throws ApiException{
// System.out.println("token:" + token);
if(token==null || token.trim().length()==0){
//throw new ApiException(403, "Invalid token");
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
}
Long clientUserId = 0L;
try{
Claims claims = JwtCodec.decode(token);
clientUserId = Long.parseLong(claims.getSubject());
} catch(JwtException e){
//throw new ApiException(403, "Access denied");
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
}
com.jrtechnologies.yum.data.entity.User userDAO = userRepo.findById(clientUserId);
if(!userDAO.hasPicture()){
//throw new ApiException(404, "No picture");
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(userDAO.getPicture());
return ResponseEntity
.ok()
.contentLength(userDAO.getPictureLength())
.contentType(MediaType.parseMediaType("image/jpeg"))
.body(new InputStreamResource(inputStream));
}
示例10: getRequestByOrderAndUser
@RequestMapping(value = "/order/{order_id}/user/{user_id}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<?> getRequestByOrderAndUser(@PathVariable("order_id") long orderId,
@PathVariable("user_id") long userId) {
LOGGER.info("Start getRequestByOrderAndUser");
Request request = requestService.findByOrderIdAndCourierId(orderId, userId);
if (request == null) {
LOGGER.error("Request {} is not found");
return new ResponseEntity<>("Request not found", HttpStatus.NOT_FOUND);
}
RequestDto requestDto = RequestDto.toDto(request);
return new ResponseEntity<>(requestDto, HttpStatus.OK);
}
示例11: handleNotImplementedException
@ExceptionHandler(NotFoundException.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND)
@ResponseBody
public XAPIErrorInfo handleNotImplementedException(final HttpServletRequest request, final NotFoundException e) {
final XAPIErrorInfo result = new XAPIErrorInfo(HttpStatus.NOT_FOUND, request, e.getLocalizedMessage());
this.logException(e);
this.logError(result);
return result;
}
示例12: findById
public Game findById(long gameId) {
GameEntity result = gameRepository.findOne(gameId);
if (result == null) {
throw new HttpClientErrorException(HttpStatus.NOT_FOUND);
}
return gameTranslator.translate(result);
}
示例13: createPerson
@RequestMapping(value = "/person", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Person> createPerson(@RequestBody Person person) {
person.setId(null);
Person current = service.createPerson(person);
if (null != current) {
return new ResponseEntity<Person>(person, HttpStatus.OK);
}
return new ResponseEntity<Person>(HttpStatus.NOT_FOUND);
}
示例14: requestHandlingNoHandlerFound
@ExceptionHandler(NoHandlerFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public Map<String,String> requestHandlingNoHandlerFound() {
Map message = new HashMap();
message.put("error","router is not exists");
return message;
}
示例15: deleteStrategy
/**
* Deletes a Strategy configuration for a given id.
*
* @param user the authenticated user.
* @param botId the id of the Bot to delete the Strategy config for.
* @param strategyId the id of the Strategy configuration to delete.
* @return 204 'No Content' HTTP status code if delete successful, some other HTTP status code otherwise.
*/
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(value = "/{botId}" + STRATEGIES_RESOURCE_PATH + "/{strategyId}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteStrategy(@AuthenticationPrincipal User user, @PathVariable String botId,
@PathVariable String strategyId) {
LOG.info("DELETE " + CONFIG_ENDPOINT_BASE_URI + botId + STRATEGIES_RESOURCE_PATH + "/" + strategyId +" - deleteStrategy()"); // - caller: " + user.getUsername());
final boolean result = strategyConfigService.deleteStrategyConfig(botId, strategyId);
return !result
? new ResponseEntity<>(HttpStatus.NOT_FOUND)
: new ResponseEntity<>(HttpStatus.NO_CONTENT);
}