Skip to content
Browse files

Finished configuration refactoring and added support for OpenWrap pac…

…kages.
  • Loading branch information...
1 parent 046f7ba commit d33a08afe28b459b8a386040d143203c05269605 @TripleEmcoder TripleEmcoder committed Mar 15, 2012
Showing with 199 additions and 126 deletions.
  1. +2 −10 Sources/SymbolSource.Gateway.Core/{ConfigurationWrapper.cs → AppSettingsConfiguration.cs}
  2. +10 −0 Sources/SymbolSource.Gateway.Core/AppSettingsConfigurationFactory.cs
  3. +40 −38 Sources/SymbolSource.Gateway.Core/GatewayManager.cs
  4. +15 −0 Sources/SymbolSource.Gateway.Core/IGatewayConfiguration.cs
  5. +2 −1 Sources/SymbolSource.Gateway.Core/IGatewayManager.cs
  6. +1 −1 Sources/SymbolSource.Gateway.Core/IPackageBackend.cs
  7. +3 −1 Sources/SymbolSource.Gateway.Core/SymbolSource.Gateway.Core.csproj
  8. +7 −7 Sources/SymbolSource.Gateway.NuGet.Core/DownloadController.cs
  9. +2 −11 Sources/SymbolSource.Gateway.NuGet.Core/NuGetGatewayManager.cs
  10. +1 −1 Sources/SymbolSource.Gateway.NuGet.Core/Upload15Controller.cs
  11. +1 −1 Sources/SymbolSource.Gateway.NuGet.Core/Upload16Controller.cs
  12. +6 −21 Sources/SymbolSource.Gateway.OpenWrap.Core/OpenWrapGatewayManager.cs
  13. +5 −5 Sources/SymbolSource.Gateway.OpenWrap.Core/WrapController.cs
  14. +2 −2 Sources/SymbolSource.Gateway.WinDbg.Core/AttributeRouting.cs
  15. +1 −1 Sources/SymbolSource.Gateway.WinDbg.Core/BinController.cs
  16. +1 −1 Sources/SymbolSource.Gateway.WinDbg.Core/PdbController.cs
  17. +5 −1 Sources/SymbolSource.Processing.Basic/Projects/SourceDiscover.cs
  18. +4 −0 Sources/SymbolSource.Server.Basic.Host/Web.config
  19. +11 −2 Sources/SymbolSource.Server.Basic.Host/Web.config.transform
  20. +1 −1 Sources/SymbolSource.Server.Basic/BasicBackend.Download.cs
  21. +32 −6 Sources/SymbolSource.Server.Basic/BasicBackend.Metadata.cs
  22. +31 −14 Sources/SymbolSource.Server.Basic/BasicBackend.Upload.cs
  23. +5 −0 Sources/SymbolSource.Server.Basic/MicroKernel.cs
  24. +3 −0 Sources/SymbolSource.Server.Basic/SymbolSource.Server.Basic.csproj
  25. +1 −0 Sources/SymbolSource.Server.Basic/packages.config
  26. +6 −1 SymbolSource.Community.sln
  27. +1 −0 SymbolSource.Server.Basic.nuspec
View
12 ...urce.Gateway.Core/ConfigurationWrapper.cs → ....Gateway.Core/AppSettingsConfiguration.cs
@@ -2,19 +2,11 @@
namespace SymbolSource.Gateway.Core
{
- public interface IGatewayConfiguration
- {
- string GatewayLogin { get; }
- string GatewayPassword { get; }
- string PublicLogin { get; }
- string PublicPassword { get; }
- }
-
- public class ConfigurationWrapper : IGatewayConfiguration
+ public class AppSettingsConfiguration : IGatewayConfiguration
{
private readonly string company;
- public ConfigurationWrapper(string company)
+ public AppSettingsConfiguration(string company)
{
this.company = company;
}
View
10 Sources/SymbolSource.Gateway.Core/AppSettingsConfigurationFactory.cs
@@ -0,0 +1,10 @@
+namespace SymbolSource.Gateway.Core
+{
+ public class AppSettingsConfigurationFactory : IGatewayConfigurationFactory
+ {
+ public IGatewayConfiguration Create(string company)
+ {
+ return new AppSettingsConfiguration(company);
+ }
+ }
+}
View
78 Sources/SymbolSource.Gateway.Core/GatewayManager.cs
@@ -12,35 +12,38 @@ namespace SymbolSource.Gateway.Core
{
public abstract class GatewayManager : IGatewayManager
{
- protected readonly IGatewayBackendFactory<IPackageBackend> factory;
- private readonly IGatewayConfiguration configuration;
+ protected readonly IGatewayBackendFactory<IPackageBackend> backendFactory;
+ private readonly IGatewayConfigurationFactory configurationFactory;
- protected GatewayManager(IGatewayBackendFactory<IPackageBackend> factory, IGatewayConfiguration configuration)
+ protected GatewayManager(IGatewayBackendFactory<IPackageBackend> backendFactory, IGatewayConfigurationFactory configurationFactory)
{
- this.factory = factory;
- this.configuration = configuration;
+ this.backendFactory = backendFactory;
+ this.configurationFactory = configurationFactory;
}
- public bool Authorize(string company, string repository)
+ public bool AuthenticateDownload(string company, string repository)
{
- return company != "Public" || repository.StartsWith("Private.");
+ return company != "Basic" && (company != "Public" || repository.StartsWith("Private."));
+ }
+
+ public bool AuthenticateUpload(string company, string repository)
+ {
+ return company != "Basic";
}
public string Download(Caller caller, string company, string repository, string projectName, string versionName, string contentType)
{
var container = new Version { Company = company, Repository = repository, Project = projectName, Name = versionName };
- using (var session = factory.Create(caller))
+ using (var session = backendFactory.Create(caller))
return session.GetPackageLink(ref container, contentType);
}
public Version[] Index(Caller caller, string company, string repository)
{
- PrepareProject(caller, company, repository, null);
-
var parent = new Repository { Company = company, Name = repository };
- using (var session = factory.Create(caller))
+ using (var session = backendFactory.Create(caller))
{
return session.GetPackages(ref parent, GetPackageFormat());
}
@@ -113,7 +116,7 @@ protected void SavePackage(Stream inputStream, string path)
protected abstract string GetFilePath(string path);
- protected abstract void GetMetadata(string path, string repository, out PackageProject project, out IList<MetadataEntry> metadata, out ILookup<ContentType, string> contents);
+ protected abstract void GetMetadata(string path, string repository, out PackageProject project, out IList<MetadataEntry> metadata, out ILookup<ContentType, string> contents);
protected abstract bool? GetProjectPermission(Caller caller, string companyName, string repositoryName, string projectName);
@@ -152,52 +155,51 @@ private void RemoveFiles(ZipFile zip, IEnumerable<string> paths)
zip.RemoveEntry(path);
}
- private void PerformUpload(Caller caller, PackageProject packageProject, Version version, string path)
+ private void PerformUpload(Caller caller, PackageProject packageProject, string path)
{
- PushPackage(caller, version, path, packageProject);
-
+ var packagePath = GetFilePath(path);
var symbolPackagePath = GetSymbolPackagePath(path);
- if (File.Exists(symbolPackagePath))
- using (var session = factory.Create(caller))
- session.CreateJob(File.ReadAllBytes(symbolPackagePath), packageProject);
- }
+ var package = File.Exists(packagePath) ? File.ReadAllBytes(packagePath) : null;
+ var symbolPackage = File.Exists(symbolPackagePath) ? File.ReadAllBytes(symbolPackagePath) : null;
- protected abstract void PushPackage(Caller caller, Version version, string path, PackageProject metadata);
+ using (var session = backendFactory.Create(caller))
+ session.UploadPackage(packageProject, GetPackageFormat(), package, symbolPackage);
+ }
public void Hide(Caller caller, string company, string repository, string projectName, string versionName)
{
- using (var session = factory.Create(caller))
+ using (var session = backendFactory.Create(caller))
{
- var project = new Project { Company = company, Repository = repository, Name = projectName };
- var versions = session.GetVersions(ref project);
- var version = versions.SingleOrDefault(v => v.Name == versionName);
+ //var project = new Project { Company = company, Repository = repository, Name = projectName };
+ //var versions = session.GetVersions(ref project);
+ //var version = versions.SingleOrDefault(v => v.Name == versionName);
- if (version == null)
- throw new ClientException("Specified version does not exist.", null);
+ //if (version == null)
+ // throw new ClientException("Specified version does not exist.", null);
- //if (version.Hidden == true)
- // throw new ClientException("Version is already hidden.", null);
+ ////if (version.Hidden == true)
+ //// throw new ClientException("Version is already hidden.", null);
- session.SetVersionHidden(ref version, true);
+ //session.SetVersionHidden(ref version, true);
}
}
public void Restore(Caller caller, string company, string repository, string projectName, string versionName)
{
- using (var session = factory.Create(caller))
+ using (var session = backendFactory.Create(caller))
{
- var project = new Project { Company = company, Repository = repository, Name = projectName };
- var versions = session.GetVersions(ref project);
- var version = versions.SingleOrDefault(v => v.Name == versionName);
+ //var project = new Project { Company = company, Repository = repository, Name = projectName };
+ //var versions = session.GetVersions(ref project);
+ //var version = versions.SingleOrDefault(v => v.Name == versionName);
- if (version == null)
- throw new ClientException("Specified version does not exist.", null);
+ //if (version == null)
+ // throw new ClientException("Specified version does not exist.", null);
- //if (version.Hidden == false)
- // throw new ClientException("Version is not hidden.", null);
+ ////if (version.Hidden == false)
+ //// throw new ClientException("Version is not hidden.", null);
- session.SetVersionHidden(ref version, false);
+ //session.SetVersionHidden(ref version, false);
}
}
}
View
15 Sources/SymbolSource.Gateway.Core/IGatewayConfiguration.cs
@@ -0,0 +1,15 @@
+namespace SymbolSource.Gateway.Core
+{
+ public interface IGatewayConfiguration
+ {
+ string GatewayLogin { get; }
+ string GatewayPassword { get; }
+ string PublicLogin { get; }
+ string PublicPassword { get; }
+ }
+
+ public interface IGatewayConfigurationFactory
+ {
+ IGatewayConfiguration Create(string company);
+ }
+}
View
3 Sources/SymbolSource.Gateway.Core/IGatewayManager.cs
@@ -5,7 +5,8 @@ namespace SymbolSource.Gateway.Core
{
public interface IGatewayManager
{
- bool Authorize(string company, string repository);
+ bool AuthenticateDownload(string company, string repository);
+ bool AuthenticateUpload(string company, string repository);
Version[] Index(Caller caller, string company, string repository);
void Upload(Caller caller, Stream stream, string company, string repository);
string Download(Caller caller, string company, string repository, string projectName, string versionName, string contentType);
View
2 Sources/SymbolSource.Gateway.Core/IPackageBackend.cs
@@ -7,7 +7,7 @@ public interface IPackageBackend : IGatewayBackend
Caller CreateUserByKey(string company, string type, string value);
string GetPackageLink(ref Version version, string contentType);
Version[] GetPackages(ref Repository repository, string packageFormat);
- Version UploadPackage(PackageProject package, byte[] packageData, byte[] symbolPackageData);
+ Version UploadPackage(PackageProject package, string packageFormat, byte[] packageData, byte[] symbolPackageData);
void SetVersionHidden(ref Version version, bool hidden);
}
}
View
4 Sources/SymbolSource.Gateway.Core/SymbolSource.Gateway.Core.csproj
@@ -46,17 +46,19 @@
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="AppSettingsConfigurationFactory.cs" />
<Compile Include="ClientException.cs" />
<Compile Include="GatewayBackendFactoryExtensions.cs" />
<Compile Include="GatewayManager.cs" />
<Compile Include="ContentType.cs" />
<Compile Include="GatewayException.cs" />
<Compile Include="IGatewayBackend.cs" />
+ <Compile Include="IGatewayConfiguration.cs" />
<Compile Include="IGatewayManager.cs" />
<Compile Include="IGatewayBackendFactory.cs" />
<Compile Include="IPackageBackend.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="ConfigurationWrapper.cs" />
+ <Compile Include="AppSettingsConfiguration.cs" />
<Compile Include="ServerException.cs" />
</ItemGroup>
<ItemGroup>
View
14 Sources/SymbolSource.Gateway.NuGet.Core/DownloadController.cs
@@ -95,7 +95,7 @@ private string GetPackageLink(string company, string login, string key, string r
#endregion
- private Caller Authorize(string company, string login, string key, bool require)
+ private Caller Authenticate(string company, string login, string key, bool require)
{
if (!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(key))
{
@@ -121,7 +121,7 @@ private Caller Authorize(string company, string login, string key, bool require)
if (!require)
{
- var configuration = new ConfigurationWrapper(company);
+ var configuration = new AppSettingsConfiguration(company);
return new Caller
{
@@ -140,7 +140,7 @@ private Caller Authorize(string company, string login, string key, bool require)
[DataService]
public ActionResult Index(string company, string login, string key, string repository)
{
- var caller = Authorize(company, login, key, manager.Authorize(company, repository));
+ var caller = Authenticate(company, login, key, manager.AuthenticateDownload(company, repository));
if (caller == null)
return null;
@@ -161,7 +161,7 @@ public ActionResult Index(string company, string login, string key, string repos
[DataService]
public ActionResult Metadata(string company, string login, string key, string repository)
{
- var caller = Authorize(company, login, key, manager.Authorize(company, repository));
+ var caller = Authenticate(company, login, key, manager.AuthenticateDownload(company, repository));
if (caller == null)
return null;
@@ -180,7 +180,7 @@ public ActionResult List(string company, string login, string key, string reposi
[DataService]
public ActionResult Search(string company, string login, string key, string repository, string searchTerm, ODataUrlQueryOptions options, bool count)
{
- var caller = Authorize(company, login, key, manager.Authorize(company, repository));
+ var caller = Authenticate(company, login, key, manager.AuthenticateDownload(company, repository));
if (caller == null)
return null;
@@ -210,7 +210,7 @@ public ActionResult Search(string company, string login, string key, string repo
[DataService]
public ActionResult Count(string company, string login, string key, string repository, string filter)
{
- var caller = Authorize(company, login, key, manager.Authorize(company, repository));
+ var caller = Authenticate(company, login, key, manager.AuthenticateDownload(company, repository));
if (caller == null)
return null;
@@ -289,7 +289,7 @@ private XElement GetPackageElement(string company, string login, string key, str
public ActionResult Download(string company, string login, string key, string repository, string project, string version)
{
- var caller = Authorize(company, login, key, manager.Authorize(company, repository));
+ var caller = Authenticate(company, login, key, manager.AuthenticateDownload(company, repository));
if (caller == null)
return null;
View
13 Sources/SymbolSource.Gateway.NuGet.Core/NuGetGatewayManager.cs
@@ -26,8 +26,8 @@ public interface INuGetGatewayManager : IGatewayManager
public class NuGetGatewayManager : GatewayManager, INuGetGatewayManager
{
- public NuGetGatewayManager(IGatewayBackendFactory<IPackageBackend> factory)
- : base(factory)
+ public NuGetGatewayManager(IGatewayBackendFactory<IPackageBackend> backendFactory, IGatewayConfigurationFactory configurationFactory)
+ : base(backendFactory, configurationFactory)
{
}
@@ -158,15 +158,6 @@ private ContentType GetContentType(string name)
return new NuGetService(configuration.Service).CheckPermission(caller.KeyValue, projectName);
}
- protected override void PushPackage(Caller caller, Version version, string path, PackageProject metadata)
- {
- using (var backend = factory.Create(caller))
- {
- version.PackageFormat = "NuGet";
- backend.PushPackage(ref version, File.ReadAllBytes(GetFilePath(path)), metadata);
- }
- }
-
protected override string GetPackageFormat()
{
return "NuGet";
View
2 Sources/SymbolSource.Gateway.NuGet.Core/Upload15Controller.cs
@@ -44,7 +44,7 @@ private ActionResult DoAction(Action action)
private Caller GetCaller(string company, string key)
{
- var configuration = new ConfigurationWrapper(company);
+ var configuration = new AppSettingsConfiguration(company);
try
{
View
2 Sources/SymbolSource.Gateway.NuGet.Core/Upload16Controller.cs
@@ -49,7 +49,7 @@ private ActionResult DoAction(Action action, int successCode, string successMess
private Caller GetCaller(string company, string key)
{
- var configuration = new ConfigurationWrapper(company);
+ var configuration = new AppSettingsConfiguration(company);
try
{
View
27 Sources/SymbolSource.Gateway.OpenWrap.Core/OpenWrapGatewayManager.cs
@@ -1,3 +1,4 @@
+using System.Collections.Generic;
using System.Linq;
using Ionic.Zip;
using OpenFileSystem.IO;
@@ -7,13 +8,6 @@
using OpenWrap.PackageManagement.Exporters.Assemblies;
using OpenWrap.Repositories;
using OpenWrap.Runtime;
-//using OpenFileSystem.IO;
-//using OpenFileSystem.IO.FileSystems.Local;
-//using OpenWrap;
-//using OpenWrap.PackageManagement;
-//using OpenWrap.PackageManagement.Exporters.Assemblies;
-//using OpenWrap.Repositories;
-//using OpenWrap.Runtime;
using SymbolSource.Gateway.Core;
using SymbolSource.Server.Management.Client;
@@ -26,8 +20,8 @@ public interface IOpenWrapGatewayManager : IGatewayManager
public class OpenWrapGatewayManager : GatewayManager, IOpenWrapGatewayManager
{
- public OpenWrapGatewayManager(IGatewayBackendFactory<IPackageBackend> factory)
- : base(factory)
+ public OpenWrapGatewayManager(IGatewayBackendFactory<IPackageBackend> backendFactory, IGatewayConfigurationFactory configurationFactory)
+ : base(backendFactory, configurationFactory)
{
}
@@ -36,7 +30,7 @@ protected override string GetFilePath(string path)
return new Path(path).Combine("upload-1.0.wrap").FullPath;
}
- protected override void GetMetadata(string path, string repository, out PackageProject project, out Version version, out ILookup<ContentType, string> contents)
+ protected override void GetMetadata(string path, string repository, out PackageProject project, out IList<MetadataEntry> metadata, out ILookup<ContentType, string> contents)
{
var assemblyExporter = new DefaultAssemblyExporter();
var packageInfo = new FolderRepository(LocalFileSystem.Instance.GetDirectory(path)).PackagesByName.Single().Single();
@@ -73,10 +67,10 @@ protected override void GetMetadata(string path, string repository, out PackageP
},
};
- version = new Version { Metadata = new MetadataEntry[0] };
-
using (var zip = new ZipFile(GetFilePath(path)))
contents = zip.EntryFileNames.ToLookup(GetContentType);
+
+ metadata = new List<MetadataEntry>();
}
private ContentType GetContentType(string name)
@@ -111,15 +105,6 @@ private string GetAssemblyPath(string assemblyPath, string rootPath)
return null;
}
- protected override void PushPackage(Caller caller, Version version, string path, PackageProject metadata)
- {
- using (var backend = factory.Create(caller))
- {
- version.PackageFormat = "OpenWrap";
- backend.PushPackage(ref version, System.IO.File.ReadAllBytes(GetFilePath(path)), metadata);
- }
- }
-
protected override string GetPackageFormat()
{
return "OpenWrap";
View
10 Sources/SymbolSource.Gateway.OpenWrap.Core/WrapController.cs
@@ -19,7 +19,7 @@ public WrapController(IGatewayBackendFactory<IPackageBackend> factory, IOpenWrap
this.manager = manager;
}
- private Caller Authorize(string company, bool require)
+ private Caller Authenticate(string company, bool require)
{
var auth = Request.Headers["Authorization"];
@@ -33,7 +33,7 @@ private Caller Authorize(string company, bool require)
if (!require)
{
- var configuration = new ConfigurationWrapper(company);
+ var configuration = new AppSettingsConfiguration(company);
return new Caller
{
@@ -55,7 +55,7 @@ public ActionResult Index(string company, string repository)
if (Request.HttpMethod == "HEAD")
return null;
- var caller = Authorize(company, manager.Authorize(company, repository));
+ var caller = Authenticate(company, manager.AuthenticateDownload(company, repository));
if (caller == null)
return null;
@@ -101,7 +101,7 @@ private bool IsCompatibleVersion(string name)
[GET("{company}/{repository}/download/{project}/{version}")]
public ActionResult Download(string company, string repository, string project, string version)
{
- var caller = Authorize(company, manager.Authorize(company, repository));
+ var caller = Authenticate(company, manager.AuthenticateDownload(company, repository));
if (caller == null)
return null;
@@ -117,7 +117,7 @@ public ActionResult Download(string company, string repository, string project,
[POST("{company}/{repository}/upload")]
public ActionResult Upload(string company, string repository)
{
- var caller = Authorize(company, true);
+ var caller = Authenticate(company, manager.AuthenticateUpload(company, repository));
if (caller == null)
return null;
View
4 Sources/SymbolSource.Gateway.WinDbg.Core/AttributeRouting.cs
@@ -45,7 +45,7 @@ public static void RegisterRoutes(RouteCollection routes)
new[] { typeof(AttributeRouting).Namespace }
);
- var configuration = new ConfigurationWrapper("Public");
+ var configuration = new AppSettingsConfiguration("Public");
routes.MapRoute(
"Default-Public",
@@ -78,7 +78,7 @@ private static void RegisterWinDbg(RouteCollection routes, string type)
new[] { typeof(AttributeRouting).Namespace }
);
- var configuration = new ConfigurationWrapper("Public");
+ var configuration = new AppSettingsConfiguration("Public");
routes.MapRoute(
type + "-Public",
View
2 Sources/SymbolSource.Gateway.WinDbg.Core/BinController.cs
@@ -41,7 +41,7 @@ public ActionResult Index(string company, string login, string password, string
if (company != "Public")
{
- var configuration = new ConfigurationWrapper("Public");
+ var configuration = new AppSettingsConfiguration("Public");
using (var backend = factory.Create("Public", configuration.PublicLogin, "VisualStudio", configuration.PublicPassword))
{
View
2 Sources/SymbolSource.Gateway.WinDbg.Core/PdbController.cs
@@ -51,7 +51,7 @@ public ActionResult Index(string company, string login, string password, string
if (company != "Public")
{
- var configuration = new ConfigurationWrapper("Public");
+ var configuration = new AppSettingsConfiguration("Public");
using (var backend = factory.Create("Public", configuration.PublicLogin, "VisualStudio", configuration.PublicPassword))
{
View
6 Sources/SymbolSource.Processing.Basic/Projects/SourceDiscover.cs
@@ -149,7 +149,11 @@ private bool CheckCandidate(string fullPath, string fileName)
/// </summary>
private string GetMaxCommonPath(IEnumerable<string> originalPaths)
{
- string maxCommonPath = originalPaths.First();
+ string maxCommonPath = originalPaths.FirstOrDefault();
+
+ if (maxCommonPath == null)
+ return string.Empty;
+
foreach (string originalPath in originalPaths)
maxCommonPath = GetMaxCommonPath(maxCommonPath, originalPath);
maxCommonPath = maxCommonPath.Trim(Path.DirectorySeparatorChar);
View
4 Sources/SymbolSource.Server.Basic.Host/Web.config
@@ -70,6 +70,10 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Mono.Cecil" publicKeyToken="0738eb9f132ed756" />
+ <bindingRedirect oldVersion="0.0.0.0-0.9.5.0" newVersion="0.9.5.0" />
+ </dependentAssembly>
</assemblyBinding>
</runtime>
<glimpse enabled="true" />
View
13 Sources/SymbolSource.Server.Basic.Host/Web.config.transform
@@ -6,16 +6,25 @@
-->
<add key="SrcSrvPath" value="C:\Program Files\Debugging Tools for Windows (x86)\srcsrv" />
</appSettings>
-
+
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
-
+
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="31457280" />
</system.web>
+ <runtime>
+ <assemblyBinding>
+ <dependentAssembly>
+ <assemblyIdentity name="Mono.Cecil" publicKeyToken="0738eb9f132ed756" />
+ <bindingRedirect oldVersion="0.0.0.0-0.9.5.0" newVersion="0.9.5.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+
<location path="WinDbg/pdbsrc">
<system.webServer>
<handlers>
View
2 Sources/SymbolSource.Server.Basic/BasicBackend.Download.cs
@@ -26,7 +26,7 @@ public string GetSourceFileLink(ref SourceFile sourceFile)
public string GetPackageLink(ref Version version, string contentType)
{
- throw new NotImplementedException();
+ return configuration.RemotePath + '/' + GetPackagePathFromVersion(version).Replace(Path.DirectorySeparatorChar, '/');
}
}
}
View
38 Sources/SymbolSource.Server.Basic/BasicBackend.Metadata.cs
@@ -8,26 +8,35 @@ namespace SymbolSource.Server.Basic
{
public partial class BasicBackend
{
-
private string GetPathToImageFile(string name, string symbolHash)
{
string binaryIndexPath = Path.Combine(configuration.IndexPath, name);
- if(!Directory.Exists(binaryIndexPath))
+ if (!Directory.Exists(binaryIndexPath))
return null;
string hashIndexPath = Path.Combine(binaryIndexPath, symbolHash + ".txt");
- if(!File.Exists(hashIndexPath))
+ if (!File.Exists(hashIndexPath))
return null;
var hashes = File.ReadAllLines(hashIndexPath)
.Where(h => Directory.Exists(Path.Combine(configuration.DataPath, h)))
.ToArray();
-
+
File.WriteAllLines(hashIndexPath, hashes);
return hashes.FirstOrDefault();
}
+ private string GetPackagePathFromVersion(Version version)
+ {
+ return new[]
+ {
+ Path.Combine(version.Project, version.Name, GetPackageName("NuGet", version.Project, version.Name)),
+ Path.Combine(version.Project, version.Name, GetPackageName("OpenWrap", version.Project, version.Name))
+ }
+ .First(candidate => File.Exists(Path.Combine(configuration.DataPath, candidate)));
+ }
+
private string GetPathFromImageFile(ImageFile imageFile)
{
return Path.Combine(imageFile.Project, imageFile.Version, "Binaries", imageFile.Name, imageFile.SymbolHash);
@@ -57,7 +66,7 @@ private ImageFile BuildImageFile(string path)
public ImageFile GetImageFile(string name, string symbolHash)
{
string pathImageFile = GetPathToImageFile(name, symbolHash);
- if(pathImageFile == null)
+ if (pathImageFile == null)
return null;
return BuildImageFile(pathImageFile);
@@ -130,7 +139,24 @@ public void CreateOrUpdateRepository(Repository repository)
public Version[] GetPackages(ref Repository repository, string packageFormat)
{
- throw new NotImplementedException();
+ var repositoryCopy = repository;
+
+ return Directory.EnumerateDirectories(configuration.DataPath)
+ .SelectMany(
+ projectPath =>
+ Directory.EnumerateDirectories(projectPath)
+ .Select(
+ versionPath =>
+ new Version
+ {
+ Company = repositoryCopy.Company,
+ Repository = repositoryCopy.Name,
+ Project = Path.GetFileName(projectPath),
+ Name = Path.GetFileName(versionPath),
+ PackageFormat = packageFormat
+ })
+ .Where(version => File.Exists(GetPackagePathFromVersion(version))))
+ .ToArray();
}
public Caller CreateUserByKey(string company, string type, string value)
View
45 Sources/SymbolSource.Server.Basic/BasicBackend.Upload.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using Ionic.Zip;
using SymbolSource.Processing.Basic;
using SymbolSource.Processing.Basic.Projects;
@@ -11,7 +12,22 @@ namespace SymbolSource.Server.Basic
{
public partial class BasicBackend
{
- public void CreateJob(byte[] data, PackageProject metadata)
+ public Version UploadPackage(PackageProject package, string packageFormat, byte[] packageData, byte[] symbolPackageData)
+ {
+ if (packageData == null && symbolPackageData == null)
+ throw new ArgumentNullException();
+
+ if (packageData != null)
+ PushPackage(package, packageFormat, packageData);
+
+ if (symbolPackageData != null)
+ CreateJob(package, symbolPackageData);
+
+ return new Version();
+ }
+
+ [Obsolete]
+ private void CreateJob(PackageProject metadata, byte[] data)
{
string directory = Path.Combine(metadata.Name, metadata.Version.Name);
Directory.CreateDirectory(Path.Combine(configuration.DataPath, directory));
@@ -53,7 +69,7 @@ public void CreateJob(byte[] data, PackageProject metadata)
var sourceIndex = new List<string>();
- foreach (var sourceInfo in binaryInfo.SymbolInfo.SourceInfos)
+ foreach (var sourceInfo in binaryInfo.SymbolInfo.SourceInfos.Where(info => info.ActualPath != null))
{
string sourcePath = Path.Combine(sourcesDirectory, sourceInfo.KeyPath);
Directory.CreateDirectory(Path.Combine(configuration.DataPath, Path.GetDirectoryName(sourcePath)));
@@ -72,26 +88,27 @@ public void CreateJob(byte[] data, PackageProject metadata)
File.Delete(file);
}
- public void PushPackage(ref Version version, byte[] data, PackageProject metadata)
+ [Obsolete]
+ private void PushPackage(PackageProject metadata, string packageFormat, byte[] data)
{
- string directory = Path.Combine(configuration.DataPath, metadata.Name, metadata.Version.Name);
+ var directory = Path.Combine(configuration.DataPath, metadata.Name, metadata.Version.Name);
Directory.CreateDirectory(directory);
- string file;
- switch(version.PackageFormat)
+ var file = Path.Combine(directory, GetPackageName(packageFormat, metadata.Name, metadata.Version.Name));
+ File.WriteAllBytes(file, data);
+ }
+
+ private static string GetPackageName(string packageFormat, string projectName, string versionName)
+ {
+ switch (packageFormat)
{
case "NuGet":
- file = Path.Combine(directory, metadata.Name + "." + metadata.Version.Name + ".nupkg");
- break;
+ return projectName + "." + versionName + ".nupkg";
case "OpenWrap":
- file = Path.Combine(directory, metadata.Name + "-" + metadata.Version.Name + ".wrap");
- break;
+ return projectName + "-" + versionName + ".wrap";
default:
- file = Path.Combine(directory, metadata.Name + "." + version.PackageFormat);
- break;
+ throw new NotSupportedException(packageFormat);
}
-
- File.WriteAllBytes(file, data);
}
}
}
View
5 Sources/SymbolSource.Server.Basic/MicroKernel.cs
@@ -67,6 +67,11 @@ private static void RegisterManagers(IWindsorContainer kernel)
Component.For<IBasicBackendConfiguration>()
.ImplementedBy<BasicBackendConfiguration>()
);
+
+ kernel.Register(
+ Component.For<IGatewayConfigurationFactory>()
+ .ImplementedBy<AppSettingsConfigurationFactory>()
+ );
}
}
View
3 Sources/SymbolSource.Server.Basic/SymbolSource.Server.Basic.csproj
@@ -39,6 +39,9 @@
<Reference Include="Castle.Windsor, Version=2.5.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Castle.Windsor.2.5.3\lib\NET40\Castle.Windsor.dll</HintPath>
</Reference>
+ <Reference Include="ICSharpCode.SharpZipLib">
+ <HintPath>..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
+ </Reference>
<Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
<HintPath>..\..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
</Reference>
View
1 Sources/SymbolSource.Server.Basic/packages.config
@@ -4,5 +4,6 @@
<package id="Castle.Windsor" version="2.5.3" />
<package id="DotNetZip" version="1.9.1.8" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
+ <package id="SharpZipLib" version="0.86.0" />
<package id="WebActivator" version="1.5" />
</packages>
View
7 SymbolSource.Community.sln
@@ -17,7 +17,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolSource.Gateway.Core",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolSource.Server.Management.Client", "Sources\SymbolSource.Server.Management.Client\SymbolSource.Server.Management.Client.csproj", "{2F619C26-9619-409F-A79C-04857C7FD634}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolSource.Gateway.NuGet.Core", "sources\SymbolSource.Gateway.NuGet.Core\SymbolSource.Gateway.NuGet.Core.csproj", "{45FD6A65-8C04-4F19-95C2-2598ED79C02E}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolSource.Gateway.NuGet.Core", "Sources\SymbolSource.Gateway.NuGet.Core\SymbolSource.Gateway.NuGet.Core.csproj", "{45FD6A65-8C04-4F19-95C2-2598ED79C02E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolSource.Gateway.OpenWrap.Core", "Sources\SymbolSource.Gateway.OpenWrap.Core\SymbolSource.Gateway.OpenWrap.Core.csproj", "{D8515DF7-5E93-4446-9ABB-CADD435BE00E}"
EndProject
@@ -31,6 +31,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolSource.OData", "Sourc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolSource.OData.Tests", "Sources\SymbolSource.OData.Tests\SymbolSource.OData.Tests.csproj", "{44BC8F67-5A0D-4474-924B-76F893E974A2}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{744C48E9-BDEF-47EB-8AF8-19D07C14838C}"
+ ProjectSection(SolutionItems) = preProject
+ SymbolSource.Server.Basic.nuspec = SymbolSource.Server.Basic.nuspec
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
View
1 SymbolSource.Server.Basic.nuspec
@@ -17,6 +17,7 @@
<dependency id="Castle.Core" version="2.5.2" />
<dependency id="Castle.Windsor" version="2.5.3" />
<dependency id="DotNetZip" version="1.9.1.8" />
+ <dependency id="SharpZipLib" version="0.86.0" />
<dependency id="DynamicQuery" version="1.0" />
<dependency id="elmah" version="1.2.0.1" />
<dependency id="log4net" version="[1.2.10]"/>

0 comments on commit d33a08a

Please sign in to comment.
Something went wrong with that request. Please try again.