Search in sources :

Example 1 with ZEventHandler

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);
            }
        }
    }
}
Also used : ZCreateEvent(com.zimbra.client.event.ZCreateEvent) ZCreateConversationEvent(com.zimbra.client.event.ZCreateConversationEvent) ZCreateMountpointEvent(com.zimbra.client.event.ZCreateMountpointEvent) ZEventHandler(com.zimbra.client.event.ZEventHandler) ZCreateTagEvent(com.zimbra.client.event.ZCreateTagEvent) ZCreateMessageEvent(com.zimbra.client.event.ZCreateMessageEvent) JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) ZCreateAppointmentEvent(com.zimbra.client.event.ZCreateAppointmentEvent) ZCreateFolderEvent(com.zimbra.client.event.ZCreateFolderEvent) ZCreateContactEvent(com.zimbra.client.event.ZCreateContactEvent) ZCreateSearchFolderEvent(com.zimbra.client.event.ZCreateSearchFolderEvent) ZCreateTaskEvent(com.zimbra.client.event.ZCreateTaskEvent)

Example 2 with ZEventHandler

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);
    }
}
Also used : ZEventHandler(com.zimbra.client.event.ZEventHandler) ZDeleteEvent(com.zimbra.client.event.ZDeleteEvent)

Example 3 with ZEventHandler

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);
    }
}
Also used : GetFolderRequest(com.zimbra.soap.mail.message.GetFolderRequest) GetFolderResponse(com.zimbra.soap.mail.message.GetFolderResponse) ZEventHandler(com.zimbra.client.event.ZEventHandler) ZRefreshEvent(com.zimbra.client.event.ZRefreshEvent) Folder(com.zimbra.soap.mail.type.Folder)

Example 4 with ZEventHandler

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;
}
Also used : ZEventHandler(com.zimbra.client.event.ZEventHandler) ZRefreshEvent(com.zimbra.client.event.ZRefreshEvent) JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) ArrayList(java.util.ArrayList)

Example 5 with ZEventHandler

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);
    }
}
Also used : ZEventHandler(com.zimbra.client.event.ZEventHandler) ZRefreshEvent(com.zimbra.client.event.ZRefreshEvent) JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) ArrayList(java.util.ArrayList) SoapFaultException(com.zimbra.common.soap.SoapFaultException)

Aggregations

ZEventHandler (com.zimbra.client.event.ZEventHandler)5 ZRefreshEvent (com.zimbra.client.event.ZRefreshEvent)3 Element (com.zimbra.common.soap.Element)3 JSONElement (com.zimbra.common.soap.Element.JSONElement)3 XMLElement (com.zimbra.common.soap.Element.XMLElement)3 ArrayList (java.util.ArrayList)2 ZCreateAppointmentEvent (com.zimbra.client.event.ZCreateAppointmentEvent)1 ZCreateContactEvent (com.zimbra.client.event.ZCreateContactEvent)1 ZCreateConversationEvent (com.zimbra.client.event.ZCreateConversationEvent)1 ZCreateEvent (com.zimbra.client.event.ZCreateEvent)1 ZCreateFolderEvent (com.zimbra.client.event.ZCreateFolderEvent)1 ZCreateMessageEvent (com.zimbra.client.event.ZCreateMessageEvent)1 ZCreateMountpointEvent (com.zimbra.client.event.ZCreateMountpointEvent)1 ZCreateSearchFolderEvent (com.zimbra.client.event.ZCreateSearchFolderEvent)1 ZCreateTagEvent (com.zimbra.client.event.ZCreateTagEvent)1 ZCreateTaskEvent (com.zimbra.client.event.ZCreateTaskEvent)1 ZDeleteEvent (com.zimbra.client.event.ZDeleteEvent)1 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 GetFolderRequest (com.zimbra.soap.mail.message.GetFolderRequest)1 GetFolderResponse (com.zimbra.soap.mail.message.GetFolderResponse)1