Search in sources :

Example 6 with WaitSetInfo

use of com.zimbra.soap.admin.type.WaitSetInfo in project zm-mailbox by Zimbra.

the class WaitSetBase method handleQuery.

@Override
public synchronized WaitSetInfo handleQuery() {
    WaitSetInfo info = WaitSetInfo.createForWaitSetIdOwnerInterestsLastAccessDate(mWaitSetId, mOwnerAccountId, WaitSetRequest.expandInterestStr(defaultInterest), mLastAccessedTime);
    if (mCurrentErrors.size() > 0) {
        for (WaitSetError error : mCurrentErrors) {
            info.addError(new IdAndType(error.accountId, error.error.name()));
        }
    }
    // signaled accounts
    if (mCurrentSignalledAccounts.size() > 0) {
        StringBuilder signaledStr = new StringBuilder();
        for (String accountId : mCurrentSignalledAccounts) {
            if (signaledStr.length() > 0)
                signaledStr.append(",");
            signaledStr.append(accountId);
        }
        info.setSignalledAccounts(new AccountsAttrib(signaledStr.toString()));
    }
    return info;
}
Also used : WaitSetInfo(com.zimbra.soap.admin.type.WaitSetInfo) AccountsAttrib(com.zimbra.soap.admin.type.AccountsAttrib) IdAndType(com.zimbra.soap.type.IdAndType)

Example 7 with WaitSetInfo

use of com.zimbra.soap.admin.type.WaitSetInfo in project zm-mailbox by Zimbra.

the class TestImapServerListener method testRegisterUnregister.

@Test
public void testRegisterUnregister() throws ServiceException, IOException, HttpException {
    Assume.assumeNotNull(remoteServer);
    Assume.assumeNotNull(remoteAccount);
    assertNotNull("ImapServerListener instance should not be null", remoteListener);
    RemoteImapMailboxStore imapStore = new RemoteImapMailboxStore(mboxStore);
    assertNotNull("ImapMailboxStore instance should not be null", imapStore);
    ImapCredentials creds = new ImapCredentials(remoteAccount);
    ImapPath path = new ImapPath("INBOX", creds);
    assertNotNull("ImapPath instance should not be null", path);
    byte params = 0;
    ImapHandler handler = new MockImapHandler().setCredentials(creds);
    ImapFolder i4folder = new ImapFolder(path, params, handler);
    assertNotNull("ImapFolder instance should not be null", i4folder);
    assertNotNull("ImapFolder.getCredentials() should not return null", i4folder.getCredentials());
    assertNotNull("ImapFolder.getPath() should not return null", i4folder.getPath());
    MockImapListener session = new MockImapListener(imapStore, i4folder, handler);
    assertNotNull("ImapListener instance should not be null", session);
    assertFalse("Expecting ImapServerListener::isListeningOn to return false before calling addListener", remoteListener.isListeningOn(session.getTargetAccountId(), session.getFolderId()));
    assertNull("Should not have a waitset before registering first listener", remoteListener.getWSId());
    remoteListener.addListener(session);
    assertTrue("Expecting ImapServerListener::isListeningOn to return true after calling addListener", remoteListener.isListeningOn(session.getTargetAccountId(), session.getFolderId()));
    assertNotNull("Should have a waitset after registering first listener", remoteListener.getWSId());
    QueryWaitSetRequest req = new QueryWaitSetRequest(remoteListener.getWSId());
    SoapTransport transport = TestUtil.getAdminSoapTransport(remoteServer);
    QueryWaitSetResponse resp = JaxbUtil.elementToJaxb(transport.invoke(JaxbUtil.jaxbToElement(req)));
    assertNotNull(resp);
    List<WaitSetInfo> wsInfoList = resp.getWaitsets();
    assertNotNull(wsInfoList);
    assertFalse(wsInfoList.isEmpty());
    assertEquals(1, wsInfoList.size());
    WaitSetInfo wsInfo = wsInfoList.get(0);
    assertNotNull(wsInfo);
    assertEquals(remoteListener.getWSId(), wsInfo.getWaitSetId());
    remoteListener.removeListener(session);
    assertFalse("Expecting ImapServerListener::isListeningOn to return false after calling removeListener", remoteListener.isListeningOn(session.getTargetAccountId(), session.getFolderId()));
    assertNull("Should not have a waitset after removing last listener", remoteListener.getWSId());
}
Also used : ImapFolder(com.zimbra.cs.imap.ImapFolder) QueryWaitSetResponse(com.zimbra.soap.admin.message.QueryWaitSetResponse) RemoteImapMailboxStore(com.zimbra.cs.imap.RemoteImapMailboxStore) ImapHandler(com.zimbra.cs.imap.ImapHandler) ImapCredentials(com.zimbra.cs.imap.ImapCredentials) ImapPath(com.zimbra.cs.imap.ImapPath) QueryWaitSetRequest(com.zimbra.soap.admin.message.QueryWaitSetRequest) WaitSetInfo(com.zimbra.soap.admin.type.WaitSetInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 8 with WaitSetInfo

use of com.zimbra.soap.admin.type.WaitSetInfo in project zm-mailbox by Zimbra.

the class TestWaitSetRequest method validateQueryWaitSetResponse.

private void validateQueryWaitSetResponse(QueryWaitSetResponse qwsResp, String acctId, Set<Integer> folderInterests, Set<Integer> expectedChangedFolders, boolean checkOwner) {
    assertEquals("Number of Waitsets in response", 1, qwsResp.getWaitsets().size());
    WaitSetInfo wsInfo = qwsResp.getWaitsets().get(0);
    if (checkOwner) {
        assertEquals("waitSet owner", acctId, wsInfo.getOwner());
    }
    assertEquals("Number of sessions in WaitSetResponse/waitSet", 1, wsInfo.getSessions().size());
    SessionForWaitSet session = wsInfo.getSessions().get(0);
    assertEquals("WaitSetResponse/waitSet/session@account", acctId, session.getAccount());
    WaitSetSessionInfo sessInfo = session.getWaitSetSession();
    if ((null != folderInterests) && !folderInterests.isEmpty()) {
        Set<Integer> respFolderInt = sessInfo.getFolderInterestsAsSet();
        for (Integer folderInterest : folderInterests) {
            assertTrue(String.format("Query reported folderInterests=%s should contain %s", respFolderInt, folderInterest), respFolderInt.contains(folderInterest));
        }
    }
    if ((null != expectedChangedFolders) && !expectedChangedFolders.isEmpty()) {
        Set<Integer> respChangedFolders = sessInfo.getChangedFoldersAsSet();
        for (Integer changedFldr : expectedChangedFolders) {
            assertTrue(String.format("Query reported respChangedFolders=%s should contain %s", respChangedFolders, changedFldr), respChangedFolders.contains(changedFldr));
        }
        String signalledAccts = wsInfo.getSignalledAccounts().getAccounts();
        assertTrue(String.format("ready accts '%s' contains '%s'", signalledAccts, acctId), signalledAccts.contains(acctId));
    }
}
Also used : WaitSetSessionInfo(com.zimbra.soap.admin.type.WaitSetSessionInfo) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) WaitSetInfo(com.zimbra.soap.admin.type.WaitSetInfo) SessionForWaitSet(com.zimbra.soap.admin.type.SessionForWaitSet)

Aggregations

WaitSetInfo (com.zimbra.soap.admin.type.WaitSetInfo)8 SessionForWaitSet (com.zimbra.soap.admin.type.SessionForWaitSet)4 QueryWaitSetResponse (com.zimbra.soap.admin.message.QueryWaitSetResponse)3 WaitSetSessionInfo (com.zimbra.soap.admin.type.WaitSetSessionInfo)3 SoapTransport (com.zimbra.common.soap.SoapTransport)2 ImapCredentials (com.zimbra.cs.imap.ImapCredentials)2 ImapFolder (com.zimbra.cs.imap.ImapFolder)2 ImapHandler (com.zimbra.cs.imap.ImapHandler)2 ImapPath (com.zimbra.cs.imap.ImapPath)2 RemoteImapMailboxStore (com.zimbra.cs.imap.RemoteImapMailboxStore)2 QueryWaitSetRequest (com.zimbra.soap.admin.message.QueryWaitSetRequest)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Test (org.junit.Test)2 ZMountpoint (com.zimbra.client.ZMountpoint)1 ServiceException (com.zimbra.common.service.ServiceException)1 AccountServiceException (com.zimbra.cs.account.AccountServiceException)1 ImapRemoteSession (com.zimbra.cs.imap.ImapRemoteSession)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 AccountsAttrib (com.zimbra.soap.admin.type.AccountsAttrib)1