Ejemplo n.º 1
1
 protected void setClientAllday(VProperty property) {
   if (property != null) {
     // set VALUE=DATE param
     if (!property.hasParam("VALUE")) {
       property.addParam("VALUE", "DATE");
     }
     // remove TZID
     property.removeParam("TZID");
     String value = property.getValue();
     if (value.length() != 8) {
       // try to convert datetime value to date value
       try {
         Calendar calendar = Calendar.getInstance();
         SimpleDateFormat dateParser = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
         calendar.setTime(dateParser.parse(value));
         calendar.add(Calendar.HOUR_OF_DAY, 12);
         SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd");
         value = dateFormatter.format(calendar.getTime());
       } catch (ParseException e) {
         LOGGER.warn("Invalid date value in allday event: " + value);
       }
     }
     property.setValue(value);
   }
 }
Ejemplo n.º 2
0
 protected void setServerAllday(VProperty property) {
   if (vTimezone != null) {
     // set TZID param
     if (!property.hasParam("TZID")) {
       property.addParam("TZID", vTimezone.getPropertyValue("TZID"));
     }
     // remove VALUE
     property.removeParam("VALUE");
     String value = property.getValue();
     if (value.length() != 8) {
       LOGGER.warn("Invalid date value in allday event: " + value);
     }
     property.setValue(property.getValue() + "T000000");
   }
 }
Ejemplo n.º 3
0
 /**
  * Get email from property value.
  *
  * @param property property
  * @return email value
  */
 public String getEmailValue(VProperty property) {
   if (property == null) {
     return null;
   }
   String propertyValue = property.getValue();
   if (propertyValue != null
       && (propertyValue.startsWith("MAILTO:") || propertyValue.startsWith("mailto:"))) {
     return propertyValue.substring(7);
   } else {
     return propertyValue;
   }
 }
Ejemplo n.º 4
0
 protected void splitExDate(VObject vObject) {
   List<VProperty> exDateProperties = vObject.getProperties("EXDATE");
   if (exDateProperties != null) {
     for (VProperty property : exDateProperties) {
       String value = property.getValue();
       if (value.indexOf(',') >= 0) {
         // split property
         vObject.removeProperty(property);
         for (String singleValue : value.split(",")) {
           VProperty singleProperty = new VProperty("EXDATE", singleValue);
           singleProperty.setParams(property.getParams());
           vObject.addProperty(singleProperty);
         }
       }
     }
   }
 }
Ejemplo n.º 5
0
 private void fixAttendees(VObject vObject, boolean fromServer) {
   if (vObject.properties != null) {
     for (VProperty property : vObject.properties) {
       if ("ATTENDEE".equalsIgnoreCase(property.getKey())) {
         if (fromServer) {
           // If this is coming from the server, strip out RSVP for this
           // user as an attendee where the partstat is something other
           // than PARTSTAT=NEEDS-ACTION since the RSVP confuses iCal4 into
           // thinking the attendee has not replied
           if (isCurrentUser(property) && property.hasParam("RSVP", "TRUE")) {
             VProperty.Param partstat = property.getParam("PARTSTAT");
             if (partstat == null || !"NEEDS-ACTION".equals(partstat.getValue())) {
               property.removeParam("RSVP");
             }
           }
         } else {
           property.setValue(replaceIcal4Principal(property.getValue()));
         }
       }
     }
   }
 }
Ejemplo n.º 6
0
 private boolean isCurrentUser(VProperty property) {
   return property.getValue().equalsIgnoreCase("mailto:" + email);
 }