test_class.file: modules/flowable-rest/src/test/java/org/flowable/rest/service/api/identity/UserPictureResourceTest.java
test_class.identifier: UserPictureResourceTest
test_class.superclass: extends BaseSpringRestTestCase
test_case.body: @Test
      public void testGetUserPicture() throws Exception {
          User savedUser = null;
          try {
              User newUser = identityService.newUser("testuser");
              newUser.setFirstName("Fred");
              newUser.setLastName("McDonald");
              newUser.setEmail("no-reply@activiti.org");
              identityService.saveUser(newUser);
              savedUser = newUser;
  
              // Create picture for user
              Picture thePicture = new Picture("this is the picture raw byte stream".getBytes(), "image/png");
              identityService.setUserPicture(newUser.getId(), thePicture);
  
              CloseableHttpResponse response = executeRequest(
                      new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_PICTURE, newUser.getId())), HttpStatus.SC_OK);
  
              try (InputStream contentStream = response.getEntity().getContent()) {
                  assertThat(contentStream).hasContent("this is the picture raw byte stream");
              }
  
              // Check if media-type is correct
              assertThat(response.getEntity().getContentType().getValue()).isEqualTo("image/png");
              closeResponse(response);
  
          } finally {
  
              // Delete user after test passes or fails
              if (savedUser != null) {
                  identityService.deleteUser(savedUser.getId());
              }
          }
      }
test_case.class_method_signature: UserPictureResourceTest.testGetUserPicture()
test_case.full_signature: @Test public void testGetUserPicture()
test_case.identifier: testGetUserPicture
test_case.invocations: newUser setFirstName setLastName setEmail saveUser getBytes setUserPicture getId executeRequest createRelativeResourceUrl getId getContent getEntity hasContent assertThat isEqualTo assertThat getValue getContentType getEntity closeResponse deleteUser getId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetUserPicture()
focal_class.file: modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/UserPictureResource.java
focal_class.identifier: UserPictureResource
focal_class.class_method_signature: UserPictureResource.getUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_class.full_signature: @ApiOperation(value = "Get a user’s picture", produces = "application/octet-stream", tags = { "Users" }, notes = "The response body contains the raw picture data, representing the user’s picture. The Content-type of the response corresponds to the mimeType that was set when creating the picture.") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and has a picture, which is returned in the body."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have a profile picture. Status-description contains additional information about the error.") }) @GetMapping(value = "/identity/users/{userId}/picture") public ResponseEntity<byte[]> getUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_class.identifier: getUserPicture
focal_class.modifiers: @ApiOperation(value = "Get a user’s picture", produces = "application/octet-stream", tags = { "Users" }, notes = "The response body contains the raw picture data, representing the user’s picture. The Content-type of the response corresponds to the mimeType that was set when creating the picture.") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and has a picture, which is returned in the body."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have a profile picture. Status-description contains additional information about the error.") }) @GetMapping(value = "/identity/users/{userId}/picture") public
focal_class.parameters: (@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> getUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_class.class_method_signature: UserPictureResource.updateUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_class.full_signature: @ApiOperation(consumes = "multipart/form-data", value = "Updating a user’s picture", tags = { "Users" }, notes = "The request should be of type multipart/form-data. There should be a single file-part included with the binary value of the picture. On top of that, the following additional form-fields can be present:\n" + "\n" + "mimeType: Optional mime-type for the uploaded picture. If omitted, the default of image/jpeg is used as a mime-type for the picture.") @ApiImplicitParams({ @ApiImplicitParam(name = "file", dataType = "file", value = "Picture to update", paramType = "form", required = true) }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the user was found and the picture has been updated. The response-body is left empty intentionally."), @ApiResponse(code = 404, message = "Indicates the requested user was not found.") }) @PutMapping(value = "/identity/users/{userId}/picture", consumes = "multipart/form-data") public void updateUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_class.identifier: updateUserPicture
focal_class.modifiers: @ApiOperation(consumes = "multipart/form-data", value = "Updating a user’s picture", tags = { "Users" }, notes = "The request should be of type multipart/form-data. There should be a single file-part included with the binary value of the picture. On top of that, the following additional form-fields can be present:\n" + "\n" + "mimeType: Optional mime-type for the uploaded picture. If omitted, the default of image/jpeg is used as a mime-type for the picture.") @ApiImplicitParams({ @ApiImplicitParam(name = "file", dataType = "file", value = "Picture to update", paramType = "form", required = true) }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the user was found and the picture has been updated. The response-body is left empty intentionally."), @ApiResponse(code = 404, message = "Indicates the requested user was not found.") }) @PutMapping(value = "/identity/users/{userId}/picture", consumes = "multipart/form-data") public
focal_class.parameters: (@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_class.return: void
focal_class.signature: void updateUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_class.superclass: extends BaseUserResource
focal_method.body: @ApiOperation(value = "Get a user’s picture", produces = "application/octet-stream", tags = {
              "Users" }, notes = "The response body contains the raw picture data, representing the user’s picture. The Content-type of the response corresponds to the mimeType that was set when creating the picture.")
      @ApiResponses(value = {
              @ApiResponse(code = 200, message = "Indicates the user was found and has a picture, which is returned in the body."),
              @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have a profile picture. Status-description contains additional information about the error.")
      })
      @GetMapping(value = "/identity/users/{userId}/picture")
      public ResponseEntity<byte[]> getUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response) {
          User user = getUserFromRequest(userId);
          Picture userPicture = identityService.getUserPicture(user.getId());
  
          if (userPicture == null) {
              throw new FlowableObjectNotFoundException("The user with id '" + user.getId() + "' does not have a picture.", Picture.class);
          }
  
          HttpHeaders responseHeaders = new HttpHeaders();
          if (userPicture.getMimeType() != null) {
              responseHeaders.set("Content-Type", userPicture.getMimeType());
          } else {
              responseHeaders.set("Content-Type", "image/jpeg");
          }
  
          try {
              return new ResponseEntity<>(IOUtils.toByteArray(userPicture.getInputStream()), responseHeaders, HttpStatus.OK);
          } catch (Exception e) {
              throw new FlowableException("Error exporting picture: " + e.getMessage(), e);
          }
      }
focal_method.class_method_signature: UserPictureResource.getUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_method.full_signature: @ApiOperation(value = "Get a user’s picture", produces = "application/octet-stream", tags = { "Users" }, notes = "The response body contains the raw picture data, representing the user’s picture. The Content-type of the response corresponds to the mimeType that was set when creating the picture.") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and has a picture, which is returned in the body."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have a profile picture. Status-description contains additional information about the error.") }) @GetMapping(value = "/identity/users/{userId}/picture") public ResponseEntity<byte[]> getUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_method.identifier: getUserPicture
focal_method.invocations: getUserFromRequest getUserPicture getId getId getMimeType set getMimeType set toByteArray getInputStream getMessage
focal_method.modifiers: @ApiOperation(value = "Get a user’s picture", produces = "application/octet-stream", tags = { "Users" }, notes = "The response body contains the raw picture data, representing the user’s picture. The Content-type of the response corresponds to the mimeType that was set when creating the picture.") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was found and has a picture, which is returned in the body."), @ApiResponse(code = 404, message = "Indicates the requested user was not found or the user does not have a profile picture. Status-description contains additional information about the error.") }) @GetMapping(value = "/identity/users/{userId}/picture") public
focal_method.parameters: (@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)
focal_method.return: ResponseEntity<byte[]>
focal_method.signature: ResponseEntity<byte[]> getUserPicture(@ApiParam(name = "userId") @PathVariable String userId, HttpServletRequest request, HttpServletResponse response)