--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-12-09 16:46:30 -08:00
9 changed files with 98 additions and 37 deletions
+5
View File
@@ -0,0 +1,5 @@
SET CDIR = %CD%
call "%ProgramFiles%\Windows Azure SDK\v1.3\bin\setenv.cmd"
csrun /devstore
csrun /run:"%CDIR %\build\Compile\Orchard.Azure.CloudService.csx";"%CDIR %\src\Orchard.Azure\Orchard.Azure.CloudService\ServiceConfiguration.cscfg" /launchbrowser
pause
@@ -83,32 +83,27 @@ namespace Orchard.Azure.Environment.Configuration {
} }
} }
class Content { static ShellSettings ParseSettings(string text)
public string Name { get; set; } {
public string DataProvider { get; set; }
public string DataConnectionString { get; set; }
public string DataPrefix { get; set; }
public string RequestUrlHost { get; set; }
public string RequestUrlPrefix { get; set; }
public string State { get; set; }
}
static ShellSettings ParseSettings(string text) {
var shellSettings = new ShellSettings(); var shellSettings = new ShellSettings();
if ( String.IsNullOrEmpty(text) ) if (String.IsNullOrEmpty(text))
return shellSettings; return shellSettings;
string[] settings = text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string[] settings = text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach ( var setting in settings ) { foreach (var setting in settings)
{
string[] settingFields = setting.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries); string[] settingFields = setting.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
int fieldsLength = settingFields.Length; int fieldsLength = settingFields.Length;
if ( fieldsLength != 2 ) if (fieldsLength != 2)
continue; continue;
for ( int i = 0; i < fieldsLength; i++ ) { for (int i = 0; i < fieldsLength; i++)
{
settingFields[i] = settingFields[i].Trim(); settingFields[i] = settingFields[i].Trim();
} }
if ( settingFields[1] != "null" ) { if (settingFields[1] != "null")
switch ( settingFields[0] ) { {
switch (settingFields[0])
{
case "Name": case "Name":
shellSettings.Name = settingFields[1]; shellSettings.Name = settingFields[1];
break; break;
@@ -130,24 +125,38 @@ namespace Orchard.Azure.Environment.Configuration {
case "RequestUrlPrefix": case "RequestUrlPrefix":
shellSettings.RequestUrlPrefix = settingFields[1]; shellSettings.RequestUrlPrefix = settingFields[1];
break; break;
case "EncryptionAlgorithm":
shellSettings.EncryptionAlgorithm = settingFields[1];
break;
case "EncryptionKey":
shellSettings.EncryptionKey = settingFields[1];
break;
case "EncryptionIV":
shellSettings.EncryptionIV = settingFields[1];
break;
} }
} }
} }
return shellSettings; return shellSettings;
} }
static string ComposeSettings(ShellSettings settings) { static string ComposeSettings(ShellSettings settings)
if ( settings == null ) {
if (settings == null)
return ""; return "";
return string.Format("Name: {0}\r\nDataProvider: {1}\r\nDataConnectionString: {2}\r\nDataPrefix: {3}\r\nRequestUrlHost: {4}\r\nRequestUrlPrefix: {5}\r\nState: {6}\r\n", return string.Format("Name: {0}\r\nDataProvider: {1}\r\nDataConnectionString: {2}\r\nDataPrefix: {3}\r\nRequestUrlHost: {4}\r\nRequestUrlPrefix: {5}\r\nState: {6}\r\nEncryptionAlgorithm: {7}\r\nEncryptionKey: {8}\r\nEncryptionIV: {9}\r\n",
settings.Name, settings.Name,
settings.DataProvider, settings.DataProvider,
settings.DataConnectionString ?? "null", settings.DataConnectionString ?? "null",
settings.DataTablePrefix ?? "null", settings.DataTablePrefix ?? "null",
settings.RequestUrlHost ?? "null", settings.RequestUrlHost ?? "null",
settings.RequestUrlPrefix ?? "null", settings.RequestUrlPrefix ?? "null",
settings.State != null ? settings.State.ToString() : String.Empty); settings.State != null ? settings.State.ToString() : String.Empty,
settings.EncryptionAlgorithm ?? "null",
settings.EncryptionKey ?? "null",
settings.EncryptionIV ?? "null"
);
} }
} }
} }
@@ -1,13 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="OrchardCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> <ServiceDefinition name="OrchardCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="Orchard.Azure.Web"> <WebRole name="Orchard.Azure.Web">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="HttpIn" endpointName="HttpIn" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings> <ConfigurationSettings>
<Setting name="DiagnosticsConnectionString" /> <Setting name="DiagnosticsConnectionString" />
<Setting name="DataConnectionString" /> <Setting name="DataConnectionString" />
@@ -75,8 +75,9 @@
<Reference Include="System.Data.DataSetExtensions"> <Reference Include="System.Data.DataSetExtensions">
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System.Data.SqlServerCe, Version=3.5.1.0, PublicKeyToken=89845dcd8080cc91"> <Reference Include="System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<Private>True</Private> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\sqlce\System.Data.SqlServerCe.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Web.ApplicationServices"> <Reference Include="System.Web.ApplicationServices">
<Private>False</Private> <Private>False</Private>
@@ -25,7 +25,7 @@ namespace Orchard.Blogs {
var singleBlog = blogCount == 1 ? blogs.ElementAt(0) : null; var singleBlog = blogCount == 1 ? blogs.ElementAt(0) : null;
if (blogCount > 0 && singleBlog == null) { if (blogCount > 0 && singleBlog == null) {
menu.Add(T("List"), "3", menu.Add(T("Manage Blogs"), "3",
item => item.Action("List", "BlogAdmin", new {area = "Orchard.Blogs"}).Permission(Permissions.MetaListOwnBlogs)); item => item.Action("List", "BlogAdmin", new {area = "Orchard.Blogs"}).Permission(Permissions.MetaListOwnBlogs));
} }
else if (singleBlog != null) else if (singleBlog != null)
@@ -1,6 +1,7 @@
using Orchard.Environment.Extensions; using Orchard.Environment.Extensions;
using Orchard.Localization; using Orchard.Localization;
using Orchard.UI.Navigation; using Orchard.UI.Navigation;
using Orchard.Security;
namespace Orchard.Packaging { namespace Orchard.Packaging {
[OrchardFeature("Gallery")] [OrchardFeature("Gallery")]
@@ -12,11 +13,14 @@ namespace Orchard.Packaging {
public void GetNavigation(NavigationBuilder builder) { public void GetNavigation(NavigationBuilder builder) {
builder.Add(T("Gallery"), "30", menu => menu builder.Add(T("Gallery"), "30", menu => menu
.Add(T("Modules"), "1.0", item => item .Add(T("Modules"), "1.0", item => item
.Action("Modules", "Gallery", new { area = "Orchard.Packaging" })) .Action("Modules", "Gallery", new { area = "Orchard.Packaging" })
.Permission(StandardPermissions.SiteOwner))
.Add(T("Themes"), "2.0", item => item .Add(T("Themes"), "2.0", item => item
.Action("Themes", "Gallery", new { area = "Orchard.Packaging" })) .Action("Themes", "Gallery", new { area = "Orchard.Packaging" })
.Permission(StandardPermissions.SiteOwner))
.Add(T("Feeds"), "3.0", item => item .Add(T("Feeds"), "3.0", item => item
.Action("Sources", "Gallery", new { area = "Orchard.Packaging" }))); .Action("Sources", "Gallery", new { area = "Orchard.Packaging" })
.Permission(StandardPermissions.SiteOwner)));
} }
} }
} }
@@ -9,6 +9,7 @@ using Orchard.Localization;
using Orchard.Logging; using Orchard.Logging;
using Orchard.Packaging.Services; using Orchard.Packaging.Services;
using Orchard.Packaging.ViewModels; using Orchard.Packaging.ViewModels;
using Orchard.Security;
using Orchard.Themes; using Orchard.Themes;
using Orchard.UI.Admin; using Orchard.UI.Admin;
using Orchard.UI.Notify; using Orchard.UI.Notify;
@@ -26,36 +27,51 @@ namespace Orchard.Packaging.Controllers {
public GalleryController( public GalleryController(
IPackageManager packageManager, IPackageManager packageManager,
IPackagingSourceManager packagingSourceManager, IPackagingSourceManager packagingSourceManager,
INotifier notifier) { INotifier notifier,
IOrchardServices services) {
_packageManager = packageManager; _packageManager = packageManager;
_packagingSourceManager = packagingSourceManager; _packagingSourceManager = packagingSourceManager;
_notifier = notifier; _notifier = notifier;
Services = services;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
Logger = NullLogger.Instance; Logger = NullLogger.Instance;
} }
public IOrchardServices Services { get; set; }
public Localizer T { get; set; } public Localizer T { get; set; }
public ILogger Logger { get; set; } public ILogger Logger { get; set; }
public ActionResult Sources() { public ActionResult Sources() {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list sources")))
return new HttpUnauthorizedResult();
return View(new PackagingSourcesViewModel { return View(new PackagingSourcesViewModel {
Sources = _packagingSourceManager.GetSources(), Sources = _packagingSourceManager.GetSources(),
}); });
} }
public ActionResult Remove(int id) { public ActionResult Remove(int id) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to remove sources")))
return new HttpUnauthorizedResult();
_packagingSourceManager.RemoveSource(id); _packagingSourceManager.RemoveSource(id);
_notifier.Information(T("The feed has been removed successfully.")); _notifier.Information(T("The feed has been removed successfully."));
return RedirectToAction("Sources"); return RedirectToAction("Sources");
} }
public ActionResult AddSource() { public ActionResult AddSource() {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
return new HttpUnauthorizedResult();
return View(new PackagingAddSourceViewModel()); return View(new PackagingAddSourceViewModel());
} }
[HttpPost] [HttpPost]
public ActionResult AddSource(string url) { public ActionResult AddSource(string url) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
return new HttpUnauthorizedResult();
try { try {
if (!String.IsNullOrEmpty(url)) { if (!String.IsNullOrEmpty(url)) {
if (!url.StartsWith("http")) { if (!url.StartsWith("http")) {
@@ -96,6 +112,9 @@ namespace Orchard.Packaging.Controllers {
} }
public ActionResult Modules(int? sourceId) { public ActionResult Modules(int? sourceId) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list modules")))
return new HttpUnauthorizedResult();
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault(); var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
var sources = selectedSource != null var sources = selectedSource != null
@@ -123,6 +142,9 @@ namespace Orchard.Packaging.Controllers {
} }
public ActionResult Themes(int? sourceId) { public ActionResult Themes(int? sourceId) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list themes")))
return new HttpUnauthorizedResult();
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault(); var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
var sources = selectedSource != null var sources = selectedSource != null
@@ -138,6 +160,9 @@ namespace Orchard.Packaging.Controllers {
} }
public ActionResult Install(string packageId, string version, int sourceId, string redirectTo) { public ActionResult Install(string packageId, string version, int sourceId, string redirectTo) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
return new HttpUnauthorizedResult();
var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault(); var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
if (source == null) { if (source == null) {
@@ -8,6 +8,7 @@ using Orchard.Environment.Extensions;
using Orchard.FileSystems.AppData; using Orchard.FileSystems.AppData;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Packaging.Services; using Orchard.Packaging.Services;
using Orchard.Security;
using Orchard.Themes; using Orchard.Themes;
using Orchard.UI.Admin; using Orchard.UI.Admin;
using Orchard.UI.Notify; using Orchard.UI.Notify;
@@ -25,7 +26,8 @@ namespace Orchard.Packaging.Controllers {
public PackagingServicesController( public PackagingServicesController(
IPackageManager packageManager, IPackageManager packageManager,
INotifier notifier, INotifier notifier,
IAppDataFolderRoot appDataFolderRoot) { IAppDataFolderRoot appDataFolderRoot,
IOrchardServices services) {
_packageManager = packageManager; _packageManager = packageManager;
_notifier = notifier; _notifier = notifier;
_appDataFolderRoot = appDataFolderRoot; _appDataFolderRoot = appDataFolderRoot;
@@ -34,31 +36,50 @@ namespace Orchard.Packaging.Controllers {
} }
public Localizer T { get; set; } public Localizer T { get; set; }
public IOrchardServices Services { get; set; }
public ActionResult AddTheme(string returnUrl) { public ActionResult AddTheme(string returnUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add themes")))
return new HttpUnauthorizedResult();
return View(); return View();
} }
[HttpPost, ActionName("AddTheme")] [HttpPost, ActionName("AddTheme")]
public ActionResult AddThemePOST(string returnUrl) { public ActionResult AddThemePOST(string returnUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add themes")))
return new HttpUnauthorizedResult();
return InstallPackage(returnUrl, Request.RawUrl); return InstallPackage(returnUrl, Request.RawUrl);
} }
[HttpPost, ActionName("RemoveTheme")] [HttpPost, ActionName("RemoveTheme")]
public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl) { public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to remove themes")))
return new HttpUnauthorizedResult();
return UninstallPackage(PackagingSourceManager.ThemesPrefix + themeId, returnUrl, retryUrl); return UninstallPackage(PackagingSourceManager.ThemesPrefix + themeId, returnUrl, retryUrl);
} }
public ActionResult AddModule(string returnUrl) { public ActionResult AddModule(string returnUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add modules")))
return new HttpUnauthorizedResult();
return View(); return View();
} }
[HttpPost, ActionName("AddModule")] [HttpPost, ActionName("AddModule")]
public ActionResult AddModulePOST(string returnUrl) { public ActionResult AddModulePOST(string returnUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add modules")))
return new HttpUnauthorizedResult();
return InstallPackage(returnUrl, Request.RawUrl); return InstallPackage(returnUrl, Request.RawUrl);
} }
public ActionResult InstallPackage(string returnUrl, string retryUrl) { public ActionResult InstallPackage(string returnUrl, string retryUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
return new HttpUnauthorizedResult();
try { try {
if (Request.Files != null && if (Request.Files != null &&
Request.Files.Count > 0 && Request.Files.Count > 0 &&
@@ -90,6 +111,9 @@ namespace Orchard.Packaging.Controllers {
} }
public ActionResult UninstallPackage(string id, string returnUrl, string retryUrl) { public ActionResult UninstallPackage(string id, string returnUrl, string retryUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to uninstall packages")))
return new HttpUnauthorizedResult();
try { try {
_packageManager.Uninstall(id, HostingEnvironment.MapPath("~/")); _packageManager.Uninstall(id, HostingEnvironment.MapPath("~/"));
@@ -18,7 +18,7 @@ namespace Orchard.Data.Providers {
public override IPersistenceConfigurer GetPersistenceConfigurer(bool createDatabase) { public override IPersistenceConfigurer GetPersistenceConfigurer(bool createDatabase) {
var persistence = MsSqlConfiguration.MsSql2008; var persistence = MsSqlConfiguration.MsSql2008;
if (string.IsNullOrEmpty(_connectionString)) { if (string.IsNullOrEmpty(_connectionString)) {
throw new NotImplementedException(); throw new ArgumentException("The connection string is empty");
} }
persistence = persistence.ConnectionString(_connectionString); persistence = persistence.ConnectionString(_connectionString);
return persistence; return persistence;