use of com.zimbra.soap.admin.message.RenameDistributionListRequest in project zm-mailbox by Zimbra.
the class TestJaxbProvisioning method doRenameDynamicGroupTest.
private void doRenameDynamicGroupTest(boolean isACLGroup, String displayName, String memberURL) throws ServiceException {
List<Attr> attrs = Lists.newArrayList();
attrs.add(new Attr("zimbraIsACLGroup", isACLGroup ? "TRUE" : "FALSE"));
attrs.add(new Attr("zimbraMailStatus", "enabled"));
attrs.add(new Attr("displayName", displayName));
if (memberURL != null) {
attrs.add(new Attr("memberURL", memberURL));
}
Domain dom = ensureDomainExists(testDlDomain);
assertNotNull(String.format("Domain for %s", testDlDomain), dom);
deleteDlIfExists(testDl);
CreateDistributionListResponse cdlResp = prov.invokeJaxb(new CreateDistributionListRequest(testDl, attrs, true));
assertNotNull("CreateDistributionListResponse", cdlResp);
RenameDistributionListResponse rdlResp = prov.invokeJaxb(new RenameDistributionListRequest(cdlResp.getDl().getId(), testDlNewName));
assertNotNull("RenameDistributionListResponse", rdlResp);
}
use of com.zimbra.soap.admin.message.RenameDistributionListRequest in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testGetDistributionListInDiffDomain.
@Test
public void testGetDistributionListInDiffDomain() throws Exception {
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
CreateDistributionListResponse caResp;
caResp = adminSoapProv.invokeJaxb(new CreateDistributionListRequest(DIFF_DL));
assertNotNull("CreateDistributionListResponse for " + DIFF_DL + " as FULL ADMIN", caResp);
String dlId = caResp.getDl().getId();
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
GetDistributionListRequest getAcctReq = new GetDistributionListRequest(DistributionListSelector.fromName(DIFF_DL));
try {
domAdminSoapProv.invokeJaxb(getAcctReq);
fail("GetDistributionListRequest succeeded for DistributionList in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access distribution list");
}
// try non-existent acct
getAcctReq = new GetDistributionListRequest(DistributionListSelector.fromName(DIFF_DL2));
try {
domAdminSoapProv.invokeJaxb(getAcctReq);
fail("GetDistributionListRequest succeeded for non-existent DistributionList in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access distribution list");
}
AddDistributionListAliasResponse aaaResp;
try {
aaaResp = domAdminSoapProv.invokeJaxb(new AddDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
fail("AddDistributionListAliasRequest succeeded for DistributionList in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access distribution list");
}
aaaResp = adminSoapProv.invokeJaxb(new AddDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
assertNotNull("AddDistributionListAliasResponse for " + TARGET_DL + " as FULL ADMIN", aaaResp);
try {
domAdminSoapProv.invokeJaxb(new RemoveDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
fail("RemoveDistributionListAliasRequest succeeded for DistributionList in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access distribution list");
}
try {
domAdminSoapProv.invokeJaxb(new RenameDistributionListRequest(dlId, TARGET_DL_RENAMED));
fail("RenameDistributionListRequest succeeded for DistributionList in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access distribution list");
}
try {
domAdminSoapProv.invokeJaxb(new DeleteDistributionListRequest(dlId));
fail("DeleteDistributionListRequest succeeded for DistributionList in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access distribution list");
}
}
use of com.zimbra.soap.admin.message.RenameDistributionListRequest in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testGetDistributionListInDomAdminDomain.
@Test
public void testGetDistributionListInDomAdminDomain() throws Exception {
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
CreateDistributionListResponse caResp;
caResp = domAdminSoapProv.invokeJaxb(new CreateDistributionListRequest(TARGET_DL));
assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", caResp);
String dlId = caResp.getDl().getId();
GetDistributionListRequest getDlReq = new GetDistributionListRequest(DistributionListSelector.fromName(TARGET_DL));
GetDistributionListResponse getDlResp = domAdminSoapProv.invokeJaxb(getDlReq);
assertNotNull("GetDistributionListResponse for " + TARGET_DL + " simple as domAdmin", getDlResp);
AddDistributionListAliasResponse aaaResp;
aaaResp = domAdminSoapProv.invokeJaxb(new AddDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
assertNotNull("AddDistributionListAliasResponse for " + TARGET_DL + " simple as domAdmin", aaaResp);
RemoveDistributionListAliasResponse daaResp;
daaResp = domAdminSoapProv.invokeJaxb(new RemoveDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
assertNotNull("RemoveDistributionListAliasResponse for " + TARGET_DL + " simple as domAdmin", daaResp);
RenameDistributionListResponse renAResp;
renAResp = domAdminSoapProv.invokeJaxb(new RenameDistributionListRequest(dlId, TARGET_DL_RENAMED));
assertNotNull("RenameDistributionListResponse for " + TARGET_DL + " simple as domAdmin", renAResp);
DeleteDistributionListRequest delDLReq;
DeleteDistributionListResponse delDlResp;
delDLReq = new DeleteDistributionListRequest(null);
try {
delDlResp = domAdminSoapProv.invokeJaxb(delDLReq);
fail("DeleteDistributionListRequest succeeded in spite of having no 'id' specified!!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "invalid request: missing required attribute: id");
}
delDLReq = new DeleteDistributionListRequest(dlId);
delDlResp = domAdminSoapProv.invokeJaxb(delDLReq);
assertNotNull("DeleteDistributionListResponse for " + TARGET_DL + " as domAdmin", delDlResp);
try {
getDlResp = domAdminSoapProv.invokeJaxb(getDlReq);
fail("GetDistributionListRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "no such distribution list:");
}
try {
getDlResp = domAdminSoapProv.invokeJaxb(new GetDistributionListRequest(DistributionListSelector.fromId(dlId)));
fail("GetDistributionListRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// because by id not name
checkSoapReason(sfe, "permission denied: can not access distribution list");
}
}
use of com.zimbra.soap.admin.message.RenameDistributionListRequest in project zm-mailbox by Zimbra.
the class RenameDistributionList method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
RenameDistributionListRequest req = zsc.elementToJaxb(request);
String id = req.getId();
String newName = req.getNewName();
Group group = prov.getGroup(DistributionListBy.id, id);
defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_renameGroup, Admin.R_renameDistributionList);
// check if the admin can "create DL" in the domain (can be same or diff)
checkDomainRightByEmail(zsc, newName, Admin.R_createDistributionList);
String oldName = group.getName();
prov.renameGroup(id, newName);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RenameDistributionList", "name", oldName, "newName", newName }));
// get again with new name...
group = prov.getGroup(DistributionListBy.id, id);
if (group == null) {
throw ServiceException.FAILURE("unable to get distribution list after rename: " + id, null);
}
Element response = zsc.createElement(AdminConstants.RENAME_DISTRIBUTION_LIST_RESPONSE);
GetDistributionList.encodeDistributionList(response, group);
return response;
}
Aggregations