Skip to content

Commit

Permalink
Merge pull request #146 from ssams/improve-allprop-compat-DAViCal
Browse files Browse the repository at this point in the history
query generator: use allprop tag from CALDAV namespace instead of DAV for generating calendar-data for the query.
  • Loading branch information
TheAntimist committed Jan 17, 2023
2 parents 93f9e4d + b69bd90 commit 6c84f98
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/main/java/com/github/caldav4j/util/GenerateQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,15 @@ private Comp getComp() {
Comp vEventComp = new Comp();
vEventComp.setName(requestedComponent);

for (String propertyName : requestedComponentProperties) {
// add properties to VCALENDAR.VEVENT
vEventComp.addProp(
new CalDAVProp(
propertyName, false, false)); // @see modification to CalDAVProp
if (requestedComponentProperties.isEmpty()) {
vEventComp.setAllProp(true);
} else {
for (String propertyName : requestedComponentProperties) {
// add properties to VCALENDAR.VEVENT
vEventComp.addProp(
new CalDAVProp(
propertyName, false, false)); // @see modification to CalDAVProp
}
}
// add only one component...maybe more ;)
List<Comp> comps = new ArrayList<>();
Expand All @@ -206,7 +210,10 @@ private Comp getComp() {
log.warn("Comp not valid");
}
vCalendarComp.setComps(comps);
} else {
vCalendarComp.setAllProp(true);
}

return vCalendarComp;
}

Expand Down Expand Up @@ -377,9 +384,7 @@ public CalendarQuery generate() throws CalDAV4JException {

CalendarQuery query = new CalendarQuery();
query.addProperty(CalDAVConstants.DNAME_GETETAG);
if (allProp) {
query.addProperty(CalDAVConstants.DNAME_ALLPROP);
}

if (!noCalendarData) {
// TODO limit-recurrence-set
CalendarData calendarData = new CalendarData();
Expand All @@ -392,6 +397,12 @@ public CalendarQuery generate() throws CalDAV4JException {

query.setCalendarDataProp(calendarData);
} else {
if (allProp) {
// only set the allprop tag if no calendar-data is included, otherwise it's
// set on the calendar-data comp if needed
query.addProperty(CalDAVConstants.DNAME_ALLPROP);
}

if (this.recurrenceSetEnd != null || this.recurrenceSetStart != null) {
throw new CalDAV4JProtocolException(
"Bad query: you set noCalendarData but you have limit-recurrence-set");
Expand Down

0 comments on commit 6c84f98

Please sign in to comment.