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
aa63ac88
Commit
aa63ac88
authored
Mar 21, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move getAll to repository
parent
322f305c
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
29 deletions
+15
-29
RegisterTasksCommand.java
...honers/krakyournet/ctf/commands/RegisterTasksCommand.java
+1
-1
RegisterTeamsCommand.java
...honers/krakyournet/ctf/commands/RegisterTeamsCommand.java
+1
-1
Repository.java
.../telephoners/krakyournet/ctf/repositories/Repository.java
+13
-6
SolutionsRepository.java
...ers/krakyournet/ctf/repositories/SolutionsRepository.java
+0
-5
TasksRepository.java
...phoners/krakyournet/ctf/repositories/TasksRepository.java
+0
-5
TeamsRepository.java
...phoners/krakyournet/ctf/repositories/TeamsRepository.java
+0
-5
UsersRepository.java
...phoners/krakyournet/ctf/repositories/UsersRepository.java
+0
-6
No files found.
service/src/main/java/com/telephoners/krakyournet/ctf/commands/RegisterTasksCommand.java
View file @
aa63ac88
...
@@ -23,7 +23,7 @@ public class RegisterTasksCommand extends ConfiguredCommand<ApplicationConfigura
...
@@ -23,7 +23,7 @@ public class RegisterTasksCommand extends ConfiguredCommand<ApplicationConfigura
super
(
COMMAND_NAME
,
COMMAND_DESCRIPTION
);
super
(
COMMAND_NAME
,
COMMAND_DESCRIPTION
);
}
}
private
void
initializeTasks
(
ApplicationConfiguration
applicationConfiguration
,
Injector
injector
)
throws
ClassNotFoundException
private
void
initializeTasks
(
ApplicationConfiguration
applicationConfiguration
,
Injector
injector
)
{
{
TasksRepository
tasksRepository
=
injector
.
getInstance
(
TasksRepository
.
class
);
TasksRepository
tasksRepository
=
injector
.
getInstance
(
TasksRepository
.
class
);
...
...
service/src/main/java/com/telephoners/krakyournet/ctf/commands/RegisterTeamsCommand.java
View file @
aa63ac88
...
@@ -20,7 +20,7 @@ public class RegisterTeamsCommand extends ConfiguredCommand<ApplicationConfigura
...
@@ -20,7 +20,7 @@ public class RegisterTeamsCommand extends ConfiguredCommand<ApplicationConfigura
super
(
COMMAND_NAME
,
COMMAND_DESCRIPTION
);
super
(
COMMAND_NAME
,
COMMAND_DESCRIPTION
);
}
}
private
void
initializeTasks
(
ApplicationConfiguration
applicationConfiguration
,
Injector
injector
)
throws
ClassNotFoundException
private
void
initializeTasks
(
ApplicationConfiguration
applicationConfiguration
,
Injector
injector
)
{
{
TeamsRepository
teamsRepository
=
injector
.
getInstance
(
TeamsRepository
.
class
);
TeamsRepository
teamsRepository
=
injector
.
getInstance
(
TeamsRepository
.
class
);
UsersRepository
usersRepository
=
injector
.
getInstance
(
UsersRepository
.
class
);
UsersRepository
usersRepository
=
injector
.
getInstance
(
UsersRepository
.
class
);
...
...
service/src/main/java/com/telephoners/krakyournet/ctf/repositories/Repository.java
View file @
aa63ac88
...
@@ -20,21 +20,28 @@ public abstract class Repository<T>
...
@@ -20,21 +20,28 @@ public abstract class Repository<T>
{
{
}
}
abstract
List
<
T
>
getAll
();
public
void
add
(
T
item
)
public
void
add
(
T
item
)
{
{
datastore
.
save
(
item
);
datastore
.
save
(
item
);
}
}
Class
getRepositoryType
()
throws
ClassNotFoundException
public
List
<
T
>
getAll
()
{
{
return
Class
.
forName
((((
ParameterizedType
)
this
.
getClass
().
getGenericSuperclass
())
//todo: unchecked cast
.
getActualTypeArguments
()[
0
]).
getTypeName
()
);
return
datastore
.
createQuery
(
getRepositoryType
()).
asList
(
);
}
}
public
void
clean
()
throws
ClassNotFoundException
public
void
clean
()
{
{
datastore
.
getCollection
(
getRepositoryType
()).
drop
();
datastore
.
getCollection
(
getRepositoryType
()).
drop
();
}
}
Class
getRepositoryType
()
{
try
{
return
Class
.
forName
((((
ParameterizedType
)
this
.
getClass
().
getGenericSuperclass
())
.
getActualTypeArguments
()[
0
]).
getTypeName
());
}
catch
(
ClassNotFoundException
e
)
{
throw
new
IllegalStateException
(
"Class not found"
);
}
}
}
}
service/src/main/java/com/telephoners/krakyournet/ctf/repositories/SolutionsRepository.java
View file @
aa63ac88
...
@@ -25,11 +25,6 @@ public class SolutionsRepository extends Repository<Solution>
...
@@ -25,11 +25,6 @@ public class SolutionsRepository extends Repository<Solution>
{
{
}
}
public
List
<
Solution
>
getAll
()
{
return
datastore
.
createQuery
(
Solution
.
class
).
asList
();
}
public
List
<
Solution
>
getByTeam
(
Team
team
)
public
List
<
Solution
>
getByTeam
(
Team
team
)
{
{
//todo: merge with upper
//todo: merge with upper
...
...
service/src/main/java/com/telephoners/krakyournet/ctf/repositories/TasksRepository.java
View file @
aa63ac88
...
@@ -53,11 +53,6 @@ public class TasksRepository extends Repository<Task>
...
@@ -53,11 +53,6 @@ public class TasksRepository extends Repository<Task>
.
asList
();
.
asList
();
}
}
public
List
<
Task
>
getAll
()
{
return
datastore
.
createQuery
(
Task
.
class
).
asList
();
}
//todo: refactor?
//todo: refactor?
public
Map
<
List
<
String
>,
Integer
>
getUserFlagsHashes
(
String
username
)
public
Map
<
List
<
String
>,
Integer
>
getUserFlagsHashes
(
String
username
)
{
{
...
...
service/src/main/java/com/telephoners/krakyournet/ctf/repositories/TeamsRepository.java
View file @
aa63ac88
...
@@ -42,9 +42,4 @@ public class TeamsRepository extends Repository<Team>
...
@@ -42,9 +42,4 @@ public class TeamsRepository extends Repository<Team>
{
{
}
}
public
List
<
Team
>
getAll
()
{
return
datastore
.
createQuery
(
Team
.
class
).
asList
();
}
}
}
service/src/main/java/com/telephoners/krakyournet/ctf/repositories/UsersRepository.java
View file @
aa63ac88
...
@@ -41,10 +41,4 @@ public class UsersRepository extends Repository<User>
...
@@ -41,10 +41,4 @@ public class UsersRepository extends Repository<User>
.
field
(
"password"
).
equal
(
Hex
.
encodeHexString
(
messageDigest
.
digest
(
basicCredentials
.
getPassword
().
getBytes
())))
.
field
(
"password"
).
equal
(
Hex
.
encodeHexString
(
messageDigest
.
digest
(
basicCredentials
.
getPassword
().
getBytes
())))
.
get
();
.
get
();
}
}
@Override
public
List
getAll
()
{
return
null
;
}
}
}
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