Search in sources :

Example 6 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class TestLdapProvSearchDirectory method getAllCalendarResourcesOnServer.

@Test
public void getAllCalendarResourcesOnServer() throws Exception {
    Account acct = createAccount(genAcctNameLocalPart("acct"));
    CalendarResource cr = createCalendarResource(genAcctNameLocalPart("cr"));
    final List<NamedEntry> crs = Lists.newArrayList();
    NamedEntry.Visitor visitor = new NamedEntry.Visitor() {

        @Override
        public void visit(NamedEntry entry) throws ServiceException {
            crs.add(entry);
        }
    };
    Server server = prov.getLocalServer();
    prov.getAllCalendarResources(domain, server, visitor);
    Verify.verifyEquals(Lists.newArrayList(cr), crs, false);
    crs.clear();
    Server otherServer = createServer(genServerName());
    assertNotNull(otherServer);
    prov.getAllCalendarResources(domain, otherServer, visitor);
    Verify.verifyEquals(null, crs, false);
    deleteAccount(acct);
    deleteAccount(cr);
    deleteServer(otherServer);
}
Also used : Account(com.zimbra.cs.account.Account) NamedEntry(com.zimbra.cs.account.NamedEntry) Server(com.zimbra.cs.account.Server) CalendarResource(com.zimbra.cs.account.CalendarResource) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 7 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class TestLdapProvSearchDirectory method getAllCalendarResources.

@Test
public void getAllCalendarResources() throws Exception {
    Account acct = createAccount(genAcctNameLocalPart("acct"));
    CalendarResource cr = createCalendarResource(genAcctNameLocalPart("cr"));
    List<CalendarResource> crs = prov.getAllCalendarResources(domain);
    Verify.verifyEquals(Lists.newArrayList(cr), crs, true);
    deleteAccount(acct);
    deleteAccount(cr);
}
Also used : Account(com.zimbra.cs.account.Account) CalendarResource(com.zimbra.cs.account.CalendarResource) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 8 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class GetIndexStats method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Element mreq = request.getElement(AdminConstants.E_MAILBOX);
    String accountId = mreq.getAttribute(AdminConstants.A_ACCOUNTID);
    Provisioning prov = Provisioning.getInstance();
    Account account = prov.get(AccountBy.id, accountId, zsc.getAuthToken());
    if (account == null) {
        throw AccountServiceException.NO_SUCH_ACCOUNT(accountId);
    }
    if (account.isCalendarResource()) {
        // need a CalendarResource instance for RightChecker
        CalendarResource resource = prov.get(Key.CalendarResourceBy.id, account.getId());
        checkCalendarResourceRight(zsc, resource, Admin.R_reindexCalendarResourceMailbox);
    } else {
        checkAccountRight(zsc, account, Admin.R_reindexMailbox);
    }
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
    if (mbox == null) {
        throw ServiceException.FAILURE("mailbox not found for account " + accountId, null);
    }
    Element response = zsc.createElement(AdminConstants.GET_INDEX_STATS_RESPONSE);
    IndexStats stats = mbox.index.getIndexStats();
    Element statsElem = response.addElement(AdminConstants.E_STATS);
    statsElem.addAttribute(AdminConstants.A_MAX_DOCS, stats.getMaxDocs());
    statsElem.addAttribute(AdminConstants.A_DELETED_DOCS, stats.getNumDeletedDocs());
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) IndexStats(com.zimbra.cs.mailbox.MailboxIndex.IndexStats) CalendarResource(com.zimbra.cs.account.CalendarResource) Provisioning(com.zimbra.cs.account.Provisioning)

Example 9 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class ModifyCalendarResource method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    ModifyCalendarResourceRequest req = zsc.elementToJaxb(request);
    String id = req.getId();
    if (null == id) {
        throw ServiceException.INVALID_REQUEST("missing required attribute: " + AdminConstants.E_ID, null);
    }
    Map<String, Object> attrs = req.getAttrsAsOldMultimap();
    CalendarResource resource = prov.get(CalendarResourceBy.id, id);
    defendAgainstCalResourceHarvesting(resource, CalendarResourceBy.id, id, zsc, attrs);
    String newServer = ModifyAccount.getStringAttrNewValue(Provisioning.A_zimbraMailHost, attrs);
    if (newServer != null) {
        defendAgainstServerNameHarvesting(Provisioning.getInstance().getServerByName(newServer), Key.ServerBy.name, newServer, zsc, Admin.R_listServer);
    }
    // pass in true to checkImmutable
    prov.modifyAttrs(resource, attrs, true);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyCalendarResource", "name", resource.getName() }, attrs));
    Element response = zsc.createElement(AdminConstants.MODIFY_CALENDAR_RESOURCE_RESPONSE);
    ToXML.encodeCalendarResource(response, resource, true);
    return response;
}
Also used : ModifyCalendarResourceRequest(com.zimbra.soap.admin.message.ModifyCalendarResourceRequest) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) CalendarResource(com.zimbra.cs.account.CalendarResource) Provisioning(com.zimbra.cs.account.Provisioning)

Example 10 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class TestJaxbProvisioning method deleteCalendarResourceIfExists.

public static void deleteCalendarResourceIfExists(String name) {
    try {
        ZimbraLog.test.debug("Deleting CalendarResource %s", name);
        Provisioning prov = TestUtil.newSoapProvisioning();
        CalendarResource res = prov.get(Key.CalendarResourceBy.name, name);
        if (res != null) {
            prov.deleteCalendarResource(res.getId());
        }
    } catch (Exception ex) {
        ZimbraLog.test.error("Problem deleting Calendar Resource %s", name, ex);
    }
}
Also used : CalendarResource(com.zimbra.cs.account.CalendarResource) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) ServiceException(com.zimbra.common.service.ServiceException)

Aggregations

CalendarResource (com.zimbra.cs.account.CalendarResource)40 Account (com.zimbra.cs.account.Account)23 Element (com.zimbra.common.soap.Element)12 Provisioning (com.zimbra.cs.account.Provisioning)11 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)11 Test (org.junit.Test)8 ProvTest (com.zimbra.qa.unittest.prov.ProvTest)7 NamedEntry (com.zimbra.cs.account.NamedEntry)6 ArrayList (java.util.ArrayList)6 ServiceException (com.zimbra.common.service.ServiceException)5 Server (com.zimbra.cs.account.Server)4 Mailbox (com.zimbra.cs.mailbox.Mailbox)4 Invite (com.zimbra.cs.mailbox.calendar.Invite)4 RecurId (com.zimbra.cs.mailbox.calendar.RecurId)4 ZAttendee (com.zimbra.cs.mailbox.calendar.ZAttendee)4 HashMap (java.util.HashMap)4 ICalTimeZone (com.zimbra.common.calendar.ICalTimeZone)3 ParsedDateTime (com.zimbra.common.calendar.ParsedDateTime)3 JavaMailInternetAddress (com.zimbra.common.mime.shim.JavaMailInternetAddress)3 SoapTransport (com.zimbra.common.soap.SoapTransport)3