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) {
}
}
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;
}
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));
}
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());
}
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);
}
}
Aggregations