Click or drag to resize

IHierarchyItemAsyncUpdatePropertiesAsync Method

IT Hit WebDAV Classes Reference
Adds, modifies and removes properties for this item.

Namespace:  ITHit.WebDAV.Server
Assembly:  ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 9.1.5460-Beta
Syntax
Task UpdatePropertiesAsync(
	IList<PropertyValue> setProps,
	IList<PropertyName> delProps,
	MultistatusException multistatus
)

Parameters

setProps
Type: System.Collections.GenericIListPropertyValue
List of properties to be set.
delProps
Type: System.Collections.GenericIListPropertyName
List of property names to be removed. Properties that don't exist shall be skipped.
multistatus
Type: ITHit.WebDAV.ServerMultistatusException
The standard requires this operation to be transactional. If some properties fail to update but there is no possibility to rollback the transaction in BeforeResponseAsync, add information about the error into multistatus using AddInnerException(String, PropertyName, DavException). In this case engine will report correct statuses for all properties at least (although this is against standard).

Return Value

Type: Task
.
Exceptions
ExceptionCondition
NeedPrivilegesExceptionThe user doesn't have enough privileges.
InsufficientStorageExceptionQuota limit is reached.
LockedExceptionThis 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:
  • CONFLICT - the client has provided a value whose semantics are not appropriate for the property, this includes trying to set read-only properties.
  • FAILED_DEPENDENCY - indicates this action would have succeeded if it were not for the conflict with updating/removing some other property.
DavExceptionIn other cases.
Remarks

In your UpdatePropertiesAsync(IListPropertyValue, IListPropertyName, MultistatusException) implementation you will create, modify and delete item properties. Single property update request may invoke following methods of single item which update properties:

Engine will update properties (call these methods) one by one unless exception is thrown. If an exception is thrown during a property update engine will report all remaining properties as failed with status FAILED_DEPENDENCY

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 BeforeResponseAsync.

Examples

The code below is part of 'WebDAVServer.FileSystemStorage.AspNet' C# & VB samples provided with the SDK.

public async Task UpdatePropertiesAsync(IList<PropertyValue> setProps, IList<PropertyName> delProps, MultistatusException multistatus)
{
    await RequireHasTokenAsync();
    List<PropertyValue> propertyValues = await GetPropertyValuesAsync();
    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:")
        {
            switch (propToSet.QualifiedName.Name)
            {
                case "Win32CreationTime":
                    fileSystemInfo.CreationTimeUtc = DateTime.Parse(propToSet.Value,
                        new System.Globalization.CultureInfo("en-US")).ToUniversalTime();
                    break;
                case "Win32LastModifiedTime":
                    fileSystemInfo.LastWriteTimeUtc = DateTime.Parse(propToSet.Value,
                        new System.Globalization.CultureInfo("en-US")).ToUniversalTime();
                    break;
                default:
                    context.Logger.LogDebug(string.Format("Unspecified case: DavHierarchyItem.UpdateProperties {0} from {1} namesapce",
                        propToSet.QualifiedName.Name, propToSet.QualifiedName.Namespace));
                    break;
            }
        }
        else
        {
            PropertyValue existingProp = propertyValues.FirstOrDefault(p => p.QualifiedName == propToSet.QualifiedName);

            if (existingProp != null)
            {
                existingProp.Value = propToSet.Value;
            }
            else
            {
                propertyValues.Add(propToSet);
            }
        }
    }

    propertyValues.RemoveAll(prop => delProps.Contains(prop.QualifiedName));

    await fileSystemInfo.SetExtendedAttributeAsync(propertiesAttributeName, propertyValues);
    await context.socketService.NotifyRefreshAsync(GetParentPath(Path));
}
See Also