Fixes up the starter kit installer in the back office with it's legacy implementation. Adds some handy methods for webapi routing for areas.
This commit is contained in:
@@ -1 +0,0 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="InstallerRestService.aspx.cs" Inherits="Umbraco.Web.UI.Install.InstallerRestService" %>
|
||||
@@ -1,126 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Security.Authentication;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Script.Services;
|
||||
using System.Web.Services;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web.Install;
|
||||
using umbraco;
|
||||
using umbraco.businesslogic.Exceptions;
|
||||
|
||||
namespace Umbraco.Web.UI.Install
|
||||
{
|
||||
public partial class InstallerRestService : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
LogHelper.Info<InstallerRestService>(string.Format("Hitting Page_Load on InstallerRestService.aspx for the requested '{0}' feed", Request.QueryString["feed"]));
|
||||
|
||||
// Stop Caching in IE
|
||||
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
|
||||
|
||||
// Stop Caching in Firefox
|
||||
Response.Cache.SetNoStore();
|
||||
|
||||
string feed = Request.QueryString["feed"];
|
||||
string url = "http://our.umbraco.org/html/twitter";
|
||||
|
||||
if (feed == "progress")
|
||||
{
|
||||
Response.ContentType = "application/json";
|
||||
//Response.Write(InstallHelper.GetProgress());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (feed == "blogs")
|
||||
url = "http://our.umbraco.org/html/blogs";
|
||||
|
||||
if (feed == "sitebuildervids")
|
||||
url = "http://umbraco.org/feeds/videos/site-builder-foundation-html";
|
||||
|
||||
if (feed == "developervids")
|
||||
url = "http://umbraco.org/feeds/videos/developer-foundation-html";
|
||||
|
||||
string xmlResponse = library.GetXmlDocumentByUrl(url).Current.OuterXml;
|
||||
|
||||
if (!xmlResponse.Contains("System.Net.WebException"))
|
||||
{
|
||||
Response.Write(library.GetXmlDocumentByUrl(url).Current.OuterXml);
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Write("We can't connect to umbraco.tv right now. Click <strong>Set up your new website</strong> above to continue.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public static string Install()
|
||||
{
|
||||
//if its not configured then we can continue
|
||||
if (ApplicationContext.Current == null || ApplicationContext.Current.IsConfigured)
|
||||
{
|
||||
throw new AuthenticationException("The application is already configured");
|
||||
}
|
||||
|
||||
LogHelper.Info<InstallerRestService>("Running 'Install' service");
|
||||
|
||||
var result = ApplicationContext.Current.DatabaseContext.CreateDatabaseSchemaAndData();
|
||||
|
||||
if (result.RequiresUpgrade == false)
|
||||
{
|
||||
HandleConnectionStrings();
|
||||
}
|
||||
|
||||
var js = new JavaScriptSerializer();
|
||||
var jsonResult = js.Serialize(result);
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public static string Upgrade()
|
||||
{
|
||||
//if its not configured then we can continue
|
||||
if (ApplicationContext.Current == null || ApplicationContext.Current.IsConfigured)
|
||||
{
|
||||
throw new AuthenticationException("The application is already configured");
|
||||
}
|
||||
|
||||
LogHelper.Info<InstallerRestService>("Running 'Upgrade' service");
|
||||
|
||||
var result = ApplicationContext.Current.DatabaseContext.UpgradeSchemaAndData();
|
||||
|
||||
HandleConnectionStrings();
|
||||
|
||||
//After upgrading we must restart the app pool - the reason is because PetaPoco caches a lot of the mapping logic
|
||||
// and after we upgrade a db, some of the mapping needs to be updated so we restart the app pool to clear it's cache or
|
||||
// else we can end up with YSODs
|
||||
ApplicationContext.Current.RestartApplicationPool(new HttpContextWrapper(HttpContext.Current));
|
||||
|
||||
var js = new JavaScriptSerializer();
|
||||
var jsonResult = js.Serialize(result);
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
private static void HandleConnectionStrings()
|
||||
{
|
||||
// Remove legacy umbracoDbDsn configuration setting if it exists and connectionstring also exists
|
||||
if (ConfigurationManager.ConnectionStrings[Core.Configuration.GlobalSettings.UmbracoConnectionName] != null)
|
||||
{
|
||||
Core.Configuration.GlobalSettings.RemoveSetting(Core.Configuration.GlobalSettings.UmbracoConnectionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
var ex = new ArgumentNullException(string.Format("ConfigurationManager.ConnectionStrings[{0}]", Core.Configuration.GlobalSettings.UmbracoConnectionName), "Install / upgrade did not complete successfully, umbracoDbDSN was not set in the connectionStrings section");
|
||||
LogHelper.Error<InstallerRestService>("", ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +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 {
|
||||
|
||||
|
||||
public partial class InstallerRestService {
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@ namespace Umbraco.Web.UI.Install.Steps.Skinning
|
||||
//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 = umbracoPath });
|
||||
//PackageInstallServiceBaseUrl = urlHelper.Action("Index", "InstallPackage", new { area = "UmbracoInstall" });
|
||||
PackageInstallServiceBaseUrl = urlHelper.GetUmbracoApiService("Index", "InstallPackage", "UmbracoInstall");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
//using System;
|
||||
//using System.Web.UI;
|
||||
//using Umbraco.Web.Install;
|
||||
|
||||
//namespace Umbraco.Web.UI.Install.Steps
|
||||
//{
|
||||
// public abstract class StepUserControl : UserControl
|
||||
// {
|
||||
// protected string GetCurrentStep()
|
||||
// {
|
||||
// var defaultPage = (Default) Page;
|
||||
// return defaultPage.step.Value;
|
||||
// }
|
||||
|
||||
// //protected virtual void GotoNextStep(object sender, EventArgs e)
|
||||
// //{
|
||||
// // InstallHelper.RedirectToNextStep(Page, GetCurrentStep());
|
||||
// //}
|
||||
// }
|
||||
//}
|
||||
@@ -55,9 +55,9 @@
|
||||
</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">
|
||||
<%--<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>
|
||||
</asp:LinkButton>--%>
|
||||
</footertemplate>
|
||||
</asp:Repeater>
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="Title.ascx.cs" Inherits="Umbraco.Web.UI.Install.Title" %>
|
||||
<%@ Import Namespace="Umbraco.Core.Configuration" %>
|
||||
<title>Umbraco <%=UmbracoVersion.Current.ToString(3)%> <%=UmbracoVersion.CurrentComment%> Configuration Wizard</title>
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace Umbraco.Web.UI.Install
|
||||
{
|
||||
public partial class Title : System.Web.UI.UserControl
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,15 +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 {
|
||||
|
||||
|
||||
public partial class Title {
|
||||
}
|
||||
}
|
||||
@@ -314,9 +314,6 @@
|
||||
<Compile Include="Areas\UmbracoInstall\Legacy\LoadStarterKits.ascx.designer.cs">
|
||||
<DependentUpon>loadStarterKits.ascx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Areas\UmbracoInstall\Legacy\StepUserControl.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Config\splashes\NoNodes.aspx.cs">
|
||||
<DependentUpon>noNodes.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -325,20 +322,6 @@
|
||||
<DependentUpon>noNodes.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Areas\UmbracoInstall\InstallerRestService.aspx.cs">
|
||||
<DependentUpon>InstallerRestService.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Areas\UmbracoInstall\InstallerRestService.aspx.designer.cs">
|
||||
<DependentUpon>InstallerRestService.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Areas\UmbracoInstall\Title.ascx.cs">
|
||||
<DependentUpon>Title.ascx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Areas\UmbracoInstall\Title.ascx.designer.cs">
|
||||
<DependentUpon>Title.ascx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
@@ -1676,8 +1659,6 @@
|
||||
<Content Include="Umbraco_Client\Installer\Js\jquery.1.4.4.js" />
|
||||
<Content Include="Umbraco_Client\Installer\Js\jquery.main.js" />
|
||||
<Content Include="Umbraco_Client\Installer\Js\jquery.ui.selectmenu.js" />
|
||||
<Content Include="Areas\UmbracoInstall\Title.ascx" />
|
||||
<Content Include="Areas\UmbracoInstall\InstallerRestService.aspx" />
|
||||
<Content Include="Umbraco\Config\Lang\ko.xml" />
|
||||
<Content Include="Umbraco\Dashboard\FeedProxy.aspx" />
|
||||
<Content Include="Umbraco\Developer\Packages\StarterKits.aspx" />
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Umbraco.Web.UI.Umbraco.Developer.Packages
|
||||
|
||||
private void ShowStarterKits()
|
||||
{
|
||||
if (Directory.Exists(Server.MapPath(SystemDirectories.Install)) == false)
|
||||
if (Directory.Exists(Server.MapPath("~/Areas/UmbracoInstall/Legacy")) == false)
|
||||
{
|
||||
InstallationDirectoryNotAvailable.Visible = true;
|
||||
StarterKitNotInstalled.Visible = false;
|
||||
@@ -71,7 +71,7 @@ namespace Umbraco.Web.UI.Umbraco.Developer.Packages
|
||||
}
|
||||
|
||||
|
||||
var starterkitsctrl = (LoadStarterKits)LoadControl(SystemDirectories.Install + "/steps/Skinning/loadStarterKits.ascx");
|
||||
var starterkitsctrl = (LoadStarterKits)LoadControl("~/Areas/UmbracoInstall/Legacy/loadStarterKits.ascx");
|
||||
|
||||
ph_starterkits.Controls.Add(starterkitsctrl);
|
||||
|
||||
|
||||
@@ -165,13 +165,7 @@
|
||||
self._setProgress(r.percentage, r.message);
|
||||
//install business logic
|
||||
self.installBusinessLogic();
|
||||
}
|
||||
else if (r && !r.success) {
|
||||
//hasn't completed restarted, re-poll in 2 seconds
|
||||
setTimeout(function() {
|
||||
self.pollForRestart();
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
self._showServerError("The server did not respond");
|
||||
}
|
||||
@@ -186,7 +180,7 @@
|
||||
data: "{'kitGuid': '" + self._packageId + "', 'manifestId': '" + self._manifestId + "', 'packageFile': '" + encodeURIComponent(self._packageFile) + "'}",
|
||||
url: self._opts.baseUrl + '/InstallBusinessLogic',
|
||||
success: function (r) {
|
||||
if (r && r.success) {
|
||||
if (r) {
|
||||
//set the progress
|
||||
self._setProgress(r.percentage, r.message);
|
||||
//cleanup install
|
||||
@@ -206,7 +200,7 @@
|
||||
data: "{'kitGuid': '" + self._packageId + "', 'manifestId': '" + self._manifestId + "', 'packageFile': '" + encodeURIComponent(self._packageFile) + "'}",
|
||||
url: self._opts.baseUrl + '/CleanupInstallation',
|
||||
success: function (r) {
|
||||
if (r && r.success) {
|
||||
if (r) {
|
||||
//set the progress
|
||||
self._setProgress(r.percentage, r.message);
|
||||
//installation complete!
|
||||
|
||||
28
src/Umbraco.Web/AreaRegistrationContextExtensions.cs
Normal file
28
src/Umbraco.Web/AreaRegistrationContextExtensions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Web.Http;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
internal static class AreaRegistrationContextExtensions
|
||||
{
|
||||
public static Route MapHttpRoute(this AreaRegistrationContext context, string name, string url, object defaults, string[] namespaces)
|
||||
{
|
||||
var apiRoute = context.Routes.MapHttpRoute(
|
||||
name,
|
||||
url,
|
||||
defaults);
|
||||
|
||||
//web api routes don't set the data tokens object
|
||||
if (apiRoute.DataTokens == null)
|
||||
{
|
||||
apiRoute.DataTokens = new RouteValueDictionary();
|
||||
}
|
||||
apiRoute.DataTokens.Add("area", context.AreaName);
|
||||
apiRoute.DataTokens.Add("Namespaces", namespaces); //look in this namespace to create the controller
|
||||
apiRoute.DataTokens.Add("UseNamespaceFallback", false); //Don't look anywhere else except this namespace!
|
||||
|
||||
return apiRoute;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace Umbraco.Web.Install.Controllers
|
||||
}
|
||||
|
||||
//gen the install base url
|
||||
ViewBag.InstallApiBaseUrl = Url.GetUmbracoApiService("GetSetup", "InstallApi", "install").TrimEnd("GetSetup");
|
||||
ViewBag.InstallApiBaseUrl = Url.GetUmbracoApiService("GetSetup", "InstallApi", "UmbracoInstall").TrimEnd("GetSetup");
|
||||
|
||||
//get the base umbraco folder
|
||||
ViewBag.UmbracoBaseFolder = IOHelper.ResolveUrl(SystemDirectories.Umbraco);
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Web.Http;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using umbraco;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Install.Models;
|
||||
using Umbraco.Web.WebApi;
|
||||
|
||||
namespace Umbraco.Web.Install.Controllers
|
||||
@@ -20,6 +21,7 @@ namespace Umbraco.Web.Install.Controllers
|
||||
/// is a bit of a mess currently.
|
||||
/// </remarks>
|
||||
[HttpInstallAuthorize]
|
||||
[AngularJsonOnlyConfiguration]
|
||||
[Obsolete("This is only used for the legacy way of installing starter kits in the back office")]
|
||||
public class InstallPackageController : ApiController
|
||||
{
|
||||
@@ -42,37 +44,38 @@ namespace Umbraco.Web.Install.Controllers
|
||||
/// Empty action, useful for retrieving the base url for this controller
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Index()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the repo, downloads the package and creates the manifest
|
||||
/// </summary>
|
||||
/// <param name="kitGuid"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public HttpResponseMessage DownloadPackageFiles(Guid kitGuid)
|
||||
/// <summary>
|
||||
/// Connects to the repo, downloads the package and creates the manifest
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <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.BadGateway);
|
||||
HttpStatusCode.OK);
|
||||
}
|
||||
if (repo.HasConnection() == false)
|
||||
{
|
||||
return Json(
|
||||
new { success = false, error = "cannot_connect" },
|
||||
HttpStatusCode.BadGateway);
|
||||
HttpStatusCode.OK);
|
||||
}
|
||||
var installer = new global::umbraco.cms.businesslogic.packager.Installer();
|
||||
|
||||
var tempFile = installer.Import(repo.fetch(kitGuid.ToString()));
|
||||
var tempFile = installer.Import(repo.fetch(model.KitGuid.ToString()));
|
||||
installer.LoadConfig(tempFile);
|
||||
var pId = installer.CreateManifest(tempFile, kitGuid.ToString(), RepoGuid);
|
||||
var pId = installer.CreateManifest(tempFile, model.KitGuid.ToString(), RepoGuid);
|
||||
return Json(new
|
||||
{
|
||||
success = true,
|
||||
@@ -88,17 +91,17 @@ namespace Umbraco.Web.Install.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public HttpResponseMessage InstallPackageFiles(Guid kitGuid, int manifestId, string packageFile)
|
||||
public HttpResponseMessage InstallPackageFiles(InstallPackageModel model)
|
||||
{
|
||||
packageFile = HttpUtility.UrlDecode(packageFile);
|
||||
model.PackageFile = HttpUtility.UrlDecode(model.PackageFile);
|
||||
var installer = new global::umbraco.cms.businesslogic.packager.Installer();
|
||||
installer.LoadConfig(packageFile);
|
||||
installer.InstallFiles(manifestId, packageFile);
|
||||
installer.LoadConfig(model.PackageFile);
|
||||
installer.InstallFiles(model.ManifestId, model.PackageFile);
|
||||
return Json(new
|
||||
{
|
||||
success = true,
|
||||
manifestId,
|
||||
packageFile,
|
||||
model.ManifestId,
|
||||
model.PackageFile,
|
||||
percentage = 20,
|
||||
message = "Installing starter kit files"
|
||||
}, HttpStatusCode.OK);
|
||||
@@ -134,7 +137,8 @@ namespace Umbraco.Web.Install.Controllers
|
||||
|
||||
return Json(new
|
||||
{
|
||||
percentage = 30
|
||||
percentage = 30,
|
||||
success = true,
|
||||
}, HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
@@ -143,17 +147,17 @@ namespace Umbraco.Web.Install.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public HttpResponseMessage InstallBusinessLogic(Guid kitGuid, int manifestId, string packageFile)
|
||||
public HttpResponseMessage InstallBusinessLogic(InstallPackageModel model)
|
||||
{
|
||||
packageFile = HttpUtility.UrlDecode(packageFile);
|
||||
model.PackageFile = HttpUtility.UrlDecode(model.PackageFile);
|
||||
var installer = new global::umbraco.cms.businesslogic.packager.Installer();
|
||||
installer.LoadConfig(packageFile);
|
||||
installer.InstallBusinessLogic(manifestId, packageFile);
|
||||
installer.LoadConfig(model.PackageFile);
|
||||
installer.InstallBusinessLogic(model.ManifestId, model.PackageFile);
|
||||
return Json(new
|
||||
{
|
||||
success = true,
|
||||
manifestId,
|
||||
packageFile,
|
||||
model.ManifestId,
|
||||
model.PackageFile,
|
||||
percentage = 70,
|
||||
message = "Installing starter kit files"
|
||||
}, HttpStatusCode.OK);
|
||||
@@ -164,20 +168,20 @@ namespace Umbraco.Web.Install.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public HttpResponseMessage CleanupInstallation(Guid kitGuid, int manifestId, string packageFile)
|
||||
public HttpResponseMessage CleanupInstallation(InstallPackageModel model)
|
||||
{
|
||||
packageFile = HttpUtility.UrlDecode(packageFile);
|
||||
model.PackageFile = HttpUtility.UrlDecode(model.PackageFile);
|
||||
var installer = new global::umbraco.cms.businesslogic.packager.Installer();
|
||||
installer.LoadConfig(packageFile);
|
||||
installer.InstallCleanUp(manifestId, packageFile);
|
||||
installer.LoadConfig(model.PackageFile);
|
||||
installer.InstallCleanUp(model.ManifestId, model.PackageFile);
|
||||
|
||||
library.RefreshContent();
|
||||
|
||||
return Json(new
|
||||
{
|
||||
success = true,
|
||||
manifestId,
|
||||
packageFile,
|
||||
model.ManifestId,
|
||||
model.PackageFile,
|
||||
percentage = 100,
|
||||
message = "Starter kit has been installed"
|
||||
}, HttpStatusCode.OK);
|
||||
|
||||
23
src/Umbraco.Web/Install/Models/InstallPackageModel.cs
Normal file
23
src/Umbraco.Web/Install/Models/InstallPackageModel.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Umbraco.Web.Install.Models
|
||||
{
|
||||
|
||||
[Obsolete("This is only used for the obsolete controller InstallPackageController")]
|
||||
[DataContract(Name = "installPackage", Namespace = "")]
|
||||
public class InstallPackageModel
|
||||
{
|
||||
[DataMember(Name = "kitGuid")]
|
||||
public Guid KitGuid { get; set; }
|
||||
[DataMember(Name = "manifestId")]
|
||||
public int ManifestId { get; set; }
|
||||
[DataMember(Name = "packageFile")]
|
||||
public string PackageFile { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,19 +28,20 @@ namespace Umbraco.Web.Install
|
||||
"Install",
|
||||
new { controller = "Install", action = "Index", id = UrlParameter.Optional },
|
||||
new[] { typeof(InstallController).Namespace });
|
||||
|
||||
var apiRoute = context.Routes.MapHttpRoute(
|
||||
|
||||
//TODO: We can remove this when we re-build the back office package installer
|
||||
//Create the install routes
|
||||
context.MapHttpRoute(
|
||||
"Umbraco_install_packages",
|
||||
"Install/PackageInstaller/{action}/{id}",
|
||||
new { controller = "InstallPackage", action = "Index", id = UrlParameter.Optional },
|
||||
new[] { typeof(InstallPackageController).Namespace });
|
||||
|
||||
context.MapHttpRoute(
|
||||
"umbraco-install-api",
|
||||
"install/api/{action}/{id}",
|
||||
new { controller = "InstallApi", action = "Status", id = RouteParameter.Optional });
|
||||
//web api routes don't set the data tokens object
|
||||
if (apiRoute.DataTokens == null)
|
||||
{
|
||||
apiRoute.DataTokens = new RouteValueDictionary();
|
||||
}
|
||||
apiRoute.DataTokens.Add("area", "Install");
|
||||
apiRoute.DataTokens.Add("Namespaces", new[] { typeof(InstallApiController).Namespace }); //look in this namespace to create the controller
|
||||
apiRoute.DataTokens.Add("UseNamespaceFallback", false); //Don't look anywhere else except this namespace!
|
||||
new {controller = "InstallApi", action = "Status", id = RouteParameter.Optional},
|
||||
new[] {typeof (InstallApiController).Namespace});
|
||||
}
|
||||
|
||||
public override string AreaName
|
||||
|
||||
@@ -36,15 +36,7 @@ namespace Umbraco.Web.Mvc
|
||||
id = @"[a-zA-Z]*"
|
||||
},
|
||||
new[] {typeof (BackOfficeController).Namespace});
|
||||
|
||||
//TODO: We can remove this when we re-build the back office package installer
|
||||
//Create the install routes
|
||||
context.MapRoute(
|
||||
"Umbraco_install_packages",
|
||||
"Install/PackageInstaller/{action}/{id}",
|
||||
new { controller = "InstallPackage", action = "Index", id = UrlParameter.Optional },
|
||||
new[] { typeof(InstallPackageController).Namespace });
|
||||
|
||||
|
||||
//Create the REST/web/script service routes
|
||||
context.MapRoute(
|
||||
"Umbraco_web_services",
|
||||
|
||||
@@ -3,11 +3,38 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
internal static class RouteCollectionExtensions
|
||||
internal static class RouteCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Routes a webapi controller with namespaces
|
||||
/// </summary>
|
||||
/// <param name="routes"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="defaults"></param>
|
||||
/// <param name="namespaces"></param>
|
||||
/// <returns></returns>
|
||||
public static Route MapHttpRoute(this RouteCollection routes, string name, string url, object defaults, string[] namespaces)
|
||||
{
|
||||
var apiRoute = routes.MapHttpRoute(
|
||||
name,
|
||||
url,
|
||||
defaults);
|
||||
|
||||
//web api routes don't set the data tokens object
|
||||
if (apiRoute.DataTokens == null)
|
||||
{
|
||||
apiRoute.DataTokens = new RouteValueDictionary();
|
||||
}
|
||||
apiRoute.DataTokens.Add("Namespaces", namespaces); //look in this namespace to create the controller
|
||||
apiRoute.DataTokens.Add("UseNamespaceFallback", false); //Don't look anywhere else except this namespace!
|
||||
|
||||
return apiRoute;
|
||||
}
|
||||
|
||||
public static void IgnoreStandardExclusions(this RouteCollection routes)
|
||||
{
|
||||
@@ -43,11 +70,11 @@ namespace Umbraco.Web
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="routes"></param>
|
||||
public static void RegisterArea<T>(this RouteCollection routes)
|
||||
where T : AreaRegistration
|
||||
where T : AreaRegistration, new()
|
||||
{
|
||||
|
||||
// instantiate the area registration
|
||||
var area = Activator.CreateInstance<T>();
|
||||
var area = new T();
|
||||
|
||||
// create a context, which is just the name and routes collection
|
||||
var context = new AreaRegistrationContext(area.AreaName, routes);
|
||||
|
||||
@@ -269,6 +269,7 @@
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ApplicationContextExtensions.cs" />
|
||||
<Compile Include="AreaRegistrationContextExtensions.cs" />
|
||||
<Compile Include="CacheHelperExtensions.cs" />
|
||||
<Compile Include="Cache\ApplicationCacheRefresher.cs" />
|
||||
<Compile Include="Cache\ApplicationTreeCacheRefresher.cs" />
|
||||
@@ -320,6 +321,7 @@
|
||||
<Compile Include="Install\Models\DatabaseType.cs" />
|
||||
<Compile Include="Install\Models\InstallationType.cs" />
|
||||
<Compile Include="Install\Models\InstallInstructions.cs" />
|
||||
<Compile Include="Install\Models\InstallPackageModel.cs" />
|
||||
<Compile Include="Install\Models\InstallProgressResultModel.cs" />
|
||||
<Compile Include="Install\Models\InstallSetup.cs" />
|
||||
<Compile Include="Install\Models\InstallSetupResult.cs" />
|
||||
@@ -483,6 +485,7 @@
|
||||
<DependentUpon>Reference.map</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WebApi\AngularJsonMediaTypeFormatter.cs" />
|
||||
<Compile Include="WebApi\AngularJsonOnlyConfigurationAttribute.cs" />
|
||||
<Compile Include="WebApi\Binders\MemberBinder.cs" />
|
||||
<Compile Include="WebApi\Filters\AngularAntiForgeryHelper.cs" />
|
||||
<Compile Include="WebApi\Filters\ClearAngularAntiForgeryTokenAttribute.cs" />
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using System.Web.Http.Controllers;
|
||||
|
||||
namespace Umbraco.Web.WebApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Applying this attribute to any webapi controller will ensure that it only contains one json formatter compatible with the angular json vulnerability prevention.
|
||||
/// </summary>
|
||||
public class AngularJsonOnlyConfigurationAttribute : Attribute, IControllerConfiguration
|
||||
{
|
||||
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
|
||||
{
|
||||
//remove all json/xml formatters then add our custom one
|
||||
var toRemove = controllerSettings.Formatters.Where(t => (t is JsonMediaTypeFormatter) || (t is XmlMediaTypeFormatter)).ToList();
|
||||
foreach (var r in toRemove)
|
||||
{
|
||||
controllerSettings.Formatters.Remove(r);
|
||||
}
|
||||
controllerSettings.Formatters.Add(new AngularJsonMediaTypeFormatter());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Formatting;
|
||||
using System.Runtime.Remoting.Contexts;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -113,21 +112,4 @@ namespace Umbraco.Web.WebApi
|
||||
// controllerContext.Configuration.Formatters.Add(new AngularJsonMediaTypeFormatter());
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applying this attribute to any webapi controller will ensure that it only contains one json formatter compatible with the angular json vulnerability prevention.
|
||||
/// </summary>
|
||||
public class AngularJsonOnlyConfigurationAttribute : Attribute, IControllerConfiguration
|
||||
{
|
||||
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
|
||||
{
|
||||
//remove all json/xml formatters then add our custom one
|
||||
var toRemove = controllerSettings.Formatters.Where(t => (t is JsonMediaTypeFormatter) || (t is XmlMediaTypeFormatter)).ToList();
|
||||
foreach (var r in toRemove)
|
||||
{
|
||||
controllerSettings.Formatters.Remove(r);
|
||||
}
|
||||
controllerSettings.Formatters.Add(new AngularJsonMediaTypeFormatter());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,27 +201,15 @@ namespace Umbraco.Web
|
||||
defaultRoute.RouteHandler = new RenderRouteHandler(ControllerBuilder.Current.GetControllerFactory());
|
||||
|
||||
//register install routes
|
||||
RouteInstallArea();
|
||||
RouteTable.Routes.RegisterArea<UmbracoInstallArea>();
|
||||
|
||||
//register all back office routes
|
||||
RouteBackOfficeArea();
|
||||
RouteTable.Routes.RegisterArea<BackOfficeArea>();
|
||||
|
||||
//plugin controllers must come first because the next route will catch many things
|
||||
RoutePluginControllers();
|
||||
}
|
||||
|
||||
private void RouteInstallArea()
|
||||
{
|
||||
var installArea = new UmbracoInstallArea();
|
||||
RouteTable.Routes.RegisterArea(installArea);
|
||||
}
|
||||
|
||||
private void RouteBackOfficeArea()
|
||||
{
|
||||
var backOfficeArea = new BackOfficeArea();
|
||||
RouteTable.Routes.RegisterArea(backOfficeArea);
|
||||
}
|
||||
|
||||
|
||||
private void RoutePluginControllers()
|
||||
{
|
||||
var umbracoPath = GlobalSettings.UmbracoMvcArea;
|
||||
@@ -271,14 +259,13 @@ namespace Umbraco.Web
|
||||
var route = RouteTable.Routes.MapHttpRoute(
|
||||
string.Format("umbraco-{0}-{1}", "api", meta.ControllerName),
|
||||
routePath,
|
||||
new { controller = meta.ControllerName, id = UrlParameter.Optional });
|
||||
new { controller = meta.ControllerName, id = UrlParameter.Optional },
|
||||
new[] { meta.ControllerNamespace });
|
||||
//web api routes don't set the data tokens object
|
||||
if (route.DataTokens == null)
|
||||
{
|
||||
route.DataTokens = new RouteValueDictionary();
|
||||
}
|
||||
route.DataTokens.Add("Namespaces", new[] { meta.ControllerNamespace }); //look in this namespace to create the controller
|
||||
route.DataTokens.Add("UseNamespaceFallback", false); //Don't look anywhere else except this namespace!
|
||||
route.DataTokens.Add("umbraco", "api"); //ensure the umbraco token is set
|
||||
}
|
||||
private void RouteLocalSurfaceController(Type controller, string umbracoPath)
|
||||
|
||||
Reference in New Issue
Block a user