Java Code Examples for org.apache.jackrabbit.webdav.client.methods.BaseDavRequest#setEntity()
The following examples show how to use
org.apache.jackrabbit.webdav.client.methods.BaseDavRequest#setEntity() .
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: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 6 votes |
public void testReportInbox() throws IOException { String buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<C:calendar-query xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\">" + "<D:prop>" + "<C:calendar-data/>" + "</D:prop>" + "<C:filter>" + "</C:filter>" + "</C:calendar-query>"; BaseDavRequest method = new BaseDavRequest(URI.create("/users/" + session.getEmail() + "/inbox/")) { @Override public String getMethod() { return DavMethods.METHOD_REPORT; } }; method.setEntity(new StringEntity(buffer, ContentType.create("text/xml", "UTF-8"))); httpClient.executeDavRequest(method); }
Example 2
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 6 votes |
public void testReportTasks() throws IOException { String buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<C:calendar-query xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\">" + "<D:prop>" + "<C:calendar-data/>" + "</D:prop>" + "<C:comp-filter name=\"VCALENDAR\">" + "<C:comp-filter name=\"VTODO\"/>" + "</C:comp-filter>" + "<C:filter>" + "</C:filter>" + "</C:calendar-query>"; BaseDavRequest method = new BaseDavRequest(URI.create("/users/" + session.getEmail() + "/calendar/")) { @Override public String getMethod() { return DavMethods.METHOD_REPORT; } }; method.setEntity(new StringEntity(buffer, ContentType.create("text/xml", "UTF-8"))); httpClient.executeDavRequest(method); }
Example 3
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 6 votes |
public void testReportEventsOnly() throws IOException { String buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<C:calendar-query xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\">" + "<D:prop>" + "<C:calendar-data/>" + "</D:prop>" + "<C:comp-filter name=\"VCALENDAR\">" + "<C:comp-filter name=\"VEVENT\"/>" + "</C:comp-filter>" + "<C:filter>" + "</C:filter>" + "</C:calendar-query>"; BaseDavRequest method = new BaseDavRequest(URI.create("/users/" + session.getEmail() + "/calendar/")) { @Override public String getMethod() { return DavMethods.METHOD_REPORT; } }; method.setEntity(new StringEntity(buffer, ContentType.create("text/xml", "UTF-8"))); httpClient.executeDavRequest(method); }
Example 4
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 6 votes |
public void testInvalidDavRequest() { BaseDavRequest method = new BaseDavRequest(URI.create("/users/" + session.getEmail() + "/calendar/")) { @Override public String getMethod() { return DavMethods.METHOD_REPORT; } }; method.setEntity(new StringEntity("invalid", ContentType.create("text/xml", "UTF-8"))); try { httpClient.executeDavRequest(method); fail("Should fail"); } catch (IOException e) { assertNotNull(e.getMessage()); assertEquals(503, ((DavException)e.getCause()).getErrorCode()); } }
Example 5
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testReportCalendar() throws IOException { SimpleDateFormat formatter = ExchangeSession.getZuluDateFormat(); Calendar cal = Calendar.getInstance(); Date end = cal.getTime(); cal.add(Calendar.MONTH, -1); Date start = cal.getTime(); BaseDavRequest method = new BaseDavRequest(URI.create("/users/" + session.getEmail() + "/calendar/")) { @Override public String getMethod() { return DavMethods.METHOD_REPORT; } }; String buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<C:calendar-query xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\">" + "<D:prop>" + "<C:calendar-data/>" + "</D:prop>" + "<C:comp-filter name=\"VCALENDAR\">" + "<C:comp-filter name=\"VEVENT\">" + "<C:time-range start=\"" + formatter.format(start) + "\" end=\"" + formatter.format(end) + "\"/>" + //"<C:time-range start=\"" + formatter.format(start) + "\"/>" + "</C:comp-filter>" + "</C:comp-filter>" + "<C:filter>" + "</C:filter>" + "</C:calendar-query>"; method.setEntity(new StringEntity(buffer, ContentType.create("text/xml", "UTF-8"))); MultiStatus multiStatus = httpClient.executeDavRequest(method); MultiStatusResponse[] responses = multiStatus.getResponses(); List<ExchangeSession.Event> events = session.searchEvents("/users/" + session.getEmail() + "/calendar/", ExchangeSession.getZuluDateFormat().format(start), ExchangeSession.getZuluDateFormat().format(end) ); assertEquals(events.size(), responses.length); }
Example 6
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testCreateCalendar() throws IOException, URISyntaxException { String folderName = "test & accentué"; //String folderName = "justatest"; URI uri = new URIBuilder().setPath("/users/" + session.getEmail() + "/calendar/" + folderName + '/').build(); // first delete calendar session.deleteFolder("calendar/" + folderName); String body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + " <C:mkcalendar xmlns:D=\"DAV:\"\n" + " xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n" + " <D:set>\n" + " <D:prop>\n" + " <D:displayname>" + StringUtil.xmlEncode(folderName) + "</D:displayname>\n" + " <C:calendar-description xml:lang=\"en\">Calendar description</C:calendar-description>\n" + " <C:supported-calendar-component-set>\n" + " <C:comp name=\"VEVENT\"/>\n" + " </C:supported-calendar-component-set>\n" + " </D:prop>\n" + " </D:set>\n" + " </C:mkcalendar>"; BaseDavRequest method = new BaseDavRequest(uri) { @Override public String getMethod() { return "MKCALENDAR"; } public boolean succeeded(HttpResponse response) { int status = response.getStatusLine().getStatusCode(); return status == HttpStatus.SC_CREATED; } }; method.setEntity(new StringEntity(body, ContentType.create("text/xml", "UTF-8"))); httpClient.executeDavRequest(method); HttpGet getRequest = new HttpGet(uri); CloseableHttpResponse getResponse = httpClient.execute(getRequest); assertEquals(org.apache.commons.httpclient.HttpStatus.SC_OK, getResponse.getStatusLine().getStatusCode()); }