Skip to content
GitLab
Explore
Sign in
VOSpace INAF
vospace-file-service
Compare revisions
62d0b750c35f26e6e4c05d79c300afc8b49771af to 209bdccfdf6cf03524a712b91cc0d7a956747e60
Commits on Source (2)
Added some Link Management features
· e6b31480
Nicola Fulvio Calabria
authored
Aug 25, 2021
e6b31480
Added location type to FileInfo and fixed issue with generation of archives containing async nodes
· 209bdccf
Sonia Zorba
authored
Sep 10, 2021
209bdccf
Show whitespace changes
Inline
Side-by-side
src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java
View file @
209bdccf
...
...
@@ -46,7 +46,8 @@ public class FileDAO {
+
"content_type, content_encoding, content_length, content_md5, name, n.location_id,\n"
+
"accept_views, provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n"
+
"(SELECT user_name FROM users WHERE user_id = creator_id) AS username, n.job_id,\n"
+
"base_path, get_os_path(n.node_id) AS os_path, ? AS vos_path, false AS is_directory\n"
+
"base_path, get_os_path(n.node_id) AS os_path, ? AS vos_path, false AS is_directory,\n"
+
"type = 'link' AS is_link\n"
+
"FROM node n\n"
+
"JOIN location l ON (n.location_id IS NOT NULL AND n.location_id = l.location_id) OR (n.location_id IS NULL AND l.location_id = ?)\n"
+
"LEFT JOIN storage s ON s.storage_id = l.storage_dest_id\n"
...
...
@@ -174,7 +175,8 @@ public class FileDAO {
+
"n.accept_views, n.provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n"
+
"(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n"
+
"base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n"
+
"n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id\n"
+
"n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n"
+
"n.type = 'link' AS is_link, l.location_type\n"
+
"FROM node n\n"
+
"JOIN node p ON p.path @> n.path\n"
+
"LEFT JOIN location l ON l.location_id = n.location_id\n"
...
...
@@ -206,7 +208,8 @@ public class FileDAO {
+
"n.accept_views, n.provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n"
+
"(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n"
+
"base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n"
+
"n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id\n"
+
"n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n"
+
"n.type = 'link' AS is_link, l.location_type\n"
+
"FROM node n\n"
+
"JOIN node p ON p.path @> n.path\n"
+
"LEFT JOIN location l ON l.location_id = n.location_id\n"
...
...
@@ -286,10 +289,12 @@ public class FileDAO {
fi
.
setContentMd5
(
rs
.
getString
(
"content_md5"
));
fi
.
setContentType
(
rs
.
getString
(
"content_type"
));
fi
.
setDirectory
(
rs
.
getBoolean
(
"is_directory"
));
fi
.
setLink
(
rs
.
getBoolean
(
"is_link"
));
fi
.
setJobId
(
rs
.
getString
(
"job_id"
));
int
locationId
=
rs
.
getInt
(
"location_id"
);
if
(!
rs
.
wasNull
())
{
fi
.
setLocationId
(
locationId
);
fi
.
setLocationType
(
rs
.
getString
(
"location_type"
));
}
fillOsPath
(
fi
,
rs
);
...
...
src/main/java/it/inaf/ia2/transfer/persistence/model/FileInfo.java
View file @
209bdccf
...
...
@@ -16,6 +16,7 @@ public class FileInfo {
private
boolean
isPublic
;
private
boolean
virtualParent
;
private
boolean
directory
;
private
boolean
link
;
private
List
<
String
>
groupRead
;
private
List
<
String
>
groupWrite
;
private
String
ownerId
;
...
...
@@ -27,6 +28,7 @@ public class FileInfo {
private
Long
contentLength
;
private
String
contentMd5
;
private
Integer
locationId
;
private
String
locationType
;
private
String
jobId
;
public
int
getNodeId
()
{
...
...
@@ -109,6 +111,14 @@ public class FileInfo {
this
.
directory
=
directory
;
}
public
boolean
isLink
()
{
return
link
;
}
public
void
setLink
(
boolean
link
)
{
this
.
link
=
link
;
}
public
boolean
hasVirtualParent
()
{
return
virtualParent
;
}
...
...
@@ -173,6 +183,14 @@ public class FileInfo {
this
.
locationId
=
locationId
;
}
public
String
getLocationType
()
{
return
locationType
;
}
public
void
setLocationType
(
String
locationType
)
{
this
.
locationType
=
locationType
;
}
public
String
getJobId
()
{
return
jobId
;
}
...
...
src/main/java/it/inaf/ia2/transfer/service/ArchiveService.java
View file @
209bdccf
...
...
@@ -112,7 +112,7 @@ public class ArchiveService {
continue
;
}
if
(
fileInfo
.
getLocationId
()
!=
null
&&
fileInfo
.
getLocation
Id
()
!=
uploadLocationId
)
{
if
(
fileInfo
.
getLocationId
()
!=
null
&&
"portal"
.
equals
(
fileInfo
.
getLocation
Type
())
)
{
// remote file
if
(
portalLocationUrls
==
null
)
{
portalLocationUrls
=
locationDAO
.
getPortalLocationUrls
();
...
...
src/main/java/it/inaf/ia2/transfer/service/FileCopyService.java
View file @
209bdccf
...
...
@@ -107,7 +107,7 @@ public class FileCopyService {
for
(
FileInfo
destinationFileInfo
:
destinationFileInfos
)
{
LOG
.
trace
(
"Processing {} destination"
,
destinationFileInfo
.
getVirtualPath
());
// Cycle on files only
if
(!
destinationFileInfo
.
isDirectory
())
{
if
(!
destinationFileInfo
.
isDirectory
()
&&
!
destinationFileInfo
.
isLink
()
)
{
// Calculate source file vos path
String
correspondingSourceVosPath
=
this
.
getCorrespondingSourceVosPath
(
sourceRootVosPath
,
...
...
@@ -134,7 +134,7 @@ public class FileCopyService {
}
}
if
(
sourceFileInfo
.
getLocationId
()
!=
null
&&
sourceFileInfo
.
getLocation
Id
()
!=
uploadLocationId
)
{
if
(
sourceFileInfo
.
getLocationId
()
!=
null
&&
"portal"
.
equals
(
sourceFileInfo
.
getLocation
Type
())
)
{
// remote file
if
(
portalLocationUrls
==
null
)
{
portalLocationUrls
=
locationDAO
.
getPortalLocationUrls
();
...
...
src/test/java/it/inaf/ia2/transfer/persistence/FileDAOTest.java
View file @
209bdccf
...
...
@@ -88,10 +88,14 @@ public class FileDAOTest {
assertEquals
(
"/home/vospace/upload/user1/file1"
,
fileInfos
.
get
(
0
).
getOsPath
());
assertEquals
(
"/home/vospace/upload/user1/file2"
,
fileInfos
.
get
(
1
).
getOsPath
());
assertEquals
(
"user"
,
fileInfos
.
get
(
1
).
getLocationType
());
assertTrue
(
fileInfos
.
get
(
2
).
isDirectory
());
assertNull
(
fileInfos
.
get
(
2
).
getLocationType
());
assertEquals
(
"/home/username1/retrieve/subdir1/file3"
,
fileInfos
.
get
(
3
).
getOsPath
());
assertEquals
(
"/home/username1/retrieve/subdir1/file4"
,
fileInfos
.
get
(
4
).
getOsPath
());
assertEquals
(
"async"
,
fileInfos
.
get
(
4
).
getLocationType
());
assertEquals
(
"portal-file"
,
fileInfos
.
get
(
5
).
getVirtualName
());
assertEquals
(
"portal"
,
fileInfos
.
get
(
5
).
getLocationType
());
}
@Test
...
...