long startTime = sWatch.start();
ZimbraContext lc = getZimbraContext(context); Mailbox mbox = getRequestedMailbox(lc); OperationContext octxt = lc.getOperationContext();
    public Element handle(Element request, Map context) throws ServiceException {        long startTime = sWatch.start();                 try {            ZimbraContext lc = getZimbraContext(context);            Mailbox mbox = getRequestedMailbox(lc);            OperationContext octxt = lc.getOperationContext();            Element msgElem = request.getElement(MailService.E_MSG);            String flagsStr = msgElem.getAttribute(MailService.A_FLAGS, null);	        String tagsStr = msgElem.getAttribute(MailService.A_TAGS, null);	        String folderStr = msgElem.getAttribute(MailService.A_FOLDER);            boolean noICal = msgElem.getAttributeBool(MailService.A_NO_ICAL, false);            long date = msgElem.getAttributeLong(MailService.A_DATE, System.currentTimeMillis());	        if (mLog.isDebugEnabled()) {	            StringBuffer toPrint = new StringBuffer("<AddMsg ");	            if (tagsStr != null)	                toPrint.append(" tags=\"").append(tagsStr).append("\"");	            if (folderStr != null)	                toPrint.append(" folder=\"").append(folderStr).append("\"");	            toPrint.append(">");	            mLog.debug(toPrint);	        }	        // sanity-check the supplied tag list	        if (tagsStr != null) {	            String[] splitTags = tagsStr.split("\\s*,\\s*");	            if (splitTags.length > 0)	                for (int i = 0; i < splitTags.length; i++) {	                    try {	                        int tagId = Integer.parseInt(splitTags[i]);	                        if (mbox.getTagById(octxt, tagId) == null)	                        	throw ServiceException.INVALID_REQUEST("Unknown tag: \"" + tagId + "\"", null);	                    } catch (NumberFormatException e) {};	                }	        }	        Folder folder = null;	        if (folderStr != null) {                try {                    ItemId iidFolder = new ItemId(folderStr, lc);                    folder = mbox.getFolderById(octxt, iidFolder.getId());                } catch (NoSuchItemException nsie) {                } catch (NumberFormatException e) {}                if (folder == null)                    folder = mbox.getFolderByPath(octxt, folderStr);                if (mLog.isDebugEnabled())                    mLog.debug("folder = " + folder.toString());	        }            // check to see whether the entire message has been uploaded under separate cover            String attachment = msgElem.getAttribute(MailService.A_ATTACHMENT_ID, null);            ParseMimeMessage.MimeMessageData mimeData = new ParseMimeMessage.MimeMessageData();            MimeMessage mm;            if (attachment != null)                mm = SendMsg.parseUploadedMessage(lc, attachment, mimeData);            else                mm = ParseMimeMessage.importMsgSoap(msgElem);	        int messageId = -1;	        try {                ParsedMessage pm = new ParsedMessage(mm, date, mbox.attachmentsIndexingEnabled());	            Message msg = mbox.addMessage(octxt, pm, folder.getId(), noICal, Flag.flagsToBitmask(flagsStr), tagsStr);	            if (msg != null)                    messageId = msg.getId();	        } catch(IOException ioe) {	            throw ServiceException.FAILURE("Error While Delivering Message", ioe);	        }            // we can now purge the uploaded attachments            if (mimeData.uploads != null)                FileUploadServlet.deleteUploads(mimeData.uploads);            Element response = lc.createElement(MailService.ADD_MSG_RESPONSE);            if (messageId != -1)	    	    response.addElement(MailService.E_MSG).addAttribute(MailService.A_ID, messageId);            return response;        } finally {            sWatch.stop(startTime);        }    }