Commit 4a80de4b authored by Ricki Hirner's avatar Ricki Hirner 🐑
Browse files

Don't set ORGANIZER if there are not attendees

* don't set ORGANIZER if there are not attendees
* change some private @Getter lists to public final
parent a9495e13
......@@ -123,6 +123,10 @@ public abstract class AndroidEvent {
}
populateExceptions();
// remove ORGANIZER if there are not attendees (i.e. this is not a group-scheduled calendar entity)
if (event.attendees.isEmpty())
event.organizer = null;
return event;
} else
throw new FileNotFoundException("Locally stored event couldn't be found");
......@@ -171,7 +175,7 @@ public abstract class AndroidEvent {
String strRDate = values.getAsString(Events.RDATE);
if (!StringUtils.isEmpty(strRDate)) {
RDate rDate = (RDate)DateUtils.androidStringToRecurrenceSet(strRDate, RDate.class, allDay);
event.getRDates().add(rDate);
event.rDates.add(rDate);
}
String strExRule = values.getAsString(Events.EXRULE);
......@@ -184,7 +188,7 @@ public abstract class AndroidEvent {
String strExDate = values.getAsString(Events.EXDATE);
if (!StringUtils.isEmpty(strExDate)) {
ExDate exDate = (ExDate)DateUtils.androidStringToRecurrenceSet(strExDate, ExDate.class, allDay);
event.getExDates().add(exDate);
event.exDates.add(exDate);
}
} catch (ParseException ex) {
Constants.log.log(Level.WARNING, "Couldn't parse recurrence rules, ignoring", ex);
......@@ -303,7 +307,7 @@ public abstract class AndroidEvent {
break;
}
event.getAttendees().add(attendee);
event.attendees.add(attendee);
} catch (URISyntaxException ex) {
Constants.log.log(Level.WARNING, "Couldn't parse attendee information, ignoring", ex);
}
......@@ -315,7 +319,7 @@ public abstract class AndroidEvent {
PropertyList props = alarm.getProperties();
props.add(Action.DISPLAY);
props.add(new Description(event.summary));
event.getAlarms().add(alarm);
event.alarms.add(alarm);
}
@SuppressWarnings("Recycle")
......@@ -327,7 +331,7 @@ public abstract class AndroidEvent {
long exceptionId = c.getLong(0);
try {
AndroidEvent exception = calendar.eventFactory.newInstance(calendar, exceptionId, null);
event.getExceptions().add(exception.getEvent());
event.exceptions.add(exception.getEvent());
} catch (CalendarStorageException e) {
Constants.log.log(Level.WARNING, "Couldn't find exception details, ignoring", e);
}
......@@ -354,15 +358,15 @@ public abstract class AndroidEvent {
batch.enqueue(builder.build());
// add reminders
for (VAlarm alarm : event.getAlarms())
for (VAlarm alarm : event.alarms)
insertReminder(batch, idxEvent, alarm);
// add attendees
for (Attendee attendee : event.getAttendees())
for (Attendee attendee : event.attendees)
insertAttendee(batch, idxEvent, attendee);
// add exceptions
for (Event exception : event.getExceptions()) {
for (Event exception : event.exceptions) {
/* I guess exceptions should be inserted using Events.CONTENT_EXCEPTION_URI so that we could
benefit from some provider logic (for recurring exceptions e.g.). However, this method
has some caveats:
......@@ -399,11 +403,11 @@ public abstract class AndroidEvent {
batch.enqueue(builder.build());
// add exception reminders
for (VAlarm alarm : exception.getAlarms())
for (VAlarm alarm : exception.alarms)
insertReminder(batch, idxException, alarm);
// add exception attendees
for (Attendee attendee : exception.getAttendees())
for (Attendee attendee : exception.attendees)
insertAttendee(batch, idxException, attendee);
}
......@@ -466,19 +470,19 @@ public abstract class AndroidEvent {
recurring = true;
builder.withValue(Events.RRULE, event.rRule.getValue());
}
if (!event.getRDates().isEmpty()) {
if (!event.rDates.isEmpty()) {
recurring = true;
try {
builder.withValue(Events.RDATE, DateUtils.recurrenceSetsToAndroidString(event.getRDates(), event.isAllDay()));
builder.withValue(Events.RDATE, DateUtils.recurrenceSetsToAndroidString(event.rDates, event.isAllDay()));
} catch (ParseException e) {
Constants.log.log(Level.WARNING, "Couldn't parse RDate(s)", e);
}
}
if (event.exRule != null)
builder.withValue(Events.EXRULE, event.exRule.getValue());
if (!event.getExDates().isEmpty())
if (!event.exDates.isEmpty())
try {
builder.withValue(Events.EXDATE, DateUtils.recurrenceSetsToAndroidString(event.getExDates(), event.isAllDay()));
builder.withValue(Events.EXDATE, DateUtils.recurrenceSetsToAndroidString(event.exDates, event.isAllDay()));
} catch (ParseException e) {
Constants.log.log(Level.WARNING, "Couldn't parse ExDate(s)", e);
}
......
......@@ -206,11 +206,11 @@ public abstract class AndroidTask {
String rDate = values.getAsString(Tasks.RDATE);
if (rDate != null)
task.getRDates().add((RDate)DateUtils.androidStringToRecurrenceSet(rDate, RDate.class, allDay));
task.rDates.add((RDate)DateUtils.androidStringToRecurrenceSet(rDate, RDate.class, allDay));
String exDate = values.getAsString(Tasks.EXDATE);
if (exDate != null)
task.getExDates().add((ExDate)DateUtils.androidStringToRecurrenceSet(exDate, ExDate.class, allDay));
task.exDates.add((ExDate)DateUtils.androidStringToRecurrenceSet(exDate, ExDate.class, allDay));
String rRule = values.getAsString(Tasks.RRULE);
if (rRule != null)
......@@ -325,15 +325,15 @@ public abstract class AndroidTask {
if (task.duration != null)
builder.withValue(Tasks.DURATION, task.duration.getValue());
if (!task.getRDates().isEmpty())
if (!task.rDates.isEmpty())
try {
builder.withValue(Tasks.RDATE, DateUtils.recurrenceSetsToAndroidString(task.getRDates(), allDay));
builder.withValue(Tasks.RDATE, DateUtils.recurrenceSetsToAndroidString(task.rDates, allDay));
} catch (ParseException e) {
Constants.log.log(Level.WARNING, "Couldn't parse RDate(s)", e);
}
if (!task.getExDates().isEmpty())
if (!task.exDates.isEmpty())
try {
builder.withValue(Tasks.EXDATE, DateUtils.recurrenceSetsToAndroidString(task.getExDates(), allDay));
builder.withValue(Tasks.EXDATE, DateUtils.recurrenceSetsToAndroidString(task.exDates, allDay));
} catch (ParseException e) {
Constants.log.log(Level.WARNING, "Couldn't parse ExDate(s)", e);
}
......
......@@ -62,7 +62,6 @@ import java.util.UUID;
import java.util.logging.Level;
import lombok.Cleanup;
import lombok.Getter;
import lombok.NonNull;
public class Event extends iCalendar {
......@@ -80,10 +79,10 @@ public class Event extends iCalendar {
public Duration duration;
public RRule rRule;
public ExRule exRule;
@Getter private List<RDate> rDates = new LinkedList<>();
@Getter private List<ExDate> exDates = new LinkedList<>();
public final List<RDate> rDates = new LinkedList<>();
public final List<ExDate> exDates = new LinkedList<>();
@Getter private List<Event> exceptions = new LinkedList<>();
public final List<Event> exceptions = new LinkedList<>();
public Boolean forPublic;
public Status status;
......@@ -91,9 +90,9 @@ public class Event extends iCalendar {
public boolean opaque;
public Organizer organizer;
@Getter private List<Attendee> attendees = new LinkedList<>();
public final List<Attendee> attendees = new LinkedList<>();
@Getter private List<VAlarm> alarms = new LinkedList<>();
public final List<VAlarm> alarms = new LinkedList<>();
/**
......@@ -263,7 +262,7 @@ public class Event extends iCalendar {
e.forPublic = false;
}
e.alarms = event.getAlarms();
e.alarms.addAll(event.getAlarms());
return e;
}
......
......@@ -55,7 +55,6 @@ import java.util.Set;
import java.util.logging.Level;
import lombok.Cleanup;
import lombok.Getter;
import lombok.NonNull;
public class Task extends iCalendar {
......@@ -75,8 +74,8 @@ public class Task extends iCalendar {
public Integer percentComplete;
public RRule rRule;
@Getter private List<RDate> rDates = new LinkedList<>();
@Getter private List<ExDate> exDates = new LinkedList<>();
public final List<RDate> rDates = new LinkedList<>();
public final List<ExDate> exDates = new LinkedList<>();
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment