Namespace: ITHit.WebDAV.Server
void UpdateProperties( IList<PropertyValue> setProps, IList<PropertyName> delProps, MultistatusException multistatus )
Exception | Condition |
---|---|
NeedPrivilegesException | The user doesn't have enough privileges. |
InsufficientStorageException | Quota limit is reached. |
LockedException | This item was locked and client did not provide lock token. |
MultistatusException |
The exception shall contain statuses for all properties that
failed to update.
Typical property error statuses:
|
DavException | In other cases. |
In your UpdateProperties implementation you will create, modify and delete item properties. Single property update request may invoke following methods of single item which update properties:
The standard requires that request which updates properties is atomic (PROPPATCH). If your storage supports transactions then atomicity requirement can be implemented by committing or rollbacking the transaction in BeforeResponse.
The code below is part of 'WebDAVServer.NtfsStorage' sample provided with the SDK.
public virtual void UpdateProperties( IList<PropertyValue> setProps, IList<PropertyName> delProps, MultistatusException multistatus) { RequireHasToken(); foreach (PropertyValue propToSet in setProps) { // Microsoft Mini-redirector may update file creation date, modification date and access time passing properties: // <Win32CreationTime xmlns="urn:schemas-microsoft-com:">Thu, 28 Mar 2013 20:15:34 GMT</Win32CreationTime> // <Win32LastModifiedTime xmlns="urn:schemas-microsoft-com:">Thu, 28 Mar 2013 20:36:24 GMT</Win32LastModifiedTime> // <Win32LastAccessTime xmlns="urn:schemas-microsoft-com:">Thu, 28 Mar 2013 20:36:24 GMT</Win32LastAccessTime> // In this case update creation and modified date in your storage or do not save this properties at all, otherwise // Windows Explorer will display creation and modification date from this props and it will differ from the values // in the Created and Modified fields in your storage if (propToSet.QualifiedName.Namespace == "urn:schemas-microsoft-com:") { if (propToSet.QualifiedName.Name == "Win32CreationTime") { fileSystemInfo.CreationTimeUtc = DateTime.Parse(propToSet.Value, new System.Globalization.CultureInfo("en-US")).ToUniversalTime(); } else if (propToSet.QualifiedName.Name == "Win32LastModifiedTime") { fileSystemInfo.LastWriteTimeUtc = DateTime.Parse(propToSet.Value, new System.Globalization.CultureInfo("en-US")).ToUniversalTime(); } } else { var propertyValues = getPropertyValues(); var existingProp = propertyValues.FirstOrDefault(p => p.QualifiedName == propToSet.QualifiedName); if (existingProp != null) { existingProp.Value = propToSet.Value; } else { propertyValues.Add(propToSet); } } } var propertyValuesForRemove = getPropertyValues(); propertyValuesForRemove.RemoveAll(prop => delProps.Contains(prop.QualifiedName)); context.FileOperation( this, () => RewriteStream("Properties", propertyValues), Privilege.Write); // You should not update modification date/time here. Mac OS X Finder expects that properties update do not change the file modification date. }