Element attElem = docElem.getElement(MailService.E_UPLOAD); String aid = attElem.getAttribute(MailService.A_ID, null);
Doc doc; Element attElem = docElem.getOptionalElement(MailService.E_UPLOAD);; if (attElem != null) { String aid = attElem.getAttribute(MailService.A_ID, null); doc = getDocumentDataFromAttachment(lc, aid); } else { attElem = docElem.getElement(MailService.E_MSG); String msgid = attElem.getAttribute(MailService.A_ID, null); String part = attElem.getAttribute(MailService.A_PART, null); doc = getDocumentDataFromMessage(octxt, mbox, msgid, part); }
	public Element handle(Element request, Map context)			throws ServiceException, SoapFaultException {        ZimbraContext lc = getZimbraContext(context);        Wiki wiki = Wiki.getInstance();        Mailbox mbox = Mailbox.getMailboxByAccountId(wiki.getWikiAccountId());        OperationContext octxt = lc.getOperationContext();        Element docElem = request.getElement(MailService.E_DOC);        Element attElem = docElem.getElement(MailService.E_UPLOAD);        String aid = attElem.getAttribute(MailService.A_ID, null);        Doc doc = getDocumentDataFromAttachment(lc, aid);                String name = docElem.getAttribute(MailService.A_NAME, doc.name);        String ctype = docElem.getAttribute(MailService.A_CONTENT_TYPE, doc.contentType);        int fid = (int)docElem.getAttributeLong(MailService.A_FOLDER, wiki.getWikiFolderId());        Document docItem;   		docItem = mbox.createDocument(octxt, fid, name, ctype, doc.contents, null);        //wiki.addWiki(docItem);  // XXX need to keep track of documents.        Element response = lc.createElement(MailService.SAVE_DOCUMENT_RESPONSE);        Element m = response.addElement(MailService.E_MSG);        m.addAttribute(MailService.A_ID, lc.formatItemId(docItem));        return response;	}