Java Code Examples for org.apache.jackrabbit.webdav.property.DavPropertyNameSet#add()
The following examples show how to use
org.apache.jackrabbit.webdav.property.DavPropertyNameSet#add() .
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: DavExchangeSession.java From davmail with GNU General Public License v2.0 | 6 votes |
protected String getItemProperty(String permanentUrl, String propertyName) throws IOException, DavException { String result = null; DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(Field.getPropertyName(propertyName)); PropFindMethod propFindMethod = new PropFindMethod(encodeAndFixUrl(permanentUrl), davPropertyNameSet, 0); try { try { DavGatewayHttpClientFacade.executeHttpMethod(httpClient, propFindMethod); } catch (UnknownHostException e) { propFindMethod.releaseConnection(); // failover for misconfigured Exchange server, replace host name in url restoreHostName = true; propFindMethod = new PropFindMethod(encodeAndFixUrl(permanentUrl), davPropertyNameSet, 0); DavGatewayHttpClientFacade.executeHttpMethod(httpClient, propFindMethod); } MultiStatus responses = propFindMethod.getResponseBodyAsMultiStatus(); if (responses.getResponses().length > 0) { DavPropertySet properties = responses.getResponses()[0].getProperties(HttpStatus.SC_OK); result = getPropertyIfExists(properties, propertyName); } } finally { propFindMethod.releaseConnection(); } return result; }
Example 2
Source File: Webdav4FileContentInfoFactory.java From commons-vfs with Apache License 2.0 | 6 votes |
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final Webdav4FileObject file = (Webdav4FileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; final DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(DavPropertyName.GETCONTENTTYPE); final DavPropertySet propertySet = file.getProperties((GenericURLFileName) file.getName(), nameSet, true); DavProperty property = propertySet.get(DavPropertyName.GETCONTENTTYPE); if (property != null) { contentType = (String) property.getValue(); } property = propertySet.get(Webdav4FileObject.RESPONSE_CHARSET); if (property != null) { contentEncoding = (String) property.getValue(); } return new DefaultFileContentInfo(contentType, contentEncoding); }
Example 3
Source File: WebdavFileContentInfoFactory.java From commons-vfs with Apache License 2.0 | 6 votes |
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final WebdavFileObject file = (WebdavFileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; final DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(DavPropertyName.GETCONTENTTYPE); final DavPropertySet propertySet = file.getProperties((URLFileName) file.getName(), nameSet, true); DavProperty property = propertySet.get(DavPropertyName.GETCONTENTTYPE); if (property != null) { contentType = (String) property.getValue(); } property = propertySet.get(WebdavFileObject.RESPONSE_CHARSET); if (property != null) { contentEncoding = (String) property.getValue(); } return new DefaultFileContentInfo(contentType, contentEncoding); }
Example 4
Source File: MultigetHandler.java From openmeetings with Apache License 2.0 | 6 votes |
public MultigetHandler(List<String> hrefs, boolean onlyEtag, String path, OmCalendar calendar, HttpClient client, HttpClientContext context, AppointmentDao appointmentDao, IcalUtils utils) { super(path, calendar, client, context, appointmentDao, utils); this.onlyEtag = onlyEtag; if (hrefs == null || hrefs.isEmpty() || calendar.getSyncType() == SyncType.NONE) { isMultigetDisabled = true; } else { DavPropertyNameSet properties = new DavPropertyNameSet(); properties.add(DavPropertyName.GETETAG); CalendarData calendarData = null; if (!onlyEtag) { calendarData = new CalendarData(); } CompFilter vcalendar = new CompFilter(Calendar.VCALENDAR); vcalendar.addCompFilter(new CompFilter(Component.VEVENT)); query = new CalendarMultiget(properties, calendarData, false, false); query.setHrefs(hrefs); } }
Example 5
Source File: CtagHandler.java From openmeetings with Apache License 2.0 | 6 votes |
@Override BaseDavRequest internalSyncItems() throws IOException, DavException { //Calendar already inited. DavPropertyNameSet properties = new DavPropertyNameSet(); properties.add(DNAME_GETCTAG); HttpPropFindMethod method = new HttpPropFindMethod(path, properties, CalDAVConstants.DEPTH_0); HttpResponse httpResponse = client.execute(method, context); if (method.succeeded(httpResponse)) { for (MultiStatusResponse response : method.getResponseBodyAsMultiStatus(httpResponse).getResponses()) { DavPropertySet set = response.getProperties(SC_OK); String ctag = AppointmentManager.getTokenFromProperty(set.get(DNAME_GETCTAG)); if (ctag != null && !ctag.equals(calendar.getToken())) { EtagsHandler etagsHandler = new EtagsHandler(path, calendar, client, context, appointmentDao, utils); etagsHandler.syncItems(); calendar.setToken(ctag); } } } else { log.error("Error executing PROPFIND Method, with status Code: {}", httpResponse.getStatusLine().getStatusCode()); } return method; }
Example 6
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 7
Source File: TestCaldav.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testPropfindRoot() throws IOException, DavException { 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:"))); PropFindMethod method = new PropFindMethod("/", davPropertyNameSet, 0); httpClient.executeMethod(method); assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode()); method.getResponseBodyAsMultiStatus(); }
Example 8
Source File: TestCaldav.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testPropfindPublicPrincipal() throws IOException, DavException { //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"))); PropFindMethod method = new PropFindMethod("/principals/public/testcalendar/", davPropertyNameSet, 0); httpClient.executeMethod(method); assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode()); MultiStatus multiStatus = method.getResponseBodyAsMultiStatus(); MultiStatusResponse[] responses = multiStatus.getResponses(); assertEquals(1, responses.length); }
Example 9
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 10
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 11
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 12
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 13
Source File: Webdav4FileObject.java From commons-vfs with Apache License 2.0 | 5 votes |
/** * Sets an attribute of this file. Is only called if {@link #doGetType} does not return {@link FileType#IMAGINARY}. */ @Override protected void doSetAttribute(final String attrName, final Object value) throws Exception { try { final GenericURLFileName fileName = (GenericURLFileName) getName(); final String urlStr = toUrlString(fileName); final DavPropertySet properties = new DavPropertySet(); final DavPropertyNameSet propertyNameSet = new DavPropertyNameSet(); final DavProperty property = new DefaultDavProperty(attrName, value, Namespace.EMPTY_NAMESPACE); if (value != null) { properties.add(property); } else { propertyNameSet.add(property.getName()); // remove property } final HttpProppatch request = new HttpProppatch(urlStr, properties, propertyNameSet); setupRequest(request); final HttpResponse response = executeRequest(request); if (!request.succeeded(response)) { throw new FileSystemException("Property '" + attrName + "' could not be set."); } } catch (final FileSystemException fse) { throw fse; } catch (final Exception e) { throw new FileSystemException("vfs.provider.webdav/set-attributes", e, getName(), attrName); } }
Example 14
Source File: TestCaldav.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testWellKnown() throws IOException, DavException { 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:"))); PropFindMethod method = new PropFindMethod("/.well-known/caldav", davPropertyNameSet, 0); httpClient.executeMethod(method); assertEquals(HttpStatus.SC_MOVED_PERMANENTLY, method.getStatusCode()); }
Example 15
Source File: TestCaldav.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testPropfindPrincipal() throws IOException, DavException { //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"))); PropFindMethod method = new PropFindMethod("/principals/users/" + session.getEmail() + "/", davPropertyNameSet, 0); httpClient.executeMethod(method); assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode()); MultiStatus multiStatus = method.getResponseBodyAsMultiStatus(); MultiStatusResponse[] responses = multiStatus.getResponses(); assertEquals(1, responses.length); }
Example 16
Source File: WebdavFileObject.java From commons-vfs with Apache License 2.0 | 5 votes |
/** * Sets an attribute of this file. Is only called if {@link #doGetType} does not return {@link FileType#IMAGINARY}. */ @Override protected void doSetAttribute(final String attrName, final Object value) throws Exception { try { final URLFileName fileName = (URLFileName) getName(); final String urlStr = toUrlString(fileName); final DavPropertySet properties = new DavPropertySet(); final DavPropertyNameSet propertyNameSet = new DavPropertyNameSet(); final DavProperty property = new DefaultDavProperty(attrName, value, Namespace.EMPTY_NAMESPACE); if (value != null) { properties.add(property); } else { propertyNameSet.add(property.getName()); // remove property } final PropPatchMethod method = new PropPatchMethod(urlStr, properties, propertyNameSet); setupMethod(method); execute(method); if (!method.succeeded()) { throw new FileSystemException("Property '" + attrName + "' could not be set."); } } catch (final FileSystemException fse) { throw fse; } catch (final Exception e) { throw new FileSystemException("vfs.provider.webdav/set-attributes", e, getName(), attrName); } }
Example 17
Source File: Webdav4FileObject.java From commons-vfs with Apache License 2.0 | 4 votes |
DavProperty getProperty(final GenericURLFileName fileName, final DavPropertyName name) throws FileSystemException { final DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(name); final DavPropertySet propertySet = getProperties(fileName, nameSet, false); return propertySet.get(name); }
Example 18
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); }
Example 19
Source File: StandardDavRequest.java From cosmo with Apache License 2.0 | 4 votes |
/** * * @throws CosmoDavException */ private void parsePropPatchRequest() throws CosmoDavException { Document requestDocument = getSafeRequestDocument(); if (requestDocument == null) { throw new BadRequestException("PROPPATCH requires entity body"); } Element root = requestDocument.getDocumentElement(); if (!DomUtil.matches(root, XML_PROPERTYUPDATE, NAMESPACE)) { throw new BadRequestException("Expected " + QN_PROPERTYUPDATE + " root element"); } ElementIterator sets = DomUtil.getChildren(root, XML_SET, NAMESPACE); ElementIterator removes = DomUtil.getChildren(root, XML_REMOVE, NAMESPACE); if (!(sets.hasNext() || removes.hasNext())) { throw new BadRequestException("Expected at least one of " + QN_REMOVE + " and " + QN_SET + " as a child of " + QN_PROPERTYUPDATE); } Element prop = null; ElementIterator i = null; proppatchSet = new DavPropertySet(); while (sets.hasNext()) { Element set = sets.nextElement(); prop = DomUtil.getChildElement(set, XML_PROP, NAMESPACE); if (prop == null) { throw new BadRequestException("Expected " + QN_PROP + " child of " + QN_SET); } i = DomUtil.getChildren(prop); while (i.hasNext()) { StandardDavProperty p = StandardDavProperty.createFromXml(i .nextElement()); proppatchSet.add(p); } } proppatchRemove = new DavPropertyNameSet(); while (removes.hasNext()) { Element remove = removes.nextElement(); prop = DomUtil.getChildElement(remove, XML_PROP, NAMESPACE); if (prop == null) { throw new BadRequestException("Expected " + QN_PROP + " child of " + QN_REMOVE); } i = DomUtil.getChildren(prop); while (i.hasNext()){ proppatchRemove.add(DavPropertyName.createFromXml(i .nextElement())); } } }
Example 20
Source File: WebdavFileObject.java From commons-vfs with Apache License 2.0 | 4 votes |
DavProperty getProperty(final URLFileName fileName, final DavPropertyName name) throws FileSystemException { final DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(name); final DavPropertySet propertySet = getProperties(fileName, nameSet, false); return propertySet.get(name); }