use of com.zimbra.soap.admin.type.CacheSelector in project zm-mailbox by Zimbra.
the class FlushCache method flushCacheOnImapDaemons.
private static void flushCacheOnImapDaemons(FlushCacheRequest req, ZimbraSoapContext zsc) throws ServiceException {
CacheSelector selector = req.getCache();
String cacheTypes = selector.getTypes();
CacheEntry[] cacheEntries = getCacheEntries(selector);
Account acct = Provisioning.getInstance().get(AccountBy.id, zsc.getAuthtokenAccountId(), zsc.getAuthToken());
flushCacheOnImapDaemons(cacheTypes, cacheEntries, acct.getName(), zsc.getAuthToken());
}
use of com.zimbra.soap.admin.type.CacheSelector in project zm-mailbox by Zimbra.
the class FlushCache method doFlushCache.
public static void doFlushCache(AdminDocumentHandler handler, Map<String, Object> context, FlushCacheRequest req) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Server localServer = Provisioning.getInstance().getLocalServer();
handler.checkRight(zsc, context, localServer, Admin.R_flushCache);
CacheSelector cacheSelector = req.getCache();
boolean allServers = cacheSelector.isAllServers();
boolean imapServers = cacheSelector.isIncludeImapServers();
String[] types = cacheSelector.getTypes().split(",");
for (String type : types) {
CacheEntryType cacheType = null;
try {
cacheType = CacheEntryType.fromString(type);
doFlush(context, cacheType, cacheSelector);
} catch (ServiceException e) {
if (cacheType == null) {
// see if it is a registered extension
CacheExtension ce = CacheExtension.getHandler(type);
if (ce != null) {
ce.flushCache();
} else {
throw e;
}
} else {
throw e;
}
}
}
if (imapServers) {
flushCacheOnImapDaemons(req, zsc);
}
if (allServers) {
flushCacheOnAllServers(zsc, req);
}
}
use of com.zimbra.soap.admin.type.CacheSelector in project zm-mailbox by Zimbra.
the class ImapHandler method doFLUSHCACHE.
private boolean doFLUSHCACHE(String tag, List<CacheEntryType> types, List<CacheEntrySelector> entries) throws IOException {
if (!checkState(tag, State.AUTHENTICATED)) {
return true;
} else if (!checkZimbraAdminAuth()) {
sendNO(tag, "must be authenticated as admin with X-ZIMBRA auth mechanism");
return true;
}
if (types.isEmpty()) {
// nothing to do here
sendOK(tag, "FLUSHCACHE completed");
return true;
}
AuthToken authToken = ((ZimbraAuthenticator) authenticator).getAuthToken();
try {
AdminAccessControl aac = AdminAccessControl.getAdminAccessControl(authToken);
Server localServer = Provisioning.getInstance().getLocalServer();
aac.checkRight(localServer, Admin.R_flushCache);
} catch (ServiceException e) {
if (e.getCode().equalsIgnoreCase(ServiceException.PERM_DENIED)) {
ZimbraLog.imap.error("insufficient rights for flushing cache on IMAP server", e);
} else {
ZimbraLog.imap.error("error while checking rights for flushing cache on IMAP server", e);
}
return canContinue(e);
}
CacheSelector cacheSelector = new CacheSelector();
cacheSelector.setEntries(entries);
for (CacheEntryType type : types) {
try {
FlushCache.doFlush(null, type, cacheSelector);
} catch (ServiceException e) {
ZimbraLog.imap.error("error flushing cache on IMAP server", e);
return canContinue(e);
}
}
sendOK(tag, "FLUSHCACHE completed");
return true;
}
use of com.zimbra.soap.admin.type.CacheSelector in project zm-mailbox by Zimbra.
the class SoapProvisioning method flushCache.
public void flushCache(String type, CacheEntry[] entries, boolean allServers, boolean imapDaemons) throws ServiceException {
CacheSelector sel = new CacheSelector(allServers, type);
if (entries != null) {
for (CacheEntry entry : entries) {
sel.addEntry(new CacheEntrySelector(SoapProvisioning.toJaxb(entry.mEntryBy), entry.mEntryIdentity));
}
}
sel.setIncludeImapServers(imapDaemons);
invokeJaxb(new FlushCacheRequest(sel));
}
use of com.zimbra.soap.admin.type.CacheSelector in project zm-mailbox by Zimbra.
the class GrantRight method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
GrantRightRequest grReq = zsc.elementToJaxb(request);
RightModifierInfo modifierInfo = grReq.getRight();
if (modifierInfo == null) {
throw ServiceException.INVALID_REQUEST("No information specified on what right to assign", null);
}
RightModifier rightModifier = getRightModifier(modifierInfo);
// right checking is done in RightCommand
EffectiveRightsTargetSelector erTargSel = grReq.getTarget();
RightCommand.grantRight(Provisioning.getInstance(), getAuthenticatedAccount(zsc), erTargSel, grReq.getGrantee(), modifierInfo.getValue(), rightModifier);
// Bug 100965 Avoid Cross server delegate admin being broken after initial creation due to stale caches
if (com.zimbra.soap.type.TargetType.domain == erTargSel.getType()) {
TargetBy by = erTargSel.getBy();
if ((TargetBy.id == by) || (TargetBy.name == by)) {
CacheSelector cacheSel = new CacheSelector(true, /* allServers */
CacheEntryType.domain.toString());
CacheEntrySelector ceSel = new CacheEntrySelector((TargetBy.id == erTargSel.getBy()) ? CacheEntryBy.id : CacheEntryBy.name, erTargSel.getValue());
cacheSel.addEntry(ceSel);
FlushCacheRequest fcReq = new FlushCacheRequest(cacheSel);
try {
FlushCache.doFlushCache(this, context, fcReq);
} catch (ServiceException se) {
ZimbraLog.acl.info("Problem flushing acl cache for domain %s/%s after granting rights", erTargSel.getBy(), erTargSel.getValue(), se);
}
}
}
Element response = zsc.createElement(AdminConstants.GRANT_RIGHT_RESPONSE);
return response;
}
Aggregations