Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package uk.gov.companieshouse.confirmationstatementapi.configuration;

import org.springframework.beans.factory.annotation.Qualifier;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import uk.gov.companieshouse.api.model.company.CompanyProfileApi;
import uk.gov.companieshouse.confirmationstatementapi.eligibility.EligibilityRule;
import uk.gov.companieshouse.confirmationstatementapi.eligibility.impl.CompanyOfficerValidation;
Expand All @@ -19,10 +23,6 @@
import uk.gov.companieshouse.confirmationstatementapi.service.PscService;
import uk.gov.companieshouse.confirmationstatementapi.service.ShareholderService;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@Configuration
public class ConfirmationStatementServiceEligibilityConfig {

Expand Down Expand Up @@ -51,7 +51,6 @@ public class ConfirmationStatementServiceEligibilityConfig {
private boolean multipleOfficerJourneyFeatureFlag;

@Bean
@Qualifier("confirmation-statement-eligibility-rules")
List<EligibilityRule<CompanyProfileApi>> confirmationStatementEligibilityRules(OfficerService officerService,
PscService pscService, CorporateBodyService corporateBodyService, ShareholderService shareholderService) {
var listOfRules = new ArrayList<EligibilityRule<CompanyProfileApi>>();
Expand Down Expand Up @@ -83,5 +82,5 @@ List<EligibilityRule<CompanyProfileApi>> confirmationStatementEligibilityRules(O
listOfRules.add(companyTradedStatusValidation);

return listOfRules;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,43 @@ public class InterceptorConfig implements WebMvcConfigurer {
PRIVATE,
COSTS
};
static final String[] NOT_COMPANY_AUTH_ENDPOINTS = (String[]) ArrayUtils.addAll(
static final String[] NOT_COMPANY_AUTH_ENDPOINTS = ArrayUtils.addAll(
USER_AUTH_ENDPOINTS,
INTERNAL_AUTH_ENDPOINTS
);

@Autowired
private CompanyNumberValidationInterceptor companyNumberValidationInterceptor;
private final CompanyNumberValidationInterceptor companyNumberValidationInterceptor;

@Autowired
private TransactionIdValidationInterceptor transactionIdValidationInterceptor;
private final TransactionIdValidationInterceptor transactionIdValidationInterceptor;

@Autowired
private TransactionInterceptor transactionInterceptor;
private final TransactionInterceptor transactionInterceptor;

@Autowired
private LoggingInterceptor loggingInterceptor;
private final LoggingInterceptor loggingInterceptor;

@Autowired
private FilingInterceptor filingInterceptor;
private final FilingInterceptor filingInterceptor;

@Autowired
private InternalUserInterceptor internalUserInterceptor;
private final InternalUserInterceptor internalUserInterceptor;

@Autowired
private SubmissionIdValidationInterceptor submissionIdValidationInterceptor;
private final SubmissionIdValidationInterceptor submissionIdValidationInterceptor;

private final SubmissionInterceptor submissionInterceptor;

@Autowired
private SubmissionInterceptor submissionInterceptor;
public InterceptorConfig(CompanyNumberValidationInterceptor companyNumberValidationInterceptor,
TransactionIdValidationInterceptor transactionIdValidationInterceptor, TransactionInterceptor transactionInterceptor,
LoggingInterceptor loggingInterceptor, FilingInterceptor filingInterceptor,
InternalUserInterceptor internalUserInterceptor, SubmissionIdValidationInterceptor submissionIdValidationInterceptor,
SubmissionInterceptor submissionInterceptor) {
super();
this.companyNumberValidationInterceptor = companyNumberValidationInterceptor;
this.transactionIdValidationInterceptor = transactionIdValidationInterceptor;
this.transactionInterceptor = transactionInterceptor;
this.loggingInterceptor = loggingInterceptor;
this.filingInterceptor = filingInterceptor;
this.internalUserInterceptor = internalUserInterceptor;
this.submissionIdValidationInterceptor = submissionIdValidationInterceptor;
this.submissionInterceptor = submissionInterceptor;
}

/**
* Setup the interceptors to run against endpoints when the endpoints are called
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
package uk.gov.companieshouse.confirmationstatementapi.controller;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import uk.gov.companieshouse.confirmationstatementapi.eligibility.EligibilityStatusCode;
import uk.gov.companieshouse.confirmationstatementapi.exception.CompanyNotFoundException;
import uk.gov.companieshouse.confirmationstatementapi.model.response.CompanyValidationResponse;
import uk.gov.companieshouse.confirmationstatementapi.service.CompanyProfileService;
import uk.gov.companieshouse.confirmationstatementapi.service.EligibilityService;
import uk.gov.companieshouse.confirmationstatementapi.utils.ApiLogger;

import java.util.HashMap;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;

@RestController
public class EligibilityController {

@Autowired
private CompanyProfileService companyProfileService;
private final CompanyProfileService companyProfileService;

private final EligibilityService eligibilityService;

@Autowired
private EligibilityService eligibilityService;
public EligibilityController(CompanyProfileService companyProfileService, EligibilityService eligibilityService) {
super();
this.companyProfileService = companyProfileService;
this.eligibilityService = eligibilityService;
}

@GetMapping("/confirmation-statement/company/{company-number}/eligibility")
public ResponseEntity<CompanyValidationResponse> getEligibility(@PathVariable("company-number") String companyNumber,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package uk.gov.companieshouse.confirmationstatementapi.controller;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.CONFIRMATION_STATEMENT_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.TRANSACTION_ID_KEY;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -8,24 +14,24 @@
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import uk.gov.companieshouse.api.model.filinggenerator.FilingApi;
import uk.gov.companieshouse.api.model.transaction.Transaction;
import uk.gov.companieshouse.confirmationstatementapi.exception.SubmissionNotFoundException;
import uk.gov.companieshouse.confirmationstatementapi.service.FilingService;
import uk.gov.companieshouse.confirmationstatementapi.utils.ApiLogger;

import java.util.HashMap;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.CONFIRMATION_STATEMENT_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.TRANSACTION_ID_KEY;

@RestController
@RequestMapping("/private/transactions/{transaction_id}/confirmation-statement/{confirmation_statement_id}/filings")
public class FilingController {

private final FilingService filingService;

@Autowired
private FilingService filingService;
public FilingController(FilingService filingService) {
super();
this.filingService = filingService;
}

@GetMapping
public ResponseEntity<FilingApi[]> getFiling(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
package uk.gov.companieshouse.confirmationstatementapi.controller;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import uk.gov.companieshouse.confirmationstatementapi.exception.CompanyNotFoundException;
import uk.gov.companieshouse.confirmationstatementapi.model.json.NextMadeUpToDateJson;
import uk.gov.companieshouse.confirmationstatementapi.service.ConfirmationStatementService;
import uk.gov.companieshouse.confirmationstatementapi.utils.ApiLogger;

import java.util.HashMap;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;

@RestController
public class NextMadeUpToDateController {

private final ConfirmationStatementService confirmationStatementService;

@Autowired
private ConfirmationStatementService confirmationStatementService;
public NextMadeUpToDateController(ConfirmationStatementService confirmationStatementService) {
super();
this.confirmationStatementService = confirmationStatementService;
}

@GetMapping("/confirmation-statement/company/{company-number}/next-made-up-to-date")
public ResponseEntity<NextMadeUpToDateJson> getNextMadeUpToDate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@
import java.util.List;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.CONFIRMATION_STATEMENT_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.TRANSACTION_ID_KEY;

@RestController
class PersonsOfSignificantControlController {

private final PscService pscService;

@Autowired
private PscService pscService;
public PersonsOfSignificantControlController(PscService pscService) {
super();
this.pscService = pscService;
}

@GetMapping("/transactions/{transaction_id}/confirmation-statement/{confirmation_statement_id}/persons-of-significant-control")
public ResponseEntity<List<PersonOfSignificantControlJson>> getPersonsOfSignificantControl(
@RequestAttribute("transaction") Transaction transaction,
@PathVariable(TRANSACTION_ID_KEY) String transactionId,
@PathVariable(CONFIRMATION_STATEMENT_ID_KEY) String confirmationStatementId,
@RequestHeader(value = ERIC_REQUEST_ID_KEY) String requestId) {

var logMap = new HashMap<String, Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.List;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.CONFIRMATION_STATEMENT_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.TRANSACTION_ID_KEY;

@RestController
Expand All @@ -34,6 +35,7 @@ public RegisterLocationsController(RegisterLocationService regLocService) {
public ResponseEntity<List<RegisterLocationJson>> getRegisterLocations(
@RequestAttribute("transaction") Transaction transaction,
@PathVariable(TRANSACTION_ID_KEY) String transactionId,
@PathVariable(CONFIRMATION_STATEMENT_ID_KEY) String confirmationStatementId,
@RequestHeader(value = ERIC_REQUEST_ID_KEY) String requestId) {

var logMap = new HashMap<String, Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.List;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.CONFIRMATION_STATEMENT_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.TRANSACTION_ID_KEY;

Expand All @@ -35,6 +36,7 @@ public ShareholderController(ShareholderService shareholderService) {
public ResponseEntity<List<ShareholderJson>> getShareholders(
@RequestAttribute("transaction") Transaction transaction,
@PathVariable(TRANSACTION_ID_KEY) String transactionId,
@PathVariable(CONFIRMATION_STATEMENT_ID_KEY) String confirmationStatementId,
@RequestHeader(value = ERIC_REQUEST_ID_KEY) String requestId) {

var map = new HashMap<String, Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.HashMap;

import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.CONFIRMATION_STATEMENT_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.ERIC_REQUEST_ID_KEY;
import static uk.gov.companieshouse.confirmationstatementapi.utils.Constants.TRANSACTION_ID_KEY;

Expand All @@ -35,6 +36,7 @@ public StatementOfCapitalController(StatementOfCapitalService statementOfCapital
public ResponseEntity<StatementOfCapitalJson> getStatementOfCapital(
@RequestAttribute("transaction") Transaction transaction,
@PathVariable(TRANSACTION_ID_KEY) String transactionId,
@PathVariable(CONFIRMATION_STATEMENT_ID_KEY) String confirmationStatementId,
@RequestHeader(value = ERIC_REQUEST_ID_KEY) String requestId) {

var logMap = new HashMap<String, Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public SubmissionInterceptor(ConfirmationStatementService confirmationStatementS

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
@SuppressWarnings("unchecked")
final Map<String, String> pathVariables = (Map<String, String>) request
.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
final var submissionId = pathVariables.get(CONFIRMATION_STATEMENT_ID_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public TransactionInterceptor(TransactionService transactionService) {

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
@SuppressWarnings("unchecked")
final Map<String, String> pathVariables = (Map<String, String>) request
.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
final var transactionId = pathVariables.get(TRANSACTION_ID_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class CompanyNumberValidationInterceptor implements HandlerInterceptor {

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
@SuppressWarnings("unchecked")
final Map<String, String> pathVariables = (Map<String, String>) request
.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
String companyNumber = pathVariables.get(COMPANY_NUMBER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class SubmissionIdValidationInterceptor implements HandlerInterceptor {

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
@SuppressWarnings("unchecked")
final Map<String, String> pathVariables = (Map<String, String>) request
.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
final var submissionId = pathVariables.get(CONFIRMATION_STATEMENT_ID_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class TransactionIdValidationInterceptor implements HandlerInterceptor {

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
@SuppressWarnings("unchecked")
final Map<String, String> pathVariables = (Map<String, String>) request
.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
final var transactionId = pathVariables.get(TRANSACTION_ID_KEY);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package uk.gov.companieshouse.confirmationstatementapi.model.mapping;

import java.sql.Timestamp;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import uk.gov.companieshouse.api.model.common.DateOfBirth;
import uk.gov.companieshouse.api.model.company.PersonOfSignificantControl;
import uk.gov.companieshouse.api.model.psc.NameElementsApi;
import uk.gov.companieshouse.confirmationstatementapi.model.json.PersonOfSignificantControlJson;

import java.sql.Timestamp;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class PscsMapper {

Expand All @@ -25,7 +25,7 @@ public List<PersonOfSignificantControlJson> mapToPscsApi(List<PersonOfSignifican
}
return pscList.stream()
.map(this::mapToPscJson)
.collect(Collectors.toList());
.toList();
}

private PersonOfSignificantControlJson mapToPscJson(PersonOfSignificantControl psc) {
Expand Down Expand Up @@ -93,7 +93,7 @@ private void mapNames(PersonOfSignificantControl psc, PersonOfSignificantControl

Arrays.stream(names).forEach(name -> {
if (StringUtils.isNotBlank(name)) {
if (fullName.length() > 0) {
if (!fullName.isEmpty()) {
fullName.append(" ");
}
fullName.append(name);
Expand Down
Loading