Search in sources :

Example 1 with DLInfo

use of com.zimbra.soap.admin.type.DLInfo in project zm-mailbox by Zimbra.

the class SoapProvisioning method getGroups.

@Override
public List<Group> getGroups(Account acct, boolean directOnly, Map<String, String> via) throws ServiceException {
    ArrayList<Group> result = new ArrayList<Group>();
    GetAccountMembershipResponse resp = invokeJaxb(new GetAccountMembershipRequest(getSelector(acct)));
    for (DLInfo dlInfo : resp.getDlList()) {
        String viaList = dlInfo.getVia();
        if (directOnly && viaList != null) {
            continue;
        }
        Group group = makeGroup(dlInfo);
        if (via != null && viaList != null) {
            via.put(group.getName(), viaList);
        }
        result.add(group);
    }
    return result;
}
Also used : Group(com.zimbra.cs.account.Group) ArrayList(java.util.ArrayList) DLInfo(com.zimbra.soap.admin.type.DLInfo)

Example 2 with DLInfo

use of com.zimbra.soap.admin.type.DLInfo in project zm-mailbox by Zimbra.

the class TestDLMembership method testAddMemberByName.

@Test
public void testAddMemberByName() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        //add a member by account name
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(testUser.getName())));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //verify that account is a member of the DL
        ArrayList<DistributionList> result = new ArrayList<DistributionList>();
        GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        List<DLInfo> dlInfoList = resp.getDlList();
        assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
        assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) GetAccountMembershipResponse(com.zimbra.soap.admin.message.GetAccountMembershipResponse) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) GetAccountMembershipRequest(com.zimbra.soap.admin.message.GetAccountMembershipRequest) ArrayList(java.util.ArrayList) DLInfo(com.zimbra.soap.admin.type.DLInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 3 with DLInfo

use of com.zimbra.soap.admin.type.DLInfo in project zm-mailbox by Zimbra.

the class TestDLMembership method testRemoveMemberByAlias.

@Test
public void testRemoveMemberByAlias() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        //add an alias to the account
        AddAccountAliasResponse addAliasResp = SoapTest.invokeJaxb(transport, new AddAccountAliasRequest(testUser.getId(), TestUtil.getAddress(TEST_ALIAS)));
        assertNotNull("AddAccountAliasResponse cannot be null", addAliasResp);
        Account acct = Provisioning.getInstance().getAccount(testUser.getId());
        assertNotNull(acct);
        assertNotNull("account's aliases are null", acct.getAliases());
        assertEquals("account has no aliases", acct.getAliases().length, 1);
        //add account to DL by alias
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(TestUtil.getAddress(TEST_ALIAS))));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //verify that account is a member of the DL
        ArrayList<DistributionList> result = new ArrayList<DistributionList>();
        GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        List<DLInfo> dlInfoList = resp.getDlList();
        assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
        assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
        //remove the account's alias from the DL
        RemoveDistributionListMemberResponse rdlmresp = SoapTest.invokeJaxb(transport, new RemoveDistributionListMemberRequest(testDL.getId(), Arrays.asList(new String[] { TestUtil.getAddress(TEST_ALIAS) })));
        assertNotNull("RemoveDistributionListMemberRequest cannot be null", rdlmresp);
        //verify that account is NOT a member of the DL anymore
        result = new ArrayList<DistributionList>();
        resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        dlInfoList = resp.getDlList();
        assertTrue("Account should not be a member of any DLs", dlInfoList.size() == 0);
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : Account(com.zimbra.cs.account.Account) GetAccountMembershipResponse(com.zimbra.soap.admin.message.GetAccountMembershipResponse) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) ArrayList(java.util.ArrayList) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) DLInfo(com.zimbra.soap.admin.type.DLInfo) RemoveDistributionListMemberRequest(com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) GetAccountMembershipRequest(com.zimbra.soap.admin.message.GetAccountMembershipRequest) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 4 with DLInfo

use of com.zimbra.soap.admin.type.DLInfo in project zm-mailbox by Zimbra.

the class TestDLMembership method testRemoveMemberByName.

@Test
public void testRemoveMemberByName() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        //add an alias to the account
        AddAccountAliasResponse addAliasResp = SoapTest.invokeJaxb(transport, new AddAccountAliasRequest(testUser.getId(), TestUtil.getAddress(TEST_ALIAS)));
        assertNotNull("AddAccountAliasResponse cannot be null", addAliasResp);
        Account acct = Provisioning.getInstance().getAccount(testUser.getId());
        assertNotNull(acct);
        assertNotNull("account's aliases are null", acct.getAliases());
        assertEquals("account has no aliases", acct.getAliases().length, 1);
        //add account to DL by alias
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(TestUtil.getAddress(TEST_ALIAS))));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //verify that account is a member of the DL
        ArrayList<DistributionList> result = new ArrayList<DistributionList>();
        GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        List<DLInfo> dlInfoList = resp.getDlList();
        assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
        assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
        //remove the account's alias from the DL
        RemoveDistributionListMemberResponse rdlmresp = SoapTest.invokeJaxb(transport, new RemoveDistributionListMemberRequest(testDL.getId(), null, Arrays.asList(new String[] { TestUtil.getAddress(TEST_USER) })));
        assertNotNull("RemoveDistributionListMemberRequest cannot be null", rdlmresp);
        //verify that account is NOT a member of the DL anymore
        result = new ArrayList<DistributionList>();
        resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        dlInfoList = resp.getDlList();
        assertTrue("Account should not be a member of any DLs", dlInfoList.size() == 0);
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : Account(com.zimbra.cs.account.Account) GetAccountMembershipResponse(com.zimbra.soap.admin.message.GetAccountMembershipResponse) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) ArrayList(java.util.ArrayList) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) DLInfo(com.zimbra.soap.admin.type.DLInfo) RemoveDistributionListMemberRequest(com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) GetAccountMembershipRequest(com.zimbra.soap.admin.message.GetAccountMembershipRequest) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 5 with DLInfo

use of com.zimbra.soap.admin.type.DLInfo in project zm-mailbox by Zimbra.

the class SoapProvisioning method getDistributionLists.

@Override
public List<DistributionList> getDistributionLists(Account acct, boolean directOnly, Map<String, String> via) throws ServiceException {
    ArrayList<DistributionList> result = new ArrayList<DistributionList>();
    GetAccountMembershipResponse resp = invokeJaxb(new GetAccountMembershipRequest(getSelector(acct)));
    for (DLInfo dlInfo : resp.getDlList()) {
        String viaList = dlInfo.getVia();
        if (directOnly && viaList != null)
            continue;
        DistributionList dl = new SoapDistributionList(dlInfo, this);
        if (via != null && viaList != null)
            via.put(dl.getName(), viaList);
        result.add(dl);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) DLInfo(com.zimbra.soap.admin.type.DLInfo) DistributionList(com.zimbra.cs.account.DistributionList)

Aggregations

DLInfo (com.zimbra.soap.admin.type.DLInfo)6 ArrayList (java.util.ArrayList)5 SoapTransport (com.zimbra.common.soap.SoapTransport)4 DistributionList (com.zimbra.cs.account.DistributionList)4 SoapTest (com.zimbra.qa.unittest.prov.soap.SoapTest)4 AddDistributionListMemberRequest (com.zimbra.soap.admin.message.AddDistributionListMemberRequest)4 AddDistributionListMemberResponse (com.zimbra.soap.admin.message.AddDistributionListMemberResponse)4 GetAccountMembershipRequest (com.zimbra.soap.admin.message.GetAccountMembershipRequest)4 GetAccountMembershipResponse (com.zimbra.soap.admin.message.GetAccountMembershipResponse)4 Test (org.junit.Test)4 Account (com.zimbra.cs.account.Account)3 AddAccountAliasRequest (com.zimbra.soap.admin.message.AddAccountAliasRequest)3 AddAccountAliasResponse (com.zimbra.soap.admin.message.AddAccountAliasResponse)3 RemoveDistributionListMemberRequest (com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest)2 RemoveDistributionListMemberResponse (com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse)2 Group (com.zimbra.cs.account.Group)1