List of usage examples for org.springframework.http ResponseEntity ok
public static BodyBuilder ok()
From source file:org.leandreck.endpoints.examples.SecondTypeScriptEndpoint.java
@TypeScriptIgnore @RequestMapping(value = "/photos/{id}", method = GET, produces = MediaType.IMAGE_PNG_VALUE) public ResponseEntity<InputStreamResource> getPhoto(@PathVariable Long id) { return ResponseEntity.ok().contentLength(0).contentType(IMAGE_PNG) .body(new InputStreamResource(new ByteArrayInputStream("No Content".getBytes()))); }
From source file:com.todo.backend.web.rest.AuthenticationApi.java
@RequestMapping(value = "/change-password", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed/*from w ww . j a v a 2 s . c om*/ @Transactional @PreAuthorize("isAuthenticated()") public ResponseEntity<ChangePasswordResponse> changePassword(@Valid @RequestBody ChangePasswordRequest request, @ApiIgnore @AuthenticationPrincipal Long principalId) { log.debug("POST /change-password {}", request); final User user = userService.changePassword(principalId, request.getOldPassword(), request.getNewPassword()); return ResponseEntity.ok().body(convertToChangePasswordResponse(user)); }
From source file:com.consol.citrus.admin.web.ProjectController.java
@RequestMapping(value = "/connector/add", method = RequestMethod.GET) public ResponseEntity addConnector() { projectService.addConnector(); return ResponseEntity.ok().build(); }
From source file:org.n52.restfulwpsproxy.webapp.rest.JobController.java
@RequestMapping(value = "/{jobId:.+}", method = RequestMethod.DELETE) public ResponseEntity<?> deleteJob(@PathVariable("processId") String processId, @PathVariable("jobId") String jobId, HttpServletRequest request) { return ResponseEntity.ok().build(); }
From source file:fi.helsinki.opintoni.web.rest.publicapi.PublicImageResource.java
@RequestMapping(value = "/backgrounds/{fileName:.+}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE) public ResponseEntity<BufferedImage> serve(@PathVariable String fileName) throws IOException { return ResponseEntity.ok().headers(headersWithContentType(MediaType.IMAGE_JPEG)) .body(backgroundImageService.getDefaultBackgroundImage(fileName)); }
From source file:com.intuit.karate.demo.controller.UploadController.java
@GetMapping("/{id:.+}") public ResponseEntity<Resource> download(@PathVariable String id) throws Exception { String filePath = FILES_BASE + id; File file = new File(filePath); File meta = new File(filePath + "_meta.txt"); String name = FileUtils.readFileToString(meta, "utf-8"); return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + name + "\"") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE) .body(new FileSystemResource(file)); }
From source file:com.consol.citrus.admin.web.ProjectController.java
@RequestMapping(value = "/connector/remove", method = RequestMethod.GET) public ResponseEntity removeConnector() { projectService.removeConnector();/* w w w. j a v a 2 s.c o m*/ return ResponseEntity.ok().build(); }
From source file:com.todo.backend.web.rest.TodoApi.java
@RequestMapping(value = "/todo/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed/* w ww . j ava 2 s .com*/ @Transactional public ResponseEntity<UpdateTodoResponse> updateTodo(@PathVariable Long id, @Valid @RequestBody RestUpdateTodoRequest request) { log.debug("PUT /todo/{} {}", id, request); final Todo todo = convertToTodo(id, request); final Todo result = todoRepository.save(todo); return ResponseEntity.ok().body(convertToUpdateTodoResponse(result)); }
From source file:com.consol.citrus.admin.connector.WebSocketPushMessageListenerTest.java
@Test public void testOnOutboundMessage() throws Exception { Message outbound = new DefaultMessage("Hello Citrus!"); reset(restTemplate, context);//from w ww. ja v a 2 s. co m when(restTemplate.exchange(eq("http://localhost:8080/connector/message/outbound?processId=MySampleTest"), eq(HttpMethod.POST), any(HttpEntity.class), eq(String.class))).thenAnswer(invocation -> { HttpEntity request = (HttpEntity) invocation.getArguments()[2]; Assert.assertEquals(request.getBody().toString(), outbound.toString()); return ResponseEntity.ok().build(); }); when(context.getVariables()) .thenReturn(Collections.singletonMap(Citrus.TEST_NAME_VARIABLE, "MySampleTest")); when(context.getVariable(Citrus.TEST_NAME_VARIABLE)).thenReturn("MySampleTest"); pushMessageListener.onOutboundMessage(outbound, context); verify(restTemplate).exchange(eq("http://localhost:8080/connector/message/outbound?processId=MySampleTest"), eq(HttpMethod.POST), any(HttpEntity.class), eq(String.class)); }
From source file:org.lecture.controller.TutorialController.java
/** * Returns one Tutorial in the original format. * * @param id the id of the topic to return. * @return a response.// w w w . j av a 2s .c om */ @RequestMapping(value = "/{id}/raw", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") public ResponseEntity<TutorialResource> getOneRaw(@PathVariable String id) { TutorialResource result = tutorialAssembler.toResource(tutorialRepository.findOne(id)); return ResponseEntity.ok().body(result); }