Search in sources :

Example 1 with ContactInfo

use of com.zimbra.soap.account.type.ContactInfo in project zm-mailbox by Zimbra.

the class TestSearchGalGroups method testSearchGroup.

/*
     * Verify isOwner and isMember flags are returned correctly.
     */
private void testSearchGroup(Account acct, Group group, Boolean needIsOwner, MemberOfSelector needIsMember, boolean actualIsOwner, boolean actualIsMember) throws Exception {
    SoapTransport transport = authUser(acct.getName());
    SearchGalRequest req = new SearchGalRequest();
    req.setName(group.getName());
    req.setNeedIsOwner(needIsOwner);
    req.setNeedIsMember(needIsMember);
    SearchGalResponse resp = invokeJaxb(transport, req);
    List<String> result = Lists.newArrayList();
    List<String> expected = Lists.newArrayList(Verify.makeResultStr(group.getName(), ContactConstants.TYPE_GROUP, needIsOwner == null ? null : actualIsOwner, needIsMember == null ? null : actualIsMember, ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name()));
    List<ContactInfo> entries = resp.getContacts();
    for (ContactInfo entry : entries) {
        List<ContactAttr> attrs = entry.getAttrs();
        String email = null;
        String type = null;
        String subsPolicy = null;
        for (ContactAttr attr : attrs) {
            String key = attr.getKey();
            if (ContactConstants.A_email.equals(key)) {
                email = attr.getValue();
            } else if (ContactConstants.A_type.equals(key)) {
                type = attr.getValue();
            } else if (Provisioning.A_zimbraDistributionListSubscriptionPolicy.equals(key)) {
                subsPolicy = attr.getValue();
            }
        }
        Boolean isOwner = entry.isOwner();
        Boolean isMember = entry.isMember();
        result.add(Verify.makeResultStr(email, type, isOwner, isMember, subsPolicy));
    }
    Verify.verifyEquals(expected, result);
}
Also used : ContactAttr(com.zimbra.soap.type.ContactAttr) SearchGalResponse(com.zimbra.soap.account.message.SearchGalResponse) SearchGalRequest(com.zimbra.soap.account.message.SearchGalRequest) ContactInfo(com.zimbra.soap.account.type.ContactInfo) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 2 with ContactInfo

use of com.zimbra.soap.account.type.ContactInfo in project zm-mailbox by Zimbra.

the class TestContactGroup method createAndGetContactGroup.

@Test
@Bug(bug = 70558)
public void createAndGetContactGroup() throws Exception {
    SoapTransport transport = authUser(acct.getName());
    /*
         * search gal to get ref of the member account in GAL
         */
    SearchGalRequest searchGalReq = new SearchGalRequest();
    searchGalReq.setName(memberAcct.getName());
    SearchGalResponse searchGalResp = invokeJaxb(transport, searchGalReq);
    List<ContactInfo> entries = searchGalResp.getContacts();
    assertEquals(1, entries.size());
    ContactInfo galEntry = entries.get(0);
    String galMemberRef = galEntry.getReference();
    /*
         * create a contact group
         */
    NewContactGroupMember contactGroupMemer = NewContactGroupMember.createForTypeAndValue(ContactGroup.Member.Type.GAL_REF.getSoapEncoded(), galMemberRef);
    NewContactAttr contactAttr = new NewContactAttr(ContactConstants.A_type);
    contactAttr.setValue(ContactConstants.TYPE_GROUP);
    ContactSpec contactSpec = new ContactSpec();
    contactSpec.addAttr(contactAttr);
    contactSpec.addContactGroupMember(contactGroupMemer);
    CreateContactRequest createContactReq = new CreateContactRequest(contactSpec);
    CreateContactResponse createContactResp = invokeJaxb(transport, createContactReq);
    String contactGroupId = createContactResp.getContact().getId();
    /*
         * get the contact group, derefed
         */
    GetContactsRequest getContactsReq = new GetContactsRequest();
    getContactsReq.addContact(new Id(contactGroupId));
    getContactsReq.setDerefGroupMember(Boolean.TRUE);
    GetContactsResponse getContactsResp = invokeJaxb(transport, getContactsReq, SoapProtocol.SoapJS);
    List<com.zimbra.soap.mail.type.ContactInfo> contacts = getContactsResp.getContacts();
    assertEquals(1, contacts.size());
    com.zimbra.soap.mail.type.ContactInfo contact = contacts.get(0);
    List<ContactGroupMember> members = contact.getContactGroupMembers();
    assertEquals(1, members.size());
    ContactGroupMember member = members.get(0);
    String memberType = member.getType();
    String memberValue = member.getValue();
    assertEquals(ContactGroup.Member.Type.GAL_REF.getSoapEncoded(), memberType);
    assertEquals(galMemberRef, memberValue);
}
Also used : ContactSpec(com.zimbra.soap.mail.type.ContactSpec) ContactGroupMember(com.zimbra.soap.mail.type.ContactGroupMember) NewContactGroupMember(com.zimbra.soap.mail.type.NewContactGroupMember) SearchGalResponse(com.zimbra.soap.account.message.SearchGalResponse) CreateContactResponse(com.zimbra.soap.mail.message.CreateContactResponse) SearchGalRequest(com.zimbra.soap.account.message.SearchGalRequest) CreateContactRequest(com.zimbra.soap.mail.message.CreateContactRequest) GetContactsResponse(com.zimbra.soap.mail.message.GetContactsResponse) GetContactsRequest(com.zimbra.soap.mail.message.GetContactsRequest) NewContactAttr(com.zimbra.soap.mail.type.NewContactAttr) ContactInfo(com.zimbra.soap.account.type.ContactInfo) NewContactGroupMember(com.zimbra.soap.mail.type.NewContactGroupMember) Id(com.zimbra.soap.type.Id) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Aggregations

SoapTransport (com.zimbra.common.soap.SoapTransport)2 SearchGalRequest (com.zimbra.soap.account.message.SearchGalRequest)2 SearchGalResponse (com.zimbra.soap.account.message.SearchGalResponse)2 ContactInfo (com.zimbra.soap.account.type.ContactInfo)2 Bug (com.zimbra.qa.QA.Bug)1 CreateContactRequest (com.zimbra.soap.mail.message.CreateContactRequest)1 CreateContactResponse (com.zimbra.soap.mail.message.CreateContactResponse)1 GetContactsRequest (com.zimbra.soap.mail.message.GetContactsRequest)1 GetContactsResponse (com.zimbra.soap.mail.message.GetContactsResponse)1 ContactGroupMember (com.zimbra.soap.mail.type.ContactGroupMember)1 ContactSpec (com.zimbra.soap.mail.type.ContactSpec)1 NewContactAttr (com.zimbra.soap.mail.type.NewContactAttr)1 NewContactGroupMember (com.zimbra.soap.mail.type.NewContactGroupMember)1 ContactAttr (com.zimbra.soap.type.ContactAttr)1 Id (com.zimbra.soap.type.Id)1 Test (org.junit.Test)1