com.atlassian.confluence.user.service
Class SetProfilePictureFromImageCommandImpl

java.lang.Object
  extended by com.atlassian.confluence.core.service.AbstractServiceCommand
      extended by com.atlassian.confluence.user.service.SetProfilePictureFromImageCommandImpl
All Implemented Interfaces:
ServiceCommand, SetProfilePictureCommand

public class SetProfilePictureFromImageCommandImpl
extends AbstractServiceCommand
implements SetProfilePictureCommand

Service command for setting a user's profile picture to a newly uploaded image. The image is cropped, saved as an attachment and set as the user's profile picture.


Field Summary
 
Fields inherited from interface com.atlassian.confluence.user.service.SetProfilePictureCommand
PICTURE_SIZE
 
Constructor Summary
SetProfilePictureFromImageCommandImpl(PermissionManager permissionManager, PersonalInformationManager personalInformationManager, UserAccessor userAccessor, AttachmentManager attachmentManager, com.atlassian.user.User user, java.io.InputStream imageData, java.lang.String imageFileName)
           
SetProfilePictureFromImageCommandImpl(PermissionManager permissionManager, PersonalInformationManager personalInformationManager, UserAccessor userAccessor, AttachmentManager attachmentManager, com.atlassian.user.User user, java.io.InputStream imageData, java.lang.String imageFileName, int topLeftX, int topLeftY, int width)
           
SetProfilePictureFromImageCommandImpl(PermissionManager permissionManager, PersonalInformationManager personalInformationManager, UserAccessor userAccessor, AttachmentManager attachmentManager, com.atlassian.user.User user, java.io.InputStream imageData, java.lang.String imageFileName, com.atlassian.confluence.user.service.SetProfilePictureFromImageCommandImpl.Selection cropSelection)
           
 
Method Summary
static byte[] convertImageToProfilePicture(java.io.InputStream imageData)
          Crop an image so it's the right size and composition for a profile picture.
protected  void executeInternal()
          Template method for implementations to perform command execution.
protected  boolean isAuthorizedInternal()
          Template method for implementations to perform authorization.
protected  void validateInternal(ServiceCommandValidator validator)
          Template method for implementations to perform validation.
 
Methods inherited from class com.atlassian.confluence.core.service.AbstractServiceCommand
execute, getCurrentUser, getValidationErrors, isAuthorized, isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.confluence.core.service.ServiceCommand
execute, getValidationErrors, isAuthorized, isValid
 

Constructor Detail

SetProfilePictureFromImageCommandImpl

public SetProfilePictureFromImageCommandImpl(PermissionManager permissionManager,
                                             PersonalInformationManager personalInformationManager,
                                             UserAccessor userAccessor,
                                             AttachmentManager attachmentManager,
                                             com.atlassian.user.User user,
                                             java.io.InputStream imageData,
                                             java.lang.String imageFileName,
                                             int topLeftX,
                                             int topLeftY,
                                             int width)

SetProfilePictureFromImageCommandImpl

public SetProfilePictureFromImageCommandImpl(PermissionManager permissionManager,
                                             PersonalInformationManager personalInformationManager,
                                             UserAccessor userAccessor,
                                             AttachmentManager attachmentManager,
                                             com.atlassian.user.User user,
                                             java.io.InputStream imageData,
                                             java.lang.String imageFileName)

SetProfilePictureFromImageCommandImpl

public SetProfilePictureFromImageCommandImpl(PermissionManager permissionManager,
                                             PersonalInformationManager personalInformationManager,
                                             UserAccessor userAccessor,
                                             AttachmentManager attachmentManager,
                                             com.atlassian.user.User user,
                                             java.io.InputStream imageData,
                                             java.lang.String imageFileName,
                                             com.atlassian.confluence.user.service.SetProfilePictureFromImageCommandImpl.Selection cropSelection)
Method Detail

validateInternal

protected void validateInternal(ServiceCommandValidator validator)
Description copied from class: AbstractServiceCommand
Template method for implementations to perform validation. Implementations should add validation errors using the provided methods. Validation will succeed or fail based on whether the list of validation errors is empty at the end of this method.

Implementations can assume that if this method is called, authorization was already successful.

Specified by:
validateInternal in class AbstractServiceCommand

isAuthorizedInternal

protected boolean isAuthorizedInternal()
Description copied from class: AbstractServiceCommand
Template method for implementations to perform authorization.

Specified by:
isAuthorizedInternal in class AbstractServiceCommand
Returns:
true if the current user is authorized to perform this command, false otherwise

executeInternal

protected void executeInternal()
Description copied from class: AbstractServiceCommand
Template method for implementations to perform command execution. Implementations can assume that if this method is called, both authorization and validation have already been completed successfully.

Specified by:
executeInternal in class AbstractServiceCommand

convertImageToProfilePicture

public static byte[] convertImageToProfilePicture(java.io.InputStream imageData)
Crop an image so it's the right size and composition for a profile picture. This method is static so it can be called from a really old upgrade task, please don't call from anywhere else

Parameters:
imageData - a stream containing the image to crop
Returns:
the cropped image, as a JPEG


Copyright © 2003-2010 Atlassian. All Rights Reserved.