Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
98d0550
FF-251 Added basic structure and exception + handler.
open-schnick Dec 25, 2020
7f03f3f
Cleanup. Reworked custom Exceptions.
open-schnick Dec 25, 2020
8603fdf
Cleanup. Implemented Change in UnitTests.
open-schnick Dec 25, 2020
a3f6460
Cleanup. Implemented necessary changes to cucumber steps
open-schnick Dec 26, 2020
0324924
added the .feature file for deleting
qvalentin Dec 27, 2020
e0d388a
FileSystemItem now includes the User
open-schnick Dec 27, 2020
9dff8a4
fixed copy pesto, added step function
qvalentin Dec 27, 2020
1aae46c
removed the empty lines
qvalentin Dec 27, 2020
f597afd
minor fixes, recusive scenarion for permissions
qvalentin Dec 27, 2020
bdca270
Merge remote-tracking branch 'origin/feature/FF-251' into feature/FF-251
open-schnick Dec 28, 2020
0f30212
Cleanup. Refactored getContentsOfFolder.
open-schnick Dec 28, 2020
cc5db3a
Commented out feature.
open-schnick Dec 28, 2020
5d52a17
Implemented TODO, updated tests.
open-schnick Dec 28, 2020
b47ecd9
WIP. basic structure, added wip comments
open-schnick Dec 29, 2020
3c11c0f
WIP. added checks for invisible entities.
open-schnick Dec 29, 2020
763d05b
WIP. started implementing. Added more comments.
open-schnick Dec 30, 2020
9d39e6a
Fixed Tests.
open-schnick Jan 2, 2021
7cbe309
FF-251 finished adding logic.
open-schnick Jan 2, 2021
b9abd26
Added UnitTests (1/2)
open-schnick Jan 2, 2021
77735a6
added some comments to understand the recursion
qvalentin Jan 3, 2021
e41df8e
Fixing, refactoring.
open-schnick Jan 3, 2021
9492db9
Added UnitTests (1,95/2)
open-schnick Jan 3, 2021
1269dab
merge. included @qvalentin 's comments.
open-schnick Jan 3, 2021
e634d35
Fixing spelling, and minor bugs in feature files.
open-schnick Jan 3, 2021
aec4c15
Implemented requested changes by @qvalentin
open-schnick Jan 3, 2021
6443646
Some more cleanup.
open-schnick Jan 4, 2021
b2b0134
Implemented return value, and Cucumber Steps.
open-schnick Jan 4, 2021
551d83a
It seems that deleteAll doesnt work, so we need to do that.
open-schnick Jan 4, 2021
6decf6c
WIP: update tests.
open-schnick Jan 7, 2021
f174c4e
Merge branch 'master' into feature/FF-251
open-schnick Jan 8, 2021
c85c4bf
Fixed broken merge.
open-schnick Jan 8, 2021
189739f
Fixed Tests, finished implementing.
open-schnick Jan 9, 2021
cf9f3d1
Added one more scenario
open-schnick Jan 9, 2021
4d46bbe
Bumped Version to v0.0.7
open-schnick Jan 9, 2021
7d7349d
Implemented changes by @qvalentin
open-schnick Jan 9, 2021
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 pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>de.filefighter</groupId>
<artifactId>rest</artifactId>
<version>0.0.6</version>
<version>0.0.7</version>
<name>RestApi</name>
<description>RestApi for FileFighter</description>

Expand Down
30 changes: 22 additions & 8 deletions src/main/java/de/filefighter/rest/configuration/CorsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,35 @@
@Configuration
public class CorsConfig {

@Bean
@Profile("dev")
public CorsFilter corsFilter() {
final CorsConfiguration config = new CorsConfiguration().applyPermitDefaultValues();
ArrayList<String> allowedOrigins = new ArrayList<>();
allowedOrigins.add("*");
config.setAllowedOrigins(allowedOrigins);
private final ArrayList<String> allowedMethods;

ArrayList<String> allowedMethods = new ArrayList<>();
public CorsConfig() {
this.allowedMethods = new ArrayList<>();
allowedMethods.add("HEAD");
allowedMethods.add("GET");
allowedMethods.add("POST");
allowedMethods.add("PUT");
allowedMethods.add("DELETE");
allowedMethods.add("OPTIONS");
}

@Bean
@Profile("dev")
public CorsFilter corsFilterDev() {
final CorsConfiguration config = new CorsConfiguration().applyPermitDefaultValues();
ArrayList<String> allowedOrigins = new ArrayList<>();
allowedOrigins.add("*");
config.setAllowedOrigins(allowedOrigins);

final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}

@Bean
@Profile({"prod","test"})
public CorsFilter corsFilterProd() {
final CorsConfiguration config = new CorsConfiguration();
config.setAllowedMethods(allowedMethods);

final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ CommandLineRunner cleanDataBase(UserRepository userRepository, FileSystemReposit
CommandLineRunner createRuntimeUser(UserRepository userRepository) {
return args -> log.info("Preloading system runtime user. {}", userRepository.save(UserEntity
.builder()
.userId(0L)
.userId(RestConfiguration.RUNTIME_USER_ID)
.username("FileFighter")
.lowercaseUsername("filefighter")
.password(null)
Expand All @@ -102,7 +102,7 @@ CommandLineRunner initDataBaseProd(UserRepository userRepository, FileSystemRepo

log.info("Preloading default fsStructure: {} {}.", fileSystemRepository.save(FileSystemEntity
.builder()
.createdByUserId(0)
.createdByUserId(RestConfiguration.RUNTIME_USER_ID)
.fileSystemId(0)
.isFile(false)
.path("/")
Expand Down Expand Up @@ -171,7 +171,7 @@ CommandLineRunner initDataBaseDev(UserRepository userRepository, AccessTokenRepo

log.info("Preloading default fsItems: {} {} {}.",
fileSystemRepository.save(FileSystemEntity.builder()
.createdByUserId(0)
.createdByUserId(RestConfiguration.RUNTIME_USER_ID)
.fileSystemId(0)
.isFile(false)
.path("/")
Expand All @@ -183,7 +183,7 @@ CommandLineRunner initDataBaseDev(UserRepository userRepository, AccessTokenRepo
.visibleForGroupIds(new long[]{FAMILY.getGroupId(), ADMIN.getGroupId()})
.build()),
fileSystemRepository.save(FileSystemEntity.builder()
.createdByUserId(0)
.createdByUserId(RestConfiguration.RUNTIME_USER_ID)
.fileSystemId(1)
.isFile(false)
.path("/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class RestConfiguration {
public static final String FS_PATH_HEADER = "X-FF-PATH";
public static final String USER_BASE_URI = "/users/";
public static final String DEFAULT_ERROR_URI = "/error";
public static final long RUNTIME_USER_ID = 0;

private RestConfiguration(){
// Cannot be instantiated.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.filefighter.rest.rest.exceptions;
package de.filefighter.rest.domain.common.exceptions;

import de.filefighter.rest.domain.health.business.SystemHealthBusinessService;
import de.filefighter.rest.domain.health.data.SystemHealth;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.filefighter.rest.domain.common.exceptions;

import org.springframework.dao.DataAccessException;

public class FileFighterDataException extends DataAccessException implements FileFighterException {

private static final String ERROR_MESSAGE_PREFIX = "Internal Error occurred.";

public FileFighterDataException(String msg) {
super(ERROR_MESSAGE_PREFIX + " " + msg);
}

public static String getErrorMessagePrefix() {
return ERROR_MESSAGE_PREFIX;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.filefighter.rest.domain.common.exceptions;

public interface FileFighterException {
static String getErrorMessagePrefix() {
throw new IllegalArgumentException("Custom exception should overwrite this message.");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.filefighter.rest.domain.common;
package de.filefighter.rest.domain.common.exceptions;

import de.filefighter.rest.rest.exceptions.RequestDidntMeetFormalRequirementsException;
import org.springframework.stereotype.Service;

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.filefighter.rest.rest.exceptions;
package de.filefighter.rest.domain.common.exceptions;

import de.filefighter.rest.rest.ServerResponse;
import lombok.extern.log4j.Log4j2;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package de.filefighter.rest.domain.common.exceptions;

public class RequestDidntMeetFormalRequirementsException extends RuntimeException implements FileFighterException {

private static final String ERROR_MESSAGE_PREFIX = "Request didnt meet formal requirements.";

public RequestDidntMeetFormalRequirementsException() {
super(ERROR_MESSAGE_PREFIX);
}

public RequestDidntMeetFormalRequirementsException(String reason) {
super(ERROR_MESSAGE_PREFIX + " " + reason);
}

public static String getErrorMessagePrefix() {
return ERROR_MESSAGE_PREFIX;
}
}
Loading