use of com.zimbra.cs.redolog.RedoException in project zm-mailbox by Zimbra.
the class CreateMessage method redo.
@Override
public void redo() throws Exception {
int mboxId = getMailboxId();
Mailbox mbox = MailboxManager.getInstance().getMailboxById(mboxId);
OperationContext octxt = getOperationContext();
if (mTags == null && mTagIds != null) {
mTags = TagUtil.tagIdStringToNames(mbox, octxt, mTagIds);
}
DeliveryContext dctxt = new DeliveryContext(mShared, Arrays.asList(mboxId));
if (mMsgBodyType == MSGBODY_LINK) {
Blob blob = StoreIncomingBlob.fetchBlob(mPath);
if (blob == null)
throw new RedoException("Missing link source blob " + mPath + " (digest=" + mDigest + ")", this);
dctxt.setIncomingBlob(blob);
ParsedMessage pm = null;
try {
ParsedMessageOptions opt = new ParsedMessageOptions().setContent(blob.getFile()).setReceivedDate(mReceivedDate).setAttachmentIndexing(mbox.attachmentsIndexingEnabled()).setSize(mMsgSize).setDigest(mDigest);
pm = new ParsedMessage(opt);
mbox.addMessage(octxt, pm, getDeliveryOptions(), dctxt);
} catch (MailServiceException e) {
if (e.getCode() == MailServiceException.ALREADY_EXISTS) {
mLog.info("Message " + mMsgId + " is already in mailbox " + mboxId);
return;
} else {
throw e;
}
} finally {
if (pm != null) {
ByteUtil.closeStream(pm.getBlobInputStream());
}
}
} else {
// mMsgBodyType == MSGBODY_INLINE
// Just one recipient. Blob data is stored inline.
InputStream in = null;
try {
in = mData.getInputStream();
if (mData.getLength() != mMsgSize) {
in = new GZIPInputStream(in);
}
mbox.addMessage(octxt, in, mMsgSize, mReceivedDate, getDeliveryOptions(), dctxt);
} catch (MailServiceException e) {
if (e.getCode() == MailServiceException.ALREADY_EXISTS) {
mLog.info("Message " + mMsgId + " is already in mailbox " + mboxId);
return;
} else {
throw e;
}
} finally {
ByteUtil.closeStream(in);
}
}
}
use of com.zimbra.cs.redolog.RedoException in project zm-mailbox by Zimbra.
the class CreateMailbox method redo.
@Override
public void redo() throws Exception {
int opMboxId = getMailboxId();
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(mAccountId, false);
if (mbox == null) {
Account account = Provisioning.getInstance().get(AccountBy.id, mAccountId);
if (account == null) {
throw new RedoException("Account " + mAccountId + " does not exist", this);
}
mbox = MailboxManager.getInstance().createMailbox(getOperationContext(), account);
if (mbox == null) {
//something went really wrong
throw new RedoException("unable to create mailbox for accountId " + mAccountId, this);
}
}
int mboxId = mbox.getId();
if (opMboxId == mboxId) {
mLog.info("Mailbox " + opMboxId + " for account " + mAccountId + " already exists");
return;
} else {
throw new MailboxIdConflictException(mAccountId, opMboxId, mboxId, this);
}
}
Aggregations