use of com.zimbra.cs.mime.ParsedMessage.CalendarPartInfo in project zm-mailbox by Zimbra.
the class ZAttendeeTest method resourceRsvpTest3.
@Test
public void resourceRsvpTest3() throws Exception {
InputStream is = getClass().getResourceAsStream("Calendar_NewMeetingRequest_RsvpFalse.txt");
ParsedMessage pm = new ParsedMessage(ByteUtil.getContent(is, -1), false);
CalendarPartInfo cpi = pm.getCalendarPartInfo();
Iterator<ZComponent> compIter = cpi.cal.getComponentIterator();
while (compIter.hasNext()) {
ZComponent comp = compIter.next();
List<ZProperty> properties = Lists.newArrayList(comp.getPropertyIterator());
for (ZProperty prop : properties) {
if (prop.getName().equalsIgnoreCase("ATTENDEE")) {
ZAttendee attendee = new ZAttendee(prop);
Assert.assertFalse(attendee.getRsvp());
}
}
}
}
use of com.zimbra.cs.mime.ParsedMessage.CalendarPartInfo in project zm-mailbox by Zimbra.
the class ZAttendeeTest method resourceRsvpTest2.
@Test
public void resourceRsvpTest2() throws ServiceException, IOException {
InputStream is = getClass().getResourceAsStream("Calendar_NewMeetingRequest_RsvpTrue.txt");
ParsedMessage pm = new ParsedMessage(ByteUtil.getContent(is, -1), false);
CalendarPartInfo cpi = pm.getCalendarPartInfo();
Iterator<ZComponent> compIter = cpi.cal.getComponentIterator();
while (compIter.hasNext()) {
ZComponent comp = compIter.next();
List<ZProperty> properties = Lists.newArrayList(comp.getPropertyIterator());
for (ZProperty prop : properties) {
if (prop.getName().equalsIgnoreCase("ATTENDEE")) {
ZAttendee attendee = new ZAttendee(prop);
Assert.assertTrue(attendee.getRsvp());
}
}
}
}
use of com.zimbra.cs.mime.ParsedMessage.CalendarPartInfo in project zm-mailbox by Zimbra.
the class ZAttendeeTest method resourceRsvpTest4.
@Test
public void resourceRsvpTest4() throws Exception {
InputStream is = getClass().getResourceAsStream("Calendar_ChangeMeetingRequest_WO_Rsvp.txt");
ParsedMessage pm = new ParsedMessage(ByteUtil.getContent(is, -1), false);
CalendarPartInfo cpi = pm.getCalendarPartInfo();
Iterator<ZComponent> compIter = cpi.cal.getComponentIterator();
while (compIter.hasNext()) {
ZComponent comp = compIter.next();
List<ZProperty> properties = Lists.newArrayList(comp.getPropertyIterator());
for (ZProperty prop : properties) {
if (prop.getName().equalsIgnoreCase("ATTENDEE")) {
ZAttendee attendee = new ZAttendee(prop);
Assert.assertNull(attendee.getRsvp());
}
}
}
}
use of com.zimbra.cs.mime.ParsedMessage.CalendarPartInfo in project zm-mailbox by Zimbra.
the class InviteTest method executeBasic.
/**
* Returns <tt>true</tt> if the message has a calendar part.
*/
protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context) {
if (mail instanceof DummyMailAdapter) {
return true;
}
if (!(mail instanceof ZimbraMailAdapter)) {
return false;
}
ParsedMessage pm = ((ZimbraMailAdapter) mail).getParsedMessage();
if (pm == null) {
return false;
}
CalendarPartInfo calPart = pm.getCalendarPartInfo();
if (calPart != null) {
if (mMethods.isEmpty()) {
// Test matches any invite.
return true;
}
if (calPart.method == null) {
// Method not specified in the calendar part.
return false;
}
if (mMethods.contains(calPart.method.toString())) {
// Calendar part method matches one of the methods in the test.
return true;
}
if (mMethods.contains("anyrequest") && isRequest(calPart.method)) {
return true;
}
if (mMethods.contains("anyreply") && isReply(calPart.method)) {
return true;
}
}
return false;
}
use of com.zimbra.cs.mime.ParsedMessage.CalendarPartInfo in project zm-mailbox by Zimbra.
the class Mailbox method addMessage.
private Message addMessage(OperationContext octxt, ParsedMessage pm, int folderId, boolean noICal, int flags, String[] tags, int conversationId, String rcptEmail, Message.DraftInfo dinfo, CustomMetadata customData, DeliveryContext dctxt) throws IOException, ServiceException {
// and then actually add the message
long start = ZimbraPerf.STOPWATCH_MBOX_ADD_MSG.start();
//
if (!noICal) {
try {
CalendarPartInfo cpi = pm.getCalendarPartInfo();
if (cpi != null && CalendarItem.isAcceptableInvite(getAccount(), cpi)) {
if (ICalTok.REPLY.equals(cpi.method)) {
processICalReplies(octxt, cpi.cal, null);
} else if (ICalTok.COUNTER.equals(cpi.method)) {
processICalReplies(octxt, cpi.cal, pm.getSender());
}
}
} catch (Exception e) {
ZimbraLog.calendar.warn("Error during calendar processing. Continuing with message add", e);
}
}
// Store the incoming blob if necessary.
if (dctxt == null) {
dctxt = new DeliveryContext();
}
boolean deleteMailboxSpecificBlob = false;
StoreManager sm = StoreManager.getInstance();
Blob blob = dctxt.getMailBoxSpecificBlob(mId);
if (blob == null) {
blob = dctxt.getIncomingBlob();
ZimbraLog.filter.debug("MailBoxSpecificBlob is null for mailbox %d", mId);
} else {
deleteMailboxSpecificBlob = true;
ZimbraLog.filter.debug("got MailBoxSpecificBlob for mailbox %d", mId);
}
boolean deleteIncoming = false;
if (blob == null) {
InputStream in = null;
try {
in = pm.getRawInputStream();
blob = sm.storeIncoming(in);
} finally {
ByteUtil.closeStream(in);
}
dctxt.setIncomingBlob(blob);
deleteIncoming = true;
}
StagedBlob staged = sm.stage(blob, this);
Account account = this.getAccount();
boolean localMsgMarkedRead = false;
if (account.getPrefMailForwardingAddress() != null && account.isFeatureMailForwardingEnabled() && account.isFeatureMarkMailForwardedAsRead()) {
ZimbraLog.mailbox.debug("Marking forwarded message as read.");
flags = flags & ~Flag.BITMASK_UNREAD;
localMsgMarkedRead = true;
}
lock.lock();
try {
try {
Message message = addMessageInternal(octxt, pm, folderId, noICal, flags, tags, conversationId, rcptEmail, dinfo, customData, dctxt, staged);
if (localMsgMarkedRead && account.getPrefMailSendReadReceipts().isAlways()) {
SendDeliveryReport.sendReport(account, message, true, null, null);
}
return message;
} finally {
if (deleteIncoming) {
sm.quietDelete(dctxt.getIncomingBlob());
}
if (deleteMailboxSpecificBlob) {
sm.quietDelete(dctxt.getMailBoxSpecificBlob(mId));
dctxt.clearMailBoxSpecificBlob(mId);
}
sm.quietDelete(staged);
}
} finally {
lock.release();
ZimbraPerf.STOPWATCH_MBOX_ADD_MSG.stop(start);
}
}
Aggregations