List of usage examples for org.springframework.http ResponseEntity status
Object status
To view the source code for org.springframework.http ResponseEntity status.
Click Source Link
From source file:com.github.lynxdb.server.api.http.handlers.EpPut.java
@RequestMapping(path = "", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity put(Authentication _authentication, @RequestBody @Valid List<Metric> _request, BindingResult _bindingResult) {/*from w ww . j av a 2s . c o m*/ User user = (User) _authentication.getPrincipal(); if (_bindingResult.hasErrors()) { ArrayList<String> errors = new ArrayList(); _bindingResult.getFieldErrors().forEach((FieldError t) -> { errors.add(t.getField() + ": " + t.getDefaultMessage()); }); return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, errors.toString(), null).response(); } List<com.github.lynxdb.server.core.Metric> metricList = new ArrayList<>(); _request.stream().forEach((m) -> { metricList.add(new com.github.lynxdb.server.core.Metric(m)); }); try { entries.insertBulk(vhosts.byId(user.getVhost()), metricList); } catch (Exception ex) { throw ex; } return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); }
From source file:de.codecentric.boot.admin.registry.StatusUpdaterTest.java
@Test @SuppressWarnings("rawtypes") public void test_update_noBody() { // HTTP 200 - UP when(template.getForEntity("health", Map.class)).thenReturn(ResponseEntity.ok((Map) null)); updater.updateStatus(Application.create("foo").withId("id").withHealthUrl("health").build()); assertThat(store.find("id").getStatusInfo().getStatus(), is("UP")); // HTTP != 200 - DOWN when(template.getForEntity("health", Map.class)).thenReturn(ResponseEntity.status(503).body((Map) null)); updater.updateStatus(Application.create("foo").withId("id").withHealthUrl("health").build()); assertThat(store.find("id").getStatusInfo().getStatus(), is("DOWN")); }
From source file:org.createnet.raptor.auth.service.controller.DevicePermissionController.java
@RequestMapping(value = "/{deviceUuid}/permission/{userUuid}", method = RequestMethod.GET) @ApiOperation(value = "List user permissions on a device", notes = "", response = String.class, responseContainer = "List", nickname = "getUserPermissions") public ResponseEntity<?> listPermissions(@PathVariable("deviceUuid") String deviceUuid, @PathVariable("userUuid") String userUuid) { Device device = deviceService.getByUuid(deviceUuid); if (device == null) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Device not found"); }// www . j a va2 s . co m User user = userService.getByUuid(userUuid); if (user == null) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("User not found"); } List<String> permissions = RaptorPermission.toLabel(aclDeviceService.list(device, user)); return ResponseEntity.status(HttpStatus.ACCEPTED).body(permissions); }
From source file:com.github.vanroy.cloud.dashboard.controller.ApplicationController.java
/** * Proxy call instance with specific management method * @param id id of instance//from ww w . j a va2s . co m * @param method Management method name * @return Return directly from instance */ @RequestMapping(value = "/api/instance/{id}/{method}", method = RequestMethod.GET) public ResponseEntity<String> proxy(@PathVariable String id, @PathVariable String method) { String managementUrl = repository.getInstanceManagementUrl(id); if (managementUrl == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } try { HttpResponse response = httpClient.execute(new HttpGet(managementUrl + "/" + method)); return ResponseEntity.status(response.getStatusLine().getStatusCode()) .body(EntityUtils.toString(response.getEntity())); } catch (Exception e) { LOGGER.debug("Cannot proxy metrics to instance", e); } return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:br.com.s2it.snakes.controllers.CarController.java
@CrossOrigin("*") @RequestMapping(value = "/reservation/{reservation}/cancel", method = RequestMethod.GET) public ResponseEntity<String> removePassengerToReservation( final @PathVariable(value = "reservation") String reservation) { if (reservation == null || reservation.isEmpty()) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); }// ww w. ja va2 s. c o m try { service.cancelCarReservation(reservation); } catch (Exception e) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); } return ResponseEntity.status(HttpStatus.OK).body(null); }
From source file:feign.form.Server.java
@RequestMapping(value = "/query_map") public ResponseEntity<Integer> queryMap(@RequestParam("filter") List<String> filters) { HttpStatus status;// ww w . j av a2 s . c om if (filters == null || filters.isEmpty()) { status = BAD_REQUEST; } else { status = OK; } return ResponseEntity.status(status).body(filters.size()); }
From source file:org.awesomeagile.testing.google.FakeGoogleController.java
@ResponseBody @RequestMapping(method = RequestMethod.GET, path = "/oauth2/auth") public ResponseEntity<?> authenticate(@RequestParam("client_id") String clientId, @RequestParam(value = "client_secret", required = false) String clientSecret, @RequestParam("response_type") String responseType, @RequestParam("redirect_uri") String redirectUri, @RequestParam("scope") String scope) { // Validate client_id and client_secret if (!this.clientId.equals(clientId) || (clientSecret != null && !this.clientSecret.equals(clientSecret))) { return ResponseEntity.<String>badRequest().body("Wrong client_id or client_secret!"); }//from w w w . j a va 2s . c o m if (!prefixMatches(redirectUri)) { return wrongRedirectUriResponse(); } String code = RandomStringUtils.randomAlphanumeric(64); String token = RandomStringUtils.randomAlphanumeric(64); codeToToken.put(code, new AccessToken(token, scope, "", System.currentTimeMillis() + EXPIRATION_MILLIS)); UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(redirectUri).queryParam(CODE, code); return ResponseEntity.status(HttpStatus.FOUND).header(HttpHeaders.LOCATION, builder.build().toUriString()) .build(); }
From source file:fr.lepellerin.ecole.web.controller.cantine.DetaillerReservationRepasController.java
@RequestMapping(value = "/reserver") @ResponseBody// w w w . ja v a2 s.co m public ResponseEntity<String> reserver(@RequestParam final String date, @RequestParam final int individuId) throws TechnicalException { final CurrentUser user = (CurrentUser) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); final LocalDate localDate = LocalDate.parse(date, DateTimeFormatter.ofPattern(GeDateUtils.DATE_FORMAT_YYYYMMDD, Locale.ROOT)); String result; try { result = this.cantineService.reserver(localDate, individuId, user.getUser().getFamille(), null); return ResponseEntity.ok(result); } catch (FunctionalException e) { LOGGER.error("Une erreur fonctionnelle s'est produite : " + e.getMessage(), e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); } }
From source file:zipkin.server.ZipkinHttpCollector.java
ListenableFuture<ResponseEntity<?>> validateAndStoreSpans(String encoding, Codec codec, byte[] body) { SettableListenableFuture<ResponseEntity<?>> result = new SettableListenableFuture<>(); metrics.incrementMessages();//from ww w. j av a2 s . c o m if (encoding != null && encoding.contains("gzip")) { try { body = gunzip(body); } catch (IOException e) { metrics.incrementMessagesDropped(); result.set(ResponseEntity.badRequest().body("Cannot gunzip spans: " + e.getMessage() + "\n")); } } collector.acceptSpans(body, codec, new Callback<Void>() { @Override public void onSuccess(@Nullable Void value) { result.set(SUCCESS); } @Override public void onError(Throwable t) { String message = t.getMessage() == null ? t.getClass().getSimpleName() : t.getMessage(); result.set(t.getMessage() == null || message.startsWith("Cannot store") ? ResponseEntity.status(500).body(message + "\n") : ResponseEntity.status(400).body(message + "\n")); } }); return result; }
From source file:feign.form.Server.java
@RequestMapping(value = "/wild-card-map", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE) public ResponseEntity<Integer> wildCardMap(@RequestParam("key1") String key1, @RequestParam("key2") String key2) { HttpStatus status = key1.equals(key2) ? OK : BAD_REQUEST; return ResponseEntity.status(status).body(null); }