/// <summary> /// Renames and re-indexes a page attachment. /// </summary> /// <param name="provider">The provider.</param> /// <param name="pageFullName">The page full name.</param> /// <param name="name">The attachment name.</param> /// <param name="newName">The new attachment name.</param> /// <returns><c>true</c> if the attachment was rename, <c>false</c> otherwise.</returns> public static bool RenamePageAttachment(IFilesStorageProviderV40 provider, string pageFullName, string name, string newName) { if (provider == null) { throw new ArgumentNullException("provider"); } if (pageFullName == null) { throw new ArgumentNullException("pageFullName"); } if (pageFullName.Length == 0) { throw new ArgumentException("Page Full Name cannot be empty", "pageFullName"); } if (name == null) { throw new ArgumentNullException("name"); } if (name.Length == 0) { throw new ArgumentException("Name cannot be empty", "name"); } if (newName == null) { throw new ArgumentNullException("newName"); } if (newName.Length == 0) { throw new ArgumentException("New Name cannot be empty", "newName"); } if (name.ToLowerInvariant() == newName.ToLowerInvariant()) { return(false); } PageContent page = Pages.FindPage(provider.CurrentWiki, pageFullName); if (page == null) { return(false); } bool done = provider.RenamePageAttachment(pageFullName, name, newName); if (!done) { return(false); } SearchClass.RenamePageAttachment(page, name, newName); Host.Instance.OnAttachmentActivity(provider.GetType().FullName, newName, pageFullName, name, FileActivity.AttachmentRenamed); return(true); }