use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method addMessage.
/**
* @param folderId (required) folderId of folder to add message to
* @param flags non-comma-separated list of flags, e.g. "sf" for "sent by me and flagged",
* or <tt>null</tt>
* @param tags comma-spearated list of tags, or null for no tags, or <tt>null</tt>
* @param receivedDate time the message was originally received, in MILLISECONDS since the epoch,
* or <tt>0</tt> for the current time
* @param in content stream
* @param contentLength number of bytes in the content stream
* @param noICal if TRUE, then don't process iCal attachments.
* @return ID of newly created message
* @throws ServiceException on error
*/
public String addMessage(String folderId, String flags, String tags, long receivedDate, InputStream in, long contentLength, boolean noICal) throws ServiceException {
// first, upload the content via the FileUploadServlet
String aid = uploadContentAsStream("message", in, "message/rfc822", contentLength, 5000);
// now, use the returned upload ID to do the message send
Element req = newRequestElement(MailConstants.ADD_MSG_REQUEST);
Element m = req.addUniqueElement(MailConstants.E_MSG);
m.addAttribute(MailConstants.A_FOLDER, folderId);
if (flags != null && flags.length() > 0) {
m.addAttribute(MailConstants.A_FLAGS, flags);
}
if (tags != null && tags.length() > 0) {
m.addAttribute(MailConstants.A_TAGS, tags);
}
if (receivedDate > 0) {
m.addAttribute(MailConstants.A_DATE, receivedDate);
}
m.addAttribute(MailConstants.A_ATTACHMENT_ID, aid);
m.addAttribute(MailConstants.A_NO_ICAL, noICal);
return invoke(req).getElement(MailConstants.E_MSG).getAttribute(MailConstants.A_ID);
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZImapDataSource method toElement.
public Element toElement(Element parent) {
Element src = parent.addElement(MailConstants.E_DS_IMAP);
src.addAttribute(MailConstants.A_ID, data.getId());
src.addAttribute(MailConstants.A_NAME, data.getName());
src.addAttribute(MailConstants.A_DS_IS_ENABLED, data.isEnabled());
src.addAttribute(MailConstants.A_DS_HOST, data.getHost());
src.addAttribute(MailConstants.A_DS_PORT, data.getPort());
src.addAttribute(MailConstants.A_DS_USERNAME, data.getUsername());
src.addAttribute(MailConstants.A_DS_PASSWORD, data.getPassword());
src.addAttribute(MailConstants.A_FOLDER, data.getFolderId());
src.addAttribute(MailConstants.A_DS_CONNECTION_TYPE, data.getConnectionType().name());
src.addAttribute(MailConstants.A_DS_IS_IMPORTONLY, data.isImportOnly());
return src;
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method modifySearchFolder.
/**
* modify a search folder.
*
* @param id id of search folder
* @param query search query or null to leave unchanged.
* @param types new types or null to leave unchanged.
* @param sortBy new sortBy or null to leave unchanged
* @return modified search folder
* @throws ServiceException on error
*/
public ZSearchFolder modifySearchFolder(String id, String query, String types, SearchSortBy sortBy) throws ServiceException {
Element req = newRequestElement(MailConstants.MODIFY_SEARCH_FOLDER_REQUEST);
Element folderEl = req.addUniqueElement(MailConstants.E_SEARCH);
folderEl.addAttribute(MailConstants.A_ID, id);
if (query != null) {
folderEl.addAttribute(MailConstants.A_QUERY, query);
}
if (types != null) {
folderEl.addAttribute(MailConstants.A_SEARCH_TYPES, types);
}
if (sortBy != null) {
folderEl.addAttribute(MailConstants.A_SORTBY, sortBy.name());
}
invoke(req);
// this assumes notifications will modify the search folder
return getSearchFolderById(id);
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method getDocument.
public ZDocument getDocument(String id) throws ServiceException {
Element req = newRequestElement(MailConstants.GET_ITEM_REQUEST);
Element item = req.addUniqueElement(MailConstants.E_ITEM);
item.addAttribute(MailConstants.A_ID, id);
Element e = invoke(req).getElement(MailConstants.E_DOC);
return new ZDocument(e);
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method autoCompleteGal.
public ZSearchGalResult autoCompleteGal(String query, GalEntryType type, int limit) throws ServiceException {
Element req = newRequestElement(AccountConstants.AUTO_COMPLETE_GAL_REQUEST);
if (type != null) {
req.addAttribute(AccountConstants.A_TYPE, type.name());
}
req.addAttribute(AccountConstants.A_LIMIT, limit);
req.addElement(AccountConstants.E_NAME).setText(query);
Element resp = invoke(req);
List<ZContact> contacts = new ArrayList<ZContact>();
for (Element contact : resp.listElements(MailConstants.E_CONTACT)) {
contacts.add(new ZContact(contact, true, this));
}
return new ZSearchGalResult(contacts, resp.getAttributeBool(AccountConstants.A_MORE, false), query, type);
}
Aggregations