diff --git a/package.json b/package.json index 7ae0df07..5ac745bc 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "generate:api:intelligence-service:client": "npx openapi-generator-cli generate -i server/intelligence-service/openapi.yaml -g java --library resttemplate --api-package de.tum.in.www1.hephaestus.intelligenceservice.api --model-package de.tum.in.www1.hephaestus.intelligenceservice.model --invoker-package de.tum.in.www1.hephaestus.intelligenceservice --model-name-prefix IS --additional-properties useJakartaEe=true,performBeanValidation=true,hideGenerationTimestamp=true --package-name de.tum.in.www1.hephaestus.intelligenceservice -o tmp/java-client && shx cp -r tmp/java-client/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice server/application-server/src/main/java/de/tum/in/www1/hephaestus && shx rm -rf tmp", "generate:api:intelligence-service": "npm run generate:api:intelligence-service:clean && npm run generate:api:intelligence-service:specs && npm run generate:api:intelligence-service:client", "generate:api": "npm run generate:api:intelligence-service && npm run generate:api:application-server", - "format:java:check": "prettier --check server/application-server/src/**/*.java", - "format:java:write": "prettier --write server/application-server/src/**/*.java", + "format:java:check": "prettier --check server/application-server/src/**/*.java --config-precedence prefer-file --config server/application-server/.prettierrc.yaml --ignore-path server/application-server/.prettierignore", + "format:java:write": "prettier --write server/application-server/src/**/*.java --config-precedence prefer-file --config server/application-server/.prettierrc.yaml --ignore-path server/application-server/.prettierignore", "format:python:check": "cd server/intelligence-service/ && poetry run black --check .", "format:python:write": "cd server/intelligence-service/ && poetry run black .", "db:changelog:diff": "cd server/application-server && docker compose down postgres && shx --silent mv postgres-data postgres-data-temp && docker compose up -d postgres && docker compose exec postgres sh -c \"until pg_isready -h localhost -p 5432; do sleep 1; done\" && mvn liquibase:update && mvn liquibase:diff && docker compose down postgres && shx rm -rf postgres-data && shx --silent mv postgres-data-temp postgres-data" diff --git a/server/application-server/.prettierignore b/server/application-server/.prettierignore index 53b1595f..306bcda9 100644 --- a/server/application-server/.prettierignore +++ b/server/application-server/.prettierignore @@ -4,4 +4,4 @@ target postgres-data # Ignore OpenAPI generated files: -src\main\java\de\tum\in\www1\hephaestus\intelligenceservice +src/main/java/de/tum/in/www1/hephaestus/intelligenceservice diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/Application.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/Application.java index 2174fba4..f28afbab 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/Application.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/Application.java @@ -7,8 +7,8 @@ @SpringBootApplication public class Application { - public static void main(String[] args) { - TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin")); - SpringApplication.run(Application.class, args); - } + public static void main(String[] args) { + TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin")); + SpringApplication.run(Application.class, args); + } } diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/ClassImportIntegratorIntegratorProvider.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/ClassImportIntegratorIntegratorProvider.java index 7e7b9a26..7ef86bf6 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/ClassImportIntegratorIntegratorProvider.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/ClassImportIntegratorIntegratorProvider.java @@ -1,11 +1,5 @@ package de.tum.in.www1.hephaestus; -import java.util.ArrayList; -import java.util.List; - -import org.hibernate.integrator.spi.Integrator; -import org.hibernate.jpa.boot.spi.IntegratorProvider; - import de.tum.in.www1.hephaestus.gitprovider.issue.IssueInfoDTO; import de.tum.in.www1.hephaestus.gitprovider.issuecomment.IssueCommentInfoDTO; import de.tum.in.www1.hephaestus.gitprovider.label.LabelInfoDTO; @@ -18,26 +12,30 @@ import de.tum.in.www1.hephaestus.mentor.message.MessageDTO; import de.tum.in.www1.hephaestus.mentor.session.SessionDTO; import io.hypersistence.utils.hibernate.type.util.ClassImportIntegrator; +import java.util.ArrayList; +import java.util.List; +import org.hibernate.integrator.spi.Integrator; +import org.hibernate.jpa.boot.spi.IntegratorProvider; public class ClassImportIntegratorIntegratorProvider implements IntegratorProvider { - @Override - public List getIntegrators() { - // Accessible DTOs - @SuppressWarnings("rawtypes") - List classes = new ArrayList<>(); - classes.add(UserInfoDTO.class); - classes.add(TeamInfoDTO.class); - classes.add(IssueInfoDTO.class); - classes.add(LabelInfoDTO.class); - classes.add(MilestoneInfoDTO.class); - classes.add(PullRequestInfoDTO.class); - classes.add(IssueCommentInfoDTO.class); - classes.add(PullRequestReviewInfoDTO.class); - classes.add(RepositoryInfoDTO.class); - classes.add(MessageDTO.class); - classes.add(SessionDTO.class); + @Override + public List getIntegrators() { + // Accessible DTOs + @SuppressWarnings("rawtypes") + List classes = new ArrayList<>(); + classes.add(UserInfoDTO.class); + classes.add(TeamInfoDTO.class); + classes.add(IssueInfoDTO.class); + classes.add(LabelInfoDTO.class); + classes.add(MilestoneInfoDTO.class); + classes.add(PullRequestInfoDTO.class); + classes.add(IssueCommentInfoDTO.class); + classes.add(PullRequestReviewInfoDTO.class); + classes.add(RepositoryInfoDTO.class); + classes.add(MessageDTO.class); + classes.add(SessionDTO.class); - return List.of(new ClassImportIntegrator(classes)); - } + return List.of(new ClassImportIntegrator(classes)); + } } diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/OpenAPIConfiguration.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/OpenAPIConfiguration.java index 19f34ab2..b3ba3829 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/OpenAPIConfiguration.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/OpenAPIConfiguration.java @@ -37,18 +37,20 @@ public OpenApiCustomizer schemaCustomizer() { if (components != null && components.getSchemas() != null) { // Only include schemas with DTO suffix and remove the suffix var schemas = components - .getSchemas() - .entrySet() - .stream() - .filter(entry -> entry.getKey().endsWith("DTO")) - .collect(Collectors.toMap( + .getSchemas() + .entrySet() + .stream() + .filter(entry -> entry.getKey().endsWith("DTO")) + .collect( + Collectors.toMap( entry -> entry.getKey().substring(0, entry.getKey().length() - 3), entry -> { var schema = entry.getValue(); schema.setName(entry.getKey().substring(0, entry.getKey().length() - 3)); return schema; } - )); + ) + ); // Remove DTO suffix from attribute names schemas.forEach((key, value) -> { @@ -70,50 +72,59 @@ public OpenApiCustomizer schemaCustomizer() { if (paths != null) { paths.forEach((path, pathItem) -> { logger.info("Processing path: {}", path); - pathItem.readOperations().forEach(operation -> { - // Remove DTO suffix from response schemas - var responses = operation.getResponses(); - if (responses != null) { - responses.forEach((responseCode, response) -> { - var content = response.getContent(); - if (content != null) { - content.forEach((contentType, mediaType) -> { - if (mediaType != null && mediaType.getSchema() != null) { - removeDTOSuffixesFromSchemaRecursively(mediaType.getSchema()); - } else { - logger.warn("MediaType or Schema is null for content type: {}", contentType); - } - }); - } else { - logger.warn("Response with code {} has no content.", responseCode); - } - }); - } - if (operation.getRequestBody() != null) { - var requestBodyContent = operation.getRequestBody().getContent(); - requestBodyContent.forEach((contentType, mediaType) -> { - removeDTOSuffixesFromSchemaRecursively(mediaType.getSchema()); - }); - } + pathItem + .readOperations() + .forEach(operation -> { + // Remove DTO suffix from response schemas + var responses = operation.getResponses(); + if (responses != null) { + responses.forEach((responseCode, response) -> { + var content = response.getContent(); + if (content != null) { + content.forEach((contentType, mediaType) -> { + if (mediaType != null && mediaType.getSchema() != null) { + removeDTOSuffixesFromSchemaRecursively(mediaType.getSchema()); + } else { + logger.warn( + "MediaType or Schema is null for content type: {}", + contentType + ); + } + }); + } else { + logger.warn("Response with code {} has no content.", responseCode); + } + }); + } + if (operation.getRequestBody() != null) { + var requestBodyContent = operation.getRequestBody().getContent(); + requestBodyContent.forEach((contentType, mediaType) -> { + removeDTOSuffixesFromSchemaRecursively(mediaType.getSchema()); + }); + } - // Remove -controller suffix from tags - if (operation.getTags() != null) { - operation.setTags( - operation.getTags() - .stream() - .filter(tag -> { - if (tag.length() > 11) { - return true; - } else { - logger.warn("Tag '{}' is shorter than expected and cannot be trimmed.", tag); - return false; - } - }) - .map(tag -> tag.substring(0, tag.length() - 11)) - .collect(Collectors.toList()) - ); - } - }); + // Remove -controller suffix from tags + if (operation.getTags() != null) { + operation.setTags( + operation + .getTags() + .stream() + .filter(tag -> { + if (tag.length() > 11) { + return true; + } else { + logger.warn( + "Tag '{}' is shorter than expected and cannot be trimmed.", + tag + ); + return false; + } + }) + .map(tag -> tag.substring(0, tag.length() - 11)) + .collect(Collectors.toList()) + ); + } + }); }); } else { logger.warn("Paths are null in OpenAPI configuration."); @@ -136,4 +147,4 @@ private void removeDTOSuffixesFromSchemaRecursively(Schema schema) { removeDTOSuffixesFromSchemaRecursively(schema.getItems()); } } -} \ No newline at end of file +} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/SecurityConfig.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/SecurityConfig.java index f8dec0f9..a69214af 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/SecurityConfig.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/SecurityConfig.java @@ -5,7 +5,6 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Stream; - import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; @@ -25,8 +24,8 @@ @Configuration @EnableWebSecurity public class SecurityConfig { - interface AuthoritiesConverter extends Converter, Collection> { - } + + interface AuthoritiesConverter extends Converter, Collection> {} @SuppressWarnings("unchecked") @Bean @@ -34,14 +33,19 @@ AuthoritiesConverter realmRolesAuthoritiesConverter() { return claims -> { final var realmAccess = Optional.ofNullable((Map) claims.get("realm_access")); final var roles = realmAccess.flatMap(map -> Optional.ofNullable((List) map.get("roles"))); - return roles.map(List::stream).orElse(Stream.empty()).map(SimpleGrantedAuthority::new) - .map(GrantedAuthority.class::cast).toList(); + return roles + .map(List::stream) + .orElse(Stream.empty()) + .map(SimpleGrantedAuthority::new) + .map(GrantedAuthority.class::cast) + .toList(); }; } @Bean JwtAuthenticationConverter authenticationConverter( - Converter, Collection> authoritiesConverter) { + Converter, Collection> authoritiesConverter + ) { var authenticationConverter = new JwtAuthenticationConverter(); authenticationConverter.setJwtGrantedAuthoritiesConverter(jwt -> { return authoritiesConverter.convert(jwt.getClaims()); @@ -51,18 +55,21 @@ JwtAuthenticationConverter authenticationConverter( @Bean SecurityFilterChain resourceServerSecurityFilterChain( - HttpSecurity http, - Converter authenticationConverter) throws Exception { + HttpSecurity http, + Converter authenticationConverter + ) throws Exception { http.oauth2ResourceServer(resourceServer -> { resourceServer.jwt(jwtDecoder -> { jwtDecoder.jwtAuthenticationConverter(authenticationConverter); }); }); - http.sessionManagement(sessions -> { - sessions.sessionCreationPolicy(SessionCreationPolicy.STATELESS); - }).csrf(csrf -> csrf.disable()) - .cors(cors -> cors.configurationSource(corsConfigurationSource())); + http + .sessionManagement(sessions -> { + sessions.sessionCreationPolicy(SessionCreationPolicy.STATELESS); + }) + .csrf(csrf -> csrf.disable()) + .cors(cors -> cors.configurationSource(corsConfigurationSource())); http.authorizeHttpRequests(requests -> { requests.requestMatchers("/workspace/**").hasAuthority("admin"); @@ -82,4 +89,4 @@ CorsConfigurationSource corsConfigurationSource() { source.registerCorsConfiguration("/**", configuration); return source; } -} \ No newline at end of file +} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/WebConfig.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/WebConfig.java index ba4fc629..35d8d0bf 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/WebConfig.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/WebConfig.java @@ -5,7 +5,6 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - @Configuration public class WebConfig implements WebMvcConfigurer { @@ -13,4 +12,4 @@ public class WebConfig implements WebMvcConfigurer { public RestTemplate restTemplate() { return new RestTemplate(); } -} \ No newline at end of file +} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/GitHubConfig.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/GitHubConfig.java index b2c8cd83..51b8dbdf 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/GitHubConfig.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/GitHubConfig.java @@ -1,7 +1,8 @@ package de.tum.in.www1.hephaestus.config; import java.io.IOException; - +import org.kohsuke.github.GitHub; +import org.kohsuke.github.GitHubBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -9,8 +10,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; -import org.kohsuke.github.GitHub; -import org.kohsuke.github.GitHubBuilder; @Configuration public class GitHubConfig { diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/IntelligenceServiceConfig.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/IntelligenceServiceConfig.java index de8f6608..327f4e3c 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/IntelligenceServiceConfig.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/IntelligenceServiceConfig.java @@ -1,12 +1,11 @@ package de.tum.in.www1.hephaestus.config; +import de.tum.in.www1.hephaestus.intelligenceservice.ApiClient; +import de.tum.in.www1.hephaestus.intelligenceservice.api.MentorApi; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import de.tum.in.www1.hephaestus.intelligenceservice.ApiClient; -import de.tum.in.www1.hephaestus.intelligenceservice.api.MentorApi; - @Configuration public class IntelligenceServiceConfig { @@ -19,6 +18,7 @@ public IntelligenceServiceApi intelligenceServiceApi() { } public class IntelligenceServiceApi extends MentorApi { + public IntelligenceServiceApi() { super(new ApiClient().setBasePath(intelligenceServiceUrl)); } diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/KeycloakConfig.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/KeycloakConfig.java index 9eea4f0d..78af739c 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/KeycloakConfig.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/KeycloakConfig.java @@ -1,11 +1,11 @@ package de.tum.in.www1.hephaestus.config; + import org.keycloak.OAuth2Constants; import org.keycloak.admin.client.Keycloak; import org.keycloak.admin.client.KeycloakBuilder; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.beans.factory.annotation.Value; - @Configuration public class KeycloakConfig { diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/NatsConfig.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/NatsConfig.java index 6ba65f46..6305a70c 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/NatsConfig.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/NatsConfig.java @@ -1,21 +1,20 @@ package de.tum.in.www1.hephaestus.config; +import io.nats.client.Connection; +import io.nats.client.Nats; +import io.nats.client.Options; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; -import io.nats.client.Connection; -import io.nats.client.Nats; -import io.nats.client.Options; - @Configuration public class NatsConfig { @Value("${nats.enabled}") private boolean isNatsEnabled; - + @Value("${nats.server}") private String natsServer; diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SentryConfiguration.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SentryConfiguration.java index 104a0ec7..231b4d62 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SentryConfiguration.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SentryConfiguration.java @@ -49,7 +49,7 @@ public void init() { options.setRelease(hephaestusVersion); options.setTracesSampleRate(getTracesSampleRate()); }); - + logger.info("Sentry configuration was successful"); } catch (Exception ex) { logger.error("Sentry configuration was not successful due to exception!", ex); diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SlackAppConfig.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SlackAppConfig.java index 98596fc4..56d0d892 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SlackAppConfig.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SlackAppConfig.java @@ -1,14 +1,14 @@ package de.tum.in.www1.hephaestus.config; +import com.slack.api.bolt.App; +import com.slack.api.bolt.AppConfig; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import com.slack.api.bolt.App; -import com.slack.api.bolt.AppConfig; - @Configuration public class SlackAppConfig { + @Value("${slack.token}") private String botToken; @@ -22,4 +22,4 @@ public App initSlackApp() { } return new App(AppConfig.builder().singleTeamBotToken(botToken).signingSecret(signingSecret).build()); } -} \ No newline at end of file +} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SpringAsyncConfig.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SpringAsyncConfig.java index 844e4789..63125b70 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SpringAsyncConfig.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/config/SpringAsyncConfig.java @@ -5,4 +5,4 @@ @Configuration @EnableAsync -public class SpringAsyncConfig { } \ No newline at end of file +public class SpringAsyncConfig {} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/core/exception/AccessForbiddenException.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/core/exception/AccessForbiddenException.java index b9e69b9d..d77565da 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/core/exception/AccessForbiddenException.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/core/exception/AccessForbiddenException.java @@ -1,7 +1,6 @@ package de.tum.in.www1.hephaestus.core.exception; import java.io.Serial; - import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/core/exception/EntityNotFoundException.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/core/exception/EntityNotFoundException.java index 8c2b34fa..509a8f5f 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/core/exception/EntityNotFoundException.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/core/exception/EntityNotFoundException.java @@ -1,7 +1,6 @@ package de.tum.in.www1.hephaestus.core.exception; import java.io.Serial; - import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/AuthorAssociation.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/AuthorAssociation.java index a8f6be60..3540c6ae 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/AuthorAssociation.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/AuthorAssociation.java @@ -9,5 +9,5 @@ public enum AuthorAssociation { MANNEQUIN, MEMBER, NONE, - OWNER + OWNER, } diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/BaseGitServiceEntity.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/BaseGitServiceEntity.java index d739c520..0d4ab458 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/BaseGitServiceEntity.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/BaseGitServiceEntity.java @@ -1,9 +1,8 @@ package de.tum.in.www1.hephaestus.gitprovider.common; -import java.time.OffsetDateTime; - import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; +import java.time.OffsetDateTime; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -17,6 +16,7 @@ @AllArgsConstructor @ToString public abstract class BaseGitServiceEntity { + @Id protected Long id; diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/BaseGitServiceEntityConverter.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/BaseGitServiceEntityConverter.java index c286f0b3..ca5b85cc 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/BaseGitServiceEntityConverter.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/BaseGitServiceEntityConverter.java @@ -1,21 +1,20 @@ package de.tum.in.www1.hephaestus.gitprovider.common; import java.io.IOException; - import org.kohsuke.github.GHObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.ReadingConverter; import org.springframework.lang.NonNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; @ReadingConverter public abstract class BaseGitServiceEntityConverter - implements Converter { + implements Converter { private static final Logger logger = LoggerFactory.getLogger(BaseGitServiceEntityConverter.class); - abstract public T update(@NonNull S source, @NonNull T target); + public abstract T update(@NonNull S source, @NonNull T target); protected void convertBaseFields(S source, T target) { if (source == null || target == null) { @@ -39,4 +38,4 @@ protected void convertBaseFields(S source, T target) { target.setUpdatedAt(null); } } -} \ No newline at end of file +} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/DateUtil.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/DateUtil.java index 41b49feb..171bf196 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/DateUtil.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/DateUtil.java @@ -5,6 +5,7 @@ import java.util.Date; public class DateUtil { + public static OffsetDateTime convertToOffsetDateTime(Date date) { return date != null ? date.toInstant().atOffset(ZoneOffset.UTC) : null; } diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubAuthorAssociationConverter.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubAuthorAssociationConverter.java index 1b94800a..445cc7ef 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubAuthorAssociationConverter.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubAuthorAssociationConverter.java @@ -1,5 +1,6 @@ package de.tum.in.www1.hephaestus.gitprovider.common.github; +import de.tum.in.www1.hephaestus.gitprovider.common.AuthorAssociation; import org.kohsuke.github.GHCommentAuthorAssociation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -7,8 +8,6 @@ import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; -import de.tum.in.www1.hephaestus.gitprovider.common.AuthorAssociation; - @Component public class GitHubAuthorAssociationConverter implements Converter { diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubMessageHandler.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubMessageHandler.java index 8600be8e..37cd9429 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubMessageHandler.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubMessageHandler.java @@ -1,17 +1,15 @@ package de.tum.in.www1.hephaestus.gitprovider.common.github; +import io.nats.client.Message; +import io.nats.client.MessageHandler; import java.io.IOException; import java.io.StringReader; import java.nio.charset.StandardCharsets; - import org.kohsuke.github.GHEvent; import org.kohsuke.github.GHEventPayload; import org.kohsuke.github.GitHub; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import io.nats.client.Message; -import io.nats.client.MessageHandler; import org.springframework.stereotype.Component; @Component diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubMessageHandlerRegistry.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubMessageHandlerRegistry.java index 35126190..b3a79d6c 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubMessageHandlerRegistry.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/common/github/GitHubMessageHandlerRegistry.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import org.kohsuke.github.GHEvent; import org.springframework.stereotype.Component; @@ -26,4 +25,4 @@ public GitHubMessageHandler getHandler(GHEvent eventType) { public List getSupportedEvents() { return new ArrayList<>(handlerMap.keySet()); } -} \ No newline at end of file +} diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/issue/Issue.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/issue/Issue.java index beb396c9..c281d110 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/issue/Issue.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/gitprovider/issue/Issue.java @@ -1,16 +1,15 @@ package de.tum.in.www1.hephaestus.gitprovider.issue; -import java.util.HashSet; -import java.util.Set; -import java.time.OffsetDateTime; - -import org.springframework.lang.NonNull; - -import jakarta.persistence.Table; +import de.tum.in.www1.hephaestus.gitprovider.common.BaseGitServiceEntity; +import de.tum.in.www1.hephaestus.gitprovider.issuecomment.IssueComment; +import de.tum.in.www1.hephaestus.gitprovider.label.Label; +import de.tum.in.www1.hephaestus.gitprovider.milestone.Milestone; +import de.tum.in.www1.hephaestus.gitprovider.repository.Repository; +import de.tum.in.www1.hephaestus.gitprovider.user.User; import jakarta.persistence.CascadeType; import jakarta.persistence.DiscriminatorColumn; -import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.DiscriminatorType; +import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; @@ -23,17 +22,16 @@ import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import java.time.OffsetDateTime; +import java.util.HashSet; +import java.util.Set; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; import lombok.experimental.Accessors; -import de.tum.in.www1.hephaestus.gitprovider.common.BaseGitServiceEntity; -import de.tum.in.www1.hephaestus.gitprovider.issuecomment.IssueComment; -import de.tum.in.www1.hephaestus.gitprovider.label.Label; -import de.tum.in.www1.hephaestus.gitprovider.milestone.Milestone; -import de.tum.in.www1.hephaestus.gitprovider.repository.Repository; -import de.tum.in.www1.hephaestus.gitprovider.user.User; +import org.springframework.lang.NonNull; @Entity @Table(name = "issue") @@ -59,13 +57,13 @@ public class Issue extends BaseGitServiceEntity { @ToString.Exclude private String body; - @NonNull + @NonNull private String htmlUrl; private boolean isLocked; - + private OffsetDateTime closedAt; - + private int commentsCount; @Accessors(prefix = "") @@ -73,19 +71,27 @@ public class Issue extends BaseGitServiceEntity { // The last time the issue and its associated comments were updated (is also used for pull requests with reviews and review comments) private OffsetDateTime lastSyncAt; - + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "author_id") @ToString.Exclude private User author; - + @ManyToMany - @JoinTable(name = "issue_label", joinColumns = @JoinColumn(name = "issue_id"), inverseJoinColumns = @JoinColumn(name = "label_id")) + @JoinTable( + name = "issue_label", + joinColumns = @JoinColumn(name = "issue_id"), + inverseJoinColumns = @JoinColumn(name = "label_id") + ) @ToString.Exclude private Set