Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • Fix/xxxx-resourceVisibility
  • Hotfix/1357-ymlFile
  • Hotfix/1370-swaggerDescription
  • Hotfix/2077-fixSupportAdminLog
  • Hotfix/2087-efNet6
  • Hotfix/2224-quotaSizeAnalytics
  • Hotfix/2427-adminTrouble
  • Hotfix/82-updateDepsOfAPIs
  • Issue/1866-ExtendResourceTypeConfigurationTUDo
  • Issue/1877-ExtendResourceTypeConfigurationNRWFHs
  • Issue/1910-MigrationtoNET6.0
  • Issue/1940ResouceKeysForNRWAndTUDO
  • Issue/1951-quotaImplementation
  • Issue/2001-extendAnalyticsLogger
  • Issue/2061-activateResourceTypeRdss3nrw
  • Issue/2072-wormResourceType
  • Issue/2309-docs
  • Issue/2330-fixNaNQuotainAdmin
  • Product/1119-quotaAdminPage
  • Product/1287-dotnet5Sharepoint
  • Product/1559-rdsS3QuotaManagement
  • Product/1600-rdsS3QuotaManagement
  • Product/1623-allocatedQuotaForAdmin
  • Sprint/2020-22
  • Sprint/2021-03
  • Sprint/2021-05
  • Sprint/2021-08
  • Sprint/2021-13
  • Sprint/2021-17
  • Sprint/2021-23
  • Sprint/2022-01
  • Sprint/2022-05
  • Topic/1163-adminApi
  • Topic/1335-dotnet5Apis
  • Topic/1568-quotaApiAdjustments
  • Topic/1688-allocatedQuotaForAdminApi
  • dev
  • gitkeep
  • master
  • v1.1.0
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.0.3
  • v2.1.0
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.4.0
  • v2.5.0
  • v2.5.1
  • v2.5.2
  • v2.5.3
  • v2.5.4
  • v2.6.0
  • v2.6.1
  • v3.0.0
  • v3.0.1
  • v3.0.2
  • v3.0.3
  • v3.0.4
  • v3.0.5
  • v3.0.6
  • v3.0.7
  • v3.0.8
68 results

Target

Select target project
  • coscine/backend/apis/admin
1 result
Select Git revision
  • Fix/xxxx-resourceVisibility
  • Hotfix/1357-ymlFile
  • Hotfix/1370-swaggerDescription
  • Hotfix/2077-fixSupportAdminLog
  • Hotfix/2087-efNet6
  • Hotfix/2224-quotaSizeAnalytics
  • Hotfix/2427-adminTrouble
  • Hotfix/82-updateDepsOfAPIs
  • Issue/1866-ExtendResourceTypeConfigurationTUDo
  • Issue/1877-ExtendResourceTypeConfigurationNRWFHs
  • Issue/1910-MigrationtoNET6.0
  • Issue/1940ResouceKeysForNRWAndTUDO
  • Issue/1951-quotaImplementation
  • Issue/2001-extendAnalyticsLogger
  • Issue/2061-activateResourceTypeRdss3nrw
  • Issue/2072-wormResourceType
  • Issue/2309-docs
  • Issue/2330-fixNaNQuotainAdmin
  • Product/1119-quotaAdminPage
  • Product/1287-dotnet5Sharepoint
  • Product/1559-rdsS3QuotaManagement
  • Product/1600-rdsS3QuotaManagement
  • Product/1623-allocatedQuotaForAdmin
  • Sprint/2020-22
  • Sprint/2021-03
  • Sprint/2021-05
  • Sprint/2021-08
  • Sprint/2021-13
  • Sprint/2021-17
  • Sprint/2021-23
  • Sprint/2022-01
  • Sprint/2022-05
  • Topic/1163-adminApi
  • Topic/1335-dotnet5Apis
  • Topic/1568-quotaApiAdjustments
  • Topic/1688-allocatedQuotaForAdminApi
  • dev
  • gitkeep
  • master
  • v1.1.0
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.0.3
  • v2.1.0
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.4.0
  • v2.5.0
  • v2.5.1
  • v2.5.2
  • v2.5.3
  • v2.5.4
  • v2.6.0
  • v2.6.1
  • v3.0.0
  • v3.0.1
  • v3.0.2
  • v3.0.3
  • v3.0.4
  • v3.0.5
  • v3.0.6
  • v3.0.7
  • v3.0.8
68 results
Show changes
Commits on Source (3)
...@@ -5,22 +5,22 @@ ...@@ -5,22 +5,22 @@
<AssemblyName>Coscine.Api.Admin</AssemblyName> <AssemblyName>Coscine.Api.Admin</AssemblyName>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Version>3.0.3</Version> <Version>3.0.4</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<Authors>RWTH Aachen University</Authors> <Authors>RWTH Aachen University</Authors>
<Company>IT Center, RWTH Aachen University</Company> <Company>IT Center, RWTH Aachen University</Company>
<Copyright>2022 IT Center, RWTH Aachen University</Copyright> <Copyright>2023 IT Center, RWTH Aachen University</Copyright>
<Description>Admin is a part of the Coscine group.</Description> <Description>Admin is a part of the Coscine group.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://git.rwth-aachen.de/coscine/backend/apis/Admin</PackageProjectUrl> <PackageProjectUrl>https://git.rwth-aachen.de/coscine/backend/apis/Admin</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Coscine.Action" Version="2.*-*" /> <PackageReference Include="Coscine.Action" Version="*-*" />
<PackageReference Include="Coscine.ApiCommons" Version="2.*-*" /> <PackageReference Include="Coscine.ApiCommons" Version="*-*" />
<PackageReference Include="Coscine.Database" Version="2.*-*" /> <PackageReference Include="Coscine.Database" Version="*-*" />
<PackageReference Include="Coscine.Metadata" Version="2.*-*" /> <PackageReference Include="Coscine.Metadata" Version="*-*" />
<PackageReference Include="Coscine.ResourceTypes" Version="1.*-*" /> <PackageReference Include="Coscine.ResourceTypes" Version="*-*" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Authorization; ...@@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Coscine.Api.Admin.Controllers namespace Coscine.Api.Admin.Controllers
...@@ -66,8 +67,8 @@ namespace Coscine.Api.Admin.Controllers ...@@ -66,8 +67,8 @@ namespace Coscine.Api.Admin.Controllers
[HttpGet("[controller]/{projectString}")] [HttpGet("[controller]/{projectString}")]
public ActionResult<AdminProjectObject> GetProject(string projectString) public ActionResult<AdminProjectObject> GetProject(string projectString)
{ {
var user = _authenticator.GetUserId(); var user = _authenticator.GetUser();
if (!HasRole(user, _adminRole)) if (!HasRole(user.Id.ToString(), _adminRole))
{ {
return Unauthorized($"User does not have the role \"{_adminRole}\"."); return Unauthorized($"User does not have the role \"{_adminRole}\".");
} }
...@@ -88,7 +89,13 @@ namespace Coscine.Api.Admin.Controllers ...@@ -88,7 +89,13 @@ namespace Coscine.Api.Admin.Controllers
return NotFound("Project was not found."); return NotFound("Project was not found.");
} }
var quotas = _projectQuotaModel.GetAllWhere(x => x.ProjectId == project.Id); var listOfResources = ResourceTypeFactory.Instance.GetSpecificResourceTypes().Select(x => x.SpecificTypeName);
var allResourceTypeIds = _resourceTypeModel.GetAllWhere((resourceType) => listOfResources.Contains(resourceType.SpecificType)).Select(e => e.Id).ToList();
var quotas = _projectQuotaModel.GetAllWhere(pq =>
pq.ProjectId == project.Id &&
allResourceTypeIds.Contains(pq.ResourceTypeId)
).ToList();
return new AdminProjectObject return new AdminProjectObject
{ {
......
using Coscine.Database.DataModel;
using Coscine.Database.Models;
using Coscine.Metadata;
using System.Collections.Generic;
using System.Linq;
namespace Coscine.Api.Admin.Util;
internal class OrganizationsHelper
{
private static readonly ExternalIdModel _externalIdModel = new();
private static readonly RdfStoreConnector _rdfStoreConnector = new(Program.Configuration.GetStringAndWait("coscine/local/virtuoso/additional/url"));
public static IEnumerable<string> GetOrganization(User user)
{
// Bellow code taken from Organizations API
var externalIds = _externalIdModel.GetAllWhere((externalId) => externalId.UserId == user.Id);
var externalIdList = _externalIdModel.GetAllWhere((externalId) => externalId.UserId == user.Id).Select(x => x.ExternalId1).ToList();
var externalOrganizations = externalIds.Select((externalId) => externalId.Organization);
var triplesExternalIds = _rdfStoreConnector.GetTriples(null, null, null, 1, externalIdList);
var triplesExternalOrganizations = externalOrganizations.SelectMany(x => _rdfStoreConnector.GetOrganizationByEntityId(x));
return triplesExternalIds.Select(x => x.Subject.ToString())
.Concat(triplesExternalOrganizations.Select(x => x.Subject.ToString()))
.Distinct();
}
}
\ No newline at end of file