Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor 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
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
5c3ea522
Commit
5c3ea522
authored
9 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-1809: log a warning if the item cannot be found
parent
001d56f1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/core/commons/modules/bc/FileUploadController.java
+19
-18
19 additions, 18 deletions
...rg/olat/core/commons/modules/bc/FileUploadController.java
with
19 additions
and
18 deletions
src/main/java/org/olat/core/commons/modules/bc/FileUploadController.java
+
19
−
18
View file @
5c3ea522
...
@@ -334,25 +334,18 @@ public class FileUploadController extends FormBasicController {
...
@@ -334,25 +334,18 @@ public class FileUploadController extends FormBasicController {
// if so, there is alread a error-msg in log (vfsContainer.createChildLeaf)
// if so, there is alread a error-msg in log (vfsContainer.createChildLeaf)
success
=
false
;
success
=
false
;
}
else
{
}
else
{
InputStream
in
=
null
;
try
(
InputStream
in
=
new
FileInputStream
(
uploadedFile
);
OutputStream
out
=
null
;
OutputStream
out
=
newFile
.
getOutputStream
(
false
))
{
try
{
in
=
new
FileInputStream
(
uploadedFile
);
out
=
newFile
.
getOutputStream
(
false
);
FileUtils
.
bcopy
(
in
,
out
,
"uploadTmpFileToDestFile"
);
FileUtils
.
bcopy
(
in
,
out
,
"uploadTmpFileToDestFile"
);
uploadedFile
.
delete
();
uploadedFile
.
delete
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
success
=
false
;
success
=
false
;
}
finally
{
FileUtils
.
closeSafely
(
in
);
FileUtils
.
closeSafely
(
out
);
}
}
}
}
if
(
success
)
{
if
(
success
)
{
String
filePath
=
(
uploadRelPath
==
null
?
""
:
uploadRelPath
+
"/"
)
+
newFile
.
getName
();
String
filePath
=
(
uploadRelPath
==
null
?
""
:
uploadRelPath
+
"/"
)
+
newFile
.
getName
();
finishSuccessfullUpload
(
filePath
,
ureq
);
finishSuccessfullUpload
(
filePath
,
newFile
,
ureq
);
fileInfoMBean
.
logUpload
(
newFile
.
getSize
());
fileInfoMBean
.
logUpload
(
newFile
.
getSize
());
fireEvent
(
ureq
,
Event
.
DONE_EVENT
);
fireEvent
(
ureq
,
Event
.
DONE_EVENT
);
}
else
{
}
else
{
...
@@ -671,16 +664,20 @@ public class FileUploadController extends FormBasicController {
...
@@ -671,16 +664,20 @@ public class FileUploadController extends FormBasicController {
private
void
finishUpload
(
UserRequest
ureq
)
{
private
void
finishUpload
(
UserRequest
ureq
)
{
// in both cases the upload must be finished and notified with a FolderEvent
// in both cases the upload must be finished and notified with a FolderEvent
String
filePath
=
(
uploadRelPath
==
null
?
""
:
uploadRelPath
+
"/"
)
+
newFile
.
getName
();
String
filePath
=
(
uploadRelPath
==
null
?
""
:
uploadRelPath
+
"/"
)
+
newFile
.
getName
();
finishSuccessfullUpload
(
filePath
,
ureq
);
VFSItem
item
=
currentContainer
.
resolve
(
filePath
);
fileInfoMBean
.
logUpload
(
newFile
.
getSize
());
if
(
item
!=
null
)
{
finishSuccessfullUpload
(
filePath
,
item
,
ureq
);
fileInfoMBean
.
logUpload
(
newFile
.
getSize
());
}
else
{
logWarn
(
"Upload with error:"
+
filePath
,
null
);
}
fireEvent
(
ureq
,
Event
.
DONE_EVENT
);
fireEvent
(
ureq
,
Event
.
DONE_EVENT
);
}
}
/**
/**
* Internal helper to finish the upload and add metadata
* Internal helper to finish the upload and add metadata
*/
*/
private
void
finishSuccessfullUpload
(
String
filePath
,
UserRequest
ureq
)
{
private
void
finishSuccessfullUpload
(
String
filePath
,
VFSItem
item
,
UserRequest
ureq
)
{
VFSItem
item
=
currentContainer
.
resolve
(
filePath
);
if
(
item
instanceof
OlatRootFileImpl
)
{
if
(
item
instanceof
OlatRootFileImpl
)
{
OlatRootFileImpl
relPathItem
=
(
OlatRootFileImpl
)
item
;
OlatRootFileImpl
relPathItem
=
(
OlatRootFileImpl
)
item
;
// create meta data
// create meta data
...
@@ -692,10 +689,14 @@ public class FileUploadController extends FormBasicController {
...
@@ -692,10 +689,14 @@ public class FileUploadController extends FormBasicController {
meta
.
clearThumbnails
();
//if overwrite an older file
meta
.
clearThumbnails
();
//if overwrite an older file
meta
.
write
();
meta
.
write
();
}
}
ThreadLocalUserActivityLogger
.
log
(
FolderLoggingAction
.
FILE_UPLOADED
,
getClass
(),
CoreLoggingResourceable
.
wrapUploadFile
(
filePath
));
if
(
item
==
null
)
{
// Notify listeners about upload
logError
(
"File cannot be uploaded: "
+
filePath
,
null
);
fireEvent
(
ureq
,
new
FolderEvent
(
FolderEvent
.
UPLOAD_EVENT
,
item
));
}
else
{
ThreadLocalUserActivityLogger
.
log
(
FolderLoggingAction
.
FILE_UPLOADED
,
getClass
(),
CoreLoggingResourceable
.
wrapUploadFile
(
filePath
));
// Notify listeners about upload
fireEvent
(
ureq
,
new
FolderEvent
(
FolderEvent
.
UPLOAD_EVENT
,
item
));
}
}
}
/**
/**
...
...
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