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;
}
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);
}
}
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);
}
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);
}
Aggregations