From 75d3c5b870f4d872d8e45ac11947023635eddc45 Mon Sep 17 00:00:00 2001 From: Napster Date: Fri, 9 Mar 2018 01:19:52 +0100 Subject: [PATCH] Backend has its own repository --- Backend/.gitignore | 2 - Backend/backend.yaml.example | 16 -- Backend/build.gradle | 49 ----- .../java/fredboat/backend/Application.java | 106 ----------- .../fredboat/backend/config/AppConfig.java | 175 ------------------ .../backend/config/RequestLoggerConfig.java | 66 ------- .../backend/config/SecurityConfig.java | 62 ------- .../fredboat/backend/config/package-info.java | 29 --- .../java/fredboat/backend/package-info.java | 29 --- .../backend/rest/BlacklistController.java | 57 ------ .../backend/rest/EntityController.java | 70 ------- .../backend/rest/GuildConfigController.java | 45 ----- .../backend/rest/GuildDataController.java | 45 ----- .../backend/rest/GuildModulesController.java | 45 ----- .../backend/rest/GuildPermsController.java | 45 ----- .../backend/rest/PrefixController.java | 60 ------ .../backend/rest/SearchResultController.java | 57 ------ .../fredboat/backend/rest/package-info.java | 29 --- ...itional-spring-configuration-metadata.json | 14 -- settings.gradle | 2 - 20 files changed, 1003 deletions(-) delete mode 100644 Backend/.gitignore delete mode 100644 Backend/backend.yaml.example delete mode 100644 Backend/build.gradle delete mode 100644 Backend/src/main/java/fredboat/backend/Application.java delete mode 100644 Backend/src/main/java/fredboat/backend/config/AppConfig.java delete mode 100644 Backend/src/main/java/fredboat/backend/config/RequestLoggerConfig.java delete mode 100644 Backend/src/main/java/fredboat/backend/config/SecurityConfig.java delete mode 100644 Backend/src/main/java/fredboat/backend/config/package-info.java delete mode 100644 Backend/src/main/java/fredboat/backend/package-info.java delete mode 100644 Backend/src/main/java/fredboat/backend/rest/BlacklistController.java delete mode 100644 Backend/src/main/java/fredboat/backend/rest/EntityController.java delete mode 100644 Backend/src/main/java/fredboat/backend/rest/GuildConfigController.java delete mode 100644 Backend/src/main/java/fredboat/backend/rest/GuildDataController.java delete mode 100644 Backend/src/main/java/fredboat/backend/rest/GuildModulesController.java delete mode 100644 Backend/src/main/java/fredboat/backend/rest/GuildPermsController.java delete mode 100644 Backend/src/main/java/fredboat/backend/rest/PrefixController.java delete mode 100644 Backend/src/main/java/fredboat/backend/rest/SearchResultController.java delete mode 100644 Backend/src/main/java/fredboat/backend/rest/package-info.java delete mode 100644 Backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json diff --git a/Backend/.gitignore b/Backend/.gitignore deleted file mode 100644 index d26dd62cf..000000000 --- a/Backend/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/logs/ -application.yml diff --git a/Backend/backend.yaml.example b/Backend/backend.yaml.example deleted file mode 100644 index edde0159a..000000000 --- a/Backend/backend.yaml.example +++ /dev/null @@ -1,16 +0,0 @@ -spring: - http: - converters: - preferred-json-mapper: gson -fredboat: - db: - main: - jdbcUrl: "" - cache: - jdbcUrl: "" - security: - admins: - - name: fredbotto - pass: - - name: patronbotto - pass: diff --git a/Backend/build.gradle b/Backend/build.gradle deleted file mode 100644 index fc93f3384..000000000 --- a/Backend/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -apply plugin: 'propdeps' -apply plugin: 'propdeps-idea' -apply plugin: 'org.springframework.boot' - - -description = 'FredBoat backend, providing REST database services' -version '1.0' -ext { - moduleName = 'Backend' -} - -bootRun { - //compiling tests during bootRun increases the likelyhood of catching broken tests locally instead of on the CI - dependsOn compileTestJava - - //pass in custom jvm args - // source: https://stackoverflow.com/a/25079415 - // example: ./gradlew bootRun -PjvmArgs="--illegal-access=debug -Dwhatever=value" - if (project.hasProperty('jvmArgs')) { - jvmArgs project.jvmArgs.split('\\s+') - } -} - -bootJar { - archiveName = "Backend.jar" - doLast { - //copies the jar into a place where the Dockerfile can find it easily (and users maybe too) - copy { - from 'build/libs/Backend.jar' - into '.' - } - } -} - -dependencies { - compile project(':Database') - - - //versioning is handled by spring - compile "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion" - compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion" - compile "org.springframework.boot:spring-boot-starter-security:$springBootVersion" - testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion" - optional "org.springframework.boot:spring-boot-configuration-processor:$springBootVersion" -} - -//required by spring boot configuration processor -compileJava.dependsOn(processResources) - diff --git a/Backend/src/main/java/fredboat/backend/Application.java b/Backend/src/main/java/fredboat/backend/Application.java deleted file mode 100644 index 45bdcfecf..000000000 --- a/Backend/src/main/java/fredboat/backend/Application.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend; - -import fredboat.db.repositories.api.*; -import fredboat.db.repositories.impl.*; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; -import space.npstr.sqlsauce.DatabaseWrapper; - -/** - * Created by napster on 16.02.18. - */ -@SpringBootApplication -@EnableAutoConfiguration(exclude = { //we handle these ourselves via the DatabaseManager - DataSourceAutoConfiguration.class, - DataSourceTransactionManagerAutoConfiguration.class, - HibernateJpaAutoConfiguration.class, - FlywayAutoConfiguration.class -}) -public class Application { - - public static final String API_VERSION = "v1"; - - public static void main(String[] args) { - System.setProperty("spring.config.name", "backend"); - SpringApplication.run(Application.class, args); - } - - - //main db repos - @Bean - @Primary - public GuildConfigRepo guildConfigRepo(DatabaseWrapper wrapper) { - return new SqlSauceGuildConfigRepo(wrapper); - } - - @Bean - @Primary - public BlacklistRepo blacklistRepo(DatabaseWrapper wrapper) { - return new SqlSauceBlacklistRepo(wrapper); - } - - @Bean - @Primary - public GuildDataRepo guildDataRepo(DatabaseWrapper wrapper) { - return new SqlSauceGuildDataRepo(wrapper); - } - - @Bean - @Primary - public GuildModulesRepo guildModulesRepo(DatabaseWrapper wrapper) { - return new SqlSauceGuildModulesRepo(wrapper); - } - - @Bean - @Primary - public GuildPermsRepo guildPermsRepo(DatabaseWrapper wrapper) { - return new SqlSauceGuildPermsRepo(wrapper); - } - - @Bean - @Primary - public PrefixRepo prefixRepo(DatabaseWrapper wrapper) { - return new SqlSaucePrefixRepo(wrapper); - } - - - //cache db repos - @Bean - @Primary - public SearchResultRepo searchResultRepo(@Qualifier("cacheDbWrapper") DatabaseWrapper wrapper) { - return new SqlSauceSearchResultRepo(wrapper); - } -} diff --git a/Backend/src/main/java/fredboat/backend/config/AppConfig.java b/Backend/src/main/java/fredboat/backend/config/AppConfig.java deleted file mode 100644 index f2434a008..000000000 --- a/Backend/src/main/java/fredboat/backend/config/AppConfig.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.config; - -import fredboat.db.DatabaseManager; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.Scope; -import org.springframework.orm.jpa.JpaVendorAdapter; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import space.npstr.sqlsauce.DatabaseWrapper; - -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by napster on 16.02.18. - * - * Mirrors the fredboat tree of the application.yaml - */ -@ConfigurationProperties(prefix = "fredboat") -@Configuration -@EnableConfigurationProperties -public class AppConfig { - - @Bean("databaseManager") - @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) - public DatabaseManager getDatabaseManager(Db dbConfig) { - //todo improve these parameters - return new DatabaseManager(null, null, - 4, "Backend", true, - dbConfig.getMain().getJdbcUrl(), null, - dbConfig.getCache().getJdbcUrl(), null, - (puName, dataSource, properties, entityPackages) -> { - LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean(); - emfb.setDataSource(dataSource); - emfb.setPackagesToScan(entityPackages.toArray(new String[entityPackages.size()])); - - JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - emfb.setJpaVendorAdapter(vendorAdapter); - emfb.setJpaProperties(properties); - - emfb.afterPropertiesSet(); //initiate creation of the native emf - return emfb.getNativeEntityManagerFactory(); - }); - } - - @Primary - @Bean("mainDbWrapper") - public DatabaseWrapper getMainDbWrapper(DatabaseManager databaseManager) { - return databaseManager.getMainDbWrapper(); - } - - @Nullable - @Bean("cacheDbWrapper") - public DatabaseWrapper getCacheDbWrapper(DatabaseManager databaseManager) { - return databaseManager.getCacheDbWrapper(); - } - - private final Db db = new Db(); - - @Bean - public Db getDb() { - return db; - } - - public static class Db { - - private final Main main = new Main(); - - public Main getMain() { - return main; - } - - private final Cache cache = new Cache(); - - public Cache getCache() { - return cache; - } - - public static class Main { - private String jdbcUrl = ""; - - public String getJdbcUrl() { - return jdbcUrl; - } - - public void setJdbcUrl(String jdbcUrl) { - this.jdbcUrl = jdbcUrl; - } - } - - public static class Cache { - private String jdbcUrl = ""; - - public String getJdbcUrl() { - return jdbcUrl; - } - - public void setJdbcUrl(String jdbcUrl) { - this.jdbcUrl = jdbcUrl; - } - } - } - - private final Security security = new Security(); - - @Bean - public Security getSecurity() { - return security; - } - - public static class Security { - - private List admins = new ArrayList<>(); - - public List getAdmins() { - return admins; - } - - public void setAdmins(List admins) { - this.admins = admins; - } - - public static class Admin { - private String name = ""; - private String pass = ""; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPass() { - return pass; - } - - public void setPass(String pass) { - this.pass = pass; - } - } - } -} diff --git a/Backend/src/main/java/fredboat/backend/config/RequestLoggerConfig.java b/Backend/src/main/java/fredboat/backend/config/RequestLoggerConfig.java deleted file mode 100644 index 82531e608..000000000 --- a/Backend/src/main/java/fredboat/backend/config/RequestLoggerConfig.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.config; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.filter.AbstractRequestLoggingFilter; - -import javax.servlet.http.HttpServletRequest; - -/** - * Created by napster on 17.02.18. - */ -@Configuration -public class RequestLoggerConfig { - - @Bean - public AbstractRequestLoggingFilter logFilter() { - RequestLogger filter = new RequestLogger(); - filter.setIncludeQueryString(true); - filter.setIncludePayload(true); - filter.setMaxPayloadLength(10000); - filter.setIncludeHeaders(true); - filter.setAfterMessagePrefix("REQUEST DATA : "); - return filter; - } - - private static class RequestLogger extends AbstractRequestLoggingFilter { - private static final Logger log = LoggerFactory.getLogger(RequestLogger.class); - - @Override - protected void beforeRequest(HttpServletRequest request, String message) { -// log.debug(message); - } - - @Override - protected void afterRequest(HttpServletRequest request, String message) { - log.debug(message); - } - } -} diff --git a/Backend/src/main/java/fredboat/backend/config/SecurityConfig.java b/Backend/src/main/java/fredboat/backend/config/SecurityConfig.java deleted file mode 100644 index 61138c950..000000000 --- a/Backend/src/main/java/fredboat/backend/config/SecurityConfig.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.authentication.configurers.provisioning.InMemoryUserDetailsManagerConfigurer; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.config.http.SessionCreationPolicy; - -/** - * Created by napster on 18.02.18. - */ -@Configuration -@EnableWebSecurity -public class SecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().anyRequest().authenticated() - .and().httpBasic() - .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); - } - - @Autowired - public void configureGlobal(AuthenticationManagerBuilder auth, AppConfig.Security security) throws Exception { - InMemoryUserDetailsManagerConfigurer inMemoryAuth = auth.inMemoryAuthentication(); - for (AppConfig.Security.Admin admin : security.getAdmins()) { - if (admin.getPass().isEmpty()) { - throw new RuntimeException("Admin " + admin.getName() + " configured with empty pass."); - } - //we are treating the pass as tokens right now so using the noop encoder is fine - inMemoryAuth.withUser(admin.getName()).password("{noop}" + admin.getPass()).roles("ADMIN", "USER"); - } - } -} diff --git a/Backend/src/main/java/fredboat/backend/config/package-info.java b/Backend/src/main/java/fredboat/backend/config/package-info.java deleted file mode 100644 index 99057decc..000000000 --- a/Backend/src/main/java/fredboat/backend/config/package-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -@space.npstr.annotations.FieldsAreNonNullByDefault -@space.npstr.annotations.ParametersAreNonnullByDefault -@space.npstr.annotations.ReturnTypesAreNonNullByDefault -package fredboat.backend.config; diff --git a/Backend/src/main/java/fredboat/backend/package-info.java b/Backend/src/main/java/fredboat/backend/package-info.java deleted file mode 100644 index dc82d6dde..000000000 --- a/Backend/src/main/java/fredboat/backend/package-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -@space.npstr.annotations.FieldsAreNonNullByDefault -@space.npstr.annotations.ParametersAreNonnullByDefault -@space.npstr.annotations.ReturnTypesAreNonNullByDefault -package fredboat.backend; diff --git a/Backend/src/main/java/fredboat/backend/rest/BlacklistController.java b/Backend/src/main/java/fredboat/backend/rest/BlacklistController.java deleted file mode 100644 index 323acec32..000000000 --- a/Backend/src/main/java/fredboat/backend/rest/BlacklistController.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.rest; - -import fredboat.backend.Application; -import fredboat.db.entity.main.BlacklistEntry; -import fredboat.db.repositories.api.BlacklistRepo; -import fredboat.db.repositories.impl.rest.RestBlacklistRepo; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * Created by napster on 17.02.18. - */ -@RestController -@RequestMapping("/" + Application.API_VERSION + RestBlacklistRepo.PATH) -public class BlacklistController extends EntityController implements BlacklistRepo { - - protected final BlacklistRepo blacklistRepo; - - public BlacklistController(BlacklistRepo repo) { - super(repo); - this.blacklistRepo = repo; - } - - @GetMapping("/loadall") - @Override - public List loadBlacklist() { - return blacklistRepo.loadBlacklist(); - } -} diff --git a/Backend/src/main/java/fredboat/backend/rest/EntityController.java b/Backend/src/main/java/fredboat/backend/rest/EntityController.java deleted file mode 100644 index 21091ee5d..000000000 --- a/Backend/src/main/java/fredboat/backend/rest/EntityController.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.rest; - -import fredboat.db.repositories.api.Repo; -import fredboat.db.repositories.impl.rest.RestRepo; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import space.npstr.sqlsauce.entities.SaucedEntity; - -import java.io.Serializable; - -/** - * Created by napster on 17.02.18. - *

- * Counterpart to the {@link RestRepo} - *

- * Oh no, all those PostMappings are totally against Https/Rest principles...too bad that GET / DELETE do not support - * RequestBodies, and our Ids can be a bit more than a simple string / long. So they are passed as json as part of the - * body. - */ -public abstract class EntityController> implements Repo { - - protected final Repo repo; - - public EntityController(Repo repo) { - this.repo = repo; - } - - @Override - @PostMapping("/delete") - public void delete(@RequestBody I id) { - repo.delete(id); - } - - @Override - @PostMapping("/fetch") - public E fetch(@RequestBody I id) { - return repo.fetch(id); - } - - @Override - @PostMapping("/merge") - public E merge(@RequestBody E entity) { - return repo.merge(entity); - } -} diff --git a/Backend/src/main/java/fredboat/backend/rest/GuildConfigController.java b/Backend/src/main/java/fredboat/backend/rest/GuildConfigController.java deleted file mode 100644 index 7ddad89a5..000000000 --- a/Backend/src/main/java/fredboat/backend/rest/GuildConfigController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.rest; - -import fredboat.backend.Application; -import fredboat.db.entity.main.GuildConfig; -import fredboat.db.repositories.api.GuildConfigRepo; -import fredboat.db.repositories.impl.rest.RestGuildConfigRepo; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Created by napster on 17.02.18. - */ -@RestController -@RequestMapping("/" + Application.API_VERSION + RestGuildConfigRepo.PATH) -public class GuildConfigController extends EntityController implements GuildConfigRepo { - - public GuildConfigController(GuildConfigRepo repo) { - super(repo); - } -} diff --git a/Backend/src/main/java/fredboat/backend/rest/GuildDataController.java b/Backend/src/main/java/fredboat/backend/rest/GuildDataController.java deleted file mode 100644 index ec4049d47..000000000 --- a/Backend/src/main/java/fredboat/backend/rest/GuildDataController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.rest; - -import fredboat.backend.Application; -import fredboat.db.entity.main.GuildData; -import fredboat.db.repositories.api.GuildDataRepo; -import fredboat.db.repositories.impl.rest.RestGuildDataRepo; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Created by napster on 17.02.18. - */ -@RestController -@RequestMapping("/" + Application.API_VERSION + RestGuildDataRepo.PATH) -public class GuildDataController extends EntityController implements GuildDataRepo { - - public GuildDataController(GuildDataRepo repo) { - super(repo); - } -} diff --git a/Backend/src/main/java/fredboat/backend/rest/GuildModulesController.java b/Backend/src/main/java/fredboat/backend/rest/GuildModulesController.java deleted file mode 100644 index 49c5b82b1..000000000 --- a/Backend/src/main/java/fredboat/backend/rest/GuildModulesController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.rest; - -import fredboat.backend.Application; -import fredboat.db.entity.main.GuildModules; -import fredboat.db.repositories.api.GuildModulesRepo; -import fredboat.db.repositories.impl.rest.RestGuildModulesRepo; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Created by napster on 17.02.18. - */ -@RestController -@RequestMapping("/" + Application.API_VERSION + RestGuildModulesRepo.PATH) -public class GuildModulesController extends EntityController implements GuildModulesRepo { - - public GuildModulesController(GuildModulesRepo repo) { - super(repo); - } -} diff --git a/Backend/src/main/java/fredboat/backend/rest/GuildPermsController.java b/Backend/src/main/java/fredboat/backend/rest/GuildPermsController.java deleted file mode 100644 index f23b00347..000000000 --- a/Backend/src/main/java/fredboat/backend/rest/GuildPermsController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.rest; - -import fredboat.backend.Application; -import fredboat.db.entity.main.GuildPermissions; -import fredboat.db.repositories.api.GuildPermsRepo; -import fredboat.db.repositories.impl.rest.RestGuildPermsRepo; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Created by napster on 17.02.18. - */ -@RestController -@RequestMapping("/" + Application.API_VERSION + RestGuildPermsRepo.PATH) -public class GuildPermsController extends EntityController implements GuildPermsRepo { - - public GuildPermsController(GuildPermsRepo repo) { - super(repo); - } -} diff --git a/Backend/src/main/java/fredboat/backend/rest/PrefixController.java b/Backend/src/main/java/fredboat/backend/rest/PrefixController.java deleted file mode 100644 index b53fb27df..000000000 --- a/Backend/src/main/java/fredboat/backend/rest/PrefixController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.rest; - -import fredboat.backend.Application; -import fredboat.db.entity.main.Prefix; -import fredboat.db.repositories.api.PrefixRepo; -import fredboat.db.repositories.impl.rest.RestPrefixRepo; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import space.npstr.sqlsauce.entities.GuildBotComposite; - -import javax.annotation.Nullable; - -/** - * Created by napster on 17.02.18. - */ -@RestController -@RequestMapping("/" + Application.API_VERSION + RestPrefixRepo.PATH) -public class PrefixController extends EntityController implements PrefixRepo { - - protected final PrefixRepo prefixRepo; - - public PrefixController(PrefixRepo repo) { - super(repo); - this.prefixRepo = repo; - } - - @Nullable - @PostMapping("/getraw") - @Override - public String getPrefix(@RequestBody GuildBotComposite id) { - return prefixRepo.getPrefix(id); - } -} diff --git a/Backend/src/main/java/fredboat/backend/rest/SearchResultController.java b/Backend/src/main/java/fredboat/backend/rest/SearchResultController.java deleted file mode 100644 index 4e49a4c02..000000000 --- a/Backend/src/main/java/fredboat/backend/rest/SearchResultController.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package fredboat.backend.rest; - -import fredboat.backend.Application; -import fredboat.db.entity.cache.SearchResult; -import fredboat.db.repositories.api.SearchResultRepo; -import fredboat.db.repositories.impl.rest.RestSearchResultRepo; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Nullable; - -/** - * Created by napster on 17.02.18. - */ -@RestController -@RequestMapping("/" + Application.API_VERSION + RestSearchResultRepo.PATH) -public class SearchResultController extends EntityController - implements SearchResultRepo { - - protected final SearchResultRepo searchResultRepo; - - public SearchResultController(SearchResultRepo repo) { - super(repo); - this.searchResultRepo = repo; - } - - @Nullable - @PostMapping("/getmaxaged") - @Override - public SearchResult getMaxAged(@RequestBody SearchResult.SearchResultId id, @RequestParam("millis") long maxAgeMillis) { - return searchResultRepo.getMaxAged(id, maxAgeMillis); - } -} diff --git a/Backend/src/main/java/fredboat/backend/rest/package-info.java b/Backend/src/main/java/fredboat/backend/rest/package-info.java deleted file mode 100644 index 290fbcc76..000000000 --- a/Backend/src/main/java/fredboat/backend/rest/package-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2017-2018 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -@space.npstr.annotations.FieldsAreNonNullByDefault -@space.npstr.annotations.ParametersAreNonnullByDefault -@space.npstr.annotations.ReturnTypesAreNonNullByDefault -package fredboat.backend.rest; diff --git a/Backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/Backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index 6aa18ceb9..000000000 --- a/Backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "properties": [ - { - "name": "fredboat.db.main.jdbcUrl", - "type": "java.lang.String", - "description": "Jdbc url of the main database including username and password." - }, - { - "name": "fredboat.db.cache.jdbcUrl", - "type": "java.lang.String", - "description": "Jdbc url of the cache database including username and password." - } - ] -} diff --git a/settings.gradle b/settings.gradle index ec130b650..1ec28b3b0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,10 +3,8 @@ include ':FredBoat' include ':Bootloader' include ':Shared' include ':Database' -include ':Backend' project(':FredBoat').projectDir = "$rootDir/FredBoat" as File project(':Bootloader').projectDir = "$rootDir/Bootloader" as File project(':Shared').projectDir = "$rootDir/Shared" as File project(':Database').projectDir = "$rootDir/Database" as File -project(':Backend').projectDir = "$rootDir/Backend" as File