public override void Save(NodeSaveSettings settings) { Security.Assert(PermissionType.ManageListsAndWorkspaces); AssertEmail(); var listEmailChanged = IsPropertyChanged("ListEmail"); if (listEmailChanged) { SetAllowedChildTypesForEmails(); } base.Save(settings); if (listEmailChanged) { using (new SystemAccount()) { // remove current mail processor workflow RemoveWorkflow(); // start new workflow + subscription if email is given var newEmail = this["ListEmail"] as string; if (!string.IsNullOrEmpty(newEmail)) { StartSubscription(); } } } }
public override void Save(NodeSaveSettings settings) { // Check uniqueness first CheckUniqueUser(); Domain = GenerateDomain(); var originalId = this.Id; // save current password to the list of old passwords this.SaveCurrentPassword(); base.Save(settings); // AD Sync SynchUser(originalId); // set creator for performant self permission setting // creator of the user will always be the user itself. this way setting permissions to the creators group on /Root/IMS will be adequate for user permissions // if you need the original creator, use the auditlog if (originalId == 0) { this.CreatedBy = this; this.NodeCreatedBy = this; base.SaveSameVersion(); } // create profiles if (originalId == 0 && Repository.UserProfilesEnabled) { CreateProfile(); } }
// caller: Node.Save, Node.SaveCopied public object BeginPopulateNode(Node node, NodeSaveSettings settings, string originalPath, string newPath) { if (node == null) { throw new ArgumentNullException(nameof(node)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (originalPath == null) { throw new ArgumentNullException(nameof(originalPath)); } if (newPath == null) { throw new ArgumentNullException(nameof(newPath)); } var populatorData = new DocumentPopulatorData { Node = node, Settings = settings, OriginalPath = originalPath, NewPath = newPath, NodeHead = settings.NodeHead, IsNewNode = node.Id == 0, }; return(populatorData); }
/// <summary> /// Persist this Content's changes by the given settings. /// Do not use this method directly from your code. /// </summary> /// <param name="settings"><see cref="NodeSaveSettings"/> that contains the persistence algorithm.</param> public override void Save(NodeSaveSettings settings) { if (this.IsNew) { this.Parent.Security.Assert(PermissionType.ManageListsAndWorkspaces); } else { this.Security.Assert(PermissionType.ManageListsAndWorkspaces); } if (this.Id > 0) { base.Save(settings); return; } Aspect existingAspect = null; lock (_saveSync) { if ((existingAspect = LoadAspectByName(this.Name)) == null) { base.Save(settings); return; } } throw new InvalidOperationException(String.Concat("Cannot create new Aspect because another Aspect exists with same name: ", existingAspect.Path)); }
public override void Save(NodeSaveSettings settings) { if (this.IsNew) { SecurityHandler.Assert(this.ParentId, PermissionType.ManageListsAndWorkspaces); } else { this.Security.Assert(PermissionType.ManageListsAndWorkspaces); } AssertEmail(); var newEmail = this["ListEmail"] as string; var listEmailChanged = IsNew && !string.IsNullOrEmpty(newEmail) || !IsNew && IsPropertyChanged("ListEmail"); if (listEmailChanged) { SetAllowedChildTypesForEmails(); } base.Save(settings); if (listEmailChanged) { MailProvider.Instance.OnListEmailChanged(this); } }
internal void SaveNodeData(NodeData nodeData, NodeSaveSettings settings, out int lastMajorVersionId, out int lastMinorVersionId) { lastMajorVersionId = 0; lastMinorVersionId = 0; bool isNewNode = nodeData.Id == 0; // shortcut var parent = NodeHead.Get(nodeData.ParentId); var path = RepositoryPath.Combine(parent.Path, nodeData.Name); Node.AssertPath(path); nodeData.Path = path; var writer = this.CreateNodeWriter(); try { var savingAlgorithm = settings.GetSavingAlgorithm(); writer.Open(); if (settings.NeedToSaveData) { SaveNodeBaseData(nodeData, savingAlgorithm, writer, settings, out lastMajorVersionId, out lastMinorVersionId); BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeBaseData, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); if (!isNewNode && nodeData.PathChanged && nodeData.SharedData != null) { writer.UpdateSubTreePath(nodeData.SharedData.Path, nodeData.Path); } SaveNodeProperties(nodeData, savingAlgorithm, writer, isNewNode); } else { writer.UpdateNodeRow(nodeData); } writer.Close(); BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeFlatProperties, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); foreach (var versionId in settings.DeletableVersionIds) { DeleteVersion(versionId, nodeData, out lastMajorVersionId, out lastMinorVersionId); } } catch //rethrow { if (isNewNode) { // Failed save: set NodeId back to 0 nodeData.Id = 0; } throw; } }
// ===================================================================================== Overrides /// <inheritdoc /> public override void Save(NodeSaveSettings settings) { if (!this.IsNew) { this.Security.Assert(PermissionType.ManageListsAndWorkspaces); } base.Save(settings); }
//================================================================================= Overrides public override void Save(NodeSaveSettings settings) { // check new content here for speedup reasons if (this.IsNew) { AssertExecutableType(this); } base.Save(settings); }
public override void Save(NodeSaveSettings settings) { AssertUserName(); if (!String.IsNullOrEmpty(_initialPassword)) { this.PasswordHash = ContentRepository.Fields.PasswordField.EncodePassword(_initialPassword, this); } base.Save(settings); }
public override void Save(NodeSaveSettings settings) { // copy abortonrelatedcontentchange info from definition to instance var workflowDefinition = Node.Load <WorkflowDefinitionHandler>(GetWorkflowDefinitionPath()); if (workflowDefinition != null) { this.AbortOnRelatedContentChange = workflowDefinition.AbortOnRelatedContentChange; } base.Save(settings); //Debug.WriteLine(String.Format("##WF> WorkflowHandlerBase.Save finished: {0}, {1}, {2}", Id, WorkflowInstanceGuid, Path)); }
public override void Save(NodeSaveSettings settings) { // copy abortonrelatedcontentchange info from definition to instance var workflowDefinition = Node.Load <WorkflowDefinitionHandler>(GetWorkflowDefinitionPath()); if (workflowDefinition != null) { this.AbortOnRelatedContentChange = workflowDefinition.AbortOnRelatedContentChange; } base.Save(settings); }
// ================================================================================= Overrides public override void Save(NodeSaveSettings settings) { var settingsObject = DeserializeToJObject(this.Binary.GetStream()); if (settingsObject != null) { ReplaceOrEncodePasswords(settingsObject); this.Binary.SetStream(RepositoryTools.GetStreamFromString(settingsObject.ToString())); } base.Save(settings); }
public override void Save(NodeSaveSettings settings) { var appParent = Parent as Application; var appName = appParent != null ? appParent.AppName : Name.Split('.')[0]; if (this.AppName != appName) { this.SetProperty(APPNAME, appName); } base.Save(settings); }
public override void Save(NodeSaveSettings settings) { var thisUser = this.User; if (thisUser != null) // skip when importing { this.NodeCreatedBy = thisUser; this.NodeModifiedBy = thisUser; this.CreatedBy = thisUser; this.ModifiedBy = thisUser; } base.Save(settings); }
// ===================================================================================== Overrides /// <inheritdoc /> public override void Save(NodeSaveSettings settings) { if (this.IsNew) { SecurityHandler.Assert(this.ParentId, PermissionType.ManageListsAndWorkspaces); } else { this.Security.Assert(PermissionType.ManageListsAndWorkspaces); } base.Save(settings); }
// caller: Node.Save, Node.SaveCopied public object BeginPopulateNode(Node node, NodeSaveSettings settings, string originalPath, string newPath) { var populatorData = new DocumentPopulatorData { Node = node, Settings = settings, OriginalPath = originalPath, NewPath = newPath, NodeHead = settings.NodeHead, IsNewNode = node.Id == 0, }; return(populatorData); }
/// <inheritdoc /> public override void Save(NodeSaveSettings settings) { AssertSettings(); if (_dynamicFieldsChanged && BinaryAsJObject != null) { // If this is a JSON settings file and the dynamic metadata changed, save the JSON binary according to the changes JsonDynamicFieldHelper.SaveToStream(BinaryAsJObject, stream => { this.Binary.SetStream(stream); base.Save(settings); _dynamicFieldsChanged = false; }); } else { base.Save(settings); } // Find all settings that inherit from this setting and remove their cached data if (RepositoryInstance.LuceneManagerIsRunning && !RepositoryEnvironment.WorkingMode.Importing) { string contextPath = null; if (this.ParentPath.StartsWith(SETTINGSCONTAINERPATH, true, System.Globalization.CultureInfo.InvariantCulture)) { contextPath = "/Root"; } else { contextPath = GetParentContextPath(this.Path); } if (contextPath == null) { using (new SystemAccount()) { var q = ContentQuery.Query(SafeQueries.InTreeAndTypeIsAndName, new QuerySettings { EnableAutofilters = FilterStatus.Disabled }, contextPath, typeof(Settings).Name, this.Name); foreach (var id in q.Identifiers) { NodeIdDependency.FireChanged(id); } } } } }
public override void Save(NodeSaveSettings settings) { // Check uniqueness first if (Id == 0 || PropertyNamesForCheckUniqueness.Any(p => IsPropertyChanged(p))) { CheckUniqueUser(); } if (_password != null) { this.PasswordHash = PasswordHashProvider.EncodePassword(_password, this); } Domain = GenerateDomain(); var originalId = this.Id; // save current password to the list of old passwords this.SaveCurrentPassword(); base.Save(settings); // AD Sync SynchUser(originalId); if (originalId == 0) { // set creator for performant self permission setting // creator of the user will always be the user itself. this way setting permissions to the creators group on /Root/IMS will be adequate for user permissions // if you need the original creator, use the auditlog Retrier.Retry(3, 200, typeof(Exception), () => { // need to clear this flag to avoid getting an 'Id <> 0' error during copying this.CopyInProgress = false; this.CreatedBy = this; this.Owner = this; this.VersionCreatedBy = this; this.DisableObserver(TypeResolver.GetType(NodeObserverNames.NOTIFICATION, false)); this.DisableObserver(TypeResolver.GetType(NodeObserverNames.WORKFLOWNOTIFICATION, false)); base.Save(SavingMode.KeepVersion); }); // create profile if (IdentityManagement.UserProfilesEnabled) { CreateProfile(); } } }
public override void Save(NodeSaveSettings settings) { AssertValidMembers(); var originalId = this.Id; base.Save(settings); // AD Sync if (_syncObject) { ADFolder.SynchADContainer(this, originalId); } // default: object should be synced. if it was not synced now (sync properties updated only) next time it should be. _syncObject = true; }
public override void Save(NodeSaveSettings settings) { if (_dynamicFieldsChanged) { JsonDynamicFieldHelper.SaveToStream(_jObject, stream => { this.Binary.SetStream(stream); base.Save(settings); _dynamicFieldsChanged = false; }); } else { base.Save(settings); } }
//================================================================================= Methods public override void Save(NodeSaveSettings settings) { var isNew = this.IsNew; bool import = RepositoryConfiguration.SpecialWorkingMode == "Import"; if (isNew && !import) { Name = GenerateName(); } base.Save(settings); if (isNew && !this.CopyInProgress && !import) { SendMail(); } }
// ================================================================================= Methods public override void Save(NodeSaveSettings settings) { var isNew = IsNew; var import = RepositoryEnvironment.WorkingMode.Importing; if (isNew && !import) { Name = GenerateName(); } base.Save(settings); if (isNew && !CopyInProgress && !import) { SendMail(); } }
public override void Save(NodeSaveSettings settings) { // Check uniqueness first CheckUniqueUser(); if (base.IsPropertyChanged("CreationDate")) { if (_password != null) { this.PasswordHash = PasswordHashProvider.EncodePassword(_password, this); } } Domain = GenerateDomain(); var originalId = this.Id; // save current password to the list of old passwords this.SaveCurrentPassword(); base.Save(settings); // AD Sync SynchUser(originalId); // set creator for performant self permission setting // creator of the user will always be the user itself. this way setting permissions to the creators group on /Root/IMS will be adequate for user permissions // if you need the original creator, use the auditlog if (originalId == 0) { //need to clear this flag to avoid getting an 'Id <> 0' error during copying this.CopyInProgress = false; this.CreatedBy = this; this.VersionCreatedBy = this; this.DisableObserver(TypeHandler.GetType(NodeObserverNames.NOTIFICATION)); this.DisableObserver(TypeHandler.GetType(NodeObserverNames.WORKFLOWNOTIFICATION)); base.Save(SavingMode.KeepVersion); } // create profiles if (originalId == 0 && Repository.UserProfilesEnabled) { CreateProfile(); } }
// ====================================================================== Helper methods private static void SavingAssert(NodeSaveSettings action, string currentversion, int currentVersionId, string expectedVersion, int expectedVersionId, int?lockerId, ICollection <int> deletableVersionIds) { Assert.IsTrue(action.CurrentVersion != null, "action.CurrentVersion is null"); Assert.IsTrue(action.CurrentVersion.ToString() == currentversion, String.Concat("action.CurrentVersion is ", action.CurrentVersion, ". Expected: ", currentversion)); Assert.IsTrue(action.CurrentVersionId == currentVersionId, String.Concat("action.CurrentVersion is ", action.CurrentVersionId, ". Expected: ", currentVersionId)); Assert.IsTrue(action.ExpectedVersion != null, "action.ExpectedVersion is null"); Assert.IsTrue(action.ExpectedVersion.ToString() == expectedVersion, String.Concat("action.CurrentVersion is ", action.ExpectedVersion, ". Expected: ", expectedVersion)); Assert.IsTrue(action.ExpectedVersionId == expectedVersionId, String.Concat("action.ExpectedVersionId is ", action.ExpectedVersionId, ". Expected: ", expectedVersionId)); Assert.IsTrue(action.LockerUserId == lockerId, String.Concat("action.LockerUserId is '", action.LockerUserId, "', Expected: ", lockerId)); Assert.IsTrue(action.DeletableVersionIds.Count == deletableVersionIds.Count, String.Concat("action..DeletableVersions.Count is ", action.DeletableVersionIds.Count, ". Expected: ", deletableVersionIds.Count)); foreach (var versionId in deletableVersionIds) { Assert.IsTrue(action.DeletableVersionIds.Contains(versionId), String.Concat("DeletableVersionIds does not contain ", versionId)); } }
public override void Save(NodeSaveSettings settings) { // copy abortonrelatedcontentchange info from definition to instance var workflowDefinition = Node.Load <WorkflowDefinitionHandler>(GetWorkflowDefinitionPath()); if (workflowDefinition != null) { this.AbortOnRelatedContentChange = workflowDefinition.AbortOnRelatedContentChange; } // disconnect from underlying workflow instance var status = this.WorkflowStatus; if (status == WorkflowStatusEnum.Aborted || status == WorkflowStatusEnum.Completed) { this.WorkflowInstanceGuid = Guid.Empty.ToString(); } // save base.Save(settings); }
// ================================================================================ Overrides public override void Save(NodeSaveSettings settings) { var isNew = IsNew; var import = RepositoryEnvironment.WorkingMode.Importing; if (isNew && !import) { Name = GenerateName(); } var parentForm = LoadContentList() as SurveyList; if (isNew && !import && parentForm != null && parentForm.OnlySingleResponse) { // must not allow users to fill the form multiple times if (parentForm.IsFilled()) { throw new InvalidOperationException(Compatibility.SR.GetString( Compatibility.SR.Exceptions.Survey.OnlySingleResponse, User.Current.Username)); } } base.Save(settings); if (parentForm == null) { return; } if (isNew && !CopyInProgress && !import && parentForm.EnableNotificationMail) { // Sending notifications after filling a form is not part of the // saving process so it can be performed asynchronously. Task.Run(() => SendMail()); } }
public object BeginPopulateNode(Node node, NodeSaveSettings settings, string originalPath, string newPath) { return PopulatorData; }
public override void Save(NodeSaveSettings settings) { AssertTimeSpan(); base.Save(settings); }
private static void SaveNodeBaseData(NodeData nodeData, SavingAlgorithm savingAlgorithm, INodeWriter writer, NodeSaveSettings settings, out int lastMajorVersionId, out int lastMinorVersionId) { switch (savingAlgorithm) { case SavingAlgorithm.CreateNewNode: //nodeData.Id = writer.InsertNodeRow(nodeData); //nodeData.VersionId = writer.InsertVersionRow(nodeData); writer.InsertNodeAndVersionRows(nodeData, out lastMajorVersionId, out lastMinorVersionId); break; case SavingAlgorithm.UpdateSameVersion: writer.UpdateNodeRow(nodeData); writer.UpdateVersionRow(nodeData, out lastMajorVersionId, out lastMinorVersionId); break; case SavingAlgorithm.CopyToNewVersionAndUpdate: writer.UpdateNodeRow(nodeData); writer.CopyAndUpdateVersion(nodeData, settings.CurrentVersionId, out lastMajorVersionId, out lastMinorVersionId); break; case SavingAlgorithm.CopyToSpecifiedVersionAndUpdate: writer.UpdateNodeRow(nodeData); writer.CopyAndUpdateVersion(nodeData, settings.CurrentVersionId, settings.ExpectedVersionId, out lastMajorVersionId, out lastMinorVersionId); break; default: throw new NotImplementedException("Unknown SavingAlgorithm: " + savingAlgorithm); } }
public object BeginPopulateNode(Node node, NodeSaveSettings settings, string originalPath, string newPath) { return(PopulatorData); }
public override void Save(NodeSaveSettings settings) { base.Save(settings); DeviceManager.Reset(); }