當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpStatus.NOT_FOUND屬性代碼示例

本文整理匯總了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);
}
 
開發者ID:scrumtracker,項目名稱:scrumtracker2017,代碼行數:19,代碼來源:ApiSprintController.java

示例2: exception

@CrossOrigin
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
public MessageDTO exception(NotFoundException e) {
    return new MessageDTO(e.getMessage());
}
 
開發者ID:Code4SocialGood,項目名稱:C4SG-Obsolete,代碼行數:6,代碼來源:GenericController.java

示例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);
}
 
開發者ID:wengwh,項目名稱:plumdo-work,代碼行數:8,代碼來源:ExceptionHandlerAdvice.java

示例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);
}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-5.0,代碼行數:10,代碼來源:MyBookController.java

示例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);
}
 
開發者ID:noveogroup-amorgunov,項目名稱:spring-mvc-react,代碼行數:14,代碼來源:UserController.java

示例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);
}
 
開發者ID:gazbert,項目名稱:bxbot-ui-server,代碼行數:21,代碼來源:EngineConfigController.java

示例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;
        }
    }
}
 
開發者ID:BBVA,項目名稱:mirrorgate-jira-stories-collector,代碼行數:14,代碼來源:CollectorService.java

示例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);
}
 
開發者ID:tmply,項目名稱:tmply,代碼行數:13,代碼來源:BucketResource.java

示例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));
        
    }
 
開發者ID:jrtechnologies,項目名稱:yum,代碼行數:35,代碼來源:SettingsApiController.java

示例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);
}
 
開發者ID:atereshkov,項目名稱:Diber-backend,代碼行數:15,代碼來源:RequestController.java

示例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;
}
 
開發者ID:Apereo-Learning-Analytics-Initiative,項目名稱:OpenLRW,代碼行數:9,代碼來源:XAPIExceptionHandlerAdvice.java

示例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);
}
 
開發者ID:MannanM,項目名稱:corporate-game-share,代碼行數:7,代碼來源:GameService.java

示例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);
}
 
開發者ID:appNG,項目名稱:appng-examples,代碼行數:9,代碼來源:PersonRestService.java

示例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;
}
 
開發者ID:Nbsaw,項目名稱:miaohu,代碼行數:7,代碼來源:GlobalExceptionAdvice.java

示例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);
}
 
開發者ID:gazbert,項目名稱:bxbot-ui-server,代碼行數:20,代碼來源:StrategiesConfigController.java


注:本文中的org.springframework.http.HttpStatus.NOT_FOUND屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。