diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IRepository.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IRepository.cs index 34730f3e45..7559f090c0 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IRepository.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IRepository.cs @@ -9,7 +9,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings string RepositoryUrl { get; } string WebServiceUrl { get; } bool HasCustomWebServiceUrl { get; } - string RestApiUrl { get; } - bool HasCustomRestApiUrl { get; } + string RestApiUrl { get; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryElement.cs index 69465f62da..a249be2ee3 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryElement.cs @@ -48,14 +48,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings get { return (string)base["restapiurl"]; } set { base["restapiurl"] = value; } } - - public bool HasCustomRestApiUrl - { - get - { - var prop = Properties["restapiurl"]; - return (string)prop.DefaultValue != (string)this[prop]; - } - } + } } \ No newline at end of file diff --git a/src/Umbraco.Core/Exceptions/ConnectionException.cs b/src/Umbraco.Core/Exceptions/ConnectionException.cs new file mode 100644 index 0000000000..3535dd52bf --- /dev/null +++ b/src/Umbraco.Core/Exceptions/ConnectionException.cs @@ -0,0 +1,12 @@ +using System; + +namespace Umbraco.Core.Exceptions +{ + internal class ConnectionException : Exception + { + public ConnectionException(string message, Exception innerException) : base(message, innerException) + { + + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Exceptions/DataOperationException.cs b/src/Umbraco.Core/Exceptions/DataOperationException.cs index 9a66e6a5be..60a3ccd4eb 100644 --- a/src/Umbraco.Core/Exceptions/DataOperationException.cs +++ b/src/Umbraco.Core/Exceptions/DataOperationException.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.Exceptions public T Operation { get; private set; } public DataOperationException(T operation, string message) - :base(message) + : base(message) { Operation = operation; } diff --git a/src/Umbraco.Core/Services/IPackagingService.cs b/src/Umbraco.Core/Services/IPackagingService.cs index c7e68e6eca..047d87afcd 100644 --- a/src/Umbraco.Core/Services/IPackagingService.cs +++ b/src/Umbraco.Core/Services/IPackagingService.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Xml.Linq; using Umbraco.Core.Models; @@ -6,6 +7,15 @@ namespace Umbraco.Core.Services { public interface IPackagingService : IService { + /// + /// This will fetch an Umbraco package file from the package repository and return the relative file path to the downloaded package file + /// + /// + /// + /// The current user id performing the operation + /// + string FetchPackageFile(Guid packageId, Version umbracoVersion, int userId); + /// /// Imports and saves package xml as /// diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs index d5f1ffea4c..3b3c65d83d 100644 --- a/src/Umbraco.Core/Services/PackagingService.cs +++ b/src/Umbraco.Core/Services/PackagingService.cs @@ -1,15 +1,20 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Linq; +using System.Net.Http; using System.Text.RegularExpressions; using System.Web; using System.Web.UI.WebControls; using System.Xml.Linq; using System.Xml.XPath; using Newtonsoft.Json; +using Umbraco.Core.Auditing; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Events; +using Umbraco.Core.Exceptions; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; @@ -28,9 +33,8 @@ namespace Umbraco.Core.Services /// Represents the Packaging Service, which provides import/export functionality for the Core models of the API /// using xml representation. This is primarily used by the Package functionality. /// - public class PackagingService : IPackagingService + public class PackagingService : ScopeRepositoryService, IPackagingService { - private readonly ILogger _logger; private readonly IContentService _contentService; private readonly IContentTypeService _contentTypeService; private readonly IMediaService _mediaService; @@ -47,7 +51,8 @@ namespace Umbraco.Core.Services public PackagingService( - ILogger logger, + ILogger logger, + IDatabaseUnitOfWorkProvider provider, IEventMessagesFactory eventMessagesFactory, IContentService contentService, IContentTypeService contentTypeService, IMediaService mediaService, @@ -58,9 +63,8 @@ namespace Umbraco.Core.Services IEntityService entityService, IUserService userService, RepositoryFactory repositoryFactory, - IScopeUnitOfWorkProvider uowProvider) + IScopeUnitOfWorkProvider uowProvider) : base(provider, repositoryFactory, logger, eventMessagesFactory) { - _logger = logger; _contentService = contentService; _contentTypeService = contentTypeService; _mediaService = mediaService; @@ -75,6 +79,61 @@ namespace Umbraco.Core.Services _importedContentTypes = new Dictionary(); } + /// + /// This will fetch an Umbraco package file from the package repository and return the relative file path to the downloaded package file + /// + /// + /// + /// /// The current user id performing the operation + /// + public string FetchPackageFile(Guid packageId, Version umbracoVersion, int userId) + { + var packageRepo = UmbracoConfig.For.UmbracoSettings().PackageRepositories.GetDefault(); + + using (var httpClient = new HttpClient()) + using (var uow = UowProvider.GetUnitOfWork()) + { + var url = string.Format("{0}/{1}?version={2}&asFile=true", packageRepo.RestApiUrl, packageId, umbracoVersion.ToString(3)); + byte[] bytes; + try + { + bytes = httpClient.GetByteArrayAsync(url).GetAwaiter().GetResult(); + } + catch (HttpRequestException ex) + { + throw new ConnectionException("An error occuring downloading the package from " + url, ex); + } + + //successfull + if (bytes.Length > 0) + { + var packagePath = IOHelper.MapPath(SystemDirectories.Packages); + + // Check for package directory + if (Directory.Exists(packagePath) == false) + Directory.CreateDirectory(packagePath); + + var packageFilePath = Path.Combine(packagePath, packageId + ".umb"); + + using (var fs1 = new FileStream(packageFilePath, FileMode.Create)) + { + fs1.Write(bytes, 0, bytes.Length); + fs1.Close(); + return "packages\\" + packageId + ".umb"; + } + } + + Audit(uow, AuditType.PackagerInstall, string.Format("Package {0} fetched from {1}", packageId, packageRepo.Id), userId, -1); + return null; + } + } + + private void Audit(IScopeUnitOfWork uow, AuditType type, string message, int userId, int objectId) + { + var auditRepo = RepositoryFactory.CreateAuditRepository(uow); + auditRepo.AddOrUpdate(new AuditItem(objectId, message, type, userId)); + } + #region Content /// @@ -476,7 +535,7 @@ namespace Umbraco.Core.Services var tryCreateFolder = _contentTypeService.CreateContentTypeContainer(-1, rootFolder); if (tryCreateFolder == false) { - _logger.Error("Could not create folder: " + rootFolder, tryCreateFolder.Exception); + Logger.Error("Could not create folder: " + rootFolder, tryCreateFolder.Exception); throw tryCreateFolder.Exception; } var rootFolderId = tryCreateFolder.Result.Entity.Id; @@ -510,7 +569,7 @@ namespace Umbraco.Core.Services var tryCreateFolder = _contentTypeService.CreateContentTypeContainer(current.Id, folderName); if (tryCreateFolder == false) { - _logger.Error("Could not create folder: " + folderName, tryCreateFolder.Exception); + Logger.Error("Could not create folder: " + folderName, tryCreateFolder.Exception); throw tryCreateFolder.Exception; } return _contentTypeService.GetContentTypeContainer(tryCreateFolder.Result.Entity.Id); @@ -616,7 +675,7 @@ namespace Umbraco.Core.Services } else { - _logger.Warn( + Logger.Warn( string.Format( "Packager: Error handling allowed templates. Template with alias '{0}' could not be found.", alias)); @@ -635,7 +694,7 @@ namespace Umbraco.Core.Services } else { - _logger.Warn( + Logger.Warn( string.Format( "Packager: Error handling default template. Default template with alias '{0}' could not be found.", defaultTemplateElement.Value)); @@ -721,7 +780,7 @@ namespace Umbraco.Core.Services // This means that the property will not be created. if (dataTypeDefinition == null) { - _logger.Warn( + Logger.Warn( string.Format("Packager: Error handling creation of PropertyType '{0}'. Could not find DataTypeDefintion with unique id '{1}' nor one referencing the DataType with a property editor alias (or legacy control id) '{2}'. Did the package creator forget to package up custom datatypes? This property will be converted to a label/readonly editor if one exists.", property.Element("Name").Value, dataTypeDefinitionId, @@ -775,7 +834,7 @@ namespace Umbraco.Core.Services } else { - _logger.Warn( + Logger.Warn( string.Format( "Packager: Error handling DocumentType structure. DocumentType with alias '{0}' could not be found and was not added to the structure for '{1}'.", alias, contentType.Alias)); @@ -979,7 +1038,7 @@ namespace Umbraco.Core.Services var tryCreateFolder = _dataTypeService.CreateContainer(-1, rootFolder); if (tryCreateFolder == false) { - _logger.Error("Could not create folder: " + rootFolder, tryCreateFolder.Exception); + Logger.Error("Could not create folder: " + rootFolder, tryCreateFolder.Exception); throw tryCreateFolder.Exception; } current = _dataTypeService.GetContainer(tryCreateFolder.Result.Entity.Id); @@ -1012,7 +1071,7 @@ namespace Umbraco.Core.Services var tryCreateFolder = _dataTypeService.CreateContainer(current.Id, folderName); if (tryCreateFolder == false) { - _logger.Error("Could not create folder: " + folderName, tryCreateFolder.Exception); + Logger.Error("Could not create folder: " + folderName, tryCreateFolder.Exception); throw tryCreateFolder.Exception; } return _dataTypeService.GetContainer(tryCreateFolder.Result.Entity.Id); @@ -1048,7 +1107,7 @@ namespace Umbraco.Core.Services } else { - _logger.Warn("No data type found with name " + dataTypeDefinitionName + " data type pre-values will not be saved"); + Logger.Warn("No data type found with name " + dataTypeDefinitionName + " data type pre-values will not be saved"); } } } @@ -1541,7 +1600,7 @@ namespace Umbraco.Core.Services else if (string.IsNullOrEmpty((string)elementCopy.Element("Master")) == false && templateElements.Any(x => (string)x.Element("Alias") == (string)elementCopy.Element("Master")) == false) { - _logger.Info(string.Format("Template '{0}' has an invalid Master '{1}', so the reference has been ignored.", (string)elementCopy.Element("Alias"), (string)elementCopy.Element("Master"))); + Logger.Info(string.Format("Template '{0}' has an invalid Master '{1}', so the reference has been ignored.", (string)elementCopy.Element("Alias"), (string)elementCopy.Element("Master"))); } var field = new TopologicalSorter.DependencyField diff --git a/src/Umbraco.Core/Services/ServiceContext.cs b/src/Umbraco.Core/Services/ServiceContext.cs index 08959a3c19..c6a282ed5e 100644 --- a/src/Umbraco.Core/Services/ServiceContext.cs +++ b/src/Umbraco.Core/Services/ServiceContext.cs @@ -281,7 +281,8 @@ namespace Umbraco.Core.Services cache.RuntimeCache)); if (_packagingService == null) - _packagingService = new Lazy(() => new PackagingService(logger, _contentService.Value, _contentTypeService.Value, _mediaService.Value, _macroService.Value, _dataTypeService.Value, _fileService.Value, _localizationService.Value, _entityService.Value, _userService.Value, repositoryFactory, provider)); + _packagingService = new Lazy(() => new PackagingService( + logger, provider, eventMessagesFactory, _contentService.Value, _contentTypeService.Value, _mediaService.Value, _macroService.Value, _dataTypeService.Value, _fileService.Value, _localizationService.Value, _entityService.Value, _userService.Value, repositoryFactory, provider)); if (_relationService == null) _relationService = new Lazy(() => new RelationService(provider, repositoryFactory, logger, eventMessagesFactory, _entityService.Value)); diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 41e6614d86..74cbe5d534 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -339,6 +339,7 @@ + diff --git a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs index f83b8a6369..f405476a4a 100644 --- a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs @@ -383,6 +383,8 @@ namespace Umbraco.Tests.Web.Mvc new Mock().Object, new PackagingService( new Mock().Object, + new Mock().Object, + new TransientMessagesFactory(), new Mock().Object, new Mock().Object, new Mock().Object, diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index ea176d0b4f..1a1dc9304e 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -349,13 +349,6 @@ Properties\SolutionInfo.cs - - loadStarterKits.ascx - ASPXCodeBehind - - - loadStarterKits.ascx - noNodes.aspx ASPXCodeBehind @@ -573,7 +566,6 @@ - diff --git a/src/Umbraco.Web.UI/umbraco/Install/Legacy/LoadStarterKits.ascx.cs b/src/Umbraco.Web.UI/umbraco/Install/Legacy/LoadStarterKits.ascx.cs deleted file mode 100644 index 013cd28c00..0000000000 --- a/src/Umbraco.Web.UI/umbraco/Install/Legacy/LoadStarterKits.ascx.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using System.Web.Routing; -using System.Web.UI; -using Umbraco.Core.Logging; -using Umbraco.Web.Install; - -namespace Umbraco.Web.UI.Install.Steps.Skinning -{ - public delegate void StarterKitInstalledEventHandler(); - - public partial class LoadStarterKits : UserControl - { - /// - /// Returns the string for the package installer web service base url - /// - protected string PackageInstallServiceBaseUrl { get; private set; } - - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - //Get the URL for the package install service base url - var umbracoPath = Core.Configuration.GlobalSettings.UmbracoMvcArea; - var urlHelper = new UrlHelper(Context.Request.RequestContext); - //PackageInstallServiceBaseUrl = urlHelper.Action("Index", "InstallPackage", new { area = "UmbracoInstall" }); - PackageInstallServiceBaseUrl = urlHelper.GetUmbracoApiService("Index", "InstallPackage", "UmbracoInstall"); - } - - /// - /// Flag to show if we can connect to the repo or not - /// - protected bool CannotConnect { get; private set; } - - public event StarterKitInstalledEventHandler StarterKitInstalled; - - protected virtual void OnStarterKitInstalled() - { - StarterKitInstalled(); - } - - - private readonly global::umbraco.cms.businesslogic.packager.repositories.Repository _repo; - private const string RepoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66"; - - public LoadStarterKits() - { - _repo = global::umbraco.cms.businesslogic.packager.repositories.Repository.getByGuid(RepoGuid); - } - - protected void Page_Load(object sender, EventArgs e) - { - - } - - //protected void NextStep(object sender, EventArgs e) - //{ - // var p = (Default)this.Page; - // //InstallHelper.RedirectToNextStep(Page, Request.GetItemAsString("installStep")); - //} - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - if (_repo == null) - { - throw new InvalidOperationException("Could not find repository with id " + RepoGuid); - } - - //clear progressbar cache - //InstallHelper.ClearProgress(); - - if (_repo.HasConnection()) - { - try - { - var r = new org.umbraco.our.Repository(); - - rep_starterKits.DataSource = r.Modules(); - rep_starterKits.DataBind(); - } - catch (Exception ex) - { - LogHelper.Error("Cannot connect to package repository", ex); - CannotConnect = true; - - } - } - else - { - CannotConnect = true; - } - } - - - protected void GotoLastStep(object sender, EventArgs e) - { - //InstallHelper.RedirectToLastStep(Page); - } - - } -} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/Install/Legacy/LoadStarterKits.ascx.designer.cs b/src/Umbraco.Web.UI/umbraco/Install/Legacy/LoadStarterKits.ascx.designer.cs deleted file mode 100644 index f9f25ad3a1..0000000000 --- a/src/Umbraco.Web.UI/umbraco/Install/Legacy/LoadStarterKits.ascx.designer.cs +++ /dev/null @@ -1,60 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Umbraco.Web.UI.Install.Steps.Skinning { - - - public partial class LoadStarterKits { - - /// - /// pl_loadStarterKits control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder pl_loadStarterKits; - - /// - /// JsInclude1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; - - /// - /// rep_starterKits control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Repeater rep_starterKits; - - /// - /// LinkButton1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.LinkButton LinkButton1; - - /// - /// LinkButton2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.LinkButton LinkButton2; - } -} diff --git a/src/Umbraco.Web.UI/umbraco/Install/Legacy/loadStarterKits.ascx b/src/Umbraco.Web.UI/umbraco/Install/Legacy/loadStarterKits.ascx deleted file mode 100644 index 490ff5b3ba..0000000000 --- a/src/Umbraco.Web.UI/umbraco/Install/Legacy/loadStarterKits.ascx +++ /dev/null @@ -1,98 +0,0 @@ -<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="LoadStarterKits.ascx.cs" Inherits="Umbraco.Web.UI.Install.Steps.Skinning.LoadStarterKits" %> -<%@ Import Namespace="Umbraco.Web.org.umbraco.our" %> - -<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> - - - - - - <% if (!CannotConnect) { %> - - <% } %> - - - -
    - - -
  • "> -
    - <%# ((Package)Container.DataItem).Text %> - -

    <%# ((Package)Container.DataItem).Text %>

    - <%# ((Package)Container.DataItem).Description %> - - - Install - -
    -
  • -
    - -
- <%-- - No thanks, do not install a starterkit! - --%> - -
- -
- -
"> - -
-

Oops...the installer can't connect to the repository

- Starter Kits could not be fetched from the repository as there was no connection - which can occur if you are using a proxy server or firewall with certain configurations, - or if you are not currently connected to the internet. -
- Click Continue to complete the installation then navigate to the Developer section of your Umbraco installation - where you will find the Starter Kits listed in the Packages tree. -
- - -
-
 
- Continue -
- -
- - \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/developer/Packages/editPackage.aspx b/src/Umbraco.Web.UI/umbraco/developer/Packages/editPackage.aspx index 87faed4e43..edd484c82e 100644 --- a/src/Umbraco.Web.UI/umbraco/developer/Packages/editPackage.aspx +++ b/src/Umbraco.Web.UI/umbraco/developer/Packages/editPackage.aspx @@ -39,7 +39,6 @@ - diff --git a/src/Umbraco.Web/Editors/PackageInstallController.cs b/src/Umbraco.Web/Editors/PackageInstallController.cs index d982d703cc..c980a06521 100644 --- a/src/Umbraco.Web/Editors/PackageInstallController.cs +++ b/src/Umbraco.Web/Editors/PackageInstallController.cs @@ -185,7 +185,7 @@ namespace Umbraco.Web.Editors var actionsXml = new XmlDocument(); actionsXml.LoadXml("" + pack.Data.Actions + ""); - LogHelper.Debug("executing undo actions: {0}", () => actionsXml.OuterXml); + LogHelper.Debug("executing undo actions: {0}", () => actionsXml.OuterXml); foreach (XmlNode n in actionsXml.DocumentElement.SelectNodes("//Action")) { @@ -196,13 +196,13 @@ namespace Umbraco.Web.Editors } catch (Exception ex) { - LogHelper.Error("An error occurred running undo actions", ex); + LogHelper.Error("An error occurred running undo actions", ex); } } } catch (Exception ex) { - LogHelper.Error("An error occurred running undo actions", ex); + LogHelper.Error("An error occurred running undo actions", ex); } } @@ -471,11 +471,7 @@ namespace Umbraco.Web.Editors string path = Path.Combine("packages", packageGuid + ".umb"); if (File.Exists(IOHelper.MapPath(Path.Combine(SystemDirectories.Data, path))) == false) { - //our repo guid - using (var our = Repository.getByGuid("65194810-1f85-11dd-bd0b-0800200c9a66")) - { - path = our.GetPackageFile(packageGuid, Security.CurrentUser.Id, UmbracoVersion.Current); - } + path = Services.PackagingService.FetchPackageFile(Guid.Parse(packageGuid), UmbracoVersion.Current, Security.GetUserId()); } var model = new LocalPackageInstallModel diff --git a/src/Umbraco.Web/Install/Controllers/InstallPackageController.cs b/src/Umbraco.Web/Install/Controllers/InstallPackageController.cs index fc4a8962b8..e73302dc02 100644 --- a/src/Umbraco.Web/Install/Controllers/InstallPackageController.cs +++ b/src/Umbraco.Web/Install/Controllers/InstallPackageController.cs @@ -8,6 +8,7 @@ using System.Web.Http; using Newtonsoft.Json.Linq; using umbraco; using Umbraco.Core; +using Umbraco.Core.Configuration; using Umbraco.Web.Install.Models; using Umbraco.Web.WebApi; @@ -57,23 +58,15 @@ namespace Umbraco.Web.Install.Controllers /// [HttpPost] public HttpResponseMessage DownloadPackageFiles(InstallPackageModel model) - { - var repo = global::umbraco.cms.businesslogic.packager.repositories.Repository.getByGuid(RepoGuid); - if (repo == null) - { - return Json( - new {success = false, error = "No repository found with id " + RepoGuid}, - HttpStatusCode.OK); - } - if (repo.HasConnection() == false) - { - return Json( - new { success = false, error = "cannot_connect" }, - HttpStatusCode.OK); - } - var installer = new global::umbraco.cms.businesslogic.packager.Installer(UmbracoContext.Current.Security.CurrentUser.Id); + { + var packageFile = _applicationContext.Services.PackagingService.FetchPackageFile( + model.KitGuid, + UmbracoVersion.Current, + UmbracoContext.Current.Security.CurrentUser.Id); - var tempFile = installer.Import(repo.fetch(model.KitGuid.ToString(), UmbracoContext.Current.Security.CurrentUser.Id)); + var installer = new global::umbraco.cms.businesslogic.packager.Installer(UmbracoContext.Current.Security.CurrentUser.Id); + + var tempFile = installer.Import(packageFile); installer.LoadConfig(tempFile); var pId = installer.CreateManifest(tempFile, model.KitGuid.ToString(), RepoGuid); return Json(new diff --git a/src/Umbraco.Web/Install/InstallHelper.cs b/src/Umbraco.Web/Install/InstallHelper.cs index de101394c1..8bc21a2334 100644 --- a/src/Umbraco.Web/Install/InstallHelper.cs +++ b/src/Umbraco.Web/Install/InstallHelper.cs @@ -50,7 +50,7 @@ namespace Umbraco.Web.Install new DatabaseConfigureStep(_umbContext.Application), new DatabaseInstallStep(_umbContext.Application), new DatabaseUpgradeStep(_umbContext.Application), - new StarterKitDownloadStep(_umbContext.Application), + new StarterKitDownloadStep(_umbContext.Application, _umbContext.Security), new StarterKitInstallStep(_umbContext.Application, _umbContext.HttpContext), new StarterKitCleanupStep(_umbContext.Application), new SetUmbracoVersionStep(_umbContext.Application, _umbContext.HttpContext), diff --git a/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs b/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs index e8397136a9..a8f55d3b2c 100644 --- a/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs @@ -4,7 +4,9 @@ using System.Linq; using System.Web; using umbraco.cms.businesslogic.packager; using Umbraco.Core; +using Umbraco.Core.Configuration; using Umbraco.Web.Install.Models; +using Umbraco.Web.Security; namespace Umbraco.Web.Install.InstallSteps { @@ -13,10 +15,12 @@ namespace Umbraco.Web.Install.InstallSteps internal class StarterKitDownloadStep : InstallSetupStep { private readonly ApplicationContext _applicationContext; + private readonly WebSecurity _security; - public StarterKitDownloadStep(ApplicationContext applicationContext) + public StarterKitDownloadStep(ApplicationContext applicationContext, WebSecurity security) { _applicationContext = applicationContext; + _security = security; } private const string RepoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66"; @@ -50,19 +54,13 @@ namespace Umbraco.Web.Install.InstallSteps } private Tuple DownloadPackageFiles(Guid kitGuid) - { - var repo = global::umbraco.cms.businesslogic.packager.repositories.Repository.getByGuid(RepoGuid); - if (repo == null) - { - throw new InstallException("No repository found with id " + RepoGuid); - } - if (repo.HasConnection() == false) - { - throw new InstallException("Cannot connect to repository"); - } + { var installer = new Installer(); - var tempFile = installer.Import(repo.fetch(kitGuid.ToString())); + //Go get the package file from the package repo + var packageFile = _applicationContext.Services.PackagingService.FetchPackageFile(kitGuid, UmbracoVersion.Current, _security.GetUserId()); + + var tempFile = installer.Import(packageFile); installer.LoadConfig(tempFile); var pId = installer.CreateManifest(tempFile, kitGuid.ToString(), RepoGuid); diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx index bd34c32478..270e58fd19 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx @@ -36,7 +36,6 @@ ControlToValidate="packageVersion">* - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs index 091996f7f0..1bd3918ec2 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs @@ -48,16 +48,10 @@ namespace umbraco.presentation.developer.packages cp = new ContentPicker(); content.Controls.Add(cp); - - bt_submitButton.Attributes.Add("onClick", "window.location = 'submitpackage.aspx?id=" + pack.Id.ToString() + "'; return false;"); - + if (string.IsNullOrEmpty(pack.PackagePath) == false) { - packageUmbFile.Text = "   Download"; - - if (cms.businesslogic.packager.repositories.Repository.getAll().Count > 0) - bt_submitButton.Visible = true; - + packageUmbFile.Text = "   Download"; } else { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.designer.cs index a4c21695a7..dfd3eaa5d7 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.designer.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.designer.cs @@ -47,6 +47,7 @@ namespace umbraco.presentation.developer.packages { protected global::System.Web.UI.WebControls.RegularExpressionValidator VersionValidator; protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator7; + /// /// packageName control. /// @@ -128,15 +129,6 @@ namespace umbraco.presentation.developer.packages { /// protected global::umbraco.uicontrols.PropertyPanel pp_file; - /// - /// bt_submitButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button bt_submitButton; - /// /// packageUmbFile control. /// diff --git a/src/umbraco.cms/businesslogic/Packager/Repositories/Repository.cs b/src/umbraco.cms/businesslogic/Packager/Repositories/Repository.cs index 6faf9d519a..28cc814a02 100644 --- a/src/umbraco.cms/businesslogic/Packager/Repositories/Repository.cs +++ b/src/umbraco.cms/businesslogic/Packager/Repositories/Repository.cs @@ -12,7 +12,8 @@ using Umbraco.Core.Logging; using Umbraco.Core.IO; namespace umbraco.cms.businesslogic.packager.repositories -{ +{ + [Obsolete("This should not be used and will be removed in future Umbraco versions")] public class Repository : DisposableObject { public string Guid { get; private set; }