CmisSync.Lib.Consumer.SituationSolver.LocalObjectDeleted.Solve C# (CSharp) Method

Solve() public method

Solves the situation by deleting the corresponding remote object.
public Solve ( IFileSystemInfo localFile, IObjectId remoteId, ContentChangeType localContent = ContentChangeType.NONE, ContentChangeType remoteContent = ContentChangeType.NONE ) : void
localFile IFileSystemInfo Local file.
remoteId IObjectId Remote identifier or object.
localContent ContentChangeType Hint if the local content has been changed.
remoteContent ContentChangeType Information if the remote content has been changed.
return void
        public override void Solve(
            IFileSystemInfo localFile,
            IObjectId remoteId,
            ContentChangeType localContent = ContentChangeType.NONE,
            ContentChangeType remoteContent = ContentChangeType.NONE)
        {
            var mappedObject = this.Storage.GetObjectByRemoteId(remoteId.Id);
            if (mappedObject.LastChangeToken != (remoteId as ICmisObject).ChangeToken) {
                throw new ArgumentException("Remote object has been changed since last sync => force crawl sync");
            }

            bool hasBeenDeleted = this.TryDeleteObjectOnServer(remoteId, mappedObject.Type);
            if (hasBeenDeleted) {
                this.Storage.RemoveObject(mappedObject);
                OperationsLogger.Info(string.Format("Deleted the corresponding remote object {0} of locally deleted object {1}", remoteId.Id, mappedObject.Name));
            } else {
                OperationsLogger.Warn(string.Format("Permission denied while trying to Delete the locally deleted object {0} on the server.", mappedObject.Name));
            }
        }