Skip to content

Commit

Permalink
Merge branch 'release-13.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
semenykhin committed Dec 20, 2021
2 parents e5c7262 + d569376 commit 4851283
Show file tree
Hide file tree
Showing 22 changed files with 530 additions and 68 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ Please use correct version of xs2a-connector-examples and Ledgers. Matches are d

| xs2a-connector-examples | Ledgers |
|-------------------------|---------|
| v.13.4 | v.4.17 |
| v.13.3 | v.4.17 |
| v.13.2 | v.4.16 |
| v.13.1 | v.4.15 |
| v.13.0 | v.4.14 |
| v.12.4 | v.4.17 |
| v.12.3 | v.4.17 |
| v.12.2 | v.4.16 |
| v.12.1 | v.4.15 |
Expand Down
23 changes: 23 additions & 0 deletions doc/release_notes/Release_notes_13.4.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
= Release notes v.13.4

== Table of Contents

* Implemented writing transactions data into file asynchronous

* Technical password from property `xs2a.funds-confirmation-user-password` changed

== Implemented writing transactions data into file asynchronous

From now on, content of downloaded transaction file is no more mocked, but the real data got during Read Transaction List
request. Transaction file writing is being performed in a separate thread to increase performance and reduce response time.
New properties were added into `application.yml` :

* `xs2a.download.files.dir` - path to directory, where files are being created for downloading
* `xs2a.download.files.cleanup.delay_s` - time in seconds, specifies how long download link will be valid after the first retrieval request.
When specified time passes, file and its parent directory will be deleted, all next requests by the same download
link will cause response with code 404 `Not Found`

== Technical password from property `xs2a.funds-confirmation-user-password` changed

Property value `xs2a.funds-confirmation-user-password` changed from `12345` to `admin123` to handle properly
ASPSP PIIS consents.
2 changes: 1 addition & 1 deletion gateway-app-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>xs2a-connector-examples</artifactId>
<groupId>de.adorsys.ledgers</groupId>
<version>13.3</version>
<version>13.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
9 changes: 8 additions & 1 deletion gateway-app-embedded/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ keycloak:
secret: a61a81cd-7178-40d8-8386-ed02791e6592 #Here should be personal generated secret for client (swap public to 'private?' generate secret, swap to public again)

xs2a.funds-confirmation-user-login: admin
xs2a.funds-confirmation-user-password: 12345
xs2a.funds-confirmation-user-password: admin123

# FILE DOWNLOADING RELATED PROPERTIES
#Filedir for the files which should be accessible by downloadLink, default value "/tmp/XS2A"
xs2a.download.files.dir: /tmp/XS2A
#Delay in seconds when already downloaded file and its parent dir will be deleted, default value 30
xs2a.download.files.cleanup.delay_s: 30


spring:
application.name: ledgers-xs2a-gateway
Expand Down
2 changes: 1 addition & 1 deletion gateway-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.adorsys.ledgers</groupId>
<artifactId>xs2a-connector-examples</artifactId>
<version>13.3</version>
<version>13.4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>gateway-app</artifactId>
Expand Down
8 changes: 7 additions & 1 deletion gateway-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ keycloak:
xs2a.swagger.psd2.api.location: #/psd2-api-1.2-Update-2018-08-18-non-oauth.yaml

xs2a.funds-confirmation-user-login: admin
xs2a.funds-confirmation-user-password: 12345
xs2a.funds-confirmation-user-password: admin123

# FILE DOWNLOADING RELATED PROPERTIES
#Filedir for the accessible by 'downloadLink' files, default value "/tmp/XS2A"
xs2a.download.files.dir: /tmp/XS2A/
#Delay in seconds when already downloaded file and its parent dir will be deleted, default value 30
xs2a.download.files.cleanup.delay_s: 30

#TanEncryption
application:
Expand Down
2 changes: 1 addition & 1 deletion ledgers-rest-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.adorsys.ledgers</groupId>
<artifactId>xs2a-connector-examples</artifactId>
<version>13.3</version>
<version>13.4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>ledgers-rest-client</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.adorsys.ledgers</groupId>
<artifactId>xs2a-connector-examples</artifactId>
<version>13.3</version>
<version>13.4</version>
<packaging>pom</packaging>

<name>XS2A Connector Examples</name>
Expand Down Expand Up @@ -86,7 +86,7 @@
<ruleset.basedir>${project.basedir}</ruleset.basedir>

<!-- xs2a version -->
<xs2a.version>13.3</xs2a.version>
<xs2a.version>13.4</xs2a.version>
<!-- ledgers version -->
<ledgers.version>4.17</ledgers.version>

Expand Down
2 changes: 1 addition & 1 deletion xs2a-connector-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>xs2a-connector-examples</artifactId>
<groupId>de.adorsys.ledgers</groupId>
<version>13.3</version>
<version>13.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion xs2a-connector-oauth-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>xs2a-connector-examples</artifactId>
<groupId>de.adorsys.ledgers</groupId>
<version>13.3</version>
<version>13.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion xs2a-connector-remote/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.adorsys.ledgers</groupId>
<artifactId>xs2a-connector-examples</artifactId>
<version>13.3</version>
<version>13.4</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion xs2a-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.adorsys.ledgers</groupId>
<artifactId>xs2a-connector-examples</artifactId>
<version>13.3</version>
<version>13.4</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2018-2021 adorsys GmbH & Co KG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package de.adorsys.aspsp.xs2a.connector.spi.file.exception;

import java.io.IOException;

public class FileManagementException extends IOException {
public FileManagementException(String errorMessage) {
super(errorMessage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2018-2021 adorsys GmbH & Co KG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package de.adorsys.aspsp.xs2a.connector.spi.file.util;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.nio.file.Path;

@Slf4j
@AllArgsConstructor
@SuppressWarnings("PMD.ShortMethodName")
public class DeleteFileRunnable implements Runnable {
private final String downloadLink;
private final int deleteFileDelay;

@Override
public void run() {
Path filePath = Path.of(downloadLink);
File file = new File(filePath.toString());

Path parentDirectoryPath = filePath.getParent();
File parentDirectory = new File(parentDirectoryPath.toString());

try {
log.info("File {} is scheduled to be deleted in {} seconds", filePath, deleteFileDelay);
Thread.sleep(deleteFileDelay * 1000L);
FileUtils.deleteQuietly(file);
log.info("File deleted. File list in directory {} before deleting: {}", parentDirectoryPath, parentDirectory.list());
log.info("Directory {} is scheduled to be deleted in {} seconds", parentDirectoryPath, deleteFileDelay);
Thread.sleep(deleteFileDelay * 1000L);
FileUtils.deleteDirectory(parentDirectory);
log.info("Directory deleted: {}", parentDirectoryPath);
} catch (Exception e) {
log.error("Delete file by Download Id failed (IOException): Decrypted Download id: [{}], message {}, exception: {}", downloadLink, e.getMessage(), e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2018-2021 adorsys GmbH & Co KG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package de.adorsys.aspsp.xs2a.connector.spi.file.util;

import de.adorsys.aspsp.xs2a.connector.spi.file.exception.FileManagementException;
import org.springframework.core.io.Resource;

public interface FileManagementService {
/**
* Stores the file and returns its identifier for further access
* @param resource is a Resource representation of input data to be stored
* @param filename is a name of file to be saved
* @return download link being used for this file retrieving
* @throws FileManagementException in case of errors during file creation and data writing
*/
String saveFileAndBuildDownloadLink(Resource resource, String filename) throws FileManagementException;

/**
* Returns file by its downloadLink, returned after execution of `saveFileAndBuildDownloadLink(Resource resource, String filename)` method
* @param downloadLink is an identifier of requested file
* @return Resource as a representation of a requested file
* @throws FileManagementException in case of error during file reading or retrieving
*/
Resource getFileByDownloadLink(String downloadLink) throws FileManagementException;

/**
* Deletes file by downloadLink
* @param downloadLink is an identifier of the file to be deleted.
*/
void deleteFileByDownloadLink(String downloadLink);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2018-2021 adorsys GmbH & Co KG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package de.adorsys.aspsp.xs2a.connector.spi.file.util;

import de.adorsys.aspsp.xs2a.connector.spi.file.exception.FileManagementException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

@Service
@Slf4j
public class FileManagementServiceSimple implements FileManagementService {
@Value("${xs2a.download.files.cleanup.delay_s:30}")
public int deleteFileDelay;

@Value("${xs2a.download.files.dir:/tmp/XS2A}")
private String configurationPath;

@Override
public String saveFileAndBuildDownloadLink(Resource resource, String filename) throws FileManagementException {

try {
byte[] bytes = resource.getInputStream().readAllBytes();
Path dirPath = Path.of(configurationPath);
Files.createDirectories(dirPath);
Path dir = Files.createTempDirectory(dirPath, StringUtils.EMPTY);
Path fileToCreatePath = dir.resolve(filename);
Path newFilePath = Files.createFile(fileToCreatePath);
File file = newFilePath.toFile();

WriteFileRunnable writeFileRunnable = new WriteFileRunnable(file, bytes);
Thread asyncFileWrite = new Thread(writeFileRunnable);
asyncFileWrite.start();

log.info("Bytes read: [{}]", bytes.length);
return file.getAbsolutePath();
} catch (IOException e) {
log.error("Save file and build Download Link failed (IOException): message {}, exception {}", e.getMessage(), e);
throw new FileManagementException(e.getMessage());
}
}

@Override
public Resource getFileByDownloadLink(String downloadLink) throws FileManagementException {
Path path = Path.of(downloadLink);
if (path.toFile().exists()) {
return new FileSystemResource(path);
}
log.error("File does not exist: [{}]", downloadLink);
throw new FileManagementException("Requested file does not exist");
}

@Override
public void deleteFileByDownloadLink(String downloadLink) {
DeleteFileRunnable deleteFileRunnable = new DeleteFileRunnable(downloadLink, deleteFileDelay);
Thread asyncFileDelete = new Thread(deleteFileRunnable);
asyncFileDelete.start();
}
}
Loading

0 comments on commit 4851283

Please sign in to comment.