Search in sources :

Example 6 with MimePartInfo

use of com.zimbra.soap.mail.type.MimePartInfo in project zm-mailbox by Zimbra.

the class TestExpandGroupInfo method sendMsg.

private void sendMsg(Account authAcct, String toAddress, String subject, String content) throws Exception {
    SoapTransport transport = authUser(authAcct.getName());
    MsgToSend msg = new MsgToSend();
    EmailAddrInfo toAddr = new EmailAddrInfo(toAddress);
    toAddr.setAddressType(EmailType.TO.toString());
    msg.addEmailAddress(toAddr);
    msg.setSubject(subject);
    MimePartInfo mp = new MimePartInfo();
    mp.setContentType("text/plain");
    mp.setContent(content);
    msg.setMimePart(mp);
    SendMsgRequest req = new SendMsgRequest();
    req.setMsg(msg);
    SendMsgResponse resp = invokeJaxb(transport, req);
}
Also used : EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) MsgToSend(com.zimbra.soap.mail.type.MsgToSend) MimePartInfo(com.zimbra.soap.mail.type.MimePartInfo) SendMsgRequest(com.zimbra.soap.mail.message.SendMsgRequest) SendMsgResponse(com.zimbra.soap.mail.message.SendMsgResponse) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 7 with MimePartInfo

use of com.zimbra.soap.mail.type.MimePartInfo in project zm-mailbox by Zimbra.

the class TestJaxb method testProposeNewTimeWorkflow.

/**
     * Bug 96748:
     * 1. user1 sends meeting invite to user2
     * 2. user2 proposes new time
     * 3. user1 accepts the proposed new time and new invite is sent to user2
     * 4. user2 accepts the new invite
     * At step 4, no acceptance message was being generated
     */
@Test
public void testProposeNewTimeWorkflow() throws Exception {
    TestUtil.createAccount(ORGANIZER);
    TestUtil.createAccount(ATTENDEE1);
    String subject = NAME_PREFIX + " attendee will cause time to change";
    ZMailbox organizerBox = TestUtil.getZMailbox(ORGANIZER);
    ZMailbox attendeeBox = TestUtil.getZMailbox(ATTENDEE1);
    String organizerEmail = organizerBox.getName();
    // Create and send the meeting request
    InviteComponent inviteComp = new InviteComponent();
    inviteComp.addAttendee(CalendarAttendee.createForAddressDisplaynameRolePartstatRsvp(attendeeBox.getName(), getCN(attendeeBox), "REQ", "NE", true));
    inviteComp.setStatus("CONF");
    inviteComp.setFreeBusy("B");
    inviteComp.setCalClass("PUB");
    inviteComp.setTransparency("O");
    inviteComp.setIsDraft(false);
    inviteComp.setIsAllDay(false);
    Date startDate = new Date(System.currentTimeMillis() + Constants.MILLIS_PER_DAY);
    ZDateTime start = new ZDateTime(startDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    Date endDate = new Date(startDate.getTime() + Constants.MILLIS_PER_HOUR);
    ZDateTime end = new ZDateTime(endDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    Date newStartDate = new Date(System.currentTimeMillis() + 2 * Constants.MILLIS_PER_DAY);
    ZDateTime newStart = new ZDateTime(newStartDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    Date newEndDate = new Date(newStartDate.getTime() + Constants.MILLIS_PER_HOUR);
    ZDateTime newEnd = new ZDateTime(newEndDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    inviteComp.setDtStart(DtTimeInfo.createForDatetimeAndZone(start.getDateTime(), start.getTimeZoneId()));
    inviteComp.setDtEnd(DtTimeInfo.createForDatetimeAndZone(end.getDateTime(), end.getTimeZoneId()));
    inviteComp.setName(subject);
    inviteComp.setLocation("room 101");
    inviteComp.setOrganizer(CalOrganizer.createForAddress(organizerEmail));
    InvitationInfo invite = new InvitationInfo();
    invite.setInviteComponent(inviteComp);
    EmailAddrInfo attendeeAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(attendeeBox.getName(), getCN(attendeeBox), "t");
    MimePartInfo mimePart = MimePartInfo.createForContentType("multipart/alternative");
    mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "invite body"));
    mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/html", "<html><body><p><b>invite</b> body</p></body></html>"));
    Msg msg = new Msg();
    msg.setFolderId("10");
    msg.setInvite(invite);
    msg.addEmailAddress(attendeeAddr);
    msg.setSubject(subject);
    msg.setMimePart(mimePart);
    CreateAppointmentRequest createApptReq = CreateAppointmentRequest.create(msg);
    CreateAppointmentResponse caResp = organizerBox.invokeJaxb(createApptReq);
    Assert.assertNotNull("JAXB CreateAppointmentResponse object", caResp);
    Assert.assertNotNull("JAXB CreateAppointmentResponse calItemId", caResp.getCalItemId());
    Assert.assertNotNull("JAXB CreateAppointmentResponse invId", caResp.getCalInvId());
    Assert.assertNotNull("JAXB CreateAppointmentResponse modified sequence ms", caResp.getModifiedSequence());
    Assert.assertNotNull("JAXB CreateAppointmentResponse rev", caResp.getRevision());
    ZMessage seriesInviteMsg = TestUtil.waitForMessage(attendeeBox, subject);
    Assert.assertNotNull("ZMessage for series invite", seriesInviteMsg);
    ZInvite seriesInvite = seriesInviteMsg.getInvite();
    Assert.assertNotNull("ZInvite for series invite", seriesInvite);
    AppointmentHitInfo hit = findMatchingAppointment(attendeeBox, startDate, endDate, subject);
    // User 1 proposes new time for meeting
    ZMessage propNewTimeMsg = attendeeProposeNewTimeForMeeting(attendeeBox, organizerBox, newStart, newEnd, hit, subject);
    Assert.assertNotNull("ZMessage for propose new time", propNewTimeMsg);
    hit = findMatchingAppointment(organizerBox, startDate, endDate, subject);
    // Organizer changes the meeting to the new proposed time
    // easier to find unique inbox entry
    subject = NAME_PREFIX + " attendee CAUSED time to change";
    ZMessage attendee2ndInvite = organizerChangeTimeForMeeting(attendeeBox, organizerBox, newStart, newEnd, hit, subject);
    Assert.assertNotNull("attendee 2nd invite", attendee2ndInvite);
    hit = findMatchingAppointment(attendeeBox, newStartDate, newEndDate, "inid:10");
    acceptInvite(attendeeBox, organizerBox, attendee2ndInvite, subject);
}
Also used : Msg(com.zimbra.soap.mail.type.Msg) ZMessage(com.zimbra.client.ZMessage) CreateAppointmentRequest(com.zimbra.soap.mail.message.CreateAppointmentRequest) ZInvite(com.zimbra.client.ZInvite) InvitationInfo(com.zimbra.soap.mail.type.InvitationInfo) CreateAppointmentResponse(com.zimbra.soap.mail.message.CreateAppointmentResponse) AppointmentHitInfo(com.zimbra.soap.mail.type.AppointmentHitInfo) Date(java.util.Date) InviteComponent(com.zimbra.soap.mail.type.InviteComponent) ZDateTime(com.zimbra.client.ZDateTime) ZMailbox(com.zimbra.client.ZMailbox) EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) MimePartInfo(com.zimbra.soap.mail.type.MimePartInfo) Test(org.junit.Test)

Example 8 with MimePartInfo

use of com.zimbra.soap.mail.type.MimePartInfo in project zm-mailbox by Zimbra.

the class TestJaxb method attendeeProposeNewTimeForMeeting.

/**
     * @param hit - From search response - represents the attendee's calendar copy
     * @return Message representing the Organizer's intray copy of the new proposal, once it has arrived
     */
private ZMessage attendeeProposeNewTimeForMeeting(ZMailbox attendeeBox, ZMailbox organizerBox, ZDateTime newStart, ZDateTime newEnd, AppointmentHitInfo hit, String subjectSuffix) throws Exception {
    EmailAddrInfo orgAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(organizerBox.getName(), organizerBox.getName(), "t");
    MimePartInfo mimePart = MimePartInfo.createForContentType("multipart/alternative");
    String plainText = "New Time Proposed.";
    String subject = "New Time Proposed: " + subjectSuffix;
    String htmlText = String.format("<html><body><p><b>%s</b></p></body></html>", plainText);
    mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", plainText));
    mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/html", htmlText));
    Msg msg = new Msg();
    InviteComponent compo = new InviteComponent();
    compo.setName(subjectSuffix);
    compo.setUid(hit.getUid());
    compo.setIsAllDay(hit.getAllDay());
    compo.setOrganizer(CalOrganizer.createForAddress(organizerBox.getName()));
    compo.setDtStart(DtTimeInfo.createForDatetimeAndZone(newStart.getDateTime(), newStart.getTimeZoneId()));
    compo.setDtEnd(DtTimeInfo.createForDatetimeAndZone(newEnd.getDateTime(), newEnd.getTimeZoneId()));
    InvitationInfo invite = InvitationInfo.create(compo);
    msg.addEmailAddress(orgAddr);
    /* replying to the organizer */
    msg.setSubject(subject);
    msg.setMimePart(mimePart);
    msg.setInvite(invite);
    CounterAppointmentResponse sirResp = attendeeBox.invokeJaxb(CounterAppointmentRequest.createForMsgModseqRevIdCompnum(msg, hit.getModifiedSequence(), hit.getRevision(), hit.getInvId(), hit.getComponentNum()));
    Assert.assertNotNull("JAXB CounterAppointmentResponse object", sirResp);
    return TestUtil.waitForMessage(organizerBox, String.format("subject:\"%s\"", subject));
}
Also used : Msg(com.zimbra.soap.mail.type.Msg) InvitationInfo(com.zimbra.soap.mail.type.InvitationInfo) EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) MimePartInfo(com.zimbra.soap.mail.type.MimePartInfo) InviteComponent(com.zimbra.soap.mail.type.InviteComponent) CounterAppointmentResponse(com.zimbra.soap.mail.message.CounterAppointmentResponse)

Example 9 with MimePartInfo

use of com.zimbra.soap.mail.type.MimePartInfo in project zm-mailbox by Zimbra.

the class TestJaxb method organizerChangeTimeForMeeting.

/**
     * @param hit - From search response - represents the organizer's calendar copy
     * @throws ServiceException
     */
private ZMessage organizerChangeTimeForMeeting(ZMailbox attendeeBox, ZMailbox organizerBox, ZDateTime newStart, ZDateTime newEnd, AppointmentHitInfo hit, String subject) throws Exception {
    String organizerEmail = organizerBox.getName();
    InviteComponent inviteComp = new InviteComponent();
    inviteComp.addAttendee(CalendarAttendee.createForAddressDisplaynameRolePartstatRsvp(attendeeBox.getName(), getCN(attendeeBox), "REQ", "NE", true));
    /* Note Tentative, not Needs action */
    inviteComp.setStatus("CONF");
    inviteComp.setFreeBusy("B");
    inviteComp.setCalClass("PUB");
    inviteComp.setTransparency("O");
    inviteComp.setIsDraft(false);
    inviteComp.setIsAllDay(false);
    inviteComp.setDtStart(DtTimeInfo.createForDatetimeAndZone(newStart.getDateTime(), newStart.getTimeZoneId()));
    inviteComp.setDtEnd(DtTimeInfo.createForDatetimeAndZone(newEnd.getDateTime(), newEnd.getTimeZoneId()));
    inviteComp.setName(subject);
    inviteComp.setLocation("room 101");
    inviteComp.setOrganizer(CalOrganizer.createForAddress(organizerEmail));
    InvitationInfo invite = new InvitationInfo();
    invite.setUid(hit.getUid());
    invite.setInviteComponent(inviteComp);
    MimePartInfo mimePart = MimePartInfo.createForContentType("multipart/alternative");
    String bodyText = String.format("The following meeting has been modified:\n\n%s", subject);
    mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", bodyText));
    Msg msg = new Msg();
    msg.setFolderId(hit.getFolderId());
    msg.setInvite(invite);
    EmailAddrInfo attendeeAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(attendeeBox.getName(), getCN(attendeeBox), "t");
    msg.addEmailAddress(attendeeAddr);
    msg.setSubject(subject);
    msg.setMimePart(mimePart);
    ModifyAppointmentRequest maReq = ModifyAppointmentRequest.createForIdModseqRevCompnumMsg(hit.getInvId(), hit.getModifiedSequence(), hit.getRevision(), hit.getComponentNum(), msg);
    ModifyAppointmentResponse maResp = organizerBox.invokeJaxb(maReq);
    Assert.assertNotNull("JAXB ModifyAppointmentResponse", maResp);
    return TestUtil.waitForMessage(attendeeBox, String.format("subject:\"%s\"", subject));
}
Also used : Msg(com.zimbra.soap.mail.type.Msg) ModifyAppointmentRequest(com.zimbra.soap.mail.message.ModifyAppointmentRequest) InvitationInfo(com.zimbra.soap.mail.type.InvitationInfo) EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) ModifyAppointmentResponse(com.zimbra.soap.mail.message.ModifyAppointmentResponse) MimePartInfo(com.zimbra.soap.mail.type.MimePartInfo) InviteComponent(com.zimbra.soap.mail.type.InviteComponent)

Example 10 with MimePartInfo

use of com.zimbra.soap.mail.type.MimePartInfo in project zm-mailbox by Zimbra.

the class TestContentTransferEncoding method testNestedMultipartMessage.

/*
     * Tests bug 103193, which is a regression introduced by bugfix for 98015.
     * The problem seems to be that the MIME structure of the forwarded message doesn't match the structure
     * of the original, which is assumed by the bugfix. Specifically, it lacks the top-level multipart/mixed parent.
     */
@Test
public void testNestedMultipartMessage() throws Exception {
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    MimeMessage mimeMsg = new ZMimeMessage(JMSession.getSession(), new SharedByteArrayInputStream(getNestedMimeString().getBytes()));
    ParsedMessage pm = new ParsedMessage(mimeMsg, true);
    DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
    Message msg = mbox.addMessage(null, pm, dopt, null);
    MsgToSend msgToSend = new MsgToSend();
    msgToSend.setOrigId(String.valueOf(msg.getId()));
    msgToSend.setReplyType("w");
    msgToSend.setSubject("Fwd: Multipart Test");
    MimePartInfo mpi = new MimePartInfo();
    mpi.setContentType("multipart/alternative");
    List<MimePartInfo> mimeParts = new LinkedList<MimePartInfo>();
    mimeParts.add(MimePartInfo.createForContentTypeAndContent("text/plain", "text content"));
    mimeParts.add(MimePartInfo.createForContentTypeAndContent("text/html", "html content"));
    mpi.setMimeParts(mimeParts);
    msgToSend.setMimePart(mpi);
    SendMsgRequest req = new SendMsgRequest();
    req.setMsg(msgToSend);
    try {
        MimeMessage parsed = sendForwardedMessage(req, msg);
    } catch (ArrayIndexOutOfBoundsException e) {
        fail("could not build MIME message");
    }
}
Also used : ZMimeMessage(com.zimbra.common.zmime.ZMimeMessage) ZMimeMessage(com.zimbra.common.zmime.ZMimeMessage) Message(com.zimbra.cs.mailbox.Message) MimeMessage(javax.mail.internet.MimeMessage) ParseMimeMessage(com.zimbra.cs.service.mail.ParseMimeMessage) SendMsgRequest(com.zimbra.soap.mail.message.SendMsgRequest) LinkedList(java.util.LinkedList) SharedByteArrayInputStream(javax.mail.util.SharedByteArrayInputStream) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZMimeMessage(com.zimbra.common.zmime.ZMimeMessage) MimeMessage(javax.mail.internet.MimeMessage) ParseMimeMessage(com.zimbra.cs.service.mail.ParseMimeMessage) MsgToSend(com.zimbra.soap.mail.type.MsgToSend) MimePartInfo(com.zimbra.soap.mail.type.MimePartInfo) DeliveryOptions(com.zimbra.cs.mailbox.DeliveryOptions) Test(org.junit.Test)

Aggregations

MimePartInfo (com.zimbra.soap.mail.type.MimePartInfo)10 EmailAddrInfo (com.zimbra.soap.mail.type.EmailAddrInfo)8 Msg (com.zimbra.soap.mail.type.Msg)7 InvitationInfo (com.zimbra.soap.mail.type.InvitationInfo)5 InviteComponent (com.zimbra.soap.mail.type.InviteComponent)5 Test (org.junit.Test)4 ZMessage (com.zimbra.client.ZMessage)3 CreateAppointmentRequest (com.zimbra.soap.mail.message.CreateAppointmentRequest)3 CreateAppointmentResponse (com.zimbra.soap.mail.message.CreateAppointmentResponse)3 SendInviteReplyRequest (com.zimbra.soap.mail.message.SendInviteReplyRequest)3 SendInviteReplyResponse (com.zimbra.soap.mail.message.SendInviteReplyResponse)3 SendMsgRequest (com.zimbra.soap.mail.message.SendMsgRequest)3 MsgToSend (com.zimbra.soap.mail.type.MsgToSend)3 ZInvite (com.zimbra.client.ZInvite)2 ZMailbox (com.zimbra.client.ZMailbox)2 SoapTransport (com.zimbra.common.soap.SoapTransport)2 ZMimeMessage (com.zimbra.common.zmime.ZMimeMessage)2 DeliveryOptions (com.zimbra.cs.mailbox.DeliveryOptions)2 Mailbox (com.zimbra.cs.mailbox.Mailbox)2 Message (com.zimbra.cs.mailbox.Message)2