Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CTF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grzegorz
CTF
Commits
49cd7aab
Commit
49cd7aab
authored
Mar 19, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
team solutions endpoint stub
parent
e568a1ce
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
SolutionsRepository.java
...ers/krakyournet/ctf/repositories/SolutionsRepository.java
+6
-0
SolutionsResource.java
...ephoners/krakyournet/ctf/resources/SolutionsResource.java
+24
-6
No files found.
service/src/main/java/com/telephoners/krakyournet/ctf/repositories/SolutionsRepository.java
View file @
49cd7aab
package
com
.
telephoners
.
krakyournet
.
ctf
.
repositories
;
import
com.telephoners.krakyournet.ctf.objects.Solution
;
import
com.telephoners.krakyournet.ctf.objects.Team
;
import
org.mongodb.morphia.Datastore
;
import
javax.inject.Inject
;
...
...
@@ -25,4 +26,9 @@ public class SolutionsRepository implements Repository
datastore
.
save
(
solution
);
//todo: error handling?
//todo: do not add if already exists
}
public
void
getByTeam
(
Team
team
)
{
}
}
\ No newline at end of file
service/src/main/java/com/telephoners/krakyournet/ctf/resources/SolutionsResource.java
View file @
49cd7aab
package
com
.
telephoners
.
krakyournet
.
ctf
.
resources
;
import
com.telephoners.krakyournet.ctf.objects.Solution
;
import
com.telephoners.krakyournet.ctf.objects.Team
;
import
com.telephoners.krakyournet.ctf.objects.User
;
import
com.telephoners.krakyournet.ctf.repositories.SolutionsRepository
;
import
com.telephoners.krakyournet.ctf.repositories.TasksRepository
;
import
com.telephoners.krakyournet.ctf.repositories.TeamsRepository
;
import
io.dropwizard.auth.Auth
;
import
javax.inject.Inject
;
...
...
@@ -16,21 +18,26 @@ import javax.ws.rs.core.MediaType;
import
javax.ws.rs.core.Response
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@Singleton
@Path
(
value
=
"/solutions"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
class
SolutionsResource
{
public
class
SolutionsResource
{
private
TeamsRepository
teamsRepository
;
private
SolutionsRepository
solutionsRepository
;
private
TasksRepository
tasksRepository
;
@Inject
public
SolutionsResource
(
SolutionsRepository
solutionsRepository
,
TasksRepository
tasksRepository
)
{
public
SolutionsResource
(
SolutionsRepository
solutionsRepository
,
TasksRepository
tasksRepository
,
TeamsRepository
teamsRepository
)
{
this
.
solutionsRepository
=
solutionsRepository
;
this
.
tasksRepository
=
tasksRepository
;
this
.
teamsRepository
=
teamsRepository
;
}
@POST
...
...
@@ -43,14 +50,25 @@ public class SolutionsResource {
return
Response
.
status
(
Response
.
Status
.
NOT_ACCEPTABLE
).
build
();
}
@GET
@Path
(
"/my"
)
public
void
getTeamSolutions
(
@Auth
User
user
)
{
Optional
<
Team
>
team
=
teamsRepository
.
getTeamByUser
(
user
);
solutionsRepository
.
getByTeam
(
team
.
get
())
}
@GET
@Path
(
"/all"
)
public
Map
<
String
,
List
<
String
>>
getTeamsSolutions
()
{
public
Map
<
String
,
List
<
String
>>
getTeamsSolutions
()
{
return
solutionsRepository
.
getAll
()
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
new
Function
<
Solution
,
String
>()
{
.
collect
(
Collectors
.
groupingBy
(
new
Function
<
Solution
,
String
>()
{
@Override
public
String
apply
(
Solution
solution
)
{
public
String
apply
(
Solution
solution
)
{
return
solution
.
getTask
().
getName
();
}
}))
...
...
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