Skip to content

Commit

Permalink
Merge pull request #333 from hmcts/feature/pdda-396v
Browse files Browse the repository at this point in the history
Feature/pdda 396v
  • Loading branch information
scottatwell1 authored Oct 16, 2024
2 parents ee07533 + ae0ec28 commit bb9d0b6
Show file tree
Hide file tree
Showing 27 changed files with 2,904 additions and 532 deletions.
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ dependencies {
implementation 'org.springframework:spring-tx:6.1.13'
implementation 'org.springframework:spring-web:6.1.13'
implementation files('lib/jsch-0.1.54.jar')
implementation 'com.hierynomus:sshj:0.38.0'
implementation group: 'org.apache.sshd', name: 'sshd-common', version: '2.14.0'
implementation group: 'org.apache.sshd', name: 'sshd-sftp', version: '2.14.0'
implementation group: 'org.apache.sshd', name: 'sshd-core', version: '2.14.0'
implementation 'org.apache.commons:commons-vfs2:2.9.0'
implementation 'org.apache.commons:commons-configuration2:2.11.0'
implementation 'org.postgresql:postgresql:42.7.4'
Expand Down Expand Up @@ -222,9 +226,11 @@ dependencies {
implementation 'org.flywaydb:flyway-database-postgresql:10.19.0'
implementation 'org.flywaydb:flyway-database-hsqldb:10.19.0'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', {
exclude group: 'junit', module: 'junit'
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
exclude group: 'junit', module: 'junit'
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation group: 'com.github.stefanbirkner', name: 'fake-sftp-server-rule', version: 'fake-sftp-server-rule-2.0.0'
implementation group: 'de.ppi', name: 'fake-sftp-server-extension', version: '1.0.3'
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.2'
testImplementation 'org.easymock:easymock:5.4.0'
testImplementation 'org.mockito:mockito-core:5.2.0'
Expand All @@ -234,6 +240,7 @@ dependencies {
compileOnly 'jakarta.servlet:jakarta.servlet-api:6.1.0'
compileOnly 'jakarta.servlet.jsp:jakarta.servlet.jsp-api:4.0.0'
implementation group: 'io.rest-assured', name: 'rest-assured'
implementation 'org.bouncycastle:bcprov-jdk18on:1.78'
}

mainClassName = 'uk.gov.hmcts.PddaSpringbootApplication'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ protected CourtRoomEvent(CourtRoomIdentifier courtRoomIdentifier) {
*/
@Override
public Integer getCourtId() {
if (courtRoomIdentifier == null) {
return null;
}
return courtRoomIdentifier.getCourtId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.stereotype.Service;
import uk.gov.hmcts.framework.scheduler.RemoteTask;
import uk.gov.hmcts.pdda.business.AbstractControllerBean;
import uk.gov.hmcts.pdda.business.services.pdda.sftp.SftpService;

/**
* <p>
Expand Down Expand Up @@ -38,7 +39,7 @@ public class PddaBaisControllerBean extends AbstractControllerBean implements Re
private static final String LOG_CALLED = " called";
private static final String TWO_PARAMS = "{}{}";

private PddaHelper pddaHelper;
private SftpService sftpService;

public PddaBaisControllerBean(EntityManager entityManager) {
super(entityManager);
Expand All @@ -50,41 +51,22 @@ public PddaBaisControllerBean() {

/**
* <p>
* Scheduler task wrapper to retrieve Bais events.
* Scheduler task wrapper to retrieve Bais messages.
* </p>
*/
@Override
public void doTask() {
retrieveFromBaisCP();
retrieveFromBaisXhibit();
}

/**
* <p>
* Retrieve Bais events from CP.
* </p>
*/
public void retrieveFromBaisCP() {
String methodName = "retrieveFromBaisCP()";
String methodName = "doTask()";
LOG.debug(TWO_PARAMS, methodName, LOG_CALLED);
getPddaHelper().retrieveFromBaisCp();
}

/**
* <p>
* Retrieve Bais events from Xhibit.
* </p>
*/
public void retrieveFromBaisXhibit() {
String methodName = "retrieveFromBaisXhibit()";
LOG.debug(TWO_PARAMS, methodName, LOG_CALLED);
getPddaHelper().retrieveFromBaisXhibit();
getSftpService().processBaisMessages(0);
}

private PddaHelper getPddaHelper() {
if (pddaHelper == null) {
pddaHelper = new PddaHelper(getEntityManager());
}
return pddaHelper;

SftpService getSftpService() {
if (sftpService == null) {
sftpService = new SftpService(getEntityManager());
}
return sftpService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,24 @@ public class PddaConfigHelper {
private XhbConfigPropRepository xhbConfigPropRepository;
private Environment environment;

protected static class Config {
static final String SFTP_HOST = "pdda.bais_sftp_hostname";
static final String SFTP_PASSWORD = "pdda.bais_sftp_password";
static final String SFTP_UPLOAD_LOCATION = "PDDA_BAIS_SFTP_UPLOAD_LOCATION";
static final String SFTP_USERNAME = "pdda.bais_sftp_username";
static final String CP_SFTP_USERNAME = "pdda.bais_cp_sftp_username";
static final String CP_SFTP_PASSWORD = "pdda.bais_cp_sftp_password";
static final String CP_SFTP_UPLOAD_LOCATION = "PDDA_BAIS_CP_SFTP_UPLOAD_LOCATION";
public static class Config {
// Database values
public static final String DB_SFTP_HOST = "PDDA_BAIS_SFTP_HOSTNAME";
public static final String DB_SFTP_PASSWORD = "PDDA_BAIS_SFTP_PASSWORD";
public static final String DB_SFTP_UPLOAD_LOCATION = "PDDA_BAIS_SFTP_UPLOAD_LOCATION";
public static final String DB_SFTP_USERNAME = "PDDA_BAIS_SFTP_USERNAME";
public static final String DB_CP_SFTP_USERNAME = "PDDA_BAIS_CP_SFTP_USERNAME";
public static final String DB_CP_SFTP_PASSWORD = "PDDA_BAIS_CP_SFTP_PASSWORD";
public static final String DB_CP_SFTP_UPLOAD_LOCATION = "PDDA_BAIS_CP_SFTP_UPLOAD_LOCATION";

// Key vault values
public static final String KV_SFTP_HOST = "pdda.bais_sftp_hostname";
public static final String KV_SFTP_PASSWORD = "pdda.bais_sftp_password";
public static final String KV_SFTP_UPLOAD_LOCATION = "PDDA_BAIS_SFTP_UPLOAD_LOCATION";
public static final String KV_SFTP_USERNAME = "pdda.bais_sftp_username";
public static final String KV_CP_SFTP_USERNAME = "pdda.bais_cp_sftp_username";
public static final String KV_CP_SFTP_PASSWORD = "pdda.bais_cp_sftp_password";
public static final String KV_CP_SFTP_UPLOAD_LOCATION = "PDDA_BAIS_CP_SFTP_UPLOAD_LOCATION";
}

protected PddaConfigHelper(EntityManager entityManager, Environment environment) {
Expand Down Expand Up @@ -97,7 +107,7 @@ public String getMandatoryConfigValue(final String propertyName) {
public String getEnvValue(final String propertyName) {
methodName = "getConfigValue(" + propertyName + ")";
LOG.debug(LOG_BRACKETS, methodName, LOG_CALLED);
String result = environment.getProperty(propertyName);
String result = getEnvironment().getProperty(propertyName);
LOG.debug("{}{}{}", propertyName, " = ", result);
return result;
}
Expand All @@ -123,6 +133,14 @@ protected ConfigPropMaintainer getConfigPropMaintainer() {
return configPropMaintainer;
}

public Environment getEnvironment() {
return environment;
}

public void setEnvironment(Environment environment) {
this.environment = environment;
}

public class InvalidConfigException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Expand Down
Loading

0 comments on commit bb9d0b6

Please sign in to comment.