public RestConfigurationChangeSummary(ConfigurationChangeRequest change)
 {
     Id     = change.Id;
     Name   = change.Entry.Name;
     Action = change.Action;
     Links  = new List <RestLink>();
 }
Beispiel #2
0
        private void PurgeAllExistingItems(ConfigurationChangeRequest change)
        {
            var filespec = Path.ChangeExtension(change.Entry.Name, CONFIG_FILE_EXTENSION);

            foreach (var filename in Directory.GetFiles(BaseFolder, filespec, SearchOption.AllDirectories))
            {
                File.Delete(filename);
            }
        }
Beispiel #3
0
 public IActionResult SetConfiguration([FromBody] ConfigurationChangeRequest request)
 {
     configChangeService.ChangeConfiguration(request.Select(opt => new ConfigurationOption
     {
         Key   = opt.Key,
         Value = opt.Value
     }));
     return(Ok());
 }
Beispiel #4
0
        public void Save(ConfigurationChangeRequest update)
        {
            lock (SyncObj)
            {
                if (_restartPending)
                {
                    throw new InvalidOperationException(string.Format("Restart in progress"));
                }

                update.Entry.Tags.RemoveAll(SpecialTags.ThatShouldNotBePersisted);
                _pendingChanges.Add(update);
            }
        }
        public override void Save(ConfigurationChangeRequest change)
        {
            if (!change.Entry.Tags.ContainsAll(SpecialTags.ACTIVITY))
            {
                return;
            }

            var filepath = Path.Combine(BaseFolder, Path.ChangeExtension(change.Entry.Name, CONFIG_FILE_EXTENSION));

            if (!HandleChange(change, filepath))
            {
                throw new InvalidOperationException(string.Format("Unknown ChangeRequest action '{0}'", change.Action));
            }
        }
Beispiel #6
0
        protected bool HandleChange(ConfigurationChangeRequest change, string filepath)
        {
            switch (change.Action.ToLowerInvariant())
            {
            case ConfigurationActions.Delete:
                File.Delete(filepath);
                return(true);

            case ConfigurationActions.Update:
                WriteConfigFile(change.Entry, filepath);
                return(true);
            }

            return(false);
        }
Beispiel #7
0
        public override void Save(ConfigurationChangeRequest change)
        {
            if (!change.Entry.Tags.ContainsAll(SpecialTags.HEALTH_CHECK))
            {
                return;
            }

            string scheduler;

            if (!change.Entry.RequiredProperties.TryGetValue(ConfigurationEntry.RequiredPropertyNames.SCHEDULER, out scheduler))
            {
                throw new InvalidOperationException(string.Format("Unable to update configuration, '{0}' property is missing",
                                                                  ConfigurationEntry.RequiredPropertyNames.SCHEDULER));
            }

            PurgeAllExistingItems(change);

            var filepath = Path.Combine(BaseFolder, scheduler, Path.ChangeExtension(change.Entry.Name, CONFIG_FILE_EXTENSION));

            if (!HandleChange(change, filepath))
            {
                throw new InvalidOperationException(string.Format("Unknown ChangeRequest action '{0}'", change.Action));
            }
        }
Beispiel #8
0
 public abstract void Save(ConfigurationChangeRequest change);
Beispiel #9
0
 public static void Update(ConfigurationChangeRequest change)
 {
     _instance.Save(change);
 }
 public override void Save(ConfigurationChangeRequest change)
 {
     throw new global::System.NotImplementedException();
 }