use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class TestShareNotifications method testCalendarShareNotification.
public void testCalendarShareNotification() 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());
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);
shares = waitForShareNotifications(recipientMbox, 1, 1000);
assertTrue("should have exactly one share notification", shares.size() == 1);
assertNotNull("share grantor is null", shares.get(0).getGrantor());
assertTrue("share grantor is not " + senderAccount.getMail(), senderAccount.getMail().equalsIgnoreCase(shares.get(0).getGrantor().getEmail()));
}
use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class SendShareNotification method validateRequest.
private Collection<ShareInfoData> validateRequest(ZimbraSoapContext zsc, Map<String, Object> context, OperationContext octxt, Mailbox mbox, Element request) throws ServiceException {
Element eShare = request.getOptionalElement(MailConstants.E_SHARE);
if (eShare != null) {
return Arrays.asList(validateShareRecipient(zsc, context, octxt, mbox, eShare));
}
String action = request.getAttribute(MailConstants.A_ACTION, null);
ArrayList<ShareInfoData> shareInfos = new ArrayList<ShareInfoData>();
SendShareNotificationRequest req = JaxbUtil.elementToJaxb(request);
ItemId iid = new ItemId(req.getItem().getId(), zsc);
MailItem item = mbox.getItemById(octxt, iid.getId(), MailItem.Type.UNKNOWN);
Provisioning prov = Provisioning.getInstance();
Account account = getRequestedAccount(zsc);
if (item instanceof Mountpoint) {
Mountpoint mp = (Mountpoint) item;
account = prov.get(AccountBy.id, mp.getOwnerId());
}
for (EmailAddrInfo email : req.getEmailAddresses()) {
// add the non-existing grantee as type GRANTEE_GUEST for share notification.
// for revoke notifications return the non-existing grantees only
Pair<NamedEntry, String> grantee;
boolean guestGrantee = false;
byte granteeType = ACL.GRANTEE_USER;
String granteeId = null;
String granteeEmail = email.getAddress();
String granteeDisplayName = null;
try {
grantee = getGrantee(zsc, granteeType, granteeId, granteeEmail);
NamedEntry entry = grantee.getFirst();
if (entry instanceof MailTarget) {
Domain domain = prov.getDomain(account);
String granteeDomainName = ((MailTarget) entry).getDomainName();
if (domain.isInternalSharingCrossDomainEnabled() || domain.getName().equals(granteeDomainName) || Sets.newHashSet(domain.getInternalSharingDomain()).contains(granteeDomainName)) {
if (entry instanceof Group) {
granteeType = ACL.GRANTEE_GROUP;
}
granteeId = entry.getId();
granteeDisplayName = grantee.getSecond();
} else {
guestGrantee = true;
}
}
} catch (ServiceException e) {
if (!e.getCode().equals(MailServiceException.NO_SUCH_GRANTEE)) {
throw e;
}
guestGrantee = true;
}
if (guestGrantee) {
granteeType = ACL.GRANTEE_GUEST;
// if guest, granteeId is the same as granteeEmail
granteeId = granteeEmail;
}
shareInfos.add(getShareInfoData(zsc, context, account, octxt, granteeType, granteeEmail, granteeId, granteeDisplayName, item, REVOKE.equals(action)));
}
return shareInfos;
}
use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class TestShareNotifications method testContactShareNotification.
public void testContactShareNotification() 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 newContactsFolder = TestUtil.createFolder(mbox, CAL_NAME1, ZFolder.View.contact);
String contactsFolderId = newContactsFolder.getId();
FolderActionSelector action = new FolderActionSelector(contactsFolderId, "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(contactsFolderId));
shareNotificationReq.addEmailAddress(new EmailAddrInfo(recipientAccount.getMail()));
SendShareNotificationResponse resp = mbox.invokeJaxb(shareNotificationReq);
assertNotNull("ShareNotificationResponse is null", resp);
shares = waitForShareNotifications(recipientMbox, 1, 1000);
assertEquals("should have exactly one share notification", 1, 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()));
}
use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class TestShareNotifications method testContactAndCalendarShareNotifications.
public void testContactAndCalendarShareNotifications() 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 newContactsFolder = TestUtil.createFolder(mbox, CONTACTS_NAME1, ZFolder.View.contact);
String contactsFolderId = newContactsFolder.getId();
action = new FolderActionSelector(contactsFolderId, "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(contactsFolderId));
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()));
}
use of com.zimbra.soap.mail.type.EmailAddrInfo in project zm-mailbox by Zimbra.
the class TestExpandGroupInfo method createAppt.
private String createAppt(Account authAcct, String toAddress, String subject, String content) throws Exception {
SoapTransport transport = authUser(authAcct.getName());
Msg msg = new Msg();
EmailAddrInfo toAddr = new EmailAddrInfo(toAddress);
toAddr.setAddressType(EmailType.TO.toString());
msg.addEmailAddress(toAddr);
msg.setSubject(subject);
MimePartInfo mp = new MimePartInfo();
mp.setContentType("multipart/alternative");
MimePartInfo mpSub = new MimePartInfo();
mpSub.setContent(content);
mp.addMimePart(mpSub);
msg.setMimePart(mp);
InvitationInfo invite = new InvitationInfo();
InviteComponent invComp = new InviteComponent(ZCalendar.ICalTok.REQUEST.name(), 0, false);
CalOrganizer organizer = new CalOrganizer();
organizer.setAddress(authAcct.getName());
CalendarAttendee attendee = new CalendarAttendee();
attendee.setAddress(toAddress);
invComp.setOrganizer(organizer);
invComp.addAttendee(attendee);
invComp.setDtStart(new DtTimeInfo("20120101"));
invComp.setDtEnd(new DtTimeInfo("20120102"));
invite.setInviteComponent(invComp);
msg.setInvite(invite);
CreateAppointmentRequest req = new CreateAppointmentRequest();
req.setMsg(msg);
CreateAppointmentResponse resp = invokeJaxb(transport, req);
/*
String calItemId = resp.getCalItemId();
return calItemId;
*/
String invId = resp.getCalInvId();
return invId;
/*
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<context xmlns="urn:zimbra">
<userAgent xmlns="" name="ZimbraWebClient - FF10 (Mac)" version="0.0"/>
<session xmlns="" id="14"/>
<account xmlns="" by="name">user1@phoebe.mbp</account>
<format xmlns="" type="js"/>
</context>
</soap:Header>
<soap:Body>
<CreateAppointmentRequest xmlns="urn:zimbraMail">
<m xmlns="" l="10">
<inv>
<comp status="CONF" fb="B" class="PUB" transp="O" draft="0" allDay="0" name="test" loc="">
<at role="REQ" ptst="NE" rsvp="1" a="user2@phoebe.mbp"/>
<at role="REQ" ptst="NE" rsvp="1" a="user3@phoebe.mbp"/>
<s tz="America/Los_Angeles" d="20120227T080000"/>
<e tz="America/Los_Angeles" d="20120227T083000"/>
<or a="user1@phoebe.mbp" d="Demo User One"/>
<alarm action="DISPLAY">
<trigger>
<rel m="5" related="START" neg="1"/>
</trigger>
</alarm>
</comp>
</inv>
<e a="user2@phoebe.mbp" t="t"/>
<e a="user3@phoebe.mbp" t="t"/>
<su>test</su>
<mp ct="multipart/alternative">
<mp ct="text/plain">
<content>The following is a new meeting request: Subject: test Organizer: "Demo User One" <user1@phoebe.mbp> Time: Monday, February 27, 2012, 8:00:00 AM - 8:30:00 AM GMT -08:00 US/Canada Pacific Invitees: user2@phoebe.mbp; user3@phoebe.mbp *~*~*~*~*~*~*~*~*~* </content></mp><mp ct="text/html"><content><html><body><h3>The following is a new meeting request:</h3> <p> <table border='0'> <tr><th align=left>Subject:</th><td>test </td></tr> <tr><th align=left>Organizer:</th><td>"Demo User One" &lt;user1@phoebe.mbp&gt; </td></tr> </table> <p> <table border='0'> <tr><th align=left>Time:</th><td>Monday, February 27, 2012, 8:00:00 AM - 8:30:00 AM GMT -08:00 US/Canada Pacific </td></tr></table> <p> <table border='0'> <tr><th align=left>Invitees:</th><td>user2@phoebe.mbp; user3@phoebe.mbp </td></tr> </table> <div>*~*~*~*~*~*~*~*~*~*</div><br></body></html></content>
</mp>
</mp>
</m>
</CreateAppointmentRequest>
</soap:Body></soap:Envelope>
*/
}
Aggregations