Search in sources :

Example 76 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetCreateObjectAttrs method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Element eTarget = request.getElement(AdminConstants.E_TARGET);
    String targetType = eTarget.getAttribute(AdminConstants.A_TYPE);
    Key.DomainBy domainBy = null;
    String domain = null;
    Element eDomain = request.getOptionalElement(AdminConstants.E_DOMAIN);
    if (eDomain != null) {
        domainBy = Key.DomainBy.fromString(eDomain.getAttribute(AdminConstants.A_BY));
        domain = eDomain.getText();
    }
    Key.CosBy cosBy = null;
    String cos = null;
    Element eCos = request.getOptionalElement(AdminConstants.E_COS);
    if (eCos != null) {
        cosBy = Key.CosBy.fromString(eCos.getAttribute(AdminConstants.A_BY));
        cos = eCos.getText();
    }
    GranteeBy granteeBy = GranteeBy.id;
    String grantee = zsc.getRequestedAccountId();
    if (!grantee.equals(zsc.getAuthtokenAccountId())) {
        checkCheckRightRight(zsc, GranteeType.GT_USER, granteeBy, grantee);
    }
    RightCommand.EffectiveRights er = RightCommand.getCreateObjectAttrs(Provisioning.getInstance(), targetType, domainBy, domain, cosBy, cos, granteeBy, grantee);
    Element resp = zsc.createElement(AdminConstants.GET_CREATE_OBJECT_ATTRS_RESPONSE);
    er.toXML_getCreateObjectAttrs(resp);
    return resp;
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) GranteeBy(com.zimbra.soap.admin.type.GranteeSelector.GranteeBy) RightCommand(com.zimbra.cs.account.accesscontrol.RightCommand) Key(com.zimbra.common.account.Key)

Example 77 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetCurrentVolumes method handle.

private GetCurrentVolumesResponse handle(@SuppressWarnings("unused") GetCurrentVolumesRequest req, Map<String, Object> ctx) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(ctx);
    checkRight(zsc, ctx, Provisioning.getInstance().getLocalServer(), Admin.R_manageVolume);
    GetCurrentVolumesResponse resp = new GetCurrentVolumesResponse();
    VolumeManager mgr = VolumeManager.getInstance();
    Volume msgVol = mgr.getCurrentMessageVolume();
    if (msgVol != null) {
        resp.addVolume(new GetCurrentVolumesResponse.CurrentVolumeInfo(msgVol.getId(), msgVol.getType()));
    }
    Volume secondaryMsgVol = mgr.getCurrentSecondaryMessageVolume();
    if (secondaryMsgVol != null) {
        resp.addVolume(new GetCurrentVolumesResponse.CurrentVolumeInfo(secondaryMsgVol.getId(), secondaryMsgVol.getType()));
    }
    Volume indexVol = mgr.getCurrentIndexVolume();
    if (indexVol != null) {
        resp.addVolume(new GetCurrentVolumesResponse.CurrentVolumeInfo(indexVol.getId(), indexVol.getType()));
    }
    return resp;
}
Also used : VolumeManager(com.zimbra.cs.volume.VolumeManager) Volume(com.zimbra.cs.volume.Volume) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) GetCurrentVolumesResponse(com.zimbra.soap.admin.message.GetCurrentVolumesResponse)

Example 78 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class SyncGalAccount method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    ZimbraLog.addToContext(ZimbraLog.C_ANAME, getAuthenticatedAccount(zsc).getName());
    for (Element accountEl : request.listElements(AdminConstants.E_ACCOUNT)) {
        String accountId = accountEl.getAttribute(AdminConstants.A_ID);
        Account account = prov.getAccountById(accountId);
        if (account == null) {
            throw AccountServiceException.NO_SUCH_ACCOUNT(accountId);
        }
        ZimbraLog.addToContext(ZimbraLog.C_NAME, account.getName());
        for (Element dsEl : accountEl.listElements(AdminConstants.E_DATASOURCE)) {
            String by = dsEl.getAttribute(AdminConstants.A_BY);
            String name = dsEl.getText();
            DataSource ds = by.equals("id") ? account.getDataSourceById(name) : account.getDataSourceByName(name);
            if (ds == null) {
                throw AccountServiceException.NO_SUCH_DATA_SOURCE(name);
            }
            if (!ds.getType().equals(DataSourceType.gal)) {
                continue;
            }
            boolean fullSync = dsEl.getAttributeBool(AdminConstants.A_FULLSYNC, false);
            boolean reset = dsEl.getAttributeBool(AdminConstants.A_RESET, false);
            int fid = ds.getFolderId();
            DataImport dataImport = DataSourceManager.getInstance().getDataImport(ds);
            if (dataImport instanceof GalImport) {
                ((GalImport) dataImport).importGal(fid, (reset ? reset : fullSync), reset);
            }
            //flush domain gal group cache
            Domain domain = prov.getDomain(account);
            GalGroup.flushCache(domain);
        }
    }
    return zsc.createElement(AdminConstants.SYNC_GAL_ACCOUNT_RESPONSE);
}
Also used : Account(com.zimbra.cs.account.Account) GalImport(com.zimbra.cs.gal.GalImport) DataImport(com.zimbra.cs.account.DataSource.DataImport) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Domain(com.zimbra.cs.account.Domain) Provisioning(com.zimbra.cs.account.Provisioning) DataSource(com.zimbra.cs.account.DataSource)

Example 79 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class UndeployZimlet method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    String name = request.getAttribute(AdminConstants.A_NAME);
    String action = request.getAttribute(AdminConstants.A_ACTION, null);
    ZAuthToken auth = null;
    if (action == null) {
        auth = zsc.getRawAuthToken();
    }
    Element response = zsc.createElement(AdminConstants.UNDEPLOY_ZIMLET_RESPONSE);
    //undeploy on local server and LDAP anyway
    ZimletUtil.undeployZimletLocally(name);
    if (AdminConstants.A_DEPLOYALL.equals(action)) {
        //undeploy on remote servers
        for (Server server : Provisioning.getInstance().getAllServers()) {
            if (!server.isLocalServer()) {
                checkRight(zsc, context, server, Admin.R_deployZimlet);
                new Thread(new UndeployThread(server, name, auth)).start();
            }
        }
    }
    return response;
}
Also used : Server(com.zimbra.cs.account.Server) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) ZAuthToken(com.zimbra.common.auth.ZAuthToken)

Example 80 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class VerifyIndex 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);
    }
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
    if (mbox == null) {
        throw ServiceException.FAILURE("mailbox not found for account " + accountId, null);
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    boolean status = mbox.index.verify(new PrintStream(out));
    Element resp = zsc.createElement(AdminConstants.VERIFY_INDEX_RESPONSE);
    resp.addElement(AdminConstants.E_STATUS).addText(String.valueOf(status));
    try {
        resp.addElement(AdminConstants.E_MESSAGE).addText(out.toString(Charsets.UTF_8.name()));
    } catch (UnsupportedEncodingException never) {
        assert false;
    }
    return resp;
}
Also used : Account(com.zimbra.cs.account.Account) PrintStream(java.io.PrintStream) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) 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