diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs index 643e0827..168db35f 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs @@ -979,6 +979,8 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@ClusterId", clusterId), new SqlParameter("@comments", comments)); + UpdateServerPackageServices(serverId); + return Convert.ToInt32(prmServiceId.Value); } @@ -1559,6 +1561,8 @@ namespace WebsitePanel.EnterpriseServer // read identity packageId = Convert.ToInt32(prmPackageId.Value); + DistributePackageServices(actorId, packageId); + return ds; } @@ -1660,6 +1664,33 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@PackageAddonID", packageAddonId)); } + public static void UpdateServerPackageServices(int serverId) + { + // FIXME + int defaultActorID = 1; + + // get server packages + IDataReader packagesReader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, + @"SELECT PackageID FROM Packages WHERE ServerID = @ServerID", + new SqlParameter("@ServerID", serverId) + ); + + // call DistributePackageServices for all packages on this server + while (packagesReader.Read()) + { + int packageId = (int) packagesReader["PackageID"]; + DistributePackageServices(defaultActorID, packageId); + } + } + + public static void DistributePackageServices(int actorId, int packageId) + { + SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "DistributePackageServices", + new SqlParameter("@ActorId", actorId), + new SqlParameter("@PackageID", packageId)); + } + #endregion #region Packages Settings @@ -3932,15 +3963,16 @@ namespace WebsitePanel.EnterpriseServer return packageId; } - public static int GetServiceIdByProviderForServer(int providerId, int serverId) + public static int GetServiceIdByProviderForServer(int providerId, int packageId) { IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, @"SELECT TOP 1 - ServiceID - FROM Services - WHERE ProviderID = @ProviderID AND ServerID = @ServerID", + PackageServices.ServiceID + FROM PackageServices + LEFT JOIN Services ON Services.ServiceID = PackageServices.ServiceID + WHERE PackageServices.PackageID = @PackageID AND Services.ProviderID = @ProviderID", new SqlParameter("@ProviderID", providerId), - new SqlParameter("@ServerID", serverId)); + new SqlParameter("@PackageID", packageId)); if (reader.Read()) { @@ -4049,6 +4081,26 @@ namespace WebsitePanel.EnterpriseServer return reader; } + public static int GetServiceIdForProviderIdAndPackageId(int providerId, int packageId) + { + IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, + @"SELECT PackageServices.ServiceID + FROM PackageServices + INNER JOIN Services ON PackageServices.ServiceID = Services.ServiceID + WHERE Services.ProviderID = @ProviderID and PackageID = @PackageID", + new SqlParameter("@ProviderID", providerId), + new SqlParameter("@PackageID", packageId) + ); + + if (reader.Read()) + { + return (int)reader["ServiceID"]; + } + + return -1; + + } + public static int GetServerIdForPackage(int packageId) { IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HeliconZoo/HeliconZooController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HeliconZoo/HeliconZooController.cs index b63e0526..d7be53b7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HeliconZoo/HeliconZooController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HeliconZoo/HeliconZooController.cs @@ -76,6 +76,31 @@ namespace WebsitePanel.EnterpriseServer public static ShortHeliconZooEngine[] GetAllowedHeliconZooQuotasForPackage(int packageId) { + // first, check IsEnginesAllowed for this server + + // get helicon zoo provider serviceId + int heliconZooProviderId, heliconZooGroupId; + DataProvider.GetHeliconZooProviderAndGroup("HeliconZoo", out heliconZooProviderId, out heliconZooGroupId); + + // get helicon zoo service id for heliconZooProviderId and packageId + int serviceId = DataProvider.GetServiceIdForProviderIdAndPackageId(heliconZooProviderId, packageId); + + if (serviceId > 0) + { + if (IsEnginesEnabled(serviceId)) + { + // all engines allowed by default + return new ShortHeliconZooEngine[] + { + new ShortHeliconZooEngine{Name = "*", DisplayName = "*", Enabled = true} + }; + } + } + + + // all engines is not allowed + // get allowed engines from hosting plan quotas + List allowedEngines = new List(); IDataReader reader = DataProvider.GetEnabledHeliconZooQuotasForPackage(packageId); @@ -236,7 +261,7 @@ namespace WebsitePanel.EnterpriseServer } // get Helicon Zoo service for site - int serviceId = DataProvider.GetServiceIdByProviderForServer(heliconZooProviderId, serverId); + int serviceId = DataProvider.GetServiceIdByProviderForServer(heliconZooProviderId, packageId); return serviceId; } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs index 0e3e8efd..1b89f3dc 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs @@ -229,6 +229,8 @@ namespace WebsitePanel.EnterpriseServer if (result.ExceedingQuotas.Tables[0].Rows.Count > 0) result.Result = BusinessErrorCodes.ERROR_PACKAGE_QUOTA_EXCEED; + DataProvider.DistributePackageServices(SecurityContext.User.UserId, plan.PackageId); + return result; } @@ -781,6 +783,8 @@ namespace WebsitePanel.EnterpriseServer // Update the Hard quota on home folder in case it was enabled and in case there was a change in disk space UpdatePackageHardQuota(package.PackageId); + + DataProvider.DistributePackageServices(SecurityContext.User.UserId, package.PackageId); } finally { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Web/HttpError.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Web/HttpError.cs index e46b2041..2b7ff7fc 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Web/HttpError.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Web/HttpError.cs @@ -34,8 +34,25 @@ using System.ComponentModel; namespace WebsitePanel.Providers.Web { - public class HttpError + public enum HttpErrorsMode { + DetailedLocalOnly = 0, + Custom = 1, + Detailed = 2 + } + + public enum HttpErrorsExistingResponse + { + Auto = 0, + Replace = 1, + PassThrough = 2 + } + + public class HttpError + { + public const HttpErrorsMode DefaultHttpErrorsMode = HttpErrorsMode.DetailedLocalOnly; + public const HttpErrorsExistingResponse DefaultHttpErrorsExistingResponse = HttpErrorsExistingResponse.Auto; + private string errorCode; private string errorSubcode; private string handlerType; diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Web/WebVirtualDirectory.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Web/WebVirtualDirectory.cs index 26bce3f7..f3e083b0 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Web/WebVirtualDirectory.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Web/WebVirtualDirectory.cs @@ -61,6 +61,8 @@ namespace WebsitePanel.Providers.Web private string defaultDocs; private string httpRedirect; private HttpError[] httpErrors; + private HttpErrorsMode errorMode; + private HttpErrorsExistingResponse existingResponse; private MimeMap[] mimeMaps; private HttpHeader[] httpHeaders; private bool aspInstalled; @@ -122,6 +124,18 @@ namespace WebsitePanel.Providers.Web set { httpErrors = value; } } + public HttpErrorsMode ErrorMode + { + get { return errorMode; } + set { errorMode = value; } + } + + public HttpErrorsExistingResponse ExistingResponse + { + get { return existingResponse; } + set { existingResponse = value; } + } + public string ApplicationPool { get { return this.applicationPool; } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/WebObjects/CustomHttpErrorsModuleService.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/WebObjects/CustomHttpErrorsModuleService.cs index 91946522..e811aa5e 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/WebObjects/CustomHttpErrorsModuleService.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/WebObjects/CustomHttpErrorsModuleService.cs @@ -54,6 +54,9 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath); // var httpErrorsSection = config.GetSection(Constants.HttpErrorsSection); + + virtualDir.ErrorMode = (HttpErrorsMode)httpErrorsSection.GetAttributeValue("errorMode"); + virtualDir.ExistingResponse = (HttpErrorsExistingResponse)httpErrorsSection.GetAttributeValue("existingResponse"); // var errorsCollection = httpErrorsSection.GetCollection(); // @@ -87,10 +90,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects } #endregion - // Http errors list is either empty or not set so defaults to the parent - if (virtualDir.HttpErrors == null || virtualDir.HttpErrors.Length == 0) - return; - #region Put the change in effect using (var srvman = GetServerManager()) { @@ -98,33 +97,45 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects // var section = config.GetSection(Constants.HttpErrorsSection); - // enable custom errors - section.SetAttributeValue("errorMode", "Custom"); + // set error mode + section.SetAttributeValue("errorMode", virtualDir.ErrorMode); + if (virtualDir.ErrorMode == HttpErrorsMode.Detailed) + { + section.SetAttributeValue("existingResponse", HttpErrorsExistingResponse.PassThrough); + } + else + { + section.SetAttributeValue("existingResponse", HttpErrorsExistingResponse.Auto); + } - // - var errorsCollection = section.GetCollection(); - // - foreach (var item in virtualDir.HttpErrors) - { - int indexOf = FindHttpError(errorsCollection, item); - // Just update the element attributes - IIS 7 API will do the rest - if (indexOf > -1) - { - var item2Renew = errorsCollection[indexOf]; - // - FillConfigurationElementWithData(item2Renew, item, virtualDir); - // - continue; - } - // - var item2Add = CreateHttpError(errorsCollection, item, virtualDir); - // - if (item2Add == null) - continue; - // - errorsCollection.Add(item2Add); - } - // + // save custom errors + if (virtualDir.HttpErrors != null && virtualDir.HttpErrors.Length > 0) + { + var errorsCollection = section.GetCollection(); + // + foreach (var item in virtualDir.HttpErrors) + { + int indexOf = FindHttpError(errorsCollection, item); + // Just update the element attributes - IIS 7 API will do the rest + if (indexOf > -1) + { + var item2Renew = errorsCollection[indexOf]; + // + FillConfigurationElementWithData(item2Renew, item, virtualDir); + // + continue; + } + // + var item2Add = CreateHttpError(errorsCollection, item, virtualDir); + // + if (item2Add == null) + continue; + // + errorsCollection.Add(item2Add); + } + } + + // srvman.CommitChanges(); } #endregion diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesCustomErrorsControl.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesCustomErrorsControl.ascx.resx index 8b02047a..a9163103 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesCustomErrorsControl.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesCustomErrorsControl.ascx.resx @@ -156,4 +156,7 @@ Redirect + + Error Mode + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx index fe5c5076..363ee19a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx @@ -1,4 +1,19 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebSitesCustomErrorsControl.ascx.cs" Inherits="WebsitePanel.Portal.WebSitesCustomErrorsControl" %> + + +
+ + + + + +
+ : + + +
+
+
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx.cs index 9f121d63..8a749672 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx.cs @@ -63,16 +63,29 @@ namespace WebsitePanel.Portal { IIs7 = item.IIs7; - // bind data + // bind error mode + ddlErrorMode.Items.Add(HttpErrorsMode.DetailedLocalOnly.ToString()); + ddlErrorMode.Items.Add(HttpErrorsMode.Custom.ToString()); + ddlErrorMode.Items.Add(HttpErrorsMode.Detailed.ToString()); + + ddlErrorMode.SelectedValue = item.ErrorMode.ToString(); + + // bind errors list gvErrorPages.DataSource = item.HttpErrors; gvErrorPages.DataBind(); } public void SaveWebItem(WebVirtualDirectory item) { + item.ErrorMode = GetSelectedErrorMode(); item.HttpErrors = CollectFormData(false).ToArray(); } + private HttpErrorsMode GetSelectedErrorMode() + { + return (HttpErrorsMode)Enum.Parse(typeof (HttpErrorsMode), ddlErrorMode.SelectedValue); + } + public List CollectFormData(bool includeEmpty) { List errors = new List(); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx.designer.cs index f9429ba1..dbe2174e 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesCustomErrorsControl.ascx.designer.cs @@ -1,10 +1,37 @@ +// Copyright (c) 2012, Outercurve Foundation. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// - Neither the name of the Outercurve Foundation nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3074 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,6 +40,33 @@ namespace WebsitePanel.Portal { public partial class WebSitesCustomErrorsControl { + /// + /// rowAspNet control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlTableRow rowAspNet; + + /// + /// lblErrorMode control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblErrorMode; + + /// + /// ddlErrorMode control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList ddlErrorMode; + /// /// btnAdd control. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesHeliconZooControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesHeliconZooControl.ascx.cs index 9fdd126c..91da8f10 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesHeliconZooControl.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesHeliconZooControl.ascx.cs @@ -58,20 +58,17 @@ namespace WebsitePanel.Portal Array.Sort(allowedEngineArray, new ShortHeliconZooEngineComparer()); - - // get enabled engines for this site from applicationHost.config string[] enabledEngineNames = ES.Services.HeliconZoo.GetEnabledEnginesForSite(site.SiteId, site.PackageId); ViewState["EnabledEnginesNames"] = enabledEngineNames; //console allowed in applicationHost.config ViewState["IsZooWebConsoleEnabled"] = enabledEngineNames.Contains("console", StringComparer.OrdinalIgnoreCase); - - List allowedEngines = new List(allowedEngineArray); + // fix engine name and check is web console enabled foreach (ShortHeliconZooEngine engine in allowedEngines) { engine.Name = engine.Name.Replace("HeliconZoo.", ""); @@ -82,7 +79,6 @@ namespace WebsitePanel.Portal //console allowed in hosting plan ViewState["IsZooWebConsoleEnabled"] = engine.Enabled; } - } ViewState["AllowedEngines"] = allowedEngines; @@ -146,7 +142,11 @@ namespace WebsitePanel.Portal continue; //skip } - if (string.Equals(appEngine, engine.KeywordedName, StringComparison.OrdinalIgnoreCase)) + if ( + string.Equals(appEngine, engine.KeywordedName, StringComparison.OrdinalIgnoreCase) + || + engine.Name == "*" + ) { filteredApplications.Add(application);