Search in sources :

Example 1 with GetCalendarResourceResponse

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

the class SoapProvisioning method get.

@Override
public CalendarResource get(CalendarResourceBy keyType, String key) throws ServiceException {
    try {
        GetCalendarResourceRequest req = new GetCalendarResourceRequest(new CalendarResourceSelector(SoapProvisioning.toJaxb(keyType), key));
        GetCalendarResourceResponse resp = invokeJaxb(req);
        return new SoapCalendarResource(resp.getCalResource(), this);
    } catch (ServiceException e) {
        if (e.getCode().equals(AccountServiceException.NO_SUCH_CALENDAR_RESOURCE))
            return null;
        else
            throw e;
    }
}
Also used : GetCalendarResourceResponse(com.zimbra.soap.admin.message.GetCalendarResourceResponse) GetCalendarResourceRequest(com.zimbra.soap.admin.message.GetCalendarResourceRequest) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) CalendarResourceSelector(com.zimbra.soap.admin.type.CalendarResourceSelector)

Example 2 with GetCalendarResourceResponse

use of com.zimbra.soap.admin.message.GetCalendarResourceResponse 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 ");
    }
}
Also used : GetCalendarResourceRequest(com.zimbra.soap.admin.message.GetCalendarResourceRequest) RenameCalendarResourceResponse(com.zimbra.soap.admin.message.RenameCalendarResourceResponse) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException) DeleteCalendarResourceRequest(com.zimbra.soap.admin.message.DeleteCalendarResourceRequest) GetCalendarResourceResponse(com.zimbra.soap.admin.message.GetCalendarResourceResponse) DeleteCalendarResourceResponse(com.zimbra.soap.admin.message.DeleteCalendarResourceResponse) RenameCalendarResourceRequest(com.zimbra.soap.admin.message.RenameCalendarResourceRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) CreateCalendarResourceResponse(com.zimbra.soap.admin.message.CreateCalendarResourceResponse) CreateCalendarResourceRequest(com.zimbra.soap.admin.message.CreateCalendarResourceRequest) Test(org.junit.Test)

Aggregations

GetCalendarResourceRequest (com.zimbra.soap.admin.message.GetCalendarResourceRequest)2 GetCalendarResourceResponse (com.zimbra.soap.admin.message.GetCalendarResourceResponse)2 ServiceException (com.zimbra.common.service.ServiceException)1 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 AccountServiceException (com.zimbra.cs.account.AccountServiceException)1 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)1 CreateCalendarResourceRequest (com.zimbra.soap.admin.message.CreateCalendarResourceRequest)1 CreateCalendarResourceResponse (com.zimbra.soap.admin.message.CreateCalendarResourceResponse)1 DeleteCalendarResourceRequest (com.zimbra.soap.admin.message.DeleteCalendarResourceRequest)1 DeleteCalendarResourceResponse (com.zimbra.soap.admin.message.DeleteCalendarResourceResponse)1 RenameCalendarResourceRequest (com.zimbra.soap.admin.message.RenameCalendarResourceRequest)1 RenameCalendarResourceResponse (com.zimbra.soap.admin.message.RenameCalendarResourceResponse)1 Attr (com.zimbra.soap.admin.type.Attr)1 CalendarResourceSelector (com.zimbra.soap.admin.type.CalendarResourceSelector)1 Test (org.junit.Test)1