javax.mail.FolderNotFoundException Java Examples

The following examples show how to use javax.mail.FolderNotFoundException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Core.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
private static void onMove(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message) throws JSONException, FolderNotFoundException {
    // Move message
    DB db = DB.getInstance(context);

    // Get arguments
    long id = jargs.getLong(0);
    boolean seen = jargs.optBoolean(1);
    boolean unflag = jargs.optBoolean(3);

    // Get target folder
    EntityFolder target = db.folder().getFolder(id);
    if (target == null)
        throw new FolderNotFoundException();

    // Move from trash/drafts only
    if (!EntityFolder.TRASH.equals(folder.type) &&
            !EntityFolder.DRAFTS.equals(folder.type))
        throw new IllegalArgumentException("Invalid POP3 folder" +
                " source=" + folder.type + " target=" + target.type);

    message.folder = target.id;
    if (seen)
        message.ui_seen = seen;
    if (unflag)
        message.ui_flagged = false;
    message.ui_hide = false;

    db.message().updateMessage(message);
}
 
Example #2
Source File: Core.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
private static void onRaw(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException, IOException, JSONException {
    // Download raw message
    DB db = DB.getInstance(context);

    if (message.raw == null || !message.raw) {
        IMAPMessage imessage = (IMAPMessage) ifolder.getMessageByUID(message.uid);
        if (imessage == null)
            throw new MessageRemovedException();

        File file = message.getRawFile(context);
        try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
            imessage.writeTo(os);
        }

        db.message().setMessageRaw(message.id, true);
    }

    if (jargs.length() > 0) {
        // Cross account move
        long tid = jargs.getLong(0);
        EntityFolder target = db.folder().getFolder(tid);
        if (target == null)
            throw new FolderNotFoundException();

        Log.i(folder.name + " queuing ADD id=" + message.id + ":" + target.id);

        EntityOperation operation = new EntityOperation();
        operation.account = target.account;
        operation.folder = target.id;
        operation.message = message.id;
        operation.name = EntityOperation.ADD;
        operation.args = jargs.toString();
        operation.created = new Date().getTime();
        operation.id = db.operation().insertOperation(operation);
    }
}
 
Example #3
Source File: Core.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
void error(Throwable ex) {
    if (ex instanceof MessagingException &&
            ("connection failure".equals(ex.getMessage()) ||
                    "Not connected".equals(ex.getMessage()) || // POP3
                    ex.getCause() instanceof SocketException ||
                    ex.getCause() instanceof ConnectionException))
        recoverable = false;

    if (ex instanceof ConnectionException)
        // failed to create new store connection
        // BYE, Socket is closed
        recoverable = false;

    if (ex instanceof StoreClosedException ||
            ex instanceof FolderClosedException ||
            ex instanceof FolderNotFoundException)
        // Lost folder connection to server
        recoverable = false;

    if (ex instanceof IllegalStateException && (
            "Not connected".equals(ex.getMessage()) ||
                    "This operation is not allowed on a closed folder".equals(ex.getMessage())))
        recoverable = false;

    if (ex instanceof OperationCanceledException)
        recoverable = false;

    thread.interrupt();
    yield();
}
 
Example #4
Source File: IMAPMockFolder.java    From javamail-mock2 with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void copyMessages(final Message[] msgs, final Folder folder) throws MessagingException {
    abortIdle();
    checkOpened();
    checkExists();
    if (msgs == null || folder == null || msgs.length == 0) {
        return;
    }

    if (!folder.exists()) {
        throw new FolderNotFoundException(folder.getFullName() + " does not exist", folder);
    }

    folder.appendMessages(msgs);
}
 
Example #5
Source File: IMAPMockFolder.java    From javamail-mock2 with Apache License 2.0 4 votes vote down vote up
@Override
protected void checkExists() throws MessagingException {
    if (!exists()) {
        throw new FolderNotFoundException(this, getFullName() + " not found");
    }
}