use of com.zimbra.soap.admin.message.RenameCalendarResourceRequest in project zm-mailbox by Zimbra.
the class RenameCalendarResource method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
RenameCalendarResourceRequest req = zsc.elementToJaxb(request);
String id = req.getId();
String newName = req.getNewName();
CalendarResource resource = prov.get(CalendarResourceBy.id, id);
defendAgainstCalResourceHarvesting(resource, CalendarResourceBy.id, id, zsc, Admin.R_renameCalendarResource);
String oldName = resource.getName();
// check if the admin can rename the calendar resource
checkAccountRight(zsc, resource, Admin.R_renameCalendarResource);
// check if the admin can "create calendar resource" in the domain (can be same or diff)
checkDomainRightByEmail(zsc, newName, Admin.R_createCalendarResource);
prov.renameCalendarResource(id, newName);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RenameCalendarResource", "name", oldName, "newName", newName }));
// get again with new name...
resource = prov.get(CalendarResourceBy.id, id);
if (resource == null) {
throw ServiceException.FAILURE("unable to get calendar resource after rename: " + id, null);
}
Element response = zsc.createElement(AdminConstants.RENAME_CALENDAR_RESOURCE_RESPONSE);
ToXML.encodeCalendarResource(response, resource, true);
return response;
}
use of com.zimbra.soap.admin.message.RenameCalendarResourceRequest in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testGetCalendarResourceInDomAdminDomain.
@Test
public void testGetCalendarResourceInDomAdminDomain() throws Exception {
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
List<Attr> attrs = Lists.newArrayList();
attrs.add(new Attr(Provisioning.A_displayName, "testGetCalendarResourceInDomAdminDomain Room 101"));
attrs.add(new Attr(Provisioning.A_description, "Room 101 for 50 seats"));
attrs.add(new Attr(Provisioning.A_zimbraCalResType, "Location"));
attrs.add(new Attr(Provisioning.A_zimbraCalResAutoAcceptDecline, "TRUE"));
attrs.add(new Attr(Provisioning.A_zimbraCalResAutoDeclineIfBusy, "TRUE"));
CreateCalendarResourceResponse caResp;
caResp = domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(TARGET_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
assertNotNull("CreateCalendarResourceResponse for " + TARGET_CALRES + " simple as domAdmin", caResp);
String acctId = caResp.getCalResource().getId();
GetCalendarResourceResponse getAcctResp = domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true));
assertNotNull("GetCalendarResourceResponse for " + TARGET_CALRES + " simple as domAdmin", getAcctResp);
getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true), acctId);
assertNotNull("GetCalendarResourceResponse for " + TARGET_CALRES + " as domAdmin specifying target acct", getAcctResp);
RenameCalendarResourceResponse renAResp;
renAResp = domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES_RENAMED));
assertNotNull("RenameCalendarResourceResponse for " + TARGET_CALRES + " simple as domAdmin", renAResp);
renAResp = domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES));
assertNotNull("RenameCalendarResourceResponse for " + TARGET_CALRES + " as domAdmin specifying target acct", renAResp);
DeleteCalendarResourceRequest delAcctReq;
DeleteCalendarResourceResponse delAcctResp;
delAcctReq = new DeleteCalendarResourceRequest(null);
try {
domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
fail("DeleteCalendarResouceRequest succeeded in spite of having no 'id' specified!!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "invalid request: missing required attribute: id");
}
delAcctReq = new DeleteCalendarResourceRequest(acctId);
delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
assertNotNull("DeleteCalendarResourceResponse for " + TARGET_CALRES + " as domAdmin specifying target acct", delAcctResp);
try {
getAcctResp = domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true));
fail("GetCalendarResourceRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "no such calendar resource: ");
}
try {
getAcctResp = domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromId(acctId), true));
fail("GetCalendarResourceRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// because by id not name
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
try {
getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true), acctId);
fail("GetCalendarResourceRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
}
use of com.zimbra.soap.admin.message.RenameCalendarResourceRequest in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testGetCalendarResourceInDiffDomain.
@Test
public void testGetCalendarResourceInDiffDomain() throws Exception {
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
List<Attr> attrs = Lists.newArrayList();
attrs.add(new Attr(Provisioning.A_displayName, "testGetCalendarResourceInDiffDomain Room 101"));
attrs.add(new Attr(Provisioning.A_description, "Room 101 for 50 seats"));
attrs.add(new Attr(Provisioning.A_zimbraCalResType, "Location"));
attrs.add(new Attr(Provisioning.A_zimbraCalResAutoAcceptDecline, "TRUE"));
attrs.add(new Attr(Provisioning.A_zimbraCalResAutoDeclineIfBusy, "TRUE"));
CreateCalendarResourceResponse caResp;
try {
caResp = domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(DIFF_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
fail("CreateCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: need right: createCalendarResource for domain");
}
caResp = adminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(DIFF_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
assertNotNull("CreateCalendarResourceResponse for " + DIFF_CALRES + " simple as domAdmin", caResp);
String acctId = caResp.getCalResource().getId();
GetCalendarResourceRequest getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName(DIFF_CALRES), true);
try {
domAdminSoapProv.invokeJaxb(getAcctReq);
fail("GetCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
try {
domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
fail("GetCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
// try non-existent
getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName(DIFF_CALRES2), true);
try {
domAdminSoapProv.invokeJaxb(getAcctReq);
fail("GetCalendarResourceRequest succeeded for non-existent account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
try {
domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES_RENAMED));
fail("RenameCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
try {
domAdminSoapProv.invokeJaxb(new DeleteCalendarResourceRequest(acctId));
fail("DeleteCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
}
Aggregations