
service.database.command.InitDatabase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of database-service Show documentation
Show all versions of database-service Show documentation
This is a library providing an API for accessing databases via socket connections
The newest version!
package service.database.command;
import databaseconnector.api.sql.SQLDatabaseConnection;
import databaseconnector.api.sql.SQLSchema;
import service.database.SQLDatabaseService;
import service.database.exception.DatabaseRoleNotActivatedException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Optional;
public class InitDatabase extends AbstractDatabaseCommand {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
setAccessControlAllowOriginHeader(req, resp);
try {
SQLDatabaseConnection databaseConnection = getDatabaseConnection();
Optional schema = SQLDatabaseService.getSchema();
assert schema.isPresent();
databaseConnection.init(schema.get());
resp.setStatus(200);
} catch (DatabaseRoleNotActivatedException exception) {
displayError(resp, 501, exception.getMessage());
}
}
public static String getCommand(){
return "/command/database/init";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy