diff --git a/build.sh b/build.sh index d206791..1924d20 100644 --- a/build.sh +++ b/build.sh @@ -11,6 +11,6 @@ function main() { cd "$(dirname "")" echo "Working Dir: " $(pwd) export JAVA_HOME="/usr/lib/jvm/java-17-openjdk/" - mvn clean package -Pproduction -Dmaven.test.skip=true + mvn clean package -U -Pproduction -Dmaven.test.skip=true } main "$@"; diff --git a/pom.xml b/pom.xml index 8e2bca8..47b140f 100644 --- a/pom.xml +++ b/pom.xml @@ -17,8 +17,11 @@ UTF-8 17 - 24.1.7 - 3.25.2 + 6.0.11 + + 6.3.1.Final + + 3.30.1 @@ -26,18 +29,9 @@ org.springframework.boot spring-boot-starter-security - - - org.springframework.session - spring-session-core - org.springframework spring-jdbc - 6.0.11 org.springframework.data @@ -46,26 +40,36 @@ org.springframework spring-beans - 6.0.11 + + org.springframework.boot + spring-boot-starter-data-jpa + + com.h2database h2 runtime + + org.hibernate.orm + hibernate-community-dialects + 6.1.6.Final + org.xerial sqlite-jdbc ${sqlite-jdbc.version} - - org.hibernate.orm - hibernate-community-dialects - org.projectlombok lombok + + jakarta.persistence + jakarta.persistence-api + 3.1.0 + jakarta.validation jakarta.validation-api @@ -86,13 +90,6 @@ - @@ -123,21 +120,6 @@ /usr/lib/jvm/java-17-openjdk/bin/javac - - com.vaadin - vaadin-maven-plugin - ${vaadin.version} - - - frontend - compile - - prepare-frontend - build-frontend - - - - diff --git a/src/main/java/com/itdominator/api/ThumbnailApiApplication.java b/src/main/java/com/itdominator/api/ThumbnailApiApplication.java index ba0d901..013d9fa 100644 --- a/src/main/java/com/itdominator/api/ThumbnailApiApplication.java +++ b/src/main/java/com/itdominator/api/ThumbnailApiApplication.java @@ -2,8 +2,11 @@ package com.itdominator.api; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Configuration; + @SpringBootApplication +@Configuration public class ThumbnailApiApplication { public static void main(String[] args) { diff --git a/src/main/java/com/itdominator/api/controller/ThumbnailerApiController.java b/src/main/java/com/itdominator/api/controller/ThumbnailerApiController.java index f8adeb3..c4e105a 100644 --- a/src/main/java/com/itdominator/api/controller/ThumbnailerApiController.java +++ b/src/main/java/com/itdominator/api/controller/ThumbnailerApiController.java @@ -45,11 +45,11 @@ public class ThumbnailerApiController { } @PreAuthorize("hashPermission('User')") - @PostMapping("/get-thumbnail/hash/{hash}") + @PostMapping("/get-thumbnail/hash/{fileHash}") public ThumbnailDto getThumbnailByHash( - @Pattern(regexp = "[a-zA-Z0-9]{32}*$") @PathVariable("hash") final String hash + @Pattern(regexp = "[a-zA-Z0-9]{32}*$") @PathVariable("fileHash") final String fileHash ) { - return thumbnailerService.getThumbnailByHash(hash); + return thumbnailerService.getThumbnailByHash(fileHash); } diff --git a/src/main/java/com/itdominator/api/entities/Thumbnails.java b/src/main/java/com/itdominator/api/entities/Thumbnails.java index 9f390ef..e15062d 100644 --- a/src/main/java/com/itdominator/api/entities/Thumbnails.java +++ b/src/main/java/com/itdominator/api/entities/Thumbnails.java @@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode; @Entity -@Table(name = "thumbnails") +@Table @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true) public class Thumbnails implements Serializable { diff --git a/src/main/java/com/itdominator/api/repositories/ThumbnailRepository.java b/src/main/java/com/itdominator/api/repositories/ThumbnailRepository.java index e6d3e62..1160700 100644 --- a/src/main/java/com/itdominator/api/repositories/ThumbnailRepository.java +++ b/src/main/java/com/itdominator/api/repositories/ThumbnailRepository.java @@ -8,7 +8,6 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import com.itdominator.api.dto.ThumbnailDto; - import com.itdominator.api.entities.Thumbnails; import com.itdominator.api.entities.ThumbnailsId; @@ -20,9 +19,9 @@ public interface ThumbnailRepository extends JpaRepository getAllThumbnails(); - @Query(value = "SELECT path FROM thumbnails WHERE hash = :hash", nativeQuery = true) - ThumbnailDto findThumbnailByHash(String id); + @Query(value = "SELECT path FROM thumbnails WHERE file_hash = :fileHash", nativeQuery = true) + ThumbnailDto findThumbnailByHash(String fileHash); - @Query(value = "SELECT path FROM thumbnails WHERE hashid = :id", nativeQuery = true) + @Query(value = "SELECT path FROM thumbnails WHERE id = :id", nativeQuery = true) ThumbnailDto findThumbnailById(int id); } diff --git a/src/main/java/com/itdominator/api/services/ThumbnailerService.java b/src/main/java/com/itdominator/api/services/ThumbnailerService.java index 3018727..0ee5842 100644 --- a/src/main/java/com/itdominator/api/services/ThumbnailerService.java +++ b/src/main/java/com/itdominator/api/services/ThumbnailerService.java @@ -28,8 +28,8 @@ public class ThumbnailerService { } - public ThumbnailDto getThumbnailByHash(final String hash) { - return thumbnailRepository.findThumbnailByHash(hash); + public ThumbnailDto getThumbnailByHash(final String fileHash) { + return thumbnailRepository.findThumbnailByHash(fileHash); } public ThumbnailDto getThumbnailByIdOrHashQuery(final ThumbnailSearchCriteria criteria) { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 445259a..24b7eb3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,14 +1,19 @@ server.port=8999 +spring.security.user.name=root +spring.security.user.password=toor +spring.security.user.roles=USER + +spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringJtaSessionContext + driverClassName=org.sqlite.JDBC -spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect -#url=jdbc:sqlite:memory:myDb?cache=shared -url=jdbc:sqlite:src/main/resource/static/db/database.db?cache=shared -username= -password= +spring.jpa.properties.hibernate.dialect=org.hibernate.community.dialect.SQLiteDialect +spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect +#url=jdbc:sqlite:memory:myDb?cache=shared +url=jdbc:sqlite:src/main/resources/static/db/database.db hibernate.hbm2ddl.auto=create-drop hibernate.show_sql=true +spring.jpa.hibernate.ddl-auto=update + + -spring.security.user.name=root -spring.security.user.password=password -spring.security.user.roles=USER diff --git a/src/main/resources/static/db/database.db b/src/main/resources/static/db/database.db index 326b2a9..62cd3a2 100644 Binary files a/src/main/resources/static/db/database.db and b/src/main/resources/static/db/database.db differ diff --git a/start-app.sh b/start-app.sh index 22fd168..0447701 100644 --- a/start-app.sh +++ b/start-app.sh @@ -12,6 +12,6 @@ function main() { echo "Working Dir: " $(pwd) export JAVA_HOME="/usr/lib/jvm/java-17-openjdk/" - /usr/lib/jvm/java-17-openjdk/bin/java -jar ./target/itdominator-0.0.1-SNAPSHOT.jar + /usr/lib/jvm/java-17-openjdk/bin/java -jar ./target/thumbnailer-api-0.0.1-SNAPSHOT.jar } main "$@";