Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ad9ebea
New develop version → 1.4.0-SNAPSHOT
supportontimize Jun 28, 2023
3ca4119
Merge pull request #16 from ontimize/sync/1.3.1
angelherce Jun 28, 2023
d05de1c
Git action add release on deploy
pmkirsten Dec 29, 2023
a034cd0
Rename deploy-artifactory-release.yml to deploy-mvn-central-release.yml
pmkirsten Dec 29, 2023
e03c7b8
Merge pull request #17 from ontimize/feature/git-action-add-release-o…
pmkirsten Dec 29, 2023
8618518
Update documentation link
pmkirsten Dec 29, 2023
e9a8f6d
performance: S3 Connection has been optimized
angelherce Apr 24, 2025
d67a743
Merge pull request #18 from ontimize/performance/optimize-s3-connection
angelherce Apr 24, 2025
03abb88
Update deploy-mvn-central-snapshot.yml
pmkirsten Apr 24, 2025
041ff5e
Update deploy-mvn-central-release.yml
pmkirsten Apr 24, 2025
af6e6bc
Merge pull request #19 from ontimize/feature/update-versions
pmkirsten Apr 24, 2025
84ad7dc
fix: properly close S3 input streams to prevent resource leaks
angelherce Apr 25, 2025
e6b68d6
Merge pull request #20 from ontimize/fix/s3-close-streams
angelherce Apr 25, 2025
125ccf8
feat: add new method to OSdmsService
angelherce Apr 25, 2025
df73d86
Merge pull request #21 from ontimize/feature/new_service_method
angelherce Apr 25, 2025
a3ce739
fix: TemporalFileManager fix cleanup and delete
angelherce Apr 25, 2025
d979967
Merge pull request #22 from ontimize/fix/temporal-file-manager
angelherce Apr 25, 2025
b4cc36d
feat: Add component to auto remove temp files
angelherce Apr 28, 2025
ff997ff
Merge pull request #23 from ontimize/feature/remove-temporal-files
angelherce Apr 28, 2025
ee03d9a
feat: Add filter to auto remove temp files
angelherce Apr 28, 2025
10cb21d
Merge pull request #24 from ontimize/feature/remove-temporal-files
angelherce Apr 28, 2025
74f9234
fix: Add new dependency
angelherce Apr 28, 2025
cbab198
Merge pull request #25 from ontimize/feature/remove-temporal-files
angelherce Apr 28, 2025
57f6560
fix: Remove filter to remove temporal files
angelherce Apr 28, 2025
211574c
feat: Add method to remove temporal files
angelherce Apr 28, 2025
deb0c8d
Merge pull request #26 from ontimize/feature/remove-temporal-files
angelherce Apr 28, 2025
11b45cb
fix: Correct NullPointerException
angelherce Apr 29, 2025
f8a573b
Merge pull request #27 from ontimize/fix/temporal-file-manager
angelherce Apr 30, 2025
9f6a1cc
Update GitHub Actions and pom.xml for deploying with Maven Central Pl…
pmkirsten May 12, 2025
5b2f100
Merge pull request #28 from ontimize/fix/publish-central-maven
pmkirsten May 12, 2025
963de51
Update GitHub Actions and pom.xml for deploying with Maven Central Pl…
pmkirsten May 12, 2025
d38f9d0
Merge pull request #29 from ontimize/fix/publish-central-maven
pmkirsten May 12, 2025
0c93156
fix: Update README.md
angelherce May 13, 2025
1f38db9
New release → 1.4.0
supportontimize May 13, 2025
147eaeb
Update CHANGELOG.md
angelherce May 13, 2025
b73c7f8
Update README.md
angelherce May 13, 2025
898334a
Update pom.xml
angelherce May 13, 2025
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
Expand Up @@ -28,16 +28,16 @@ jobs:
run: |
echo "BRANCH=${{ github.event.inputs.RELEASE_BRANCH || github.ref }}" >> $GITHUB_ENV
- name: Checkout repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH }}
fetch-depth: 0
- name: Setup Java JDK and Maven
uses: ontimize/setup-java-maven-gitAction@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
server-id: ossrh
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
Expand Down Expand Up @@ -68,4 +68,13 @@ jobs:
- name: Create pull request
run: |
version=${{ steps.tag.outputs.version }}
gh pr create -B develop -H sync/$version --title "Backmerge from main into develop" --body "Created by a GitHub Action → Resync develop branch with main branch and increase project version"
gh pr create -B develop -H sync/$version --title "Backmerge from main into develop" --body "Created by a GitHub Action → Resync develop branch with main branch and increase project version"
- name: Create release on Github
uses: ncipollo/release-action@2792aea87063cfd0d27953ac38e3ab45afacc154
with:
commit: ${{ env.BRANCH }}
tag: ${{ steps.tag.outputs.version }}
name: ${{ steps.tag.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Check out the [changelog](CHANGELOG.md) for version ${{ steps.tag.outputs.version }}
8 changes: 4 additions & 4 deletions .github/workflows/deploy-mvn-central-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
steps:
- name: Checkout repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Java JDK and Maven
uses: ontimize/setup-java-maven-gitAction@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
server-id: ossrh
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish to Apache Maven Central
run: mvn -B -U clean deploy -Pgenerate-version
run: mvn -B -U clean deploy -Pgenerate-version
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@

## [Unreleased]

## [1.4.0] - 2025-05-13

### Added ✔️
* The `TemporalFileManager` has been created to manage temporary files per request.

* **OSdmsService:** Added `getTemporalFiles` method has been added to `OSdmsService`.

### Fixed 🐛
* Closed `S3ObjectInputStream` instances properly to avoid `CLOSE_WAIT` socket issues and potential memory/resource leaks during file download operations.

### Changed 🛠️
* **S3 Connection:** The connection to S3 has been optimized.

## [1.3.1] - 2023-06-28

### Fixed 🐛
Expand Down Expand Up @@ -65,9 +78,10 @@
* **OSdmsWorkspace Annotation:** Added an annotation to establish multiple query workspaces on the DMS system for an
entity.

[unreleased]: https://github.com/ontimize/ontimize-jee-sdms/compare/1.3.1...HEAD
[unreleased]: https://github.com/ontimize/ontimize-jee-sdms/compare/1.4.0...HEAD
[1.4.0]: https://github.com/ontimize/ontimize-jee-sdms/compare/1.3.1...1.4.0
[1.3.1]: https://github.com/ontimize/ontimize-jee-sdms/compare/1.3.0...1.3.1
[1.3.0]: https://github.com/ontimize/ontimize-jee-sdms/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/ontimize/ontimize-jee-sdms/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/ontimize/ontimize-jee-sdms/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/ontimize/ontimize-jee-sdms/releases/tag/1.0.0
[1.0.0]: https://github.com/ontimize/ontimize-jee-sdms/releases/tag/1.0.0
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Ontimize JEE Storage DMS
# Ontimize JEE Storage SDMS

## 📜 Introduction
Ontimize JEE Storage DMS is a module of the Ontimize framework that provides a document management solution for Java Enterprise Edition (JEE) based enterprise applications. This module enables organizations to store and manage documents within their enterprise applications.
## ✍ Use
To use the module, you only need to import it into your project to be able to use it. On the entity that is required to have the DMS endpoints, you will have to extend the drivers and add the corresponding DMS methods to the entity services. For more information, see the [documentation]().
Ontimize JEE Storage SDMS is a module of the Ontimize framework that provides a document management solution for Java Enterprise Edition (JEE) based enterprise applications. This module enables organizations to store and manage documents within their enterprise applications.

## ✍ Usage
To use this module, you only need to import it into your project. For entities requiring SDMS endpoints, you must extend the drivers and add the corresponding SDMS methods to the entity's services. For more information, please refer to the [documentation](https://ontimize.github.io/docs/v3/systems/sdms/).

## 💼 Documentation
All documentation related to how to use it in a project, tutorials and details of its systems and usage can be found online by accessing the link about [Ontimize Boot documentation](https://ontimize.github.io/ontimize-boot/).
## 👁️‍🗨️ Versions and dependencies
All the versions and dependencies of the artifacts contained in this project can be downloaded from [Maven Central](https://central.sonatype.dev/namespace/com.ontimize.boot), as well as knowing each of its dependencies.
All documentation related to project integration, tutorials, and details about its systems and usage can be found online via the following link to the [Ontimize Boot documentation](https://ontimize.github.io/docs/).

## 👁️‍🗨️ Versions and Dependencies
All versions and dependencies of the artifacts included in this project can be downloaded from [Maven Central](https://central.sonatype.com/namespace/com.ontimize.jee.sdms), as well as viewing each of their dependencies.

## :gear: Changelog
You can consult our changelog at the following [link](CHANGELOG.md)
You can consult our changelog at the following [link](CHANGELOG.md)
9 changes: 7 additions & 2 deletions ontimize-jee-sdms-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.ontimize.jee.sdms</groupId>
<artifactId>ontimize-jee-sdms-common</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>
<packaging>jar</packaging>
<name>Ontimize EE SDMS (Common module)</name>
<description>Ontimize EE Storage DMS (SDMS) - Common module</description>
Expand All @@ -14,7 +14,7 @@
<parent>
<groupId>com.ontimize.jee.sdms</groupId>
<artifactId>ontimize-jee-sdms</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>
</parent>

<organization>
Expand Down Expand Up @@ -51,6 +51,11 @@
<artifactId>ontimize-jee-common</artifactId>
</dependency>

<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>

<!-- REFLECTIONS -->
<dependency>
<groupId>org.reflections</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public interface IOSdmsAction {
*/
EntityResult download( OSdmsRestDataDto data );

EntityResult getTemporalFiles( OSdmsRestDataDto data );

// ------------------------------------------------------------------------------------------------------------------ \\
// -------| DMS - UPLOAD |------------------------------------------------------------------------------------------- \\
// ------------------------------------------------------------------------------------------------------------------ \\
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.ontimize.jee.sdms.common.file;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Component
public class DefaultTemporalFileManager implements TemporalFileManager{

@Value( "${ontimize.sdms.file.temporal.directory}" )
private String temporalDirectory;

private static final ThreadLocal<List<File>> FILES = new ThreadLocal<>();

@Override
public File create( final String name, final InputStream inputStream ) throws IOException {
final File directory = new File( this.temporalDirectory );
final File file;
if( directory.exists() && directory.isDirectory() ) file = File.createTempFile( name, ".tmp", directory );
else file = File.createTempFile( name, ".tmp" );
try( FileOutputStream fos = new FileOutputStream( file )) {
inputStream.transferTo( fos );
}
if( FILES.get() == null ) FILES.set( new ArrayList<>() );
FILES.get().add( file );
return file;
}

@Override
public File create( final InputStream inputStream ) throws IOException {
return this.create( UUID.randomUUID().toString(), inputStream );
}

@Override
public void delete( final File file ) throws IOException {
if( FILES.get() == null ) return;
final Optional<File> result = FILES.get().stream()
.filter( target -> target.getAbsolutePath().equals( file.getAbsolutePath() ))
.findFirst();
if( result.isPresent() ){
final File target = result.get();
FILES.get().remove( target );
if( target.exists() ) Files.delete( target.toPath() );
}
}

@Override
public void cleanUp() throws IOException {
if( FILES.get() == null ) return;
for( final File file : FILES.get() ) if( file.exists() ) Files.delete( file.toPath() );
FILES.remove();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.ontimize.jee.sdms.common.file;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

public interface TemporalFileManager {

File create( InputStream inputStream ) throws IOException;
File create( String name, InputStream inputStream ) throws IOException;
void delete( File file ) throws IOException;
void cleanUp() throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.*;
import java.util.List;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -35,48 +33,44 @@ public class OSdmsZipCompressor implements IOSdmsZipCompressor {
@Override
public <T extends IOSdmsZippeable> OSdmsZipDto compress( final String zipName, final List<T> dataToZip ) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ZipOutputStream zos = new ZipOutputStream( baos );
final Set<OSdmsZipData> data = dataToZip.stream()
.map( IOSdmsZippeable::getDataToZip )
.filter( Objects::nonNull )
.collect( Collectors.toSet() );

for( final OSdmsZipData zipData : data ) {
final ZipEntry entry = new ZipEntry( zipData.getFileName() );
try {
zos.putNextEntry( entry );
final byte[] bytes = new byte[ 1024 ];
int length;
while( ( length = zipData.getInputStream().read( bytes ) ) >= 0 ) {
zos.write( bytes, 0, length );

try (ZipOutputStream zos = new ZipOutputStream(baos)) {
final Set<OSdmsZipData> data = dataToZip.stream()
.map(IOSdmsZippeable::getDataToZip)
.filter(Objects::nonNull)
.collect(Collectors.toSet());

for (final OSdmsZipData zipData : data) {
final ZipEntry entry = new ZipEntry(zipData.getFileName());
final File file = zipData.getFile();

if (file == null || !file.exists()) {
LOGGER.warn("File {} does not exist or is null, skipping", zipData.getFileName());
continue;
}
}
catch( final IOException e ) {
LOGGER.error( "Error compressing data to ZIP file: {}", e.getMessage() );
}
finally {
try {

try (InputStream inputStream = new FileInputStream(file)) {
zos.putNextEntry(entry);
byte[] buffer = new byte[4096];
int length;
while ((length = inputStream.read(buffer)) >= 0) {
zos.write(buffer, 0, length);
}
zos.closeEntry();
zipData.getInputStream().close();
}
catch( final IOException e ) {
LOGGER.error( "Error closing Resoources: {}", e.getMessage() );
} catch (IOException e) {
LOGGER.error("Error compressing file {}: {}", zipData.getFileName(), e.getMessage());
}
}
} catch (IOException e) {
LOGGER.error("Error creating ZIP output stream: {}", e.getMessage());
}

try {
zos.close();
}
catch( final IOException e ) {
LOGGER.error( "Error closing ZIP file: {}", e.getMessage() );
}

final ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() );
// Construir el DTO con el contenido del zip en memoria
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final OSdmsZipDto zipDto = new OSdmsZipDto();
zipDto.setFile( bais );
zipDto.setName( zipName );
zipDto.setSize( baos.size() );
zipDto.setFile(bais);
zipDto.setName(zipName);
zipDto.setSize(baos.size());

return zipDto;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ontimize.jee.sdms.common.zip;

import java.io.InputStream;
import java.io.File;
import java.util.Objects;


Expand All @@ -15,18 +15,18 @@ public class OSdmsZipData {
private String fileName;

/**
* The inputStream field represents the input stream to be zipped.
* The File field represents the file to be zipped.
*/
private InputStream inputStream;
private File file;

// ------------------------------------------------------------------------------------------------------------------ \\

public OSdmsZipData() {
}

public OSdmsZipData( final String fileName, final InputStream inputStream ) {
public OSdmsZipData( final String fileName, final File file ) {
this.setFileName( fileName );
this.setInputStream( inputStream );
this.setFile( file );
}

// ------------------------------------------------------------------------------------------------------------------ \\
Expand All @@ -41,12 +41,12 @@ public void setFileName( final String fileName ) {
this.fileName = fileName;
}

public InputStream getInputStream() {
return this.inputStream;
public File getFile() {
return this.file;
}

public void setInputStream( final InputStream inputStream ) {
this.inputStream = inputStream;
public void setFile( final File file ) {
this.file = file;
}

// ------------------------------------------------------------------------------------------------------------------ \\
Expand Down
4 changes: 2 additions & 2 deletions ontimize-jee-sdms-engine/ontimize-jee-sdms-engine-s3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.ontimize.jee.sdms</groupId>
<artifactId>ontimize-jee-sdms-engine-s3</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>
<packaging>jar</packaging>
<name>Ontimize EE SDMS (Engine S3 module)</name>
<description>Ontimize EE Storage DMS (SDMS) - Engine S3 module</description>
Expand All @@ -14,7 +14,7 @@
<parent>
<groupId>com.ontimize.jee.sdms</groupId>
<artifactId>ontimize-jee-sdms-engine</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>
</parent>

<organization>
Expand Down
Loading