Search in sources :

Example 1 with ZCreateTagEvent

use of com.zimbra.client.event.ZCreateTagEvent in project zm-mailbox by Zimbra.

the class ZMailbox method handleCreated.

private void handleCreated(Element created) throws ServiceException {
    if (created == null) {
        return;
    }
    List<ZCreateEvent> events = null;
    List<ZFolder> parentFixup = null;
    for (Element e : created.listElements()) {
        ZCreateEvent event = null;
        if (e.getName().equals(MailConstants.E_CONV)) {
            event = new ZCreateConversationEvent(e);
        } else if (e.getName().equals(MailConstants.E_MSG)) {
            event = new ZCreateMessageEvent(e);
        } else if (e.getName().equals(MailConstants.E_CONTACT)) {
            event = new ZCreateContactEvent(e);
        } else if (e.getName().equals(MailConstants.E_APPOINTMENT)) {
            event = new ZCreateAppointmentEvent(e);
        } else if (e.getName().equals(MailConstants.E_TASK)) {
            event = new ZCreateTaskEvent(e);
        } else if (e.getName().equals(MailConstants.E_FOLDER)) {
            String parentId = e.getAttribute(MailConstants.A_FOLDER);
            ZFolder parent = getFolderById(parentId);
            ZFolder child = new ZFolder(e, parent, this);
            addItemIdMapping(child);
            event = new ZCreateFolderEvent(child);
            parentFixup = parentCheck(parentFixup, child, parent);
        } else if (e.getName().equals(MailConstants.E_MOUNT)) {
            String parentId = e.getAttribute(MailConstants.A_FOLDER);
            ZFolder parent = getFolderById(parentId);
            ZMountpoint child = new ZMountpoint(e, parent, this);
            addItemIdMapping(child);
            addRemoteItemIdMapping(child.getCanonicalRemoteId(), child);
            parentFixup = parentCheck(parentFixup, child, parent);
            event = new ZCreateMountpointEvent(child);
        } else if (e.getName().equals(MailConstants.E_SEARCH)) {
            String parentId = e.getAttribute(MailConstants.A_FOLDER);
            ZFolder parent = getFolderById(parentId);
            ZSearchFolder child = new ZSearchFolder(e, parent, this);
            addItemIdMapping(child);
            event = new ZCreateSearchFolderEvent(child);
            parentFixup = parentCheck(parentFixup, child, parent);
        } else if (e.getName().equals(MailConstants.E_TAG)) {
            event = new ZCreateTagEvent(new ZTag(e, this));
            addTag(((ZCreateTagEvent) event).getTag());
        }
        if (event != null) {
            if (events == null) {
                events = new ArrayList<ZCreateEvent>();
            }
            events.add(event);
        }
    }
    if (parentFixup != null) {
        for (ZFolder f : parentFixup) {
            ZFolder parent = getFolderById(f.getParentId());
            if (parent != null) {
                parent.addChild(f);
                f.setParent(parent);
            }
        }
    }
    if (events != null) {
        for (ZCreateEvent event : events) {
            for (ZEventHandler handler : mHandlers) {
                handler.handleCreate(event, this);
            }
        }
    }
}
Also used : ZCreateEvent(com.zimbra.client.event.ZCreateEvent) ZCreateConversationEvent(com.zimbra.client.event.ZCreateConversationEvent) ZCreateMountpointEvent(com.zimbra.client.event.ZCreateMountpointEvent) ZEventHandler(com.zimbra.client.event.ZEventHandler) ZCreateTagEvent(com.zimbra.client.event.ZCreateTagEvent) ZCreateMessageEvent(com.zimbra.client.event.ZCreateMessageEvent) JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) ZCreateAppointmentEvent(com.zimbra.client.event.ZCreateAppointmentEvent) ZCreateFolderEvent(com.zimbra.client.event.ZCreateFolderEvent) ZCreateContactEvent(com.zimbra.client.event.ZCreateContactEvent) ZCreateSearchFolderEvent(com.zimbra.client.event.ZCreateSearchFolderEvent) ZCreateTaskEvent(com.zimbra.client.event.ZCreateTaskEvent)

Aggregations

ZCreateAppointmentEvent (com.zimbra.client.event.ZCreateAppointmentEvent)1 ZCreateContactEvent (com.zimbra.client.event.ZCreateContactEvent)1 ZCreateConversationEvent (com.zimbra.client.event.ZCreateConversationEvent)1 ZCreateEvent (com.zimbra.client.event.ZCreateEvent)1 ZCreateFolderEvent (com.zimbra.client.event.ZCreateFolderEvent)1 ZCreateMessageEvent (com.zimbra.client.event.ZCreateMessageEvent)1 ZCreateMountpointEvent (com.zimbra.client.event.ZCreateMountpointEvent)1 ZCreateSearchFolderEvent (com.zimbra.client.event.ZCreateSearchFolderEvent)1 ZCreateTagEvent (com.zimbra.client.event.ZCreateTagEvent)1 ZCreateTaskEvent (com.zimbra.client.event.ZCreateTaskEvent)1 ZEventHandler (com.zimbra.client.event.ZEventHandler)1 Element (com.zimbra.common.soap.Element)1 JSONElement (com.zimbra.common.soap.Element.JSONElement)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1