// Path: rest/java/src/main/java/de/hda/fbi/ds/mbredel/configuration/ConfigurationService.java
// public interface ConfigurationService {
//     /**
//      * Get a configuration property of a given basic {@code type}.
//      *
//      * @param key The configuration key.
//      * @param <T> The property type.
//      * @throws NoSuchElementException When the provided {@code key} doesn't have a corresponding config value
//      * @throws IllegalArgumentException When property can't be converted to {@code type}
//      * @throws IllegalStateException When provider is unable to fetch configuration value for the given {@code key}
//      */
//     @Nullable
//     <T> T getProperty(String key, Class<T> type);
// 
//     /**
//      * Get a configuration property of a given basic {@code type}.
//      *
//      * @param key The configuration key.
//      * @param defaultValue The default value. Has to be the same type as property type.
//      * @param <T> The property type.
//      * @throws IllegalArgumentException When property can't be converted to {@code type}
//      */
//     @Nonnull
//     <T> T getProperty(String key, Object defaultValue, Class<T> type);
// }
// 
// Path: rest/java/src/main/java/de/hda/fbi/ds/mbredel/model/User.java
// public class User {
//     public String name;
//     public String surname;
//     public String username;
//     public String password;
// }
// 
// Path: rest/java/src/main/java/de/hda/fbi/ds/mbredel/store/StoreService.java
// public interface StoreService {
//     /**
//      * Extracts the uploaded file form the HTTP
//      * request and stores it using the filename.
//      *
//      * @param user The user object to store.
//      * @return The username as the primary key of the user object.
//      * @throws PersistenceException When the file cannot be stored.
//      * @throws IllegalArgumentException When at least one of the arguments is null.
//      */
//     @Nonnull
//     String create(User user) throws PersistenceException, IllegalArgumentException;
// 
//     /**
//      * Read and return a file by its file name.
//      *
//      * @param username The username that acts as primary key.
//      * @return The user.
//      * @throws IllegalArgumentException When the arguments is null.
//      */
//     @Nullable
//     User read(String username) throws IllegalArgumentException;
// 
//     /**
//      * Read and return all users stored in
//      * the image store.
//      *
//      * @return A list of all users in the store. The list might be empty.
//      */
//     @Nonnull
//     Collection<User> readAll();
// 
//     /**
//      * Delete the file by its file name.
//      *
//      * @param username The username that acts as primary key.
//      * @return The name of the file that has been deleted successfully.
//      * @throws PersistenceException When the file cannot be deleted.
//      * @throws IllegalArgumentException When the arguments is null.
//      */
//     @Nonnull
//     User delete(String username) throws PersistenceException, IllegalArgumentException;
// }


import javax.inject.Inject;
import java.io.IOException;
import static spark.Spark.halt;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.hda.fbi.ds.mbredel.configuration.ConfigurationService;
import de.hda.fbi.ds.mbredel.model.User;
import de.hda.fbi.ds.mbredel.store.StoreService;
import org.apache.http.HttpStatus;
import spark.Request;
import spark.Response;
     * @return The HTTP status and, in case of success, the user.
     */
    public String getUser(Request req, Response res) {

        String username = req.params(":username");
        User user = this.storeService.read(username);
        if (user == null) {
            halt(HttpStatus.SC_NOT_FOUND);
        }

        String result = "";
        ObjectMapper mapper = new ObjectMapper();
        try {
            result = mapper.writeValueAsString(this.storeService.read(username));
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return result;
    }

    /**
     * Create a new user.
     *
     * @param req The HTTP request information.
     * @param res The HTTP response information.
     * @return The HTTP status and, in case of success, the image or a list of images.
     */
    public String postUsers(Request req, Response res) {
        ObjectMapper mapper = new ObjectMapper();
        try {
// Path: rest/java/src/main/java/de/hda/fbi/ds/mbredel/configuration/ConfigurationService.java
// public interface ConfigurationService {
//     /**
//      * Get a configuration property of a given basic {@code type}.
//      *
//      * @param key The configuration key.
//      * @param <T> The property type.
//      * @throws NoSuchElementException When the provided {@code key} doesn't have a corresponding config value
//      * @throws IllegalArgumentException When property can't be converted to {@code type}
//      * @throws IllegalStateException When provider is unable to fetch configuration value for the given {@code key}
//      */
//     @Nullable
//     <T> T getProperty(String key, Class<T> type);
// 
//     /**
//      * Get a configuration property of a given basic {@code type}.
//      *
//      * @param key The configuration key.
//      * @param defaultValue The default value. Has to be the same type as property type.
//      * @param <T> The property type.
//      * @throws IllegalArgumentException When property can't be converted to {@code type}
//      */
//     @Nonnull
//     <T> T getProperty(String key, Object defaultValue, Class<T> type);
// }
// 
// Path: rest/java/src/main/java/de/hda/fbi/ds/mbredel/model/User.java
// public class User {
//     public String name;
//     public String surname;
//     public String username;
//     public String password;
// }
// 
// Path: rest/java/src/main/java/de/hda/fbi/ds/mbredel/store/StoreService.java
// public interface StoreService {
//     /**
//      * Extracts the uploaded file form the HTTP
//      * request and stores it using the filename.
//      *
//      * @param user The user object to store.
//      * @return The username as the primary key of the user object.
//      * @throws PersistenceException When the file cannot be stored.
//      * @throws IllegalArgumentException When at least one of the arguments is null.
//      */
//     @Nonnull
//     String create(User user) throws PersistenceException, IllegalArgumentException;
// 
//     /**
//      * Read and return a file by its file name.
//      *
//      * @param username The username that acts as primary key.
//      * @return The user.
//      * @throws IllegalArgumentException When the arguments is null.
//      */
//     @Nullable
//     User read(String username) throws IllegalArgumentException;
// 
//     /**
//      * Read and return all users stored in
//      * the image store.
//      *
//      * @return A list of all users in the store. The list might be empty.
//      */
//     @Nonnull
//     Collection<User> readAll();
// 
//     /**
//      * Delete the file by its file name.
//      *
//      * @param username The username that acts as primary key.
//      * @return The name of the file that has been deleted successfully.
//      * @throws PersistenceException When the file cannot be deleted.
//      * @throws IllegalArgumentException When the arguments is null.
//      */
//     @Nonnull
//     User delete(String username) throws PersistenceException, IllegalArgumentException;
// }


// Path: rest/java/src/main/java/de/hda/fbi/ds/mbredel/controller/UserController.java
import javax.inject.Inject;
import java.io.IOException;
import static spark.Spark.halt;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.hda.fbi.ds.mbredel.configuration.ConfigurationService;
import de.hda.fbi.ds.mbredel.model.User;
import de.hda.fbi.ds.mbredel.store.StoreService;
import org.apache.http.HttpStatus;
import spark.Request;
import spark.Response;

     * @return The HTTP status and, in case of success, the user.
     */
    public String getUser(Request req, Response res) {

        String username = req.params(":username");
        User user = this.storeService.read(username);
        if (user == null) {
            halt(HttpStatus.SC_NOT_FOUND);
        }

        String result = "";
        ObjectMapper mapper = new ObjectMapper();
        try {
            result = mapper.writeValueAsString(this.storeService.read(username));
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return result;
    }

    /**
     * Create a new user.
     *
     * @param req The HTTP request information.
     * @param res The HTTP response information.
     * @return The HTTP status and, in case of success, the image or a list of images.
     */
    public String postUsers(Request req, Response res) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            User user = mapper.readValue(req.body(), User.class);