Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
243001a
feat: added github actions based on build test push image and trigger…
Saccilotto Mar 4, 2025
18370cc
feat: add owner to folder class in domain and add method to retrieve…
MatheusmPigatto Mar 4, 2025
ca1f67b
feat: adds new ownerId to create method params on create folder use c…
MatheusmPigatto Mar 4, 2025
37443f0
Merge branch 'develop' into feature/folder-owner
MatheusmPigatto Mar 10, 2025
f9f3d0a
fix: update createFolder method to use owner object for ID retrieval
MatheusmPigatto Mar 10, 2025
aef39c8
feat: integrate owner ID retrieval in create folder method for enhanc…
MatheusmPigatto Mar 10, 2025
2f14a33
feat: add member gateway to create folder use case for improved funct…
MatheusmPigatto Mar 10, 2025
f0c3487
feat: update FolderAdapter to include owner ID in folder creation input
MatheusmPigatto Mar 10, 2025
eb9b9b3
feat: add owner ID field to FolderJpaEntity for improved folder owner…
MatheusmPigatto Mar 10, 2025
c3188cf
feat: implement existsById method in MemberGateway for member existen…
MatheusmPigatto Mar 14, 2025
6ea2d47
feat: enhance folder use cases to include owner ID for improved owner…
MatheusmPigatto Mar 19, 2025
97ce7ce
feat: implement GetRootFolder use case with owner ID for improved fol…
MatheusmPigatto Mar 19, 2025
500fa4b
Merge pull request #22 from CallVDois/feature/folder-owner
jhonatapers Mar 19, 2025
86e5948
chore: remove version declaration from build.gradle
jhonatapers Mar 23, 2025
7eacd27
chore: set destination directory for build artifacts in build.gradle
jhonatapers Mar 23, 2025
14f04ee
chore: remove client configuration for user-api from application-loca…
jhonatapers Mar 23, 2025
3e3ed8f
feat: add application-hmg.yml for environment-specific configuration
jhonatapers Mar 23, 2025
a0cef09
feat: add Dockerfile and .dockerignore for containerization
jhonatapers Mar 23, 2025
223424a
Merge pull request #24 from CallVDois/feature/dockerfile
jhonatapers Mar 23, 2025
c90d4e4
Merge branch 'develop' into feature/add-actions
jhonatapers May 13, 2025
1d1e2a3
fix: update gradlew file permissions to executable
jhonatapers May 13, 2025
143dbd1
feat: add GitHub Actions workflows for Docker image build and push; u…
jhonatapers May 13, 2025
641f19b
Merge pull request #26 from CallVDois/feature/add-actions
jhonatapers May 13, 2025
cb363a0
fix: fix application configuration files for production and local env…
jhonatapers May 14, 2025
89d7cbf
Merge pull request #27 from CallVDois/hotfix/fix-develop
jhonatapers May 14, 2025
bf27a5e
feat: implement execution and error context records; add logging aspe…
jhonatapers May 15, 2025
a3f16b1
feat: add ArgsLogAspect and SignatureLogAspect for enhanced logging o…
jhonatapers May 15, 2025
ecd42b6
feat: add StackTraceLogAspect for enhanced error logging
jhonatapers May 15, 2025
8bd1420
feat: implement logging aspects for execution and error handling; add…
jhonatapers May 15, 2025
60a7137
feat: add logging configuration and implement aspect handlers for exe…
jhonatapers May 15, 2025
5c31d41
chore: update .gitignore to include additional environment and log files
jhonatapers May 15, 2025
8347325
Refactor AOP structure and logging aspects
jhonatapers May 16, 2025
2574d6f
feat: implement AspectExecutorChain and refactor method invocation ch…
jhonatapers May 17, 2025
8836f70
feat: enhance AOP structure with new context handling and logging exe…
jhonatapers May 17, 2025
2c5817d
feat: change package
jhonatapers May 17, 2025
2d8c56a
fix: correct logging level configuration in application.yml and ensur…
jhonatapers May 17, 2025
3db5e1b
feat: update logging levels in AspectConfig for improved debugging an…
jhonatapers May 17, 2025
13d891c
feat: add storage location configuration in Dockerfile for improved d…
jhonatapers May 17, 2025
06208b5
fix: Dokerfile dir's
jhonatapers May 17, 2025
1ed30e8
fix: update Spring Boot version to 3.4.5 in build.gradle
jhonatapers May 17, 2025
4ff3f44
refactor: replace application-dev.yml and application-local.yml with …
jhonatapers May 18, 2025
b8c11a0
feat: add .env.example and log4j2-spring.xml for environment configur…
jhonatapers May 18, 2025
433adc6
fix: update .gitignore to include *.log.json for log file exclusion
jhonatapers May 18, 2025
dfc4831
refactor: remove DomainLogConfig class
jhonatapers May 18, 2025
88efce1
fix: enhance JsonLog configuration to include stacktrace as string
jhonatapers May 18, 2025
368036a
refactor: remove LOG_JSON_PATTERN property from log4j2-spring.xml
jhonatapers May 18, 2025
faf9b49
fix: correct typo in variable name for postInvocationResult in Simple…
jhonatapers May 18, 2025
93963d8
fix: replace jakarta annotations with javax annotations in MethodInvo…
jhonatapers May 18, 2025
f70d5f1
fix: return result from next executor in AspectExecutorChain
jhonatapers May 18, 2025
4cad21e
fix: improve error handling in SimpleMethodInterceptorWithContextHandler
jhonatapers May 18, 2025
1b05cf4
fix: improve logging format in MethodSignatureLogExecutor, PostTeleme…
jhonatapers May 18, 2025
caca724
feat: add ArgsLogExecutor for logging method calls and arguments
jhonatapers May 18, 2025
64db9df
feat: add ArgsLogExecutor to MethodInvocationAspectExecutorChain for …
jhonatapers May 18, 2025
c7faab6
fix: add @Nonnull annotations to context retrieval methods for improv…
jhonatapers May 18, 2025
aa1d5a9
Merge pull request #30 from CallVDois/feature/aop
jhonatapers May 18, 2025
d7e6c6c
feat: add forward-headers-strategy configuration to environment files…
jhonatapers May 22, 2025
482e8a9
Merge pull request #31 from CallVDois/feature/enable-proxy-forward-he…
jhonatapers May 22, 2025
9bc2a84
feat: add CORS configuration properties to support cross-origin requests
jhonatapers May 27, 2025
0becab1
Merge pull request #33 from CallVDois/feature/cors
jhonatapers May 27, 2025
9790524
feat: allow OPTIONS requests for CORS and streamline session manageme…
jhonatapers May 28, 2025
8cb9b75
Merge pull request #34 from CallVDois/feature/cors
jhonatapers May 28, 2025
f05f302
feat: allow OPTIONS requests for all endpoints in security configuration
jhonatapers May 28, 2025
cb6478b
Merge pull request #35 from CallVDois/feature/cors
jhonatapers May 28, 2025
25f4954
fix: rename allowedOriginsPatterns to allowedOrigins in CORS configur…
jhonatapers May 28, 2025
a3cf684
Merge pull request #36 from CallVDois/fix/cors
jhonatapers May 28, 2025
352e928
Merge pull request #37 from CallVDois/develop
jhonatapers May 28, 2025
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
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.git
.github
.gradle
**/build
**/out
**/target
.idea
.vscode
**/*.iml
**/*.ipr
**/*.iws
**/.DS_Store
36 changes: 36 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
SPRING_PROFILES_ACTIVE=env

SERVER_PORT=8080
FORWARD_HEADERS_STRATEGY=framework #none for no proxy, framework for Spring Cloud Gateway, native for native proxy
REQUEST_TIMEOUT=60000

CORS_PATTERN=/**
CORS_ALLOWED_ORIGINS=*
CORS_ALLOWED_METHODS=GET,POST,PUT,PATCH,DELETE,OPTIONS
CORS_ALLOWED_HEADERS=*
CORS_ALLOW_CREDENTIALS=true

KEYCLOAK_HOST=http://localhost:8090
KEYCLOAK_REALM=heroes

POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DATABASE=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

DB_DDL_AUTO=none

STORAGE_LOCATION=/srv/drive/storage/
MAX_FILE_SIZE=2048MB
MAX_REQUEST_SIZE=100MB

LOG_PATH=log
ROOT_LOG_LEVEL=trace
ROOT_LOG_LEVEL_CONSOLE=info
ROOT_LOG_LEVEL_FILE=info
ROOT_LOG_LEVEL_JSON=info
CALLV2_LOG_LEVEL=trace
CALLV2_LOG_LEVEL_CONSOLE=debug
CALLV2_LOG_LEVEL_FILE=debug
CALLV2_LOG_LEVEL_JSON=debug
42 changes: 42 additions & 0 deletions .github/workflows/build-and-push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: build-and-push-docker-image

on:
workflow_call:
inputs:
imageName:
required: true
type: string
imageTag:
required: true
type: string
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
docker:
runs-on: [self-hosted, Linux, X64]
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ inputs.imageName }}:${{ inputs.imageTag }}
16 changes: 16 additions & 0 deletions .github/workflows/latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Release build & push to Docker Hub

on:
push:
branches:
- main

jobs:
release-build-push:
uses: ./.github/workflows/build-and-push-docker-image.yml
with:
imageName: drive-api
imageTag: latest
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Develop nightly build & push to Docker Hub

on:
push:
branches:
- develop

jobs:
nightly-build-push:
uses: ./.github/workflows/build-and-push-docker-image.yml
with:
imageName: drive-api
imageTag: nightly
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Release build & push to Docker Hub

on:
release:
types: [published]

jobs:
release-build-push:
uses: ./.github/workflows/build-and-push-docker-image.yml
with:
imageName: drive-api
imageTag: ${{ github.event.release.tag_name }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ bin


*.db


.env

*.log
*.log.json
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM eclipse-temurin:21.0.7_6-jdk-alpine AS builder

WORKDIR /usr/app

COPY . .

RUN ./gradlew clean bootJar --no-daemon

FROM eclipse-temurin:21.0.7_6-jdk-alpine

COPY --from=builder /usr/app/build/libs/application.jar /opt/app/application.jar

ENV STORAGE_LOCATION=/srv/drive/storage

RUN mkdir -p $STORAGE_LOCATION
RUN addgroup -S app && adduser -S app -G app
RUN chown -R app:app /srv/drive/storage/
USER app:app



EXPOSE 80

CMD ["sh", "-c", "java -jar /opt/app/application.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import java.util.UUID;

public record CreateFolderInput(String name, UUID parentFolderId) {
public record CreateFolderInput(String ownerId, String name, UUID parentFolderId) {

public static CreateFolderInput from(String name, UUID parentFolderId) {
return new CreateFolderInput(name, parentFolderId);
public static CreateFolderInput from(String ownerdId, String name, UUID parentFolderId) {
return new CreateFolderInput(ownerdId, name, parentFolderId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,44 @@
import com.callv2.drive.domain.folder.FolderGateway;
import com.callv2.drive.domain.folder.FolderID;
import com.callv2.drive.domain.folder.FolderName;
import com.callv2.drive.domain.member.Member;
import com.callv2.drive.domain.member.MemberGateway;
import com.callv2.drive.domain.member.MemberID;
import com.callv2.drive.domain.validation.Error;
import com.callv2.drive.domain.validation.handler.Notification;

public class DefaultCreateFolderUseCase extends CreateFolderUseCase {

private final MemberGateway memberGateway;
private final FolderGateway folderGateway;

public DefaultCreateFolderUseCase(final FolderGateway folderGateway) {
public DefaultCreateFolderUseCase(final MemberGateway memberGateway, final FolderGateway folderGateway) {
this.memberGateway = memberGateway;
this.folderGateway = folderGateway;
}

@Override
public CreateFolderOutput execute(final CreateFolderInput input) {
final MemberID ownerId = MemberID.of(input.ownerId());

if (!memberGateway.existsById(ownerId))
throw NotFoundException.with(Member.class, input.ownerId().toString());

final Folder parentFolder = folderGateway
.findById(FolderID.of(input.parentFolderId()))
.orElseThrow(() -> NotFoundException.with(
Folder.class,
"Parent folder with id %s not found".formatted(input.parentFolderId().toString())));

return CreateFolderOutput.from(createFolder(FolderName.of(input.name()), parentFolder));
return CreateFolderOutput.from(createFolder(ownerId, FolderName.of(input.name()), parentFolder));
}

private Folder createFolder(final FolderName name, final Folder parentFolder) {
private Folder createFolder(final MemberID ownerId, FolderName name, final Folder parentFolder) {
final Notification notification = Notification.create();
if (parentFolder.getSubFolders().stream().anyMatch(subFolder -> subFolder.name().equals(name)))
notification.append(Error.with("Folder with the same name already exists"));

final Folder folder = notification.valdiate(() -> Folder.create(name, parentFolder));
final Folder folder = notification.valdiate(() -> Folder.create(ownerId, name, parentFolder));

if (notification.hasError())
throw ValidationException.with("Could not create Aggregate Folder", notification);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,39 @@
import java.util.Objects;
import java.util.Optional;

import com.callv2.drive.domain.exception.NotFoundException;
import com.callv2.drive.domain.file.FileGateway;
import com.callv2.drive.domain.folder.Folder;
import com.callv2.drive.domain.folder.FolderGateway;
import com.callv2.drive.domain.member.Member;
import com.callv2.drive.domain.member.MemberGateway;
import com.callv2.drive.domain.member.MemberID;

public class DefaultGetRootFolderUseCase extends GetRootFolderUseCase {

private final MemberGateway memberGateway;
private final FolderGateway folderGateway;
private final FileGateway fileGateway;

public DefaultGetRootFolderUseCase(
final MemberGateway memberGateway,
final FolderGateway folderGateway,
final FileGateway fileGateway) {
this.memberGateway = Objects.requireNonNull(memberGateway);
this.folderGateway = Objects.requireNonNull(folderGateway);
this.fileGateway = Objects.requireNonNull(fileGateway);
}

@Override
public GetRootFolderOutput execute() {
public GetRootFolderOutput execute(final GetRootFolderInput input) {

final MemberID owner = MemberID.of(input.ownerId());

if (!memberGateway.existsById(owner))
throw NotFoundException.with(Member.class, owner.getValue().toString());

final Optional<Folder> root = folderGateway.findRoot();
final Folder folder = root.isPresent() ? root.get() : folderGateway.create(Folder.createRoot());
final Folder folder = root.isPresent() ? root.get() : folderGateway.create(Folder.createRoot(owner));
return GetRootFolderOutput.from(folder, fileGateway.findByFolder(folder.getId()));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.callv2.drive.application.folder.retrieve.get.root;
public record GetRootFolderInput(String ownerId) {

public static GetRootFolderInput from(final String ownerId) {
return new GetRootFolderInput(ownerId);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.callv2.drive.application.folder.retrieve.get.root;

import com.callv2.drive.application.NullaryUseCase;
import com.callv2.drive.application.UseCase;

public abstract class GetRootFolderUseCase extends NullaryUseCase<GetRootFolderOutput> {
public abstract class GetRootFolderUseCase extends UseCase<GetRootFolderInput, GetRootFolderOutput> {

}
Loading