CmisCmdlets.UpdateCmisObjectCommand.EndProcessing C# (CSharp) Method

EndProcessing() protected method

protected EndProcessing ( ) : void
return void
        protected override void EndProcessing()
        {
            var navigation = new CmisNavigation(CmisSession, WorkingFolder);
            ICmisObject obj = (Object != null) ? Object : navigation.Get(Path);

/*
            if (Properties != null || !String.IsNullOrEmpty(Name))
            {
                var props = Utilities.HashtableToDict(Properties);
                if (!String.IsNullOrEmpty(Name))
                {
                    props[PropertyIds.Name] = Name;
                }
                obj = obj.UpdateProperties(props);
            }
 */
            if (!String.IsNullOrEmpty(Name))
            {
                var props = new Dictionary<string, object>() { { PropertyIds.Name, Name } };
                obj = obj.UpdateProperties(props);
            }

            // check if we should update content
            if (LocalFile == null && !HasContent())
            {
                WriteObject(obj);
                return; 
            }

            // otherwise the object must be a document
            var doc = obj as IDocument;
            if (doc == null)
            {
                var ex = new CmisObjectNotFoundException("The provided object is not a Document");
                ThrowTerminatingError(new ErrorRecord(ex, "UpdateObjNotDocument",
                                                      ErrorCategory.InvalidArgument, Object));
            }

            var stream = GetContentStream();
            stream.FileName = obj.Name; // important, as may not set
            try
            {
                var result = doc.SetContentStream(stream, true);
                WriteObject(result == null ? doc : result);
            }
            finally
            {
                stream.Stream.Close();
            }
        }
    }
UpdateCmisObjectCommand