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