New method for IPackagingService to fetch a package from the repo, removes usages of the old repo endpoint, removes ability to push a package from the back office to Our since that would require a different endpoint.

This commit is contained in:
Shannon
2017-04-26 19:02:36 +10:00
parent 968d52e490
commit 944b3dcaac
22 changed files with 134 additions and 358 deletions

View File

@@ -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; }
}
}

View File

@@ -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];
}
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
namespace Umbraco.Core.Exceptions
{
internal class ConnectionException : Exception
{
public ConnectionException(string message, Exception innerException) : base(message, innerException)
{
}
}
}

View File

@@ -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;
}

View File

@@ -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
{
/// <summary>
/// This will fetch an Umbraco package file from the package repository and return the relative file path to the downloaded package file
/// </summary>
/// <param name="packageId"></param>
/// <param name="umbracoVersion"></param>
/// <param name="userId">The current user id performing the operation</param>
/// <returns></returns>
string FetchPackageFile(Guid packageId, Version umbracoVersion, int userId);
/// <summary>
/// Imports and saves package xml as <see cref="IContent"/>
/// </summary>

View File

@@ -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.
/// </summary>
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<string, IContentType>();
}
/// <summary>
/// This will fetch an Umbraco package file from the package repository and return the relative file path to the downloaded package file
/// </summary>
/// <param name="packageId"></param>
/// <param name="umbracoVersion"></param>
/// /// <param name="userId">The current user id performing the operation</param>
/// <returns></returns>
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
/// <summary>
@@ -476,7 +535,7 @@ namespace Umbraco.Core.Services
var tryCreateFolder = _contentTypeService.CreateContentTypeContainer(-1, rootFolder);
if (tryCreateFolder == false)
{
_logger.Error<PackagingService>("Could not create folder: " + rootFolder, tryCreateFolder.Exception);
Logger.Error<PackagingService>("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<PackagingService>("Could not create folder: " + folderName, tryCreateFolder.Exception);
Logger.Error<PackagingService>("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<PackagingService>(
Logger.Warn<PackagingService>(
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<PackagingService>(
Logger.Warn<PackagingService>(
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<PackagingService>(
Logger.Warn<PackagingService>(
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<PackagingService>(
Logger.Warn<PackagingService>(
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<PackagingService>("Could not create folder: " + rootFolder, tryCreateFolder.Exception);
Logger.Error<PackagingService>("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<PackagingService>("Could not create folder: " + folderName, tryCreateFolder.Exception);
Logger.Error<PackagingService>("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<PackagingService>("No data type found with name " + dataTypeDefinitionName + " data type pre-values will not be saved");
Logger.Warn<PackagingService>("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<PackagingService>(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<PackagingService>(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<XElement>

View File

@@ -281,7 +281,8 @@ namespace Umbraco.Core.Services
cache.RuntimeCache));
if (_packagingService == null)
_packagingService = new Lazy<IPackagingService>(() => 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<IPackagingService>(() => 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<IRelationService>(() => new RelationService(provider, repositoryFactory, logger, eventMessagesFactory, _entityService.Value));

View File

@@ -339,6 +339,7 @@
<Compile Include="Events\IDeletingMediaFilesEventArgs.cs" />
<Compile Include="Events\ScopeEventDispatcherBase.cs" />
<Compile Include="Events\ScopeLifespanMessagesFactory.cs" />
<Compile Include="Exceptions\ConnectionException.cs" />
<Compile Include="IHttpContextAccessor.cs" />
<Compile Include="Models\PublishedContent\PublishedContentTypeConverter.cs" />
<Compile Include="OrderedHashSet.cs" />

View File

@@ -383,6 +383,8 @@ namespace Umbraco.Tests.Web.Mvc
new Mock<ILocalizationService>().Object,
new PackagingService(
new Mock<ILogger>().Object,
new Mock<IScopeUnitOfWorkProvider>().Object,
new TransientMessagesFactory(),
new Mock<IContentService>().Object,
new Mock<IContentTypeService>().Object,
new Mock<IMediaService>().Object,

View File

@@ -349,13 +349,6 @@
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="Umbraco\Install\Legacy\LoadStarterKits.ascx.cs">
<DependentUpon>loadStarterKits.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Umbraco\Install\Legacy\LoadStarterKits.ascx.designer.cs">
<DependentUpon>loadStarterKits.ascx</DependentUpon>
</Compile>
<Compile Include="Config\splashes\NoNodes.aspx.cs">
<DependentUpon>noNodes.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -573,7 +566,6 @@
<Content Include="Config\Lang\sv-SE.user.xml" />
<Content Include="Config\Lang\zh-CN.user.xml" />
<Content Include="Umbraco\Config\Lang\cs.xml" />
<Content Include="Umbraco\Install\Legacy\loadStarterKits.ascx" />
<Content Include="Umbraco\ClientRedirect.aspx" />
<Content Include="Umbraco\create.aspx" />
<Content Include="Umbraco\Logout.aspx" />

View File

@@ -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
{
/// <summary>
/// Returns the string for the package installer web service base url
/// </summary>
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");
}
/// <summary>
/// Flag to show if we can connect to the repo or not
/// </summary>
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<LoadStarterKits>("Cannot connect to package repository", ex);
CannotConnect = true;
}
}
else
{
CannotConnect = true;
}
}
protected void GotoLastStep(object sender, EventArgs e)
{
//InstallHelper.RedirectToLastStep(Page);
}
}
}

View File

@@ -1,60 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Umbraco.Web.UI.Install.Steps.Skinning {
public partial class LoadStarterKits {
/// <summary>
/// pl_loadStarterKits control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.PlaceHolder pl_loadStarterKits;
/// <summary>
/// JsInclude1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.JsInclude JsInclude1;
/// <summary>
/// rep_starterKits control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Repeater rep_starterKits;
/// <summary>
/// LinkButton1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.LinkButton LinkButton1;
/// <summary>
/// LinkButton2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.LinkButton LinkButton2;
}
}

View File

@@ -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" %>
<asp:PlaceHolder ID="pl_loadStarterKits" runat="server">
<umb:JsInclude ID="JsInclude1" runat="server" FilePath="installer/js/PackageInstaller.js" PathNameAlias="UmbracoClient" />
<% if (!CannotConnect) { %>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
var installer = new Umbraco.Installer.PackageInstaller({
starterKits: $("a.selectStarterKit"),
baseUrl: "<%= PackageInstallServiceBaseUrl %>",
serverError: $("#serverError"),
connectionError: $("#connectionError"),
setProgress: updateProgressBar,
setStatusMessage: updateStatusMessage
});
installer.init();
});
})(jQuery);
</script>
<% } %>
<div id="starter-kit-progress" style="display: none;">
<h2>Installation in progress...</h2>
<div class="loader">
<div class="hold">
<div class="progress-bar">
</div>
<span class="progress-bar-value">0%</span>
</div>
<strong></strong>
</div>
</div>
<asp:Repeater ID="rep_starterKits" runat="server">
<headertemplate>
<ul class="thumbnails">
</headertemplate>
<itemtemplate>
<li class="span4 add-<%# ((Package)Container.DataItem).Text.Replace(" ","").ToLower() %>">
<div class="thumbnail" style="margin-right: 10px; height: 260px">
<img src="http://our.umbraco.org<%# ((Package)Container.DataItem).Thumbnail %>?width=170" alt="<%# ((Package)Container.DataItem).Text %>">
<h4><%# ((Package)Container.DataItem).Text %></h4>
<%# ((Package)Container.DataItem).Description %>
<a href="#" class="btn btn-success single-tab selectStarterKit" data-name="<%# ((Package)Container.DataItem).Text %>" title="Install <%# ((Package)Container.DataItem).Text %>" data-repoid="<%# ((Package)Container.DataItem).RepoGuid %>">
Install
</a>
</div>
</li>
</itemtemplate>
<footertemplate>
</ul>
<%--<asp:LinkButton runat="server" ID="declineStarterKits" CssClass="declineKit" OnClientClick="return confirm('Are you sure you do not want to install a starter kit?');" OnClick="NextStep">
No thanks, do not install a starterkit!
</asp:LinkButton>--%>
</footertemplate>
</asp:Repeater>
</asp:PlaceHolder>
<div id="connectionError" style="<%= CannotConnect ? "" : "display:none;" %>">
<div style="padding: 0 100px 13px 5px;">
<h2>Oops...the installer can't connect to the repository</h2>
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.
<br />
Click <strong>Continue</strong> 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.
</div>
<!-- btn box -->
<footer class="btn-box">
<div class="t">&nbsp;</div>
<asp:LinkButton ID="LinkButton1" class="btn-step btn btn-continue" runat="server" OnClick="GotoLastStep"><span>Continue</span></asp:LinkButton>
</footer>
</div>
<div id="serverError" style="display:none;">
<div style="padding: 0 100px 13px 5px;">
<h2>Oops...the installer encountered an error</h2>
<div class="error-message"></div>
</div>
<!-- btn box -->
<footer class="btn-box">
<div class="t">&nbsp;</div>
<asp:LinkButton ID="LinkButton2" class="btn-step btn btn-continue" runat="server" OnClick="GotoLastStep"><span>Continue</span></asp:LinkButton>
</footer>
</div>

View File

@@ -39,7 +39,6 @@
<asp:TextBox ID="iconUrl" runat="server" Width="230px" CssClass="guiInputText"></asp:TextBox>
</cc2:PropertyPanel>
<cc2:PropertyPanel runat="server" ID="pp_file" Text="Package file (.zip):">
<asp:Button ID="bt_submitButton" runat="server" Text="Submit to repository" Visible="false" />
<asp:Literal ID="packageUmbFile" runat="server" />
</cc2:PropertyPanel>

View File

@@ -185,7 +185,7 @@ namespace Umbraco.Web.Editors
var actionsXml = new XmlDocument();
actionsXml.LoadXml("<Actions>" + pack.Data.Actions + "</Actions>");
LogHelper.Debug<installedPackage>("executing undo actions: {0}", () => actionsXml.OuterXml);
LogHelper.Debug<PackageInstallController>("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<installedPackage>("An error occurred running undo actions", ex);
LogHelper.Error<PackageInstallController>("An error occurred running undo actions", ex);
}
}
}
catch (Exception ex)
{
LogHelper.Error<installedPackage>("An error occurred running undo actions", ex);
LogHelper.Error<PackageInstallController>("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

View File

@@ -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
/// <returns></returns>
[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

View File

@@ -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),

View File

@@ -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<Guid?>
{
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<string, int> 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);

View File

@@ -36,7 +36,6 @@
ControlToValidate="packageVersion">*</asp:RequiredFieldValidator>
</cc2:PropertyPanel>
<cc2:PropertyPanel runat="server" ID="pp_file" Text="Package file (.zip):">
<asp:Button ID="bt_submitButton" runat="server" Text="Submit to repository" Visible="false" />
<asp:Literal ID="packageUmbFile" runat="server" />
</cc2:PropertyPanel>
</cc2:Pane>

View File

@@ -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 = " &nbsp; <a href='" + Page.ResolveClientUrl(pack.PackagePath) + "'>Download</a>";
if (cms.businesslogic.packager.repositories.Repository.getAll().Count > 0)
bt_submitButton.Visible = true;
packageUmbFile.Text = " &nbsp; <a href='" + Page.ResolveClientUrl(pack.PackagePath) + "'>Download</a>";
}
else
{

View File

@@ -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;
/// <summary>
/// packageName control.
/// </summary>
@@ -128,15 +129,6 @@ namespace umbraco.presentation.developer.packages {
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_file;
/// <summary>
/// bt_submitButton control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button bt_submitButton;
/// <summary>
/// packageUmbFile control.
/// </summary>

View File

@@ -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; }