use of net.fortuna.ical4j.model.ParameterList in project ofbiz-framework by apache.
the class ICalConverter method loadPartyAssignment.
protected static void loadPartyAssignment(Property property, GenericValue partyAssign, Map<String, Object> context) {
getPartyUrl(property, partyAssign, context);
if (UtilValidate.isEmpty(property.getValue())) {
try {
// RFC 2445 4.8.4.1 and 4.8.4.3 Value must be a URL
property.setValue("MAILTO:ofbiz-test@example.com");
} catch (Exception e) {
Debug.logError(e, "Error while setting Property value: ", module);
}
}
ParameterList parameterList = property.getParameters();
replaceParameter(parameterList, toXParameter(partyIdXParamName, partyAssign.getString("partyId")));
replaceParameter(parameterList, new Cn(makePartyName(partyAssign)));
replaceParameter(parameterList, toParticipationStatus(partyAssign.getString("assignmentStatusId")));
}
use of net.fortuna.ical4j.model.ParameterList in project zm-mailbox by Zimbra.
the class DefaultTnefToICalendar method addAlarmComponent.
/**
* @param icalOutput
* @param reminderDelta number of minutes before Start
* @throws ParserException
* @throws URISyntaxException
* @throws IOException
* @throws ParseException
*/
private void addAlarmComponent(ContentHandler icalOutput, Integer reminderDelta) throws ParserException, URISyntaxException, IOException, ParseException {
if (reminderDelta == null) {
return;
}
icalOutput.startComponent(Component.VALARM);
IcalUtil.addProperty(icalOutput, Action.DISPLAY);
IcalUtil.addProperty(icalOutput, Property.DESCRIPTION, "Reminder", false);
String trigStr;
if (reminderDelta % 60 == 0) {
reminderDelta = reminderDelta / 60;
if (reminderDelta % 24 == 0) {
reminderDelta = reminderDelta / 24;
trigStr = String.format("-PT%dD", reminderDelta);
} else {
trigStr = String.format("-PT%dH", reminderDelta);
}
} else {
trigStr = String.format("-PT%dM", reminderDelta);
}
ParameterList trigParams = new ParameterList();
trigParams.add(Related.START);
Trigger trigger = new Trigger(trigParams, trigStr);
IcalUtil.addProperty(icalOutput, trigger);
icalOutput.endComponent(Component.VALARM);
}
use of net.fortuna.ical4j.model.ParameterList in project opencast by opencast.
the class CalendarGenerator method addEvent.
/**
* Adds an SchedulerEvent as a new entry to this iCalendar
*
* @param mp
* {@link MediaPackage} of event
* @param agentId
* the agent identifier
* @param start
* the start date
* @param end
* the end date
* @param captureAgentMetadata
* properties for capture agent metadata
*
* @return true if the event could be added.
*/
public boolean addEvent(MediaPackage mp, DublinCoreCatalog catalog, String agentId, Date start, Date end, Date lastModified, String captureAgentMetadata) {
String eventId = mp.getIdentifier().compact();
logger.debug("Creating iCaleandar VEvent from scheduled event '{}'", eventId);
DateTime startDate = new DateTime(start);
DateTime endDate = new DateTime(end);
Date marginEndDate = new org.joda.time.DateTime(endDate.getTime()).plusHours(1).toDate();
if (marginEndDate.before(new Date())) {
logger.debug("Event has already passed more than an hour, skipping!");
return false;
}
startDate.setUtc(true);
endDate.setUtc(true);
String seriesID = null;
VEvent event = new VEvent(startDate, endDate, catalog.getFirst(DublinCore.PROPERTY_TITLE));
try {
ParameterList pl = new ParameterList();
if (StringUtils.isNotEmpty(catalog.getFirst(DublinCore.PROPERTY_CREATOR))) {
pl.add(new Cn(catalog.getFirst(DublinCore.PROPERTY_CREATOR)));
}
event.getProperties().add(new Uid(eventId));
DateTime lastModifiedDate = new DateTime(lastModified);
lastModifiedDate.setUtc(true);
event.getProperties().add(new LastModified(lastModifiedDate));
// TODO Organizer should be URI (email-address?) created fake address
if (StringUtils.isNotEmpty(catalog.getFirst(DublinCore.PROPERTY_CREATOR))) {
URI organizer = new URI("mailto", catalog.getFirst(DublinCore.PROPERTY_CREATOR) + "@opencast.tld", null);
event.getProperties().add(new Organizer(pl, organizer));
}
if (StringUtils.isNotEmpty(catalog.getFirst(DublinCore.PROPERTY_DESCRIPTION))) {
event.getProperties().add(new Description(catalog.getFirst(DublinCore.PROPERTY_DESCRIPTION)));
}
event.getProperties().add(new Location(agentId));
if (StringUtils.isNotEmpty(catalog.getFirst(DublinCore.PROPERTY_IS_PART_OF))) {
seriesID = catalog.getFirst(DublinCore.PROPERTY_IS_PART_OF);
event.getProperties().add(new RelatedTo(seriesID));
}
ParameterList dcParameters = new ParameterList();
dcParameters.add(new FmtType("application/xml"));
dcParameters.add(Value.BINARY);
dcParameters.add(Encoding.BASE64);
dcParameters.add(new XParameter("X-APPLE-FILENAME", "episode.xml"));
Attach metadataAttachment = new Attach(dcParameters, catalog.toXmlString().getBytes("UTF-8"));
event.getProperties().add(metadataAttachment);
String seriesDC = getSeriesDublinCoreAsString(seriesID);
if (seriesDC != null) {
logger.debug("Attaching series {} information to event {}", seriesID, eventId);
ParameterList sDcParameters = new ParameterList();
sDcParameters.add(new FmtType("application/xml"));
sDcParameters.add(Value.BINARY);
sDcParameters.add(Encoding.BASE64);
sDcParameters.add(new XParameter("X-APPLE-FILENAME", "series.xml"));
Attach seriesAttachment = new Attach(sDcParameters, seriesDC.getBytes("UTF-8"));
event.getProperties().add(seriesAttachment);
} else {
logger.debug("No series provided for event {}.", eventId);
}
ParameterList caParameters = new ParameterList();
caParameters.add(new FmtType("application/text"));
caParameters.add(Value.BINARY);
caParameters.add(Encoding.BASE64);
caParameters.add(new XParameter("X-APPLE-FILENAME", "org.opencastproject.capture.agent.properties"));
Attach agentsAttachment = new Attach(caParameters, captureAgentMetadata.getBytes("UTF-8"));
event.getProperties().add(agentsAttachment);
} catch (Exception e) {
logger.error("Unable to add event '{}' to recording calendar: {}", eventId, ExceptionUtils.getStackTrace(e));
return false;
}
cal.getComponents().add(event);
logger.debug("new VEvent = {} ", event.toString());
return true;
}
use of net.fortuna.ical4j.model.ParameterList in project zm-mailbox by Zimbra.
the class ZoneInfo2iCalendar method toObservanceComp.
private static Observance toObservanceComp(int hintYear, RuleLine rline, boolean isStandard, Time standardOffset, Time daylightOffset, String tznameFormat) {
PropertyList props = new PropertyList();
String tzname = getObservanceName(tznameFormat, rline);
if (tzname != null) {
props.add(new TzName(tzname));
}
Time at = rline.getAt();
Time onset;
switch(at.getType()) {
case STANDARD_TIME:
if (isStandard) {
// We're moving from daylight time to standard time. In iCalendar we want hh:mm:ss in
// wall clock in the pre-transition time, so it's daylight time.
// daylight = utc + daylight offset = (standard - standard offset) + daylight offset
onset = addTimes(subtractTimes(at, standardOffset), daylightOffset);
} else {
// We're moving from standard time to daylight time. In iCalendar we want hh:mm:ss in
// wall clock in the pre-transition time, so it's standard time. at is already in
// standard time.
onset = at;
}
break;
case UTC_TIME:
if (isStandard) {
// We're moving from daylight time to standard time. In iCalendar we want hh:mm:ss in
// wall clock in the pre-transition time, so it's daylight time.
// daylight = utc + daylightOffset.
onset = addTimes(at, daylightOffset);
} else {
// We're moving from standard time to daylight time. In iCalendar we want hh:mm:ss in
// wall clock in the pre-transition time, so it's standard time.
// standard = utc + standard offset.
onset = addTimes(at, standardOffset);
}
break;
default:
// WALL_TIME
// at is already in the iCalendar style.
onset = at;
break;
}
int hh = onset.getHour();
int mm = onset.getMinute();
int ss = onset.getSecond();
if (hh >= 24) {
// Hour should be between 0 and 23, but sometimes we can get 24:00:00 from the zoneinfo source.
// Since hour part in iCalendar only allows 0-23, let's approximate any time with hour >= 24 to
// 23:59:59.
hh = 23;
mm = 59;
ss = 59;
}
// YYYYMMDD fixed to 16010101 (MS Outlook style)
props.add(getDtStart(String.format("16010101T%02d%02d%02d", hh, mm, ss)));
Time toOffset, fromOffset;
if (isStandard) {
toOffset = standardOffset;
fromOffset = daylightOffset;
} else {
toOffset = daylightOffset;
fromOffset = standardOffset;
}
props.add(new TzOffsetTo(new UtcOffset(getUtcOffset(toOffset))));
props.add(new TzOffsetFrom(new UtcOffset(getUtcOffset(fromOffset))));
int month = rline.getIn();
StringBuilder rruleVal = new StringBuilder();
rruleVal.append("FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=").append(month).append(";");
rruleVal.append(dayToICalRRulePart(hintYear, month, rline.getOn()));
try {
RRule rrule = new RRule(new ParameterList(), rruleVal.toString());
props.add(rrule);
} catch (ParseException e) {
}
if (isStandard) {
return new Standard(props);
} else {
return new Daylight(props);
}
}
use of net.fortuna.ical4j.model.ParameterList in project zm-mailbox by Zimbra.
the class IcalUtil method addProperty.
public static void addProperty(ContentHandler icalOutput, Property icalProp) throws ParserException, URISyntaxException, IOException, ParseException {
if (icalProp == null) {
return;
}
icalOutput.startProperty(icalProp.getName());
icalOutput.propertyValue(icalProp.getValue());
ParameterList plist = icalProp.getParameters();
if (plist != null) {
for (Iterator<?> it = plist.iterator(); it.hasNext(); ) {
Object currObj = it.next();
if (currObj instanceof Parameter) {
Parameter parameter = (Parameter) currObj;
icalOutput.parameter(parameter.getName(), parameter.getValue());
}
}
}
icalOutput.endProperty(icalProp.getName());
}
Aggregations