-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
530 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...main/java/de/adorsys/aspsp/xs2a/connector/spi/file/exception/FileManagementException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...ector/src/main/java/de/adorsys/aspsp/xs2a/connector/spi/file/util/DeleteFileRunnable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...or/src/main/java/de/adorsys/aspsp/xs2a/connector/spi/file/util/FileManagementService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
81 changes: 81 additions & 0 deletions
81
.../main/java/de/adorsys/aspsp/xs2a/connector/spi/file/util/FileManagementServiceSimple.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.