use of com.zimbra.soap.mail.message.CreateMountpointRequest in project zm-mailbox by Zimbra.
the class GetMsgTest method testHandle.
@Test
public void testHandle() throws Exception {
Account acct1 = Provisioning.getInstance().get(Key.AccountBy.name, "test@zimbra.com");
Account acct2 = Provisioning.getInstance().get(Key.AccountBy.name, "test2@zimbra.com");
Mailbox mbox1 = MailboxManager.getInstance().getMailboxByAccount(acct1);
Folder calendarFolder = mbox1.getCalendarFolders(null, SortBy.NONE).get(0);
String fragment = "Some message";
ZVCalendar calendar = new ZVCalendar();
calendar.addDescription(desc, null);
ZComponent comp = new ZComponent("VEVENT");
calendar.addComponent(comp);
Invite invite = MailboxTestUtil.generateInvite(acct1, fragment, calendar);
ICalTimeZone ical = invite.getTimeZoneMap().getLocalTimeZone();
long utc = 5 * 60 * 60 * 1000;
ParsedDateTime s = ParsedDateTime.fromUTCTime(System.currentTimeMillis() + utc, ical);
ParsedDateTime e = ParsedDateTime.fromUTCTime(System.currentTimeMillis() + (30 * 60 * 1000) + utc, ical);
invite.setDtStart(s);
invite.setDtEnd(e);
invite.setPriority("5");
invite.setClassProp("PRI");
invite.setOrganizer(new ZOrganizer("test@zimbra.com", null));
invite.setUid(UUID.randomUUID().toString());
invite.setMethod("REQUEST");
invite.setName("Testing");
invite.setFreeBusy("B");
invite.setIsOrganizer(true);
invite.setItemType(MailItem.Type.APPOINTMENT);
invite.setUid(UUID.randomUUID().toString());
AddInviteData inviteData = mbox1.addInvite(null, invite, calendarFolder.getId());
calendarFolder = mbox1.getCalendarFolders(null, SortBy.NONE).get(0);
MsgSpec msgSpec = new MsgSpec(acct1.getId() + ":" + inviteData.calItemId + "-" + inviteData.invId);
msgSpec.setWantHtml(true);
msgSpec.setNeedCanExpand(true);
GetMsgRequest getMsgReq = new GetMsgRequest(msgSpec);
Element response = new GetMsg().handle(JaxbUtil.jaxbToElement(getMsgReq), ServiceTestUtil.getRequestContext(acct1));
Element organizer = response.getElement("m").getElement("inv").getElement("comp").getElement("or");
String organizerString = organizer.prettyPrint();
assertTrue(organizerString.contains("a=\"test@zimbra.com\" url=\"test@zimbra.com\""));
mbox1.grantAccess(null, 10, acct2.getId(), ACL.GRANTEE_USER, ACL.RIGHT_READ, null);
NewMountpointSpec mpSpec = new NewMountpointSpec("sharedcal");
mpSpec.setFlags("#");
mpSpec.setDefaultView("appoinment");
mpSpec.setFolderId("10");
mpSpec.setOwnerName("test@zimbra.com");
mpSpec.setReminderEnabled(false);
mpSpec.setPath("/Calendar");
CreateMountpointRequest createMpReq = new CreateMountpointRequest(mpSpec);
response = new CreateMountpoint().handle(JaxbUtil.jaxbToElement(createMpReq), ServiceTestUtil.getRequestContext(acct2));
String mptId = response.getElement("link").getAttribute("id");
msgSpec = new MsgSpec(acct1.getId() + ":" + inviteData.calItemId + "-" + mptId);
msgSpec.setWantHtml(true);
msgSpec.setNeedCanExpand(true);
getMsgReq = new GetMsgRequest(msgSpec);
response = new GetMsg().handle(JaxbUtil.jaxbToElement(getMsgReq), ServiceTestUtil.getRequestContext(acct2, acct1));
organizerString = response.getElement("m").prettyPrint();
assertTrue(!organizerString.contains("a=\"test@zimbra.com\" url=\"test@zimbra.com\""));
FolderActionSelector action = new FolderActionSelector(mptId, "delete");
FolderActionRequest folderActionReq = new FolderActionRequest(action);
response = new FolderAction().handle(JaxbUtil.jaxbToElement(folderActionReq), ServiceTestUtil.getRequestContext(acct2));
mbox1.revokeAccess(null, 10, acct2.getId());
}
use of com.zimbra.soap.mail.message.CreateMountpointRequest in project zm-mailbox by Zimbra.
the class TestInvite method testBug86864DelegateInboxInviteLooksLikeInvite.
public void testBug86864DelegateInboxInviteLooksLikeInvite() throws Exception {
TestUtil.createAccount(ORGANIZER);
Account attendee = TestUtil.createAccount(ATTENDEE);
Account delegate = TestUtil.createAccount(DELEGATE);
ZMailbox mboxOrganizer = TestUtil.getZMailbox(ORGANIZER);
ZMailbox mboxAttendee = TestUtil.getZMailbox(ATTENDEE);
ZMailbox mboxDelegate = TestUtil.getZMailbox(DELEGATE);
String subject = NAME_PREFIX + " for testing treatment at delegate inbox";
Date startDate = new Date(System.currentTimeMillis() + Constants.MILLIS_PER_DAY);
Date endDate = new Date(startDate.getTime() + Constants.MILLIS_PER_HOUR);
String calendarId = Integer.valueOf(Mailbox.ID_FOLDER_CALENDAR).toString();
FolderActionSelector action = new FolderActionSelector(calendarId, /* id */
"grant");
ActionGrantSelector grant = new ActionGrantSelector("rwidxa", /* perm */
"usr");
grant.setDisplayName(delegate.getName());
grant.setPassword("");
action.setGrant(grant);
FolderActionRequest folderActionReq = new FolderActionRequest(action);
FolderActionResponse folderActionResp = mboxAttendee.invokeJaxb(folderActionReq);
assertNotNull("null FolderAction Response used to share folder", folderActionResp);
ModifyPrefsRequest modPrefsReq = new ModifyPrefsRequest();
Pref fwdInvitesPref = Pref.createPrefWithNameAndValue(ZAttrProvisioning.A_zimbraPrefCalendarForwardInvitesTo, delegate.getName());
modPrefsReq.addPref(fwdInvitesPref);
Pref noAutoAddPref = Pref.createPrefWithNameAndValue(ZAttrProvisioning.A_zimbraPrefCalendarAutoAddInvites, Boolean.FALSE.toString().toUpperCase());
modPrefsReq.addPref(noAutoAddPref);
ModifyPrefsResponse modPrefsResp = mboxAttendee.invokeJaxb(modPrefsReq);
assertNotNull("null ModifyPrefs Response for forwarding calendar invites/no auto-add", modPrefsResp);
NewMountpointSpec mpSpec = new NewMountpointSpec("Shared Calendar");
mpSpec.setFlags("#");
mpSpec.setRemoteId(Mailbox.ID_FOLDER_CALENDAR);
mpSpec.setColor((byte) 4);
mpSpec.setOwnerId(attendee.getId());
mpSpec.setFolderId(Integer.valueOf(Mailbox.ID_FOLDER_USER_ROOT).toString());
mpSpec.setDefaultView(MailItem.Type.APPOINTMENT.toString());
CreateMountpointRequest createMpReq = new CreateMountpointRequest(mpSpec);
CreateMountpointResponse createMpResp = mboxDelegate.invokeJaxb(createMpReq);
assertNotNull("null ModifyPrefs Response for forwarding calendar invites", createMpResp);
TestUtil.createAppointment(mboxOrganizer, subject, attendee.getName(), startDate, endDate);
ZMessage inviteMsg = TestUtil.waitForMessage(mboxDelegate, "in:inbox " + subject);
assertNotNull("null inviteMsg in delegate inbox", inviteMsg);
MsgSpec msgSpec = new MsgSpec(inviteMsg.getId());
msgSpec.setWantHtml(true);
msgSpec.setNeedCanExpand(true);
msgSpec.setMaxInlinedLength(250000);
GetMsgRequest getMsgReq = new GetMsgRequest(msgSpec);
GetMsgResponse getMsgResp = mboxDelegate.invokeJaxb(getMsgReq);
assertNotNull("null GetMsgResponse in delegate inbox", getMsgResp);
MsgWithGroupInfo msg = getMsgResp.getMsg();
assertNotNull("null message in GetMsgResponse in delegate inbox", msg);
InviteWithGroupInfo invite = msg.getInvite();
assertNotNull("null invite in message in GetMsgResponse in delegate inbox regression to Bug 86864?", invite);
}
use of com.zimbra.soap.mail.message.CreateMountpointRequest in project zm-mailbox by Zimbra.
the class TestJaxbProvisioning method createMountpoint.
public void createMountpoint(Account acct, String localFolderName, String defaultView, String remoteZimbraId, String remoteFolderId) {
NewMountpointSpec folderSpec = new NewMountpointSpec(localFolderName);
folderSpec.setFolderId("1");
folderSpec.setDefaultView(defaultView);
folderSpec.setOwnerId(remoteZimbraId);
folderSpec.setRemoteId(Integer.parseInt(remoteFolderId.substring(remoteFolderId.indexOf(':') + 1)));
CreateMountpointRequest req = new CreateMountpointRequest(folderSpec);
try {
CreateMountpointResponse resp = prov.invokeJaxbOnTargetAccount(req, acct.getId());
assertNotNull(String.format("CreateMountpointResponse for account %s folder %s", acct.getName(), localFolderName), resp);
} catch (ServiceException e) {
fail("Unexpected exception while creating mountpoint " + e);
}
}
use of com.zimbra.soap.mail.message.CreateMountpointRequest in project zm-mailbox by Zimbra.
the class TestCalDav method createCalendarMountPoint.
public static CreateMountpointResponse createCalendarMountPoint(ZMailbox mboxSharee, Account sharer) throws ServiceException {
NewMountpointSpec mpSpec = new NewMountpointSpec("Shared Calendar");
mpSpec.setFlags("#");
mpSpec.setRemoteId(Mailbox.ID_FOLDER_CALENDAR);
mpSpec.setColor((byte) 4);
mpSpec.setOwnerId(sharer.getId());
mpSpec.setFolderId(Integer.valueOf(Mailbox.ID_FOLDER_USER_ROOT).toString());
mpSpec.setDefaultView(MailItem.Type.APPOINTMENT.toString());
CreateMountpointRequest createMpReq = new CreateMountpointRequest(mpSpec);
CreateMountpointResponse createMpResp = mboxSharee.invokeJaxb(createMpReq);
assertNotNull(String.format("CreateMountPointResponse for %s's Calendar on mbox %s", sharer.getName(), mboxSharee.getName()), createMpResp);
return createMpResp;
}
Aggregations