Search in sources :

Example 1 with AbstractMailboxPathLocker

use of org.apache.james.mailbox.store.AbstractMailboxPathLocker in project i2p.i2p-bote by i2p.

the class MapperFactory method createUidProvider.

private UidProvider createUidProvider() {
    MailboxPathLocker uidLocker = new AbstractMailboxPathLocker() {

        @Override
        protected void lock(MailboxSession session, MailboxPath path, boolean writeLock) throws MailboxException {
            BoteMailbox mailbox = getMailboxes().get(path.getName().toLowerCase());
            mailbox.lockNextUid(writeLock);
        }

        @Override
        protected void unlock(MailboxSession session, MailboxPath path, boolean writeLock) throws MailboxException {
            BoteMailbox mailbox = getMailboxes().get(path.getName().toLowerCase());
            mailbox.unlockNextUid(writeLock);
        }
    };
    return new AbstractLockingUidProvider(uidLocker) {

        @Override
        protected MessageUid lockedNextUid(MailboxSession session, Mailbox mailbox) throws MailboxException {
            BoteMailbox boteMailbox = (BoteMailbox) mailbox;
            return boteMailbox.lockedNextUid();
        }

        @Override
        public Optional<MessageUid> lastUid(MailboxSession session, Mailbox mailbox) throws MailboxException {
            BoteMailbox boteMailbox = (BoteMailbox) mailbox;
            return boteMailbox.lastUid();
        }
    };
}
Also used : MailboxSession(org.apache.james.mailbox.MailboxSession) MailboxPath(org.apache.james.mailbox.model.MailboxPath) MessageUid(org.apache.james.mailbox.MessageUid) AbstractLockingUidProvider(org.apache.james.mailbox.store.mail.AbstractLockingUidProvider) Mailbox(org.apache.james.mailbox.store.mail.model.Mailbox) AbstractMailboxPathLocker(org.apache.james.mailbox.store.AbstractMailboxPathLocker) MailboxPathLocker(org.apache.james.mailbox.MailboxPathLocker) AbstractMailboxPathLocker(org.apache.james.mailbox.store.AbstractMailboxPathLocker)

Example 2 with AbstractMailboxPathLocker

use of org.apache.james.mailbox.store.AbstractMailboxPathLocker in project i2p.i2p-bote by i2p.

the class MapperFactory method createModSeqProvider.

private ModSeqProvider createModSeqProvider() {
    MailboxPathLocker modSeqLocker = new AbstractMailboxPathLocker() {

        @Override
        protected void lock(MailboxSession session, MailboxPath path, boolean writeLock) throws MailboxException {
            BoteMailbox mailbox = getMailboxes().get(path.getName().toLowerCase());
            mailbox.lockNextModSeq(writeLock);
        }

        @Override
        protected void unlock(MailboxSession session, MailboxPath path, boolean writeLock) throws MailboxException {
            BoteMailbox mailbox = getMailboxes().get(path.getName().toLowerCase());
            mailbox.unlockNextModSeq(writeLock);
        }
    };
    return new AbstractLockingModSeqProvider(modSeqLocker) {

        @Override
        protected long lockedNextModSeq(MailboxSession session, Mailbox mailbox) throws MailboxException {
            BoteMailbox boteMailbox = (BoteMailbox) mailbox;
            return boteMailbox.lockedNextModSeq();
        }

        @Override
        public long highestModSeq(MailboxSession session, Mailbox mailbox) throws MailboxException {
            BoteMailbox boteMailbox = (BoteMailbox) mailbox;
            return boteMailbox.highestModSeq();
        }

        @Override
        public long highestModSeq(MailboxSession session, MailboxId mailboxId) throws MailboxException {
            return highestModSeq(session, getMailboxes().get(mailboxId.serialize().toLowerCase()));
        }
    };
}
Also used : MailboxSession(org.apache.james.mailbox.MailboxSession) AbstractLockingModSeqProvider(org.apache.james.mailbox.store.mail.AbstractLockingModSeqProvider) MailboxPath(org.apache.james.mailbox.model.MailboxPath) Mailbox(org.apache.james.mailbox.store.mail.model.Mailbox) MailboxId(org.apache.james.mailbox.model.MailboxId) AbstractMailboxPathLocker(org.apache.james.mailbox.store.AbstractMailboxPathLocker) MailboxPathLocker(org.apache.james.mailbox.MailboxPathLocker) AbstractMailboxPathLocker(org.apache.james.mailbox.store.AbstractMailboxPathLocker)

Aggregations

MailboxPathLocker (org.apache.james.mailbox.MailboxPathLocker)2 MailboxSession (org.apache.james.mailbox.MailboxSession)2 MailboxPath (org.apache.james.mailbox.model.MailboxPath)2 AbstractMailboxPathLocker (org.apache.james.mailbox.store.AbstractMailboxPathLocker)2 Mailbox (org.apache.james.mailbox.store.mail.model.Mailbox)2 MessageUid (org.apache.james.mailbox.MessageUid)1 MailboxId (org.apache.james.mailbox.model.MailboxId)1 AbstractLockingModSeqProvider (org.apache.james.mailbox.store.mail.AbstractLockingModSeqProvider)1 AbstractLockingUidProvider (org.apache.james.mailbox.store.mail.AbstractLockingUidProvider)1