@Override
public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext)
{
try
{
SaveImageRequest request = (SaveImageRequest) inActionContext.getActionContext().getParams();
String avatarId = request.getImageId();
Long entityId = request.getEntityId();
T avatarEntity = finder.findEntity(inActionContext.getActionContext().getPrincipal(), entityId);
String oldAvatarId = avatarEntity.getAvatarId();
avatarEntity.setAvatarId(avatarId);
mapper.flush();
BufferedImage originalImage = imageWriter.getImageFromFile(request.getFileItem());
Integer scaleX = SCALE_X;
Integer scaleY = SCALE_Y;
if (originalImage.getWidth(null) > originalImage.getHeight(null))