/// <summary>
        /// Assigns a server project to given configuration items.
        /// </summary>
        /// <param name="serverProject">The server project.</param>
        /// <param name="configurationItemsSupport">The configuration items provider.</param>
        /// <param name="serverAddress">The server address.</param>
        public void AssignServerProject(ServerProject serverProject, IConfigurationItemsSupport configurationItemsSupport, string serverAddress)
        {
            // for now, we extract the project name from the address
            var projectNameWithoutAddress = serverProject.Address.Substring(serverAddress.Length, serverProject.Address.Length - serverAddress.Length - 1).Trim('/');

            if (projectNameWithoutAddress.StartsWith("job", StringComparison.CurrentCultureIgnoreCase))
            {
                projectNameWithoutAddress = projectNameWithoutAddress.Substring(3, projectNameWithoutAddress.Length - 3).TrimStart('/');
            }

            configurationItemsSupport.GetConfigurationByKey(JenkinsProject.ProjectName).Value   = projectNameWithoutAddress;
            configurationItemsSupport.GetConfigurationByKey(JenkinsProject.ServerAddress).Value = serverAddress;
        }
Example #2
0
        private Tuple <ServerProject, ClientProject> InitProject(GenerateRequest request, IDisk serverDisk, IDisk clientDisk)
        {
            DataModel dataModel = new DataModel();
            var       jObject   = JObject.Parse(request.Data, new JsonLoadSettings {
                CommentHandling = CommentHandling.Load, DuplicatePropertyNameHandling = DuplicatePropertyNameHandling.Error
            });

            dataModel.Load(jObject);
            var collection = new ResourceCollection(dataModel);
            var userClass  = dataModel.Classes.FirstOrDefault(c => c.Name == "User");

            if (userClass == null)
            {
                throw new Exception("The model must contain a user class.");
            }
            if (userClass.Properties.Any(p => p.Name == "PasswordHash" || p.Name == "Password"))
            {
                throw new Exception("You must not explicitly set passwords for users. A password hash will be automatically added to the user class.");
            }
            CheckMandatoryUserProperty(userClass, "Email");
            CheckMandatoryUserProperty(userClass, "UserName");
            userClass.Properties.Add(new Property
            {
                Name         = "PasswordHash",
                IsServerOnly = true,
                BuiltInType  = BuiltInType.String
            });
            var seedStore = new SeedDataStore(collection);

            seedStore.Load(jObject);
            var serverPlugin  = GetServerPlugin(request);
            var serverProject = new ServerProject
            {
                Config             = serverPlugin.Config,
                Disk               = serverDisk,
                ResourceCollection = collection,
                SeedStore          = seedStore,
                Templates          = serverPlugin.Templates
            };
            var clientPlugin  = GetClientPlugin(request);
            var clientProject = new ClientProject
            {
                Config             = clientPlugin.Config,
                Disk               = clientDisk,
                ResourceCollection = collection,
                SeedStore          = seedStore,
                Templates          = clientPlugin.Templates
            };

            return(Tuple.Create(serverProject, clientProject));
        }
 /// <summary>
 /// Assigns the <see cref="T:Soloplan.WhatsON.ServerProject" /> to <see cref="T:Soloplan.WhatsON.ConfigurationItem" />.
 /// </summary>
 /// <param name="serverProject">The server project.</param>
 /// <param name="configurationItemsSupport">The configuration items provider.</param>
 /// <param name="serverAddress">The server address.</param>
 public void AssignServerProject(ServerProject serverProject, IConfigurationItemsSupport configurationItemsSupport, string serverAddress)
 {
     configurationItemsSupport.GetConfigurationByKey(CruiseControlProject.ProjectName).Value = serverProject.Name;
     configurationItemsSupport.GetConfigurationByKey(ServerConnector.ServerAddress).Value    = serverAddress;
 }