Search in sources :

Example 1 with ModifyContactSpec

use of com.zimbra.soap.mail.type.ModifyContactSpec in project zm-mailbox by Zimbra.

the class ZMailbox method modifyContact.

/**
 * @param id of contact
 * @param replace if true, replace all attrs with specified attrs, otherwise merge with existing
 * @param attrs modified attrs, or <tt>null</tt>
 * @param attachments modified attachments , or <tt>null</tt>
 * @param members members of a contact group
 * @return updated contact
 * @throws ServiceException on error
 */
public ZContact modifyContact(String id, boolean replace, Map<String, String> attrs, Map<String, ZAttachmentInfo> attachments, Map<String, String> members) throws ServiceException {
    ModifyContactSpec contactSpec = ModifyContactSpec.createForId(Integer.valueOf(id));
    ModifyContactRequest mcReq = new ModifyContactRequest(contactSpec);
    mcReq.setWantImapUid(true);
    mcReq.setWantModifiedSequence(true);
    mcReq.setReplace(replace);
    addAttrsAndAttachmentsToContact(contactSpec, attrs, attachments);
    if (members != null) {
        for (Map.Entry<String, String> entry : members.entrySet()) {
            contactSpec.addContactGroupMemberWithTypeAndValue(entry.getValue(), entry.getKey());
        }
    }
    return new ZContact(invokeJaxbToElement(mcReq).getElement(MailConstants.E_CONTACT), this);
}
Also used : ModifyContactSpec(com.zimbra.soap.mail.type.ModifyContactSpec) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) ModifyContactRequest(com.zimbra.soap.mail.message.ModifyContactRequest)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 ModifyContactRequest (com.zimbra.soap.mail.message.ModifyContactRequest)1 ModifyContactSpec (com.zimbra.soap.mail.type.ModifyContactSpec)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1