use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class CalendarUser method toProperty.
public ZProperty toProperty() throws ServiceException {
String addr = getAddress();
if (addr != null && addr.indexOf(':') < 0)
addr = "mailto:" + addr;
ZProperty prop = new ZProperty(getPropertyName(), addr);
setProperty(prop);
// x-param
for (ZParameter xparam : mXParams) {
prop.addParameter(xparam);
}
return prop;
}
use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class TextCalendarHandler method analyze.
private void analyze(boolean needCal) throws MimeHandlerException {
if (mContent != null)
return;
DataSource source = getDataSource();
if (source == null) {
mContent = "";
return;
}
InputStream is = null;
try {
is = source.getInputStream();
String charset = MimeConstants.P_CHARSET_UTF8;
String ctStr = source.getContentType();
if (ctStr != null) {
String cs = Mime.getCharset(ctStr);
if (cs != null)
charset = cs;
}
if (needCal) {
miCalendar = ZCalendarBuilder.build(is, charset);
StringBuilder buf = new StringBuilder(1024);
int maxLength = MimeHandlerManager.getIndexedTextLimit();
for (Iterator<ZComponent> compIter = miCalendar.getComponentIterator(); compIter.hasNext() && buf.length() < maxLength; ) {
ZComponent comp = compIter.next();
for (Iterator<ZProperty> propIter = comp.getPropertyIterator(); propIter.hasNext(); ) {
ZProperty prop = propIter.next();
if (sIndexedProps.contains(prop.getName())) {
String value = prop.getValue();
if (value != null && value.length() > 0) {
if (buf.length() > 0)
buf.append(' ');
buf.append(value);
}
}
}
}
mContent = buf.toString();
} else {
IcsParseHandler handler = new IcsParseHandler();
ZCalendarBuilder.parse(is, charset, handler);
mContent = handler.getContent();
}
} catch (Exception e) {
mContent = "";
ZimbraLog.index.warn("error reading text/calendar mime part", e);
throw new MimeHandlerException(e);
} finally {
ByteUtil.closeStream(is);
}
}
use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class TestCalDav method makeFreeBusyRequestIcal.
public String makeFreeBusyRequestIcal(Account organizer, List<Account> attendees, Date start, Date end) throws IOException {
ZVCalendar vcal = new ZVCalendar();
vcal.addVersionAndProdId();
vcal.addProperty(new ZProperty(ICalTok.METHOD, ICalTok.REQUEST.toString()));
ZComponent vfreebusy = new ZComponent(ICalTok.VFREEBUSY);
ParsedDateTime dtstart = ParsedDateTime.fromUTCTime(start.getTime());
vfreebusy.addProperty(dtstart.toProperty(ICalTok.DTSTART, false));
ParsedDateTime dtend = ParsedDateTime.fromUTCTime(end.getTime());
vfreebusy.addProperty(dtend.toProperty(ICalTok.DTEND, false));
vfreebusy.addProperty(new ZProperty(ICalTok.DTSTAMP, "20140108T224700Z"));
vfreebusy.addProperty(new ZProperty(ICalTok.UID, "d123f102-42a7-4283-b025-3376dabe53b3"));
vfreebusy.addProperty(organizer(organizer));
for (Account attendee : attendees) {
vfreebusy.addProperty(new ZProperty(ICalTok.ATTENDEE, "mailto:" + attendee.getName()));
}
vcal.addComponent(vfreebusy);
StringWriter calWriter = new StringWriter();
vcal.toICalendar(calWriter);
String icalString = calWriter.toString();
Closeables.closeQuietly(calWriter);
return icalString;
}
use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class TestCalDav method exampleCancelIcal.
public String exampleCancelIcal(Account organizer, Account attendee1, Account attendee2) throws IOException {
ZVCalendar vcal = new ZVCalendar();
vcal.addVersionAndProdId();
vcal.addProperty(new ZProperty(ICalTok.METHOD, ICalTok.CANCEL.toString()));
ICalTimeZone tz = ICalTimeZone.lookupByTZID("Africa/Harare");
vcal.addComponent(tz.newToVTimeZone());
ZComponent vevent = new ZComponent(ICalTok.VEVENT);
ParsedDateTime dtstart = parsedDateTime(2020, java.util.Calendar.APRIL, 1, 9, 0, tz);
vevent.addProperty(dtstart.toProperty(ICalTok.DTSTART, false));
ParsedDateTime dtend = parsedDateTime(2020, java.util.Calendar.APRIL, 1, 13, 0, tz);
vevent.addProperty(dtend.toProperty(ICalTok.DTEND, false));
vevent.addProperty(new ZProperty(ICalTok.DTSTAMP, "20140108T224700Z"));
vevent.addProperty(new ZProperty(ICalTok.SUMMARY, "Meeting for fun"));
vevent.addProperty(new ZProperty(ICalTok.UID, "d123f102-42a7-4283-b025-3376dabe53b3"));
vevent.addProperty(new ZProperty(ICalTok.STATUS, ICalTok.CANCELLED.toString()));
vevent.addProperty(new ZProperty(ICalTok.SEQUENCE, "1"));
vevent.addProperty(organizer(organizer));
vevent.addProperty(attendee(attendee1, ICalTok.REQ_PARTICIPANT, ICalTok.INDIVIDUAL, ICalTok.NEEDS_ACTION));
vevent.addProperty(attendee(attendee2, ICalTok.REQ_PARTICIPANT, ICalTok.INDIVIDUAL, ICalTok.NEEDS_ACTION));
vcal.addComponent(vevent);
StringWriter calWriter = new StringWriter();
vcal.toICalendar(calWriter);
String icalString = calWriter.toString();
Closeables.closeQuietly(calWriter);
return icalString;
}
use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class TestCalDav method simpleMeeting.
public ZVCalendar simpleMeeting(Account organizer, List<MailTarget> attendees, String uid, String seq, int startHour) throws IOException {
ZVCalendar vcal = new ZVCalendar();
vcal.addVersionAndProdId();
vcal.addProperty(new ZProperty(ICalTok.METHOD, ICalTok.PUBLISH.toString()));
ICalTimeZone tz = ICalTimeZone.lookupByTZID("Africa/Harare");
vcal.addComponent(tz.newToVTimeZone());
ZComponent vevent = new ZComponent(ICalTok.VEVENT);
ParsedDateTime dtstart = parsedDateTime(2020, java.util.Calendar.APRIL, 1, startHour, 0, tz);
vevent.addProperty(dtstart.toProperty(ICalTok.DTSTART, false));
ParsedDateTime dtend = parsedDateTime(2020, java.util.Calendar.APRIL, 1, startHour + 4, 0, tz);
vevent.addProperty(dtend.toProperty(ICalTok.DTEND, false));
vevent.addProperty(new ZProperty(ICalTok.DTSTAMP, "20150108T224700Z"));
vevent.addProperty(new ZProperty(ICalTok.SUMMARY, "Simple Meeting"));
vevent.addProperty(new ZProperty(ICalTok.UID, uid));
vevent.addProperty(new ZProperty(ICalTok.STATUS, ICalTok.CONFIRMED.toString()));
vevent.addProperty(new ZProperty(ICalTok.SEQUENCE, seq));
vevent.addProperty(organizer(organizer));
for (MailTarget att : attendees) {
if (att.getId().equals(organizer.getId())) {
vevent.addProperty(attendee(att, ICalTok.REQ_PARTICIPANT, ICalTok.INDIVIDUAL, ICalTok.ACCEPTED));
} else {
vevent.addProperty(attendee(att, ICalTok.REQ_PARTICIPANT, ICalTok.INDIVIDUAL, ICalTok.NEEDS_ACTION));
}
}
vcal.addComponent(vevent);
return vcal;
}
Aggregations