From 5f2140844f9e4a102f9a2a7dd5faede644849afd Mon Sep 17 00:00:00 2001 From: Milad Khalilian Date: Tue, 22 Aug 2023 14:13:10 +0200 Subject: [PATCH] fix ArchUnit violations --- .../example/{ => api}/ExampleController.java | 3 ++- .../backbase/example/mapper/GreetingsMapper.java | 3 ++- .../example/service/GreetingsServiceImpl.java | 14 ++++++++++++++ .../example/{ => api}/ExampleController.java | 3 ++- .../banking/{ => api}/ExampleController.java | 3 ++- .../MessagingServiceRestClientConfiguration.java | 4 +++- .../messaging-api/pom.xml | 1 + .../messaging-service/pom.xml | 2 +- .../message/{ => api}/ExampleController.java | 2 +- .../example/{ => api}/ExampleController.java | 4 ++-- .../{integration => client}/MessageClient.java | 2 +- .../{integration => client}/MessageClientImpl.java | 6 +++--- .../example/mapper/IntegrationMessageMapper.java | 3 ++- .../example-integration-openapi-spec/pom.xml | 1 + .../example/service/GreetingsServiceImpl.java | 5 +++++ .../{ => controller}/ExampleController.java | 2 +- .../example/service/GreetingsServiceImpl.java | 6 ++++++ 17 files changed, 49 insertions(+), 15 deletions(-) rename service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/{ => api}/ExampleController.java (95%) rename service-sdk/16.0.0/create-core-service/example-core-service/src/main/java/com/backbase/example/{ => api}/ExampleController.java (89%) rename service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/{ => api}/ExampleController.java (91%) rename service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/{ => config}/MessagingServiceRestClientConfiguration.java (92%) rename service-sdk/16.0.0/create-openapi-spec-project/messaging-service/src/main/java/com/backbase/message/{ => api}/ExampleController.java (97%) rename service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/{ => api}/ExampleController.java (96%) rename service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/{integration => client}/MessageClient.java (81%) rename service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/{integration => client}/MessageClientImpl.java (93%) rename service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/{ => controller}/ExampleController.java (98%) diff --git a/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/ExampleController.java b/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/api/ExampleController.java similarity index 95% rename from service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/ExampleController.java rename to service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/api/ExampleController.java index 5d14019..0955898 100644 --- a/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/ExampleController.java +++ b/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/api/ExampleController.java @@ -1,5 +1,6 @@ -package com.backbase.example; +package com.backbase.example.api; +import com.backbase.example.Message; import com.backbase.example.domain.Greeting; import com.backbase.example.mapper.GreetingsMapper; import com.backbase.example.service.GreetingsService; diff --git a/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/mapper/GreetingsMapper.java b/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/mapper/GreetingsMapper.java index a8e20bd..38028ee 100644 --- a/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/mapper/GreetingsMapper.java +++ b/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/mapper/GreetingsMapper.java @@ -3,11 +3,12 @@ import com.backbase.example.Message; import com.backbase.example.domain.Greeting; import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; import org.mapstruct.factory.Mappers; import java.util.List; -@Mapper +@Mapper(unmappedTargetPolicy= ReportingPolicy.ERROR) public interface GreetingsMapper { GreetingsMapper INSTANCE = Mappers.getMapper( GreetingsMapper.class); diff --git a/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java b/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java index 275c8e7..6b4a54e 100644 --- a/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java +++ b/service-sdk/16.0.0/add-persistence-to-service/example-persistence-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java @@ -2,29 +2,43 @@ import com.backbase.example.domain.Greeting; import com.backbase.example.repository.GreetingsRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import java.util.List; +import org.springframework.transaction.annotation.Transactional; @Service +@Transactional(readOnly=true) public class GreetingsServiceImpl implements GreetingsService { + private static final Logger log = LoggerFactory.getLogger(GreetingsServiceImpl.class); + @Autowired private GreetingsRepository greetingsRepository; @Override + @PreAuthorize("permitAll()") public List getGreetings() { + log.debug("Service getGreetings is called {}", 1); return greetingsRepository.findAll(); } @Override + @PreAuthorize("permitAll()") public Greeting getGreetingById(String id) { + log.debug("Service getGreetingById is called {}", id); return greetingsRepository.findById(id).get(); } @Override + @PreAuthorize("permitAll()") + @Transactional public void addNewGreeting(Greeting greeting) { + log.debug("Service addNewGreeting is called {}", 1); greetingsRepository.save(greeting); } } diff --git a/service-sdk/16.0.0/create-core-service/example-core-service/src/main/java/com/backbase/example/ExampleController.java b/service-sdk/16.0.0/create-core-service/example-core-service/src/main/java/com/backbase/example/api/ExampleController.java similarity index 89% rename from service-sdk/16.0.0/create-core-service/example-core-service/src/main/java/com/backbase/example/ExampleController.java rename to service-sdk/16.0.0/create-core-service/example-core-service/src/main/java/com/backbase/example/api/ExampleController.java index 179d9e1..4dbe9a0 100644 --- a/service-sdk/16.0.0/create-core-service/example-core-service/src/main/java/com/backbase/example/ExampleController.java +++ b/service-sdk/16.0.0/create-core-service/example-core-service/src/main/java/com/backbase/example/api/ExampleController.java @@ -1,5 +1,6 @@ -package com.backbase.example; +package com.backbase.example.api; +import com.backbase.example.Message; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/ExampleController.java b/service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/api/ExampleController.java similarity index 91% rename from service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/ExampleController.java rename to service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/api/ExampleController.java index 351e15e..41fe36f 100644 --- a/service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/ExampleController.java +++ b/service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/api/ExampleController.java @@ -1,5 +1,6 @@ -package com.backbase.banking; +package com.backbase.banking.api; +import com.backbase.banking.Message; import com.backbase.messaging.api.client.v2.MessageApi; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; diff --git a/service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/MessagingServiceRestClientConfiguration.java b/service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/config/MessagingServiceRestClientConfiguration.java similarity index 92% rename from service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/MessagingServiceRestClientConfiguration.java rename to service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/config/MessagingServiceRestClientConfiguration.java index 16287b0..b042b8b 100644 --- a/service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/MessagingServiceRestClientConfiguration.java +++ b/service-sdk/16.0.0/create-openapi-client/banking-service/src/main/java/com/backbase/banking/config/MessagingServiceRestClientConfiguration.java @@ -1,4 +1,4 @@ -package com.backbase.banking; +package com.backbase.banking.config; import com.backbase.buildingblocks.communication.client.ApiClientConfig; import com.backbase.buildingblocks.communication.http.HttpCommunicationConfiguration; @@ -6,10 +6,12 @@ import com.backbase.messaging.api.client.v2.MessageApi; import org.springframework.context.annotation.*; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; // tag::MessagingServiceRestClientConfiguration[] @Configuration @ConfigurationProperties("backbase.communication.services.name") +@Validated public class MessagingServiceRestClientConfiguration extends ApiClientConfig { public static final String MESSAGING_SERVICE_ID = "messaging-service"; diff --git a/service-sdk/16.0.0/create-openapi-spec-project/messaging-api/pom.xml b/service-sdk/16.0.0/create-openapi-spec-project/messaging-api/pom.xml index 9aa9244..fad4a98 100644 --- a/service-sdk/16.0.0/create-openapi-spec-project/messaging-api/pom.xml +++ b/service-sdk/16.0.0/create-openapi-spec-project/messaging-api/pom.xml @@ -74,6 +74,7 @@ ${project.basedir}/target/boat-lint-reports true true + 219,215,218,115,134,104,105,110,176,M011,151,S007,S005,B013,H001 diff --git a/service-sdk/16.0.0/create-openapi-spec-project/messaging-service/pom.xml b/service-sdk/16.0.0/create-openapi-spec-project/messaging-service/pom.xml index 31d9002..a203dc0 100644 --- a/service-sdk/16.0.0/create-openapi-spec-project/messaging-service/pom.xml +++ b/service-sdk/16.0.0/create-openapi-spec-project/messaging-service/pom.xml @@ -22,7 +22,7 @@ 17 0.17.5 -] + diff --git a/service-sdk/16.0.0/create-openapi-spec-project/messaging-service/src/main/java/com/backbase/message/ExampleController.java b/service-sdk/16.0.0/create-openapi-spec-project/messaging-service/src/main/java/com/backbase/message/api/ExampleController.java similarity index 97% rename from service-sdk/16.0.0/create-openapi-spec-project/messaging-service/src/main/java/com/backbase/message/ExampleController.java rename to service-sdk/16.0.0/create-openapi-spec-project/messaging-service/src/main/java/com/backbase/message/api/ExampleController.java index 08ec10a..763367c 100644 --- a/service-sdk/16.0.0/create-openapi-spec-project/messaging-service/src/main/java/com/backbase/message/ExampleController.java +++ b/service-sdk/16.0.0/create-openapi-spec-project/messaging-service/src/main/java/com/backbase/message/api/ExampleController.java @@ -1,4 +1,4 @@ -package com.backbase.message; +package com.backbase.message.api; import com.backbase.dbs.messaging_service.api.service.v2.MessageApi; import com.backbase.dbs.messaging_service.api.service.v2.model.MessagePostResponseBody; diff --git a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/ExampleController.java b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/api/ExampleController.java similarity index 96% rename from service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/ExampleController.java rename to service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/api/ExampleController.java index f6e6001..6c4f546 100644 --- a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/ExampleController.java +++ b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/api/ExampleController.java @@ -1,9 +1,9 @@ -package com.backbase.example; +package com.backbase.example.api; import com.backbase.buildingblocks.presentation.errors.InternalServerErrorException; import com.backbase.example.api.client.v1.MessageApi; import com.backbase.example.api.client.v1.model.MessagePostResponseBody; -import com.backbase.example.integration.MessageClient; +import com.backbase.example.client.MessageClient; import com.backbase.example.mapper.IntegrationMessageMapper; import com.backbase.example.model.Message; import java.io.IOException; diff --git a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/integration/MessageClient.java b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/client/MessageClient.java similarity index 81% rename from service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/integration/MessageClient.java rename to service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/client/MessageClient.java index 93214dc..e976f61 100644 --- a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/integration/MessageClient.java +++ b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/client/MessageClient.java @@ -1,4 +1,4 @@ -package com.backbase.example.integration; +package com.backbase.example.client; import com.backbase.example.model.Message; diff --git a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/integration/MessageClientImpl.java b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/client/MessageClientImpl.java similarity index 93% rename from service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/integration/MessageClientImpl.java rename to service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/client/MessageClientImpl.java index 816bb42..2a0d262 100644 --- a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/integration/MessageClientImpl.java +++ b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/client/MessageClientImpl.java @@ -1,11 +1,11 @@ -package com.backbase.example.integration; +package com.backbase.example.client; import com.backbase.example.model.Message; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.http.HttpMethod; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import java.io.IOException; @@ -13,7 +13,7 @@ import java.util.ArrayList; import java.util.List; -@Service +@Component public class MessageClientImpl implements MessageClient { private static final String SERVICE_URL = "http://echo.jsontest.com/messageId/abcdef-393939-dffdfdf/message/Hello%20World/"; diff --git a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/mapper/IntegrationMessageMapper.java b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/mapper/IntegrationMessageMapper.java index cb6fab9..e43b5aa 100644 --- a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/mapper/IntegrationMessageMapper.java +++ b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-service/src/main/java/com/backbase/example/mapper/IntegrationMessageMapper.java @@ -4,9 +4,10 @@ import java.util.List; import org.mapstruct.Mapper; import org.mapstruct.Mapping; +import org.mapstruct.ReportingPolicy; import org.mapstruct.factory.Mappers; -@Mapper +@Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR) public interface IntegrationMessageMapper { IntegrationMessageMapper INSTANCE = Mappers.getMapper( IntegrationMessageMapper.class); diff --git a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-spec/pom.xml b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-spec/pom.xml index 26c229d..dbc916b 100644 --- a/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-spec/pom.xml +++ b/service-sdk/16.0.0/create-outbound-integration-service-openapi/example-integration-openapi-spec/pom.xml @@ -74,6 +74,7 @@ ${project.basedir}/target/boat-lint-reports true true + 219,215,218,115,134,104,105,110,176,M011,151,S007,S005,B013,H001 diff --git a/service-sdk/16.0.0/include-persistence-crud-service-specification/example-crud-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java b/service-sdk/16.0.0/include-persistence-crud-service-specification/example-crud-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java index 57384dd..39ebe0a 100644 --- a/service-sdk/16.0.0/include-persistence-crud-service-specification/example-crud-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java +++ b/service-sdk/16.0.0/include-persistence-crud-service-specification/example-crud-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java @@ -3,6 +3,7 @@ import com.backbase.example.domain.Greeting; import com.backbase.example.repository.GreetingsRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -16,24 +17,28 @@ public class GreetingsServiceImpl implements GreetingsService { @Override @Transactional(readOnly = true) + @PreAuthorize("permitAll()") public List getGreetings() { return greetingsRepository.findAll(); } @Override @Transactional(readOnly = true) + @PreAuthorize("permitAll()") public Greeting getGreetingById(String id) { return greetingsRepository.findById(id).get(); } @Override @Transactional + @PreAuthorize("permitAll()") public void saveGreeting(Greeting greeting) { greetingsRepository.save(greeting); } @Override @Transactional + @PreAuthorize("permitAll()") public void deleteGreeting(Greeting greeting) { greetingsRepository.delete(greeting); } diff --git a/service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/ExampleController.java b/service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/controller/ExampleController.java similarity index 98% rename from service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/ExampleController.java rename to service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/controller/ExampleController.java index 362dd48..3744e0a 100644 --- a/service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/ExampleController.java +++ b/service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/controller/ExampleController.java @@ -1,4 +1,4 @@ -package com.backbase.example; +package com.backbase.example.controller; import com.backbase.example.domain.Greeting; import com.backbase.example.mapper.GreetingsMapper; diff --git a/service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java b/service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java index 545d548..2b57565 100644 --- a/service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java +++ b/service-sdk/16.0.0/service-to-service-communication/example-service-to-service/src/main/java/com/backbase/example/service/GreetingsServiceImpl.java @@ -5,6 +5,7 @@ import com.backbase.example.repository.GreetingsRepository; import com.backbase.integration.example.client.v1.MessageApi; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,6 +22,7 @@ public class GreetingsServiceImpl implements GreetingsService { @Override @Transactional(readOnly = true) + @PreAuthorize("permitAll()") public List getGreetings() { return greetingsRepository.findAll(); } @@ -28,6 +30,7 @@ public List getGreetings() { // tag::getExternalGreetings[] @Override @Transactional(readOnly = true) + @PreAuthorize("permitAll()") public List getExternalGreetings() { return GreetingsMapper.INSTANCE.integrationMessageToGreeting(exampleIntegrationApiClient.getMessages()); } @@ -35,16 +38,19 @@ public List getExternalGreetings() { @Override @Transactional(readOnly = true) + @PreAuthorize("permitAll()") public Greeting getGreetingById(String id) { return greetingsRepository.findById(id).get(); } @Override + @PreAuthorize("permitAll()") public void saveGreeting(Greeting greeting) { greetingsRepository.save(greeting); } @Override + @PreAuthorize("permitAll()") public void deleteGreeting(Greeting greeting) { greetingsRepository.delete(greeting); }