/// <summary> /// A list of TopicChanges to a topic since a given date [sorted by date] /// </summary> /// <param name="topic">A given date</param> /// <param name="stamp">A non-null timestamp; changes before this time won't be included in the answer </param> /// <param name="rule">A composite cache rule to fill with rules that represented accumulated dependencies (or null)</param> /// <returns>Enumeration of TopicChanges</returns> public override TopicChangeCollection AllChangesForTopicSince(UnqualifiedTopicName topic, DateTime stamp) { TopicChangeCollection answer = new TopicChangeCollection(); SqlInfoForTopic[] infos = _sqlHelper.GetSqlTopicInfosForTopicSince(Namespace, topic.LocalName, stamp); ArrayList sortable = new ArrayList(); foreach (SqlInfoForTopic each in infos) { sortable.Add(new SqlInfoTopicData(each, Namespace)); } sortable.Sort(new TimeSort()); foreach (TopicData each in sortable) { if (each.LastModificationTime < stamp) { continue; } QualifiedTopicRevision name = new QualifiedTopicRevision(topic.LocalName, Namespace); name.Version = each.Version; TopicChange change = TopicChangeFromName(name); answer.Add(change); } return answer; }
/// <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; }
private static string MakeTopicName(UnqualifiedTopicName topic) { return MakeTopicName(new UnqualifiedTopicRevision(topic)); }
public override bool TopicIsReadOnly(UnqualifiedTopicName topicName) { return (!_sqlHelper.IsExistingTopicWritable(Namespace, MakeTopicName(topicName))); }
public override bool HasPermission(UnqualifiedTopicName topic, TopicPermission permission) { if (!_sqlHelper.TopicExists(Namespace, topic.LocalName)) { // It might seem a little weird to return true if the topic doesn't exist, but // basically what we're saying is that there's no reason to deny read/edit return true; } if (permission == TopicPermission.Read) { return true; } else if (permission == TopicPermission.Edit) { return _sqlHelper.IsExistingTopicWritable(Namespace, topic.LocalName); } else { throw new ArgumentException("Unrecognized topic permission: " + permission.ToString()); } }
public UnqualifiedTopicRevision(UnqualifiedTopicName name, string version) : base(name, version) { }
private bool IsBuiltInTopic(UnqualifiedTopicName topic) { QualifiedTopicName qualifiedTopicName = new QualifiedTopicName(topic.LocalName, Namespace); return GetBuiltInTopics().Contains(qualifiedTopicName); }
// Properties // Methods public override TopicChangeCollection AllChangesForTopicSince(UnqualifiedTopicName topic, DateTime stamp) { TopicChangeCollection changes = Next.AllChangesForTopicSince(topic, stamp); if (IsBuiltInTopic(topic)) { // All the built-in topics have a default revision at DateTime.MinValue. If the // timestamp is later than that, we don't report back the default revision. if (stamp == DateTime.MinValue) { if (changes == null) { changes = new TopicChangeCollection(); } changes.Insert(0, new TopicChange( new QualifiedTopicRevision( topic.LocalName, NamespaceManager.Namespace, QualifiedTopicRevision.NewVersionStringForUser(c_builtInAuthor, DateTime.MinValue)), DateTime.MinValue, c_builtInAuthor)); } } return changes; }
/// <summary> /// Delete a topic /// </summary> /// <param name="topic"></param> public virtual void DeleteTopic(UnqualifiedTopicName topic, bool removeHistory) { _next.DeleteTopic(topic, removeHistory); }
/// <summary> /// A list of TopicChanges to a topic since a given date [sorted by date] /// </summary> /// <param name="topic">A given date</param> /// <param name="stamp">A non-null timestamp; changes before this time won't be included in the answer </param> /// <param name="rule">A composite cache rule to fill with rules that represented accumulated dependencies (or null)</param> /// <returns>List of <see cref="TopicChange" /> objects, sorted so that the newest appears first in the list.</returns> public virtual TopicChangeCollection AllChangesForTopicSince(UnqualifiedTopicName topic, DateTime stamp) { return _next.AllChangesForTopicSince(topic, stamp); }
public override void WriteTopicAndNewVersion(UnqualifiedTopicName topic, string content, string author) { throw new NotImplementedException(); }
/// <summary> /// Delete a topic /// </summary> /// <param name="topic"></param> public override void DeleteTopic(UnqualifiedTopicName topic) { if (!SqlHelper.TopicExists(Namespace, topic.LocalName, _connectionString)) { return; } SqlHelper.DeleteTopic(Namespace, topic.LocalName, _connectionString); // // Fire the event // FederationUpdate update = new FederationUpdate(); // update.RecordDeletedTopic(topic.AsAbsoluteTopicName(Namespace)); // OnFederationUpdated(new FederationUpdateEventArgs(update)); }
/// <summary> /// Answer whether a topic exists and is writable /// </summary> /// <param name="topic">The topic (must directly be in this content base)</param> /// <returns>true if the topic exists AND is writable by the current user; else false</returns> public override bool IsExistingTopicWritable(UnqualifiedTopicName topic) { if (!SqlHelper.TopicExists(Namespace, topic.LocalName, _connectionString)) { return false; } return SqlHelper.IsExistingTopicWritable(Namespace, topic.LocalName, _connectionString); }
/// <summary> /// Answer true if a topic exists in this ContentProviderChain /// </summary> /// <param name="name">Name of the topic</param> /// <returns>true if it exists</returns> public override bool TopicExists(UnqualifiedTopicName name) { return SqlHelper.TopicExists(Namespace, MakeTopicName(name), _connectionString); }
/// <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); }
public override bool TopicExists(UnqualifiedTopicName name) { throw new NotImplementedException(); //foreach (AbsoluteTopicName each in AllTopicsUnsorted()) //{ // if (each.LocalName.Equals(name)) // return true; //} //return false; }
public override bool TopicIsReadOnly(UnqualifiedTopicName name) { throw new NotImplementedException(); }
/// <summary> /// Answer whether the current user has the given permission for the specified topic. /// </summary> /// <param name="topic">The topic </param> /// <returns>true if the topic exists AND the specified permission is allowed for the current user; else false</returns> public virtual bool HasPermission(UnqualifiedTopicName topic, TopicPermission permission) { return _next.HasPermission(topic, permission); }
public override bool TopicExists(UnqualifiedTopicName name) { if (IsBuiltInTopic(name)) { return true; } return Next.TopicExists(name); }
/// <summary> /// Answer true if a topic exists in this namespace /// </summary> /// <param name="name">Name of the topic</param> /// <returns>true if it exists</returns> public virtual bool TopicExists(UnqualifiedTopicName name) { return _next.TopicExists(name); }
public UnqualifiedTopicRevision(UnqualifiedTopicName name) : base(name, null) { }
public virtual bool TopicIsReadOnly(UnqualifiedTopicName name) { return _next.TopicIsReadOnly(name); }
/// <summary> /// Delete a topic /// </summary> /// <param name="topic"></param> public override void DeleteTopic(UnqualifiedTopicName topic, bool removeHistory) { if (!_sqlHelper.TopicExists(Namespace, topic.LocalName)) { return; } _sqlHelper.DeleteTopic(Namespace, topic.LocalName); if (removeHistory) { QualifiedTopicNameCollection results = new QualifiedTopicNameCollection(); SqlInfoForTopic[] topicInfos = _sqlHelper.GetSqlTopicInfosForTopic(Namespace, topic.LocalName); foreach (SqlInfoForTopic topicInfo in topicInfos) { _sqlHelper.DeleteTopic(Namespace, topicInfo.Name); } } }
/// <summary> /// Makes an existing topic read-write. /// </summary> /// <param name="topic">The topic to modify.</param> /// <exception cref="TopicNotFoundException"> /// Thrown if the specified topic does not exist. /// </exception> public virtual void UnlockTopic(UnqualifiedTopicName topic) { Next.UnlockTopic(topic); }
/// <summary> /// Answer true if a topic exists in this ContentProviderChain /// </summary> /// <param name="name">Name of the topic</param> /// <returns>true if it exists</returns> public override bool TopicExists(UnqualifiedTopicName name) { return _sqlHelper.TopicExists(Namespace, MakeTopicName(name)); }
/// <summary> /// A list of TopicChanges to a topic since a given date [sorted by date] /// </summary> /// <param name="topic">A given date</param> /// <param name="stamp">A non-null timestamp; changes before this time won't be included in the answer </param> /// <returns>Enumeration of TopicChanges</returns> public override TopicChangeCollection AllChangesForTopicSince(UnqualifiedTopicName topic, DateTime stamp) { throw new NotImplementedException(); /* ArrayList answer = new ArrayList(); foreach (AbsoluteTopicName each in AllVersionsForTopic(topic)) { DateTime when = GetTopicLastModificationTime(topic); if (when >= stamp) answer.Add(new TopicChange(each, when, GetTopicLastAuthor(each.LocalName))); } return answer; */ }
public override void UnlockTopic(UnqualifiedTopicName topic) { _sqlHelper.WriteTopicUnlock(Namespace, MakeTopicName(topic)); //throw new NotImplementedException("Not implemented in this version of FlexWiki. Future releases may support locking topics in SQL stores."); }
public override void DeleteTopic(UnqualifiedTopicName topicName) { throw new NotImplementedException(); }
public override bool HasPermission(UnqualifiedTopicName topicName, TopicPermission permission) { throw new NotImplementedException(); }
public string Read(UnqualifiedTopicName topic) { return Read(new UnqualifiedTopicRevision(topic.LocalName, null)); }