use of com.zimbra.cs.redolog.op.ModifyContact in project zm-mailbox by Zimbra.
the class Mailbox method modifyContact.
public void modifyContact(OperationContext octxt, int contactId, ParsedContact pc) throws ServiceException {
StoreManager sm = StoreManager.getInstance();
StagedBlob staged = null;
if (pc.hasAttachment()) {
// write the contact content directly to the mailbox's blob staging area
InputStream is = null;
try {
staged = sm.stage(is = pc.getContentStream(), pc.getSize(), this);
} catch (IOException ioe) {
throw ServiceException.FAILURE("could not save contact blob", ioe);
} finally {
ByteUtil.closeStream(is);
}
}
ModifyContact redoRecorder = new ModifyContact(mId, contactId, pc);
boolean success = false;
try {
beginTransaction("modifyContact", octxt, redoRecorder);
Contact con = getContactById(contactId);
if (!checkItemChangeID(con)) {
throw MailServiceException.MODIFY_CONFLICT();
}
try {
// setContent() calls reanalyze(), which also updates the contact fields even when there is no blob
con.setContent(staged, pc);
} catch (IOException ioe) {
throw ServiceException.FAILURE("could not save contact blob", ioe);
}
index.add(con);
success = true;
} finally {
endTransaction(success);
sm.quietDelete(staged);
}
}
Aggregations