-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from JimTheCat/CU-8697bjvqr_EPIC---API-v5---i…
…ntegration-with-OCI-Object-Storage_Kinga-Traczyk feature: Integration with OCI Object Storage
- Loading branch information
Showing
44 changed files
with
731 additions
and
438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,145 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.2.4</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>meowhub</groupId> | ||
<artifactId>backend</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>backend</name> | ||
<description>backend</description> | ||
<properties> | ||
<java.version>21</java.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc8</artifactId> | ||
<version>19.8.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-security</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-validation</artifactId> | ||
<version>3.3.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt-api</artifactId> | ||
<version>0.12.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt-impl</artifactId> | ||
<version>0.12.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt-jackson</artifactId> | ||
<version>0.12.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> | ||
<version>2.0.2</version> | ||
</dependency> | ||
</dependencies> | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.2.4</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>meowhub</groupId> | ||
<artifactId>backend</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>backend</name> | ||
<description>backend</description> | ||
<properties> | ||
<java.version>22</java.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc8</artifactId> | ||
<version>19.8.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-security</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-validation</artifactId> | ||
<version>3.3.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt-api</artifactId> | ||
<version>0.12.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt-impl</artifactId> | ||
<version>0.12.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt-jackson</artifactId> | ||
<version>0.12.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> | ||
<version>2.0.2</version> | ||
</dependency> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependency> | ||
<groupId>com.oracle.oci.sdk</groupId> | ||
<artifactId>oci-java-sdk-addons-resteasy-client-configurator</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.oracle.oci.sdk</groupId> | ||
<artifactId>oci-java-sdk-objectstorage</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.oracle.oci.sdk</groupId> | ||
<artifactId>oci-java-sdk-common-httpclient-jersey</artifactId> | ||
</dependency> | ||
<!-- Other dependencies --> | ||
<dependency> | ||
<groupId>javax.xml.bind</groupId> | ||
<artifactId>jaxb-api</artifactId> | ||
<version>2.3.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jaxb</groupId> | ||
<artifactId>jaxb-runtime</artifactId> | ||
<version>2.3.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.18.0</version> <!-- Sprawdź najnowszą wersję na Maven Central --> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.oracle.oci.sdk</groupId> | ||
<artifactId>oci-java-sdk-bom</artifactId> | ||
<version>3.55.1</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oracle.oci.sdk</groupId> | ||
<artifactId>oci-java-sdk-common-httpclient-jersey</artifactId> | ||
<version>3.55.1</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
23 changes: 23 additions & 0 deletions
23
backend/src/main/java/meowhub/backend/ext/oci/MockOCIUploadService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package meowhub.backend.ext.oci; | ||
|
||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.util.logging.Logger; | ||
|
||
@Service | ||
@Profile("mock-oci") | ||
public class MockOCIUploadService extends OCIUploadService { | ||
Logger logger = Logger.getLogger(getClass().getName()); | ||
|
||
@Override | ||
public void upload(MultipartFile file, String objectName) throws Exception { | ||
logger.info("Mock upload: %s" + objectName); | ||
} | ||
|
||
@Override | ||
public String getFileObjectUrl(String objectName) throws Exception { | ||
return "https://mock-oci-url.com/" + objectName; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
backend/src/main/java/meowhub/backend/ext/oci/OCIClientConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package meowhub.backend.ext.oci; | ||
|
||
import com.oracle.bmc.ConfigFileReader; | ||
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider; | ||
import com.oracle.bmc.objectstorage.ObjectStorage; | ||
import com.oracle.bmc.objectstorage.ObjectStorageClient; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.io.IOException; | ||
|
||
@Configuration | ||
public class OCIClientConfiguration { | ||
// Path to OCI configs file | ||
String configurationFilePath = "backend/src/main/resources/config"; | ||
String profile = "DEFAULT"; | ||
|
||
public ObjectStorage getObjectStorage() throws IOException { | ||
//load configs file | ||
final ConfigFileReader.ConfigFile configFile = ConfigFileReader.parse(configurationFilePath, profile); | ||
final ConfigFileAuthenticationDetailsProvider provider = new ConfigFileAuthenticationDetailsProvider(configFile); | ||
|
||
//build and return client | ||
return ObjectStorageClient.builder().build(provider); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
backend/src/main/java/meowhub/backend/ext/oci/OCIController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package meowhub.backend.ext.oci; | ||
|
||
import jakarta.annotation.security.RolesAllowed; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@RestController | ||
@RequestMapping("api/ext") | ||
@Deprecated(since = "only to test connection with OCI Object Storage. Otherwise - don't use!!!", forRemoval = true) | ||
@RolesAllowed("ROLE_ADMIN") | ||
public class OCIController { | ||
private static final String urlPrefix = "https://objectstorage.eu-frankfurt-1.oraclecloud.com"; | ||
|
||
@Autowired | ||
private OCIUploadService ociUploadService; | ||
|
||
@PostMapping(path = "upload") | ||
public ResponseEntity<Object> uploadFile(@RequestParam("file") MultipartFile file){ | ||
try { | ||
ociUploadService.upload(file, "TEST/"+file.getOriginalFilename()); | ||
return ResponseEntity.ok().body("Uploaded File : "+file.getOriginalFilename()); | ||
} catch (Exception e) { | ||
return ResponseEntity.internalServerError().body(e.getMessage()); | ||
} | ||
} | ||
|
||
@GetMapping(path = "file/{fileName}") | ||
public ResponseEntity<Object> getURl(@PathVariable(value = "fileName") String fileName){ | ||
try { | ||
return ResponseEntity.ok().body(ociUploadService.getFileObjectUrl(fileName)); | ||
} catch (Exception e) { | ||
return ResponseEntity.internalServerError().body(e.getMessage()); | ||
} | ||
} | ||
} |
Oops, something went wrong.