Search in sources :

Example 1 with ZRefreshEvent

use of com.zimbra.client.event.ZRefreshEvent 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 2 with ZRefreshEvent

use of com.zimbra.client.event.ZRefreshEvent 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 3 with ZRefreshEvent

use of com.zimbra.client.event.ZRefreshEvent 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)3 ZRefreshEvent (com.zimbra.client.event.ZRefreshEvent)3 Element (com.zimbra.common.soap.Element)2 JSONElement (com.zimbra.common.soap.Element.JSONElement)2 XMLElement (com.zimbra.common.soap.Element.XMLElement)2 ArrayList (java.util.ArrayList)2 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 GetFolderRequest (com.zimbra.soap.mail.message.GetFolderRequest)1 GetFolderResponse (com.zimbra.soap.mail.message.GetFolderResponse)1 Folder (com.zimbra.soap.mail.type.Folder)1