Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f173b9d8
authored
Jun 03, 2015
by
Juho Juopperi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'vectorama2014api' of gitlab.codecrew.fi:liv/moya into vectorama2014api
2 parents
49accc3b
6a16b7ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/UserRestViewV2.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/UserPojo.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/UserRestViewV2.java
View file @
f173b9d
...
...
@@ -106,10 +106,12 @@ public class UserRestViewV2 {
eventUser
.
setGender
(
Gender
.
UNDEFINED
);
}
eventUser
.
setPhone
(
userPojo
.
phoneNumber
);
eventUser
.
setEmail
(
userPojo
.
email
);
eventUser
.
setAddress
(
userPojo
.
streetAddress
);
eventUser
.
setZip
(
userPojo
.
zipCode
);
eventUser
.
setTown
(
userPojo
.
postOffice
);
userBean
.
createNewUser
(
eventUser
,
null
);
userBean
.
createNewUser
(
eventUser
,
userPojo
.
password
);
return
Response
.
ok
(
pojoFactory
.
createUserPojo
(
eventUser
)).
build
();
}
catch
(
Exception
e
)
{
...
...
@@ -132,14 +134,18 @@ public class UserRestViewV2 {
public
Response
updateUserImage
(
@Context
HttpServletRequest
request
,
@PathParam
(
"userid"
)
@ApiParam
(
"User ID"
)
Integer
userId
,
@FormDataParam
(
"image"
)
FormDataContentDisposition
imageInfo
,
@FormDataParam
(
"image"
)
InputStream
imageStream
)
{
@FormDataParam
(
"image"
)
InputStream
imageStream
,
@FormDataParam
(
"image"
)
FormDataBodyPart
body
)
{
logger
.
info
(
"Starting to upload new user image for user {}"
,
userId
);
try
{
if
(
permissionBean
.
hasPermission
(
UserPermission
.
MODIFY
)
==
false
||
permissionBean
.
hasPermission
(
UserPermission
.
VIEW_ALL
)
==
false
)
{
return
Response
.
status
(
Response
.
Status
.
FORBIDDEN
).
build
();
}
EventUser
eventUser
=
userBean
.
findByUserId
(
userId
,
true
);
userBean
.
uploadImage
(
eventUser
,
imageInfo
.
getType
(),
imageStream
,
imageInfo
.
getFileName
(),
null
);
logger
.
info
(
"Mimetype: "
+
body
.
getMediaType
());
userBean
.
uploadImage
(
eventUser
,
body
.
getMediaType
().
getType
(),
imageStream
,
imageInfo
.
getFileName
(),
null
);
logger
.
info
(
"Image uploaded"
);
return
Response
.
ok
(
pojoFactory
.
createUserPojo
(
eventUser
)).
build
();
...
...
@@ -157,12 +163,15 @@ public class UserRestViewV2 {
@GET
@Path
(
"/{userid}/image"
)
@ApiOperation
(
value
=
"Download user image"
)
@Consumes
(
MediaType
.
MULTIPART_FORM_DATA
)
@Produces
({
MediaType
.
APPLICATION_JSON
,
"image/png"
,
"image/jpeg"
})
//@Consumes()
//@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
//@Produces({MediaType.APPLICATION_JSON, "image/png", "image/jpeg"})
//@Produces({MediaType.MULTIPART_FORM_DATA, "image/png", "image/jpeg"})
public
Response
downloadUserImage
(
@PathParam
(
"userid"
)
@ApiParam
(
"User ID"
)
Integer
userId
)
{
try
{
User
user
=
userBean
.
getUser
(
userId
);
UserImage
image
=
user
.
getCurrentImage
();
//logger.info("Mimetype: " + body.getMediaType());
return
Response
.
ok
(
image
.
getImageData
(),
image
.
getMimeType
()).
build
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"Getting image failed"
,
e
);
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/UserPojo.java
View file @
f173b9d
...
...
@@ -24,11 +24,13 @@ public class UserPojo {
public
Integer
userId
=
0
;
public
String
firstname
=
""
;
public
String
lastname
=
""
;
public
String
password
=
""
;
// foo..
public
Date
birthday
;
public
UserGender
gender
;
public
String
phoneNumber
;
public
String
email
;
// address info
public
String
streetAddress
;
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment