Search in sources :

Example 1 with GetFolderResponse

use of com.zimbra.soap.mail.message.GetFolderResponse in project zm-mailbox by Zimbra.

the class ZMailbox method getSharedFolderById.

/**
 * always bypass caching and issues a GetFolderRequest
 */
public ZSharedFolder getSharedFolderById(String id) throws ServiceException {
    GetFolderRequest req = new GetFolderRequest(GetFolderSpec.forID(id));
    req.setVisible(true);
    GetFolderResponse resp = invokeJaxb(req);
    Folder folderInfo = resp.getFolder();
    ZSharedFolder folder = new ZSharedFolder(folderInfo, null, /* parent */
    id, this);
    return folder.isHierarchyPlaceholder() ? null : folder;
}
Also used : GetFolderRequest(com.zimbra.soap.mail.message.GetFolderRequest) GetFolderResponse(com.zimbra.soap.mail.message.GetFolderResponse) Folder(com.zimbra.soap.mail.type.Folder)

Example 2 with GetFolderResponse

use of com.zimbra.soap.mail.message.GetFolderResponse in project zm-mailbox by Zimbra.

the class ZMailbox method populateFolderCache.

private void populateFolderCache() throws ServiceException {
    if (mUserRoot != null) {
        if (alwaysRefreshFolders) {
            noOp();
        }
        return;
    }
    if (mNotifyPreference == null || mNotifyPreference == SessionPreference.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 3 with GetFolderResponse

use of com.zimbra.soap.mail.message.GetFolderResponse in project zm-mailbox by Zimbra.

the class TestJaxb method testGetFolderWithCacheContainingNullParent.

@Test
public void testGetFolderWithCacheContainingNullParent() throws Exception {
    TestUtil.createAccount(USER_NAME);
    ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
    ZFolder f1 = TestUtil.createFolder(zmbox, FOLDER_F1);
    ZFolder f2 = TestUtil.createFolder(zmbox, SUB_FOLDER_F2);
    Mailbox mbox = TestUtil.getMailbox(USER_NAME);
    OperationContext octxt = new OperationContext(mbox);
    ItemId f1ItemId = new ItemId(mbox, Integer.parseInt(f1.getId()));
    ItemId f2ItemId = new ItemId(mbox, Integer.parseInt(f2.getId()));
    // ItemId rootItemId = new ItemId(mbox, Mailbox.ID_FOLDER_USER_ROOT);
    // mbox.getFolderTree(octxt, rootItemId, false);
    Folder f1folder = mbox.getFolderById(octxt, f1ItemId.getId());
    Folder f2folder = mbox.getFolderById(octxt, f2ItemId.getId());
    // Bug 100588 f1folder/f2folder will have been retrieved from the folder cache.  Deliberately poison it
    // by setting the parent folder to null, and ensure that can still successfully do a GetFolderRequest
    f1folder.setParent(null);
    f2folder.setParent(null);
    GetFolderResponse gfResp = zmbox.invokeJaxb(new GetFolderRequest());
    Assert.assertNotNull("GetFolderResponse null", gfResp);
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) ZMailbox(com.zimbra.client.ZMailbox) GetFolderResponse(com.zimbra.soap.mail.message.GetFolderResponse) GetFolderRequest(com.zimbra.soap.mail.message.GetFolderRequest) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZMailbox(com.zimbra.client.ZMailbox) ZFolder(com.zimbra.client.ZFolder) Folder(com.zimbra.cs.mailbox.Folder) ZFolder(com.zimbra.client.ZFolder) ItemId(com.zimbra.cs.service.util.ItemId) Test(org.junit.Test)

Example 4 with GetFolderResponse

use of com.zimbra.soap.mail.message.GetFolderResponse 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)4 GetFolderRequest (com.zimbra.soap.mail.message.GetFolderRequest)3 Folder (com.zimbra.soap.mail.type.Folder)3 Test (org.junit.Test)2 ZFolder (com.zimbra.client.ZFolder)1 ZMailbox (com.zimbra.client.ZMailbox)1 ZEventHandler (com.zimbra.client.event.ZEventHandler)1 ZRefreshEvent (com.zimbra.client.event.ZRefreshEvent)1 Folder (com.zimbra.cs.mailbox.Folder)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 OperationContext (com.zimbra.cs.mailbox.OperationContext)1 ItemId (com.zimbra.cs.service.util.ItemId)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