Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IIS Version of WebService; fixes #248 #249

Merged
merged 6 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CDP4-Server.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CDP4WspDatabaseAuthenticati
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CDP4WspDatabaseAuthentication.Tests", "CDP4WspDatabaseAuthentication.Tests\CDP4WspDatabaseAuthentication.Tests.csproj", "{D95B61F1-4F95-4F7F-8C95-7B809A83FDEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CDP4WebServer.IIS", "CDP4WebServer.IIS\CDP4WebServer.IIS.csproj", "{CC208C1D-99CB-490F-993A-1015FA675A47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -93,6 +95,12 @@ Global
{D95B61F1-4F95-4F7F-8C95-7B809A83FDEF}.Release|Any CPU.Build.0 = Release|Any CPU
{D95B61F1-4F95-4F7F-8C95-7B809A83FDEF}.Test|Any CPU.ActiveCfg = Test|Any CPU
{D95B61F1-4F95-4F7F-8C95-7B809A83FDEF}.Test|Any CPU.Build.0 = Test|Any CPU
{CC208C1D-99CB-490F-993A-1015FA675A47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC208C1D-99CB-490F-993A-1015FA675A47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC208C1D-99CB-490F-993A-1015FA675A47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC208C1D-99CB-490F-993A-1015FA675A47}.Release|Any CPU.Build.0 = Release|Any CPU
{CC208C1D-99CB-490F-993A-1015FA675A47}.Test|Any CPU.ActiveCfg = Test|Any CPU
{CC208C1D-99CB-490F-993A-1015FA675A47}.Test|Any CPU.Build.0 = Test|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
255 changes: 255 additions & 0 deletions CDP4WebServer.IIS/CDP4WebServer.IIS.csproj

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions CDP4WebServer.IIS/CDP4WebServer.IIS.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=files/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
33 changes: 33 additions & 0 deletions CDP4WebServer.IIS/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2021 RHEA System S.A.
//
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski
//
// This file is part of COMET Web Services Community Edition.
// The COMET Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The COMET Web Services Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The COMET Web Services Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTrademark("CDP")]
lxatstariongroup marked this conversation as resolved.
Show resolved Hide resolved

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
61 changes: 61 additions & 0 deletions CDP4WebServer.IIS/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\app.publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>True</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="$(MSBuildProjectDirectory)\bin\Authentication\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\Authentication\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>

<Target Name="CustomCollectFiles2">
<ItemGroup>
<_CustomFiles2 Include="$(MSBuildProjectDirectory)\bin\config.json" />
<FilesForPackagingFromProject Include="%(_CustomFiles2.Identity)">
<DestinationRelativePath>bin\config.json.new</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>

<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>

<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>

<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles2;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>

<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles2;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>

</PropertyGroup>
</Project>
53 changes: 53 additions & 0 deletions CDP4WebServer.IIS/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2021 RHEA System S.A.
//
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski
//
// This file is part of COMET Web Services Community Edition.
// The COMET Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The COMET Web Services Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The COMET Web Services Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace CDP4WebServer.IIS
{
using CDP4WebServices.API.Configuration;

using Microsoft.Owin.Extensions;

using Owin;

/// <summary>
/// Provides the entry point for the ASP.NET application
/// </summary>
public class Startup
{
/// <summary>
/// Specifies how the ASP.NET application will respond to individual HTTP requests.
/// </summary>
/// <param name="app">
/// Application pipeline
/// </param>
public void Configuration(IAppBuilder app)
{
// load application configuration from file
AppConfig.Load();

app.UseNancy();
app.UseStageMarker(PipelineStage.MapHandler);
}
}
}
68 changes: 68 additions & 0 deletions CDP4WebServer.IIS/Web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
lxatstariongroup marked this conversation as resolved.
Show resolved Hide resolved
<configuration>
<appSettings>
<!-- OWIN is used, so all calls should be handled by OWIN -->
<add key="owin:HandleAllRequests" value="true"/>
<add key="owin:appStartup" value="CDP4WebServer.IIS.Startup, CDP4WebServer.IIS" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<!-- E-CSS-TM-10-25 defines wildcard URL's that contain an asterisk (*) -->
<httpRuntime maxUrlLength="16384" maxQueryStringLength="16384" requestPathInvalidCharacters="&lt;,&gt;,%,&amp;,:,\,?" />
</system.web>
<system.webServer>
<!-- Without this additional configuration, the StaticFileModule from OWIN would intercept the request and return a 404. -->
<modules runAllManagedModulesForAllRequests="true" />
<security>
<requestFiltering>
<!-- Since files to be uploaded could be quite large, we allow the maximum allowed content length-->
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
<!-- Specific handler for PUT, HEAD or DELETE requests-->
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
35 changes: 35 additions & 0 deletions CDP4WebServer.IIS/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="3.5.2" targetFramework="net472" />
<package id="CDP4Common-CE" version="8.1.0" targetFramework="net472" />
<package id="CDP4JsonSerializer-CE" version="8.1.0" targetFramework="net472" />
<package id="DotNetZip" version="1.14.0" targetFramework="net472" />
<package id="Hangfire" version="1.7.19" targetFramework="net472" />
<package id="Hangfire.Autofac" version="2.3.1" targetFramework="net472" />
<package id="Hangfire.Core" version="1.7.19" targetFramework="net472" />
<package id="Hangfire.MemoryStorage" version="1.7.0" targetFramework="net472" />
<package id="Hangfire.SqlServer" version="1.7.19" targetFramework="net472" />
<package id="MailKit" version="2.8.0" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0" targetFramework="net472" />
<package id="Microsoft.Owin" version="4.2.0" targetFramework="net472" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.2.0" targetFramework="net472" />
<package id="MimeKit" version="2.9.1" targetFramework="net472" />
<package id="Nancy" version="1.4.5" targetFramework="net472" />
<package id="Nancy.Bootstrappers.Autofac" version="1.4.1" targetFramework="net472" />
<package id="Nancy.Owin" version="1.4.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="NLog" version="4.7.10" targetFramework="net472" />
<package id="Npgsql" version="4.1.3.1" targetFramework="net472" />
<package id="Owin" version="1.0" targetFramework="net472" />
<package id="Portable.BouncyCastle" version="1.8.5" targetFramework="net472" />
<package id="System.Buffers" version="4.5.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.3" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Resources.Extensions" version="4.6.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.6.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="4.6.0" targetFramework="net472" />
<package id="System.Text.Json" version="4.6.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
<package id="System.Xml.XmlSerializer" version="4.3.0" targetFramework="net472" />
</packages>
2 changes: 1 addition & 1 deletion CDP4WebServer/CDP4WebServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<OutputType>Exe</OutputType>
<Company>RHEA System S.A.</Company>
<Title>CDP4WebServer-CE</Title>
<Version>7.0.3</Version>
<Version>7.0.4</Version>
<Description>CDP4 Services Host</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander</Authors>
Expand Down
9 changes: 9 additions & 0 deletions CDP4WebServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ public static int Main(string[] args)
}
catch (Exception ex)
{
if (ex.InnerException != null)
{
Logger.Error(ex.InnerException);
}
else
{
Logger.Error(ex);
}

// global catch all
Logger.Fatal(ex, "The CDP4 Services encountered an unrecoverable error");
return 42;
Expand Down
18 changes: 15 additions & 3 deletions CDP4WebServices.API/CDP4WebServices.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework>
<Company>RHEA System S.A.</Company>
<Title>CDP4WebServices-CE.API</Title>
<Version>7.0.3</Version>
<Version>7.0.4</Version>
<Description>Library that contains the CDP4 Services API</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander</Authors>
Expand All @@ -20,7 +20,10 @@
</ItemGroup>

<ItemGroup>
<None Remove="Resources\cdplogo_48x48.ico" />
<None Remove="Resources\COMET-Community-Edition.png" />
<None Remove="Resources\comet.ico" />
<None Remove="Resources\rhealogo.png" />
<None Remove="Resources\RootPage.html" />
</ItemGroup>

<ItemGroup>
Expand All @@ -47,9 +50,18 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\cdplogo_48x48.ico">
<EmbeddedResource Include="Resources\COMET-Community-Edition.png">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Resources\comet.ico">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Resources\rhealogo.png">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Resources\RootPage.html">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion CDP4WebServices.API/Cdp4Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private static byte[] LoadFavoriteIcon()
{
using (var ms = new MemoryStream())
{
Properties.Resources.cdplogo_48x48.Save(ms);
Properties.Resources.comet.Save(ms);
return ms.ToArray();
}
}
Expand Down
6 changes: 3 additions & 3 deletions CDP4WebServices.API/Configuration/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ private static void ValidateConfiguration(AppConfig appConfig)
/// </returns>
private static string ReadConfigFile(string configPath)
{
var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), configPath);

var path = Path.Combine(AppDomain.CurrentDomain.RelativeSearchPath ?? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), configPath);
lxatstariongroup marked this conversation as resolved.
Show resolved Hide resolved
if (!File.Exists(path))
{
throw new FileNotFoundException("Configuration file not found.", Configpath);
throw new FileNotFoundException($"Configuration file not found ({path}).", Configpath);
}

var json = File.ReadAllText(path);
Expand Down
2 changes: 1 addition & 1 deletion CDP4WebServices.API/Modules/10-25/ApiBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ protected string GenerateRandomToken()
// use the file hash value to easily identify the multipart content for each respective filerevision hash entry
binaryContent.Headers.Add(
ContentDispositionHeader,
$"attachment; filename={folderPath + ".zip"}");
$"attachment; filename={new DirectoryInfo(folderPath).Name + ".zip"}");

binaryContent.Headers.Add(ContentLengthHeader, fileSize.ToString());
content.Add(binaryContent);
Expand Down
Loading