Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-file-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-file-service
Commits
f6c3963e
Commit
f6c3963e
authored
3 years ago
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
Supported both multipart and direct stream upload
parent
4dd402ae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#1594
passed
3 years ago
Stage: test
Stage: dockerize
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/inaf/ia2/transfer/controller/PutFileController.java
+22
-15
22 additions, 15 deletions
...va/it/inaf/ia2/transfer/controller/PutFileController.java
with
22 additions
and
15 deletions
src/main/java/it/inaf/ia2/transfer/controller/PutFileController.java
+
22
−
15
View file @
f6c3963e
...
...
@@ -14,6 +14,7 @@ import java.security.NoSuchAlgorithmException;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.xml.bind.DatatypeConverter
;
import
net.ivoa.xml.uws.v1.ExecutionPhase
;
import
org.slf4j.Logger
;
...
...
@@ -38,42 +39,43 @@ public class PutFileController extends FileController {
@Autowired
private
JobDAO
jobDAO
;
@Autowired
private
ListOfFilesDAO
listOfFilesDAO
;
@PutMapping
(
"/**"
)
public
ResponseEntity
<?>
putFile
(
@RequestHeader
(
value
=
HttpHeaders
.
CONTENT_ENCODING
,
required
=
false
)
String
contentEncoding
,
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
value
=
"jobid"
,
required
=
false
)
String
jobId
)
throws
IOException
,
NoSuchAlgorithmException
{
@RequestParam
(
value
=
"file"
,
required
=
false
)
MultipartFile
file
,
@RequestParam
(
value
=
"jobid"
,
required
=
false
)
String
jobId
,
HttpServletRequest
request
)
throws
IOException
,
NoSuchAlgorithmException
{
String
path
=
getPath
();
String
path
=
getPath
();
if
(
jobId
==
null
)
{
LOG
.
debug
(
"putFile called for path {}"
,
path
);
}
else
{
LOG
.
debug
(
"putFile called for path {} with jobId {}"
,
path
,
jobId
);
if
(!
jobDAO
.
isJobExisting
(
jobId
))
{
return
new
ResponseEntity
<>(
"Job "
+
jobId
+
" not found"
,
NOT_FOUND
);
if
(!
jobDAO
.
isJobExisting
(
jobId
))
{
return
new
ResponseEntity
<>(
"Job "
+
jobId
+
" not found"
,
NOT_FOUND
);
}
}
Optional
<
FileInfo
>
optFileInfo
=
fileDAO
.
getFileInfo
(
path
);
if
(
optFileInfo
.
isPresent
())
{
try
(
InputStream
in
=
file
.
getInputStream
())
{
try
(
InputStream
in
=
file
!=
null
?
file
.
getInputStream
()
:
request
.
getInputStream
())
{
FileInfo
fileInfo
=
optFileInfo
.
get
();
if
(
fileInfo
.
getAcceptViews
()
!=
null
&&
fileInfo
.
getAcceptViews
().
contains
(
"urn:list-of-files"
))
{
storeListOfFiles
(
fileInfo
,
in
);
}
else
{
fileInfo
.
setContentType
(
file
.
getContentType
());
if
(
file
!=
null
)
{
fileInfo
.
setContentType
(
file
.
getContentType
());
}
fileInfo
.
setContentEncoding
(
contentEncoding
);
storeGenericFile
(
fileInfo
,
in
,
jobId
);
}
}
return
ResponseEntity
.
ok
().
build
();
}
else
{
...
...
@@ -120,10 +122,15 @@ public class PutFileController extends FileController {
}
try
{
if
(
jobId
!=
null
){
if
(
jobId
!=
null
)
{
fileDAO
.
setBusy
(
fileInfo
.
getNodeId
(),
true
);
}
Files
.
copy
(
is
,
file
.
toPath
());
if
(
fileInfo
.
getContentType
()
==
null
)
{
fileInfo
.
setContentType
(
Files
.
probeContentType
(
file
.
toPath
()));
}
Long
fileSize
=
Files
.
size
(
file
.
toPath
());
String
md5Checksum
=
makeMD5Checksum
(
file
);
...
...
@@ -137,13 +144,13 @@ public class PutFileController extends FileController {
}
}
catch
(
IOException
|
NoSuchAlgorithmException
ex
)
{
if
(
jobId
!=
null
)
{
if
(
jobId
!=
null
)
{
jobDAO
.
updateJobPhase
(
ExecutionPhase
.
ERROR
,
jobId
);
}
throw
ex
;
}
finally
{
if
(
jobId
!=
null
){
fileDAO
.
setBusy
(
fileInfo
.
getNodeId
(),
false
);
if
(
jobId
!=
null
)
{
fileDAO
.
setBusy
(
fileInfo
.
getNodeId
(),
false
);
}
}
}
...
...
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