use of com.zimbra.client.event.ZEventHandler in project zm-mailbox by Zimbra.
the class ZMailbox method handleCreated.
private void handleCreated(Element created) throws ServiceException {
if (created == null) {
return;
}
List<ZCreateEvent> events = null;
List<ZFolder> parentFixup = null;
for (Element e : created.listElements()) {
ZCreateEvent event = null;
if (e.getName().equals(MailConstants.E_CONV)) {
event = new ZCreateConversationEvent(e);
} else if (e.getName().equals(MailConstants.E_MSG)) {
event = new ZCreateMessageEvent(e);
} else if (e.getName().equals(MailConstants.E_CONTACT)) {
event = new ZCreateContactEvent(e);
} else if (e.getName().equals(MailConstants.E_APPOINTMENT)) {
event = new ZCreateAppointmentEvent(e);
} else if (e.getName().equals(MailConstants.E_TASK)) {
event = new ZCreateTaskEvent(e);
} else if (e.getName().equals(MailConstants.E_FOLDER)) {
String parentId = e.getAttribute(MailConstants.A_FOLDER);
ZFolder parent = getFolderById(parentId);
ZFolder child = new ZFolder(e, parent, this);
addItemIdMapping(child);
event = new ZCreateFolderEvent(child);
parentFixup = parentCheck(parentFixup, child, parent);
} else if (e.getName().equals(MailConstants.E_MOUNT)) {
String parentId = e.getAttribute(MailConstants.A_FOLDER);
ZFolder parent = getFolderById(parentId);
ZMountpoint child = new ZMountpoint(e, parent, this);
addItemIdMapping(child);
addRemoteItemIdMapping(child.getCanonicalRemoteId(), child);
parentFixup = parentCheck(parentFixup, child, parent);
event = new ZCreateMountpointEvent(child);
} else if (e.getName().equals(MailConstants.E_SEARCH)) {
String parentId = e.getAttribute(MailConstants.A_FOLDER);
ZFolder parent = getFolderById(parentId);
ZSearchFolder child = new ZSearchFolder(e, parent, this);
addItemIdMapping(child);
event = new ZCreateSearchFolderEvent(child);
parentFixup = parentCheck(parentFixup, child, parent);
} else if (e.getName().equals(MailConstants.E_TAG)) {
event = new ZCreateTagEvent(new ZTag(e, this));
addTag(((ZCreateTagEvent) event).getTag());
}
if (event != null) {
if (events == null) {
events = new ArrayList<ZCreateEvent>();
}
events.add(event);
}
}
if (parentFixup != null) {
for (ZFolder f : parentFixup) {
ZFolder parent = getFolderById(f.getParentId());
if (parent != null) {
parent.addChild(f);
f.setParent(parent);
}
}
}
if (events != null) {
for (ZCreateEvent event : events) {
for (ZEventHandler handler : mHandlers) {
handler.handleCreate(event, this);
}
}
}
}
use of com.zimbra.client.event.ZEventHandler in project zm-mailbox by Zimbra.
the class ZMailbox method handleDeleted.
private void handleDeleted(Element deleted) throws ServiceException {
if (deleted == null) {
return;
}
String ids = deleted.getAttribute(MailConstants.A_ID, null);
if (ids == null) {
return;
}
ZDeleteEvent de = new ZDeleteEvent(ids);
for (ZEventHandler handler : mHandlers) {
handler.handleDelete(de, this);
}
}
use of com.zimbra.client.event.ZEventHandler in project zm-mailbox by Zimbra.
the class ZMailbox method populateFolderCache.
private void populateFolderCache() throws ServiceException {
if (mUserRoot != null) {
return;
}
if (mNotifyPreference == null || mNotifyPreference == NotifyPreference.full) {
noOp();
if (mUserRoot != null) {
return;
}
}
GetFolderRequest req = new GetFolderRequest(null, true);
GetFolderResponse res = invokeJaxb(req);
Folder root = res.getFolder();
ZFolder userRoot = (root != null ? new ZFolder(root, null, this) : null);
ZRefreshEvent event = new ZRefreshEvent(mSize, userRoot, null);
for (ZEventHandler handler : mHandlers) {
handler.handleRefresh(event, this);
}
}
use of com.zimbra.client.event.ZEventHandler in project zm-mailbox by Zimbra.
the class ZMailbox method handleRefresh.
private void handleRefresh(Element refresh) throws ServiceException {
for (Element mbx : refresh.listElements(MailConstants.E_MAILBOX)) {
// FIXME: logic should be different if ZMailbox points at another user's mailbox
if (mbx.getAttribute(HeaderConstants.A_ACCOUNT_ID, null) == null) {
mSize = mbx.getAttributeLong(MailConstants.A_SIZE);
}
}
Element tags = refresh.getOptionalElement(ZimbraNamespace.E_TAGS);
List<ZTag> tagList = new ArrayList<ZTag>();
if (tags != null) {
for (Element t : tags.listElements(MailConstants.E_TAG)) {
ZTag tag = new ZTag(t, this);
tagList.add(tag);
}
}
Element folderEl = refresh.getOptionalElement(MailConstants.E_FOLDER);
ZFolder userRoot = new ZFolder(folderEl, null, this);
ZRefreshEvent event = new ZRefreshEvent(mSize, userRoot, tagList);
for (ZEventHandler handler : mHandlers) {
handler.handleRefresh(event, this);
}
incomingRules = null;
outgoingRules = null;
}
use of com.zimbra.client.event.ZEventHandler in project zm-mailbox by Zimbra.
the class ZMailbox method populateTagCache.
private void populateTagCache() throws ServiceException {
if (mNameToTag != null) {
return;
}
if (mNotifyPreference == null || mNotifyPreference == NotifyPreference.full) {
noOp();
if (mNameToTag != null) {
return;
}
}
List<ZTag> tagList = new ArrayList<ZTag>();
if (!mNoTagCache) {
try {
Element response = invoke(newRequestElement(MailConstants.GET_TAG_REQUEST));
for (Element t : response.listElements(MailConstants.E_TAG)) {
tagList.add(new ZTag(t, this));
}
} catch (SoapFaultException sfe) {
if (!sfe.getCode().equals(ServiceException.PERM_DENIED)) {
throw sfe;
}
}
}
ZRefreshEvent event = new ZRefreshEvent(mSize, null, tagList);
for (ZEventHandler handler : mHandlers) {
handler.handleRefresh(event, this);
}
}
Aggregations