Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BlobApi
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
apis
BlobApi
Commits
bfa244a0
Commit
bfa244a0
authored
Nov 28, 2022
by
Benedikt Heinrichs
Browse files
Options
Downloads
Patches
Plain Diff
Use new Id
parent
a0b87f1e
No related branches found
No related tags found
1 merge request
!77
New: Use the new metadata structure (coscine/issues#1792)
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Blob/Controllers/BlobController.cs
+33
-2
33 additions, 2 deletions
src/Blob/Controllers/BlobController.cs
with
33 additions
and
2 deletions
src/Blob/Controllers/BlobController.cs
+
33
−
2
View file @
bfa244a0
...
@@ -6,6 +6,7 @@ using Coscine.Database.Models;
...
@@ -6,6 +6,7 @@ using Coscine.Database.Models;
using
Coscine.Database.Util
;
using
Coscine.Database.Util
;
using
Coscine.Logging
;
using
Coscine.Logging
;
using
Coscine.Metadata
;
using
Coscine.Metadata
;
using
Coscine.Metadata.Util
;
using
Coscine.ResourceTypes
;
using
Coscine.ResourceTypes
;
using
Coscine.ResourceTypes.Base.Models
;
using
Coscine.ResourceTypes.Base.Models
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Authorization
;
...
@@ -61,9 +62,39 @@ namespace Coscine.Api.Blob.Controllers
...
@@ -61,9 +62,39 @@ namespace Coscine.Api.Blob.Controllers
/// </summary>
/// </summary>
/// <param name="resourceId">Id of the resource</param>
/// <param name="resourceId">Id of the resource</param>
/// <param name="path">Path to file</param>
/// <param name="path">Path to file</param>
/// <param name="retrieve">Is retrieve action?</param>
/// <returns> Uri </returns>
/// <returns> Uri </returns>
public
Uri
GenerateId
(
string
resourceId
,
string
path
)
public
Uri
GenerateId
(
string
resourceId
,
string
path
,
bool
retrieve
=
false
)
{
{
if
(!
path
.
StartsWith
(
"/"
))
{
path
=
"/"
+
path
;
}
var
currentId
=
_rdfStoreConnector
.
GetMetadataId
(
resourceId
,
path
);
if
(
currentId
==
null
&&
retrieve
)
{
return
GenerateOldId
(
resourceId
,
path
);
}
var
newVersionGraph
=
new
CustomUri
(
$"https://purl.org/coscine/resources/
{
resourceId
}{
path
}
/@type=metadata&version=
{
VersionUtil
.
GetNewVersion
()}
"
);
return
newVersionGraph
;
}
/// <summary>
/// Generates Id
/// </summary>
/// <param name="resourceId">Id of the resource</param>
/// <param name="path">Path to file</param>
/// <returns> Uri </returns>
public
Uri
GenerateOldId
(
string
resourceId
,
string
path
)
{
if
(!
path
.
StartsWith
(
"/"
))
{
path
=
"/"
+
path
;
}
return
new
CustomUri
(
$"https://hdl.handle.net/
{
_prefix
}
/
{
resourceId
}
@path=
{
Uri
.
EscapeDataString
(
path
)}
"
);
return
new
CustomUri
(
$"https://hdl.handle.net/
{
_prefix
}
/
{
resourceId
}
@path=
{
Uri
.
EscapeDataString
(
path
)}
"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment