예제 #1
0
        /// <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;
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
 private static string MakeTopicName(UnqualifiedTopicName topic)
 {
     return MakeTopicName(new UnqualifiedTopicRevision(topic));
 }
예제 #4
0
 public override bool TopicIsReadOnly(UnqualifiedTopicName topicName)
 {
     return (!_sqlHelper.IsExistingTopicWritable(Namespace, MakeTopicName(topicName)));
 }
예제 #5
0
        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)
 {
 }
예제 #7
0
 private bool IsBuiltInTopic(UnqualifiedTopicName topic)
 {
     QualifiedTopicName qualifiedTopicName = new QualifiedTopicName(topic.LocalName, Namespace);
     return GetBuiltInTopics().Contains(qualifiedTopicName); 
 }
예제 #8
0
        // 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; 
        }
예제 #9
0
 /// <summary>
 /// Delete a topic
 /// </summary>
 /// <param name="topic"></param>
 public virtual void DeleteTopic(UnqualifiedTopicName topic, bool removeHistory)
 {
     _next.DeleteTopic(topic, removeHistory);
 }
예제 #10
0
 /// <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);
 }
예제 #11
0
 public override void WriteTopicAndNewVersion(UnqualifiedTopicName topic, string content, string author)
 {
     throw new NotImplementedException();
 }
예제 #12
0
        /// <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));

        }
예제 #13
0
        /// <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);
        }
예제 #14
0
 /// <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);
 }
예제 #15
0
 /// <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);
 }
예제 #16
0
        public override bool TopicExists(UnqualifiedTopicName name)
        {
            throw new NotImplementedException();

            //foreach (AbsoluteTopicName each in AllTopicsUnsorted())
            //{
            //    if (each.LocalName.Equals(name))

            //        return true;
            //}
            //return false;
        }
예제 #17
0
 public override bool TopicIsReadOnly(UnqualifiedTopicName name)
 {
     throw new NotImplementedException();
 }
예제 #18
0
 /// <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);
 }
예제 #19
0
        public override bool TopicExists(UnqualifiedTopicName name)
        {
            if (IsBuiltInTopic(name))
            {
                return true; 
            }

            return Next.TopicExists(name); 
        }
예제 #20
0
 /// <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)
 {
 }
예제 #22
0
 public virtual bool TopicIsReadOnly(UnqualifiedTopicName name)
 {
     return _next.TopicIsReadOnly(name);
 }
예제 #23
0
        /// <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);
                }
            }
        }
예제 #24
0
 /// <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);
 }
예제 #25
0
 /// <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));
 }
예제 #26
0
 /// <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;
      */
 }
예제 #27
0
 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.");
 }
예제 #28
0
 public override void DeleteTopic(UnqualifiedTopicName topicName)
 {
     throw new NotImplementedException();
 }
예제 #29
0
 public override bool HasPermission(UnqualifiedTopicName topicName, TopicPermission permission)
 {
     throw new NotImplementedException();
 }
예제 #30
0
 public string Read(UnqualifiedTopicName topic)
 {
     return Read(new UnqualifiedTopicRevision(topic.LocalName, null)); 
 }