Search in sources :

Example 1 with BlobstoreFailureException

use of com.google.appengine.api.blobstore.BlobstoreFailureException in project teammates by TEAMMATES.

the class AdminEmailTrashDeleteAction method execute.

@Override
protected ActionResult execute() {
    gateKeeper.verifyAdminPrivileges(account);
    boolean shouldEmptyTrashBin = getRequestParamAsBoolean(Const.ParamsNames.ADMIN_EMAIL_EMPTY_TRASH_BIN);
    if (shouldEmptyTrashBin) {
        try {
            logic.deleteAllEmailsInTrashBin();
            statusToAdmin = "All emails in trash bin has been deleted";
            statusToUser.add(new StatusMessage("All emails in trash bin has been deleted", StatusMessageColor.SUCCESS));
        } catch (BlobstoreFailureException e) {
            statusToAdmin = "Blobstore connection failure";
            statusToUser.add(new StatusMessage("Blobstore connection failure", StatusMessageColor.DANGER));
        }
    }
    return createRedirectResult(Const.ActionURIs.ADMIN_EMAIL_TRASH_PAGE);
}
Also used : BlobstoreFailureException(com.google.appengine.api.blobstore.BlobstoreFailureException) StatusMessage(teammates.common.util.StatusMessage)

Example 2 with BlobstoreFailureException

use of com.google.appengine.api.blobstore.BlobstoreFailureException in project teammates by TEAMMATES.

the class StudentProfilePictureUploadAction method execute.

/*
     * This class is not tested in ActionTests as it is difficult to
     * reproduce the upload action done by Google Blobstore API
     * without the server running.
     * This class is covered in UiTests.
     */
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    gateKeeper.verifyLoggedInUserPrivileges();
    String pictureKey = "";
    BlobKey blobKey = new BlobKey("");
    RedirectResult r = createRedirectResult(Const.ActionURIs.STUDENT_PROFILE_PAGE);
    try {
        BlobInfo blobInfo = extractProfilePictureKey();
        if (!isError) {
            blobKey = blobInfo.getBlobKey();
            pictureKey = renameFileToGoogleId(blobInfo);
            logic.updateStudentProfilePicture(account.googleId, pictureKey);
            statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_PICTURE_SAVED, StatusMessageColor.SUCCESS));
            r.addResponseParam(Const.ParamsNames.STUDENT_PROFILE_PHOTOEDIT, "true");
        }
    } catch (BlobstoreFailureException | IOException bfe) {
        deletePicture(blobKey);
        updateStatusesForBlobstoreFailure();
        isError = true;
    } catch (Exception e) {
        /*
             * This is for other exceptions like EntityNotFound, IllegalState, etc
             * that occur rarely and are handled higher up.
             */
        deletePicture(new BlobKey(pictureKey));
        statusToUser.clear();
        throw e;
    }
    return r;
}
Also used : BlobKey(com.google.appengine.api.blobstore.BlobKey) BlobstoreFailureException(com.google.appengine.api.blobstore.BlobstoreFailureException) BlobInfo(com.google.appengine.api.blobstore.BlobInfo) IOException(java.io.IOException) BlobstoreFailureException(com.google.appengine.api.blobstore.BlobstoreFailureException) IOException(java.io.IOException) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) StatusMessage(teammates.common.util.StatusMessage)

Example 3 with BlobstoreFailureException

use of com.google.appengine.api.blobstore.BlobstoreFailureException in project teammates by TEAMMATES.

the class AdminEmailCreateGroupReceiverListUploadUrlAction method execute.

@Override
protected ActionResult execute() {
    gateKeeper.verifyAdminPrivileges(account);
    AdminEmailCreateGroupReceiverListUploadUrlAjaxPageData data = new AdminEmailCreateGroupReceiverListUploadUrlAjaxPageData(account, sessionToken);
    try {
        String callbackUrl = Url.addParamToUrl(Const.ActionURIs.ADMIN_EMAIL_GROUP_RECEIVER_LIST_UPLOAD, Const.ParamsNames.SESSION_TOKEN, sessionToken);
        data.nextUploadUrl = GoogleCloudStorageHelper.getNewUploadUrl(callbackUrl);
        data.ajaxStatus = "Group receiver list upload url created, proceed to uploading";
    } catch (BlobstoreFailureException | IllegalArgumentException e) {
        data.nextUploadUrl = null;
        isError = true;
        data.ajaxStatus = "An error occurred when creating upload URL, please try again";
    }
    return createAjaxResult(data);
}
Also used : BlobstoreFailureException(com.google.appengine.api.blobstore.BlobstoreFailureException) AdminEmailCreateGroupReceiverListUploadUrlAjaxPageData(teammates.ui.pagedata.AdminEmailCreateGroupReceiverListUploadUrlAjaxPageData)

Example 4 with BlobstoreFailureException

use of com.google.appengine.api.blobstore.BlobstoreFailureException in project teammates by TEAMMATES.

the class CreateImageUploadUrlAction method getCreateImageUploadUrlPageData.

protected final CreateImageUploadUrlAjaxPageData getCreateImageUploadUrlPageData() {
    CreateImageUploadUrlAjaxPageData data = new CreateImageUploadUrlAjaxPageData(account, sessionToken);
    try {
        data.nextUploadUrl = getUploadUrl();
        data.ajaxStatus = "Image upload url created, proceed to uploading";
    } catch (BlobstoreFailureException | IllegalArgumentException e) {
        data.nextUploadUrl = null;
        isError = true;
        data.ajaxStatus = "An error occurred when creating upload URL, please try again";
    }
    return data;
}
Also used : BlobstoreFailureException(com.google.appengine.api.blobstore.BlobstoreFailureException) CreateImageUploadUrlAjaxPageData(teammates.ui.pagedata.CreateImageUploadUrlAjaxPageData)

Aggregations

BlobstoreFailureException (com.google.appengine.api.blobstore.BlobstoreFailureException)4 StatusMessage (teammates.common.util.StatusMessage)2 BlobInfo (com.google.appengine.api.blobstore.BlobInfo)1 BlobKey (com.google.appengine.api.blobstore.BlobKey)1 IOException (java.io.IOException)1 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)1 AdminEmailCreateGroupReceiverListUploadUrlAjaxPageData (teammates.ui.pagedata.AdminEmailCreateGroupReceiverListUploadUrlAjaxPageData)1 CreateImageUploadUrlAjaxPageData (teammates.ui.pagedata.CreateImageUploadUrlAjaxPageData)1