use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class ModifyCos method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
String id = request.getElement(AdminConstants.E_ID).getText();
Map<String, Object> attrs = AdminService.getAttrs(request);
Cos cos = prov.get(Key.CosBy.id, id);
if (cos == null)
throw AccountServiceException.NO_SUCH_COS(id);
checkRight(zsc, context, cos, attrs);
// pass in true to checkImmutable
prov.modifyAttrs(cos, attrs, true);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyCos", "name", cos.getName() }, attrs));
Element response = zsc.createElement(AdminConstants.MODIFY_COS_RESPONSE);
GetCos.encodeCos(response, cos);
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class ModifyUCService method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
String id = request.getElement(AdminConstants.E_ID).getText();
Map<String, Object> attrs = AdminService.getAttrs(request);
UCService ucService = prov.get(Key.UCServiceBy.id, id);
if (ucService == null) {
throw AccountServiceException.NO_SUCH_UC_SERVICE(id);
}
checkRight(zsc, context, ucService, attrs);
// pass in true to checkImmutable
prov.modifyAttrs(ucService, attrs, true);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyUCService", "name", ucService.getName() }, attrs));
Element response = zsc.createElement(AdminConstants.MODIFY_UC_SERVICE_RESPONSE);
GetUCService.encodeUCService(response, ucService, null, null);
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class PurgeAccountCalendarCache method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
// allow only system admin for now
checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
Provisioning prov = Provisioning.getInstance();
String id = request.getAttribute(AdminConstants.A_ID);
Account account = prov.get(AccountBy.id, id, zsc.getAuthToken());
if (account == null)
throw AccountServiceException.NO_SUCH_ACCOUNT(id);
if (!Provisioning.onLocalServer(account))
throw ServiceException.WRONG_HOST(account.getAttr(Provisioning.A_zimbraMailHost), null);
CalendarCacheManager calCache = CalendarCacheManager.getInstance();
ZimbraLog.calendar.info("Purging calendar cache for account " + account.getName());
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
if (mbox != null)
calCache.purgeMailbox(mbox);
Element response = zsc.createElement(AdminConstants.PURGE_ACCOUNT_CALENDAR_CACHE_RESPONSE);
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetSystemRetentionPolicy method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
GetSystemRetentionPolicyRequest req = JaxbUtil.elementToJaxb(request);
Provisioning prov = Provisioning.getInstance();
// assume default retention policy to be set in globalConfig (for backward compatibility)
Entry entry = prov.getConfig();
// check if cos is specified
CosSelector cosSelector = req.getCos();
if (cosSelector != null) {
entry = prov.get(Key.CosBy.fromString(cosSelector.getBy().name()), cosSelector.getKey());
if (entry == null)
throw AccountServiceException.NO_SUCH_COS(cosSelector.getKey());
}
// check right
checkGetRight(entry, zsc, context);
RetentionPolicy rp = RetentionPolicyManager.getInstance().getSystemRetentionPolicy(entry);
GetSystemRetentionPolicyResponse res = new GetSystemRetentionPolicyResponse(rp);
return JaxbUtil.jaxbToElement(res, zsc.getResponseProtocol().getFactory());
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetUCService method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Set<String> reqAttrs = getReqAttrs(request, AttributeClass.ucService);
Element eUCService = request.getElement(AdminConstants.E_UC_SERVICE);
String by = eUCService.getAttribute(AdminConstants.A_BY);
String name = eUCService.getText();
if (Strings.isNullOrEmpty(name)) {
throw ServiceException.INVALID_REQUEST("must specify a value for a uc service", null);
}
UCService ucService = prov.get(Key.UCServiceBy.fromString(by), name);
if (ucService == null) {
throw AccountServiceException.NO_SUCH_UC_SERVICE(name);
}
AdminAccessControl aac = checkRight(zsc, context, ucService, AdminRight.PR_ALWAYS_ALLOW);
// reload the uc service
prov.reload(ucService);
Element response = zsc.createElement(AdminConstants.GET_UC_SERVICE_RESPONSE);
encodeUCService(response, ucService, reqAttrs, aac.getAttrRightChecker(ucService));
return response;
}
Aggregations