本文整理汇总了Java中org.springframework.http.HttpStatus.NO_CONTENT属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.NO_CONTENT属性的具体用法?Java HttpStatus.NO_CONTENT怎么用?Java HttpStatus.NO_CONTENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.NO_CONTENT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: globalsettingsHolidaysYearPost
@Override
@PreAuthorize("hasAuthority('admin')")
public ResponseEntity<Object> globalsettingsHolidaysYearPost( @Min(2000) @Max(2100)@ApiParam(value = "",required=true ) @PathVariable("year") Integer year,
@ApiParam(value = "The holidays to set" ,required=true ) @Valid @RequestBody Holidays holidays) throws ApiException {
try {
globalsettingsService.setHolidays(year, holidays);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (OptimisticLockException ex) {
try {
Holidays lastHolidays = globalsettingsService.getHolidays(year);
throw new ConcurrentModificationException(409, "Concurrent modification error.", lastHolidays);
} catch (ApiException ex1) {
Logger.getLogger(SettingsApiController.class.getName()).log(Level.SEVERE, null, ex1);
throw new ApiException(500, "Concurrent modification exception: internal error");
}
}
}
示例2: updateContributionStatus
@ApiOperation(value = "Update the contribution status")
@ApiResponses(value = {
@ApiResponse(code = 403, message = "No permissions"),
@ApiResponse(code = 404, message = "No contribution found or no user found")
})
@PreAuthorize("hasRole('ROLE_USER')")
@PutMapping(value = "/contributions/{id}/status")
@ResponseStatus(HttpStatus.NO_CONTENT)
public
void updateContributionStatus(
@ApiParam(value = "The contribution ID", required = true)
@PathVariable("id") final Long id,
@ApiParam(value = "Status for the contribution", required = true)
@RequestParam("status") final VerificationStatus status,
@ApiParam(value = "Comment for verification")
@RequestParam(value = "comment", required = false) final String comment
) {
log.info("Called with id {}, status {}, comment {}", id, status, comment);
this.movieContributionPersistenceService.updateContributionStatus(id, authorizationService.getUserId(), status, comment);
}
示例3: findByName
/**
* Fetch users with the specified name. A partial case-insensitive match is
* supported. So <code>http://.../user/rest</code> will find any users with
* upper or lower case 'rest' in their name.
*
* @param name
* @return A non-null, non-empty collection of users.
*/
@HystrixCommand(fallbackMethod = "defaultUsers")
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<User>> findByName(@RequestParam("name") String name) {
logger.info(String.format("user-service findByName() invoked:%s for %s ", userService.getClass().getName(), name));
name = name.trim().toLowerCase();
Collection<User> users;
try {
users = userService.findByName(name);
} catch (Exception ex) {
logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
return users.size() > 0 ? new ResponseEntity<>(users, HttpStatus.OK)
: new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:23,代码来源:UserController.java
示例4: event
@PostMapping("/stack-events")
public ResponseEntity<String> event(@RequestBody String payload) {
try {
String result = java.net.URLDecoder.decode(payload, "UTF-8");
ObjectMapper objectMapper = new ObjectMapper();
StackEvent stackEvent = objectMapper.readValue(result, StackEvent.class);
stackEvent.setUserToken(authenticationService.getCurrentToken());
payload = jsonTransformService.write(stackEvent);
this.queueMessagingTemplate.send(queue,
MessageBuilder.withPayload(payload).build());
} catch (IOException e) {
log.error(e.getLocalizedMessage());
}
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
示例5: findByName
/**
* Fetch restaurants with the specified name. A partial case-insensitive
* match is supported. So <code>http://.../restaurants/rest</code> will find
* any restaurants with upper or lower case 'rest' in their name.
*
* @param name
* @return A non-null, non-empty collection of restaurants.
*/
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<Restaurant>> findByName(@RequestParam("name") String name) {
logger.info(String.format("restaurant-service findByName() invoked:{} for {} ", restaurantService.getClass().getName(), name));
name = name.trim().toLowerCase();
Collection<Restaurant> restaurants;
try {
restaurants = restaurantService.findByName(name);
} catch (Exception ex) {
logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
return restaurants.size() > 0 ? new ResponseEntity<>(restaurants, HttpStatus.OK)
: new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:22,代码来源:RestaurantController.java
示例6: deleteBot
/**
* Deletes a Bot configuration for a given id.
*
* @param user the authenticated user.
* @param botId the id of the Bot 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}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteBot(@AuthenticationPrincipal User user, @PathVariable String botId) {
LOG.info("DELETE " + CONFIG_ENDPOINT_BASE_URI + botId + " - deleteBot()"); // - caller: " + user.getUsername());
final BotConfig deletedConfig = botConfigService.deleteBotConfig(botId);
return deletedConfig == null
? new ResponseEntity<>(HttpStatus.NOT_FOUND)
: new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
示例7: changeLevel
@PutMapping("/logs")
@ResponseStatus(HttpStatus.NO_CONTENT)
@Timed
public void changeLevel(@RequestBody LoggerVM jsonLogger) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
}
示例8: delete
@Authorize(scopes = "authorities:delete")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@RequestMapping(value = "/v1/authorities/{id}", method = DELETE)
public void delete(@PathVariable String id) {
Authority authority = authorityService.findById(id).orThrow();
authorityService.delete(authority).orThrow();
}
示例9: deleteUser
@RequestMapping(value = "/users/{id}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteUser(@PathVariable("id") long id) {
logger.info("Fetching & Deleting User with id {}", id);
User user = userService.getById(id);
if (user == null) {
logger.error("Unable to delete. User with id {} not found.", id);
return new ResponseEntity(new CustomErrorType("Unable to delete. User with id " + id + " not found."),
HttpStatus.NOT_FOUND);
}
userService.delete(id);
return new ResponseEntity<User>(HttpStatus.NO_CONTENT);
}
示例10: getStats
/**
* Gets the stats.
*
* @param request the request
* @param model the model
* @param startDate the start date
* @param endDate the end date
* @param metric the metric
* @return the stats
* @throws Exception the exception
*/
@RequestMapping(value = "/{startDate}/{endDate}/{metric:.+}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<Object> getStats(@Context HttpServletRequest request,
@PathVariable String startDate, @PathVariable String endDate,
@PathVariable String metric) throws Exception {
log.info("Inside StatsController method getStats ");
String response = statsService.getStats(startDate, endDate, metric, request);
if (response == null || response.equalsIgnoreCase(""))
return new ResponseEntity<Object>(new JSONObject(), HttpStatus.NO_CONTENT);
return new ResponseEntity<Object>(response, HttpStatus.OK);
}
示例11: removeItem
@RequestMapping(value = "/remove/{productId}", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void removeItem(@PathVariable long productId, HttpServletRequest request) {
String sessionId = request.getSession(true).getId();
Cart cart = cartService.read(sessionId);
if(cart== null) {
cart = cartService.create(new Cart(sessionId));
}
Product product = productService.read(productId);
if(product == null) {
throw new IllegalArgumentException(new ProductNotFoundException(productId));
}
cart.removeCartItem(new CartItem(product));
cartService.update(sessionId, cart);
}
示例12: deleteImage
/**
* Delete image from system.
*/
@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteImage(@PathVariable final String id) {
log.info("deleting image with id: \"" + id + "\"");
imageService.delete(id);
}
示例13: post
@PostMapping("/teams")
public ResponseEntity<String> post(@RequestBody String payload) {
log.info(new GsonBuilder().setPrettyPrinting().create().toJson(new JsonParser().parse(payload)));
Team team = jsonTransformService.read(Team.class, payload);
team.setRequestToken(authenticationService.getCurrentToken());
this.queueMessagingTemplate.send(queue, MessageBuilder.withPayload(jsonTransformService.write(team)).build());
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
示例14: stopJms
@RequestMapping(path="/mockedserver/jms/stop", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<?> stopJms() throws MockServerException {
mockedServerEngineService.shutdownJms();
return new ResponseEntity<String>(HttpStatus.NO_CONTENT);
}
示例15: deleteLotteryDetail
@DeleteMapping("/lottery-details/{detailId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteLotteryDetail(@PathVariable Integer detailId) {
LotteryDetail lotteryDetail = getLotteryDetailFromRequest(detailId);
lotteryDetailRepository.delete(lotteryDetail);
}