Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VOSpace INAF
vospace-rest
Commits
7e0a7327
Commit
7e0a7327
authored
Nov 11, 2021
by
Sonia Zorba
Browse files
Fixed special characters issue on pullFromVoSpace
parent
a80fd0ac
Pipeline
#7878
passed with stages
in 2 minutes and 34 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/it/inaf/oats/vospace/FileServiceClient.java
View file @
7e0a7327
...
...
@@ -28,7 +28,6 @@ import org.springframework.http.HttpMethod;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
static
org
.
springframework
.
web
.
servlet
.
mvc
.
method
.
RequestMappingInfo
.
paths
;
@Component
public
class
FileServiceClient
{
...
...
src/main/java/it/inaf/oats/vospace/UriService.java
View file @
7e0a7327
...
...
@@ -26,6 +26,7 @@ import it.inaf.oats.vospace.persistence.model.Location;
import
it.inaf.oats.vospace.persistence.model.LocationType
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
...
...
@@ -41,6 +42,7 @@ import net.ivoa.xml.vospace.v2.Transfer;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
@Service
public
class
UriService
{
...
...
@@ -179,7 +181,8 @@ public class UriService {
private
String
getEndpoint
(
JobSummary
job
,
Transfer
transfer
)
{
String
relativePath
=
URIUtils
.
returnVosPathFromNodeURI
(
transfer
.
getTarget
(),
authority
);
String
relativePath
=
StringUtils
.
uriDecode
(
URIUtils
.
returnVosPathFromNodeURI
(
transfer
.
getTarget
(),
authority
),
StandardCharsets
.
UTF_8
);
User
user
=
(
User
)
servletRequest
.
getUserPrincipal
();
String
creator
=
user
.
getName
();
...
...
@@ -201,6 +204,7 @@ public class UriService {
case
pullFromVoSpace:
// Refresh relative path: it can differ in case of links followed
relativePath
=
NodeUtils
.
getVosPath
(
node
);
relativePath
=
StringUtils
.
uriDecode
(
relativePath
,
StandardCharsets
.
UTF_8
);
if
(!
NodeUtils
.
checkIfReadable
(
node
,
creator
,
groups
))
{
throw
PermissionDeniedException
.
forPath
(
relativePath
);
}
...
...
src/test/java/it/inaf/oats/vospace/UriServiceTest.java
View file @
7e0a7327
...
...
@@ -560,6 +560,38 @@ public class UriServiceTest {
assertTrue
(
ex
.
getMessage
().
contains
(
"no protocol"
));
}
@Test
public
void
testPullFileWithSpecialChars
()
{
DataNode
node
=
new
DataNode
();
node
.
setUri
(
"vos://example.com!vospace/(%20+%20).txt"
);
Property
publicProperty
=
new
Property
();
publicProperty
.
setUri
(
NodeProperties
.
PUBLIC_READ_URI
);
publicProperty
.
setValue
(
String
.
valueOf
(
true
));
node
.
getProperties
().
add
(
publicProperty
);
when
(
nodeDAO
.
listNode
(
eq
(
"/( + ).txt"
))).
thenReturn
(
Optional
.
of
(
node
));
Transfer
transfer
=
new
Transfer
();
transfer
.
setDirection
(
"pullFromVoSpace"
);
transfer
.
setTarget
(
"vos://example.com!vospace/(%20+%20).txt"
);
Protocol
protocol
=
new
Protocol
();
protocol
.
setUri
(
"ivo://ivoa.net/vospace/core#httpget"
);
transfer
.
getProtocols
().
add
(
protocol
);
JobSummary
job
=
new
JobSummary
();
JobSummary
.
JobInfo
jobInfo
=
new
JobSummary
.
JobInfo
();
jobInfo
.
getAny
().
add
(
transfer
);
job
.
setJobInfo
(
jobInfo
);
Transfer
negotiatedTransfer
=
uriService
.
getNegotiatedTransfer
(
job
,
transfer
);
assertEquals
(
1
,
negotiatedTransfer
.
getProtocols
().
size
());
assertTrue
(
negotiatedTransfer
.
getProtocols
().
get
(
0
).
getEndpoint
().
contains
(
"/%28%20%2B%20%29.txt"
));
}
private
void
testArchiveViewEndpoint
(
String
viewUri
)
{
Transfer
transfer
=
new
Transfer
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment