mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 11:42:23 -05:00
Workaroung for Lightning bug https://bugzilla.mozilla.org/show_bug.cgi?id=474112:
do not pretty print Caldav XML responses (remove non mandatory spaces and CRLF) git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@299 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
cbbbc13d05
commit
b84a2974f0
@ -255,22 +255,22 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
|
|
||||||
protected void appendEventResponse(StringBuilder buffer, CaldavRequest request, ExchangeSession.Event event) throws IOException {
|
protected void appendEventResponse(StringBuilder buffer, CaldavRequest request, ExchangeSession.Event event) throws IOException {
|
||||||
String eventPath = event.getPath().replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
String eventPath = event.getPath().replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
||||||
buffer.append("<D:response>\n");
|
buffer.append("<D:response>");
|
||||||
buffer.append(" <D:href>/users/").append(session.getEmail()).append("/calendar").append(eventPath).append("</D:href>\n");
|
buffer.append("<D:href>/users/").append(session.getEmail()).append("/calendar").append(eventPath).append("</D:href>");
|
||||||
buffer.append(" <D:propstat>\n");
|
buffer.append("<D:propstat>");
|
||||||
buffer.append(" <D:prop>\n");
|
buffer.append("<D:prop>");
|
||||||
if (request.hasProperty("calendar-data")) {
|
if (request.hasProperty("calendar-data")) {
|
||||||
String ics = event.getICS();
|
String ics = event.getICS();
|
||||||
if (ics != null && ics.length() > 0) {
|
if (ics != null && ics.length() > 0) {
|
||||||
ics = ics.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
ics = ics.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
||||||
buffer.append(" <C:calendar-data xmlns:C=\"urn:ietf:params:xml:ns:caldav\"\n");
|
buffer.append("<C:calendar-data xmlns:C=\"urn:ietf:params:xml:ns:caldav\"");
|
||||||
buffer.append(" C:content-type=\"text/calendar\" C:version=\"2.0\">");
|
buffer.append(" C:content-type=\"text/calendar\" C:version=\"2.0\">");
|
||||||
buffer.append(ics);
|
buffer.append(ics);
|
||||||
buffer.append("</C:calendar-data>\n");
|
buffer.append("</C:calendar-data>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (request.hasProperty("getetag")) {
|
if (request.hasProperty("getetag")) {
|
||||||
buffer.append(" <D:getetag>").append(event.getEtag()).append("</D:getetag>\n");
|
buffer.append("<D:getetag>").append(event.getEtag()).append("</D:getetag>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
buffer.append("<D:resourcetype/>");
|
buffer.append("<D:resourcetype/>");
|
||||||
@ -278,94 +278,94 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
if (request.hasProperty("displayname")) {
|
if (request.hasProperty("displayname")) {
|
||||||
buffer.append("<D:displayname>").append(eventPath).append("</D:displayname>");
|
buffer.append("<D:displayname>").append(eventPath).append("</D:displayname>");
|
||||||
}
|
}
|
||||||
buffer.append(" </D:prop>\n");
|
buffer.append("</D:prop>");
|
||||||
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
|
buffer.append("<D:status>HTTP/1.1 200 OK</D:status>");
|
||||||
buffer.append(" </D:propstat>\n");
|
buffer.append("</D:propstat>");
|
||||||
buffer.append(" </D:response>\n");
|
buffer.append("</D:response>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendCalendar(StringBuilder buffer, String principal, CaldavRequest request) throws IOException {
|
public void appendCalendar(StringBuilder buffer, String principal, CaldavRequest request) throws IOException {
|
||||||
buffer.append(" <D:response>\n");
|
buffer.append("<D:response>");
|
||||||
buffer.append(" <D:href>/users/").append(principal).append("/calendar</D:href>\n");
|
buffer.append("<D:href>/users/").append(principal).append("/calendar</D:href>");
|
||||||
buffer.append(" <D:propstat>\n");
|
buffer.append("<D:propstat>");
|
||||||
buffer.append(" <D:prop>\n");
|
buffer.append("<D:prop>");
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
buffer.append(" <D:resourcetype>\n");
|
buffer.append("<D:resourcetype>");
|
||||||
buffer.append(" <D:collection/>\n");
|
buffer.append("<D:collection/>");
|
||||||
buffer.append(" <C:calendar xmlns:C=\"urn:ietf:params:xml:ns:caldav\"/>\n");
|
buffer.append("<C:calendar xmlns:C=\"urn:ietf:params:xml:ns:caldav\"/>");
|
||||||
buffer.append(" </D:resourcetype>\n");
|
buffer.append("</D:resourcetype>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("owner")) {
|
if (request.hasProperty("owner")) {
|
||||||
buffer.append(" <D:owner>\n");
|
buffer.append("<D:owner>");
|
||||||
buffer.append(" <D:href>/principals/users/").append(principal).append("</D:href>\n");
|
buffer.append("<D:href>/principals/users/").append(principal).append("</D:href>");
|
||||||
buffer.append(" </D:owner>\n");
|
buffer.append("</D:owner>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("getetag")) {
|
if (request.hasProperty("getetag")) {
|
||||||
buffer.append("<D:getetag>")
|
buffer.append("<D:getetag>")
|
||||||
.append(session.getCalendarEtag())
|
.append(session.getCalendarEtag())
|
||||||
.append("</D:getetag>\n");
|
.append("</D:getetag>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("getctag")) {
|
if (request.hasProperty("getctag")) {
|
||||||
buffer.append("<CS:getctag xmlns:CS=\"http://calendarserver.org/ns/\">")
|
buffer.append("<CS:getctag xmlns:CS=\"http://calendarserver.org/ns/\">")
|
||||||
.append(base64Encode(session.getCalendarCtag()))
|
.append(base64Encode(session.getCalendarCtag()))
|
||||||
.append("</CS:getctag>\n");
|
.append("</CS:getctag>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("displayname")) {
|
if (request.hasProperty("displayname")) {
|
||||||
buffer.append("<D:displayname>calendar</D:displayname>");
|
buffer.append("<D:displayname>calendar</D:displayname>");
|
||||||
}
|
}
|
||||||
buffer.append(" </D:prop>\n");
|
buffer.append("</D:prop>");
|
||||||
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
|
buffer.append("<D:status>HTTP/1.1 200 OK</D:status>");
|
||||||
buffer.append(" </D:propstat>\n");
|
buffer.append("</D:propstat>");
|
||||||
buffer.append(" </D:response>\n");
|
buffer.append("</D:response>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendInbox(StringBuilder buffer, String principal, CaldavRequest request) throws IOException {
|
public void appendInbox(StringBuilder buffer, String principal, CaldavRequest request) throws IOException {
|
||||||
buffer.append(" <D:response>\n");
|
buffer.append("<D:response>");
|
||||||
buffer.append(" <D:href>/users/").append(principal).append("/inbox</D:href>\n");
|
buffer.append("<D:href>/users/").append(principal).append("/inbox</D:href>");
|
||||||
buffer.append(" <D:propstat>\n");
|
buffer.append("<D:propstat>");
|
||||||
buffer.append(" <D:prop>\n");
|
buffer.append("<D:prop>");
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
buffer.append(" <D:resourcetype>\n");
|
buffer.append("<D:resourcetype>");
|
||||||
buffer.append(" <D:collection/>\n");
|
buffer.append("<D:collection/>");
|
||||||
buffer.append(" <C:schedule-inbox xmlns:C=\"urn:ietf:params:xml:ns:caldav\"/>\n");
|
buffer.append("<C:schedule-inbox xmlns:C=\"urn:ietf:params:xml:ns:caldav\"/>");
|
||||||
buffer.append(" </D:resourcetype>\n");
|
buffer.append("</D:resourcetype>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("getctag")) {
|
if (request.hasProperty("getctag")) {
|
||||||
buffer.append(" <CS:getctag xmlns:CS=\"http://calendarserver.org/ns/\">0</CS:getctag>\n");
|
buffer.append("<CS:getctag xmlns:CS=\"http://calendarserver.org/ns/\">0</CS:getctag>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("displayname")) {
|
if (request.hasProperty("displayname")) {
|
||||||
buffer.append("<D:displayname>inbox</D:displayname>");
|
buffer.append("<D:displayname>inbox</D:displayname>");
|
||||||
}
|
}
|
||||||
buffer.append(" </D:prop>\n");
|
buffer.append("</D:prop>");
|
||||||
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
|
buffer.append("<D:status>HTTP/1.1 200 OK</D:status>");
|
||||||
buffer.append(" </D:propstat>\n");
|
buffer.append("</D:propstat>");
|
||||||
buffer.append(" </D:response>\n");
|
buffer.append("</D:response>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendOutbox(StringBuilder buffer, String principal, CaldavRequest request) throws IOException {
|
public void appendOutbox(StringBuilder buffer, String principal, CaldavRequest request) throws IOException {
|
||||||
buffer.append(" <D:response>\n");
|
buffer.append("<D:response>");
|
||||||
buffer.append(" <D:href>/users/").append(principal).append("/outbox</D:href>\n");
|
buffer.append("<D:href>/users/").append(principal).append("/outbox</D:href>");
|
||||||
buffer.append(" <D:propstat>\n");
|
buffer.append("<D:propstat>");
|
||||||
buffer.append(" <D:prop>\n");
|
buffer.append("<D:prop>");
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
buffer.append(" <D:resourcetype>\n");
|
buffer.append("<D:resourcetype>");
|
||||||
buffer.append(" <D:collection/>\n");
|
buffer.append("<D:collection/>");
|
||||||
buffer.append(" <C:schedule-outbox xmlns:C=\"urn:ietf:params:xml:ns:caldav\"/>\n");
|
buffer.append("<C:schedule-outbox xmlns:C=\"urn:ietf:params:xml:ns:caldav\"/>");
|
||||||
buffer.append(" </D:resourcetype>\n");
|
buffer.append("</D:resourcetype>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("getctag")) {
|
if (request.hasProperty("getctag")) {
|
||||||
buffer.append(" <CS:getctag xmlns:CS=\"http://calendarserver.org/ns/\">0</CS:getctag>\n");
|
buffer.append("<CS:getctag xmlns:CS=\"http://calendarserver.org/ns/\">0</CS:getctag>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("displayname")) {
|
if (request.hasProperty("displayname")) {
|
||||||
buffer.append("<D:displayname>outbox</D:displayname>");
|
buffer.append("<D:displayname>outbox</D:displayname>");
|
||||||
}
|
}
|
||||||
buffer.append(" </D:prop>\n");
|
buffer.append("</D:prop>");
|
||||||
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
|
buffer.append("<D:status>HTTP/1.1 200 OK</D:status>");
|
||||||
buffer.append(" </D:propstat>\n");
|
buffer.append("</D:propstat>");
|
||||||
buffer.append(" </D:response>\n");
|
buffer.append("</D:response>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendGetRoot() throws IOException {
|
public void sendGetRoot() throws IOException {
|
||||||
@ -378,35 +378,35 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
|
|
||||||
public void sendInbox(CaldavRequest request, String principal) throws IOException {
|
public void sendInbox(CaldavRequest request, String principal) throws IOException {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n");
|
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">");
|
||||||
appendInbox(buffer, principal, request);
|
appendInbox(buffer, principal, request);
|
||||||
buffer.append("</D:multistatus>\n");
|
buffer.append("</D:multistatus>");
|
||||||
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reportInbox() throws IOException {
|
public void reportInbox() throws IOException {
|
||||||
// inbox is always empty
|
// inbox is always empty
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||||
"<D:multistatus xmlns:D=\"DAV:\">\n");
|
"<D:multistatus xmlns:D=\"DAV:\">");
|
||||||
buffer.append("</D:multistatus>");
|
buffer.append("</D:multistatus>");
|
||||||
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendOutbox(CaldavRequest request, String principal) throws IOException {
|
public void sendOutbox(CaldavRequest request, String principal) throws IOException {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n");
|
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">");
|
||||||
appendOutbox(buffer, principal, request);
|
appendOutbox(buffer, principal, request);
|
||||||
buffer.append("</D:multistatus>\n");
|
buffer.append("</D:multistatus>");
|
||||||
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendCalendar(CaldavRequest request, int depth, String principal) throws IOException {
|
public void sendCalendar(CaldavRequest request, int depth, String principal) throws IOException {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n");
|
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">");
|
||||||
appendCalendar(buffer, principal, request);
|
appendCalendar(buffer, principal, request);
|
||||||
if (depth == 1) {
|
if (depth == 1) {
|
||||||
DavGatewayTray.debug("Searching calendar events...");
|
DavGatewayTray.debug("Searching calendar events...");
|
||||||
@ -414,7 +414,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
DavGatewayTray.debug("Found "+events.size()+" calendar events");
|
DavGatewayTray.debug("Found "+events.size()+" calendar events");
|
||||||
appendEventsResponses(buffer, request, events);
|
appendEventsResponses(buffer, request, events);
|
||||||
}
|
}
|
||||||
buffer.append("</D:multistatus>\n");
|
buffer.append("</D:multistatus>");
|
||||||
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,18 +452,18 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||||
"<D:multistatus xmlns:D=\"DAV:\">\n");
|
"<D:multistatus xmlns:D=\"DAV:\">");
|
||||||
appendEventsResponses(buffer, request, events);
|
appendEventsResponses(buffer, request, events);
|
||||||
|
|
||||||
// send not found events errors
|
// send not found events errors
|
||||||
for (String href : notFound) {
|
for (String href : notFound) {
|
||||||
buffer.append(" <D:response>\n");
|
buffer.append("<D:response>");
|
||||||
buffer.append(" <D:href>").append(href).append("</D:href>\n");
|
buffer.append("<D:href>").append(href).append("</D:href>");
|
||||||
buffer.append(" <D:propstat>\n");
|
buffer.append("<D:propstat>");
|
||||||
buffer.append(" <D:status>HTTP/1.1 404 Not Found</D:status>\n");
|
buffer.append("<D:status>HTTP/1.1 404 Not Found</D:status>");
|
||||||
buffer.append(" </D:propstat>\n");
|
buffer.append("</D:propstat>");
|
||||||
buffer.append(" </D:response>\n");
|
buffer.append("</D:response>");
|
||||||
}
|
}
|
||||||
buffer.append("</D:multistatus>");
|
buffer.append("</D:multistatus>");
|
||||||
|
|
||||||
@ -472,87 +472,87 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
|
|
||||||
public void sendUserRoot(CaldavRequest request, int depth, String principal) throws IOException {
|
public void sendUserRoot(CaldavRequest request, int depth, String principal) throws IOException {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n");
|
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">");
|
||||||
buffer.append(" <D:response>\n");
|
buffer.append("<D:response>");
|
||||||
buffer.append(" <D:href>/users/").append(principal).append("</D:href>\n");
|
buffer.append("<D:href>/users/").append(principal).append("</D:href>");
|
||||||
buffer.append(" <D:propstat>\n");
|
buffer.append("<D:propstat>");
|
||||||
buffer.append(" <D:prop>\n");
|
buffer.append("<D:prop>");
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
buffer.append(" <D:resourcetype>\n");
|
buffer.append("<D:resourcetype>");
|
||||||
buffer.append(" <D:collection/>\n");
|
buffer.append("<D:collection/>");
|
||||||
buffer.append(" </D:resourcetype>\n");
|
buffer.append("</D:resourcetype>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("displayname")) {
|
if (request.hasProperty("displayname")) {
|
||||||
buffer.append("<D:displayname>").append(principal).append("</D:displayname>");
|
buffer.append("<D:displayname>").append(principal).append("</D:displayname>");
|
||||||
}
|
}
|
||||||
buffer.append(" </D:prop>\n");
|
buffer.append("</D:prop>");
|
||||||
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
|
buffer.append("<D:status>HTTP/1.1 200 OK</D:status>");
|
||||||
buffer.append(" </D:propstat>\n");
|
buffer.append("</D:propstat>");
|
||||||
buffer.append(" </D:response>\n");
|
buffer.append("</D:response>");
|
||||||
if (depth == 1) {
|
if (depth == 1) {
|
||||||
appendInbox(buffer, principal, request);
|
appendInbox(buffer, principal, request);
|
||||||
appendOutbox(buffer, principal, request);
|
appendOutbox(buffer, principal, request);
|
||||||
appendCalendar(buffer, principal, request);
|
appendCalendar(buffer, principal, request);
|
||||||
}
|
}
|
||||||
buffer.append("</D:multistatus>\n");
|
buffer.append("</D:multistatus>");
|
||||||
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendRoot(CaldavRequest request) throws IOException {
|
public void sendRoot(CaldavRequest request) throws IOException {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n");
|
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">");
|
||||||
buffer.append(" <D:response>\n");
|
buffer.append("<D:response>");
|
||||||
buffer.append(" <D:href>/</D:href>\n");
|
buffer.append("<D:href>/</D:href>");
|
||||||
buffer.append(" <D:propstat>\n");
|
buffer.append("<D:propstat>");
|
||||||
buffer.append(" <D:prop>\n");
|
buffer.append("<D:prop>");
|
||||||
if (request.hasProperty("principal-collection-set")) {
|
if (request.hasProperty("principal-collection-set")) {
|
||||||
buffer.append(" <D:principal-collection-set>\n");
|
buffer.append("<D:principal-collection-set>");
|
||||||
buffer.append(" <D:href>/principals/users/").append(session.getEmail()).append("</D:href>\n");
|
buffer.append("<D:href>/principals/users/").append(session.getEmail()).append("</D:href>");
|
||||||
buffer.append("</D:principal-collection-set>");
|
buffer.append("</D:principal-collection-set>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("displayname")) {
|
if (request.hasProperty("displayname")) {
|
||||||
buffer.append("<D:displayname>ROOT</D:displayname>");
|
buffer.append("<D:displayname>ROOT</D:displayname>");
|
||||||
}
|
}
|
||||||
buffer.append(" </D:prop>\n");
|
buffer.append("</D:prop>");
|
||||||
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
|
buffer.append("<D:status>HTTP/1.1 200 OK</D:status>");
|
||||||
buffer.append(" </D:propstat>\n");
|
buffer.append("</D:propstat>");
|
||||||
buffer.append(" </D:response>\n");
|
buffer.append("</D:response>");
|
||||||
buffer.append("</D:multistatus>\n");
|
buffer.append("</D:multistatus>");
|
||||||
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPrincipal(CaldavRequest request, String principal) throws IOException {
|
public void sendPrincipal(CaldavRequest request, String principal) throws IOException {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n");
|
buffer.append("<D:multistatus xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">");
|
||||||
buffer.append(" <D:response>\n");
|
buffer.append("<D:response>");
|
||||||
buffer.append(" <D:href>/principals/users/").append(principal).append("</D:href>\n");
|
buffer.append("<D:href>/principals/users/").append(principal).append("</D:href>");
|
||||||
buffer.append(" <D:propstat>\n");
|
buffer.append("<D:propstat>");
|
||||||
buffer.append(" <D:prop>\n");
|
buffer.append("<D:prop>");
|
||||||
if (request.hasProperty("calendar-home-set")) {
|
if (request.hasProperty("calendar-home-set")) {
|
||||||
buffer.append(" <C:calendar-home-set>\n");
|
buffer.append("<C:calendar-home-set>");
|
||||||
buffer.append(" <D:href>/users/").append(principal).append("</D:href>\n");
|
buffer.append("<D:href>/users/").append(principal).append("</D:href>");
|
||||||
buffer.append("</C:calendar-home-set>");
|
buffer.append("</C:calendar-home-set>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.hasProperty("calendar-user-address-set")) {
|
if (request.hasProperty("calendar-user-address-set")) {
|
||||||
buffer.append(" <C:calendar-user-address-set>\n");
|
buffer.append("<C:calendar-user-address-set>");
|
||||||
buffer.append(" <D:href>mailto:").append(principal).append("</D:href>\n");
|
buffer.append("<D:href>mailto:").append(principal).append("</D:href>");
|
||||||
buffer.append("</C:calendar-user-address-set>");
|
buffer.append("</C:calendar-user-address-set>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.hasProperty("schedule-inbox-URL")) {
|
if (request.hasProperty("schedule-inbox-URL")) {
|
||||||
buffer.append(" <C:schedule-inbox-URL>\n");
|
buffer.append("<C:schedule-inbox-URL>");
|
||||||
buffer.append(" <D:href>/users/").append(principal).append("/inbox</D:href>\n");
|
buffer.append("<D:href>/users/").append(principal).append("/inbox</D:href>");
|
||||||
buffer.append("</C:schedule-inbox-URL>");
|
buffer.append("</C:schedule-inbox-URL>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.hasProperty("schedule-outbox-URL")) {
|
if (request.hasProperty("schedule-outbox-URL")) {
|
||||||
buffer.append(" <C:schedule-outbox-URL>\n");
|
buffer.append("<C:schedule-outbox-URL>");
|
||||||
buffer.append(" <D:href>/users/").append(principal).append("/outbox</D:href>\n");
|
buffer.append("<D:href>/users/").append(principal).append("/outbox</D:href>");
|
||||||
buffer.append("</C:schedule-outbox-URL>");
|
buffer.append("</C:schedule-outbox-URL>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,16 +560,16 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
buffer.append("<D:displayname>").append(principal).append("</D:displayname>");
|
buffer.append("<D:displayname>").append(principal).append("</D:displayname>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
buffer.append(" <D:resourcetype>\n");
|
buffer.append("<D:resourcetype>");
|
||||||
buffer.append(" <D:collection/>\n");
|
buffer.append("<D:collection/>");
|
||||||
buffer.append(" <D:principal/>\n");
|
buffer.append("<D:principal/>");
|
||||||
buffer.append(" </D:resourcetype>\n");
|
buffer.append("</D:resourcetype>");
|
||||||
}
|
}
|
||||||
buffer.append(" </D:prop>\n");
|
buffer.append("</D:prop>");
|
||||||
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
|
buffer.append("<D:status>HTTP/1.1 200 OK</D:status>");
|
||||||
buffer.append(" </D:propstat>\n");
|
buffer.append("</D:propstat>");
|
||||||
buffer.append(" </D:response>\n");
|
buffer.append("</D:response>");
|
||||||
buffer.append("</D:multistatus>\n");
|
buffer.append("</D:multistatus>");
|
||||||
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,14 +601,13 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
}
|
}
|
||||||
String freeBusy = session.getFreebusy(valueMap);
|
String freeBusy = session.getFreebusy(valueMap);
|
||||||
if (freeBusy != null) {
|
if (freeBusy != null) {
|
||||||
String response = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
|
String response = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
|
||||||
" <C:schedule-response xmlns:D=\"DAV:\"\n" +
|
"<C:schedule-response xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">" +
|
||||||
" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n" +
|
"<C:response>" +
|
||||||
" <C:response>\n" +
|
"<C:recipient>" +
|
||||||
" <C:recipient>\n" +
|
"<D:href>" + valueMap.get("ATTENDEE") + "</D:href>" +
|
||||||
" <D:href>" + valueMap.get("ATTENDEE") + "</D:href>\n" +
|
"</C:recipient>" +
|
||||||
" </C:recipient>\n" +
|
"<C:request-status>2.0;Success</C:request-status>" +
|
||||||
" <C:request-status>2.0;Success</C:request-status>\n" +
|
|
||||||
"<C:calendar-data>BEGIN:VCALENDAR\n" +
|
"<C:calendar-data>BEGIN:VCALENDAR\n" +
|
||||||
"VERSION:2.0\n" +
|
"VERSION:2.0\n" +
|
||||||
"PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" +
|
"PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" +
|
||||||
@ -623,8 +622,8 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
"FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:" + freeBusy + "\n" +
|
"FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:" + freeBusy + "\n" +
|
||||||
"END:VFREEBUSY\n" +
|
"END:VFREEBUSY\n" +
|
||||||
"END:VCALENDAR" +
|
"END:VCALENDAR" +
|
||||||
"</C:calendar-data>\n" +
|
"</C:calendar-data>" +
|
||||||
" </C:response>\n" +
|
"</C:response>" +
|
||||||
"</C:schedule-response>";
|
"</C:schedule-response>";
|
||||||
sendHttpResponse(HttpStatus.SC_OK, null, "text/xml;charset=UTF-8", response, true);
|
sendHttpResponse(HttpStatus.SC_OK, null, "text/xml;charset=UTF-8", response, true);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user