use of com.zimbra.cs.mailbox.Tag in project zm-mailbox by Zimbra.
the class ImapSession method handleModify.
private void handleModify(int changeId, Change chg, AddedItems added) {
if (chg.what instanceof Tag && (chg.why & Change.NAME) != 0) {
mFolder.handleTagRename(changeId, (Tag) chg.what, chg);
} else if (chg.what instanceof Folder && ((Folder) chg.what).getId() == mFolderId) {
Folder folder = (Folder) chg.what;
if ((chg.why & Change.FLAGS) != 0 && (folder.getFlagBitmask() & Flag.BITMASK_DELETED) != 0) {
// mailbox accessed by sending a untagged BYE response."
if (handler != null) {
handler.close();
}
} else if ((chg.why & (Change.FOLDER | Change.NAME)) != 0) {
mFolder.handleFolderRename(changeId, folder, chg);
}
} else if (chg.what instanceof Message || chg.what instanceof Contact) {
MailItem item = (MailItem) chg.what;
boolean inFolder = mIsVirtual || item.getFolderId() == mFolderId;
if (!inFolder && (chg.why & Change.FOLDER) == 0) {
return;
}
mFolder.handleItemUpdate(changeId, chg, added);
}
}
use of com.zimbra.cs.mailbox.Tag in project zm-mailbox by Zimbra.
the class TestUnread method setUp.
/**
* Sets up the following data set:
* <ul>
* <li>F1 contains F2 and M1</li>
* <li>F2 contains M2 and M3</li>
* <li>T1 is assigned to M1</li>
* <li>T2 is assigned to M1 and M2</li>
* </ul>
*/
@Before
public void setUp() throws Exception {
mAccount = TestUtil.createAccount(USER_NAME);
Assert.assertNotNull(String.format("Unable to create account for user '%s'", USER_NAME), mAccount);
mMbox = MailboxManager.getInstance().getMailboxByAccount(mAccount);
Message msg = TestUtil.addMessage(mMbox, TEST_NAME);
mMessage1Id = msg.getId();
ZimbraLog.test.debug("Created message 1, id=" + mMessage1Id);
msg = TestUtil.addMessage(mMbox, "RE: " + TEST_NAME);
mMessage2Id = msg.getId();
ZimbraLog.test.debug("Created message 2, id=" + mMessage2Id);
msg = TestUtil.addMessage(mMbox, "RE: " + TEST_NAME);
mMessage3Id = msg.getId();
ZimbraLog.test.debug("Created message 3, id=" + mMessage3Id);
mConvId = getMessage1().getConversationId();
ZimbraLog.test.debug("Created conversation, id=" + mConvId);
Folder folder = mMbox.createFolder(null, FOLDER1_NAME, Mailbox.ID_FOLDER_INBOX, new Folder.FolderOptions());
mFolder1Id = folder.getId();
folder = mMbox.createFolder(null, FOLDER2_NAME, mFolder1Id, new Folder.FolderOptions());
mFolder2Id = folder.getId();
Tag tag = mMbox.createTag(null, TAG1_NAME, (byte) 0);
mTag1Id = tag.getId();
tag = mMbox.createTag(null, TAG2_NAME, (byte) 0);
mTag2Id = tag.getId();
tag = mMbox.createTag(null, TAG3_NAME, (byte) 0);
mTag3Id = tag.getId();
mMbox.move(null, mMessage1Id, getMessage1().getType(), mFolder1Id);
mMbox.move(null, mMessage2Id, getMessage1().getType(), mFolder2Id);
mMbox.move(null, mMessage3Id, getMessage1().getType(), mFolder2Id);
mMbox.alterTag(null, mMessage1Id, getMessage1().getType(), getTag1().getName(), true, null);
mMbox.alterTag(null, mMessage1Id, getMessage1().getType(), getTag2().getName(), true, null);
mMbox.alterTag(null, mMessage2Id, getMessage2().getType(), getTag2().getName(), true, null);
}
use of com.zimbra.cs.mailbox.Tag in project zm-mailbox by Zimbra.
the class TestTags method testRemoteTagSearch.
/**
* Bug 79576 was seeing extra (wrong) hits from shared folder when click on a tag.
*/
public void testRemoteTagSearch() throws Exception {
Account remoteAcct = TestUtil.createAccount(remoteUser);
remoteAcct = TestUtil.getAccount(remoteUser);
Mailbox remoteMbox = MailboxManager.getInstance().getMailboxByAccount(remoteAcct);
remoteMbox.grantAccess(null, Mailbox.ID_FOLDER_INBOX, mAccount.getId(), ACL.GRANTEE_USER, (short) (ACL.RIGHT_READ | ACL.RIGHT_WRITE | ACL.RIGHT_INSERT), null);
mountpoint = mMbox.createMountpoint(null, Mailbox.ID_FOLDER_USER_ROOT, "remoteInbox", remoteAcct.getId(), Mailbox.ID_FOLDER_INBOX, null, MailItem.Type.MESSAGE, Flag.ID_CHECKED, (byte) 2, false);
Message remoteMsg1 = TestUtil.addMessage(remoteMbox, MSG_SUBJECT + " in shared inbox tagged with shared TAG");
Message remoteMsg2 = TestUtil.addMessage(remoteMbox, MSG_SUBJECT + " in shared inbox tagged remOnly");
Tag[] remoteTags = new Tag[2];
remoteTags[0] = remoteMbox.createTag(null, TAG_PREFIX + 1, (byte) 0);
remoteTags[1] = remoteMbox.createTag(null, TAG_PREFIX + "remOnly", (byte) 0);
mTags = new Tag[2];
for (int i = 0; i < mTags.length; i++) {
mTags[i] = mMbox.createTag(null, TAG_PREFIX + (i + 1), (byte) 0);
}
refresh();
remoteMbox.alterTag(null, remoteMsg1.getId(), remoteMsg1.getType(), remoteTags[0].getName(), true, null);
remoteMbox.alterTag(null, remoteMsg2.getId(), remoteMsg2.getType(), remoteTags[1].getName(), true, null);
mMbox.alterTag(null, mMessage2.getId(), mMessage2.getType(), mTags[0].getName(), true, null);
mMbox.alterTag(null, mMessage3.getId(), mMessage3.getType(), mTags[1].getName(), true, null);
Folder sharedFolder = mMbox.getFolderByName(null, Mailbox.ID_FOLDER_USER_ROOT, "remoteInbox");
sharedFolder.getId();
List<ZimbraHit> hits = TestUtil.searchForHits(mMbox, String.format("tag:\"%s\" (inid:%d OR is:local)", mTags[0].getName(), sharedFolder.getId()), MailItem.Type.MESSAGE);
assertEquals("Search for tag present in both local and remote mboxes. Number of hits returned", 2, hits.size());
boolean gotLocalHit = false;
boolean gotRemoteHit = false;
ZimbraLog.test.setLevel(Level.trace);
for (ZimbraHit hit : hits) {
ZimbraLog.test.info("HIT %s", hit.getParsedItemID());
ItemId parsedId = hit.getParsedItemID();
if (parsedId.belongsTo(mAccount) && hit.getItemId() == mMessage2.getId()) {
gotLocalHit = true;
}
if (parsedId.belongsTo(remoteAcct) && hit.getItemId() == remoteMsg1.getId()) {
gotRemoteHit = true;
}
}
assertTrue("1st search should return one local hit", gotLocalHit);
assertTrue("1st search should return one remote hit", gotRemoteHit);
Set<Integer> ids = search(String.format("tag:\"%s\" (inid:%d OR is:local)", mTags[1].getName(), sharedFolder.getId()), MailItem.Type.MESSAGE);
assertEquals("Search for tag not present in remote mbox. Number of ids returned", 1, ids.size());
assertTrue("2nd search should contain message 3", ids.contains(new Integer(mMessage3.getId())));
}
use of com.zimbra.cs.mailbox.Tag in project zm-mailbox by Zimbra.
the class FilterListener method notify.
@Override
public void notify(ChangeNotification notification) {
if (notification.mods.modified != null && EVENTS.contains(notification.op)) {
for (PendingModifications.Change change : notification.mods.modified.values()) {
if (change.what instanceof Folder) {
if ((change.why & Change.PARENT) == 0 && (change.why & Change.NAME) == 0) {
continue;
}
Folder folder = (Folder) change.what;
Folder oldFolder = (Folder) change.preModifyObj;
if (oldFolder == null) {
ZimbraLog.filter.warn("Cannot determine the old folder name for %s.", folder.getName());
continue;
}
updateFilterRules(notification.mailboxAccount, folder, oldFolder.getPath());
} else if (change.what instanceof Tag) {
if ((change.why & Change.NAME) == 0) {
continue;
}
Tag tag = (Tag) change.what;
Tag oldTag = (Tag) change.preModifyObj;
if (oldTag == null) {
ZimbraLog.filter.warn("Cannot determine the old tag name for %s.", tag.getName());
continue;
}
updateFilterRules(notification.mailboxAccount, tag, oldTag.getName());
}
}
}
if (notification.mods.deleted != null) {
for (Map.Entry<ModificationKey, Change> entry : notification.mods.deleted.entrySet()) {
MailItem.Type type = (MailItem.Type) entry.getValue().what;
if (type == MailItem.Type.FOLDER || type == MailItem.Type.MOUNTPOINT) {
Folder oldFolder = (Folder) entry.getValue().preModifyObj;
if (oldFolder == null) {
ZimbraLog.filter.warn("Cannot determine the old folder name for %s.", entry.getKey());
continue;
}
updateFilterRules(notification.mailboxAccount, (Folder) null, oldFolder.getPath());
} else if (type == MailItem.Type.TAG) {
Tag oldTag = (Tag) entry.getValue().preModifyObj;
updateFilterRules(notification.mailboxAccount, oldTag);
}
}
}
}
use of com.zimbra.cs.mailbox.Tag in project zm-mailbox by Zimbra.
the class ArchiveFormatter method addItem.
private void addItem(UserServletContext context, Folder fldr, Map<Object, Folder> fmap, FolderDigestInfo digestInfo, Map<Integer, Integer> idMap, int[] ids, Set<MailItem.Type> types, Resolve r, ItemData id, ArchiveInputStream ais, ArchiveInputEntry aie, List<ServiceException> errs) throws ServiceException {
try {
Mailbox mbox = fldr.getMailbox();
MailItem mi = MailItem.constructItem(mbox, id.ud);
MailItem newItem = null, oldItem = null;
OperationContext octxt = context.opContext;
String path;
ParsedMessage pm;
boolean root = fldr.getId() == Mailbox.ID_FOLDER_ROOT || fldr.getId() == Mailbox.ID_FOLDER_USER_ROOT || id.path.startsWith(fldr.getPath() + '/');
if ((ids != null && Arrays.binarySearch(ids, id.ud.id) < 0) || (types != null && !types.contains(MailItem.Type.of(id.ud.type))))
return;
if (id.ud.getBlobDigest() != null && aie == null) {
addError(errs, FormatterServiceException.MISSING_BLOB(id.path));
return;
}
if (root) {
path = id.path;
} else {
path = fldr.getPath() + id.path;
}
if (path.endsWith("/") && !path.equals("/")) {
path = path.substring(0, path.length() - 1);
}
if (mbox.isImmutableSystemFolder(id.ud.folderId))
return;
switch(mi.getType()) {
case APPOINTMENT:
case TASK:
CalendarItem ci = (CalendarItem) mi;
fldr = createPath(context, fmap, path, ci.getType() == MailItem.Type.APPOINTMENT ? MailItem.Type.APPOINTMENT : MailItem.Type.TASK);
if (!root || r != Resolve.Reset) {
CalendarItem oldCI = null;
try {
oldCI = mbox.getCalendarItemByUid(octxt, ci.getUid());
} catch (Exception e) {
}
if (oldCI != null && r == Resolve.Replace) {
mbox.delete(octxt, oldCI.getId(), oldCI.getType());
} else {
oldItem = oldCI;
}
}
if (oldItem == null || r != Resolve.Skip) {
CalendarItem.AlarmData ad = ci.getAlarmData();
byte[] data = readArchiveEntry(ais, aie);
Map<Integer, MimeMessage> blobMimeMsgMap = data == null ? null : CalendarItem.decomposeBlob(data);
SetCalendarItemData defScid = new SetCalendarItemData();
SetCalendarItemData[] exceptionScids = null;
Invite[] invs = ci.getInvites();
MimeMessage mm;
if (invs != null && invs.length > 0) {
defScid.invite = invs[0];
if (blobMimeMsgMap != null && (mm = blobMimeMsgMap.get(defScid.invite.getMailItemId())) != null) {
defScid.message = new ParsedMessage(mm, mbox.attachmentsIndexingEnabled());
}
if (invs.length > 1) {
exceptionScids = new SetCalendarItemData[invs.length - 1];
for (int i = 1; i < invs.length; i++) {
SetCalendarItemData scid = new SetCalendarItemData();
scid.invite = invs[i];
if (blobMimeMsgMap != null && (mm = blobMimeMsgMap.get(defScid.invite.getMailItemId())) != null) {
scid.message = new ParsedMessage(mm, mbox.attachmentsIndexingEnabled());
}
exceptionScids[i - 1] = scid;
}
}
newItem = mbox.setCalendarItem(octxt, oldItem != null && r == Resolve.Modify ? oldItem.getFolderId() : fldr.getId(), ci.getFlagBitmask(), ci.getTags(), defScid, exceptionScids, ci.getAllReplies(), ad == null ? CalendarItem.NEXT_ALARM_KEEP_CURRENT : ad.getNextAt());
}
}
break;
case CHAT:
Chat chat = (Chat) mi;
byte[] content = readArchiveEntry(ais, aie);
pm = new ParsedMessage(content, mi.getDate(), mbox.attachmentsIndexingEnabled());
fldr = createPath(context, fmap, path, MailItem.Type.CHAT);
if (root && r != Resolve.Reset) {
Chat oldChat = null;
try {
oldChat = mbox.getChatById(octxt, chat.getId());
if (oldChat.getFolderId() != fldr.getId()) {
oldChat = null;
}
} catch (Exception e) {
}
if (oldChat != null && chat.getSender().equals(oldChat.getSender()) && chat.getSubject().equals(oldChat.getSubject())) {
if (r == Resolve.Replace) {
mbox.delete(octxt, oldChat.getId(), oldChat.getType());
} else {
oldItem = oldChat;
if (r == Resolve.Modify)
newItem = mbox.updateChat(octxt, pm, oldItem.getId());
}
}
}
if (oldItem == null)
newItem = mbox.createChat(octxt, pm, fldr.getId(), chat.getFlagBitmask(), chat.getTags());
break;
case CONVERSATION:
Conversation cv = (Conversation) mi;
if (r != Resolve.Reset && r != Resolve.Skip) {
try {
oldItem = mbox.getConversationByHash(octxt, Mailbox.getHash(cv.getSubject()));
} catch (Exception e) {
}
}
break;
case CONTACT:
Contact ct = (Contact) mi;
fldr = createPath(context, fmap, path, Folder.Type.CONTACT);
if (root && r != Resolve.Reset) {
Contact oldContact = null;
oldContact = findContact(octxt, mbox, ct, fldr);
if (oldContact != null) {
String email = string(ct.get(ContactConstants.A_email));
String first = string(ct.get(ContactConstants.A_firstName));
String name = string(ct.get(ContactConstants.A_fullName));
String oldemail = string(oldContact.get(ContactConstants.A_email));
String oldfirst = string(oldContact.get(ContactConstants.A_firstName));
String oldname = string(oldContact.get(ContactConstants.A_fullName));
if (email.equals(oldemail) && first.equals(oldfirst) && name.equals(oldname)) {
if (r == Resolve.Replace) {
mbox.delete(octxt, oldContact.getId(), oldContact.getType());
} else {
oldItem = oldContact;
if (r == Resolve.Modify) {
mbox.modifyContact(octxt, oldItem.getId(), new ParsedContact(ct.getFields(), readArchiveEntry(ais, aie)));
}
}
}
}
}
if (oldItem == null) {
newItem = mbox.createContact(octxt, new ParsedContact(ct.getFields(), readArchiveEntry(ais, aie)), fldr.getId(), ct.getTags());
}
break;
case DOCUMENT:
case WIKI:
Document doc = (Document) mi;
Document oldDoc = null;
Integer oldId = idMap.get(mi.getId());
fldr = createParent(context, fmap, path, doc.getType() == MailItem.Type.DOCUMENT ? MailItem.Type.DOCUMENT : MailItem.Type.WIKI);
if (oldId == null) {
try {
for (Document listDoc : mbox.getDocumentList(octxt, fldr.getId())) {
if (doc.getName().equals(listDoc.getName())) {
oldDoc = listDoc;
idMap.put(doc.getId(), oldDoc.getId());
break;
}
}
} catch (Exception e) {
}
} else {
oldDoc = mbox.getDocumentById(octxt, oldId);
}
if (oldDoc != null) {
if (r == Resolve.Replace && oldId == null) {
mbox.delete(octxt, oldDoc.getId(), oldDoc.getType());
} else if (doc.getVersion() < oldDoc.getVersion()) {
return;
} else {
oldItem = oldDoc;
if (doc.getVersion() > oldDoc.getVersion()) {
newItem = mbox.addDocumentRevision(octxt, oldDoc.getId(), doc.getCreator(), doc.getName(), doc.getDescription(), doc.isDescriptionEnabled(), ais.getInputStream());
}
if (r != Resolve.Skip) {
mbox.setDate(octxt, oldDoc.getId(), doc.getType(), doc.getDate());
}
}
}
if (oldItem == null) {
if (mi.getType() == MailItem.Type.DOCUMENT) {
newItem = mbox.createDocument(octxt, fldr.getId(), doc.getName(), doc.getContentType(), doc.getCreator(), doc.getDescription(), ais.getInputStream());
} else {
WikiItem wi = (WikiItem) mi;
newItem = mbox.createWiki(octxt, fldr.getId(), wi.getWikiWord(), wi.getCreator(), wi.getDescription(), ais.getInputStream());
}
mbox.setDate(octxt, newItem.getId(), doc.getType(), doc.getDate());
idMap.put(doc.getId(), newItem.getId());
}
break;
case FLAG:
return;
case FOLDER:
String aclParam = context.params.get("acl");
boolean doACL = aclParam == null || !aclParam.equals("0");
Folder f = (Folder) mi;
ACL acl = f.getACL();
Folder oldF = null;
MailItem.Type view = f.getDefaultView();
if (view == MailItem.Type.CONVERSATION || view == MailItem.Type.FLAG || view == MailItem.Type.TAG)
break;
try {
oldF = mbox.getFolderByPath(octxt, path);
} catch (Exception e) {
}
if (oldF != null) {
oldItem = oldF;
if (r != Resolve.Skip) {
if (!f.getUrl().equals(oldF.getUrl())) {
mbox.setFolderUrl(octxt, oldF.getId(), f.getUrl());
}
if (doACL) {
ACL oldACL = oldF.getACL();
if ((acl == null && oldACL != null) || (acl != null && (oldACL == null || !acl.equals(oldACL)))) {
mbox.setPermissions(octxt, oldF.getId(), acl);
}
}
}
}
if (oldItem == null) {
fldr = createParent(context, fmap, path, Folder.Type.UNKNOWN);
Folder.FolderOptions fopt = new Folder.FolderOptions();
fopt.setDefaultView(f.getDefaultView()).setFlags(f.getFlagBitmask()).setColor(f.getColor()).setUrl(f.getUrl());
newItem = fldr = mbox.createFolder(octxt, f.getName(), fldr.getId(), fopt);
if (doACL && acl != null) {
mbox.setPermissions(octxt, fldr.getId(), acl);
}
fmap.put(fldr.getId(), fldr);
fmap.put(fldr.getPath(), fldr);
}
break;
case MESSAGE:
Message msg = (Message) mi;
Message oldMsg = null;
fldr = createPath(context, fmap, path, Folder.Type.MESSAGE);
if (root && r != Resolve.Reset) {
try {
oldMsg = mbox.getMessageById(octxt, msg.getId());
if (!msg.getDigest().equals(oldMsg.getDigest()) || oldMsg.getFolderId() != fldr.getId()) {
oldMsg = null;
}
} catch (Exception e) {
}
}
if (oldMsg == null) {
Integer digestId = digestInfo.getIdForDigest(fldr, mi.getDigest());
if (digestId != null) {
oldMsg = mbox.getMessageById(octxt, digestId);
if (!msg.getDigest().equals(oldMsg.getDigest())) {
oldMsg = null;
}
}
}
if (oldMsg != null) {
if (r == Resolve.Replace) {
ZimbraLog.misc.debug("Deleting old msg with id=%s as has same digest='%s'", oldMsg.getId(), mi.getDigest());
mbox.delete(octxt, oldMsg.getId(), oldMsg.getType());
} else {
oldItem = oldMsg;
}
}
if (oldItem != null) {
ZimbraLog.misc.debug("Message with id=%s has same digest='%s' - not re-adding", oldItem.getId(), mi.getDigest());
} else {
DeliveryOptions opt = new DeliveryOptions().setFolderId(fldr.getId()).setNoICal(true).setFlags(msg.getFlagBitmask()).setTags(msg.getTags());
newItem = mbox.addMessage(octxt, ais.getInputStream(), (int) aie.getSize(), msg.getDate(), opt, null, id);
}
break;
case MOUNTPOINT:
Mountpoint mp = (Mountpoint) mi;
MailItem oldMP = null;
try {
oldMP = mbox.getItemByPath(octxt, path);
if (oldMP.getType() == mi.getType()) {
oldMP = null;
}
} catch (Exception e) {
}
if (oldMP != null) {
if (r == Resolve.Modify || r == Resolve.Replace) {
mbox.delete(octxt, oldMP.getId(), oldMP.getType());
} else {
oldItem = oldMP;
}
}
if (oldItem == null) {
fldr = createParent(context, fmap, path, Folder.Type.UNKNOWN);
newItem = mbox.createMountpoint(context.opContext, fldr.getId(), mp.getName(), mp.getOwnerId(), mp.getRemoteId(), mp.getRemoteUuid(), mp.getDefaultView(), mp.getFlagBitmask(), mp.getColor(), mp.isReminderEnabled());
}
break;
case NOTE:
Note note = (Note) mi;
Note oldNote = null;
fldr = createPath(context, fmap, path, MailItem.Type.NOTE);
try {
for (Note listNote : mbox.getNoteList(octxt, fldr.getId())) {
if (note.getSubject().equals(listNote.getSubject())) {
oldNote = listNote;
break;
}
}
} catch (Exception e) {
}
if (oldNote != null) {
if (r == Resolve.Replace) {
mbox.delete(octxt, oldNote.getId(), oldNote.getType());
} else {
oldItem = oldNote;
if (r == Resolve.Modify) {
mbox.editNote(octxt, oldItem.getId(), new String(readArchiveEntry(ais, aie), UTF8));
}
}
break;
}
if (oldItem == null) {
newItem = mbox.createNote(octxt, new String(readArchiveEntry(ais, aie), UTF8), note.getBounds(), note.getColor(), fldr.getId());
}
break;
case SEARCHFOLDER:
SearchFolder sf = (SearchFolder) mi;
MailItem oldSF = null;
try {
oldSF = mbox.getItemByPath(octxt, path);
if (oldSF.getType() == mi.getType()) {
oldSF = null;
}
} catch (Exception e) {
}
if (oldSF != null) {
if (r == Resolve.Modify) {
mbox.modifySearchFolder(octxt, oldSF.getId(), sf.getQuery(), sf.getReturnTypes(), sf.getSortField());
} else if (r == Resolve.Replace) {
mbox.delete(octxt, oldSF.getId(), oldSF.getType());
} else {
oldItem = oldSF;
}
}
if (oldItem == null) {
fldr = createParent(context, fmap, path, MailItem.Type.UNKNOWN);
newItem = mbox.createSearchFolder(octxt, fldr.getId(), sf.getName(), sf.getQuery(), sf.getReturnTypes(), sf.getSortField(), sf.getFlagBitmask(), sf.getColor());
}
break;
case TAG:
Tag tag = (Tag) mi;
try {
Tag oldTag = mbox.getTagByName(octxt, tag.getName());
oldItem = oldTag;
} catch (Exception e) {
}
if (oldItem == null) {
newItem = mbox.createTag(octxt, tag.getName(), tag.getColor());
}
break;
case VIRTUAL_CONVERSATION:
return;
}
if (newItem != null) {
if (mi.getColor() != newItem.getColor()) {
mbox.setColor(octxt, newItem.getId(), newItem.getType(), mi.getColor());
}
if (!id.flags.equals(newItem.getFlagString()) || !id.tagsEqual(newItem)) {
mbox.setTags(octxt, newItem.getId(), newItem.getType(), Flag.toBitmask(id.flags), getTagNames(id), null);
}
} else if (oldItem != null && r == Resolve.Modify) {
if (mi.getColor() != oldItem.getColor()) {
mbox.setColor(octxt, oldItem.getId(), oldItem.getType(), mi.getColor());
}
if (!id.flags.equals(oldItem.getFlagString()) || !id.tagsEqual(oldItem)) {
mbox.setTags(octxt, oldItem.getId(), oldItem.getType(), Flag.toBitmask(id.flags), getTagNames(id), null);
}
}
} catch (MailServiceException e) {
if (e.getCode() == MailServiceException.QUOTA_EXCEEDED) {
throw e;
} else if (r != Resolve.Skip || e.getCode() != MailServiceException.ALREADY_EXISTS) {
addError(errs, e);
}
} catch (Exception e) {
String path = id.path;
// When importing items into, e.g. the Inbox, often path is just "/Inbox" which isn't that useful
if ((aie != null) && !Strings.isNullOrEmpty(aie.getName())) {
path = aie.getName();
}
addError(errs, FormatterServiceException.UNKNOWN_ERROR(path, e));
}
}
Aggregations