Package org.apache.james.mailbox

Examples of org.apache.james.mailbox.MailboxException


                                }
                            }
                        }
                    }
                } catch (IOException e) {
                    throw new MailboxException("Unable to read recent messages", e);
                }  
                return recentMessages;
            }
        });
    }
View Full Code Here


            pw = new PrintWriter(uidList);
            pw.println(createUidListHeader());
            for (Entry<Long, MaildirMessageName> entry : uidMap.entrySet())
                pw.println(String.valueOf(entry.getKey()) + " " + entry.getValue().getFullName());
        } catch (IOException e) {
            throw new MailboxException("Unable to create uid file", e);
        } finally {
            IOUtils.closeQuietly(pw);
        }    

        return uidMap;
View Full Code Here

            while ((line = reader.readLine()) != null) {
                if (!line.equals("")) {
                    int gap = line.indexOf(" ");
                    if (gap == -1) {
                        // there must be some issues in the file if no gap can be found
                        throw new MailboxException("Corrupted entry in uid-file " + uidList + " line " + lineNumber++);
                    }
                    Long uid = Long.valueOf(line.substring(0, gap));
                    String name = line.substring(gap + 1, line.length());
                    reverseUidMap.put(stripMetaFromName(name), uid);
                }
            }
            String[] allFiles = (String[]) ArrayUtils.addAll(curFiles, newFiles);
            for (String file : allFiles) {
                MaildirMessageName messageName = new MaildirMessageName(MaildirFolder.this, file);
                Long uid = reverseUidMap.get(messageName.getBaseName());
                if (uid == null)
                    uid = getNextUid();
                uidMap.put(uid, messageName);
            }
            pw = new PrintWriter(uidList);
            pw.println(createUidListHeader());
            for (Entry<Long, MaildirMessageName> entry : uidMap.entrySet())
                pw.println(String.valueOf(entry.getKey()) + " " + entry.getValue().getFullName());
        } catch (IOException e) {
            throw new MailboxException("Unable to update uid file", e);
        } finally {
            IOUtils.closeQuietly(pw);
            IOUtils.closeQuietly(fileReader);
            IOUtils.closeQuietly(fileReader);
        }              
View Full Code Here

                    int gap = line.indexOf(" ");

                    if (gap == -1) {
                        // there must be some issues in the file if no gap can
                        // be found
                        throw new MailboxException("Corrupted entry in uid-file " + uidList + " line " + lineNumber++);
                    }

                    Long uid = Long.valueOf(line.substring(0, gap));
                    if (uid >= from) {
                        if (to != -1 && uid > to)
                            break;
                        String name = line.substring(gap + 1, line.length());
                        uidMap.put(uid, new MaildirMessageName(MaildirFolder.this, name));
                    }
                }
            }
        } catch (IOException e) {
            throw new MailboxException("Unable to read uid file", e);
        } finally {
            IOUtils.closeQuietly(reader);
            IOUtils.closeQuietly(fileReader);
        }
        messageCount = uidMap.size();
View Full Code Here

                        pw.println(createUidListHeader());
                        for (String line : lines)
                            pw.println(line);
                    }
                } catch (IOException e) {
                    throw new MailboxException("Unable to append msg", e);
                } finally {
                    IOUtils.closeQuietly(pw);
                    IOUtils.closeQuietly(reader);
                    IOUtils.closeQuietly(fileReader);
                }
                if (uid == -1) {
                    throw new MailboxException("Unable to append msg");
                } else {
                   return uid;
                }
            }
        });
View Full Code Here

                    writer = new PrintWriter(uidList);
                    writer.println(createUidListHeader());
                    for (String entry : lines)
                        writer.println(entry);
                } catch (IOException e) {
                    throw new MailboxException("Unable to update msg with uid " + uid, e);
                } finally {
                    IOUtils.closeQuietly(writer);
                    IOUtils.closeQuietly(reader);
                    IOUtils.closeQuietly(fileReader);
                }   
View Full Code Here

                            writer.println(entry);
                    }
                    return deletedMessage;

                } catch (IOException e) {
                    throw new MailboxException("Unable to delete msg with uid " + uid, e);
                } finally {
                    IOUtils.closeQuietly(writer);
                    IOUtils.closeQuietly(reader);
                    IOUtils.closeQuietly(fileReader);
                }  
View Full Code Here

            uidValidity = folder.getUidValidity();
            lastUid = folder.getLastUid(session);
            return new SimpleMailbox<Integer>(mailboxPath, uidValidity);

        } catch (IOException e) {
            throw new MailboxException("Unable to load Mailbox " + mailboxPath, e);
        }
    }
View Full Code Here

     */
    public File getMailboxRootForUser(String user) throws MailboxException {
        String path = userRoot(user);
        File root = new File(path);
        if (!root.isDirectory())
            throw new MailboxException("Unable to load Mailbox for user " + user);
        return root;
    }
View Full Code Here

     */
    public long nextUid(MailboxSession session, Mailbox<Integer> mailbox) throws MailboxException {
        try {
            return createMaildirFolder(mailbox).getLastUid(session) +1;
        } catch (MailboxException e) {
            throw new MailboxException("Unable to generate next uid", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mailbox.MailboxException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.