Search in sources :

Example 21 with SoapProvisioning

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

the class AttributeMigration method clearConfigCacheOnAllServers.

public static void clearConfigCacheOnAllServers(boolean includeLocal) {
    ExecutorService executor = newCachedThreadPool(newDaemonThreadFactory("ClearEphemeralConfigCache"));
    List<Server> servers = null;
    try {
        servers = Provisioning.getInstance().getAllMailClientServers();
    } catch (ServiceException e) {
        ZimbraLog.account.warn("cannot fetch list of servers");
        return;
    }
    for (Server server : servers) {
        try {
            if (server.isLocalServer() && !includeLocal) {
                // don't need to flush cache on this server
                continue;
            }
        } catch (ServiceException e2) {
            ZimbraLog.ephemeral.warn("error determining if server %s is local server", server.getServiceHostname());
        }
        executor.submit(new Runnable() {

            @Override
            public void run() {
                SoapProvisioning soapProv = new SoapProvisioning();
                try {
                    String adminUrl = URLUtil.getAdminURL(server, AdminConstants.ADMIN_SERVICE_URI, true);
                    soapProv.soapSetURI(adminUrl);
                } catch (ServiceException e1) {
                    ZimbraLog.ephemeral.warn("could not get admin URL for server %s during ephemeral backend change", e1);
                    return;
                }
                try {
                    soapProv.soapZimbraAdminAuthenticate();
                    soapProv.flushCache(CacheEntryType.config, null);
                    ZimbraLog.ephemeral.debug("sent FlushCache request to server %s", server.getServiceHostname());
                } catch (ServiceException e) {
                    ZimbraLog.ephemeral.warn("cannot send FlushCache request to server %s", server.getServiceHostname(), e);
                }
            }
        });
    }
    executor.shutdown();
    try {
        executor.awaitTermination(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
    }
}
Also used : Server(com.zimbra.cs.account.Server) ServiceException(com.zimbra.common.service.ServiceException) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) ExecutorService(java.util.concurrent.ExecutorService)

Example 22 with SoapProvisioning

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

the class TestProvisioningUtil method getSoapProvisioning.

public static SoapProvisioning getSoapProvisioning() throws ServiceException {
    SoapProvisioning sp = new SoapProvisioning();
    // use infinite timeout
    sp.soapSetTransportTimeout(0);
    sp.soapSetURI("https://localhost:7071" + AdminConstants.ADMIN_SERVICE_URI);
    sp.soapZimbraAdminAuthenticate();
    return sp;
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

Example 23 with SoapProvisioning

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

the class TestPurge method testSystemRetentionPolicy.

@Test
public void testSystemRetentionPolicy() throws Exception {
    SoapProvisioning prov = TestUtil.newSoapProvisioning();
    // Test getting empty system policy.
    GetSystemRetentionPolicyRequest getReq = new GetSystemRetentionPolicyRequest();
    GetSystemRetentionPolicyResponse getRes = prov.invokeJaxb(getReq);
    RetentionPolicy rp = getRes.getRetentionPolicy();
    Assert.assertEquals(0, rp.getKeepPolicy().size());
    Assert.assertEquals(0, rp.getPurgePolicy().size());
    // Create keep policy.
    Policy keep = Policy.newSystemPolicy("keep", "60d");
    CreateSystemRetentionPolicyRequest createReq = CreateSystemRetentionPolicyRequest.newKeepRequest(keep);
    CreateSystemRetentionPolicyResponse createRes = prov.invokeJaxb(createReq);
    Policy p = createRes.getPolicy();
    Assert.assertNotNull(p.getId());
    Assert.assertEquals(keep.getName(), p.getName());
    Assert.assertEquals(keep.getLifetime(), p.getLifetime());
    keep = p;
    // Create purge policy.
    Policy purge1 = Policy.newSystemPolicy("purge1", "120d");
    createReq = CreateSystemRetentionPolicyRequest.newPurgeRequest(purge1);
    createRes = prov.invokeJaxb(createReq);
    purge1 = createRes.getPolicy();
    Policy purge2 = Policy.newSystemPolicy("purge2", "240d");
    createReq = CreateSystemRetentionPolicyRequest.newPurgeRequest(purge2);
    createRes = prov.invokeJaxb(createReq);
    purge2 = createRes.getPolicy();
    // Test getting updated system policy.
    getRes = prov.invokeJaxb(getReq);
    rp = getRes.getRetentionPolicy();
    Assert.assertEquals(1, rp.getKeepPolicy().size());
    Assert.assertEquals(keep, rp.getKeepPolicy().get(0));
    Assert.assertEquals(2, rp.getPurgePolicy().size());
    Assert.assertEquals(purge1, rp.getPolicyById(purge1.getId()));
    Assert.assertEquals(purge2, rp.getPolicyById(purge2.getId()));
    // Get system policy with the mail API.
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    com.zimbra.soap.mail.message.GetSystemRetentionPolicyResponse mailRes = mbox.invokeJaxb(new com.zimbra.soap.mail.message.GetSystemRetentionPolicyRequest());
    Assert.assertEquals(rp, mailRes.getRetentionPolicy());
    // Modify lifetime.
    Policy modLifetime = Policy.newSystemPolicy(purge1.getId(), null, "121d");
    ModifySystemRetentionPolicyRequest modifyReq = new ModifySystemRetentionPolicyRequest(modLifetime);
    ModifySystemRetentionPolicyResponse modifyRes = prov.invokeJaxb(modifyReq);
    Policy newPurge1 = modifyRes.getPolicy();
    Assert.assertEquals(Policy.newSystemPolicy(purge1.getId(), "purge1", "121d"), newPurge1);
    getRes = prov.invokeJaxb(getReq);
    Assert.assertEquals(newPurge1, getRes.getRetentionPolicy().getPolicyById(newPurge1.getId()));
    // Modify name.
    Policy modName = Policy.newSystemPolicy(purge1.getId(), "purge1-new", null);
    modifyReq = new ModifySystemRetentionPolicyRequest(modName);
    modifyRes = prov.invokeJaxb(modifyReq);
    newPurge1 = modifyRes.getPolicy();
    Assert.assertEquals(Policy.newSystemPolicy(purge1.getId(), "purge1-new", "121d"), newPurge1);
    // Delete.
    DeleteSystemRetentionPolicyRequest deleteReq = new DeleteSystemRetentionPolicyRequest(purge1);
    @SuppressWarnings("unused") DeleteSystemRetentionPolicyResponse deleteRes = prov.invokeJaxb(deleteReq);
    getRes = prov.invokeJaxb(getReq);
    rp = getRes.getRetentionPolicy();
    Assert.assertEquals(1, rp.getKeepPolicy().size());
    Assert.assertEquals(keep, rp.getKeepPolicy().get(0));
    Assert.assertEquals(1, rp.getPurgePolicy().size());
    Assert.assertEquals(purge2, rp.getPurgePolicy().get(0));
}
Also used : Policy(com.zimbra.soap.mail.type.Policy) RetentionPolicy(com.zimbra.soap.mail.type.RetentionPolicy) DeleteSystemRetentionPolicyResponse(com.zimbra.soap.admin.message.DeleteSystemRetentionPolicyResponse) DeleteSystemRetentionPolicyRequest(com.zimbra.soap.admin.message.DeleteSystemRetentionPolicyRequest) CreateSystemRetentionPolicyResponse(com.zimbra.soap.admin.message.CreateSystemRetentionPolicyResponse) GetSystemRetentionPolicyResponse(com.zimbra.soap.admin.message.GetSystemRetentionPolicyResponse) RetentionPolicy(com.zimbra.soap.mail.type.RetentionPolicy) ModifySystemRetentionPolicyRequest(com.zimbra.soap.admin.message.ModifySystemRetentionPolicyRequest) ZMailbox(com.zimbra.client.ZMailbox) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) CreateSystemRetentionPolicyRequest(com.zimbra.soap.admin.message.CreateSystemRetentionPolicyRequest) GetSystemRetentionPolicyRequest(com.zimbra.soap.admin.message.GetSystemRetentionPolicyRequest) ModifySystemRetentionPolicyResponse(com.zimbra.soap.admin.message.ModifySystemRetentionPolicyResponse) Test(org.junit.Test)

Example 24 with SoapProvisioning

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

the class TestReIndex method statusIdle.

@Test
public void statusIdle() throws Exception {
    Account account = TestUtil.getAccount("user1");
    SoapProvisioning prov = TestProvisioningUtil.getSoapProvisioning();
    ReIndexInfo info = prov.reIndex(account, "status", null, null);
    Assert.assertEquals("idle", info.getStatus());
}
Also used : Account(com.zimbra.cs.account.Account) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) ReIndexInfo(com.zimbra.cs.account.soap.SoapProvisioning.ReIndexInfo) Test(org.junit.Test)

Example 25 with SoapProvisioning

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

the class TestProvDomainStatus method setUp.

@Before
public void setUp() throws Exception {
    TEST_ID = TestProvisioningUtil.genTestId();
    System.out.println("\nTest " + TEST_ID + " setting up...\n");
    mSoapProv = new SoapProvisioning();
    mSoapProv.soapSetURI(TestUtil.getSoapUrl());
    mSoapProvAdmin = new SoapProvisioning();
    mSoapProvAdmin.soapSetURI(TestUtil.getAdminSoapUrl());
    // mSoapProvAdmin.soapSetURI("https://phoebe.local:7071/service/admin/soap/");
    // mSoapProvAdmin.soapSetURI("https://localhost:7071/service/admin/soap/");
    mSoapProvAdmin.soapZimbraAdminAuthenticate();
    mProv = mSoapProvAdmin;
    DOMAIN_NAME = TestProvisioningUtil.baseDomainName(TEST_CLASS_NAME, TEST_ID);
    createDomain(DOMAIN_NAME);
    mAccts = new Account[AccountStatus.values().length];
    for (AccountStatus as : AccountStatus.values()) {
        Account acct = createAccount(ACCOUNT_NAME(as), AccountType.ACCT_USER);
        mAccts[as.ordinal()] = acct;
        mProv.modifyAccountStatus(acct, as.name());
        if (as == AccountStatus.lockout)
            lockoutAccount(acct, true);
    }
}
Also used : Account(com.zimbra.cs.account.Account) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) Before(org.junit.Before)

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