Build on top of Dropwizard framework, the default database implementation is H2 and the database is located into target/db. To see an example of usages for MySql please point to the test cases
TMS uses JPA (hibernate) for storing the data into database.
Schema
The DB schema has been managed using the dropwizard-migrations module. Please find the definition on the project resource folder.
Entity
The first implementation uses two entities
- Activity.java to manage the task list
- User.java to manage the users list
predefined users are
<insert tableName="users">
<column name="username">auth</column>
<column name="password">secret</column>
<column name="role">AUTHENTICATED</column>
</insert>
<insert tableName="users">
<column name="username">basic</column>
<column name="password">secret</column>
<column name="role">BASIC</column>
</insert>
The entity contains all tasks created by the user. The not authenticated users will store the activity as GUEST so all can reads/writes elements. Authenticated users have their own space in the database.
The DB access is regulated from an interface ActivityRepository.java
Authentication
The server uses a Basic Authentication all RESTs have an optional authentication, so the app works also if the users are not authenticated. The only REST api that requires authentication is the remove all data from database.:
@DELETE
@UnitOfWork
@RolesAllowed("AUTHENTICATED")
public Response removeAll()`
For semplicity I’ve implemented a LoginController.java to handle a very-very basic auth.
REST
The REST APIs are defined in ActivityController.java and the CRUD APIs are documented with OpenAPI annotation, here is a screenshot that shows the exposed APIs