Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
cache: maven

- name: Build
run: mvn -B clean verify
run: mvn -B clean verify spotless:check

- name: Publish test results
uses: dorny/test-reporter@v3
Expand Down
21 changes: 21 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,27 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<java>
<googleJavaFormat/>
<removeUnusedImports/>
<trimTrailingWhitespace/>
<endWithNewline/>
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
Comment thread
FionaSprinkles marked this conversation as resolved.
</plugins>
</build>

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/example/alfs/AlfsApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
@SpringBootApplication
public class AlfsApplication {

public static void main(String[] args) {
SpringApplication.run(AlfsApplication.class, args);
}

public static void main(String[] args) {
SpringApplication.run(AlfsApplication.class, args);
}
}
10 changes: 5 additions & 5 deletions src/main/java/org/example/alfs/config/DemoDataInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
@RequiredArgsConstructor
public class DemoDataInitializer implements CommandLineRunner {

private final DemoDataService demoDataService;
private final DemoDataService demoDataService;

@Override
public void run(String... args) {
demoDataService.seedDemoData();
}
@Override
public void run(String... args) {
demoDataService.seedDemoData();
}
}
51 changes: 26 additions & 25 deletions src/main/java/org/example/alfs/config/GlobalModelAttributes.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
package org.example.alfs.config;

import org.example.alfs.security.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.example.alfs.security.SecurityUtils;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

@ControllerAdvice
public class GlobalModelAttributes {
private static final Logger log = LoggerFactory.getLogger(GlobalModelAttributes.class);
private final SecurityUtils securityUtils;

public GlobalModelAttributes(SecurityUtils securityUtils) {
this.securityUtils = securityUtils;
}
private static final Logger log = LoggerFactory.getLogger(GlobalModelAttributes.class);
private final SecurityUtils securityUtils;

@ModelAttribute
public void addGlobalAttributes(Model model) {
public GlobalModelAttributes(SecurityUtils securityUtils) {
this.securityUtils = securityUtils;
}

boolean isLoggedIn = false;
String username = null;
String role = null;
try {
var user = securityUtils.getCurrentUser();
isLoggedIn = true;
username = user.getUsername();
role = user.getRole().name();
} catch (RuntimeException ex) {
log.debug("Could not resolve current user for global model attributes", ex);
}
@ModelAttribute
public void addGlobalAttributes(Model model) {

model.addAttribute("isLoggedIn", isLoggedIn);
model.addAttribute("username", username);
model.addAttribute("role", role);
boolean isLoggedIn = false;
String username = null;
String role = null;
try {
var user = securityUtils.getCurrentUser();
isLoggedIn = true;
username = user.getUsername();
role = user.getRole().name();
} catch (RuntimeException ex) {
log.debug("Could not resolve current user for global model attributes", ex);
}
}

model.addAttribute("isLoggedIn", isLoggedIn);
model.addAttribute("username", username);
model.addAttribute("role", role);
}
}
10 changes: 5 additions & 5 deletions src/main/java/org/example/alfs/config/PasswordConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
@Configuration
public class PasswordConfig {

// Makes password encoder available in the whole app
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder();
}
// Makes password encoder available in the whole app
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
89 changes: 42 additions & 47 deletions src/main/java/org/example/alfs/config/S3Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,58 @@
@Validated
@ConfigurationProperties(prefix = "storage.s3")
public class S3Properties {
@NotBlank
private String endpoint;
@NotBlank
private String accessKey;
@NotBlank
private String secretKey;
@NotBlank
private String bucket;
@NotBlank
private String region;
private boolean secure;
@NotBlank private String endpoint;
@NotBlank private String accessKey;
@NotBlank private String secretKey;
@NotBlank private String bucket;
@NotBlank private String region;
private boolean secure;

public String getEndpoint() {
return endpoint;
}
public String getEndpoint() {
return endpoint;
}

public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}

public String getAccessKey() {
return accessKey;
}
public String getAccessKey() {
return accessKey;
}

public void setAccessKey(String accessKey) {
this.accessKey = accessKey;
}
public void setAccessKey(String accessKey) {
this.accessKey = accessKey;
}

public String getSecretKey() {
return secretKey;
}
public String getSecretKey() {
return secretKey;
}

public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}
public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}

public String getBucket() {
return bucket;
}
public String getBucket() {
return bucket;
}

public void setBucket(String bucket) {
this.bucket = bucket;
}
public void setBucket(String bucket) {
this.bucket = bucket;
}

public String getRegion() {
return region;
}
public String getRegion() {
return region;
}

public void setRegion(String region) {
this.region = region;
}
public void setRegion(String region) {
this.region = region;
}

public boolean isSecure() {
return secure;
}
public boolean isSecure() {
return secure;
}

public void setSecure(boolean secure) {
this.secure = secure;
}
public void setSecure(boolean secure) {
this.secure = secure;
}
}
Loading
Loading