@Override public Result<TemporaryAvatarBean> cropTemporary(String ownerId, Avatar.Type type, Selection selection) { if (!isAllowedToPickAvatar(ownerId, type)) { return new Result<TemporaryAvatarBean>().addError(null, ErrorCollection.Reason.FORBIDDEN); } TemporaryAvatar temporaryAvatar = (TemporaryAvatar) ExecutingHttpRequest.get().getSession() .getAttribute(SessionKeys.TEMP_AVATAR); if (temporaryAvatar == null) { return new Result<TemporaryAvatarBean>().addError(getText("avatarpicker.upload.failure"), ErrorCollection.Reason.SERVER_ERROR); } TemporaryAvatar croppedAvatar = new TemporaryAvatar(temporaryAvatar.getContentType(), temporaryAvatar.getTemporaryContentType(), temporaryAvatar.getOriginalFilename(), temporaryAvatar.getFile(), selection); ExecutingHttpRequest.get().getSession().setAttribute(SessionKeys.TEMP_AVATAR, croppedAvatar); return new Result<TemporaryAvatarBean>(new TemporaryAvatarBean(getTemporaryAvatarUrl(), selection)); }