/// <summary> /// Rename the given topic. If requested, find references and fix them up. Answer a report of what was fixed up. Throw a DuplicationTopicException /// if the new name is the name of a topic that already exists. /// </summary> /// <param name="oldName">Old topic name</param> /// <param name="newName">The new name</param> /// <param name="fixup">true to fixup referenced topic *in this namespace*; false to do no fixups</param> /// <returns>ArrayList of strings that can be reported back to the user of what happened during the fixup process</returns> public RenameTopicDetails RenameTopic(QualifiedTopicName oldName, UnqualifiedTopicName newName, ReferenceFixupPolicy fixupPolicy, string author) { NamespaceManager namespaceManager = NamespaceManagerForTopic(oldName); if (namespaceManager == null) { throw NamespaceNotFoundException.ForNamespace(oldName.Namespace); } return namespaceManager.RenameTopic(new UnqualifiedTopicName(oldName.LocalName), new UnqualifiedTopicName(newName.LocalName), fixupPolicy, author); }
/// <summary> /// Rename the given topic. If requested, find references and fix them up. Answer a report of what was fixed up. Throw a DuplicationTopicException /// if the new name is the name of a topic that already exists. /// </summary> /// <param name="oldName">Old topic name</param> /// <param name="newName">The new name</param> /// <param name="fixup">true to fixup referenced topic *in this namespace*; false to do no fixups</param> /// <returns>ArrayList of strings that can be reported back to the user of what happened during the fixup process</returns> public RenameTopicDetails RenameTopic(UnqualifiedTopicName oldName, UnqualifiedTopicName newName, ReferenceFixupPolicy fixupPolicy, string author) { RenameTopicDetails details = new RenameTopicDetails(); if (!TopicExists(oldName, ImportPolicy.DoNotIncludeImports)) { details.Result = RenameTopicResult.SourceTopicDoesNotExist; return details; } if (TopicExists(newName, ImportPolicy.DoNotIncludeImports)) { details.Result = RenameTopicResult.DestinationTopicExists; return details; } string oldTopicOldContents = Read(oldName.LocalName); string oldTopicNewContents = string.Format("Redirect: {0}\n\nThis topic was renamed to {0}.", newName.LocalName); WriteTopicAndNewVersion(oldName.LocalName, oldTopicNewContents, author); WriteTopicAndNewVersion(newName.LocalName, oldTopicOldContents, author); if (fixupPolicy == ReferenceFixupPolicy.FixReferences) { foreach (TopicName topicName in AllTopics(ImportPolicy.DoNotIncludeImports)) { bool renamed = RenameTopicReferences(topicName.LocalName, oldName.LocalName, newName.LocalName, author); if (renamed) { details.UpdatedReferenceTopics.Add(topicName); } } } details.Result = RenameTopicResult.Success; return details; }