use of net.fortuna.ical4j.model.parameter.SentBy in project bw-calendar-engine by Bedework.
the class IcalUtil method setOrganizer.
/**
* @param val
* @return Organizer
* @throws Throwable
*/
public static Organizer setOrganizer(final BwOrganizer val) throws Throwable {
ParameterList pars = new ParameterList();
String temp = val.getScheduleStatus();
if (temp != null) {
pars.add(new ScheduleStatus(temp));
}
temp = val.getCn();
if (temp != null) {
pars.add(new Cn(temp));
}
temp = val.getDir();
if (temp != null) {
pars.add(new Dir(temp));
}
temp = val.getLanguage();
if (temp != null) {
pars.add(new Language(temp));
}
temp = val.getSentBy();
if (temp != null) {
pars.add(new SentBy(temp));
}
Organizer prop = new Organizer(pars, val.getOrganizerUri());
return prop;
}
use of net.fortuna.ical4j.model.parameter.SentBy in project bw-calendar-engine by Bedework.
the class IcalUtil method setAttendeeVoter.
/**
* make an attendee
*
* @param val
* @return Attendee
* @throws Throwable
*/
private static void setAttendeeVoter(final BwAttendee val, final ParameterList pars) throws Throwable {
if (val.getRsvp()) {
pars.add(Rsvp.TRUE);
}
String temp = val.getCn();
if (temp != null) {
pars.add(new Cn(temp));
}
temp = val.getScheduleStatus();
if (temp != null) {
pars.add(new ScheduleStatus(temp));
}
temp = val.getCuType();
if (temp != null) {
pars.add(new CuType(temp));
}
temp = val.getDelegatedFrom();
if (temp != null) {
pars.add(new DelegatedFrom(temp));
}
temp = val.getDelegatedTo();
if (temp != null) {
pars.add(new DelegatedTo(temp));
}
temp = val.getDir();
if (temp != null) {
pars.add(new Dir(temp));
}
temp = val.getLanguage();
if (temp != null) {
pars.add(new Language(temp));
}
temp = val.getMember();
if (temp != null) {
pars.add(new Member(temp));
}
temp = val.getRole();
if (temp != null) {
pars.add(new Role(temp));
}
temp = val.getSentBy();
if (temp != null) {
pars.add(new SentBy(temp));
}
}
use of net.fortuna.ical4j.model.parameter.SentBy in project zm-mailbox by Zimbra.
the class DefaultTnefToICalendar method addAttendees.
/**
* @param icalOutput
* @param mimeMsg
* @param partstat
* @param replyWanted
* @throws ParserException
* @throws URISyntaxException
* @throws IOException
* @throws ParseException
* @throws MessagingException
*/
private void addAttendees(ContentHandler icalOutput, MimeMessage mimeMsg, PartStat partstat, boolean replyWanted) throws ParserException, URISyntaxException, IOException, ParseException, MessagingException {
// ATTENDEEs
InternetAddress firstFromIA = null;
String firstFromEmailAddr = null;
// Use for SENT-BY if applicable
String senderMailto = null;
String senderCn = null;
javax.mail.Address[] toRecips = null;
javax.mail.Address[] ccRecips = null;
javax.mail.Address[] bccRecips = null;
javax.mail.Address[] msgFroms = null;
javax.mail.Address msgSender = null;
if (mimeMsg != null) {
toRecips = mimeMsg.getRecipients(javax.mail.Message.RecipientType.TO);
ccRecips = mimeMsg.getRecipients(javax.mail.Message.RecipientType.CC);
bccRecips = mimeMsg.getRecipients(javax.mail.Message.RecipientType.BCC);
msgFroms = mimeMsg.getFrom();
msgSender = mimeMsg.getSender();
}
if (msgFroms != null) {
if (msgFroms.length != 1) {
sLog.debug(msgFroms.length + " From: recipients for " + method.getValue());
}
if (msgFroms.length >= 1) {
firstFromIA = (InternetAddress) msgFroms[0];
firstFromEmailAddr = firstFromIA.getAddress();
}
if (msgSender != null) {
String senderAddr = msgSender.toString();
if (msgSender instanceof InternetAddress) {
InternetAddress senderIA = (InternetAddress) msgSender;
senderAddr = senderIA.getAddress();
senderCn = senderIA.getPersonal();
if (!firstFromIA.equals(senderIA)) {
senderMailto = "Mailto:" + senderAddr;
}
}
}
}
if (method.equals(Method.REPLY) || method.equals(Method.COUNTER)) {
// from ATTENDEE to ORGANIZER
if (toRecips != null) {
if (toRecips.length != 1) {
sLog.debug(toRecips.length + " To: recipients for " + method.getValue());
}
if (toRecips.length >= 1) {
InternetAddress ia = (InternetAddress) toRecips[0];
String email = ia.getAddress();
String displayName = ia.getPersonal();
icalOutput.startProperty(Property.ORGANIZER);
icalOutput.propertyValue("Mailto:" + email);
if (displayName != null) {
icalOutput.parameter(Parameter.CN, displayName);
}
icalOutput.endProperty(Property.ORGANIZER);
}
}
if (firstFromEmailAddr != null) {
String displayName = firstFromIA.getPersonal();
icalOutput.startProperty(Property.ATTENDEE);
icalOutput.propertyValue("Mailto:" + firstFromEmailAddr);
if (displayName != null) {
icalOutput.parameter(Parameter.CN, displayName);
}
icalOutput.parameter(Parameter.CUTYPE, CuType.INDIVIDUAL.getValue());
if (partstat != null) {
icalOutput.parameter(Parameter.PARTSTAT, partstat.getValue());
}
if (senderMailto != null) {
icalOutput.parameter(Parameter.SENT_BY, senderMailto);
}
icalOutput.endProperty(Property.ATTENDEE);
}
} else {
// ORGANIZER to ATTENDEEs - REQUEST or CANCEL
InternetAddress organizerEmail = null;
if (firstFromEmailAddr != null) {
SentBy sentBy = null;
Cn cn = null;
if (senderMailto != null) {
sentBy = new SentBy(senderMailto);
}
organizerEmail = firstFromIA;
String displayName = firstFromIA.getPersonal();
if ((displayName != null) && (!displayName.equals(firstFromEmailAddr))) {
cn = new Cn(displayName);
}
Organizer organizer = new Organizer();
organizer.setValue("Mailto:" + firstFromEmailAddr);
if (cn != null) {
organizer.getParameters().add(cn);
}
if (sentBy != null) {
organizer.getParameters().add(sentBy);
}
IcalUtil.addProperty(icalOutput, organizer);
if (icalType == ICALENDAR_TYPE.VEVENT) {
// Assumption - ORGANIZER is an attendee and is attending.
Attendee attendee = new Attendee("Mailto:" + firstFromEmailAddr);
if (cn != null) {
attendee.getParameters().add(cn);
}
attendee.getParameters().add(CuType.INDIVIDUAL);
attendee.getParameters().add(Role.REQ_PARTICIPANT);
if (!method.equals(Method.CANCEL)) {
PartStat orgPartstat = PartStat.ACCEPTED;
if (ccRecips != null) {
for (Address a : ccRecips) {
InternetAddress ia = (InternetAddress) a;
if (organizerEmail.equals(ia)) {
orgPartstat = PartStat.TENTATIVE;
break;
}
}
}
attendee.getParameters().add(orgPartstat);
}
// Was including SENT-BY but probably not appropriate
// for a request
IcalUtil.addProperty(icalOutput, attendee);
}
}
if (toRecips != null) {
for (Address a : toRecips) {
InternetAddress ia = (InternetAddress) a;
if ((organizerEmail != null) && organizerEmail.equals(ia)) {
// No need to add the information twice
continue;
}
addAttendee(icalOutput, ia, Role.REQ_PARTICIPANT, CuType.INDIVIDUAL, partstat, replyWanted);
}
}
if (ccRecips != null) {
for (Address a : ccRecips) {
InternetAddress ia = (InternetAddress) a;
if ((organizerEmail != null) && organizerEmail.equals(ia)) {
// No need to add the information twice
continue;
}
addAttendee(icalOutput, ia, Role.OPT_PARTICIPANT, CuType.INDIVIDUAL, partstat, replyWanted);
}
}
if (bccRecips != null) {
for (Address a : bccRecips) {
InternetAddress ia = (InternetAddress) a;
addAttendee(icalOutput, ia, Role.NON_PARTICIPANT, CuType.RESOURCE, partstat, replyWanted);
}
}
}
if (senderMailto != null) {
XProperty msOlkSender = new XProperty("X-MS-OLK-SENDER", senderMailto);
if (senderCn != null) {
Cn cn = new Cn(senderCn);
msOlkSender.getParameters().add(cn);
}
IcalUtil.addProperty(icalOutput, msOlkSender);
}
}
Aggregations