Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs/#71] Add annotation using Javadoc entirely #73

Merged
merged 8 commits into from
Dec 1, 2024
15 changes: 15 additions & 0 deletions src/main/java/api/goraebab/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestClient;

/**
* Configuration class for application-level beans.
*
* <p>This class defines beans that are required across the application, ensuring centralized management and
* reusability of these components.</p>
*
* @author whitem4rk
* @version 1.0
*/
@Configuration
public class AppConfig {

/**
* Creates and returns a {@link RestClient} bean for making HTTP requests.
*
* @return a configured instance of {@link RestClient}.
* @see api.goraebab.global.util.ConnectionUtil
*/
@Bean
public RestClient restClient() {
return RestClient.create();
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/api/goraebab/config/CorsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* Configuration class for setting up Cross-Origin Resource Sharing (CORS) rules.
*
* <p>This configuration allows the application to handle requests from different origins,
* enabling cross-origin communication for frontend-backend interactions in a secure and configurable way.</p>
*
* <p>Note: While this configuration is useful for rapid development and testing, a more restrictive policy
* is recommended for production environments to prevent potential security risks such as unauthorized
* access from malicious origins.</p>
*
* <p>For more details about CORS in Spring, refer to the <a href="https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-cors">Spring Documentation</a>.</p>
*
* @author whitem4rk
* @version 1.0
*/
@Configuration
public class CorsConfig implements WebMvcConfigurer {

Expand Down
22 changes: 22 additions & 0 deletions src/main/java/api/goraebab/config/JpaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

/**
* Configuration class for JPA and database connection setup.
*
* <p>This class configures database-related properties, including dialect detection based on the
* {@code spring.datasource.url}, and provides a {@link DataSource} bean for database access.</p>
*
* <p>Additionally, this configuration enables JPA auditing, allowing automatic management of entity audit fields.</p>
*
* <p>Supported DBMS dialects include:</p>
* <ul>
* <li>MySQL</li>
* <li>MariaDB</li>
* <li>PostgreSQL</li>
* <li>Oracle</li>
* <li>SQL Server</li>
* </ul>
*
* @author whitem4rk
* @version 1.0
* @see JpaProperties
* @see DataSource
*/
@Configuration
@EnableJpaAuditing
public class JpaConfig {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/api/goraebab/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* Configuration class for Swagger/OpenAPI documentation.
*
* <p>This configuration sets up the OpenAPI documentation for the application, providing metadata about
* the API such as its title, description, and version. The documentation helps developers understand
* and interact with the API effectively.</p>
*
* @author whitem4rk
* @version 1.0
* @see OpenAPI
* @see Info
*/
@Configuration
public class SwaggerConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* Request DTO which client sends when connect to DBMS.
* Strict validation check is required.
*
* @author whitem4rk
* @version 1.0
* @see DBMS
*/
@Getter
@NoArgsConstructor
public class StorageReqDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* Response DTO which client request details of connected DBMS.
* Password must not be contained.
*
* @author whitem4rk
* @version 1.0
* @see DBMS
*/
@Getter
@NoArgsConstructor
@Schema(description = "Represents the storage info.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.Arrays;

/**
* The list of compatible DBMS.
* You can check connection logic in config package.
*
* @author whitem4rk
* @version 1.0
* @see api.goraebab.config.JpaConfig
*/
public enum DBMS {
MYSQL, MARIADB, POSTGRESQL, ORACLE, SQLSERVER;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* Represents a storage entity that contains information about a database connection.
*
* <p>Instances of this class are typically used to persist and retrieve storage configurations
* from the database.</p>
*
* @author whitem4rk
* @version 1.0
* @see BaseEntity
*/
@Getter
@Entity
@Table(name = "storage")
Expand Down Expand Up @@ -44,6 +54,16 @@ public class Storage extends BaseEntity {
@Column(nullable = false)
private String password;

/**
* Constructs a new {@link Storage} instance using the specified parameters.
*
* @param host the host address of the database server.
* @param port the port number of the database server.
* @param dbms the type of database management system.
* @param name the custom name of the connection.
* @param username the username for database authentication.
* @param password the password for database authentication.
*/
@Builder
public Storage(String host, Integer port, DBMS dbms, String name, String username,
String password) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
* Mapper interface for converting between {@link Storage} entities and their corresponding DTOs.
*
* <p>This interface uses MapStruct for generating implementation code at compile time.</p>
*
* @author whitem4rk
* @version 1.0
*/
@Mapper
public interface StorageMapper {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
import api.goraebab.domain.remote.database.entity.Storage;
import org.springframework.data.jpa.repository.JpaRepository;

/**
* Repository interface for managing {@link Storage} entities.
*
* <p>Extends the {@link JpaRepository} interface to provide CRUD operations and
* additional query methods for {@link Storage} objects.</p>
*
* <p>This interface is a Spring Data JPA repository and will be implemented automatically
* by Spring at runtime.</p>
*
* <p>Note: This repository currently does not include QueryDSL integration.
* If you need to perform complex dynamic queries with type safety, you may consider
* adding a custom repository interface and implementing QueryDSL functionality.</p>
*
* @author whitem4rk
* @version 1.0
* @see org.springframework.data.jpa.repository.JpaRepository
*/
public interface StorageRepository extends JpaRepository<Storage, Long> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
import api.goraebab.domain.remote.database.dto.StorageResDto;
import java.util.List;

/**
* Service interface for managing storage entities and their operations.
*
* <p>This interface provides methods for retrieving, connecting, deleting, and copying storage configurations.</p>
*
* @author whitem4rk
* @version 1.0
*/
public interface StorageService {

List<StorageResDto> getStorages();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* Service implementation for managing storage entities and their operations.
*
* @author whitem4rk
* @version 1.0
*/
@Service
@RequiredArgsConstructor
public class StorageServiceImpl implements StorageService {
Expand All @@ -39,6 +45,16 @@ public List<StorageResDto> getStorages() {
}
}

/**
* Connects to a storage system using the provided configuration and saves the storage information to the repository.
*
* <p>This method validates the storage configuration by attempting to execute a query on the target storage.
* If the connection is successful, the storage details are mapped to a {@link Storage} entity and persisted in the repository.</p>
*
* @param storageReqDto the {@link StorageReqDto} containing the storage configuration details, such as host, port, username, and password.
* @throws CustomException if the connection fails ({@link ErrorCode#CONNECTION_FAILED}).
* @see ConnectionUtil
*/
@Override
@Transactional
public void connectStorage(StorageReqDto storageReqDto) {
Expand All @@ -64,6 +80,13 @@ public void deleteStorage(Long storageId) {
}
}

/**
* Copies all blueprints which are stored in target storage to local storage.
* This functionality allows users to import blueprints created on another server into the currently active server.
*
* @param storageId the ID of the storage whose blueprints are to be copied.
* @throws CustomException if the storage is not found ({@link ErrorCode#NOT_FOUND_VALUE}) or if the copy operation fails ({@link ErrorCode#COPY_FAILED}).
*/
@Override
@Transactional
public void copyStorage(Long storageId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* Request DTO which Client sends when connect to remote Docker daemon
*
* @author whitem4rk
* @version 1.0
*/
@Getter
@NoArgsConstructor
public class DaemonReqDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* Response DTO which client request list of Docker daemon connections.
*
* @author whitem4rk
* @version 1.0
*/
@Getter
@NoArgsConstructor
public class DaemonResDto {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/api/goraebab/domain/remote/docker/entity/Daemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* Entity class representing a Daemon, which typically refers to a background process running on a
* specific host and port with a given name. This class is mapped to the "daemon" table in the
* database.
*
* <p>This class extends {@code BaseEntity}, which may include common fields like
* creation and update timestamps.
*
* @author whitem4rk
* @version 1.0
* @see BaseEntity
*/
@Getter
@Entity
@Table(name = "daemon")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
* Mapper interface for converting between {@link Daemon} entities and their corresponding DTOs.
*
* <p>This interface uses MapStruct to generate the implementation at compile time, ensuring efficient and type-safe mapping.</p>
*
* @author whitem4rk
* @version 1.0
*/
@Mapper
public interface DaemonMapper {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
package api.goraebab.domain.remote.docker.repository;

import api.goraebab.domain.remote.database.entity.Storage;
import api.goraebab.domain.remote.docker.entity.Daemon;
import org.springframework.data.jpa.repository.JpaRepository;

/**
* Repository interface for managing {@link Storage} entities.
*
* <p>Extends the {@link JpaRepository} interface to provide CRUD operations and
* additional query methods for {@link Storage} objects.</p>
*
* <p>This interface is a Spring Data JPA repository and will be implemented automatically
* by Spring at runtime.</p>
*
* <p>Note: This repository currently does not include QueryDSL integration.
* If you need to perform complex dynamic queries with type safety, you may consider
* adding a custom repository interface and implementing QueryDSL functionality.</p>
*
* @author whitem4rk
* @version 1.0
* @see org.springframework.data.jpa.repository.JpaRepository
*/
public interface DaemonRepository extends JpaRepository<Daemon, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
import api.goraebab.domain.remote.docker.dto.DaemonResDto;
import java.util.List;

/**
* Service interface for managing daemon entities and their operations.
*
* <p>This interface provides methods for retrieving, connecting and deleting daemon configurations.</p>
*
* @author whitem4rk
* @version 1.0
*/
public interface DaemonService {

List<DaemonResDto> getDaemons();
Expand Down
Loading