Vorbereitung Release 0.2.0
This commit is contained in:
@@ -14,7 +14,6 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@ import jakarta.validation.constraints.NotNull;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
@@ -14,7 +14,6 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* Represents a work type in the application.
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package de.thpeetz.kontor.integration.routes;
|
||||
|
||||
import de.thpeetz.kontor.integration.services.AddLinkProcessor;
|
||||
import de.thpeetz.kontor.media.services.MediaFileService;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AddLinkFromQueue extends RouteBuilder {
|
||||
|
||||
@Autowired
|
||||
private final MediaFileService mediaFileService;
|
||||
|
||||
@Autowired
|
||||
public AddLinkFromQueue(MediaFileService mediaFileService) {
|
||||
this.mediaFileService = mediaFileService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
from("jms:queue:add_link_file")
|
||||
.routeId("read-queue-add-link_file")
|
||||
.log("${body}")
|
||||
.process(new AddLinkProcessor(mediaFileService))
|
||||
.to("jms:queue:update_title");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package de.thpeetz.kontor.integration.routes;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ReadQueueRoute extends RouteBuilder {
|
||||
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
from("jms:queue:KontorMediaFile")
|
||||
.routeId("add-link-from-queue")
|
||||
.trace(true)
|
||||
.log(">>> ${body}");
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package de.thpeetz.kontor.integration.services;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import de.thpeetz.kontor.media.data.MediaFile;
|
||||
import de.thpeetz.kontor.media.services.MediaFileService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class AddLinkProcessor implements Processor {
|
||||
|
||||
private final MediaFileService mediaFileService;
|
||||
|
||||
public AddLinkProcessor(MediaFileService mediaFileService) {
|
||||
this.mediaFileService = mediaFileService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(Exchange exchange) throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
HashMap<String,String> myMap = objectMapper.readValue(exchange.getIn().getBody().toString(), new TypeReference<HashMap<String,String>>() {});
|
||||
String url = myMap.get("url");
|
||||
log.info("found url: {}", url);
|
||||
MediaFile mediaFile = mediaFileService.findAllMediaFilesByUrl(url);
|
||||
if (mediaFile == null) {
|
||||
log.info("URL not found, create MediaFile");
|
||||
mediaFile = new MediaFile();
|
||||
mediaFile.setUrl(url);
|
||||
mediaFile.setReview(true);
|
||||
mediaFile.setShouldDownload(true);
|
||||
MediaFile mediaFileResult = mediaFileService.saveMediaFile(mediaFile);
|
||||
log.info("created MediaFile with {}", mediaFileResult.getId());
|
||||
exchange.getMessage().getHeaders().put("mediafile_id", mediaFileResult.getId());
|
||||
}
|
||||
log.info("found MediaFile: {}", mediaFile);
|
||||
Map<String, Object> map = exchange.getMessage().getHeaders();
|
||||
log.info("Headers: {}", map);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.thpeetz.kontor.integration.services;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AddLinkService {
|
||||
|
||||
public void fromQueue(String messageBody) throws JsonProcessingException {
|
||||
log.info("get body: {}", messageBody);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
HashMap<String,String> myMap = objectMapper.readValue(messageBody, new TypeReference<HashMap<String,String>>() {});
|
||||
String url = myMap.get("url");
|
||||
log.info("found url: {}", url);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,9 @@ public class MediaActor extends AbstractEntity {
|
||||
@Column(unique = true)
|
||||
private String name;
|
||||
|
||||
@Nullable
|
||||
private String url;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "media_actor", cascade = CascadeType.REFRESH, orphanRemoval = true)
|
||||
@Nullable
|
||||
List<MediaActorFile> mediaActorFiles = new LinkedList<>();
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.List;
|
||||
@Setter
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "url" }) })
|
||||
public class MediaFile extends AbstractEntity {
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -78,9 +78,9 @@ public class MediaFileService {
|
||||
public void saveMediaFile(MediaFile mediaFile) {
|
||||
if (mediaFile == null) {
|
||||
log.warn("MediaFile is null. Are you sure you have connected your form to the application?");
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
mediaFileRepository.save(mediaFile);
|
||||
return mediaFileRepository.save(mediaFile);
|
||||
}
|
||||
|
||||
public void deleteMediaFile(MediaFile mediaFile) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.button.ButtonVariant;
|
||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.listbox.MultiSelectListBox;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||
@@ -22,6 +21,7 @@ import java.util.List;
|
||||
public class MediaActorForm extends FormLayout {
|
||||
|
||||
TextField name = new TextField("Name");
|
||||
TextField url = new TextField("URL");
|
||||
Grid<MediaActorFile> mediaActorFiles = new Grid<>(MediaActorFile.class);
|
||||
|
||||
Button save = new Button("Save");
|
||||
@@ -37,6 +37,7 @@ public class MediaActorForm extends FormLayout {
|
||||
mediaActorFiles.setColumns("media_file.title");
|
||||
mediaActorFiles.getColumnByKey("media_file.title").setHeader("File Title");
|
||||
add(name, 2);
|
||||
add(url, 2);
|
||||
add(mediaActorFiles, 2);
|
||||
add(createButtonsLayout());
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.thpeetz.kontor.media.views;
|
||||
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.button.ButtonVariant;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
@@ -10,9 +11,12 @@ import com.vaadin.flow.data.value.ValueChangeMode;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
|
||||
import de.thpeetz.kontor.common.views.ColumnToggleContextMenu;
|
||||
import de.thpeetz.kontor.common.views.MainLayout;
|
||||
import de.thpeetz.kontor.media.MediaConstants;
|
||||
import de.thpeetz.kontor.media.data.MediaActor;
|
||||
import de.thpeetz.kontor.media.data.MediaFile;
|
||||
import de.thpeetz.kontor.media.services.MediaFileService;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import lombok.Getter;
|
||||
@@ -26,7 +30,17 @@ import org.springframework.context.annotation.Scope;
|
||||
public class MediaActorView extends VerticalLayout {
|
||||
|
||||
@Getter
|
||||
Grid<MediaActor> grid = new Grid<>(MediaActor.class);
|
||||
Grid<MediaActor> grid = new Grid<>(MediaActor.class, false);
|
||||
Grid.Column<MediaActor> idColumn = grid.addColumn(MediaActor::getId)
|
||||
.setHeader("ID").setResizable(true).setSortable(true);
|
||||
Grid.Column<MediaActor> createdColumn = grid.addColumn(MediaActor::getCreatedDate)
|
||||
.setHeader("Erstellt").setResizable(true).setSortable(true);
|
||||
Grid.Column<MediaActor> modifiedColumn = grid.addColumn(MediaActor::getLastModifiedDate)
|
||||
.setHeader("Geändert").setResizable(true).setSortable(true);
|
||||
Grid.Column<MediaActor> nameColumn = grid.addColumn(MediaActor::getName)
|
||||
.setHeader("Name").setResizable(true).setSortable(true);
|
||||
Grid.Column<MediaActor> urlColumn = grid.addColumn(MediaActor::getUrl)
|
||||
.setHeader("URL").setResizable(true).setSortable(true);
|
||||
TextField filterText = new TextField();
|
||||
@Getter
|
||||
MediaActorForm form;
|
||||
@@ -46,7 +60,6 @@ public class MediaActorView extends VerticalLayout {
|
||||
private void configureGrid() {
|
||||
grid.addClassName("media-actor-grid");
|
||||
grid.setSizeFull();
|
||||
grid.setColumns("name");
|
||||
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||
grid.asSingleSelect().addValueChangeListener(event -> editMediaActor(event.getValue()));
|
||||
}
|
||||
@@ -90,7 +103,15 @@ public class MediaActorView extends VerticalLayout {
|
||||
Button addMediaActorButton = new Button("Add actor");
|
||||
addMediaActorButton.addClickListener(click -> addMediaActor());
|
||||
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addMediaActorButton);
|
||||
Button menuButton = new Button("Show/Hide Columns");
|
||||
menuButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
ColumnToggleContextMenu<MediaActor> columnToggleContextMenu = new ColumnToggleContextMenu<>(menuButton);
|
||||
columnToggleContextMenu.addColumnToggleItem(idColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(createdColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(modifiedColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(nameColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(urlColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addMediaActorButton, menuButton);
|
||||
toolbar.addClassName("toolbar");
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
@@ -13,14 +13,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.oauth2.jose.jws.JwsAlgorithms;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
@EnableWebSecurity
|
||||
@Configuration
|
||||
@@ -36,8 +34,9 @@ public class SecurityConfig extends VaadinWebSecurity {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests(auth -> auth.requestMatchers(
|
||||
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/images/*.png")).permitAll());
|
||||
http.authorizeHttpRequests(auth -> auth
|
||||
.requestMatchers("/images/*.png").permitAll()
|
||||
.requestMatchers("/actuator/**").permitAll());
|
||||
super.configure(http);
|
||||
setLoginView(http, LoginView.class);
|
||||
setStatelessAuthentication(http, new SecretKeySpec(Base64.getDecoder().decode(authSecret), JwsAlgorithms.HS256),
|
||||
|
||||
@@ -11,19 +11,17 @@ import jakarta.validation.constraints.NotNull;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(indexes = {@Index(columnList = "team_id, player_id, position_id")},
|
||||
uniqueConstraints = {@UniqueConstraint(name = "uniqueRooster", columnNames = {"year", "team_id", "player_id", "position_id"})}
|
||||
)
|
||||
@Table(indexes = { @Index(columnList = "team_id, player_id, position_id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(name = "uniqueRooster", columnNames = { "year", "team_id", "player_id", "position_id" }) })
|
||||
public class Rooster extends AbstractEntity {
|
||||
|
||||
private int year;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "team_id")
|
||||
@NotNull
|
||||
|
||||
@@ -14,7 +14,6 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* Represents a vendor entity.
|
||||
@@ -23,9 +22,7 @@ import lombok.ToString;
|
||||
@Setter
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Entity
|
||||
@Table(indexes = {@Index(columnList = "name")},
|
||||
uniqueConstraints = {@UniqueConstraint(columnNames = "name")}
|
||||
)
|
||||
@Table(indexes = { @Index(columnList = "name") }, uniqueConstraints = { @UniqueConstraint(columnNames = "name") })
|
||||
public class Vendor extends AbstractEntity {
|
||||
|
||||
@NotEmpty
|
||||
|
||||
@@ -24,14 +24,25 @@ spring:
|
||||
multipart:
|
||||
max-file-size: 10MB
|
||||
max-request-size: 10MB
|
||||
camel:
|
||||
cloud:
|
||||
enabled: true
|
||||
springboot:
|
||||
routes-reload-enabled: true
|
||||
routes-reload-directory: routes
|
||||
routes-relaod-pattern: "*.xml"
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
include: health,info,metrics,prometheus,camelroutes
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
probes:
|
||||
enabled: true
|
||||
prometheus:
|
||||
enabled: true
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
@@ -39,6 +50,10 @@ logging:
|
||||
hibernate: INFO
|
||||
springframework:
|
||||
web: INFO
|
||||
jms: DEBUG
|
||||
apache:
|
||||
activemq:
|
||||
artemis: DEBUG
|
||||
guru:
|
||||
springframework:
|
||||
controllers: DEBUG
|
||||
@@ -61,8 +76,13 @@ spring:
|
||||
url: jdbc:postgresql://postgres:5432/kontor
|
||||
username: 'kontor'
|
||||
password: 'kontor'
|
||||
artemis:
|
||||
mode: native
|
||||
broker-url: tcp://activemq:61616
|
||||
user: artemis
|
||||
password: artemis
|
||||
server:
|
||||
port: 8000
|
||||
port: 8100
|
||||
---
|
||||
spring:
|
||||
config:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<property name="LOGS" value="./logs" />
|
||||
<property name="LOGS" value="logs" />
|
||||
|
||||
<appender name="Console"
|
||||
class="ch.qos.logback.core.ConsoleAppender">
|
||||
|
||||
Reference in New Issue
Block a user