Ejemplo n.º 1
0
 public void RefreshData(XmlDocument doc)
 {
     Revisions.Clear();
     foreach (XmlElement elem in doc.FirstChild.ChildNodes)
     {
         Revisions.Add(Revision.CreateFromXml(elem));
     }
 }
Ejemplo n.º 2
0
        async Task ISessionAdapter.Save(ReviewRevision revision)
        {
            if (Revisions.Contains(revision))
            {
                return;
            }

            Assert.That(revision.RevisionNumber, Is.EqualTo(Revisions.Count + 1));

            Revisions.Add(revision);
        }
Ejemplo n.º 3
0
        public ReviewRevision MarkRevision(PublishReview.RevisionCommits commits)
        {
            var revision = new ReviewRevision
            {
                BaseCommit     = commits.Base,
                HeadCommit     = commits.Head,
                ReviewId       = ReviewId,
                RevisionNumber = Revisions.Count + 1,
                Id             = Guid.NewGuid()
            };

            Revisions.Add(revision);

            return(revision);
        }
Ejemplo n.º 4
0
        public virtual Revision Revise()
        {
            var original = LatestRevision;
            var revision = new Revision();

            if (original != null)
            {
                revision.Body   = original.Body;
                revision.Reason = original.Reason;
            }
            revision.Entry          = this;
            revision.Revised        = DateTime.UtcNow;
            revision.RevisionNumber = Revisions.Count + 1;
            LatestRevision          = revision;
            Revisions.Add(revision);
            return(revision);
        }
 /// <summary>
 /// Adds the value to the <see cref="Revisions"/> collection property and
 /// returns this <see cref="CloneCommand"/> instance.
 /// </summary>
 /// <param name="value">
 /// The value to add to the <see cref="Revisions"/> collection property.
 /// </param>
 /// <returns>
 /// This <see cref="CloneCommand"/> instance.
 /// </returns>
 /// <remarks>
 /// This method is part of the fluent interface.
 /// </remarks>
 public CloneCommand WithRevision(RevSpec value)
 {
     Revisions.Add(value);
     return(this);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds the value to the <see cref="Revisions"/> collection property and
 /// returns this <see cref="IncomingCommand"/> instance.
 /// </summary>
 /// <param name="value">
 /// The value to add to the <see cref="Revisions"/> collection property.
 /// </param>
 /// <returns>
 /// This <see cref="IncomingCommand"/> instance.
 /// </returns>
 /// <remarks>
 /// This method is part of the fluent interface.
 /// </remarks>
 public IncomingCommand WithRevision(RevSpec value)
 {
     Revisions.Add(value);
     return(this);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Adds the specified value to the <see cref="Revisions"/> property and
 /// returns this <see cref="StatusCommand"/> instance.
 /// </summary>
 /// <param name="value">
 /// The value to add to the <see cref="Revisions"/> property.
 /// </param>
 /// <returns>
 /// This <see cref="StatusCommand"/> instance.
 /// </returns>
 /// <remarks>
 /// This method is part of the fluent interface.
 /// </remarks>
 public StatusCommand WithRevisions(RevSpec value)
 {
     Revisions.Add(value);
     return(this);
 }
Ejemplo n.º 8
0
        public async Task MaterializeAsync(ILogStore store, byte[] secretKey   = default, long?startingFrom = default,
                                           CancellationToken cancellationToken = default)
        {
            if (startingFrom == default)
            {
                startingFrom = Interlocked.Read(ref _index) + 1;
            }

            foreach (var entry in store.StreamEntries((ulong)startingFrom, secretKey))
            {
                Interlocked.Exchange(ref _index, (long)entry.Index.GetValueOrDefault());

                foreach (var @object in entry.Objects)
                {
                    switch (@object.Data)
                    {
                    case Namespace ns:
                    {
                        var key = ns;
                        Namespaces.Add(key);
                        _namespace = key;

                        if (!Revisions.ContainsKey(_namespace.Value))
                        {
                            Revisions.Add(_namespace.Value,
                                          new Dictionary <string, ulong>(StringComparer.OrdinalIgnoreCase));
                        }

                        if (!Manifest.ContainsKey(_namespace.Value))
                        {
                            Manifest.Add(_namespace.Value, new Dictionary <ulong, List <Schema> >());
                        }

                        if (!Roles.ContainsKey(_namespace.Value))
                        {
                            Roles.Add(_namespace.Value, new List <string>());
                        }

                        break;
                    }

                    case Schema schema:
                    {
                        var key = schema.Name;

                        if (!Revisions[_namespace.Value].TryGetValue(key, out var revision))
                        {
                            Revisions[_namespace.Value].Add(key, revision = 1);
                        }

                        if (!Manifest[_namespace.Value].TryGetValue(revision, out var manifest))
                        {
                            Manifest[_namespace.Value].Add(revision, manifest = new List <Schema>());
                        }

                        if (!Schemas.TryGetValue(key, out var schemaMap))
                        {
                            Schemas.Add(key, schemaMap = new Dictionary <ulong, List <Schema> >());
                        }

                        if (!schemaMap.TryGetValue(revision, out var list))
                        {
                            schemaMap.Add(revision, list = new List <Schema>());
                        }

                        manifest.Add(schema);
                        list.Add(schema);

                        await _events.OnSchemaAddedAsync(store, schema, cancellationToken);

                        break;
                    }

                    case RevokeRole revokeRole:
                    {
                        if (!revokeRole.Verify())
                        {
                            throw new InvalidOperationException($"invalid {revokeRole.Type}");
                        }

                        if (RoleGrants.TryGetValue(_namespace.Value, out var lookup) &&
                            lookup.Count == 1 &&
                            lookup[Constants.DefaultOwnerRole].Count == 1)
                        {
                            throw new CannotRemoveSingleOwnerException("cannot revoke admin rights of only owner");
                        }

                        break;
                    }

                    default:
                        throw new NotImplementedException(@object.Data.GetType().Name);
                    }
                }
            }
        }
Ejemplo n.º 9
0
 public void AddToDb(Revision revision)
 {
     Revisions.Add(revision);
 }