Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
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 8c0322bd
authored
Mar 29, 2015
by
Juho Juopperi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rest annotations and return types
1 parent
83117e3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/util/v1/ErrorRoot.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/util/v1/ErrorRoot.java
View file @
8c0322b
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
util
.
v1
;
import
com.wordnik.swagger.annotations.ApiModel
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
@ApiModel
public
class
ErrorRoot
{
private
String
error
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
View file @
8c0322b
...
...
@@ -310,7 +310,7 @@ public class UserRestView {
@POST
@Path
(
"/{userid}/check-password"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
@ApiOperation
(
value
=
"Check user password"
)
@ApiOperation
(
value
=
"Check user password"
,
response
=
EventUserRestPojo
.
class
)
@Consumes
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
public
Response
checkPassword
(
@PathParam
(
"userid"
)
@ApiParam
(
"User ID"
)
Integer
userId
,
@FormParam
(
"password"
)
@ApiParam
(
"Password"
)
String
password
)
{
...
...
@@ -337,7 +337,7 @@ public class UserRestView {
@POST
@Path
(
"/{userid}/reset-password"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
@ApiOperation
(
value
=
"Reset user password"
)
@ApiOperation
(
value
=
"Reset user password"
,
response
=
EventUserRestPojo
.
class
)
@Consumes
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
public
Response
resetPassword
(
@PathParam
(
"userid"
)
@ApiParam
(
"User ID"
)
Integer
userId
,
@FormParam
(
"password"
)
@ApiParam
(
"New password"
)
String
password
)
{
...
...
@@ -352,24 +352,28 @@ public class UserRestView {
}
}
/**
* Post forma parameter "image" with the image data in it.
* @param request
* @param userId
* @return
* @throws IOException
*/
@PUT
@Path
(
"/{user
I
d}/image"
)
@ApiOperation
(
value
=
"Upload image"
)
@Consumes
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
@Path
(
"/{user
i
d}/image"
)
@ApiOperation
(
value
=
"Upload image"
,
response
=
EventUserRestPojo
.
class
)
@Consumes
(
MediaType
.
MULTIPART_FORM_DATA
)
public
Response
updateUserImage
(
@Context
HttpServletRequest
request
,
@PathParam
(
"user
I
d"
)
@ApiParam
(
"User ID"
)
Integer
userId
)
throws
IOException
{
@PathParam
(
"user
i
d"
)
@ApiParam
(
"User ID"
)
Integer
userId
)
throws
IOException
{
try
{
Part
imagePart
=
request
.
getPart
(
"image"
);
User
user
=
userbean
.
getUser
(
userId
);
EventUser
eventUser
=
userbean
.
getEventUser
(
user
,
true
);
EventUser
eventUser
=
userbean
.
findByUserId
(
userId
,
true
);
UserImage
userImage
=
userbean
.
uploadImage
(
eventUser
,
imagePart
.
getContentType
(),
imagePart
.
getInputStream
(),
imagePart
.
getSubmittedFileName
(),
null
);
return
Response
.
ok
().
build
();
return
Response
.
ok
(
PojoUtils
.
initEventUserRestPojo
(
eventUser
)).
build
();
}
catch
(
ServletException
e
)
{
logger
.
error
(
"Updating user image failed"
,
e
);
return
Response
.
serverError
().
build
();
return
Response
.
serverError
().
entity
(
PojoUtils
.
initErrorPojo
(
"Updating user image failed"
)).
build
();
}
}
...
...
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