Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:kevinobee/Sitecore.Ship
Browse files Browse the repository at this point in the history
# By Kevin Obee (19) and others
# Via Kevin Obee (6) and The Gitter Badger (1)
* 'develop' of github.com:kevinobee/Sitecore.Ship: (22 commits)
  Add Gitter badge
  Transferring blueprint from apiary.io
  Minor text changes to the  Apiary.Io content
  Initial defintition of the service root
  kevinobee#45 initial load
  Minor change to ItemsToPublish to make it safe to use by default
  kevinobee#47 fix for Activator.CreateInstance for Sitecore.Ship against Sitecore 8.0 rev. 141212
  Fix minor build configuration issues
  Tried to undo weird formatting that carried across from work StyleCop settings
  Issue kevinobee#44 - Smoke test added for specific example from kevinobee#44
  kevinobee#46 Fixed InvokePublishingCommand return values
  kevinobee#46 Fixes added to ensure InvokePublishingCommand handles the publish/listofitems JSON POST body robustly
  kevinobee#46 Add failing smoke test
  kevinobee#48 Remove support for IIS classic mode from wec.config.transform files
  Added guidance to README to ensure that existing web.config files are included in the target .csproj
  Add call to PublishService with List of Items
  Transferring blueprint from apiary.io
  kevinobee#26 Treat compiler warnings as errors applied to all src projects
  Minor changes to README to not update to NET 4.5 and the removal of Classic mode support in IIS
  Projects now built against NET 4.5. Platform assemblies tested from Sitecore 8.0 rev. 141212 (8.0 RTM).
  ...
  • Loading branch information
jimmah committed Sep 22, 2015
2 parents a4eb969 + ca51947 commit 2672da3
Show file tree
Hide file tree
Showing 22 changed files with 263 additions and 170 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Sitecore.Ship

[![Join the chat at https://gitter.im/kevinobee/Sitecore.Ship](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kevinobee/Sitecore.Ship?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Sitecore.Ship is a lightweight means to install Sitecore Update packages via HTTP requests.


Expand All @@ -21,7 +23,9 @@ The latest release versions of the Sitecore.Ship packages can be found on the Nu

### Installing the Package

Ensure that the website project is set to run with .NET Framework 4.0
Ensure that the website project is set to run with .NET Framework 4.5

Ensure that the web.config file for the target project if already existing is included into your project.

Run the following powershell command in the package manager console of the Visual Studio solution for the target website:

Expand All @@ -33,7 +37,7 @@ Installing the package will do the following:

* Add a new `packageInstallation` section to your `web.config` file. You can set configuration options in this section to enable remote access to the installer and to enable the package streaming functionality. These options are safe by default, that is, no remote access and package streaming disabled. **Note:** the configuration settings are ignored in this branch of Sitecore.Ship.

* Register a single new HTTP handler section in `<system.web>` and `<system.webserver>`
* Register a single new HTTP handler section in `<system.webserver>`. Support for classic mode in IIS has been removed.

* Add a `ship.config` Sitecore include file to the `App_Config\include` folder.

Expand Down Expand Up @@ -79,7 +83,7 @@ The body of a successfull request will contain details of the package contents i
{"Entries":[{"ID":"110d559f-dea5-42ea-9c1c-8a5df7e70ef9","Path":"addeditems/master/sitecore/content/home"}]}

The request also takes an optional `DisableIndexing` parameter in the x-www-form-urlencoded form-data which defaults to *false*. When the parameter is set to *true* updating of search indexes during the package installation will be suspended. Disabling the search index updates will increase the speed at which packages are installed into the CMS. You can read more about this approach on Alex Shyba's
[blog](http://sitecoreblog.alexshyba.com/2010/04/sitecore-installation-wizard-disable.html "Sitecore Installation Wizard disable search index update during install")
[blog](http://sitecoreblog.alexshyba.com/2010/04/sitecore-installation-wizard-disable.html "Sitecore Installation Wizard disable search index update during install")



Expand Down
2 changes: 2 additions & 0 deletions Sitecore.Ship.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F0717179-F14B-4667-8D5A-5980EC935F0F}"
EndProject
Expand Down Expand Up @@ -41,6 +42,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "packaging", "packaging", "{
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{D11D4F10-B2C8-4E1C-BF78-B192D303D20D}"
ProjectSection(SolutionItems) = preProject
apiary.apib = apiary.apib
docs\Assembly Linkage.dgml = docs\Assembly Linkage.dgml
README.md = README.md
EndProjectSection
Expand Down
18 changes: 18 additions & 0 deletions apiary.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FORMAT: 1A
HOST: http://docs.sitecoreship.apiary.io/

# Sitecore.Ship

The package offers a simple API to help consumers install their packages into Sitecore over an internet connection.

## Sitecore.Ship API Root [/services]

Returns information on the currently installed Sitecore.Ship.

### Retrieve information on the installed Sitecore.Ship [GET]

+ Response 200 (application/json)

{
"sitecore.ship.version": "0.4.0"
}
8 changes: 6 additions & 2 deletions build/Build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<LibFiles Include="Sitecore.Zip.dll" />
</ItemGroup>

<Target Name="RunSmokeTests" DependsOnTargets="Build">
<Target Name="RunSmokeTests" >
<PropertyGroup>
<SitecoreShipPackagePath>$(ProjectRoot)\build\sitecore packages\SitecoreShip.zip</SitecoreShipPackagePath>
<TestPackagePath>$(ProjectRoot)\tests\acceptance-test\01-package.update</TestPackagePath>
Expand Down Expand Up @@ -68,7 +68,11 @@

<!-- Show the last completed publish time (after publishing) specifying source/target/language parameters -->
<Exec Command="$(CurlExePath) -i $(TestWebsiteUrl)services/publish/lastcompleted/master/web/en" />


<Exec Command="$(CurlExePath) -i -X POST $(TestWebsiteUrl)services/publish/listofitems --header &quot;Content-Type: application/x-www-form-urlencoded&quot; --header &quot;Content-Length: 0&quot; -H &quot;Accept:application/json&quot;" />

<!-- Issue #44 - 404, when trying to publish a list of items github.com/kevinobee/Sitecore.Ship/issues/44 -->
<Exec Command="$(CurlExePath) -i -H &quot;Content-Type: application/json&quot; -X POST -d &quot;{\&quot;Items\&quot;:[{\&quot;itemId\&quot;:\&quot;662a3670-2671-414c-97e5-f9b30473cdd7\&quot;,\&quot;PublishChildren\&quot;:\&quot;false\&quot;},{\&quot;itemId\&quot;:\&quot;a49599a5-1b25-4efe-82aa-fa1af0993919\&quot;,\&quot;PublishChildren\&quot;:\&quot;false\&quot;},{\&quot;itemId\&quot;:\&quot;377cb37e-2b00-417e-bbec-872b4ef9e9a0\&quot;,\&quot;PublishChildren\&quot;:\&quot;false\&quot;},{\&quot;itemId\&quot;:\&quot;9502a1e1-7bdd-4b3e-a234-a488ba871889\&quot;,\&quot;PublishChildren\&quot;:\&quot;false\&quot;}],\&quot;TargetDatabases\&quot;:[\&quot;web\&quot;],\&quot;TargetLanguages\&quot;:[\&quot;en\&quot;]}&quot; http://ship/services/publish/listofitems" />
</Target>

</Project>
2 changes: 1 addition & 1 deletion build/build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@
<Target Name="Go" DependsOnTargets="RunCodeAnalysis; Build; RunTests; StdPackage">
</Target>

<Target Name="GoCI" DependsOnTargets="UpdateVersion; Build">
<Target Name="GoCI" DependsOnTargets="UpdateVersion; RunCodeAnalysis; Build; RunTests; StdPackage">
</Target>
</Project>
4 changes: 3 additions & 1 deletion lib/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ The following files need to be placed in the folder:
* Sitecore.Update.dll
* Sitecore.Zip.dll

These files should be from a 6.x solution, NOT Sitecore 7
These files should be from a 8.x solution.

Current testing based on Sitecore 8.0 rev. 141212 (8.0 RTM).
158 changes: 95 additions & 63 deletions src/Sitecore.Ship.AspNet/Publish/InvokePublishingCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
Expand All @@ -10,67 +11,98 @@

namespace Sitecore.Ship.AspNet.Publish
{
public class InvokePublishingCommand : CommandHandler
{
private readonly IPublishService _publishService;

public InvokePublishingCommand(IPublishService publishService)
{
_publishService = publishService;
}

public InvokePublishingCommand() : this(new PublishService())
{
}

public override void HandleRequest(HttpContextBase context)
{
if (CanHandle(context))
{
var publishParameters = GetRequest(context.Request);

var now = DateTime.Now;
var date = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

_publishService.Run(publishParameters);

var json = Json.Encode(new { date });

JsonResponse(json, HttpStatusCode.Accepted, context);
}
else if (Successor != null)
{
Successor.HandleRequest(context);
}
}

private static bool CanHandle(HttpContextBase context)
{
return context.Request.Url != null &&
IsPublishModeUrl(context.Request.Url.PathAndQuery.ToLowerInvariant()) &&
context.Request.HttpMethod == "POST";
}

private static bool IsPublishModeUrl(string urlPath)
{
return urlPath.EndsWith("/services/publish/full") ||
urlPath.EndsWith("/services/publish/smart") ||
urlPath.EndsWith("/services/publish/incremental");
}

private static PublishParameters GetRequest(HttpRequestBase request)
{
if (request.Url == null) throw new InvalidOperationException("Missing Url");

var publishRequest = new PublishParameters
{
Mode = request.Url.PathAndQuery.Split(new[] {'/'}).Last(),
Source = request.Form["source"] ?? "master",
Targets = request.Form["targets"].CsvStringToStringArray(new[] { "web" }),
Languages = request.Form["languages"].CsvStringToStringArray(new[] { "en" })
};

return publishRequest;
}
}
public class InvokePublishingCommand : CommandHandler
{
private readonly IPublishService _publishService;

public InvokePublishingCommand(IPublishService publishService)
{
_publishService = publishService;
}

public InvokePublishingCommand() : this(new PublishService())
{
}

public override void HandleRequest(HttpContextBase context)
{
if (CanHandle(context))
{
var publishParameters = GetRequest(context.Request);

var now = DateTime.Now;
var date = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

if (publishParameters.Mode.ToLowerInvariant() == "listofitems")
{
using (var reader = new StreamReader(context.Request.InputStream))
{
var values = reader.ReadToEnd();

if (string.IsNullOrEmpty(values))
{
JsonResponse(string.Empty, HttpStatusCode.NoContent, context);
}
else
{
var itemsToPublish = Json.Decode<ItemsToPublish>(values);

if (itemsToPublish == null)
{
JsonResponse(string.Empty, HttpStatusCode.BadRequest, context);
}
else
{
_publishService.Run(itemsToPublish);
var json = Json.Encode(new { date });

JsonResponse(json, HttpStatusCode.Accepted, context);
}
}
}
}
else
{
_publishService.Run(publishParameters);
var json = Json.Encode(new { date });

JsonResponse(json, HttpStatusCode.Accepted, context);
}
}
else if (Successor != null)
{
Successor.HandleRequest(context);
}
}

private static bool CanHandle(HttpContextBase context)
{
return context.Request.Url != null &&
IsPublishModeUrl(context.Request.Url.PathAndQuery.ToLowerInvariant()) &&
context.Request.HttpMethod == "POST";
}

private static bool IsPublishModeUrl(string urlPath)
{
return urlPath.EndsWith("/services/publish/full") ||
urlPath.EndsWith("/services/publish/smart") ||
urlPath.EndsWith("/services/publish/incremental") ||
urlPath.EndsWith("/services/publish/listofitems");
}

private static PublishParameters GetRequest(HttpRequestBase request)
{
if (request.Url == null) throw new InvalidOperationException("Missing Url");

var publishRequest = new PublishParameters
{
Mode = request.Url.PathAndQuery.Split(new[] {'/'}).Last(),
Source = request.Form["source"] ?? "master",
Targets = request.Form["targets"].CsvStringToStringArray(new[] { "web" }),
Languages = request.Form["languages"].CsvStringToStringArray(new[] { "en" })
};

return publishRequest;
}
}
}
1 change: 1 addition & 0 deletions src/Sitecore.Ship.AspNet/Sitecore.Ship.AspNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
6 changes: 3 additions & 3 deletions src/Sitecore.Ship.AspNet/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
5 changes: 0 additions & 5 deletions src/Sitecore.Ship.AspNet/content/web.config.transform
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
<section name="packageInstallation" type="Sitecore.Ship.Infrastructure.Configuration.PackageInstallationConfiguration, Sitecore.Ship.Infrastructure"/>
</configSections>
<packageInstallation enabled="true" allowRemote="false" allowPackageStreaming="false" recordInstallationHistory="false" />
<system.web>
<httpHandlers>
<add verb="*" type="Sitecore.Ship.AspNet.SitecoreShipHttpHandler, Sitecore.Ship.AspNet" path="/services/*" />
</httpHandlers>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false"/>
Expand Down
5 changes: 5 additions & 0 deletions src/Sitecore.Ship.Core/Domain/InstallPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ public class InstallPackage
public string Path { get; set; }

public bool DisableIndexing { get; set; }

/// <summary>
/// Set to true to disable reporting of items contained in the package.
/// </summary>
public bool DisableManifest { get; set; }
}
}
5 changes: 5 additions & 0 deletions src/Sitecore.Ship.Core/Domain/InstallUploadPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ public class InstallUploadPackage
public string PackageId { get; set; }
public string Description { get; set; }
public bool DisableIndexing { get; set; }

/// <summary>
/// Set to true to disable reporting of items contained in the package.
/// </summary>
public bool DisableManifest { get; set; }
}
}
21 changes: 14 additions & 7 deletions src/Sitecore.Ship.Core/Domain/ItemsToPublish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@

namespace Sitecore.Ship.Core.Domain
{
public class ItemsToPublish
{
public List<Guid> Items { get; set; }
public string[] TargetDatabases { get; set; }
public string[] TargetLanguages { get; set; }
}
}
public class ItemsToPublish
{
public List<Guid> Items { get; set; }
public string[] TargetDatabases { get; set; }
public string[] TargetLanguages { get; set; }

public ItemsToPublish()
{
Items = new List<Guid>();
TargetDatabases = new string[] { };
TargetLanguages = new string[] { };
}
}
}
1 change: 1 addition & 0 deletions src/Sitecore.Ship.Core/Sitecore.Ship.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
Loading

0 comments on commit 2672da3

Please sign in to comment.