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);
}
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);
}
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;
}
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;
}
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);
}
}
Aggregations