Search in sources :

Example 1 with MsgActionRequest

use of com.zimbra.soap.mail.message.MsgActionRequest in project zm-mailbox by Zimbra.

the class SearchAction method performReadUnreadAction.

private static void performReadUnreadAction(SearchRequest searchRequest, List<SearchHit> searchHits, Mailbox mbox, String op) throws ServiceException, AuthTokenException, IOException, HttpException {
    Account acct = mbox.getAccount();
    Server server = Provisioning.getInstance().getServer(acct);
    String url = URLUtil.getSoapURL(server, false);
    SoapHttpTransport transport = new SoapHttpTransport(url);
    transport.setAuthToken(AuthProvider.getAuthToken(acct).getEncoded());
    transport.setTargetAcctId(acct.getId());
    if ("message".equalsIgnoreCase(searchRequest.getSearchTypes())) {
        MsgActionRequest req = getMsgActionRequest(searchHits, op);
        transport.invokeWithoutSession(JaxbUtil.jaxbToElement(req));
    } else if ("conversation".equalsIgnoreCase(searchRequest.getSearchTypes())) {
        ConvActionRequest req = getConvActionRequest(searchHits, op);
        transport.invokeWithoutSession(JaxbUtil.jaxbToElement(req));
    } else {
        throw ServiceException.INVALID_REQUEST("Invalid target search type", null);
    }
}
Also used : Account(com.zimbra.cs.account.Account) MsgActionRequest(com.zimbra.soap.mail.message.MsgActionRequest) Server(com.zimbra.cs.account.Server) ConvActionRequest(com.zimbra.soap.mail.message.ConvActionRequest) SoapHttpTransport(com.zimbra.common.soap.SoapHttpTransport)

Example 2 with MsgActionRequest

use of com.zimbra.soap.mail.message.MsgActionRequest in project zm-mailbox by Zimbra.

the class SearchAction method getMsgActionRequest.

public static MsgActionRequest getMsgActionRequest(List<SearchHit> searchHits, String op) {
    StringBuilder Ids = new StringBuilder();
    for (SearchHit searchHit : searchHits) {
        String id = searchHit.getId();
        Ids.append(id);
        Ids.append(",");
    }
    String IdsStr = Ids.length() > 0 ? Ids.substring(0, Ids.length() - 1) : "";
    ActionSelector actionSelector = new ActionSelector(IdsStr, op);
    MsgActionRequest req = new MsgActionRequest(actionSelector);
    return req;
}
Also used : MsgActionRequest(com.zimbra.soap.mail.message.MsgActionRequest) SearchHit(com.zimbra.soap.type.SearchHit) ActionSelector(com.zimbra.soap.mail.type.ActionSelector) ConvActionSelector(com.zimbra.soap.mail.type.ConvActionSelector)

Example 3 with MsgActionRequest

use of com.zimbra.soap.mail.message.MsgActionRequest in project zm-mailbox by Zimbra.

the class TestTags method testAddTag.

@SuppressWarnings("deprecation")
@Test
public void testAddTag() throws Exception {
    CreateTagRequest createTagReq = new CreateTagRequest();
    TagSpec tag = new TagSpec("tag150146840461812563");
    tag.setColor((byte) 5);
    createTagReq.setTag(tag);
    ZMailbox zMbox = TestUtil.getZMailbox(USER);
    CreateTagResponse createResp = zMbox.invokeJaxb(createTagReq);
    assertNotNull("CreateTagResponse should not be null", createResp);
    TagInfo createdTag = createResp.getTag();
    assertNotNull("CreateTagResponse/tag should not be null", createdTag);
    assertNotNull("Created tag should have an ID", createdTag.getId());
    assertNotNull("Created tag should have a color", createdTag.getColor());
    assertTrue("Color of created tag should be 5", createdTag.getColor() == (byte) 5);
    // use "update" and "t" element
    ActionSelector msgAction = ActionSelector.createForIdsAndOperation(Integer.toString(mMessage1.getId()), MailConstants.OP_UPDATE);
    msgAction.setTags(createdTag.getId());
    MsgActionRequest msgActionReq = new MsgActionRequest(msgAction);
    MsgActionResponse msgActionResp = zMbox.invokeJaxb(msgActionReq);
    assertNotNull("MsgActionResponse should not be null", msgActionResp);
    ActionResult res = msgActionResp.getAction();
    assertNotNull("MsgActionResponse/action should not be null", res);
    // use "tag" and "tag" element
    msgAction = ActionSelector.createForIdsAndOperation(Integer.toString(mMessage3.getId()), MailConstants.OP_TAG);
    msgAction.setTag(Integer.parseInt(createdTag.getId()));
    msgActionReq = new MsgActionRequest(msgAction);
    msgActionResp = zMbox.invokeJaxb(msgActionReq);
    assertNotNull("MsgActionResponse should not be null", msgActionResp);
    res = msgActionResp.getAction();
    assertNotNull("MsgActionResponse/action should not be null", res);
}
Also used : TagSpec(com.zimbra.soap.mail.type.TagSpec) MsgActionRequest(com.zimbra.soap.mail.message.MsgActionRequest) ZMailbox(com.zimbra.client.ZMailbox) ActionResult(com.zimbra.soap.mail.type.ActionResult) TagInfo(com.zimbra.soap.mail.type.TagInfo) MsgActionResponse(com.zimbra.soap.mail.message.MsgActionResponse) CreateTagRequest(com.zimbra.soap.mail.message.CreateTagRequest) CreateTagResponse(com.zimbra.soap.mail.message.CreateTagResponse) ActionSelector(com.zimbra.soap.mail.type.ActionSelector) Test(org.junit.Test)

Aggregations

MsgActionRequest (com.zimbra.soap.mail.message.MsgActionRequest)3 ActionSelector (com.zimbra.soap.mail.type.ActionSelector)2 ZMailbox (com.zimbra.client.ZMailbox)1 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)1 Account (com.zimbra.cs.account.Account)1 Server (com.zimbra.cs.account.Server)1 ConvActionRequest (com.zimbra.soap.mail.message.ConvActionRequest)1 CreateTagRequest (com.zimbra.soap.mail.message.CreateTagRequest)1 CreateTagResponse (com.zimbra.soap.mail.message.CreateTagResponse)1 MsgActionResponse (com.zimbra.soap.mail.message.MsgActionResponse)1 ActionResult (com.zimbra.soap.mail.type.ActionResult)1 ConvActionSelector (com.zimbra.soap.mail.type.ConvActionSelector)1 TagInfo (com.zimbra.soap.mail.type.TagInfo)1 TagSpec (com.zimbra.soap.mail.type.TagSpec)1 SearchHit (com.zimbra.soap.type.SearchHit)1 Test (org.junit.Test)1