Skip to content

Commit

Permalink
Merge pull request #52 from companieshouse/fixed-enum-issue
Browse files Browse the repository at this point in the history
Fixed issues with enums
  • Loading branch information
kkonuganti-ch authored Mar 20, 2024
2 parents 17f6cda + 3283e59 commit abf960f
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package uk.gov.companieshouse.accounts.association;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AccountsAssociationServiceApplication {

@Value("${spring.application.name}")
public static String applicationNameSpace;

public static void main(String[] args) {
SpringApplication.run(AccountsAssociationServiceApplication.class, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
import java.util.Collections;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import uk.gov.companieshouse.accounts.association.AccountsAssociationServiceApplication;
import uk.gov.companieshouse.accounts.association.interceptor.LoggingInterceptor;
import uk.gov.companieshouse.api.interceptor.InternalUserInterceptor;
import uk.gov.companieshouse.api.interceptor.UserAuthenticationInterceptor;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

@Value("${spring.application.name}")
public static String applicationNameSpace;

private final LoggingInterceptor loggingInterceptor;

Expand Down Expand Up @@ -50,8 +52,7 @@ private void addEricInterceptors( final InterceptorRegistry registry){
new UserAuthenticationInterceptor(
new ArrayList<>(),
Collections.singletonList("oauth2"),
new InternalUserInterceptor(
AccountsAssociationServiceApplication.applicationNameSpace)
new InternalUserInterceptor(applicationNameSpace)
)
).excludePathPatterns("/*/healthcheck");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package uk.gov.companieshouse.accounts.association.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import uk.gov.companieshouse.accounts.association.AccountsAssociationServiceApplication;
import uk.gov.companieshouse.accounts.association.exceptions.BadRequestRuntimeException;
import uk.gov.companieshouse.accounts.association.service.AssociationsService;
import uk.gov.companieshouse.accounts.association.service.CompanyService;
Expand All @@ -15,10 +15,13 @@
@RestController
public class AssociationsListForCompanyController implements AssociationsListForCompanyInterface {

@Value("${spring.application.name}")
public static String applicationNameSpace;

private final AssociationsService associationsService;
private final CompanyService companyService;

private static final Logger LOG = LoggerFactory.getLogger( AccountsAssociationServiceApplication.applicationNameSpace );
private static final Logger LOG = LoggerFactory.getLogger( applicationNameSpace );

public AssociationsListForCompanyController(AssociationsService associationsService, CompanyService companyService) {
this.associationsService = associationsService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import uk.gov.companieshouse.accounts.association.AccountsAssociationServiceApplication;
import uk.gov.companieshouse.accounts.association.exceptions.BadRequestRuntimeException;
import uk.gov.companieshouse.accounts.association.exceptions.InternalServerErrorRuntimeException;
import uk.gov.companieshouse.accounts.association.exceptions.NotFoundRuntimeException;
Expand All @@ -24,7 +24,10 @@
@org.springframework.web.bind.annotation.ControllerAdvice
public class ControllerAdvice extends ResponseEntityExceptionHandler {

private static final Logger LOG = LoggerFactory.getLogger(AccountsAssociationServiceApplication.applicationNameSpace);
@Value("${spring.application.name}")
public static String applicationNameSpace;

private static final Logger LOG = LoggerFactory.getLogger(applicationNameSpace);
public static final String X_REQUEST_ID = "X-Request-Id";
public static final String ACCOUNTS_ASSOCIATION_API = "accounts_association_api";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import uk.gov.companieshouse.accounts.association.AccountsAssociationServiceApplication;
import uk.gov.companieshouse.accounts.association.exceptions.BadRequestRuntimeException;
import uk.gov.companieshouse.accounts.association.service.AssociationsService;
import uk.gov.companieshouse.accounts.association.service.UsersService;
Expand All @@ -22,7 +22,10 @@
@RestController
public class UserCompanyAssociations implements UserCompanyAssociationsInterface {

private static final Logger LOG = LoggerFactory.getLogger(AccountsAssociationServiceApplication.applicationNameSpace);
@Value("${spring.application.name}")
public static String applicationNameSpace;

private static final Logger LOG = LoggerFactory.getLogger(applicationNameSpace);


private final UsersService usersService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package uk.gov.companieshouse.accounts.association.interceptor;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.HandlerInterceptor;
import uk.gov.companieshouse.accounts.association.AccountsAssociationServiceApplication;
import uk.gov.companieshouse.logging.Logger;
import uk.gov.companieshouse.logging.LoggerFactory;
import uk.gov.companieshouse.logging.util.RequestLogger;
Expand All @@ -16,8 +16,9 @@
@Component
public class LoggingInterceptor implements HandlerInterceptor, RequestLogger {

private static final Logger LOGGER = LoggerFactory.getLogger(
AccountsAssociationServiceApplication.applicationNameSpace);
@Value("${spring.application.name}")
public static String applicationNameSpace;
private static final Logger LOGGER = LoggerFactory.getLogger(applicationNameSpace);

@Override
public boolean preHandle(HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ protected void enrichAssociation(@MappingTarget Association association) {

@Mapping(target = "status",
expression = "java(Association.StatusEnum.fromValue(associationDao.getStatus()))")
@Mapping(target = "approvalRoute",
expression = "java(Association.ApprovalRouteEnum.fromValue(associationDao.getApprovalRoute()))")
public abstract Association daoToDto(final AssociationDao associationDao);

public OffsetDateTime localDateTimeToOffsetDateTime(LocalDateTime localDateTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class AssociationDao {
private LocalDateTime removedAt;
@NotNull
@Field("approval_route")
private ApprovalRouteEnum approvalRoute;
private String approvalRoute;
@Indexed
@Field("user_email")
private String userEmail;
Expand Down Expand Up @@ -94,11 +94,11 @@ public LocalDateTime getCreatedAt() {
return createdAt;
}

public ApprovalRouteEnum getApprovalRoute() {
public String getApprovalRoute() {
return approvalRoute;
}

public void setApprovalRoute(ApprovalRouteEnum approvalRoute) {
public void setApprovalRoute(String approvalRoute) {
this.approvalRoute = approvalRoute;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package uk.gov.companieshouse.accounts.association.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import uk.gov.companieshouse.accounts.association.AccountsAssociationServiceApplication;
import uk.gov.companieshouse.accounts.association.exceptions.InternalServerErrorRuntimeException;
import uk.gov.companieshouse.accounts.association.exceptions.NotFoundRuntimeException;
import uk.gov.companieshouse.accounts.association.rest.CompanyProfileEndpoint;
Expand All @@ -15,9 +15,12 @@
@Service
public class CompanyService {

@Value("${spring.application.name}")
public static String applicationNameSpace;

private final CompanyProfileEndpoint companyProfileEndpoint;

private static final Logger LOG = LoggerFactory.getLogger(AccountsAssociationServiceApplication.applicationNameSpace);
private static final Logger LOG = LoggerFactory.getLogger(applicationNameSpace);

@Autowired
public CompanyService(CompanyProfileEndpoint companyProfileEndpoint) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.companieshouse.accounts.association.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import uk.gov.companieshouse.accounts.association.AccountsAssociationServiceApplication;
import uk.gov.companieshouse.accounts.association.exceptions.InternalServerErrorRuntimeException;
import uk.gov.companieshouse.accounts.association.exceptions.NotFoundRuntimeException;
import uk.gov.companieshouse.accounts.association.rest.AccountsUserEndpoint;
Expand All @@ -14,9 +14,12 @@
@Service
public class UsersService {

@Value("${spring.application.name}")
public static String applicationNameSpace;

private final AccountsUserEndpoint accountsUserEndpoint;

private static final Logger LOG = LoggerFactory.getLogger(AccountsAssociationServiceApplication.applicationNameSpace);
private static final Logger LOG = LoggerFactory.getLogger(applicationNameSpace);

public UsersService(AccountsUserEndpoint accountsUserEndpoint) {
this.accountsUserEndpoint = accountsUserEndpoint;
Expand Down
Loading

0 comments on commit abf960f

Please sign in to comment.