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
adcce1b7
Commit
adcce1b7
authored
Mar 09, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement register teams command
parent
012cb848
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
9 deletions
+44
-9
CTFApplication.java
service/src/main/java/CTFApplication.java
+2
-0
RegisterTeamsCommand.java
service/src/main/java/commands/RegisterTeamsCommand.java
+42
-0
TeamsRepository.java
service/src/main/java/repositories/TeamsRepository.java
+0
-9
No files found.
service/src/main/java/CTFApplication.java
View file @
adcce1b7
...
@@ -6,6 +6,7 @@ import com.google.inject.Injector;
...
@@ -6,6 +6,7 @@ import com.google.inject.Injector;
import
com.mongodb.MongoClient
;
import
com.mongodb.MongoClient
;
import
commands.PurgeDatabaseCommand
;
import
commands.PurgeDatabaseCommand
;
import
commands.RegisterTasksCommand
;
import
commands.RegisterTasksCommand
;
import
commands.RegisterTeamsCommand
;
import
core.ApplicationConfiguration
;
import
core.ApplicationConfiguration
;
import
io.dropwizard.Application
;
import
io.dropwizard.Application
;
import
io.dropwizard.assets.AssetsBundle
;
import
io.dropwizard.assets.AssetsBundle
;
...
@@ -37,6 +38,7 @@ public class CTFApplication extends Application<ApplicationConfiguration>
...
@@ -37,6 +38,7 @@ public class CTFApplication extends Application<ApplicationConfiguration>
bootstrap
.
addBundle
(
new
AssetsBundle
(
"/assets"
,
"/page"
,
"index.html"
));
bootstrap
.
addBundle
(
new
AssetsBundle
(
"/assets"
,
"/page"
,
"index.html"
));
bootstrap
.
addCommand
(
new
PurgeDatabaseCommand
());
bootstrap
.
addCommand
(
new
PurgeDatabaseCommand
());
bootstrap
.
addCommand
(
new
RegisterTasksCommand
());
bootstrap
.
addCommand
(
new
RegisterTasksCommand
());
bootstrap
.
addCommand
(
new
RegisterTeamsCommand
());
Stream
.
of
(
"org.webjars.npm"
,
"org.webjars.bower"
)
Stream
.
of
(
"org.webjars.npm"
,
"org.webjars.bower"
)
.
map
(
WebJarBundle:
:
new
)
.
map
(
WebJarBundle:
:
new
)
.
forEach
(
bootstrap:
:
addBundle
);
.
forEach
(
bootstrap:
:
addBundle
);
...
...
service/src/main/java/commands/RegisterTeamsCommand.java
0 → 100644
View file @
adcce1b7
package
commands
;
import
com.google.inject.Guice
;
import
com.google.inject.Injector
;
import
core.ApplicationConfiguration
;
import
io.dropwizard.cli.ConfiguredCommand
;
import
io.dropwizard.setup.Bootstrap
;
import
modules.ApplicationModule
;
import
net.sourceforge.argparse4j.inf.Namespace
;
import
org.mongodb.morphia.Datastore
;
import
repositories.TeamsRepository
;
public
class
RegisterTeamsCommand
extends
ConfiguredCommand
<
ApplicationConfiguration
>
{
private
static
final
String
COMMAND_NAME
=
"registertasks"
;
private
static
final
String
COMMAND_DESCRIPTION
=
"Register tasks"
;
public
RegisterTeamsCommand
()
{
super
(
COMMAND_NAME
,
COMMAND_DESCRIPTION
);
}
private
void
initializeTasks
(
ApplicationConfiguration
applicationConfiguration
,
Injector
injector
)
{
Datastore
datastore
=
injector
.
getInstance
(
Datastore
.
class
);
TeamsRepository
teamsRepository
=
injector
.
getInstance
(
TeamsRepository
.
class
);
teamsRepository
.
clean
();
applicationConfiguration
.
getTeams
().
forEach
(
team
->
{
team
.
getMembers
().
stream
().
forEach
(
datastore:
:
save
);
//todo: use usersrepostiroy to save?
datastore
.
save
(
team
);
});
}
@Override
protected
void
run
(
Bootstrap
<
ApplicationConfiguration
>
bootstrap
,
Namespace
namespace
,
ApplicationConfiguration
applicationConfiguration
)
throws
Exception
{
//todo: move and merge with app setup
Injector
injector
=
Guice
.
createInjector
(
new
ApplicationModule
(
applicationConfiguration
));
initializeTasks
(
applicationConfiguration
,
injector
);
}
}
service/src/main/java/repositories/TeamsRepository.java
View file @
adcce1b7
...
@@ -48,15 +48,6 @@ public class TeamsRepository implements Repository {
...
@@ -48,15 +48,6 @@ public class TeamsRepository implements Repository {
return
datastore
.
createQuery
(
Team
.
class
).
asList
();
return
datastore
.
createQuery
(
Team
.
class
).
asList
();
}
}
//todo: move to command
public
void
initialize
()
{
this
.
clean
();
applicationConfiguration
.
getTeams
().
forEach
(
team
->
{
team
.
getMembers
().
stream
().
forEach
(
user
->
datastore
.
save
(
user
));
datastore
.
save
(
team
);
});
}
//todo: move to interface
//todo: move to interface
//todo: use default as interface-implemented methods
//todo: use default as interface-implemented methods
public
void
add
(
Team
team
)
{
public
void
add
(
Team
team
)
{
...
...
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