Java Code Examples for org.apache.jackrabbit.webdav.property.DavPropertySet#add()
The following examples show how to use
org.apache.jackrabbit.webdav.property.DavPropertySet#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: DavUserPrincipal.java From cosmo with Apache License 2.0 | 6 votes |
protected void loadLiveProperties(DavPropertySet properties) { properties.add(new CreationDate(user.getCreationDate())); properties.add(new DisplayName(getDisplayName())); properties.add(new ResourceType(getResourceTypes())); properties.add(new IsCollection(isCollection())); properties.add(new Etag(user.getEntityTag())); properties.add(new LastModified(user.getModifiedDate())); properties.add(new CalendarHomeSet(getResourceLocator(), user)); // for now scheduling is an option if(isSchedulingEnabled()) { properties.add(new CalendarUserAddressSet(user, userIdentitySupplier)); properties.add(new ScheduleInboxURL(getResourceLocator(), user)); properties.add(new ScheduleOutboxURL(getResourceLocator(), user)); } properties.add(new AlternateUriSet()); properties.add(new PrincipalUrl(getResourceLocator(), user)); properties.add(new GroupMembership()); }
Example 2
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 6 votes |
public void testRenameCalendar() throws IOException, URISyntaxException { String folderName = "testcalendarfolder"; String renamedFolderName = "renamedcalendarfolder"; URI uri = new URIBuilder().setPath("/users/" + session.getEmail() + "/calendar/" + folderName + '/').build(); // first delete calendar session.deleteFolder("calendar/" + folderName); session.deleteFolder("calendar/" + renamedFolderName); session.createCalendarFolder("calendar/" + folderName, null); DavPropertySet davPropertySet = new DavPropertySet(); davPropertySet.add(new DefaultDavProperty<>(DavPropertyName.create("displayname", Namespace.getNamespace("DAV:")), renamedFolderName)); HttpProppatch propPatchMethod = new HttpProppatch(uri, davPropertySet, new DavPropertyNameSet()); httpClient.executeDavRequest(propPatchMethod); ExchangeSession.Folder renamedFolder = session.getFolder("calendar/" + renamedFolderName); assertNotNull(renamedFolder); }
Example 3
Source File: DavFile.java From cosmo with Apache License 2.0 | 6 votes |
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); FileItem content = (FileItem) getItem(); if (content == null) { return; } if (content.getContentLanguage() != null) { properties.add(new ContentLanguage(content.getContentLanguage())); } properties.add(new ContentLength(content.getContentLength())); properties.add(new ContentType(content.getContentType(), content.getContentEncoding())); }
Example 4
Source File: Webdav4FileObject.java From commons-vfs with Apache License 2.0 | 6 votes |
private void setUserName(final GenericURLFileName fileName, final String urlStr) throws IOException { final DavPropertySet setProperties = new DavPropertySet(); final DavPropertyNameSet removeProperties = new DavPropertyNameSet(); String name = builder.getCreatorName(getFileSystem().getFileSystemOptions()); final String userName = fileName.getUserName(); if (name == null) { name = userName; } else { if (userName != null) { final String comment = "Modified by user " + userName; setProperties.add(new DefaultDavProperty(DeltaVConstants.COMMENT, comment)); } } setProperties.add(new DefaultDavProperty(DeltaVConstants.CREATOR_DISPLAYNAME, name)); final HttpProppatch request = new HttpProppatch(urlStr, setProperties, removeProperties); setupRequest(request); executeRequest(request); }
Example 5
Source File: WebdavFileObject.java From commons-vfs with Apache License 2.0 | 6 votes |
DavPropertySet getProperties(final URLFileName name, final int type, final DavPropertyNameSet nameSet, final boolean addEncoding) throws FileSystemException { try { final String urlStr = toUrlString(name); final PropFindMethod method = new PropFindMethod(urlStr, type, nameSet, DavConstants.DEPTH_0); setupMethod(method); execute(method); if (method.succeeded()) { final MultiStatus multiStatus = method.getResponseBodyAsMultiStatus(); final MultiStatusResponse response = multiStatus.getResponses()[0]; final DavPropertySet props = response.getProperties(HttpStatus.SC_OK); if (addEncoding) { final DavProperty prop = new DefaultDavProperty(RESPONSE_CHARSET, method.getResponseCharSet()); 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 6
Source File: DavItemResourceBase.java From cosmo with Apache License 2.0 | 6 votes |
protected void loadDeadProperties(DavPropertySet properties) { for (Iterator<Map.Entry<QName, Attribute>> i = item.getAttributes() .entrySet().iterator(); i.hasNext();) { Map.Entry<QName, Attribute> entry = i.next(); // skip attributes that are not meant to be shown as dead // properties if (getDeadPropertyFilter().contains(entry.getKey().getNamespace())) { continue; } DavPropertyName propName = qNameToPropName(entry.getKey()); // ignore live properties, as they'll be loaded separately if (isLiveProperty(propName)) { continue; } // XXX: language Object propValue = entry.getValue().getValue(); properties.add(new StandardDavProperty(propName, propValue, false)); } }
Example 7
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 8
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 9
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 10
Source File: DavCalendarCollection.java From cosmo with Apache License 2.0 | 5 votes |
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); CalendarCollectionStamp cc = getCalendarCollectionStamp(); if (cc == null) { return; } if (cc.getDescription() != null) { properties.add(new CalendarDescription(cc.getDescription(), cc.getLanguage())); } if (cc.getTimezoneCalendar() != null) { properties.add(new CalendarTimezone(cc.getTimezoneCalendar().toString())); } // add CS:getctag property, which is the collection's entitytag // if it exists Item item = getItem(); if (item != null && item.getEntityTag() != null) { properties.add(new GetCTag(item.getEntityTag())); } properties.add(new SupportedCalendarComponentSet()); properties.add(new SupportedCollationSet()); properties.add(new SupportedCalendarData()); properties.add(new MaxResourceSize()); if (cc.getVisibility() != null) { properties.add(new CalendarVisibility(cc.getVisibility())); } if (cc.getColor() != null) { properties.add(new CalendarColor(cc.getColor())); } if (cc.getDisplayName() != null) { properties.add(new DisplayName(cc.getDisplayName())); } }
Example 11
Source File: StandardDavRequest.java From cosmo with Apache License 2.0 | 5 votes |
/** * * @return DavPropertySet * @throws CosmoDavException */ private DavPropertySet parseMkCalendarRequest() throws CosmoDavException { DavPropertySet propertySet = new DavPropertySet(); Document requestDocument = getSafeRequestDocument(false); if (requestDocument == null) { return propertySet; } Element root = requestDocument.getDocumentElement(); if (!DomUtil.matches(root, ELEMENT_CALDAV_MKCALENDAR, NAMESPACE_CALDAV)) { throw new BadRequestException("Expected " + QN_MKCALENDAR + " root element"); } Element set = DomUtil.getChildElement(root, XML_SET, NAMESPACE); if (set == null) { throw new BadRequestException("Expected " + QN_SET + " child of " + QN_MKCALENDAR); } Element prop = DomUtil.getChildElement(set, XML_PROP, NAMESPACE); if (prop == null) { throw new BadRequestException("Expected " + QN_PROP + " child of " + QN_SET); } ElementIterator i = DomUtil.getChildren(prop); while (i.hasNext()){ propertySet.add(StandardDavProperty.createFromXml(i.nextElement())); } return propertySet; }
Example 12
Source File: DavItemResourceBase.java From cosmo with Apache License 2.0 | 5 votes |
protected void loadLiveProperties(DavPropertySet properties) { if (item == null) { return; } properties.add(new CreationDate(item.getCreationDate())); properties.add(new LastModified(item.getModifiedDate())); properties.add(new Etag(getETag())); properties.add(new DisplayName(getDisplayName())); properties.add(new ResourceType(getResourceTypes())); properties.add(new IsCollection(isCollection())); properties.add(new Owner(getResourceLocator(), item.getOwner())); properties.add(new PrincipalCollectionSet(getResourceLocator())); properties.add(new Uuid(item.getUid())); }
Example 13
Source File: DavCalendarResource.java From cosmo with Apache License 2.0 | 5 votes |
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); try { byte[] calendarBytes = getCalendar().toString().getBytes("UTF-8"); properties.add(new ContentLength(Long.valueOf(calendarBytes.length))); } catch (Exception e) { throw new CosmoException("Can't convert calendar", e); } properties.add(new ContentType(ICALENDAR_MEDIA_TYPE, "UTF-8")); }
Example 14
Source File: DavCollectionBase.java From cosmo with Apache License 2.0 | 5 votes |
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); CollectionItem cc = (CollectionItem) getItem(); if (cc == null) { return; } properties.add(new ExcludeFreeBusyRollup(cc.isExcludeFreeBusyRollup())); }
Example 15
Source File: DavUserPrincipalCollection.java From cosmo with Apache License 2.0 | 5 votes |
protected void loadLiveProperties(DavPropertySet properties) { properties.add(new DisplayName(getDisplayName())); properties.add(new ResourceType(getResourceTypes())); properties.add(new IsCollection(isCollection())); properties.add(new CurrentUserPrincipal(getResourceLocator(), getSecurityManager().getSecurityContext().getUser())); }
Example 16
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 17
Source File: DavInboxCollection.java From cosmo with Apache License 2.0 | 4 votes |
protected void loadLiveProperties(DavPropertySet properties) { properties.add(new DisplayName(getDisplayName())); properties.add(new ResourceType(getResourceTypes())); properties.add(new IsCollection(isCollection())); properties.add(new Etag(getETag())); }
Example 18
Source File: DavOutboxCollection.java From cosmo with Apache License 2.0 | 4 votes |
protected void loadLiveProperties(DavPropertySet properties) { properties.add(new DisplayName(getDisplayName())); properties.add(new ResourceType(getResourceTypes())); properties.add(new IsCollection(isCollection())); properties.add(new Etag(getETag())); }