use of com.zimbra.cs.mailbox.Tag in project zm-mailbox by Zimbra.
the class SoapSession method putRefresh.
/** Serializes basic folder/tag structure to a SOAP response header.
* <p>
* Adds a <refresh> block to the existing <context> element.
* This <refresh> block contains the basic folder, tag, and mailbox
* size information needed to display and update the web UI's overview
* pane. The <refresh> block is sent when a new session is created.
*
* This API implicitly clears all cached notifications and therefore
* should only been used during session creation.
* @param ctxt An existing SOAP header <context> element
* @param zsc The SOAP request's encapsulated context */
public void putRefresh(Element ctxt, ZimbraSoapContext zsc) throws ServiceException {
Mailbox mbox = mailbox;
if (mbox == null) {
return;
}
synchronized (sentChanges) {
for (QueuedNotifications ntfn : sentChanges) {
ntfn.clearMailboxChanges();
}
}
Element eRefresh = ctxt.addUniqueElement(ZimbraNamespace.E_REFRESH);
eRefresh.addAttribute(AccountConstants.E_VERSION, BuildInfo.FULL_VERSION, Element.Disposition.CONTENT);
OperationContext octxt = DocumentHandler.getOperationContext(zsc, this);
ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
// dump current mailbox status (currently just size)
ToXML.encodeMailbox(eRefresh, octxt, mbox);
// dump all tags under a single <tags> parent
List<Tag> tags = mbox.getTagList(octxt);
if (tags != null && tags.size() > 0) {
Element eTags = eRefresh.addUniqueElement(ZimbraNamespace.E_TAGS);
for (Tag tag : tags) {
if (tag != null && !(tag instanceof Flag)) {
ToXML.encodeTag(eTags, ifmt, octxt, tag);
}
}
}
// first, get the user's folder hierarchy
FolderNode root = mbox.getFolderTree(octxt, null, false);
OperationContextData.setNeedGranteeName(octxt, false);
GetFolder.encodeFolderNode(root, eRefresh, ifmt, octxt);
// The Boolean of the Pair indicates whether the mountpoint is found to be broken
Map<ItemId, Pair<Boolean, Element>> mountpoints = new HashMap<ItemId, Pair<Boolean, Element>>();
// for mountpoints pointing to this host, get the serialized folder subhierarchy
expandLocalMountpoints(octxt, root, eRefresh.getFactory(), mountpoints);
// for mountpoints pointing to other hosts, get the folder structure from the remote server
expandRemoteMountpoints(octxt, zsc, mountpoints);
// graft in subfolder trees from the other user's mailbox, making sure that mountpoints reflect the counts (etc.) of the target folder
if (!mountpoints.isEmpty()) {
transferMountpointContents(eRefresh.getOptionalElement(MailConstants.E_FOLDER), octxt, mountpoints);
}
}
Aggregations