Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TreeApi
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
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
TreeApi
Commits
310edc24
Commit
310edc24
authored
3 years ago
by
Petar Hristov
Browse files
Options
Downloads
Plain Diff
Merge branch 'Sprint/2021-15' into 'master'
Sprint/2021 15 See merge request
!44
parents
b741abb4
50081280
No related branches found
No related tags found
1 merge request
!44
Sprint/2021 15
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+2
-30
2 additions, 30 deletions
README.md
src/Tree/Controllers/TreeController.cs
+43
-11
43 additions, 11 deletions
src/Tree/Controllers/TreeController.cs
with
45 additions
and
41 deletions
README.md
+
2
−
30
View file @
310edc24
##
C# Templat
e
##
Tre
e
This template includes:
*
Automatic building using cake
*
Automatic testing with NUnit
*
Automatic linting with Resharper
*
Automatic documentation publishing using Gitlab CI / CD and a self written script which puts the docs in the docs folder to the wiki
*
Automatic releases using semantic-release (
[
ESLint Code Convention
](
docs/ESLintConvention
)
), cake and Gitlab CI / CD
## What you need to do
Place you C# project solution file in .src/.
Make sure Create directory for solution is unticked.

Delete unused docs and update this README.
Add
[
NUnit
](
docs/nunit.md
)
tests to your solution.
## Building
Build this project by running either the build.ps1 or the build
<span></span>
.sh script.
The project will be build and tested.
### Links
*
[
Commit convention
](
docs/ESLintConvention.md
)
*
[
Everything possible with markup
](
docs/testdoc.md
)
*
[
Adding NUnit tests
](
docs/nunit.md
)
The TreeApi handles the retrieving or storing metadata to a certain path.
This diff is collapsed.
Click to expand it.
src/Tree/Controllers/TreeController.cs
+
43
−
11
View file @
310edc24
...
...
@@ -118,10 +118,18 @@ namespace Coscine.Api.Tree.Controllers
return
BadRequest
(
$"No provider for: \"
{
resource
.
Type
.
DisplayName
}
\"."
);
}
var
infos
=
await
resourceTypeDefinition
.
ListEntries
(
resourceId
,
path
,
resourceTypeOptions
);
var
fileInfos
=
await
resourceTypeDefinition
.
ListEntries
(
resourceId
,
path
,
resourceTypeOptions
);
var
metadataInfos
=
new
List
<
ResourceEntry
>(
fileInfos
);
if
(
path
.
EndsWith
(
"/"
))
{
metadataInfos
.
Insert
(
0
,
new
ResourceEntry
(
path
,
false
,
0
,
null
,
null
,
new
DateTime
(),
new
DateTime
()));
}
var
graphs
=
new
List
<
JToken
>();
int
metadataCount
=
0
;
foreach
(
var
info
in
i
nfos
)
foreach
(
var
info
in
metadataI
nfos
)
{
var
id
=
GenerateId
(
resourceId
,
info
.
Key
);
if
(
_rdfStoreConnector
.
HasGraph
(
id
.
AbsoluteUri
))
...
...
@@ -135,11 +143,11 @@ namespace Coscine.Api.Tree.Controllers
var
jObject
=
new
JObject
(
new
JProperty
(
"data"
,
new
JObject
(
new
JProperty
(
"metadataStorage"
,
JToken
.
FromObject
(
graphs
)),
new
JProperty
(
"fileStorage"
,
JToken
.
FromObject
(
i
nfos
.
Select
(
x
=>
new
JProperty
(
"fileStorage"
,
JToken
.
FromObject
(
fileI
nfos
.
Select
(
x
=>
{
var
objectMetaInfo
=
new
ObjectMetaInfo
{
Name
=
x
.
Key
[(
x
.
Key
.
LastIndexOf
(
"/"
)
+
1
)..]
,
Name
=
GetFolderOrFileName
(
x
)
,
Path
=
x
.
Key
,
Size
=
(
int
)
x
.
BodyBytes
,
Kind
=
x
.
Key
[(
x
.
Key
.
LastIndexOf
(
"."
)
+
1
)..],
...
...
@@ -155,10 +163,12 @@ namespace Coscine.Api.Tree.Controllers
[
"Modified"
]
=
objectMetaInfoReturnObject
.
Modified
,
[
"Created"
]
=
objectMetaInfoReturnObject
.
Created
,
[
"Provider"
]
=
objectMetaInfoReturnObject
.
Provider
,
[
"IsFolder"
]
=
objectMetaInfoReturnObject
.
IsFolder
,
[
"IsFile"
]
=
objectMetaInfoReturnObject
.
IsFile
,
[
"Action"
]
=
new
JObject
{
[
"Delete"
]
=
new
JObject
{
[
"IsFolder"
]
=
!
x
.
HasBody
,
[
"IsFile"
]
=
x
.
HasBody
,
[
"Action"
]
=
new
JObject
{
[
"Delete"
]
=
new
JObject
{
[
"Method"
]
=
"DELETE"
,
[
"Url"
]
=
objectMetaInfoReturnObject
.
DeleteLink
},
...
...
@@ -186,12 +196,34 @@ namespace Coscine.Api.Tree.Controllers
return
Json
(
jObject
);
}
catch
catch
(
Exception
e
)
{
return
BadRequest
(
$"Error in communication with the resource"
);
}
}
/// <summary>
/// This method retrieves the folder or file name.
/// </summary>
/// <param name="x">Resource Entry</param>
/// <returns>Name</returns>
private
static
string
GetFolderOrFileName
(
ResourceEntry
x
)
{
var
lastSlash
=
x
.
Key
.
LastIndexOf
(
"/"
)
+
1
;
var
name
=
x
.
Key
[
lastSlash
..];
if
(
name
==
""
)
{
var
tempPath
=
x
.
Key
[..(
lastSlash
-
1
)];
if
(
tempPath
.
Contains
(
"/"
))
{
tempPath
=
tempPath
[(
tempPath
.
IndexOf
(
"/"
)
+
1
)..];
}
name
=
tempPath
;
}
return
name
;
}
/// <summary>
/// This method stores the metadata of the file
/// </summary>
...
...
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