Search in sources :

Example 16 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class TestUtil method deleteDistributionList.

/**
     * Deletes the specified DL.
     */
public static void deleteDistributionList(String listName) throws ServiceException {
    Provisioning prov = Provisioning.getInstance();
    // so that both the account and mailbox are deleted.
    if (!(prov instanceof SoapProvisioning)) {
        prov = newSoapProvisioning();
    }
    DistributionList dl = prov.get(DistributionListBy.name, getAddress(listName));
    if (dl != null) {
        prov.deleteDistributionList(dl.getId());
    }
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) DistributionList(com.zimbra.cs.account.DistributionList)

Example 17 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class TestUtil method setLCValue.

protected static void setLCValue(KnownKey key, String newValue) throws DocumentException, ConfigException, IOException, ServiceException {
    LocalConfig lc = new LocalConfig(null);
    if (newValue == null) {
        lc.remove(key.key());
    } else {
        lc.set(key.key(), newValue);
    }
    lc.save();
    SoapProvisioning prov = TestUtil.newSoapProvisioning();
    ReloadLocalConfigRequest req = new ReloadLocalConfigRequest();
    ReloadLocalConfigResponse resp = prov.invokeJaxb(req);
    assertNotNull("ReloadLocalConfigResponse", resp);
}
Also used : ReloadLocalConfigResponse(com.zimbra.soap.admin.message.ReloadLocalConfigResponse) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) LocalConfig(com.zimbra.common.localconfig.LocalConfig) ReloadLocalConfigRequest(com.zimbra.soap.admin.message.ReloadLocalConfigRequest)

Example 18 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class DistributionListDocumentHandler method flushAccountCache.

private static void flushAccountCache(Provisioning prov, String[] members) {
    // List<CacheEntry> localAccts = Lists.newArrayList();
    Map<String, List<CacheEntry>> /* server name */
    remoteAccts = Maps.newHashMap();
    for (String member : members) {
        try {
            Account acct = prov.get(AccountBy.name, member);
            if (acct != null) {
                if (prov.onLocalServer(acct)) {
                // localAccts.add(new CacheEntry(CacheEntryBy.id, acct.getId()));
                } else {
                    Server server = acct.getServer();
                    String serverName = server.getName();
                    List<CacheEntry> acctsOnServer = remoteAccts.get(serverName);
                    if (acctsOnServer == null) {
                        acctsOnServer = Lists.newArrayList();
                        remoteAccts.put(serverName, acctsOnServer);
                    }
                    acctsOnServer.add(new CacheEntry(CacheEntryBy.id, acct.getId()));
                }
            }
        // else, not internal account, skip
        } catch (ServiceException e) {
            // log and continue
            ZimbraLog.account.warn("unable to flush account cache", e);
        }
    }
    /*
         * No need to flush cache on local server, account membership for static/dynamic
         * groups are handled in LdapProvisioning
         *
        // flush accounts from cache on local server
        try {
            prov.flushCache(CacheEntryType.account, localAccts.toArray(new CacheEntry[localAccts.size()]));
        } catch (ServiceException e) {
            // log and continue
            ZimbraLog.account.warn("unable to flush account cache on local server", e);
        }
        */
    // flush accounts from cache on remote servers
    // if the remote server does not run admin server, too bad - accounts on that
    // server will have to wait till cache expire to get updated membership
    SoapProvisioning soapProv = new SoapProvisioning();
    String adminUrl = null;
    for (Map.Entry<String, List<CacheEntry>> acctsOnServer : remoteAccts.entrySet()) {
        String serverName = acctsOnServer.getKey();
        List<CacheEntry> accts = acctsOnServer.getValue();
        try {
            Server server = prov.get(ServerBy.name, serverName);
            adminUrl = URLUtil.getAdminURL(server, AdminConstants.ADMIN_SERVICE_URI, true);
            soapProv.soapSetURI(adminUrl);
            soapProv.soapZimbraAdminAuthenticate();
            soapProv.flushCache(CacheEntryType.account, accts.toArray(new CacheEntry[accts.size()]));
        } catch (ServiceException e) {
            ZimbraLog.account.warn("unable to flush account cache on remote server: " + serverName, e);
        }
    }
}
Also used : Account(com.zimbra.cs.account.Account) Server(com.zimbra.cs.account.Server) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) List(java.util.List) CacheEntry(com.zimbra.cs.account.Provisioning.CacheEntry) Map(java.util.Map)

Example 19 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class SoapProvTestUtil method getSoapProvisioning.

static SoapProvisioning getSoapProvisioning(String userName, String password) throws ServiceException {
    SoapProvisioning sp = new SoapProvisioning();
    sp.soapSetHttpTransportDebugListener(new SoapDebugListener());
    sp.soapSetURI("https://localhost:7071" + AdminConstants.ADMIN_SERVICE_URI);
    sp.soapAdminAuthenticate(userName, password);
    return sp;
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

Example 20 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class Cleanup method deleteAll.

static void deleteAll(String... domainNames) throws Exception {
    if (InMemoryLdapServer.isOn()) {
        return;
    }
    com.zimbra.qa.unittest.prov.ldap.Cleanup.deleteAll(domainNames);
    SoapProvisioning prov = SoapProvisioning.getAdminInstance();
    prov.flushCache(CacheEntryType.account.name() + "," + CacheEntryType.group.name() + "," + CacheEntryType.config.name() + "," + CacheEntryType.globalgrant.name() + "," + CacheEntryType.cos.name() + "," + CacheEntryType.domain.name() + "," + CacheEntryType.mime.name() + "," + CacheEntryType.server.name() + "," + CacheEntryType.alwaysOnCluster.name() + "," + CacheEntryType.zimlet.name(), null, true);
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

Aggregations

SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)78 Test (org.junit.Test)18 SoapFaultException (com.zimbra.common.soap.SoapFaultException)14 Account (com.zimbra.cs.account.Account)13 Attr (com.zimbra.soap.admin.type.Attr)10 ServiceException (com.zimbra.common.service.ServiceException)9 CreateDistributionListRequest (com.zimbra.soap.admin.message.CreateDistributionListRequest)6 CreateDistributionListResponse (com.zimbra.soap.admin.message.CreateDistributionListResponse)6 AccountLogger (com.zimbra.common.util.AccountLogger)5 Server (com.zimbra.cs.account.Server)5 CreateCalendarResourceRequest (com.zimbra.soap.admin.message.CreateCalendarResourceRequest)4 CreateCalendarResourceResponse (com.zimbra.soap.admin.message.CreateCalendarResourceResponse)4 DeleteCalendarResourceRequest (com.zimbra.soap.admin.message.DeleteCalendarResourceRequest)4 List (java.util.List)4 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 Provisioning (com.zimbra.cs.account.Provisioning)3 CacheEntry (com.zimbra.cs.account.Provisioning.CacheEntry)3 DeleteAccountRequest (com.zimbra.soap.admin.message.DeleteAccountRequest)3 DeleteAccountResponse (com.zimbra.soap.admin.message.DeleteAccountResponse)3