private void ProcessFolderNameChange(FolderCommand.FolderRequest folderRequest, Folder folder) { if (folder.DisplayName != folderRequest.DisplayName) { folder.DisplayName = folderRequest.DisplayName; FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.Exception != null) { throw folderSaveResult.Exception; } if (folderSaveResult.OperationResult == OperationResult.PartiallySucceeded) { if (folderSaveResult.PropertyErrors.Length > 0) { PropertyError propertyError = folderSaveResult.PropertyErrors[0]; if (propertyError.PropertyErrorCode == PropertyErrorCode.FolderNameConflict) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FolderNameConflict"); throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), null, false); } this.ThrowUnknownFolderError(propertyError.PropertyErrorCode.ToString()); } this.ThrowUnknownFolderError("PartialSuccessNoPropertyErrors"); } folder.Load(); } }
protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator) { using (CalendarFolder calendarFolder = CalendarFolder.Bind(mailboxSession, context.FolderId, CalendarFolderSchema.ConsumerCalendarProperties)) { Guid a = calendarFolder.ConsumerCalendarGuid; Guid consumerCalendarPrivateFreeBusyId = calendarFolder.ConsumerCalendarPrivateFreeBusyId; Guid consumerCalendarPrivateDetailId = calendarFolder.ConsumerCalendarPrivateDetailId; if (a == Guid.Empty) { a = (calendarFolder.ConsumerCalendarGuid = Guid.NewGuid()); } if (consumerCalendarPrivateFreeBusyId == Guid.Empty) { Guid guid = calendarFolder.ConsumerCalendarPrivateFreeBusyId = Guid.NewGuid(); } if (consumerCalendarPrivateDetailId == Guid.Empty) { Guid guid2 = calendarFolder.ConsumerCalendarPrivateDetailId = Guid.NewGuid(); } if (calendarFolder.IsDirty) { FolderSaveResult folderSaveResult = calendarFolder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { throw folderSaveResult.ToException(new LocalizedString("TODO: LOC: Failed to share the calendar.")); } } context.FolderEwsId = a.ToString(); context.MailboxId = ((IUserPrincipal)mailboxSession.MailboxOwner).NetId.ToByteArray(); context.FolderName = (context.IsPrimary ? string.Format("TODO: LOC: {0}'s Calendar", context.InitiatorName) : calendarFolder.DisplayName); context.IsPrimary = false; } return(new PerformInvitationResults(recipients)); }
private void WorkWithPermissions(MailboxSession itemStore) { if (this.delegatesToAddPermission.Count > 0 || this.delegatesToRemovePermission.Count > 0 || this.policyMembersToAddPermission.Count > 0 || this.policyMembersToRemovePermission.Count > 0 || this.oldAllPolicy != this.newAllPolicy) { using (CalendarFolder calendarFolder = CalendarFolder.Bind(itemStore, DefaultFolderType.Calendar)) { using (Folder folder = Folder.Create(itemStore, itemStore.GetDefaultFolderId(DefaultFolderType.Configuration), StoreObjectType.Folder, "Freebusy Data", CreateMode.OpenIfExists)) { CalendarFolderPermissionSet permissionSet = calendarFolder.GetPermissionSet(); PermissionSet permissionSet2 = folder.GetPermissionSet(); permissionSet.DefaultPermission.FreeBusyAccess = (this.newAllPolicy ? FreeBusyAccess.Details : FreeBusyAccess.Basic); this.AddPermissions(permissionSet, permissionSet2); this.RemovePermissions(permissionSet, permissionSet2); FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded) { base.ThrowTerminatingError(new FolderSaveException(Strings.CalendarSave, folderSaveResult), ErrorCategory.InvalidOperation, null); } folderSaveResult = calendarFolder.Save(); if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded) { base.ThrowTerminatingError(new FolderSaveException(Strings.CalendarSave, folderSaveResult), ErrorCategory.InvalidOperation, null); } } } if (this.delegatesToAddPermission.Count > 0 || this.delegatesToRemovePermission.Count > 0) { this.DataObject.GrantSendOnBehalfTo = this.Instance.ResourceDelegates; base.DataSession.Save(this.DataObject); } } }
internal static Folder CreateELCRootFolder(MailboxSession mailboxSession, string elcRootUrl) { string arg = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); ProvisionedFolderCreator.Tracer.TraceDebug <string>(0L, "'{0}': Attempting to create the ELC Root Folder.", arg); if (mailboxSession.CreateDefaultFolder(DefaultFolderType.ElcRoot) == null) { throw new ELCRootFailureException(Strings.descFailedToCreateELCRoot(mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()), null); } Folder folder = Folder.Bind(mailboxSession, DefaultFolderType.ElcRoot, new PropertyDefinition[] { FolderSchema.FolderHomePageUrl }); if (!string.IsNullOrEmpty(elcRootUrl)) { ProvisionedFolderCreator.Tracer.TraceDebug <string, string>(0L, "'{0}': Attempting to set the ELC Root Folder URL to '{1}'.", arg, elcRootUrl); ElcMailboxHelper.SetPropAndTrace(folder, FolderSchema.FolderHomePageUrl, elcRootUrl); folder.ClassName = Globals.ElcRootFolderClass; FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { ProvisionedFolderCreator.Tracer.TraceError <SmtpAddress>(0L, "{0}: Unable to set the ELC Root Folder home page. Will attempt this again on the next run.", mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress); } folder.Load(); } return(folder); }
// Token: 0x06000475 RID: 1141 RVA: 0x00020064 File Offset: 0x0001E264 internal static void AssignTagPropsToFolder(FolderTuple source, Folder target, MailboxSession session) { StoreObjectId objectId = target.Id.ObjectId; for (FolderHelper.DataColumnIndex dataColumnIndex = FolderHelper.DataColumnIndex.startOfTagPropsIndex; dataColumnIndex <= FolderHelper.DataColumnIndex.containerClassIndex; dataColumnIndex++) { PropertyDefinition key = FolderHelper.DataColumns[(int)dataColumnIndex]; object obj = source.FolderProps[key]; if (obj != null && !(obj is PropertyError)) { if (dataColumnIndex != FolderHelper.DataColumnIndex.containerClassIndex) { target[FolderHelper.DataColumns[(int)dataColumnIndex]] = obj; } else if (target.GetValueOrDefault <string>(FolderHelper.DataColumns[(int)dataColumnIndex], null) == null) { target[FolderHelper.DataColumns[(int)dataColumnIndex]] = obj; } } else if (target.GetValueOrDefault <object>(FolderHelper.DataColumns[(int)dataColumnIndex]) != null && dataColumnIndex != FolderHelper.DataColumnIndex.containerClassIndex) { target.DeleteProperties(new PropertyDefinition[] { FolderHelper.DataColumns[(int)dataColumnIndex] }); } } FolderSaveResult folderSaveResult = target.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { FolderTuple.Tracer.TraceError <StoreObjectId, FolderSaveResult>(0L, "AssignTagPropsToFolder for folder {0} save result {1}", objectId, folderSaveResult); throw new IWPermanentException(Strings.descUnableToSaveFolderTagProperties(objectId.ToString(), session.MailboxOwner.ToString(), folderSaveResult.ToString())); } }
protected override void InternalSave(ConfigurableObject instance) { if (instance == null) { throw new ArgumentNullException("instance"); } MailboxFolder mailboxFolder = instance as MailboxFolder; if (mailboxFolder == null) { throw new NotSupportedException("Save: " + instance.GetType().FullName); } FolderSaveResult folderSaveResult = null; switch (mailboxFolder.ObjectState) { case ObjectState.New: try { using (Folder folder = Folder.Create(base.MailboxSession, mailboxFolder.InternalParentFolderIdentity, ObjectClass.GetObjectType(mailboxFolder.FolderClass), mailboxFolder.Name, CreateMode.CreateNew)) { mailboxFolder.SaveDataToXso(folder, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition> { MailboxFolderSchema.Name, MailboxFolderSchema.InternalParentFolderIdentity })); MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(mailboxFolder.Name, folder, mailboxFolder.Schema); folderSaveResult = folder.Save(); } goto IL_FD; } catch (ObjectExistedException innerException) { throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(mailboxFolder.Name), innerException); } break; case ObjectState.Unchanged: goto IL_FD; case ObjectState.Changed: break; case ObjectState.Deleted: throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted); default: goto IL_FD; } throw new NotImplementedException("Save.Changed"); IL_FD: if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded) { throw folderSaveResult.ToException(ServerStrings.ErrorFolderSave(instance.Identity.ToString(), folderSaveResult.ToString())); } }
internal static void SaveELCFolder(Folder folder, bool create) { string displayName = folder.DisplayName; bool flag = false; LocalizedException innerException = null; try { FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult == OperationResult.Succeeded) { return; } if (folderSaveResult.OperationResult == OperationResult.PartiallySucceeded) { ProvisionedFolderCreator.Tracer.TraceError <string>(0L, "Failed to set ELC props on folder '{0}'.", displayName); foreach (PropertyError propertyError in folderSaveResult.PropertyErrors) { ProvisionedFolderCreator.Tracer.TraceError <PropertyDefinition, PropertyErrorCode, string>(0L, "Failed to set '{0}', error '{1}', on folder '{2}'.", propertyError.PropertyDefinition, propertyError.PropertyErrorCode, displayName); if (propertyError.PropertyDefinition == FolderSchema.ELCPolicyIds || propertyError.PropertyDefinition == FolderSchema.AdminFolderFlags) { flag = true; } } } else if (folderSaveResult.OperationResult == OperationResult.Failed) { ProvisionedFolderCreator.Tracer.TraceError <string>(0L, "Failed to create or update the ELC folder '{0}'.", displayName); flag = true; } } catch (ObjectNotFoundException ex) { ProvisionedFolderCreator.Tracer.TraceError <string>(0L, "Failed to set ELC props on folder '{0}' - the folder was not found in the mailbox.", displayName); flag = true; innerException = ex; } catch (SaveConflictException ex2) { ProvisionedFolderCreator.Tracer.TraceError <string>(0L, "Failed to set ELC props on folder '{0}' - conflict during save.", displayName); flag = true; innerException = ex2; } if (flag) { if (create) { ProvisionedFolderCreator.Tracer.TraceError <string>(0L, "Unable to save the ELC folder '{0}' in the mailbox.", displayName); throw new ELCOrgFolderCreationException(((MailboxSession)folder.Session).MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), displayName, innerException); } ProvisionedFolderCreator.Tracer.TraceError <string>(0L, "Unable to sync the ELC folder '{0}' in the mailbox.", displayName); throw new ELCFolderSyncException(((MailboxSession)folder.Session).MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), displayName, innerException); } }
public override void Save(SaveMode saveMode) { FolderSaveResult folderSaveResult = this.Folder.Save(saveMode); if (folderSaveResult.OperationResult == OperationResult.Succeeded) { return; } if (AnchorUtil.IsTransientException(folderSaveResult.Exception)) { throw new MigrationTransientException(folderSaveResult.Exception.LocalizedString, folderSaveResult.Exception); } throw new MigrationPermanentException(folderSaveResult.Exception.LocalizedString, folderSaveResult.Exception); }
protected override void SaveAndCheckForConflicts(ICalendarFolder storeObject, SaveMode saveMode) { string displayName = storeObject.DisplayName; try { FolderSaveResult folderSaveResult = storeObject.Save(saveMode); switch (folderSaveResult.OperationResult) { case OperationResult.Failed: throw new CalendarFolderUpdateFailedException(folderSaveResult.Exception); case OperationResult.PartiallySucceeded: if (folderSaveResult.PropertyErrors.Length == 1 && folderSaveResult.PropertyErrors[0].PropertyDefinition == FolderSchema.DisplayName && folderSaveResult.PropertyErrors[0].PropertyErrorCode == PropertyErrorCode.FolderNameConflict) { throw new CalendarNameAlreadyInUseException(displayName, folderSaveResult.Exception); } throw new CalendarFolderUpdateFailedException(folderSaveResult.Exception); } } catch (ObjectValidationException ex) { IMailboxSession mailboxSession = base.Session as IMailboxSession; bool flag = mailboxSession != null && mailboxSession.IsDefaultFolderType(storeObject.Id) == DefaultFolderType.Calendar; bool flag2; if (flag) { flag2 = (ex.Errors.FirstOrDefault((StoreObjectValidationError x) => x.PropertyDefinition == FolderSchema.DisplayName) != null); } else { flag2 = false; } bool flag3 = flag2; if (flag3) { throw new CannotRenameDefaultCalendarException(ex); } throw; } catch (ObjectExistedException innerException) { throw new CalendarNameAlreadyInUseException(displayName, innerException); } }
public override void Apply(CoreFolder folder) { using (UserConfiguration mailboxConfiguration = this.GetMailboxConfiguration(folder)) { IDictionary dictionary = mailboxConfiguration.GetDictionary(); dictionary["OlcIsVisible"] = this.IsVisible; dictionary["OlcIsHidden"] = this.IsHidden; dictionary["OlcColorIndex"] = this.ColorIndex; dictionary["OlcIsDailySummaryEnabled"] = this.IsDailySummaryEnabled; dictionary["ConsumerTaskPermissionLevel"] = this.ConsumerTaskPermissionLevel; dictionary["OlcConsecutiveErrorCount"] = this.ConsecutiveErrorCount; dictionary["OlcTotalErrorCount"] = this.TotalErrorCount; dictionary["OlcPollingInterval"] = this.PollingInterval; dictionary["OlcEntityTag"] = (this.EntityTag ?? string.Empty); dictionary["OlcImportedEventCount"] = this.ImportedEventCount; dictionary["OlcTotalEventCount"] = this.TotalEventCount; dictionary["OlcUpdateStatus"] = this.UpdateStatus; dictionary["OlcMissingUidCount"] = this.MissingUidCount; dictionary["OlcConsecutiveCriticalErrorCount"] = this.ConsecutiveCriticalErrorCount; dictionary["OlcPersonIdMigrated"] = this.PersonIdMigrated; ConflictResolutionResult conflictResolutionResult = mailboxConfiguration.Save(SaveMode.ResolveConflicts); if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict) { throw new ConversionFailedException(ConversionFailureReason.ConverterInternalFailure, MrsStrings.ReportCalendarFolderFaiSaveFailed, null); } MrsTracer.Provider.Debug("Calendar folder user configuration has been updated.", new object[0]); } folder.PropertyBag.Load(CalendarFolderSchema.Instance.AutoloadProperties); if (this.OlcCalendarType != OlcCalendarType.RegularEvents) { folder.PropertyBag[FolderSchema.DisplayName] = (this.Name ?? string.Empty); } folder.PropertyBag[CalendarFolderSchema.CharmId] = (this.CharmId ?? string.Empty); FolderSaveResult folderSaveResult = folder.Save(SaveMode.NoConflictResolution); if (folderSaveResult.OperationResult == OperationResult.Failed) { throw new ConversionFailedException(ConversionFailureReason.ConverterInternalFailure, MrsStrings.ReportCalendarFolderSaveFailed, null); } MrsTracer.Provider.Debug("Calendar folder has been updated with settings.", new object[0]); folder.PropertyBag.Load(CalendarFolderSchema.Instance.AutoloadProperties); }
public void Rename() { ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "TreeEventHandler.Rename"); OwaStoreObjectId owaStoreObjectId = (OwaStoreObjectId)base.GetParameter("destId"); string text = ((string)base.GetParameter("fN")).Trim(); string s = text; if (text.Length == 0) { throw new OwaEventHandlerException("User did not provide name for new folder", LocalizedStrings.GetNonEncoded(-41080803), true); } using (Folder folder = Utilities.GetFolder <Folder>(base.UserContext, owaStoreObjectId, new PropertyDefinition[0])) { if (!Utilities.CanFolderBeRenamed(base.UserContext, folder)) { throw new OwaInvalidRequestException("Folder cannot be renamed."); } folder.DisplayName = text; FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { if (Utilities.IsFolderNameConflictError(folderSaveResult)) { throw new OwaEventHandlerException("Folder rename did not return OperationResult.Succeeded", LocalizedStrings.GetNonEncoded(1602494619), OwaEventHandlerErrorCode.FolderNameExists, true); } throw new OwaAccessDeniedException(LocalizedStrings.GetNonEncoded(995407892)); } else { if (owaStoreObjectId.IsArchive) { s = string.Format(LocalizedStrings.GetNonEncoded(-83764036), text, Utilities.GetMailboxOwnerDisplayName((MailboxSession)folder.Session)); } this.Writer.Write("<div id=tn>"); Utilities.HtmlEncode(text, this.Writer, true); this.Writer.Write("</div><div id=ntn>"); Utilities.HtmlEncode(s, this.Writer, true); this.Writer.Write("</div>"); } } }
// Token: 0x06000A17 RID: 2583 RVA: 0x000429E0 File Offset: 0x00040BE0 private StoreObjectId GetSettingsFolderID(string settingsFolderName) { StoreObjectId defaultFolderId = this.systemMailboxSession.GetDefaultFolderId(DefaultFolderType.Configuration); StoreObjectId objectId; using (Folder folder = Folder.Create(this.systemMailboxSession, defaultFolderId, StoreObjectType.Folder, settingsFolderName, CreateMode.OpenIfExists)) { if (folder.Id == null) { FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { SystemMailbox.Tracer.TraceError <IExchangePrincipal>((long)this.GetHashCode(), "Failed to open settings folder in the config folder:{0}", this.systemMailboxSession.MailboxOwner); throw new TransientMailboxException(Strings.descFailedToCreateTempFolder(this.systemMailboxSession.MailboxOwner.MailboxInfo.DisplayName, this.databaseInfo.DisplayName)); } folder.Load(); } objectId = folder.Id.ObjectId; } return(objectId); }
private StoreId CreateFolder(MailboxSession mailboxSession, StoreId parentId, string displayName, bool sourceBasedFolder) { StoreId result = null; using (Folder folder = Folder.Create(mailboxSession, parentId, StoreObjectType.Folder, displayName, CreateMode.OpenIfExists)) { if (sourceBasedFolder) { folder[FolderSchema.OwaViewStateSortColumn] = "DeliveryTime"; } FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { SearchMailboxAction.Tracer.TraceError <string, FolderSaveResult>((long)this.GetHashCode(), "Folder.Save operation failed on mailbox {0} with operation result {1} ", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, folderSaveResult); throw folderSaveResult.ToException(Strings.CreateFolderFailed(displayName)); } folder.Load(); result = folder.Id; } return(result); }
private static StoreObjectId CreateFreeBusyFolder(PublicFolderSession session, StoreObjectId parentFolder, string folderName) { Exception ex = null; try { using (Folder folder = Folder.Create(session, parentFolder, StoreObjectType.Folder, folderName, CreateMode.OpenIfExists)) { folder[FolderSchema.ResolveMethod] = (ResolveMethod.LastWriterWins | ResolveMethod.NoConflictNotification); FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult == OperationResult.Succeeded) { folder.Load(); StoreObjectId objectId = folder.Id.ObjectId; FreeBusyFolder.Tracer.TraceDebug <string, StoreObjectId, StoreObjectId>(0L, "Created free/busy folder '{0}' under folder '{1}' with id '{2}'.", folderName, parentFolder, objectId); return(objectId); } ex = folderSaveResult.Exception; } } catch (PropertyErrorException ex2) { ex = ex2; } catch (CorruptDataException ex3) { ex = ex3; } catch (ObjectNotFoundException ex4) { ex = ex4; } if (ex != null) { FreeBusyFolder.Tracer.TraceError <string, StoreObjectId, Exception>(0L, "Failed to create free/busy folder '{0}' under folder '{1}' due exception: {2}", folderName, parentFolder, ex); } return(null); }
public void Rename() { base.ThrowIfCannotActAsOwner(); string text = ((string)base.GetParameter("SB")).Trim(); string s = text; NavigationNodeGroupSection navigationNodeGroupSection = (NavigationNodeGroupSection)base.GetParameter("GS"); NavigationNodeCollection navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, navigationNodeGroupSection); NavigationNode navigationNode = navigationNodeCollection.FindNavigationNodeByNodeId((StoreObjectId)base.GetParameter("srcNId")); if (navigationNode == null) { throw new OwaEventHandlerException("Cannot find specified navigation node", LocalizedStrings.GetNonEncoded(-289549140), true); } if (text.Length != 0) { if (navigationNode is NavigationNodeFolder) { NavigationNodeFolder navigationNodeFolder = navigationNode as NavigationNodeFolder; if (!navigationNodeFolder.IsValid) { throw new OwaInvalidRequestException("This is not a valid navigation node"); } if (navigationNodeFolder.NavigationNodeType == NavigationNodeType.SmartFolder && !navigationNodeFolder.IsFilteredView) { throw new OwaInvalidRequestException("Cannot rename search folders"); } OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromNavigationNodeFolder(base.UserContext, navigationNodeFolder); MailboxSession mailboxSession = owaStoreObjectId.IsArchive ? ((MailboxSession)owaStoreObjectId.GetSession(base.UserContext)) : base.UserContext.MailboxSession; if (owaStoreObjectId.IsArchive && navigationNodeFolder.NavigationNodeType == NavigationNodeType.NormalFolder) { s = string.Format(LocalizedStrings.GetNonEncoded(-83764036), text, Utilities.GetMailboxOwnerDisplayName(mailboxSession)); } if (navigationNodeFolder.IsFolderInSpecificMailboxSession(mailboxSession)) { using (Folder folder = Folder.Bind(mailboxSession, navigationNodeFolder.FolderId, new PropertyDefinition[] { FolderSchema.ExtendedFolderFlags })) { if (!Utilities.CanFolderBeRenamed(base.UserContext, folder)) { throw new OwaInvalidRequestException("Folder cannot be renamed."); } folder.DisplayName = text; FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { if (Utilities.IsFolderNameConflictError(folderSaveResult)) { throw new OwaEventHandlerException("Folder rename did not return OperationResult.Succeeded", LocalizedStrings.GetNonEncoded(1602494619), OwaEventHandlerErrorCode.FolderNameExists, true); } throw new OwaAccessDeniedException(LocalizedStrings.GetNonEncoded(995407892)); } } } } navigationNode.Subject = text; navigationNodeCollection.Save(base.UserContext.MailboxSession); this.Writer.Write("<div id=tn>"); Utilities.HtmlEncode(text, this.Writer, true); this.Writer.Write("</div><div id=ntn>"); Utilities.HtmlEncode(s, this.Writer, true); this.Writer.Write("</div>"); return; } if (navigationNode is NavigationNodeGroup) { throw new OwaEventHandlerException("User did not provide name for new group", LocalizedStrings.GetNonEncoded(-1749891264), true); } throw new OwaEventHandlerException("User did not provide name for new folder", LocalizedStrings.GetNonEncoded(-41080803), true); }
// Token: 0x060002D4 RID: 724 RVA: 0x00011398 File Offset: 0x0000F598 private StoreObjectId CreateFolderHierarchy(string[] subfoldersToCreate, StoreObjectId startFolderId, string sourcePath, string targetRootPath, string elcPolicyName, string startFolderPath) { string text = null; string text2 = string.Empty; foreach (string text2 in subfoldersToCreate) { text2 = text2.Replace('', '/'); text2 = text2.Trim(); FolderProcessor.Tracer.TraceDebug <FolderProcessor, string, string>((long)this.GetHashCode(), "{0}: ExpirationEnforcer is creating folder hierarchy under target folder. Source folder: {1}. Going to create subfolder {2} under target.", this, sourcePath, text2); try { using (Folder folder = Folder.Create(this.mailboxSession, startFolderId, StoreObjectType.Folder, text2, CreateMode.OpenIfExists)) { object obj = folder.TryGetProperty(FolderSchema.ExtendedFolderFlags); if (!(obj is ExtendedFolderFlags)) { folder[FolderSchema.ExtendedFolderFlags] = ExtendedFolderFlags.ShowTotal; } FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { text = folderSaveResult.ToString(); break; } folder.Load(); startFolderId = folder.Id.ObjectId; FolderProcessor.Tracer.TraceDebug <FolderProcessor, string, string>((long)this.GetHashCode(), "{0}: ExpirationEnforcer is creating folder hierarchy under target folder. Source folder name: {1}. Just created subfolder {2} under target.", this, sourcePath, folder.DisplayName); } } catch (PropertyErrorException ex) { text = ex.ToString(); break; } catch (CorruptDataException ex2) { text = ex2.ToString(); break; } catch (ObjectNotFoundException ex3) { text = ex3.ToString(); break; } } if (!string.IsNullOrEmpty(text)) { FolderProcessor.Tracer.TraceError((long)this.GetHashCode(), "{0}: ExpirationEnforcer: Failed to create folder hierarchy. Policy '{1}'. Source folder path '{2}'. Target folder path '{3}'. Creating the subfolder '{4}' under '{5}' failed. Error: ", new object[] { this, elcPolicyName, sourcePath, targetRootPath, text2, startFolderPath, text }); Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_FailedToCreateFolderHierarchy, null, new object[] { sourcePath, this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), elcPolicyName, targetRootPath, text2, startFolderPath, text }); throw new InvalidExpiryDestinationException(Strings.descFailedToCreateFolderHierarchy(sourcePath, this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString())); } return(startFolderId); }
protected override void InternalSave(ConfigurableObject instance) { PublicFolder publicFolder = instance as PublicFolder; if (publicFolder == null) { throw new NotSupportedException("Save: " + instance.GetType().FullName); } FolderSaveResult folderSaveResult = null; switch (publicFolder.ObjectState) { case ObjectState.New: try { using (Folder folder = Folder.Create(this.PublicFolderSession, publicFolder.InternalParentFolderIdentity, ObjectClass.GetObjectType(publicFolder.FolderClass), publicFolder.Name, CreateMode.CreateNew)) { publicFolder.SaveDataToXso(folder, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition> { PublicFolderSchema.Name, MailboxFolderSchema.InternalParentFolderIdentity })); MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(publicFolder.Name, folder, publicFolder.Schema); folderSaveResult = folder.Save(); publicFolder.OrganizationId = this.PublicFolderSession.OrganizationId; } goto IL_157; } catch (ObjectExistedException innerException) { throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(publicFolder.Name), innerException); } break; case ObjectState.Unchanged: goto IL_157; case ObjectState.Changed: break; case ObjectState.Deleted: goto IL_147; default: goto IL_157; } using (Folder folder2 = Folder.Bind(this.PublicFolderSession, publicFolder.InternalFolderIdentity, null)) { publicFolder.SaveDataToXso(folder2, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition> { MailboxFolderSchema.InternalParentFolderIdentity })); MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(publicFolder.Name, folder2, publicFolder.Schema); folderSaveResult = folder2.Save(); goto IL_157; } IL_147: throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted); IL_157: if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded && folderSaveResult.PropertyErrors.Length > 0) { foreach (PropertyError propertyError in folderSaveResult.PropertyErrors) { if (propertyError.PropertyErrorCode == PropertyErrorCode.FolderNameConflict) { throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(publicFolder.Name)); } } throw folderSaveResult.ToException(ServerStrings.ErrorFolderSave(instance.Identity.ToString(), folderSaveResult.ToString())); } }
public void AddFilterToFavorites() { string text = ((string)base.GetParameter("fltrSbj")).Trim(); if (text.Length == 0) { throw new OwaEventHandlerException("User did not provide name for new folder", LocalizedStrings.GetNonEncoded(-41080803), true); } if (text.Length > 256) { text = text.Substring(0, 256); } base.BindToFolder(); try { if (Utilities.IsDefaultFolder(base.ContextFolder, DefaultFolderType.DeletedItems) || Utilities.IsItemInDefaultFolder(base.ContextFolder, DefaultFolderType.DeletedItems) || Utilities.IsFavoritesFilterFolder(base.UserContext, base.ContextFolder)) { throw new OwaInvalidRequestException("Only normal folder or Outlook search folder can be filtered."); } if (base.FilteredFolder != null) { NavigationNodeCollection navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, NavigationNodeGroupSection.First); if (navigationNodeCollection.FindFoldersById(base.FilteredFolder.Id.ObjectId).Length > 0) { throw new OwaEventHandlerException("Filtered view has already been added.", LocalizedStrings.GetNonEncoded(-44763698), true); } int num = 0; foreach (NavigationNodeFolder navigationNodeFolder in navigationNodeCollection[0].Children) { if (navigationNodeFolder.IsValid && navigationNodeFolder.IsFilteredView) { num++; } } if (num >= Globals.MaximumFilteredViewInFavoritesPerUser) { string description = string.Format(base.UserContext.UserCulture, LocalizedStrings.GetNonEncoded(-529843556), new object[] { Globals.MaximumFilteredViewInFavoritesPerUser }); throw new OwaEventHandlerException("Filtered view exceeds budget.", description, true); } base.FilteredFolder[FolderSchema.SearchFolderAllowAgeout] = false; base.FilteredFolder.DisplayName = text; FolderSaveResult folderSaveResult = base.FilteredFolder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { if (Utilities.IsFolderNameConflictError(folderSaveResult)) { throw new OwaEventHandlerException("Folder name exists", LocalizedStrings.GetNonEncoded(-1782850773), OwaEventHandlerErrorCode.FolderNameExists, true); } throw new OwaEventHandlerException("Fail to save folder properties.", LocalizedStrings.GetNonEncoded(-920350130), true); } else { base.FilteredFolder.Load(FolderList.FolderTreeQueryProperties); NavigationNodeFolder navigationNodeFolder2 = navigationNodeCollection.AppendFolderToFavorites(base.FilteredFolder); navigationNodeFolder2.SetFilterParameter(base.FilterCondition.SourceFolderId.StoreObjectId, base.FilterCondition.GetBooleanFlags(), base.FilterCondition.GetCategories(), base.FilterCondition.From, base.FilterCondition.To); navigationNodeCollection.Save(base.UserContext.MailboxSession); navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, NavigationNodeGroupSection.First); NavigationHost.RenderFavoritesAndNavigationTrees(this.Writer, base.UserContext, null, new NavigationNodeGroupSection[] { NavigationNodeGroupSection.First }); } } } finally { this.EndProcessEvent(); } }