Click or drag to resize

IHierarchyItemUpdateProperties 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: 4.5.3121.0
Syntax
void UpdateProperties(
	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 BeforeResponse, 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: 
.
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 UpdateProperties 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 BeforeResponse.

Examples

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.
}
See Also