Java Code Examples for net.fortuna.ical4j.model.Property#getParameter()

The following examples show how to use net.fortuna.ical4j.model.Property#getParameter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventValidator.java    From cosmo with Apache License 2.0 6 votes vote down vote up
private static boolean areTimeZoneIdsValid(VEvent event) {
    for (String propertyName : PROPERTIES_WITH_TIMEZONES) {
        List<Property> props = event.getProperties(propertyName);
        for (Property p : props) {
            if (p != null && p.getParameter(Parameter.TZID) != null) {
                String tzId = p.getParameter(Parameter.TZID).getValue();
                if (tzId != null && timeZoneRegistry.getTimeZone(tzId) == null) {
                    LOG.warn("Unknown TZID [" + tzId + "] for event " + event);
                    return false;

                }
            }
        }
    }
    return true;
}
 
Example 2
Source File: ICalConverter.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
protected static void loadRelatedParties(List<GenericValue> relatedParties, PropertyList<Property> componentProps, Map<String, Object> context) {
    PropertyList<Property> attendees = componentProps.getProperties("ATTENDEE");
    for (GenericValue partyValue : relatedParties) {
        if ("CAL_ORGANIZER~CAL_OWNER".contains(partyValue.getString("roleTypeId"))) {
            // RFC 2445 4.6.1, 4.6.2, and 4.6.3 ORGANIZER can appear only once
            replaceProperty(componentProps, createOrganizer(partyValue, context));
        } else {
            String partyId = partyValue.getString("partyId");
            boolean newAttendee = true;
            // SCIPIO: cast not necessary
            //Attendee attendee = null;
            //Iterator<Attendee> i = UtilGenerics.cast(attendees.iterator());
            Property attendee = null;
            Iterator<Property> i = attendees.iterator();
            while (i.hasNext()) {
                attendee = i.next();
                Parameter xParameter = attendee.getParameter(partyIdXParamName);
                if (xParameter != null && partyId.equals(xParameter.getValue())) {
                    loadPartyAssignment(attendee, partyValue, context);
                    newAttendee = false;
                    break;
                }
            }
            if (newAttendee) {
                attendee = createAttendee(partyValue, context);
                componentProps.add(attendee);
            }
        }
    }
}
 
Example 3
Source File: IcalUtils.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
/**
 * Convenience function to parse date from {@link net.fortuna.ical4j.model.Property} to
 * {@link Date}
 *
 * @param dt       DATE-TIME Property from which we parse.
 * @param timeZone Timezone of the Date.
 * @return {@link java.util.Date} representation of the iCalendar value.
 */
public Date parseDate(Property dt, TimeZone timeZone) {
	if (dt == null || Strings.isEmpty(dt.getValue())) {
		return null;
	}

	String[] acceptedFormats = {"yyyyMMdd'T'HHmmss", "yyyyMMdd'T'HHmmss'Z'", "yyyyMMdd"};
	Parameter tzid = dt.getParameter(Parameter.TZID);
	if (tzid == null) {
		return parseDate(dt.getValue(), acceptedFormats, timeZone);
	} else {
		return parseDate(dt.getValue(), acceptedFormats, getTimeZone(tzid.getValue()));
	}
}
 
Example 4
Source File: ICal3ClientFilter.java    From cosmo with Apache License 2.0 5 votes vote down vote up
private void fixDateTimeProperties(Component component) {
    PropertyList<Property> props = component.getProperties();
    for(Property prop : props) {
        if(prop instanceof DateProperty || prop instanceof DateListProperty) {
            Value v = (Value) prop.getParameter(Parameter.VALUE);
            if(Value.DATE_TIME.equals(v)) {
                prop.getParameters().remove(v);
            }
        }
    }
}
 
Example 5
Source File: ICalendarService.java    From axelor-open-suite with GNU Affero General Public License v3.0 4 votes vote down vote up
protected ICalendarUser findOrCreateUser(Property source, ICalendarEvent event) {
  URI addr = null;
  if (source instanceof Organizer) {
    addr = ((Organizer) source).getCalAddress();
  }
  if (source instanceof Attendee) {
    addr = ((Attendee) source).getCalAddress();
  }
  if (addr == null) {
    return null;
  }

  String email = mailto(addr.toString(), true);
  ICalendarUserRepository repo = Beans.get(ICalendarUserRepository.class);
  ICalendarUser user = null;
  if (source instanceof Organizer) {
    user = repo.all().filter("self.email = ?1", email).fetchOne();
  } else {
    user =
        repo.all()
            .filter("self.email = ?1 AND self.event.id = ?2", email, event.getId())
            .fetchOne();
  }
  if (user == null) {
    user = new ICalendarUser();
    user.setEmail(email);
    user.setName(email);
    EmailAddress emailAddress = Beans.get(EmailAddressRepository.class).findByAddress(email);
    if (emailAddress != null
        && emailAddress.getPartner() != null
        && emailAddress.getPartner().getUser() != null) {
      user.setUser(emailAddress.getPartner().getUser());
    }
  }
  if (source.getParameter(Parameter.CN) != null) {
    user.setName(source.getParameter(Parameter.CN).getValue());
  }
  if (source.getParameter(Parameter.PARTSTAT) != null) {
    String role = source.getParameter(Parameter.PARTSTAT).getValue();
    if (role.equals("TENTATIVE")) {
      user.setStatusSelect(ICalendarUserRepository.STATUS_MAYBE);
    } else if (role.equals("ACCEPTED")) {
      user.setStatusSelect(ICalendarUserRepository.STATUS_YES);
    } else if (role.equals("DECLINED")) {
      user.setStatusSelect(ICalendarUserRepository.STATUS_NO);
    }
  }

  return user;
}