Created JSP Home and Scan pages; moved to use war
This commit is contained in:
parent
366f1f7e69
commit
8487384eda
5
pom.xml
5
pom.xml
|
@ -13,6 +13,7 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>ITDominator Thumbnailer</name>
|
<name>ITDominator Thumbnailer</name>
|
||||||
<description>A thumbnailer api for files.</description>
|
<description>A thumbnailer api for files.</description>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -51,6 +52,10 @@
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-core</artifactId>
|
<artifactId>spring-security-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.tomcat.embed</groupId>
|
||||||
|
<artifactId>tomcat-embed-jasper</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.itdominator.api;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@ -9,10 +11,15 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ComponentScan("com.itdominator.api")
|
@ComponentScan("com.itdominator.api")
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ThumbnailApiApplication {
|
public class ThumbnailApiApplication extends SpringBootServletInitializer {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
@Override
|
||||||
SpringApplication.run(ThumbnailApiApplication.class, args);
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||||
}
|
return application.sources(ThumbnailApiApplication.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ThumbnailApiApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,39 @@
|
||||||
package com.itdominator.api.controller;
|
package com.itdominator.api.controller;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import com.itdominator.api.dto.ScanQuery;
|
||||||
|
import com.itdominator.api.dto.User;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@EnableMethodSecurity(securedEnabled = true, prePostEnabled = true)
|
@Controller
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Validated
|
|
||||||
public class BaseController {
|
public class BaseController {
|
||||||
|
|
||||||
|
@GetMapping({"/", "home"})
|
||||||
@PreAuthorize("hasRole('User')")
|
public String index() {
|
||||||
// @PreAuthorize("hashPermission('User')")
|
return "index";
|
||||||
@GetMapping("/")
|
|
||||||
public String root() {
|
|
||||||
return "<h1>Hello, World!</h1>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/register")
|
||||||
|
public String register(Model model) {
|
||||||
|
model.addAttribute("user", new User());
|
||||||
|
|
||||||
|
return "register";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/submit-for-scan")
|
||||||
|
public String submitForScan(Model model) {
|
||||||
|
model.addAttribute("scan_query", new ScanQuery());
|
||||||
|
|
||||||
|
return "submit-for-scan";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,13 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.itdominator.api.dto.ScanQuery;
|
||||||
import com.itdominator.api.dto.ThumbnailDto;
|
import com.itdominator.api.dto.ThumbnailDto;
|
||||||
import com.itdominator.api.dto.ThumbnailSearchCriteria;
|
import com.itdominator.api.dto.ThumbnailSearchCriteria;
|
||||||
import com.itdominator.api.entities.Thumbnails;
|
import com.itdominator.api.entities.Thumbnails;
|
||||||
|
@ -72,6 +74,7 @@ public class ThumbnailerApiController {
|
||||||
return thumbnailerService.getThumbnailByIdOrHashQuery(criteria);
|
return thumbnailerService.getThumbnailByIdOrHashQuery(criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @PreAuthorize("hashPermission('User')")
|
||||||
@PreAuthorize("hasRole('Admin')")
|
@PreAuthorize("hasRole('Admin')")
|
||||||
@GetMapping("/get-all-thumbnails")
|
@GetMapping("/get-all-thumbnails")
|
||||||
public List<ThumbnailDto> getAllThumbnails() {
|
public List<ThumbnailDto> getAllThumbnails() {
|
||||||
|
@ -79,9 +82,11 @@ public class ThumbnailerApiController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasRole('User')")
|
@PreAuthorize("hasRole('User')")
|
||||||
@GetMapping("/temp-videos-list-test")
|
@PostMapping("/scan-target")
|
||||||
public Set<String> getAllVideoFiles() throws IOException {
|
public Set<String> scanTarget(
|
||||||
Set<Path> paths = thumbnailer.collectVideoFilePaths("/home/abaddon/Downloads");
|
@ModelAttribute("scan_query") ScanQuery query
|
||||||
|
) throws IOException {
|
||||||
|
Set<Path> paths = thumbnailer.collectVideoFilePaths(query.getPath());
|
||||||
Set<String> files = new HashSet<>();
|
Set<String> files = new HashSet<>();
|
||||||
|
|
||||||
thumbnailer.generateThumbnails(paths);
|
thumbnailer.generateThumbnails(paths);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.itdominator.api.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ScanQuery {
|
||||||
|
private String path;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.itdominator.api.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class User {
|
||||||
|
private String email;
|
||||||
|
private String password;
|
||||||
|
}
|
|
@ -36,7 +36,7 @@ public class Thumbnails implements Serializable {
|
||||||
@Pattern(regexp = "[a-zA-Z0-9]*$")
|
@Pattern(regexp = "[a-zA-Z0-9]*$")
|
||||||
private String fileHash;
|
private String fileHash;
|
||||||
|
|
||||||
@Column(name = "image", columnDefinition="BLOB NOT NULL")
|
@Column(name = "image", columnDefinition = "BLOB NOT NULL")
|
||||||
private byte[] image;
|
private byte[] image;
|
||||||
|
|
||||||
public Thumbnails(String fileName, String fileHash, byte[] image) {
|
public Thumbnails(String fileName, String fileHash, byte[] image) {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
server.port=8999
|
server.port=8999
|
||||||
|
|
||||||
|
spring.mvc.view.prefix:/WEB-INF/jsp/
|
||||||
|
spring.mvc.view.suffix:.jsp
|
||||||
|
|
||||||
spring.security.user.name=root
|
spring.security.user.name=root
|
||||||
spring.security.user.password=toor
|
spring.security.user.password=toor
|
||||||
spring.security.user.roles=User,Admin
|
spring.security.user.roles=User,Admin
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type"
|
||||||
|
content="text/html; charset=UTF-8">
|
||||||
|
<title>Thumbnailer</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="/submit-for-scan">Manual Scanner</a>
|
||||||
|
<a href="/register">Register</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type"
|
||||||
|
content="text/html; charset=ISO-8859-1">
|
||||||
|
<title>User Registration</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form:form method="POST" modelAttribute="user">
|
||||||
|
<form:label path="email">Email: </form:label>
|
||||||
|
<form:input path="email" type="text"/>
|
||||||
|
<form:label path="password">Password: </form:label>
|
||||||
|
<form:input path="password" type="password" />
|
||||||
|
<input type="submit" value="Submit" />
|
||||||
|
</form:form>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type"
|
||||||
|
content="text/html; charset=ISO-8859-1">
|
||||||
|
<title>Manual Scan</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form:form method="POST" action="scan-target" modelAttribute="scan_query">
|
||||||
|
<form:label path="path">Scan Path: </form:label>
|
||||||
|
<form:input path="path" type="text"/>
|
||||||
|
<input type="submit" value="Scan" />
|
||||||
|
</form:form>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -12,6 +12,7 @@ function main() {
|
||||||
echo "Working Dir: " $(pwd)
|
echo "Working Dir: " $(pwd)
|
||||||
|
|
||||||
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk/"
|
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk/"
|
||||||
/usr/lib/jvm/java-17-openjdk/bin/java -jar ./target/thumbnailer-api-0.0.1-SNAPSHOT.jar
|
# /usr/lib/jvm/java-17-openjdk/bin/java -jar ./target/thumbnailer-api-0.0.1-SNAPSHOT.jar
|
||||||
|
/usr/lib/jvm/java-17-openjdk/bin/java -jar ./target/thumbnailer-api-0.0.1-SNAPSHOT.war
|
||||||
}
|
}
|
||||||
main "$@";
|
main "$@";
|
||||||
|
|
Loading…
Reference in New Issue