Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
a22bbce1
Commit
a22bbce1
authored
Jul 25, 2019
by
Piotr Gawron
Browse files
we should properly handle nulls
parent
9f2292ea
Changes
4
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/files/FileController.java
View file @
a22bbce1
...
...
@@ -42,7 +42,7 @@ public class FileController extends BaseController {
@PreAuthorize
(
"@fileService.getOwnerByFileId(#id)?.login == authentication.name"
)
@PostMapping
(
value
=
"/{id}:uploadContent"
)
public
Map
<
String
,
Object
>
uploadContent
(
@PathVariable
(
value
=
"id"
)
String
id
,
@RequestBody
byte
[]
data
)
public
Map
<
String
,
Object
>
uploadContent
(
@PathVariable
(
value
=
"id"
)
Integer
id
,
@RequestBody
byte
[]
data
)
throws
ObjectNotFoundException
{
return
fileRest
.
uploadContent
(
id
,
data
);
}
...
...
rest-api/src/main/java/lcsb/mapviewer/api/files/FileRestImpl.java
View file @
a22bbce1
...
...
@@ -60,7 +60,7 @@ public class FileRestImpl extends BaseRestImpl {
return
result
;
}
public
Map
<
String
,
Object
>
uploadContent
(
String
id
,
byte
[]
data
)
throws
ObjectNotFoundException
{
public
Map
<
String
,
Object
>
uploadContent
(
Integer
id
,
byte
[]
data
)
throws
ObjectNotFoundException
{
int
fileId
=
Integer
.
valueOf
(
id
);
UploadedFileEntry
fileEntry
=
uploadedFileEntryDao
.
getById
(
fileId
);
if
(
fileEntry
==
null
)
{
...
...
service/src/main/java/lcsb/mapviewer/services/impl/FileService.java
View file @
a22bbce1
...
...
@@ -21,20 +21,22 @@ public class FileService implements IFileService {
}
@Override
public
UploadedFileEntry
getById
(
i
nt
id
)
{
public
UploadedFileEntry
getById
(
I
nt
eger
id
)
{
return
uploadedFileEntryDao
.
getById
(
id
);
}
@Override
public
User
getOwnerByFileId
(
i
nt
id
)
{
UploadedFileEntry
entry
=
uploadedFileEntryDao
.
getById
(
id
);
if
(
entry
!
=
null
&&
e
ntry
.
get
Owner
()
!=
null
)
{
//it's lazy initialized
entry
.
getOwner
().
getLogin
();
return
uploadedFileE
ntry
Dao
.
get
ById
(
id
).
getOwner
();
}
else
{
return
null
;
public
User
getOwnerByFileId
(
I
nt
eger
id
)
{
if
(
id
!=
null
)
{
UploadedFileEntry
entry
=
uploadedFileE
ntry
Dao
.
get
ById
(
id
);
if
(
entry
!=
null
&&
entry
.
getOwner
()
!=
null
)
{
// it's lazy initialized
e
ntry
.
get
Owner
().
getLogin
();
return
uploadedFileEntryDao
.
getById
(
id
).
getOwner
();
}
}
return
null
;
}
}
service/src/main/java/lcsb/mapviewer/services/interfaces/IFileService.java
View file @
a22bbce1
...
...
@@ -5,8 +5,8 @@ import lcsb.mapviewer.model.user.User;
public
interface
IFileService
{
UploadedFileEntry
getById
(
i
nt
id
);
UploadedFileEntry
getById
(
I
nt
eger
id
);
User
getOwnerByFileId
(
i
nt
id
);
User
getOwnerByFileId
(
I
nt
eger
id
);
}
Write
Preview
Markdown
is supported
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