use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method iCalReply.
/**
* Sends an iCalendar REPLY object
* @param ical iCalendar data
* @throws ServiceException on error
*/
public void iCalReply(String ical, String sender) throws ServiceException {
Element req = newRequestElement(MailConstants.ICAL_REPLY_REQUEST);
Element icalElem = req.addUniqueElement(MailConstants.E_CAL_ICAL);
icalElem.setText(ical);
if (sender != null) {
icalElem.addAttribute(MailConstants.E_CAL_ATTENDEE, sender);
}
invoke(req);
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method getAllContacts.
/**
*
* @param optFolderId return contacts only in specified folder (null for all folders)
* @param sortBy sort results (null for no sorting)
* @param sync if true, return modified date on contacts
* @return list of contacts
* @throws ServiceException on error
* @param attrs specified attrs to return, or null for all.
*/
public List<ZContact> getAllContacts(String optFolderId, ContactSortBy sortBy, boolean sync, List<String> attrs) throws ServiceException {
Element req = newRequestElement(MailConstants.GET_CONTACTS_REQUEST);
if (optFolderId != null) {
req.addAttribute(MailConstants.A_FOLDER, optFolderId);
}
if (sortBy != null) {
req.addAttribute(MailConstants.A_SORTBY, sortBy.name());
}
if (sync) {
req.addAttribute(MailConstants.A_SYNC, sync);
}
if (attrs != null) {
for (String name : attrs) {
req.addElement(MailConstants.E_ATTRIBUTE).addAttribute(MailConstants.A_ATTRIBUTE_NAME, name);
}
}
Element response = invoke(req);
List<ZContact> result = new ArrayList<ZContact>();
for (Element cn : response.listElements(MailConstants.E_CONTACT)) {
result.add(new ZContact(cn, this));
}
return result;
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method modifyAppointment.
public ZAppointmentResult modifyAppointment(String id, String component, ZDateTime exceptionId, ZOutgoingMessage message, ZInvite invite) throws ServiceException {
Element req = newRequestElement(MailConstants.MODIFY_APPOINTMENT_REQUEST);
req.addAttribute(MailConstants.A_ID, id);
req.addAttribute(MailConstants.E_INVITE_COMPONENT, component);
Element mEl = getMessageElement(req, message, null);
Element invEl = invite.toElement(mEl);
if (exceptionId != null) {
Element compEl = invEl.getElement(MailConstants.E_INVITE_COMPONENT);
exceptionId.toElement(MailConstants.E_CAL_EXCEPTION_ID, compEl);
}
return new ZAppointmentResult(invoke(req));
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method getContactsForFolder.
/**
* Fetch contacts for a given folder or contacts ids
* @param folderid folder id of the contact folder
* @param ids comma-separated list of contact ids
* @param attrs limit attrs returns to given list
* @param sortBy sort results (null for no sorting)
* @param sync if true, return modified date on contacts
* @return list of contacts
* @throws ServiceException on error
*/
public List<ZContact> getContactsForFolder(String folderid, String ids, ContactSortBy sortBy, boolean sync, List<String> attrs) throws ServiceException {
Element req = newRequestElement(MailConstants.GET_CONTACTS_REQUEST);
if (!StringUtil.isNullOrEmpty(folderid)) {
req.addAttribute(MailConstants.A_FOLDER, folderid);
}
if (sortBy != null) {
req.addAttribute(MailConstants.A_SORTBY, sortBy.name());
}
if (sync) {
req.addAttribute(MailConstants.A_SYNC, sync);
}
if (!StringUtil.isNullOrEmpty(ids)) {
req.addAttribute(MailConstants.A_DEREF_CONTACT_GROUP_MEMBER, true);
req.addElement(MailConstants.E_CONTACT).addAttribute(MailConstants.A_ID, ids);
}
if (attrs != null) {
for (String name : attrs) {
req.addElement(MailConstants.E_ATTRIBUTE).addAttribute(MailConstants.A_ATTRIBUTE_NAME, name);
}
}
List<ZContact> result = new ArrayList<ZContact>();
for (Element cn : invoke(req).listElements(MailConstants.E_CONTACT)) {
result.add(new ZContact(cn, this));
}
return result;
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method getValidFolderIds.
/**
* Validates the given set of folder ids. If a folder id corresponds to a mountpoint
* that is not accessible, that id is omitted from the returned list.
*/
public synchronized String getValidFolderIds(String ids) throws ServiceException {
if (StringUtil.isNullOrEmpty(ids)) {
return "";
}
// 1. Separate Local FolderIds and Remote FolderIds
// sbResult is a list of valid folderIds
// sbRemote is a list of mountpoints
Set<String> mountpointIds = new HashSet<String>();
Set<String> validIds = new HashSet<String>();
for (String id : ids.split(",")) {
ZFolder f = getFolderById(id);
if (f instanceof ZMountpoint) {
mountpointIds.add(id);
} else {
validIds.add(id);
}
}
//2. Send a batch request GetFolderRequest with sbRemote as input
try {
Element batch = newRequestElement(ZimbraNamespace.E_BATCH_REQUEST);
//Element resp;
for (String id : mountpointIds) {
Element folderrequest = batch.addElement(MailConstants.GET_FOLDER_REQUEST);
Element e = folderrequest.addElement(MailConstants.E_FOLDER);
e.addAttribute(MailConstants.A_FOLDER, id);
}
Element resp = mTransport.invoke(batch);
//3. Parse the response and add valid folderIds to sbResult.
for (Element e : resp.listElements()) {
if (e.getName().equals(MailConstants.GET_FOLDER_RESPONSE.getName())) {
boolean isBrokenMountpoint = e.getElement(MailConstants.E_MOUNT).getAttributeBool(MailConstants.A_BROKEN, false);
if (!isBrokenMountpoint) {
String id = e.getElement(MailConstants.E_MOUNT).getAttribute(MailConstants.A_ID);
validIds.add(id);
}
}
}
return StringUtil.join(",", validIds);
} catch (IOException e) {
throw ZClientException.IO_ERROR("invoke " + e.getMessage(), e);
}
}
Aggregations