org.apache.jackrabbit.webdav.client.methods.HttpPropfind Java Examples
The following examples show how to use
org.apache.jackrabbit.webdav.client.methods.HttpPropfind.
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: HC4DavExchangeSession.java From davmail with GNU General Public License v2.0 | 6 votes |
protected void checkPublicFolder() { // check public folder access try { publicFolderUrl = URIUtils.resolve(httpClientAdapter.getUri(), PUBLIC_ROOT).toString(); DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(Field.getPropertyName("displayname")); HttpPropfind httpPropfind = new HttpPropfind(publicFolderUrl, davPropertyNameSet, 0); httpClientAdapter.executeDavRequest(httpPropfind); // update public folder URI publicFolderUrl = httpPropfind.getURI().toString(); } catch (IOException e) { LOGGER.warn("Public folders not available: " + (e.getMessage() == null ? e : e.getMessage())); // default public folder path publicFolderUrl = PUBLIC_ROOT; } }
Example #2
Source File: HC4DavExchangeSession.java From davmail with GNU General Public License v2.0 | 5 votes |
/** * @inheritDoc */ @Override protected Folder internalGetFolder(String folderPath) throws IOException { MultiStatus multiStatus = httpClientAdapter.executeDavRequest(new HttpPropfind( URIUtil.encodePath(getFolderPath(folderPath)), FOLDER_PROPERTIES_NAME_SET, 0)); MultiStatusResponse[] responses = multiStatus.getResponses(); Folder folder = null; if (responses.length > 0) { folder = buildFolder(responses[0]); folder.folderPath = folderPath; } return folder; }
Example #3
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testGetOtherUserCalendar() throws IOException { HttpPropfind method = new HttpPropfind("/principals/users/" + Settings.getProperty("davmail.usera"), DavConstants.PROPFIND_ALL_PROP, new DavPropertyNameSet(), DavConstants.DEPTH_INFINITY); try (CloseableHttpResponse response = httpClient.execute(method)) { assertEquals(HttpStatus.SC_MULTI_STATUS, response.getStatusLine().getStatusCode()); } }
Example #4
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testPropfindPrincipal() throws IOException { //Settings.setLoggingLevel("httpclient.wire", Level.DEBUG); DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("calendar-home-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("calendar-user-address-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("schedule-inbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("schedule-outbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); HttpPropfind method = new HttpPropfind("/principals/users/" + session.getEmail() + "/", davPropertyNameSet, 0); MultiStatus multiStatus = httpClient.executeDavRequest(method); MultiStatusResponse[] responses = multiStatus.getResponses(); assertEquals(1, responses.length); }
Example #5
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testWellKnown() throws IOException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("current-user-principal", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("principal-URL", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("resourcetype", Namespace.getNamespace("DAV:"))); HttpPropfind method = new HttpPropfind("/.well-known/caldav", davPropertyNameSet, 0) { @Override public boolean succeeded(HttpResponse response) { return response.getStatusLine().getStatusCode() == DavServletResponse.SC_MOVED_PERMANENTLY; } }; httpClient.executeDavRequest(method); }
Example #6
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testPropfindRoot() throws IOException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("current-user-principal", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("principal-URL", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("resourcetype", Namespace.getNamespace("DAV:"))); HttpPropfind method = new HttpPropfind("/", davPropertyNameSet, 0); httpClient.executeDavRequest(method); }
Example #7
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testPropfindPublicPrincipal() throws IOException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("calendar-home-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("calendar-user-address-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("schedule-inbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("schedule-outbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); HttpPropfind method = new HttpPropfind("/principals/public/testcalendar/", davPropertyNameSet, 0); MultiStatus multiStatus = httpClient.executeDavRequest(method); MultiStatusResponse[] responses = multiStatus.getResponses(); assertEquals(1, responses.length); }
Example #8
Source File: Webdav4FileObject.java From commons-vfs with Apache License 2.0 | 5 votes |
DavPropertySet getProperties(final GenericURLFileName name, final int type, final DavPropertyNameSet nameSet, final boolean addEncoding) throws FileSystemException { try { final String urlStr = toUrlString(name); final HttpPropfind request = new HttpPropfind(urlStr, type, nameSet, DavConstants.DEPTH_0); setupRequest(request); final HttpResponse res = executeRequest(request); if (request.succeeded(res)) { final MultiStatus multiStatus = request.getResponseBodyAsMultiStatus(res); final MultiStatusResponse response = multiStatus.getResponses()[0]; final DavPropertySet props = response.getProperties(HttpStatus.SC_OK); if (addEncoding) { final ContentType resContentType = ContentType.getOrDefault(res.getEntity()); final DavProperty prop = new DefaultDavProperty(RESPONSE_CHARSET, resContentType.getCharset().name()); props.add(prop); } return props; } return new DavPropertySet(); } catch (final FileSystemException fse) { throw fse; } catch (final Exception e) { throw new FileSystemException("vfs.provider.webdav/get-property.error", e, getName(), name, type, nameSet.getContent(), addEncoding); } }
Example #9
Source File: HC4DavExchangeSession.java From davmail with GNU General Public License v2.0 | 4 votes |
protected void getWellKnownFolders() throws DavMailException { // Retrieve well known URLs try { HttpPropfind httpPropfind = new HttpPropfind(mailPath, WELL_KNOWN_FOLDERS, 0); MultiStatus multiStatus; try (CloseableHttpResponse response = httpClientAdapter.execute(httpPropfind)) { multiStatus = httpPropfind.getResponseBodyAsMultiStatus(response); } MultiStatusResponse[] responses = multiStatus.getResponses(); if (responses.length == 0) { throw new WebdavNotAvailableException("EXCEPTION_UNABLE_TO_GET_MAIL_FOLDER", mailPath); } DavPropertySet properties = responses[0].getProperties(org.apache.http.HttpStatus.SC_OK); inboxUrl = getURIPropertyIfExists(properties, "inbox"); inboxName = getFolderName(inboxUrl); deleteditemsUrl = getURIPropertyIfExists(properties, "deleteditems"); deleteditemsName = getFolderName(deleteditemsUrl); sentitemsUrl = getURIPropertyIfExists(properties, "sentitems"); sentitemsName = getFolderName(sentitemsUrl); sendmsgUrl = getURIPropertyIfExists(properties, "sendmsg"); sendmsgName = getFolderName(sendmsgUrl); draftsUrl = getURIPropertyIfExists(properties, "drafts"); draftsName = getFolderName(draftsUrl); calendarUrl = getURIPropertyIfExists(properties, "calendar"); calendarName = getFolderName(calendarUrl); tasksUrl = getURIPropertyIfExists(properties, "tasks"); tasksName = getFolderName(tasksUrl); contactsUrl = getURIPropertyIfExists(properties, "contacts"); contactsName = getFolderName(contactsUrl); outboxUrl = getURIPropertyIfExists(properties, "outbox"); outboxName = getFolderName(outboxUrl); // junk folder not available over webdav LOGGER.debug("Inbox URL: " + inboxUrl + " Trash URL: " + deleteditemsUrl + " Sent URL: " + sentitemsUrl + " Send URL: " + sendmsgUrl + " Drafts URL: " + draftsUrl + " Calendar URL: " + calendarUrl + " Tasks URL: " + tasksUrl + " Contacts URL: " + contactsUrl + " Outbox URL: " + outboxUrl + " Public folder URL: " + publicFolderUrl ); } catch (IOException | DavException e) { LOGGER.error(e.getMessage()); throw new WebdavNotAvailableException("EXCEPTION_UNABLE_TO_GET_MAIL_FOLDER", mailPath); } }
Example #10
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 4 votes |
public void testPropfindCalendar() throws IOException { HttpPropfind method = new HttpPropfind("/users/" + session.getEmail() + "/calendar/", null, 1); try (CloseableHttpResponse response = httpClient.execute(method)) { assertEquals(HttpStatus.SC_MULTI_STATUS, response.getStatusLine().getStatusCode()); } }
Example #11
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 4 votes |
public void testPrincipalUrl() throws IOException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("principal-URL", Namespace.getNamespace("DAV:"))); HttpPropfind method = new HttpPropfind("/principals/users/" + session.getEmail(), davPropertyNameSet, 0); httpClient.executeDavRequest(method); }