use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class TestJaxb method sendInviteReplyToSeries.
private ZMessage sendInviteReplyToSeries(ZMailbox attendeeBox, ZMailbox organizerBox, String inviteMsgId, String subjectSuffix, String verb) throws Exception {
SendInviteReplyRequest sirReq = new SendInviteReplyRequest(inviteMsgId, 0, /* componentNum */
verb);
sirReq.setIdentityId(attendeeBox.getAccountInfo(false).getId());
sirReq.setUpdateOrganizer(true);
EmailAddrInfo attendeeAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(attendeeBox.getName(), getCN(attendeeBox), "f");
EmailAddrInfo orgAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(organizerBox.getName(), organizerBox.getName(), "t");
MimePartInfo mimePart = MimePartInfo.createForContentType("multipart/alternative");
String plainText;
String subject;
if ("ACCEPT".equals(verb)) {
plainText = "Yes, I will attend.";
subject = "Accept: " + subjectSuffix;
} else if ("DECLINE".equals(verb)) {
plainText = "No, I won't attend.";
subject = "Decline: " + subjectSuffix;
} else {
plainText = "Maybe, I will attend.";
subject = "Tentative: " + 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();
msg.setReplyType("r");
msg.setIdentityId(attendeeBox.getAccountInfo(false).getId());
msg.addEmailAddress(orgAddr);
msg.addEmailAddress(attendeeAddr);
msg.setSubject(subject);
msg.setMimePart(mimePart);
sirReq.setMsg(msg);
SendInviteReplyResponse sirResp = attendeeBox.invokeJaxb(sirReq);
Assert.assertNotNull("JAXB SendInviteReplyResponse object", sirResp);
return TestUtil.waitForMessage(organizerBox, String.format("subject:\"%s\"", subject));
}
use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class TestJaxb method acceptInvite.
private ZMessage acceptInvite(ZMailbox attendeeBox, ZMailbox organizerBox, ZMessage inviteMsg, String subject) throws Exception {
SendInviteReplyRequest sirReq = new SendInviteReplyRequest(inviteMsg.getId(), 0, /* componentNum */
"ACCEPT");
sirReq.setIdentityId(attendeeBox.getAccountInfo(false).getId());
// ZWC 8.6 and earlier used to set this to false. Now sets it to true.
sirReq.setUpdateOrganizer(true);
MimePartInfo mimePart = MimePartInfo.createForContentType("multipart/alternative");
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "Accepting"));
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/html", "<html><body><p><b>Accepting</b></p></body></html>"));
Msg msg = new Msg();
msg.setReplyType("r");
msg.setIdentityId(attendeeBox.getAccountInfo(false).getId());
EmailAddrInfo orgAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(organizerBox.getName(), organizerBox.getName(), "t");
EmailAddrInfo attendeeAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(attendeeBox.getName(), getCN(attendeeBox), "f");
msg.addEmailAddress(orgAddr);
msg.addEmailAddress(attendeeAddr);
String acceptSubject = "Accept: " + subject;
msg.setSubject(acceptSubject);
msg.setMimePart(mimePart);
sirReq.setMsg(msg);
SendInviteReplyResponse sirResp = attendeeBox.invokeJaxb(sirReq);
Assert.assertNotNull("JAXB SendInviteReplyResponse object", sirResp);
ZMessage inboxMsg = TestUtil.waitForMessage(organizerBox, String.format("subject:\"%s\"", acceptSubject));
Assert.assertNotNull("ZMessage for accept", inboxMsg);
return inboxMsg;
}
use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class TestJaxb method testAcceptSeriesDeclineInstance.
/**
* Bug 94018. Accepting series, then declining single instance leads to inconsistent display of attendee
* status for organizer copy for the declined instance.
* Test steps:
* 1. Invite 2 users to a daily meeting.
* 2. User 1 replies, accepting the daily meeting.
* 3. User 1 replies again, declining one of the instances in the daily meeting.
* 4. User 2 replies tentatively accepting the daily meeting.
*
* At the end of this, check that an exception has been created. Check that that exception registers
* the decline from user 1 AND the tentative acceptance from user2 that arrived later.
*/
@Test
public void testAcceptSeriesDeclineInstance() throws Exception {
TestUtil.createAccount(ORGANIZER);
TestUtil.createAccount(ATTENDEE1);
TestUtil.createAccount(ATTENDEE2);
String subject = NAME_PREFIX + " Daily";
ZMailbox organizerBox = TestUtil.getZMailbox(ORGANIZER);
ZMailbox attendeeBox = TestUtil.getZMailbox(ATTENDEE1);
ZMailbox attendee2Box = TestUtil.getZMailbox(ATTENDEE2);
String organizerEmail = organizerBox.getName();
// Create and send the daily meeting
InviteComponent inviteComp = new InviteComponent();
inviteComp.addAttendee(CalendarAttendee.createForAddressDisplaynameRolePartstatRsvp(attendeeBox.getName(), getCN(attendeeBox), "REQ", "NE", true));
inviteComp.addAttendee(CalendarAttendee.createForAddressDisplaynameRolePartstatRsvp(attendee2Box.getName(), getCN(attendee2Box), "REQ", "NE", true));
inviteComp.setStatus("CONF");
inviteComp.setFreeBusy("B");
inviteComp.setCalClass("PUB");
inviteComp.setTransparency("O");
inviteComp.setIsDraft(false);
inviteComp.setIsAllDay(false);
inviteComp.setDtStart(DtTimeInfo.createForDatetimeAndZone("20161008T130000", "Europe/London"));
inviteComp.setDtEnd(DtTimeInfo.createForDatetimeAndZone("20161008T140000", "Europe/London"));
inviteComp.setName(subject);
inviteComp.setLocation("room 101");
inviteComp.setOrganizer(CalOrganizer.createForAddress(organizerEmail));
inviteComp.setRecurrence(RecurrenceInfo.create(AddRecurrenceInfo.create(SimpleRepeatingRule.createFromFrequencyAndInterval("DAI", IntervalRule.create(1)))));
InvitationInfo invite = new InvitationInfo();
invite.setInviteComponent(inviteComp);
EmailAddrInfo attendeeAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(attendeeBox.getName(), getCN(attendeeBox), "t");
EmailAddrInfo attendeeAddr2 = EmailAddrInfo.createForAddressPersonalAndAddressType(attendee2Box.getName(), getCN(attendee2Box), "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.addEmailAddress(attendeeAddr2);
msg.setSubject(subject);
msg.setMimePart(mimePart);
CreateAppointmentRequest createSeriesRequest = CreateAppointmentRequest.create(msg);
CreateAppointmentResponse caResp = organizerBox.invokeJaxb(createSeriesRequest);
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);
// User 1 accepts the daily meeting
ZMessage seriesAcceptMsg = sendInviteReplyToSeries(attendeeBox, organizerBox, seriesInviteMsg.getId(), subject, "ACCEPT");
Assert.assertNotNull("ZMessage for series accept", seriesAcceptMsg);
// User 1 declines one instance of the daily meeting
SendInviteReplyRequest sirReq = new SendInviteReplyRequest(seriesInviteMsg.getId(), 0, /* componentNum */
"DECLINE");
sirReq.setIdentityId(attendeeBox.getAccountInfo(false).getId());
sirReq.setExceptionId(DtTimeInfo.createForDatetimeAndZone("20161011T130000", "Europe/London"));
sirReq.setUpdateOrganizer(true);
attendeeAddr.setAddressType("f");
mimePart = MimePartInfo.createForContentType("multipart/alternative");
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "I won't attend on Tuesday, October 11, 2016."));
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/html", "<html><body><p><b>I won't attend on Tuesday, October 11, 2016</b></p></body></html>"));
msg = new Msg();
msg.setReplyType("r");
msg.setIdentityId(attendeeBox.getAccountInfo(false).getId());
EmailAddrInfo orgAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(organizerBox.getName(), organizerBox.getName(), "t");
msg.addEmailAddress(orgAddr);
msg.addEmailAddress(attendeeAddr);
String declineSubject = "Decline: " + subject;
msg.setSubject(declineSubject);
msg.setMimePart(mimePart);
sirReq.setMsg(msg);
SendInviteReplyResponse sirResp = attendeeBox.invokeJaxb(sirReq);
Assert.assertNotNull("JAXB SendInviteReplyResponse object", sirResp);
ZMessage instanceDeclineMsg = TestUtil.waitForMessage(organizerBox, String.format("subject:\"%s\"", declineSubject));
Assert.assertNotNull("ZMessage for series accept", instanceDeclineMsg);
seriesInviteMsg = TestUtil.waitForMessage(attendee2Box, subject);
Assert.assertNotNull("ZMessage for series invite", seriesInviteMsg);
seriesInvite = seriesInviteMsg.getInvite();
Assert.assertNotNull("ZInvite for series invite", seriesInvite);
// User 2 tentatively accepts the daily meeting
ZMessage seriesTentativeMsg = sendInviteReplyToSeries(attendee2Box, organizerBox, seriesInviteMsg.getId(), subject, "TENTATIVE");
Assert.assertNotNull("ZMessage for series tentative", seriesTentativeMsg);
// Search for the organizer's calendar entry
SearchRequest sReq = new SearchRequest();
sReq.setSearchTypes(ZSearchParams.TYPE_APPOINTMENT);
sReq.setCalItemExpandStart(ymdStringToDate("2016-10-09"));
sReq.setCalItemExpandEnd(ymdStringToDate("2016-10-14"));
sReq.setQuery((String.format("in:Calendar and subject:%s", subject)));
SearchResponse sResp = organizerBox.invokeJaxb(sReq);
List<SearchHit> hits = sResp.getSearchHits();
Assert.assertNotNull("Organizer calendar Search hits at end", hits);
Assert.assertEquals("Num Organizer calendar hits at end", 1, hits.size());
SearchHit orgCalHit = hits.get(0);
Assert.assertTrue(orgCalHit instanceof AppointmentHitInfo);
AppointmentHitInfo orgApptHit = (AppointmentHitInfo) orgCalHit;
String seriesInviteId = orgApptHit.getInvId();
Assert.assertNotNull("Organizer Calendar at end - series invite id", seriesInviteId);
List<InstanceDataInfo> instances = orgApptHit.getInstances();
Assert.assertNotNull("Organizer Calendar at end - instances in expansion", instances);
Assert.assertEquals("Organizer Calendar at end - number of instances in expansion", 5, instances.size());
// The third entry in the list should be for the exception
String exceptionInviteId = instances.get(2).getInvId();
Assert.assertNotNull("Organizer Calendar at end - exception invite id", exceptionInviteId);
String exceptionRidZ = instances.get(2).getRecurIdZ();
Assert.assertNotNull("Organizer Calendar at end - exception invite RecurIdZ", exceptionRidZ);
// Do a GetMsg for the exception in the Organizer's calendar
MsgSpec gmeMsgSpec = new MsgSpec(exceptionInviteId);
gmeMsgSpec.setRecurIdZ(exceptionRidZ);
GetMsgRequest gmeReq = new GetMsgRequest(gmeMsgSpec);
GetMsgResponse gmeResp = organizerBox.invokeJaxb(gmeReq);
List<InviteComponentWithGroupInfo> eInviteComps = gmeResp.getMsg().getInvite().getInviteComponents();
Assert.assertEquals("Organizer Calendar at end - number of components in exception", 1, eInviteComps.size());
List<CalendarAttendeeWithGroupInfo> eAttendees = eInviteComps.get(0).getAttendees();
Assert.assertEquals("Organizer Calendar at end - number of attendees in exception", 2, eAttendees.size());
for (CalendarAttendeeWithGroupInfo eAttendee : eAttendees) {
String addr = eAttendee.getAddress();
String ptst = eAttendee.getPartStat();
if (addr.equals(attendeeBox.getName())) {
Assert.assertEquals("exception attendee1 partstat", "DE", ptst);
} else if (addr.equals(attendee2Box.getName())) {
Assert.assertEquals("exception attendee2 partstat", "TE", ptst);
} else {
Assert.fail(String.format("Unexpected attendee in exception [%s]", addr));
}
}
// Do a GetMsg for the series in the Organizer's calendar
MsgSpec gmsMsgSpec = new MsgSpec(seriesInviteId);
GetMsgRequest gmsReq = new GetMsgRequest(gmsMsgSpec);
GetMsgResponse gmsResp = organizerBox.invokeJaxb(gmsReq);
List<InviteComponentWithGroupInfo> sInviteComps = gmsResp.getMsg().getInvite().getInviteComponents();
Assert.assertEquals("Organizer Calendar at end - number of components in series", 1, sInviteComps.size());
List<CalendarAttendeeWithGroupInfo> sAttendees = sInviteComps.get(0).getAttendees();
Assert.assertEquals("Organizer Calendar at end - number of attendees in exception", 2, sAttendees.size());
for (CalendarAttendeeWithGroupInfo sAttendee : sAttendees) {
String addr = sAttendee.getAddress();
String ptst = sAttendee.getPartStat();
if (addr.equals(attendeeBox.getName())) {
Assert.assertEquals("exception attendee1 partstat", "AC", ptst);
} else if (addr.equals(attendee2Box.getName())) {
Assert.assertEquals("exception attendee2 partstat", "TE", ptst);
} else {
Assert.fail(String.format("Unexpected attendee in exception [%s]", addr));
}
}
}
use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class AbstractCalendarProxy method changeGroupMembership.
/**
* Reflect changes in membership, i.e. invite new members and revoke access to people no longer in the group.
* Note that we are only dealing with the default Calendar - the Apple model doesn't talk about things at
* the calendar level - so for our purposes we shall assume it only applies to that calendar.
*/
private void changeGroupMembership(DavContext ctxt, Set<Account> invitees, Set<Account> revokees, short role) {
try {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(getAccount());
ZMailbox zmbox = ctxt.getZMailbox(getAccount());
List<EmailAddrInfo> emailAddresses = Lists.newArrayList();
for (Account target : invitees) {
mbox.grantAccess(ctxt.getOperationContext(), Mailbox.ID_FOLDER_CALENDAR, target.getId(), ACL.GRANTEE_USER, role, null);
emailAddresses.add(new EmailAddrInfo(target.getName()));
}
SendShareNotificationRequest ssnreq;
if (!emailAddresses.isEmpty()) {
ssnreq = SendShareNotificationRequest.create(Mailbox.ID_FOLDER_CALENDAR, null, /* SendShareNotificationRequest.Action */
null, /* notes */
emailAddresses);
zmbox.invokeJaxb(ssnreq);
}
emailAddresses = Lists.newArrayList();
for (Account target : revokees) {
mbox.revokeAccess(ctxt.getOperationContext(), Mailbox.ID_FOLDER_CALENDAR, target.getId());
emailAddresses.add(new EmailAddrInfo(target.getName()));
}
if (!emailAddresses.isEmpty()) {
ssnreq = SendShareNotificationRequest.create(Mailbox.ID_FOLDER_CALENDAR, SendShareNotificationRequest.Action.revoke, null, /* notes */
emailAddresses);
zmbox.invokeJaxb(ssnreq);
}
} catch (ServiceException se) {
ZimbraLog.dav.warn("can't modify acl on %s for %s", getAccount().getName(), ctxt.getPath());
}
}
use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class TestShareNotifications method testMultipleCalendarShareNotifications.
public void testMultipleCalendarShareNotifications() throws Exception {
Account senderAccount = TestUtil.createAccount(SENDER_NAME);
Account recipientAccount = TestUtil.createAccount(RECIPIENT_NAME);
ZMailbox mbox = TestUtil.getZMailbox(SENDER_NAME);
// check that there are no share notifications in the recipient's mailbox
ZMailbox recipientMbox = TestUtil.getZMailbox(RECIPIENT_NAME);
List<ShareNotificationInfo> shares = waitForShareNotifications(recipientMbox, 0, 100);
assertEquals("Recipient should have exactly 0 share notification", 0, shares.size());
// create and share the first calendar
ZFolder newCal = TestUtil.createFolder(mbox, CAL_NAME1, ZFolder.View.appointment);
String calendarId = newCal.getId();
FolderActionSelector action = new FolderActionSelector(calendarId, "grant");
ActionGrantSelector grant = new ActionGrantSelector("r", "usr");
grant.setDisplayName(recipientAccount.getName());
grant.setPassword("");
action.setGrant(grant);
FolderActionRequest folderActionReq = new FolderActionRequest(action);
FolderActionResponse folderActionResp = mbox.invokeJaxb(folderActionReq);
assertNotNull("FolderActionResponse is null", folderActionResp);
SendShareNotificationRequest shareNotificationReq = new SendShareNotificationRequest();
shareNotificationReq.setItem(new com.zimbra.soap.type.Id(calendarId));
shareNotificationReq.addEmailAddress(new EmailAddrInfo(recipientAccount.getMail()));
SendShareNotificationResponse resp = mbox.invokeJaxb(shareNotificationReq);
assertNotNull("ShareNotificationResponse is null", resp);
// create and share the second calendar
ZFolder newCal2 = TestUtil.createFolder(mbox, CAL_NAME2, ZFolder.View.appointment);
String calendarId2 = newCal2.getId();
action = new FolderActionSelector(calendarId2, "grant");
grant = new ActionGrantSelector("r", "usr");
grant.setDisplayName(recipientAccount.getName());
grant.setPassword("");
action.setGrant(grant);
folderActionReq = new FolderActionRequest(action);
folderActionResp = mbox.invokeJaxb(folderActionReq);
assertNotNull("FolderActionResponse is null", folderActionResp);
shareNotificationReq = new SendShareNotificationRequest();
shareNotificationReq.setItem(new com.zimbra.soap.type.Id(calendarId2));
shareNotificationReq.addEmailAddress(new EmailAddrInfo(recipientAccount.getMail()));
resp = mbox.invokeJaxb(shareNotificationReq);
assertNotNull("ShareNotificationResponse is null", resp);
shares = waitForShareNotifications(recipientMbox, 2, 1000);
assertEquals("should have exactly two share notification", 2, shares.size());
assertNotNull("share grantor is null", shares.get(0).getGrantor());
assertTrue("share grantor is not " + senderAccount.getMail(), senderAccount.getMail().equalsIgnoreCase(shares.get(0).getGrantor().getEmail()));
}
Aggregations