public void OpenOtherUserFolder() { base.ThrowIfCannotActAsOwner(); if (base.UserContext.IsExplicitLogon) { throw new OwaInvalidRequestException("Cannot open other's folder in explict logon mode"); } NavigationNodeGroupSection navigationNodeGroupSection = (NavigationNodeGroupSection)base.GetParameter("GS"); if (navigationNodeGroupSection == NavigationNodeGroupSection.Contacts || navigationNodeGroupSection == NavigationNodeGroupSection.Tasks) { throw new OwaInvalidRequestException("Cannot open other's contacts/tasks folder"); } DefaultFolderType defaultFolderType; switch (navigationNodeGroupSection) { case NavigationNodeGroupSection.Mail: defaultFolderType = DefaultFolderType.Inbox; break; case NavigationNodeGroupSection.Calendar: defaultFolderType = DefaultFolderType.Calendar; break; case NavigationNodeGroupSection.Contacts: defaultFolderType = DefaultFolderType.Contacts; break; case NavigationNodeGroupSection.Tasks: defaultFolderType = DefaultFolderType.Tasks; break; default: throw new OwaInvalidRequestException("Invalid group section: " + navigationNodeGroupSection.ToString()); } RecipientInfoAC[] array = (RecipientInfoAC[])base.GetParameter("Recips"); if (array != null && array.Length != 0) { AutoCompleteCache.UpdateAutoCompleteCacheFromRecipientInfoList(array, base.OwaContext.UserContext); } if (defaultFolderType != DefaultFolderType.Calendar) { Folder folder = null; if (base.IsParameterSet("RCP")) { RecipientInfoAC recipientInfoAC = (RecipientInfoAC)base.GetParameter("RCP"); ExchangePrincipal exchangePrincipal = null; if (base.UserContext.DelegateSessionManager.TryGetExchangePrincipal(recipientInfoAC.RoutingAddress, out exchangePrincipal)) { if (string.Equals(base.UserContext.MailboxSession.MailboxOwnerLegacyDN, exchangePrincipal.LegacyDn, StringComparison.OrdinalIgnoreCase)) { throw new OwaEventHandlerException("Cannot open own folder", LocalizedStrings.GetNonEncoded(-1770024075), true); } folder = this.GetOtherUserFolder(exchangePrincipal, defaultFolderType); } } else { if (!base.IsParameterSet("Id")) { throw new OwaInvalidRequestException("Must specific one of recipient and folder Id."); } OwaStoreObjectId owaStoreObjectId = (OwaStoreObjectId)base.GetParameter("Id"); if (!owaStoreObjectId.IsOtherMailbox) { throw new OwaEventHandlerException("Cannot open own folder", LocalizedStrings.GetNonEncoded(-1770024075), true); } folder = Utilities.GetFolder <Folder>(base.UserContext, owaStoreObjectId, FolderList.FolderTreeQueryProperties); } try { if (folder == null || !Utilities.CanReadItemInFolder(folder)) { Strings.IDs localizedId = 1414246128; switch (navigationNodeGroupSection) { case NavigationNodeGroupSection.Mail: localizedId = -236167850; break; case NavigationNodeGroupSection.Contacts: localizedId = -1505241540; break; case NavigationNodeGroupSection.Tasks: localizedId = -65263937; break; } throw new OwaEventHandlerException(LocalizedStrings.GetNonEncoded(995407892), LocalizedStrings.GetNonEncoded(localizedId), true); } MailboxSession mailboxSession = folder.Session as MailboxSession; if (navigationNodeGroupSection == NavigationNodeGroupSection.Mail) { OtherMailboxConfigEntry otherMailboxConfigEntry = OtherMailboxConfiguration.AddOtherMailboxSession(base.UserContext, mailboxSession); if (otherMailboxConfigEntry != null) { NavigationHost.RenderOtherMailboxFolderTree(this.Writer, base.UserContext, otherMailboxConfigEntry, true); } } else { NavigationNodeCollection.AddNonMailFolderToSharedFoldersGroup(base.UserContext, folder, navigationNodeGroupSection); OwaStoreObjectId owaStoreObjectId2 = OwaStoreObjectId.CreateFromStoreObject(folder); NavigationHost.RenderFavoritesAndNavigationTrees(this.Writer, base.UserContext, owaStoreObjectId2, new NavigationNodeGroupSection[] { navigationNodeGroupSection }); this.RenderOpenOtherUserFolderReponse(folder.ClassName, owaStoreObjectId2); } } finally { if (folder != null) { folder.Dispose(); } } return; } if (!base.IsParameterSet("RCP")) { throw new OwaInvalidRequestException("Recipient is missing for open other user's calendar request"); } this.OpenOtherUserCalendar((RecipientInfoAC)base.GetParameter("RCP")); }
private static void ThrowIfGroupSectionNotMatchFolderClass(NavigationNodeGroupSection groupSection, string folderClass) { switch (groupSection) { case NavigationNodeGroupSection.First: if (string.IsNullOrEmpty(folderClass) || ObjectClass.IsOfClass(folderClass, "IPF.Note")) { return; } break; case NavigationNodeGroupSection.Calendar: if (ObjectClass.IsOfClass(folderClass, "IPF.Appointment")) { return; } break; case NavigationNodeGroupSection.Contacts: if (ObjectClass.IsOfClass(folderClass, "IPF.Contact")) { return; } break; case NavigationNodeGroupSection.Tasks: if (ObjectClass.IsOfClass(folderClass, "IPF.Task")) { return; } break; } throw new InvalidOperationException(string.Format("The folder container class \"{0}\" doesn't match the group section \"{1}\".", folderClass, groupSection.ToString())); }
public void AddNewFolder() { base.ThrowIfCannotActAsOwner(); string text = ((string)base.GetParameter("SB")).Trim(); if (text.Length == 0) { throw new OwaEventHandlerException("User did not provide name for new folder", LocalizedStrings.GetNonEncoded(-41080803), true); } NavigationNodeGroupSection navigationNodeGroupSection = (NavigationNodeGroupSection)base.GetParameter("GS"); StoreObjectType folderType; string className; DefaultFolderType defaultFolderType; switch (navigationNodeGroupSection) { case NavigationNodeGroupSection.Calendar: folderType = StoreObjectType.CalendarFolder; className = "IPF.Appointment"; defaultFolderType = DefaultFolderType.Calendar; break; case NavigationNodeGroupSection.Contacts: folderType = StoreObjectType.ContactsFolder; className = "IPF.Contact"; defaultFolderType = DefaultFolderType.Contacts; break; case NavigationNodeGroupSection.Tasks: folderType = StoreObjectType.TasksFolder; className = "IPF.Task"; defaultFolderType = DefaultFolderType.Tasks; break; default: throw new OwaInvalidRequestException("Invalid group section: " + navigationNodeGroupSection.ToString()); } StoreObjectId nodeId = (StoreObjectId)base.GetParameter("pid"); NavigationNodeCollection navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, navigationNodeGroupSection); int num = navigationNodeCollection.FindChildByNodeId(nodeId); if (num < 0) { throw new OwaEventHandlerException("The parent group doesn't exist.", LocalizedStrings.GetNonEncoded(-289549140), true); } using (Folder folder = Utilities.CreateSubFolder(Utilities.GetDefaultFolderId(base.UserContext, base.UserContext.MailboxSession, defaultFolderType), folderType, text, base.UserContext)) { folder.ClassName = className; try { folder.Save(); } catch (ObjectExistedException) { throw; } catch (StoragePermanentException innerException) { throw new OwaAccessDeniedException(LocalizedStrings.GetNonEncoded(995407892), innerException); } folder.Load(FolderList.FolderTreeQueryProperties); StoreObjectId objectId = folder.Id.ObjectId; navigationNodeCollection.AddFolderToGroup(num, folder, base.UserContext, folder.DisplayName, NavigationNodeType.NormalFolder); navigationNodeCollection.Save(base.UserContext.MailboxSession); navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, navigationNodeGroupSection); NavigationFolderTreeNode navigationFolderTreeNode = new NavigationFolderTreeNode(base.UserContext, navigationNodeCollection.FindFoldersById(objectId)[0], folder); NavigationFolderTreeNode navigationFolderTreeNode2 = navigationFolderTreeNode; navigationFolderTreeNode2.CustomAttributes += " _NF=1"; this.Writer.Write("<div id=ntn>"); navigationFolderTreeNode.RenderUndecoratedNode(this.Writer); this.Writer.Write("</div>"); } }