From 953c371580765c349ece74f436c34349f286e0cc Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Sun, 30 Nov 2014 15:50:55 +0100 Subject: [PATCH 1/4] Get starterkits in new way so we can support version compatibility (Fanoe is only compatible with 7.2+) --- .../Controllers/InstallApiController.cs | 12 +++------- src/Umbraco.Web/Install/InstallHelper.cs | 23 +++++++++++++++++++ .../InstallSteps/StarterKitDownloadStep.cs | 15 ++++++------ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs index 6041e23ca5..720304d1ab 100644 --- a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs +++ b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs @@ -84,15 +84,9 @@ namespace Umbraco.Web.Install.Controllers public IEnumerable GetPackages() { - var r = new org.umbraco.our.Repository(); - var modules = r.Modules(); - - return modules.Select(package => new Package() - { - Id = package.RepoGuid, - Name = package.Text, - Thumbnail = package.Thumbnail - }); + var installHelper = new InstallHelper(UmbracoContext.Current); + var starterKits = installHelper.GetStarterKits(); + return starterKits; } /// diff --git a/src/Umbraco.Web/Install/InstallHelper.cs b/src/Umbraco.Web/Install/InstallHelper.cs index 1528bd89e1..0c43d218e5 100644 --- a/src/Umbraco.Web/Install/InstallHelper.cs +++ b/src/Umbraco.Web/Install/InstallHelper.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Configuration; using System.IO; using System.Linq; +using System.Net.Http; using System.Web; using System.Web.Script.Serialization; using System.Web.UI; @@ -11,6 +12,7 @@ using umbraco.BusinessLogic; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.IO; +using Umbraco.Core.Logging; using Umbraco.Core.Persistence; using Umbraco.Web.Install.InstallSteps; using Umbraco.Web.Install.Models; @@ -182,5 +184,26 @@ namespace Umbraco.Web.Install return false; } } + + internal IEnumerable GetStarterKits() + { + var packages = new List(); + + try + { + var requestUri = string.Format("http://localhost:24217/webapi/StarterKit/Get/?umbracoVersion={0}", + UmbracoVersion.Current); + var request = new HttpRequestMessage(HttpMethod.Get, requestUri); + var httpClient = new HttpClient(); + var response = httpClient.SendAsync(request).Result; + packages = response.Content.ReadAsAsync>().Result.ToList(); + } + catch (AggregateException ex) + { + LogHelper.Error("Could not download list of available starter kits", ex); + } + + return packages; + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs b/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs index f5bc96fdea..e8397136a9 100644 --- a/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs @@ -21,16 +21,17 @@ namespace Umbraco.Web.Install.InstallSteps private const string RepoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66"; - //adding a package guid hardcoded, so we can change the sent package remotely, currently this just points to txt kit - //but a future starterkit will be inserted under the same guid on our. - private const string PackageGuid = "69E44BEB-15FF-4CEE-8B64-0A7DAE498657"; - public override InstallSetupResult Execute(Guid? starterKitId) { //if there is no value assigned then use the default starter kit if (starterKitId.HasValue == false) { - starterKitId = Guid.Parse(PackageGuid); + var installHelper = new InstallHelper(UmbracoContext.Current); + var starterKits = installHelper.GetStarterKits().FirstOrDefault(); + if (starterKits != null) + starterKitId = starterKits.Id; + else + return null; } else if (starterKitId.Value == Guid.Empty) { @@ -57,7 +58,7 @@ namespace Umbraco.Web.Install.InstallSteps } if (repo.HasConnection() == false) { - throw new InstallException("Cannot connect to repository"); + throw new InstallException("Cannot connect to repository"); } var installer = new Installer(); @@ -76,7 +77,7 @@ namespace Umbraco.Web.Install.InstallSteps var installer = new Installer(); installer.LoadConfig(packageFile); installer.InstallFiles(manifestId, packageFile); - + } public override string View From 801828df70c2f38e30420c751ea0174507ca6759 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Sun, 30 Nov 2014 17:02:25 +0100 Subject: [PATCH 2/4] Update test URL to live URL --- src/Umbraco.Web/Install/InstallHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Install/InstallHelper.cs b/src/Umbraco.Web/Install/InstallHelper.cs index 0c43d218e5..c08dac71d8 100644 --- a/src/Umbraco.Web/Install/InstallHelper.cs +++ b/src/Umbraco.Web/Install/InstallHelper.cs @@ -191,7 +191,7 @@ namespace Umbraco.Web.Install try { - var requestUri = string.Format("http://localhost:24217/webapi/StarterKit/Get/?umbracoVersion={0}", + var requestUri = string.Format("http://our.umbraco.org/webapi/StarterKit/Get/?umbracoVersion={0}", UmbracoVersion.Current); var request = new HttpRequestMessage(HttpMethod.Get, requestUri); var httpClient = new HttpClient(); From 36ffebbb49e6e54cd062848882df40ccbb8922a0 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 1 Dec 2014 08:17:37 +0100 Subject: [PATCH 3/4] Adds usings for the http request, client and response --- src/Umbraco.Web/Install/InstallHelper.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web/Install/InstallHelper.cs b/src/Umbraco.Web/Install/InstallHelper.cs index c08dac71d8..da0cb3c7ee 100644 --- a/src/Umbraco.Web/Install/InstallHelper.cs +++ b/src/Umbraco.Web/Install/InstallHelper.cs @@ -41,7 +41,7 @@ namespace Umbraco.Web.Install public IEnumerable GetAllSteps() { return new List - { + { new NewInstallStep(_umbContext.Application), new UpgradeStep(), new FilePermissionsStep(), @@ -87,12 +87,12 @@ namespace Umbraco.Web.Install { Directory.Move(IOHelper.MapPath(SystemDirectories.Install), IOHelper.MapPath("~/app_data/temp/install_backup")); } - } + } if (Directory.Exists(IOHelper.MapPath("~/Areas/UmbracoInstall"))) - { + { Directory.Delete(IOHelper.MapPath("~/Areas/UmbracoInstall"), true); - } + } } internal void InstallStatus(bool isCompleted, string errorMsg) @@ -193,14 +193,17 @@ namespace Umbraco.Web.Install { var requestUri = string.Format("http://our.umbraco.org/webapi/StarterKit/Get/?umbracoVersion={0}", UmbracoVersion.Current); - var request = new HttpRequestMessage(HttpMethod.Get, requestUri); - var httpClient = new HttpClient(); - var response = httpClient.SendAsync(request).Result; - packages = response.Content.ReadAsAsync>().Result.ToList(); + + using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri)) + using (var httpClient = new HttpClient()) + using (var response = httpClient.SendAsync(request).Result) + { + packages = response.Content.ReadAsAsync>().Result.ToList(); + } } catch (AggregateException ex) { - LogHelper.Error("Could not download list of available starter kits", ex); + LogHelper.Error("Could not download list of available starter kits", ex); } return packages; From 9beaaa825eb1799a860fa79b53b722e1b4a0c551 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 3 Dec 2014 08:56:21 +0100 Subject: [PATCH 4/4] Use the UmbracoContext property instead of the singleton --- src/Umbraco.Web/Install/Controllers/InstallApiController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs index 720304d1ab..2ab1fd97ad 100644 --- a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs +++ b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs @@ -84,7 +84,7 @@ namespace Umbraco.Web.Install.Controllers public IEnumerable GetPackages() { - var installHelper = new InstallHelper(UmbracoContext.Current); + var installHelper = new InstallHelper(UmbracoContext); var starterKits = installHelper.GetStarterKits(); return starterKits; }