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
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
14 changes: 14 additions & 0 deletions .run/AllJUnitTests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run All Tests" type="JUnit" factoryName="JUnit">
<module name="RestApi" />
<useClassPathOnly />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="PARAMETERS" value="" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<option name="FILE_PATH" value="$PROJECT_DIR$/src/test/cucumber/de/filefighter/rest" />
<option name="GLUE" value="de.filefighter.rest.cucumber" />
<option name="MAIN_CLASS_NAME" value="io.cucumber.core.cli.Main" />
<module name="rest" />
<module name="RestApi" />
<option name="PROGRAM_PARAMETERS" value=" --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter" />
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
<method v="2">
Expand Down
17 changes: 17 additions & 0 deletions .run/JUnit Tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run only Unit Tests" type="JUnit" factoryName="JUnit">
<module name="RestApi" />
<useClassPathOnly />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="pattern" />
<option name="PARAMETERS" value="" />
<patterns>
<pattern testClass="^(.*)UnitTest$" />
</patterns>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration name="RestApplication[DEV]" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="rest" />
<configuration default="false" name="RestApplication[DEV]" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="RestApi" />
<option name="SPRING_BOOT_MAIN_CLASS" value="de.filefighter.rest.RestApplication" />
<option name="ACTIVE_PROFILES" value="dev" />
<option name="ALTERNATIVE_JRE_PATH" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="RestApplication[PROD]" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="rest" />
<module name="RestApi" />
<option name="SPRING_BOOT_MAIN_CLASS" value="de.filefighter.rest.RestApplication" />
<option name="ACTIVE_PROFILES" value="prod" />
<option name="ALTERNATIVE_JRE_PATH" />
Expand Down
File renamed without changes.
15 changes: 7 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</parent>
<groupId>de.filefighter</groupId>
<artifactId>rest</artifactId>
<version>0.0.2</version>
<name>rest</name>
<description>RestApi</description>
<version>0.0.3-Snapshot</version>
<name>RestApi</name>
<description>RestApi for FileFighter</description>

<properties>
<java.version>11</java.version>
Expand Down Expand Up @@ -43,12 +43,12 @@
<version>1.18.12</version>
</dependency>

<!-- tag::spring-hateoas[] -->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<!-- end::spring-hateoas[] -->

<!-- TESTING -->
<dependency>
Expand Down Expand Up @@ -76,7 +76,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/de/filefighter/rest/RestApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

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

@Bean
public RestTemplate getRestTemplate() {
return new RestTemplate();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.filefighter.rest.configuration;

import de.filefighter.rest.domain.user.data.persistance.UserEntitiy;
import de.filefighter.rest.domain.user.data.persistance.UserEntity;
import de.filefighter.rest.domain.user.data.persistance.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -22,7 +22,14 @@ CommandLineRunner initUserDataBase(UserRepository repository) {
return args -> {
LOG.info("Starting with clean user collection.");
repository.deleteAll();
LOG.info("Preloading default admin user: " + repository.save(new UserEntitiy(0L, "admin", "admin", "refreshToken1234", 0, 1)));
LOG.info("Preloading default admin user: " + repository.save(UserEntity
.builder()
.userId(0L)
.username("admin")
.password("admin")
.refreshToken("refreshToken1234")
.roleIds(new long[]{0, 1})
.build()));
LOG.info("Loading Users" + (repository.findAll().size() == 1 ? " was successful." : " failed."));
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class RestConfiguration {
public static final String BASE_API_URI = "/api/v1/";
public static final String AUTHORIZATION_BASIC_PREFIX = "Basic: ";
public static final String AUTHORIZATION_BEARER_PREFIX = "Bearer: ";
public final static String FS_BASE_URI = "/filesystem/";
public final static String USER_BASE_URI = "/users/";

public static final String FS_BASE_URI = "/filesystem/";
public static final String FS_PATH_HEADER = "X-FF-PATH";
public static final String USER_BASE_URI = "/users/";

@Bean
public WebMvcConfigurer configurer(){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.filefighter.rest.domain.filesystem.business;

import org.springframework.stereotype.Service;

@Service
public class FileSystemBusinessService {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.hateoas.EntityModel;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import static de.filefighter.rest.configuration.RestConfiguration.*;
Expand All @@ -26,8 +26,8 @@ public FileSystemRestController(FileSystemRestServiceInterface fileSystemRestSer
}

@GetMapping(FS_BASE_URI + "contents")
public EntityModel<FolderContents> getContentsOfFolder(
@RequestHeader(value = "X-FF-PATH", defaultValue = "/") String path,
public ResponseEntity<FolderContents> getContentsOfFolder(
@RequestHeader(value = FS_PATH_HEADER, defaultValue = "/") String path,
@RequestHeader(value = "Authorization", defaultValue = AUTHORIZATION_BEARER_PREFIX + "token") String accessToken
) {

Expand All @@ -36,7 +36,7 @@ public EntityModel<FolderContents> getContentsOfFolder(
}

@GetMapping(FS_BASE_URI + "{fsItemId}/info")
public EntityModel<FileSystemItem> getFileOrFolderInfo(
public ResponseEntity<FileSystemItem> getFileOrFolderInfo(
@PathVariable long fsItemId,
@RequestHeader(value = "Authorization", defaultValue = AUTHORIZATION_BEARER_PREFIX + "token") String accessToken
) {
Expand All @@ -46,7 +46,7 @@ public EntityModel<FileSystemItem> getFileOrFolderInfo(
}

@GetMapping(FS_BASE_URI+"search")
public EntityModel<FileSystemItem> searchFileOrFolderByName(
public ResponseEntity<FileSystemItem> searchFileOrFolderByName(
@RequestParam(name = "name", defaultValue = "name") String name,
@RequestHeader(value = "Authorization", defaultValue = AUTHORIZATION_BEARER_PREFIX + "token") String accessToken
){
Expand All @@ -56,7 +56,7 @@ public EntityModel<FileSystemItem> searchFileOrFolderByName(
}

@PostMapping(FS_BASE_URI+"upload")
public EntityModel<FileSystemItem> uploadFileOrFolder(
public ResponseEntity<FileSystemItem> uploadFileOrFolder(
@RequestBody FileSystemItemUpdate fileSystemItemUpdate,
@RequestHeader(value = "Authorization", defaultValue = AUTHORIZATION_BEARER_PREFIX + "token") String accessToken
){
Expand All @@ -66,7 +66,7 @@ public EntityModel<FileSystemItem> uploadFileOrFolder(
}

@PutMapping(FS_BASE_URI+"{fsItemId}/update")
public EntityModel<FileSystemItem> updateExistingFileOrFolder(
public ResponseEntity<FileSystemItem> updateExistingFileOrFolder(
@PathVariable long fsItemId,
@RequestBody FileSystemItemUpdate fileSystemItemUpdate,
@RequestHeader(value = "Authorization", defaultValue = AUTHORIZATION_BEARER_PREFIX + "token") String accessToken
Expand All @@ -77,7 +77,7 @@ public EntityModel<FileSystemItem> updateExistingFileOrFolder(
}

@DeleteMapping(FS_BASE_URI+"{fsItemId}/delete")
public EntityModel<ServerResponse> deleteFileOrFolder(
public ResponseEntity<ServerResponse> deleteFileOrFolder(
@PathVariable long fsItemId,
@RequestHeader(value = "Authorization", defaultValue = AUTHORIZATION_BEARER_PREFIX + "token") String accessToken
){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@
import de.filefighter.rest.domain.filesystem.data.dto.FileSystemItemUpdate;
import de.filefighter.rest.domain.filesystem.data.dto.FolderContents;
import de.filefighter.rest.rest.ServerResponse;
import org.springframework.hateoas.EntityModel;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

@Service
public class FileSystemRestService implements FileSystemRestServiceInterface {

@Override
public EntityModel<FolderContents> getContentsOfFolderByIdAndAccessToken(String path, String accessToken) {
public ResponseEntity<FolderContents> getContentsOfFolderByIdAndAccessToken(String path, String accessToken) {
return null;
}

@Override
public EntityModel<FileSystemItem> getInfoAboutFileOrFolderByIdAndAccessToken(long fsItemId, String accessToken) {
public ResponseEntity<FileSystemItem> getInfoAboutFileOrFolderByIdAndAccessToken(long fsItemId, String accessToken) {
return null;
}

@Override
public EntityModel<FileSystemItem> findFileOrFolderByNameAndAccessToken(String name, String accessToken) {
public ResponseEntity<FileSystemItem> findFileOrFolderByNameAndAccessToken(String name, String accessToken) {
return null;
}

@Override
public EntityModel<FileSystemItem> uploadFileSystemItemWithAccessToken(FileSystemItemUpdate fileSystemItemUpdate, String accessToken) {
public ResponseEntity<FileSystemItem> uploadFileSystemItemWithAccessToken(FileSystemItemUpdate fileSystemItemUpdate, String accessToken) {
return null;
}

@Override
public EntityModel<FileSystemItem> updatedFileSystemItemWithIdAndAccessToken(long fsItemId, FileSystemItemUpdate fileSystemItemUpdate, String accessToken) {
public ResponseEntity<FileSystemItem> updatedFileSystemItemWithIdAndAccessToken(long fsItemId, FileSystemItemUpdate fileSystemItemUpdate, String accessToken) {
return null;
}

@Override
public EntityModel<ServerResponse> deleteFileSystemItemWithIdAndAccessToken(long fsItemId, String accessToken) {
public ResponseEntity<ServerResponse> deleteFileSystemItemWithIdAndAccessToken(long fsItemId, String accessToken) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import de.filefighter.rest.domain.filesystem.data.dto.FileSystemItemUpdate;
import de.filefighter.rest.domain.filesystem.data.dto.FolderContents;
import de.filefighter.rest.rest.ServerResponse;
import org.springframework.hateoas.EntityModel;
import org.springframework.http.ResponseEntity;

public interface FileSystemRestServiceInterface {
EntityModel<FolderContents> getContentsOfFolderByIdAndAccessToken(String path, String accessToken);
EntityModel<FileSystemItem> getInfoAboutFileOrFolderByIdAndAccessToken(long fsItemId, String accessToken);
EntityModel<FileSystemItem> findFileOrFolderByNameAndAccessToken(String name, String accessToken);
EntityModel<FileSystemItem> uploadFileSystemItemWithAccessToken(FileSystemItemUpdate fileSystemItemUpdate, String accessToken);
EntityModel<FileSystemItem> updatedFileSystemItemWithIdAndAccessToken(long fsItemId, FileSystemItemUpdate fileSystemItemUpdate, String accessToken);
EntityModel<ServerResponse> deleteFileSystemItemWithIdAndAccessToken(long fsItemId, String accessToken);
ResponseEntity<FolderContents> getContentsOfFolderByIdAndAccessToken(String path, String accessToken);
ResponseEntity<FileSystemItem> getInfoAboutFileOrFolderByIdAndAccessToken(long fsItemId, String accessToken);
ResponseEntity<FileSystemItem> findFileOrFolderByNameAndAccessToken(String name, String accessToken);
ResponseEntity<FileSystemItem> uploadFileSystemItemWithAccessToken(FileSystemItemUpdate fileSystemItemUpdate, String accessToken);
ResponseEntity<FileSystemItem> updatedFileSystemItemWithIdAndAccessToken(long fsItemId, FileSystemItemUpdate fileSystemItemUpdate, String accessToken);
ResponseEntity<ServerResponse> deleteFileSystemItemWithIdAndAccessToken(long fsItemId, String accessToken);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import de.filefighter.rest.domain.health.data.SystemHealth;
import io.swagger.annotations.Api;
import org.springframework.hateoas.EntityModel;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -17,7 +17,7 @@ public SystemHealthRestController(SystemHealthRestInterface healthRestService) {
}

@GetMapping("/health")
public EntityModel<SystemHealth> getSystemHealthInfo(){
public ResponseEntity<SystemHealth> getSystemHealthInfo(){
return healthRestService.getSystemHealth();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.filefighter.rest.domain.health.rest;

import de.filefighter.rest.domain.health.data.SystemHealth;
import org.springframework.hateoas.EntityModel;
import org.springframework.http.ResponseEntity;

public interface SystemHealthRestInterface {
EntityModel<SystemHealth> getSystemHealth();
ResponseEntity<SystemHealth> getSystemHealth();
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
package de.filefighter.rest.domain.health.rest;

import de.filefighter.rest.domain.health.business.SystemHealthBusinessService;
import de.filefighter.rest.domain.health.business.SystemHealthModelAssembler;
import de.filefighter.rest.domain.health.data.SystemHealth;
import org.springframework.hateoas.EntityModel;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

@Service
public class SystemHealthRestService implements SystemHealthRestInterface {

private final SystemHealthBusinessService systemHealthBusinessService;
private final SystemHealthModelAssembler systemHealthModelAssembler;

public SystemHealthRestService(SystemHealthBusinessService systemHealthBusinessService, SystemHealthModelAssembler systemHealthModelAssembler) {
public SystemHealthRestService(SystemHealthBusinessService systemHealthBusinessService) {
this.systemHealthBusinessService = systemHealthBusinessService;
this.systemHealthModelAssembler = systemHealthModelAssembler;
}

@Override
public EntityModel<SystemHealth> getSystemHealth() {
SystemHealth systemHealth = systemHealthBusinessService.getCurrentSystemHealthInfo();
return systemHealthModelAssembler.toModel(systemHealth);
public ResponseEntity<SystemHealth> getSystemHealth() {
return new ResponseEntity<>(systemHealthBusinessService.getCurrentSystemHealthInfo(), HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.filefighter.rest.domain.permission.business;

import org.springframework.stereotype.Service;

@Service
public class PermissionBusinessService {
}
Loading