Search in sources :

Example 1 with Folder

use of com.zimbra.soap.mail.type.Folder 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 Folder

use of com.zimbra.soap.mail.type.Folder in project zm-mailbox by Zimbra.

the class GetFolderTest method unmarshallGetFolderResponseContainingGrant.

/**
     * Motivated by Bug 55153 failure in ZGrant.java line 134:
     *      mGranteeType = GranteeType.fromString(grant.getGranteeType().toString());
     */
@Test
public void unmarshallGetFolderResponseContainingGrant() throws Exception {
    GetFolderResponse result = (GetFolderResponse) unmarshaller.unmarshal(getClass().getResourceAsStream("GetFolderResponseWithGrant.xml"));
    Folder top = result.getFolder();
    boolean foundGrant = false;
    for (Folder child : top.getSubfolders()) {
        Acl acl = child.getAcl();
        if (acl != null) {
            List<Grant> myGrants = acl.getGrants();
            if (myGrants.size() > 0) {
                foundGrant = true;
                Grant first = myGrants.get(0);
                GrantGranteeType mGranteeType = GrantGranteeType.fromString(first.getGranteeType().toString());
                Assert.assertEquals(GrantGranteeType.usr, mGranteeType);
            }
        }
    }
    Assert.assertTrue("Should have processed a valid <grant>", foundGrant);
    result = (GetFolderResponse) unmarshaller.unmarshal(getClass().getResourceAsStream("GetFolderResponseWithBadGrant.xml"));
    top = result.getFolder();
    foundGrant = false;
    for (Folder child : top.getSubfolders()) {
        Acl acl = child.getAcl();
        if (acl != null) {
            List<Grant> myGrants = acl.getGrants();
            if (myGrants.size() > 0) {
                foundGrant = true;
                Grant first = myGrants.get(0);
                GrantGranteeType mGranteeType = first.getGranteeType();
                Assert.assertNull("There was no 'gt' attribute", mGranteeType);
            }
        }
    }
    Assert.assertTrue("Should have processed a bad <grant>", foundGrant);
}
Also used : Grant(com.zimbra.soap.mail.type.Grant) GetFolderResponse(com.zimbra.soap.mail.message.GetFolderResponse) GrantGranteeType(com.zimbra.soap.type.GrantGranteeType) Acl(com.zimbra.soap.mail.type.Acl) Folder(com.zimbra.soap.mail.type.Folder) SearchFolder(com.zimbra.soap.mail.type.SearchFolder) Test(org.junit.Test)

Aggregations

GetFolderResponse (com.zimbra.soap.mail.message.GetFolderResponse)2 Folder (com.zimbra.soap.mail.type.Folder)2 ZEventHandler (com.zimbra.client.event.ZEventHandler)1 ZRefreshEvent (com.zimbra.client.event.ZRefreshEvent)1 GetFolderRequest (com.zimbra.soap.mail.message.GetFolderRequest)1 Acl (com.zimbra.soap.mail.type.Acl)1 Grant (com.zimbra.soap.mail.type.Grant)1 SearchFolder (com.zimbra.soap.mail.type.SearchFolder)1 GrantGranteeType (com.zimbra.soap.type.GrantGranteeType)1 Test (org.junit.Test)1