Skip to content

Commit

Permalink
Merge pull request #254 from bcgov/feature/GRAD2-2244
Browse files Browse the repository at this point in the history
GRAD2-2244: task is complete.
  • Loading branch information
infstar authored Apr 2, 2024
2 parents 3375c97 + 04b2268 commit 0095c3b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ private void mergeDocuments(ProcessorData processorData,String mincode,String fi
objs.setDestinationFileName(pBuilder.toString());
objs.addSources(locations);
objs.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
sftpUtils.sftpUploadTSW(processorData.getBatchId(),mincode,fileName);
}catch (Exception e) {
logger.debug(EXCEPTION,e.getLocalizedMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ public class SFTPUtils {
@Value("${sftp.bcmail.known-hosts}")
private String BCMAIL_KNOWN_HOSTS;

@Value("${sftp.tsw.host}")
private String TSW_REMOTE_HOST;
@Value("${sftp.tsw.username}")
private String TSW_SFTP_USERNAME;
@Value("${sftp.tsw.priv-key}")
private String TSW_PRIVATE_KEY;
@Value("${sftp.tsw.pub-key}")
private String TSW_PUBLIC_KEY;
@Value("${sftp.tsw.known-hosts}")
private String TSW_KNOWN_HOSTS;


@Value("${sftp.bcmail.location}")
private String BC_MAIL_LOCATION;

Expand Down Expand Up @@ -89,27 +77,7 @@ public boolean sftpUploadBCMail(Long batchId, String rootFolder, String mincode)
}

/**
* Method specific for uploading files to TSW
* @param batchId batch id
* @param mincode mincode
* @param fileName the filename
* @return true if successful
*/
public boolean sftpUploadTSW(Long batchId,String mincode,String fileName) {
Map<String, List<String>> files = new HashMap<>();
String localFile = formatPath(EducDistributionApiConstants.TMP_DIR + EducDistributionApiConstants.DEL + batchId + EducDistributionApiConstants.DEL + mincode + EducDistributionApiConstants.DEL + fileName+".pdf");
String remoteFile = "/$1$dga5037/EDUC/XTD";
String location1 = remoteFile+"/WEB/"+fileName+".pdf";
String location2 = remoteFile+"/TSWSFTP/"+fileName+".pdf";
String location3 = remoteFile+"/WEB/PST/"+fileName+".pdf";
files.computeIfAbsent(localFile, v -> new ArrayList<>()).add(location1);
files.computeIfAbsent(localFile, v -> new ArrayList<>()).add(location2);
files.computeIfAbsent(localFile, v -> new ArrayList<>()).add(location3);
return sftpUpload(files, TSW_SFTP_USERNAME, TSW_REMOTE_HOST, REMOTE_PORT, TSW_PRIVATE_KEY, TSW_PUBLIC_KEY, TSW_KNOWN_HOSTS);
}

/**
* Method for uploading files to an sftp server
* Method for uploading files to a sftp server
* @param files a map of local -> remote file paths. Use of Map<String, List<String>> enables the key (the file to upload)
* to have multiple upload locations (the List<String> represents the upload locations)
* @param userName the username to log into the sftp server
Expand Down
6 changes: 0 additions & 6 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ sftp:
pub-key: ${BCMAIL_SSH_PUBLIC_KEY}
known-hosts: ${BCMAIL_KNOWN_HOSTS_ENTRY}
location: ${BCMAIL_LOCATION}
tsw:
host: ${TSW_SFTP_HOST}
username: ${TSW_SFTP_USER}
priv-key: ${grad_vms_id_rsa}
pub-key: ${grad_vms_id_rsa.pub}
known-hosts: ${TSW_KNOWN_HOSTS_ENTRY}

endpoint:
keycloak:
Expand Down
10 changes: 2 additions & 8 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,7 @@ sftp:
pub-key: 676
known-hosts: 45fsdss
location: /Index/Dev
tsw:
host: 454@tsw.aril.com
username: tswmail
priv-key: 565
pub-key: 888
known-hosts: 5644ddww


#Endpoints
endpoint:
keycloak:
Expand Down Expand Up @@ -173,4 +167,4 @@ splunk:
enabled: false

scheduler:
clean-tmp-cache-cron: 0 0 */4 * * *
clean-tmp-cache-cron: 0 0 */4 * * *

0 comments on commit 0095c3b

Please sign in to comment.