/// <summary> /// Removes the sync ignore flags of the given device Ids from the given cmis object. /// </summary> /// <param name="obj">Remote CMIS Object.</param> /// <param name="deviceIds">Device identifiers which should be removed from ignore list.</param> public static void RemoveSyncIgnore(this ICmisObject obj, params string[] deviceIds) { var ids = obj.SecondaryObjectTypeIds(); if (ids.Contains("gds:sync")) { var devices = obj.IgnoredDevices(); if (deviceIds == null || deviceIds.Length == 0) { if (devices.Remove("*") || devices.Remove(ConfigManager.CurrentConfig.DeviceId.ToString().ToLower())) { if (devices.Count > 0) { Dictionary <string, object> properties = new Dictionary <string, object>(); properties.Add("gds:ignoreDeviceIds", devices); obj.UpdateProperties(properties, true); } else { obj.RemoveAllSyncIgnores(); } } } else { bool changed = false; foreach (var removeId in deviceIds) { if (devices.Remove(removeId)) { changed = true; } } if (changed) { if (devices.Count > 0) { Dictionary <string, object> properties = new Dictionary <string, object>(); properties.Add("gds:ignoreDeviceIds", devices); obj.UpdateProperties(properties, true); } else { obj.RemoveAllSyncIgnores(); } } } } }
/* * TODO: enable support for properties * [Parameter(Position = 4, Mandatory = false)] * public Hashtable Properties { get; set; } */ 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(); } }
/// <summary> /// Removes all sync ignores flags from the given cmis object /// </summary> /// <param name="obj">Remote CMIS Object.</param> public static void RemoveAllSyncIgnores(this ICmisObject obj) { Dictionary <string, object> properties = new Dictionary <string, object>(); var ids = obj.SecondaryObjectTypeIds(); if (ids.Remove("gds:sync")) { properties.Add(PropertyIds.SecondaryObjectTypeIds, ids); obj.UpdateProperties(properties, true); } }