Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-rest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-rest
Commits
9afaf057
Commit
9afaf057
authored
Jan 18, 2021
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
NodeDAO bugfix
parent
a5513676
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+24
-9
24 additions, 9 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
with
24 additions
and
9 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+
24
−
9
View file @
9afaf057
...
...
@@ -41,21 +41,24 @@ public class NodeDAO {
String
path
=
nodeURI
.
replaceAll
(
"vos://[^/]+"
,
""
);
String
parentPath
=
getParentPath
(
path
);
String
sql
=
"SELECT path
, relative_path
from "
String
sql
=
"SELECT path from "
+
"node n join node_vos_path p on n.node_id = p.node_id "
+
"where p.vos_path = ?"
;
List
<
NodePaths
>
p
aths
=
jdbcTemplate
.
query
(
conn
->
{
List
<
String
>
ltreeParentP
aths
=
jdbcTemplate
.
query
(
conn
->
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
parentPath
);
return
ps
;
},
(
row
,
index
)
->
{
return
getPathsFromResultSet
(
row
);
return
row
.
getString
(
"path"
);
});
if
(
p
aths
.
isEmpty
())
{
if
(
ltreeParentP
aths
.
isEmpty
())
{
throw
new
IllegalStateException
(
"Unable to find parent node during node creation"
);
}
if
(
ltreeParentPaths
.
size
()
>
1
)
{
throw
new
IllegalStateException
(
"Multiple ltree parent paths found for "
+
parentPath
);
}
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"INSERT INTO node"
);
...
...
@@ -72,7 +75,7 @@ public class NodeDAO {
ps
.
setArray
(
5
,
fromPropertyToArray
(
ps
,
getProperty
(
myNode
,
getPropertyURI
(
"groupread"
))));
ps
.
setArray
(
6
,
fromPropertyToArray
(
ps
,
getProperty
(
myNode
,
getPropertyURI
(
"groupwrite"
))));
ps
.
setBoolean
(
7
,
Boolean
.
valueOf
(
getProperty
(
myNode
,
getPropertyURI
(
"publicread"
))));
ps
.
setObject
(
8
,
paths
.
get
(
0
).
p
arentPath
,
Types
.
OTHER
);
ps
.
setObject
(
8
,
ltreeP
arentPath
s
.
get
(
0
)
,
Types
.
OTHER
);
ps
.
setObject
(
9
,
getDbNodeType
(
myNode
),
Types
.
OTHER
);
return
ps
;
});
...
...
@@ -81,7 +84,7 @@ public class NodeDAO {
public
Optional
<
Node
>
listNode
(
String
path
)
{
String
sql
=
"SELECT os.vos_path, n.node_id, type, async_trans, busy_state,
owne
r_id, group_read, group_write, is_public, content_length, created_on, last_modified from node n\n"
String
sql
=
"SELECT os.vos_path, n.node_id, type, async_trans, busy_state,
creato
r_id, group_read, group_write, is_public, content_length, created_on, last_modified from node n\n"
+
"JOIN node_vos_path os ON n.node_id = os.node_id\n"
+
"WHERE n.path ~ ("
+
getFirstLevelChildrenSelector
(
path
)
+
")::lquery\n"
+
"OR os.vos_path = ? ORDER BY vos_path"
;
...
...
@@ -141,6 +144,9 @@ public class NodeDAO {
addProperty
(
getPropertyURI
(
"btime"
),
rs
.
getString
(
"created_on"
),
properties
);
addProperty
(
getPropertyURI
(
"creator"
),
rs
.
getString
(
"creator_id"
),
properties
);
addProperty
(
getPropertyURI
(
"mtime"
),
rs
.
getString
(
"last_modified"
),
properties
);
...
...
@@ -228,13 +234,22 @@ public class NodeDAO {
return
false
;
}
// Copied from CreateNodeController: to be moved in a common utility class
private
String
getParentPath
(
String
path
)
{
String
[]
parsedPath
=
path
.
split
(
"/"
);
String
[]
parsedPath
=
path
.
split
(
"[/]+"
);
if
(
parsedPath
.
length
<
2
||
!
parsedPath
[
0
].
isEmpty
())
{
throw
new
IllegalArgumentException
();
}
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"/"
);
for
(
int
i
=
0
;
i
<
parsedPath
.
length
-
1
;
i
++)
{
sb
.
append
(
"/"
).
append
(
parsedPath
[
i
]);
for
(
int
i
=
1
;
i
<
parsedPath
.
length
-
1
;
i
++)
{
sb
.
append
(
parsedPath
[
i
]);
if
(
i
<
parsedPath
.
length
-
2
)
{
sb
.
append
(
"/"
);
}
}
return
sb
.
toString
();
...
...
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
sign in
to comment