using System; using System.Collections.Generic; using System.Net.Http; using System.Web.Http; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Web.Install.Models; using Umbraco.Web.WebApi; namespace Umbraco.Web.Install.Controllers { [AngularJsonOnlyConfiguration] [HttpInstallAuthorize] public class InstallApiController : ApiController { protected InstallApiController() : this(UmbracoContext.Current) { } protected InstallApiController(UmbracoContext umbracoContext) { if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); UmbracoContext = umbracoContext; } /// /// Returns the current UmbracoContext /// public UmbracoContext UmbracoContext { get; private set; } /// /// Gets the install setup /// /// public InstallSetup GetSetup() { var status = new InstallSetup() { Status = GlobalSettings.ConfigurationStatus.IsNullOrWhiteSpace() ? InstallStatus.NewInstall : InstallStatus.Upgrade }; //TODO: Check for user/site token var steps = new List(); if (status.Status == InstallStatus.NewInstall) { steps.AddRange(new[] { new InstallStep() { Name = "User", View = "user" }, new InstallStep() { Name = "Database", View = "database" }, new InstallStep() { Name = "StarterKit", View = "starterKit" }, }); } else { //TODO: Add steps for upgrades } return status; } /// /// Checks if the db can be connected to /// /// public HttpResponseMessage PostCheckDbConnection() { throw new NotImplementedException(); } /// /// Checks if the db credentials are correct /// /// public HttpResponseMessage PostCheckDbCredentials() { throw new NotImplementedException(); } /// /// Does the install /// /// public HttpResponseMessage PostPerformInstall(InstallInstructions model) { var steps = GetSetup(); InstallStatusTracker.Initialize(steps.Steps); throw new NotImplementedException(); } /// /// Returns the current install status /// /// public IDictionary GetStatus() { return InstallStatusTracker.GetStatus(); } } }