Search in sources :

Example 6 with AddDistributionListMemberResponse

use of com.zimbra.soap.admin.message.AddDistributionListMemberResponse in project zm-mailbox by Zimbra.

the class AddDistributionListMember method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    OperationContext octxt = getOperationContext(zsc, context);
    Provisioning prov = Provisioning.getInstance();
    Group group = getGroupFromContext(context);
    String id = request.getAttribute(AdminConstants.E_ID);
    defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_addGroupMember, Admin.R_addDistributionListMember);
    List<String> memberList = getMemberList(request, context);
    if (memberList.isEmpty()) {
        throw ServiceException.INVALID_REQUEST("members to add not specified", null);
    }
    String[] members = memberList.toArray(new String[0]);
    prov.addGroupMembers(group, members);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "AddDistributionListMember", "name", group.getName(), "members", Arrays.deepToString(members) }));
    // send share notification email
    if (group.isDynamic()) {
    // do nothing for now
    } else {
        boolean sendShareInfoMsg = group.getBooleanAttr(Provisioning.A_zimbraDistributionListSendShareMessageToNewMembers, true);
        if (sendShareInfoMsg) {
            ShareInfo.NotificationSender.sendShareInfoMessage(octxt, (DistributionList) group, members);
        }
    }
    return zsc.jaxbToElement(new AddDistributionListMemberResponse());
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Group(com.zimbra.cs.account.Group) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Provisioning(com.zimbra.cs.account.Provisioning)

Example 7 with AddDistributionListMemberResponse

use of com.zimbra.soap.admin.message.AddDistributionListMemberResponse in project zm-mailbox by Zimbra.

the class TestDLMembership method testGetDistributionListMembers.

@Test
public void testGetDistributionListMembers() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(testUser.getName())));
        AddDistributionListMemberResponse addDLMemberResp2 = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL2.getId(), Collections.singleton(testUser2.getName())));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //Verify GetDistributionListMembersRequest returns correct members.
        SoapTransport transportAccount = TestUtil.authUser(testUser.getName(), TestUtil.DEFAULT_PASSWORD);
        GetDistributionListMembersResponse resp = SoapTest.invokeJaxb(transportAccount, new GetDistributionListMembersRequest(0, 0, testDL2.getName()));
        List<String> dlInfoList = resp.getDlMembers();
        assertFalse("Unexepcted member present", dlInfoList.contains(testUser.getName()));
        assertTrue("DL member not present", dlInfoList.contains(testUser2.getName()));
        resp = SoapTest.invokeJaxb(transportAccount, new GetDistributionListMembersRequest(0, 0, testDL.getName()));
        dlInfoList = resp.getDlMembers();
        assertFalse("Unexepcted member present", dlInfoList.contains(testUser2.getName()));
        assertTrue("DL member not present", dlInfoList.contains(testUser.getName()));
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) GetDistributionListMembersResponse(com.zimbra.soap.account.message.GetDistributionListMembersResponse) GetDistributionListMembersRequest(com.zimbra.soap.account.message.GetDistributionListMembersRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 8 with AddDistributionListMemberResponse

use of com.zimbra.soap.admin.message.AddDistributionListMemberResponse in project zm-mailbox by Zimbra.

the class TestDLMembership method testAddMemberByAlias.

@Test
public void testAddMemberByAlias() {
    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 a member 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
        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 : Account(com.zimbra.cs.account.Account) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) GetAccountMembershipResponse(com.zimbra.soap.admin.message.GetAccountMembershipResponse) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) GetAccountMembershipRequest(com.zimbra.soap.admin.message.GetAccountMembershipRequest) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) DLInfo(com.zimbra.soap.admin.type.DLInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Aggregations

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