internal static void Delete(Folder folder, string searchString, UserConfigurationSearchFlags searchFlags) { EnumValidator.AssertValid <UserConfigurationSearchFlags>(searchFlags); if (searchFlags != UserConfigurationSearchFlags.SubString && searchFlags != UserConfigurationSearchFlags.FullString && searchFlags != UserConfigurationSearchFlags.Prefix) { ExTraceGlobals.StorageTracer.TraceError <UserConfigurationSearchFlags>(0L, "UserConfiguration::FindItems. The search flag is not supported. searchFlags = {0}.", searchFlags); throw new NotSupportedException(); } IList <IStorePropertyBag> list = null; try { list = UserConfiguration.QueryConfigurations(folder, null, new UserConfigurationName(searchString, ConfigurationNameKind.PartialName), searchFlags, StorageLimits.Instance.UserConfigurationMaxSearched, new PropertyDefinition[0]); } catch (InvalidOperationException innerException) { throw new InvalidOperationException(ServerStrings.ExCannotQueryAssociatedTable, innerException); } List <VersionedId> list2 = new List <VersionedId>(); for (int i = 0; i < list.Count; i++) { list2.Add((VersionedId)list[i][InternalSchema.ItemId]); if (i == list.Count - 1 || list2.Count > 100) { AggregateOperationResult result = folder.Session.Delete(DeleteItemFlags.SoftDelete, list2.ToArray()); UserConfiguration.CheckOperationResults(result, "Delete"); list2.Clear(); } } }
private void TraceAggregateOperationResultFromDelete(AggregateOperationResult result, string syncStateName, StoreObjectId id) { string text = null; if (result == null) { text = string.Format("SyncState '{0}' with ID = '{1}' doesn't exist.", syncStateName, id); } else if (!result.OperationResult.Equals(OperationResult.Succeeded)) { StringBuilder stringBuilder = new StringBuilder(500); stringBuilder.AppendFormat("SyncState '{0}' is not deleted properly. Result: '{1}' ", syncStateName, result); stringBuilder.Append("GroupOperationResult: \n\n"); if (result.GroupOperationResults != null) { foreach (GroupOperationResult groupOperationResult in result.GroupOperationResults) { stringBuilder.AppendFormat("Result: '{0}', Exception: '{1}' \n", groupOperationResult.OperationResult, groupOperationResult.Exception); } } text = stringBuilder.ToString(); } if (text != null) { this.syncLogger.Information(ExTraceGlobals.SyncTracer, (long)this.GetHashCode(), text); } }
private static CalendarGroup CreateMyCalendarsGroup(MailboxSession session) { CalendarGroup calendarGroup = null; using (DisposeGuard disposeGuard = default(DisposeGuard)) { calendarGroup = CalendarGroup.InternalCreateGroup(session, CalendarGroupType.MyCalendars); disposeGuard.Add <CalendarGroup>(calendarGroup); using (CalendarGroupEntry calendarGroupEntry = CalendarGroupEntry.Create(session, session.GetDefaultFolderId(DefaultFolderType.Calendar), FolderTreeData.MyFoldersClassId, calendarGroup.GroupName)) { calendarGroupEntry.CalendarName = ClientStrings.Calendar.ToString(session.InternalCulture); ConflictResolutionResult conflictResolutionResult = calendarGroupEntry.Save(SaveMode.NoConflictResolution); if (conflictResolutionResult.SaveStatus != SaveResult.Success) { ExTraceGlobals.StorageTracer.TraceWarning <SmtpAddress>(0L, "Unable to associate default calendar with the MyCalendars group for user: {0}. Attempting to delete default calendars group.", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress); AggregateOperationResult aggregateOperationResult = session.Delete(DeleteItemFlags.HardDelete, new StoreId[] { calendarGroup.Id }); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { ExTraceGlobals.StorageTracer.TraceWarning <SmtpAddress>(0L, "Unable to delete default calendar group after failing to add the default calendar to it. User: {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress); } throw new DefaultCalendarNodeCreationException(); } } disposeGuard.Success(); } return(calendarGroup); }
private void MoveFromDeletedIfNecessary(StoreObjectId folderId, SharingDataType dataType) { using (Folder folder = Folder.Bind(this.mailboxSession, DefaultFolderType.DeletedItems)) { using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, new PropertyDefinition[] { FolderSchema.Id })) { ComparisonFilter seekFilter = new ComparisonFilter(ComparisonOperator.Equal, FolderSchema.Id, folderId); if (!queryResult.SeekToCondition(SeekReference.OriginBeginning, seekFilter)) { return; } } } ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, StoreObjectId>((long)this.GetHashCode(), "{0}: Folder is in deleted items, need to move back to calendar folder. FolderId: {1}", this.mailboxSession.MailboxOwner, folderId); AggregateOperationResult aggregateOperationResult = this.mailboxSession.Move(this.mailboxSession.GetDefaultFolderId(dataType.DefaultFolderType), new StoreId[] { folderId }); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { GroupOperationResult groupOperationResult = aggregateOperationResult.GroupOperationResults[0]; ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, StoreObjectId, LocalizedException>((long)this.GetHashCode(), "{0}: Failed to move folder. FolderId: {1}, Exception: {2}", this.mailboxSession.MailboxOwner, folderId, groupOperationResult.Exception); throw groupOperationResult.Exception; } }
private static void CheckOperationResults(AggregateOperationResult result, string methodName) { if (result.OperationResult != OperationResult.Succeeded) { ExTraceGlobals.UserConfigurationTracer.TraceDebug <string, AggregateOperationResult>(0L, "UserConfiguration::{0}. Operation failed. Result = {1}.", methodName, result); } }
private static TaskGroup CreateMyTasksGroup(MailboxSession session) { TaskGroup taskGroup = TaskGroup.InternalCreateDefaultGroup(session); bool flag = TaskGroup.AddDefaultTaskFolder(session, taskGroup, DefaultFolderType.ToDoSearch, ClientStrings.ToDoSearch.ToString(session.InternalCulture)); string folderType = DefaultFolderType.ToDoSearch.ToString(); if (flag) { flag = TaskGroup.AddDefaultTaskFolder(session, taskGroup, DefaultFolderType.Tasks, ClientStrings.Tasks.ToString(session.InternalCulture)); folderType = DefaultFolderType.Tasks.ToString(); } if (!flag) { AggregateOperationResult aggregateOperationResult = session.Delete(DeleteItemFlags.HardDelete, new StoreId[] { taskGroup.Id }); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { ExTraceGlobals.StorageTracer.TraceWarning <SmtpAddress>(0L, "Unable to delete default task group after failing to add the default task folder to it. User: {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress); } throw new DefaultTaskNodeCreationException(folderType); } return(taskGroup); }
private void ConflictDetection() { using (Folder folder = Folder.Bind(this.storeSession, this.FolderId)) { SortBy[] sorts = new SortBy[] { new SortBy(InternalSchema.LastModifiedTime, SortOrder.Ascending), new SortBy(InternalSchema.CreationTime, SortOrder.Ascending), new SortBy(InternalSchema.MID, SortOrder.Ascending) }; IList <IStorePropertyBag> list = UserConfiguration.QueryConfigurations(folder, sorts, this.configName, UserConfigurationSearchFlags.FullString, 2, new PropertyDefinition[0]); if (list.Count <= 0) { ExTraceGlobals.UserConfigurationTracer.TraceDebug((long)this.GetHashCode(), "UserConfiguration::ConflictDetection. The object I just created cannot be found."); } else { VersionedId versionedId = (VersionedId)list[0][InternalSchema.ItemId]; if (list.Count >= 1 && !this.id.Equals(versionedId.ObjectId)) { this.Dispose(); AggregateOperationResult aggregateOperationResult = this.storeSession.Delete(DeleteItemFlags.SoftDelete, new StoreId[] { this.id }); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>((long)this.GetHashCode(), "UserConfiguration::ConflictResolution. Failed to delete configuration item. ConfigName = {0}.", this.configName); } ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "UserConfiguration::Save. The same configuration object was created by someone prio to the current one. ConfigName = {0}.", this.configName.Name); throw new ObjectExistedException(ServerStrings.ExConfigExisted(this.configName.Name)); } } } }
private static void AddToConfigurationCache(Folder folder, IList <IStorePropertyBag> items) { if (items == null || items.Count == 0) { return; } MailboxSession mailboxSession = folder.Session as MailboxSession; if (mailboxSession == null) { throw new NotSupportedException(); } UserConfigurationManager userConfigurationManager = mailboxSession.UserConfigurationManager; List <VersionedId> list = new List <VersionedId>(); new List <int>(); string a = null; for (int i = 0; i < items.Count; i++) { IStorePropertyBag storePropertyBag = items[i]; if (PropertyError.IsPropertyError(storePropertyBag.TryGetProperty(InternalSchema.ItemClass))) { ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = ItemClass."); throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("ItemClass")); } if (PropertyError.IsPropertyError(storePropertyBag.TryGetProperty(InternalSchema.ItemId))) { ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = Id."); throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Id")); } string b = storePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string; if (a == b) { list.Add((VersionedId)storePropertyBag[InternalSchema.ItemId]); items.RemoveAt(i); i--; } else { string name = (string)storePropertyBag[InternalSchema.ItemClass]; if (UserConfigurationName.IsValidName(name, ConfigurationNameKind.ItemClass)) { userConfigurationManager.UserConfigurationCache.Add(folder.Id.ObjectId, new UserConfigurationName(name, ConfigurationNameKind.ItemClass), ((VersionedId)storePropertyBag[InternalSchema.ItemId]).ObjectId); } } a = (storePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string); } if (folder.Session.LogonType == LogonType.Owner) { userConfigurationManager.UserConfigurationCache.Save(); } AggregateOperationResult result = folder.Session.Delete(DeleteItemFlags.SoftDelete, list.ToArray()); UserConfiguration.CheckOperationResults(result, "DeleteDuplicates"); }
public static bool DeleteSyncStateStorage(MailboxSession mailboxSession, StoreObjectId deviceFolderId, DeviceIdentity deviceIdentity, ISyncLogger syncLogger = null) { if (syncLogger == null) { syncLogger = TracingLogger.Singleton; } ArgumentValidator.ThrowIfNull("mailboxSession", mailboxSession); ArgumentValidator.ThrowIfNull("folderId", deviceFolderId); bool result = false; SyncStateTypeFactory.GetInstance().RegisterInternalBuilders(); UserSyncStateMetadata userSyncStateMetadata = UserSyncStateMetadataCache.Singleton.Get(mailboxSession, syncLogger); AggregateOperationResult aggregateOperationResult = mailboxSession.Delete(DeleteItemFlags.SoftDelete, new StoreId[] { deviceFolderId }); syncLogger.Information <string>(ExTraceGlobals.SyncTracer, 0L, "SyncStateStorage::DeleteSyncStateStorage. Result = {0}", aggregateOperationResult.OperationResult.ToString()); userSyncStateMetadata.TryRemove(deviceIdentity, syncLogger); List <DeviceSyncStateMetadata> allDevices = userSyncStateMetadata.GetAllDevices(mailboxSession, false, syncLogger); if (allDevices != null) { foreach (DeviceSyncStateMetadata deviceSyncStateMetadata in allDevices) { syncLogger.Information <DeviceIdentity, DeviceIdentity>(ExTraceGlobals.SyncTracer, 0L, "SyncStateStorage::DeleteSyncStateStorage. Found device folder '{0}', Looking for folder '{1}'", deviceSyncStateMetadata.Id, deviceIdentity); if (deviceSyncStateMetadata.Id.Equals(deviceIdentity)) { try { aggregateOperationResult = mailboxSession.Delete(DeleteItemFlags.SoftDelete, new StoreId[] { deviceSyncStateMetadata.DeviceFolderId }); syncLogger.Information <DeviceIdentity, DeviceIdentity, string>(ExTraceGlobals.SyncTracer, 0L, "SyncStateStorage::DeleteSyncStateStorage. try Deleting SyncState folder again.folderName:{0}, originalFolder:{1}, result:{2}", deviceSyncStateMetadata.Id, deviceIdentity, aggregateOperationResult.OperationResult.ToString()); continue; } catch { syncLogger.Information(ExTraceGlobals.SyncTracer, 0L, "SyncStateStorage::DeleteSyncStateStorage. Error deleting the sync state folder."); continue; } } if (deviceSyncStateMetadata.Id.IsProtocol("AirSync")) { result = true; break; } } } return(result); }
public AggregateOperationResult AlwaysClutterOrUnclutter(bool?clutterOrUnclutter, bool processItems) { AggregateOperationResult result = null; using (ConversationActionItem associatedActionItem = this.GetAssociatedActionItem()) { associatedActionItem.AlwaysClutterOrUnclutterValue = clutterOrUnclutter; if (clutterOrUnclutter != null && processItems) { result = associatedActionItem.ProcessItems(ConversationAction.AlwaysClutterOrUnclutter, this); } associatedActionItem.Save(SaveMode.ResolveConflicts); } return(result); }
public AggregateOperationResult AlwaysCategorize(string[] categories, bool processItems) { AggregateOperationResult result = null; using (ConversationActionItem associatedActionItem = this.GetAssociatedActionItem()) { associatedActionItem.AlwaysCategorizeValue = categories; if (categories != null && processItems) { result = associatedActionItem.ProcessItems(ConversationAction.AlwaysCategorize, this); } associatedActionItem.Save(SaveMode.ResolveConflicts); } return(result); }
public AggregateOperationResult AlwaysMove(StoreObjectId folderId, bool processItems) { AggregateOperationResult result = null; using (ConversationActionItem associatedActionItem = this.GetAssociatedActionItem()) { associatedActionItem.AlwaysMoveValue = folderId; if (folderId != null && processItems) { result = associatedActionItem.ProcessItems(ConversationAction.AlwaysMove, this); } associatedActionItem.Save(SaveMode.ResolveConflicts); } return(result); }
public AggregateOperationResult AlwaysDelete(bool enable, bool processItems) { AggregateOperationResult result = null; using (ConversationActionItem associatedActionItem = this.GetAssociatedActionItem()) { associatedActionItem.AlwaysDeleteValue = enable; associatedActionItem.ConversationActionMaxDeliveryTime = ExDateTime.MinValue; if (enable && processItems) { result = associatedActionItem.ProcessItems(ConversationAction.AlwaysDelete, this); } associatedActionItem.Save(SaveMode.ResolveConflicts); } return(result); }
internal virtual void RemoveForRecover(ref DefaultFolderData data) { if (data.FolderId != null) { if (this.defaultFolderInfo.StoreObjectType == StoreObjectType.SearchFolder) { AggregateOperationResult aggregateOperationResult = this.defaultFolderInfo.FolderCreator.Delete(this.context, DeleteItemFlags.HardDelete, data.FolderId); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { ExTraceGlobals.DefaultFoldersTracer.TraceError <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::Create. The default folder cannot be deleted. defaultFolder = {0}.", this); } } data = new DefaultFolderData(null, data.IdInitialized, data.HasInitialized); this.defaultFolderInfo.EntryIdStrategy.UnsetEntryId(this.context); } }
private void ResolveConflictAfterCreation(TKey subscriptionKey, VersionedId subscriptionId) { object[] array = this.FindFirstByKey(subscriptionKey); VersionedId versionedId = (VersionedId)array[1]; if (!subscriptionId.ObjectId.Equals(versionedId.ObjectId)) { ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: A race condition occurred. This subscription is about to be deleted due to duplication: {0}", this.mailboxSession.MailboxOwner, subscriptionId); AggregateOperationResult aggregateOperationResult = this.mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[] { subscriptionId }); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, AggregateOperationResult>((long)this.GetHashCode(), "{0}: Failed to delete this subscription {1}: {2}", this.mailboxSession.MailboxOwner, subscriptionId, aggregateOperationResult); } throw new SharingConflictException(); } }
public static AggregateOperationResult Merge(AggregateOperationResult first, AggregateOperationResult second) { OperationResult operationResult; if (first.OperationResult == OperationResult.Succeeded && second.OperationResult == OperationResult.Succeeded) { operationResult = OperationResult.Succeeded; } else if (first.OperationResult == OperationResult.Failed && second.OperationResult == OperationResult.Failed) { operationResult = OperationResult.Failed; } else { operationResult = OperationResult.PartiallySucceeded; } GroupOperationResult[] array = new GroupOperationResult[first.GroupOperationResults.Length + second.GroupOperationResults.Length]; first.GroupOperationResults.Concat(second.GroupOperationResults).CopyTo(array, 0); return(new AggregateOperationResult(operationResult, array)); }
private AggregateOperationResult InternalDeleteSyncState(string name) { this.CheckDisposed("DeleteCustomSyncState"); this.syncLogger.Information <int>(ExTraceGlobals.SyncTracer, (long)this.GetHashCode(), "SyncStateStorage::InternalDeleteSyncState. Hashcode = {0}", this.GetHashCode()); ArgumentValidator.ThrowIfNullOrEmpty("name", name); SyncStateMetadata syncState = this.DeviceMetadata.GetSyncState(this.folder.Session as MailboxSession, name, this.syncLogger); this.DeviceMetadata.TryRemove(name, this.syncLogger); AggregateOperationResult result = null; if (syncState != null) { if (syncState.FolderSyncStateId == null && syncState.ItemSyncStateId != null) { this.syncLogger.Information <string>(ExTraceGlobals.SyncTracer, (long)this.GetHashCode(), "[SyncStateStorage.InternalDeleteSyncState] Deleting direct item sync state {0}", name); result = this.folder.DeleteObjects(DeleteItemFlags.SoftDelete, new StoreId[] { syncState.ItemSyncStateId }); } else if (syncState.FolderSyncStateId != null) { this.syncLogger.Information <string>(ExTraceGlobals.SyncTracer, (long)this.GetHashCode(), "[SyncStateStorage.InternalDeleteSyncState] Deleting sync folder for sync state {0}", name); result = this.folder.DeleteObjects(DeleteItemFlags.SoftDelete, new StoreId[] { syncState.FolderSyncStateId }); } else { this.syncLogger.Information <string>(ExTraceGlobals.SyncTracer, (long)this.GetHashCode(), "[SyncStateStorage.InternalDeleteSyncState] Metadata had null for both item and folder id. Weird - not deleting anything. Sync State: {0}", name); } StoreObjectId storeObjectId = (syncState.FolderSyncStateId != null) ? syncState.FolderSyncStateId : syncState.ItemSyncStateId; if (storeObjectId != null) { this.TraceAggregateOperationResultFromDelete(result, name, storeObjectId); } } return(result); }
internal virtual void Delete(DeleteItemFlags deleteItemFlags) { ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::Delete. The default folder is about to be deleted. defaultFolder = {0}.", this); EnumValidator.ThrowIfInvalid <DeleteItemFlags>(deleteItemFlags, "deleteItemFlags"); EnumValidator.ThrowIfInvalid <DefaultFolderType>(this.defaultFolderInfo.DefaultFolderType, DefaultFolder.DefaultFoldersThatCanBeDeleted); StoreObjectId storeObjectId; if (!this.TryGetFolderId(out storeObjectId)) { throw new InvalidOperationException(string.Format("Cannot delete the default folder {0}, because it does not exist.", this.defaultFolderInfo.DefaultFolderType)); } this.defaultFolderInfo.EntryIdStrategy.UnsetEntryId(this.context); DefaultFolderData defaultFolderData = this.GetDefaultFolderData(); AggregateOperationResult aggregateOperationResult = this.defaultFolderInfo.FolderCreator.Delete(this.context, deleteItemFlags, defaultFolderData.FolderId); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { throw new AggregateOperationFailedException(ServerStrings.ExFailedToDeleteDefaultFolder, aggregateOperationResult); } this.defaultFolderInfo.EntryIdStrategy.UnsetEntryId(this.context); this.SetDefaultFolderData(new DefaultFolderData(null)); }
public AggregateOperationFailedException(LocalizedString message, AggregateOperationResult aggregateOperationResult) : base(message) { this.aggregateOperationResult = aggregateOperationResult; }
private bool Initialize(ref DefaultFolderData data) { bool flag = true; Exception ex = null; if (!data.IdInitialized) { DefaultFolderData defaultFolderData = this.InitializeFolderIdPrivate(); if (defaultFolderData != null) { data = defaultFolderData; } } ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::Initialize. The default folder is about to be initialized. defaultFolder = {0}.", this); if (this.defaultFolderInfo.DefaultFolderType == DefaultFolderType.None) { if (!data.HasInitialized) { data = new DefaultFolderData(true); } return(true); } try { if (DefaultFolder.TestInjectInitFailure != null) { DefaultFolder.TestInjectInitFailure(this); } bool flag2 = true; if (data.FolderId != null && !this.Validate(data)) { flag2 = false; data = new DefaultFolderData(null, data.IdInitialized, data.HasInitialized); } if (data.FolderId == null && (this.IsOwnerSession || (!flag2 && this.context.Session.Capabilities.MustHideDefaultFolders)) && (this.defaultFolderInfo.Behavior & DefaultFolderBehavior.CreateIfMissing) == DefaultFolderBehavior.CreateIfMissing) { flag = this.CreateInternal(ref data); } if (flag && data.FolderId != null && this.HideUnderNonIpmSubtree) { using (Folder folder = Folder.Bind(this.context.Session, data.FolderId)) { if (!this.IsParentFolderConfigurationFolder(folder)) { ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::Initialize. defaultFolder={0} is not under the non-IPM subtree(aka. Configuration folder). Move it to the non-IPM subtree.", this); AggregateOperationResult aggregateOperationResult = this.context.Session.Move(this.context[DefaultFolderType.Configuration], new StoreId[] { data.FolderId }); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { LocalizedException exception = aggregateOperationResult.GroupOperationResults[0].Exception; ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder, LocalizedException>((long)this.GetHashCode(), "DefaultFolder::Initialize. Moving defaultFolder={0} to the non-IPM subtree(aka. Configuration folder) fails with exception={1}.", this, exception); if (exception.ErrorCode == -2146233088 && exception is ObjectExistedException) { folder.PropertyBag.Reload(); if (this.IsParentFolderConfigurationFolder(folder)) { ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::Initialize. After reloading, defaultFolder={0} is under the non-IPM subtree(aka. Configuration folder).", this); } else { data = new DefaultFolderData(null, data.IdInitialized, data.HasInitialized); flag = false; ExTraceGlobals.DefaultFoldersTracer.TraceError <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::Initialize. After reloading, defaultFolder={0} is still NOT under the non-IPM subtree(aka. Configuration folder).", this); } } else { data = new DefaultFolderData(null, data.IdInitialized, data.HasInitialized); flag = false; ExTraceGlobals.DefaultFoldersTracer.TraceError <DefaultFolder, LocalizedException>((long)this.GetHashCode(), "DefaultFolder::Initialize. Unable to move defaultFolder={0} to the Configuration node. Exception={1}.", this, exception); } } } } } if (flag && data.FolderId != null && this.context.Session.MailboxOwner.RecipientTypeDetails == RecipientTypeDetails.TeamMailbox && this.IsHiddenTeamMailboxFolder) { using (Folder folder2 = Folder.Bind(this.context.Session, data.FolderId)) { folder2.PropertyBag[FolderSchema.IsHidden] = true; folder2.Save(); } } if (this.CheckShouldRefreshFolderId(data)) { data = this.InitializeFolderIdPrivate(); if (data.FolderId != null) { if (this.Validate(data)) { flag = true; } else { data = new DefaultFolderData(null, data.IdInitialized, data.HasInitialized); } } } } catch (CorruptDataException ex2) { ex = ex2; } this.SetDefaultFolderData(data); if (ex != null) { this.defaultFolderInfo.CorruptDataRecoveryStrategy.Recover(this, ex, ref data); } if (!data.HasInitialized) { data = new DefaultFolderData(data.FolderId, data.IdInitialized, true); this.SetDefaultFolderData(data); } return(flag); }
internal static UserConfiguration GetIgnoringCache(UserConfigurationManager manager, Folder folder, UserConfigurationName configurationName, UserConfigurationTypes freefetchType) { EnumValidator.AssertValid <UserConfigurationTypes>(freefetchType); UserConfiguration userConfiguration = null; PropertyDefinition[] columns; if ((freefetchType & UserConfigurationTypes.Dictionary) > (UserConfigurationTypes)0) { columns = new PropertyDefinition[] { InternalSchema.UserConfigurationDictionary }; } else { columns = UserConfiguration.ZeroProperties; } SortBy[] sorts = new SortBy[] { new SortBy(InternalSchema.CreationTime, SortOrder.Ascending), new SortBy(InternalSchema.MID, SortOrder.Ascending) }; IList <IStorePropertyBag> list = null; try { ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>(0L, "UserConfiguration::GetIgnoringCache. Hit Query. ConfigName = {0}.", configurationName); list = UserConfiguration.QueryConfigurations(folder, sorts, configurationName, UserConfigurationSearchFlags.FullString, 2, columns); } catch (InvalidOperationException innerException) { throw new InvalidOperationException(ServerStrings.ExCannotQueryAssociatedTable, innerException); } if (list.Count <= 0) { ExTraceGlobals.StorageTracer.TraceError <UserConfigurationName, UserConfigurationTypes>(0L, "UserConfiguration::GetIgnoringCache. The configuration object was not found. Name = {0}, type = {1}.", configurationName, freefetchType); throw new ObjectNotFoundException(ServerStrings.ExConfigurationNotFound(configurationName.Name)); } ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>(0L, "UserConfiguration::GetIgnoringCache. Find the config item and build user config object from it. ConfigName = {0}.", configurationName); bool flag = false; UserConfiguration result2; try { userConfiguration = UserConfiguration.BuildConfigurationFromQueryItem(folder, list[0], (freefetchType & UserConfigurationTypes.Dictionary) > (UserConfigurationTypes)0); if (list.Count > 1) { ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>(0L, "UserConfiguration::GetIgnoringCache. Found duplicate items. Conflict resolution. ConfigName = {0}.", configurationName); List <VersionedId> list2 = new List <VersionedId>(); list = UserConfiguration.QueryConfigurations(folder, sorts, configurationName, UserConfigurationSearchFlags.FullString, 100, new PropertyDefinition[0]); for (int i = 1; i < list.Count; i++) { list2.Add((VersionedId)list[i][InternalSchema.ItemId]); } if (list2.Count > 0) { AggregateOperationResult result = folder.Session.Delete(DeleteItemFlags.HardDelete, list2.ToArray()); UserConfiguration.CheckOperationResults(result, "DeleteDuplicates"); } } flag = true; result2 = userConfiguration; } finally { if (!flag && userConfiguration != null) { userConfiguration.Dispose(); } } return(result2); }