WIP page leaf
This commit is contained in:
@ -6,7 +6,8 @@ using System.Threading.Tasks;
|
||||
using isn.Abstract;
|
||||
using isnd.Controllers;
|
||||
using isnd.Data;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Data.Packages;
|
||||
using isnd.Data.Packages.Catalog;
|
||||
using isnd.Entities;
|
||||
using isnd.Helpers;
|
||||
using isnd.Interfaces;
|
||||
@ -23,7 +24,7 @@ namespace isnd.Services
|
||||
public const string BASE_API_LEVEL = "3.5.0";
|
||||
|
||||
ApplicationDbContext dbContext;
|
||||
|
||||
|
||||
public PackageManager(ApplicationDbContext dbContext,
|
||||
IOptions<IsndSettings> siteConfigOptionsOptions)
|
||||
{
|
||||
@ -48,15 +49,15 @@ namespace isnd.Services
|
||||
Comment = "Package Publish service"
|
||||
});
|
||||
// under dev, only leash in release mode
|
||||
if (unleashClient.IsEnabled("pkg-get", false))
|
||||
if (unleashClient.IsEnabled("pkg-get", true))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.GetPackage,
|
||||
Type = "PackageBaseAddress/3.0.0" ,
|
||||
Type = "PackageBaseAddress/3.0.0",
|
||||
Comment = "Package Base Address service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-autocomplete", false))
|
||||
if (unleashClient.IsEnabled("pkg-autocomplete", true))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
@ -72,22 +73,51 @@ namespace isnd.Services
|
||||
Type = "SearchQueryService/" + BASE_API_LEVEL,
|
||||
Comment = "Search Query service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-catalog", false))
|
||||
if (unleashClient.IsEnabled("pkg-catalog", true))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.Catalog,
|
||||
Type = "Catalog/"+ BASE_API_LEVEL,
|
||||
Type = "Catalog/" + BASE_API_LEVEL,
|
||||
Comment = "Package Catalog Index"
|
||||
});
|
||||
|
||||
/* FIXME res.Add(
|
||||
|
||||
/* FIXME */
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.Registration,
|
||||
Type = "RegistrationsBaseUrl/3.6.0",
|
||||
Id = extUrl + "v" + BASE_API_LEVEL + "/" + ApiConfig.Registration,
|
||||
Type = "RegistrationsBaseUrl",
|
||||
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
|
||||
}); */
|
||||
});
|
||||
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + "v3.0.0-beta/" + ApiConfig.Registration,
|
||||
Type = "RegistrationsBaseUrl/3.0.0-beta",
|
||||
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
|
||||
});
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + "v3.0.0-rc/" + ApiConfig.Registration,
|
||||
Type = "RegistrationsBaseUrl/3.0.0-rc",
|
||||
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
|
||||
});
|
||||
res.Add(new Resource
|
||||
{
|
||||
Id = extUrl + "v3.4.0/" + ApiConfig.Registration,
|
||||
Type = "RegistrationsBaseUrl/3.4.0",
|
||||
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
|
||||
});
|
||||
|
||||
res.Add(new Resource
|
||||
{
|
||||
Id = extUrl + "v3.6.0/" + ApiConfig.Registration,
|
||||
Type = "RegistrationsBaseUrl/3.6.0",
|
||||
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -97,7 +127,6 @@ namespace isnd.Services
|
||||
{
|
||||
|
||||
var scope = dbContext.Packages
|
||||
.Include(p => p.Versions)
|
||||
.Where(
|
||||
p => (PackageIdHelpers.CamelCaseMatch(p.Id, query) || PackageIdHelpers.SeparatedByMinusMatch(p.Id, query))
|
||||
&& (prerelease || p.Versions.Any(v => !v.IsPrerelease))
|
||||
@ -171,8 +200,8 @@ namespace isnd.Services
|
||||
int p = 0;
|
||||
var oldIndex = CurrentCatalogIndex;
|
||||
var oldPages = CurrentCatalogPages;
|
||||
string baseid= extUrl + ApiConfig.Catalog;
|
||||
string basepageid= extUrl + ApiConfig.CatalogPage;
|
||||
string baseid = extUrl + ApiConfig.Catalog;
|
||||
string basepageid = extUrl + ApiConfig.CatalogPage;
|
||||
CurrentCatalogIndex = new CatalogIndex
|
||||
{
|
||||
Id = baseid,
|
||||
@ -181,7 +210,7 @@ namespace isnd.Services
|
||||
CurrentCatalogPages = new List<Page>();
|
||||
|
||||
var scope = dbContext.Commits.OrderBy(c => c.TimeStamp);
|
||||
|
||||
|
||||
PageRef pageRef = null;
|
||||
Page page = null;
|
||||
i = isndSettings.CatalogPageLen;
|
||||
@ -217,14 +246,14 @@ namespace isnd.Services
|
||||
foreach (var pkg in validPkgs)
|
||||
{
|
||||
var v = pkg.Versions.
|
||||
Where (cv => cv.CommitId == commit.CommitId)
|
||||
Where(cv => cv.CommitId == commit.CommitId)
|
||||
.OrderByDescending(vc => vc.CommitNId).First();
|
||||
|
||||
StringBuilder refid = new StringBuilder(extUrl);
|
||||
refid.AppendFormat("{0}/{1}/{2}",ApiConfig.CatalogLeaf, v.PackageId
|
||||
refid.AppendFormat("{0}/{1}/{2}", ApiConfig.CatalogLeaf, v.PackageId
|
||||
, v.FullString);
|
||||
if (v.Type!=null)
|
||||
refid.AppendFormat("/{0}",v.Type);
|
||||
if (v.Type != null)
|
||||
refid.AppendFormat("/{0}", v.Type);
|
||||
|
||||
var pkgref = new PackageRef
|
||||
{
|
||||
@ -258,7 +287,8 @@ namespace isnd.Services
|
||||
public async Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type)
|
||||
{
|
||||
// TODO deletion on disk
|
||||
var commit = new Commit{
|
||||
var commit = new Commit
|
||||
{
|
||||
Action = PackageAction.DeletePackage,
|
||||
TimeStamp = DateTime.Now
|
||||
};
|
||||
@ -270,12 +300,12 @@ namespace isnd.Services
|
||||
);
|
||||
if (pkg == null)
|
||||
{
|
||||
return new PackageDeletionReport{ Deleted = false };
|
||||
return new PackageDeletionReport { Deleted = false };
|
||||
}
|
||||
dbContext.PackageVersions.Remove(pkg);
|
||||
await dbContext.SaveChangesAsync();
|
||||
ÛpdateCatalogFor(commit);
|
||||
return new PackageDeletionReport{ Deleted = true, DeletedVersion = pkg };
|
||||
return new PackageDeletionReport { Deleted = true, DeletedVersion = pkg };
|
||||
}
|
||||
|
||||
public async Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type)
|
||||
@ -301,7 +331,7 @@ namespace isnd.Services
|
||||
public IEnumerable<PackageVersion> GetCatalogLeaf(string id, string version, string lower)
|
||||
{
|
||||
return dbContext.PackageVersions
|
||||
.Include(v=>v.Package)
|
||||
.Include(v => v.Package)
|
||||
.Where(v => v.PackageId == id && v.FullString == version
|
||||
&& (lower == null || lower == v.Type));
|
||||
}
|
||||
|
Reference in New Issue
Block a user