Search in sources :

Example 96 with ZimbraSoapContext

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;
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Cos(com.zimbra.cs.account.Cos) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 97 with ZimbraSoapContext

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;
}
Also used : UCService(com.zimbra.cs.account.UCService) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 98 with ZimbraSoapContext

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;
}
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) CalendarCacheManager(com.zimbra.cs.mailbox.calendar.cache.CalendarCacheManager) Provisioning(com.zimbra.cs.account.Provisioning)

Example 99 with ZimbraSoapContext

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());
}
Also used : Entry(com.zimbra.cs.account.Entry) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) CosSelector(com.zimbra.soap.admin.type.CosSelector) GetSystemRetentionPolicyResponse(com.zimbra.soap.admin.message.GetSystemRetentionPolicyResponse) GetSystemRetentionPolicyRequest(com.zimbra.soap.admin.message.GetSystemRetentionPolicyRequest) RetentionPolicy(com.zimbra.soap.mail.type.RetentionPolicy) Provisioning(com.zimbra.cs.account.Provisioning)

Example 100 with ZimbraSoapContext

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;
}
Also used : UCService(com.zimbra.cs.account.UCService) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)382 Element (com.zimbra.common.soap.Element)315 Provisioning (com.zimbra.cs.account.Provisioning)162 Account (com.zimbra.cs.account.Account)158 Mailbox (com.zimbra.cs.mailbox.Mailbox)106 OperationContext (com.zimbra.cs.mailbox.OperationContext)82 ItemId (com.zimbra.cs.service.util.ItemId)58 Server (com.zimbra.cs.account.Server)47 ItemIdFormatter (com.zimbra.cs.service.util.ItemIdFormatter)44 ServiceException (com.zimbra.common.service.ServiceException)40 HashMap (java.util.HashMap)37 Domain (com.zimbra.cs.account.Domain)32 HashSet (java.util.HashSet)25 ArrayList (java.util.ArrayList)23 IOException (java.io.IOException)20 Group (com.zimbra.cs.account.Group)17 CalendarItem (com.zimbra.cs.mailbox.CalendarItem)17 Message (com.zimbra.cs.mailbox.Message)17 MimeMessage (javax.mail.internet.MimeMessage)16 Map (java.util.Map)15