Releases: Coreoz/Plume-file
4.0.0-beta1
Changelog
- Upgrade to Plume 5.0.0-beta1 with Jakarta and JUnit 5, see Plume 5.0.0-beta1 release notes for details
v3.1.0
Changelog
Plume File v3.1.0 brings changes for the module Plume File Upload:
- (cca1e71) A new way of handling file upload using Apache Commons FileUpload Streaming
- (98711a5) Adding a new
FileUploadValidator
validation on the file original name, adding more flexibility on the file name handling
Migration Guide
Althought there is no breaking changes in this new version, the FileUploadFinisher
finish()
method is now deprecated, and will be deleted in future version.
It is replaced by the finish()
method of FileUploadDataBuilder
, only accessible after validating the original file name with one of FileUploadFinisher
method:
- keepOriginalFileName
- sanitizeFileName
- changeFileName
v3.0.2
Changelog
This release contains:
- (d28eb46) Plume File Core: fix
MeasuredSizeInputStream
for file size computing. It is now extending FilterInputStream.
v3.0.1
Changelog
This release contains:
- (91f30ef) Plume File Core: fix
MeasuredSizeInputStream
for file size computing. In the previous version, the size was wrongly multiplied by 2
Upgrade instructions
- In order to have accurate file sizes, you will have to divide each previously computed sizes by 2 in the table plm_file, column file_size
v3.0.0
Changelog
Plume File v3 introduces breaking changes that require manually updating the codebase and the database of an existing project.
Plume File v3 uses what was introduced in the v2.0.0-beta5 version, which is the file name generation.
This technique prevents :
- Database ID auto-increment generation to reference a file, fixing a security issue
- Files to be override on the system disk if they have the same name
Migrate to V3 involves:
- Identifying the migration :
- Which Plume File Version is currently running
- Where does the files are currently stored (if migrating from >= v2)
- Updating the library version and import the right modules
- Running the SQL migration(s) script(s)
- SQL migration guide here
- Updating the code base
Upgrade instructions from v1.0.0-rc1 ~ v1.0.0-rc9
The first version of Plume File:
- Only stored files on database
- There were no unique names stored in the metadata for files
- The file download was included in the library
Modules needed :
- plume-file-core module
- plume-file-metadata-database module
- plume-file-storage-database module
- plume-file-web-download-jersey module (Optional, only if you use the download part)
Upgrade instructions from v2.0.0-alpha1 ~ v2.0.0-beta5
These version of Plume File:
- Stored files either on database or on the system disk
- There were unique names stored in the metadata only for the v2.0.0-beta5 version
- The file download was included in the library
If files were stored on database :
- plume-file-core module
- plume-file-metadata-database module
- plume-file-storage-database module
- plume-file-web-download-jersey module (Optional, only if the download part was used)
If your files were stored on the system disk :
- plume-file-core module
- plume-file-metadata-database module
- plume-file-storage-system module
- plume-file-web-download-jersey module (Optional, only if the download part was used)
Warning : The SQL script migration is different on the v2.0.0-beta5 as it does not include file unique name generation
If the plm_file.id
column was referenced in multiple other tables
This behavior is not supported anymore for maintenance reasons.
So in that case, these scripts might be useful to duplicated the files (this must be run after the migration to Plume File V3 has been completed):
public List<FileMetadataQuerydsl> fetchFilesByFileType(String fileType, EntityPath<?> fileEntity, StringPath column) {
return projectTransactionManager.executeAndReturn(connection -> projectTransactionManager
.selectQuery(connection)
.select(QFileMetadataQuerydsl.fileMetadata)
.from(QFileMetadataQuerydsl.fileMetadata)
.where(QFileMetadataQuerydsl.fileMetadata.fileType.eq(fileType))
.where(QFileMetadataQuerydsl.fileMetadata.uniqueName.in(
SQLExpressions
.select(column)
.from(fileEntity)
.where(column.isNotNull())
))
.fetch());
}
public void updateFileReference(RelationalPath<?> fileEntity, StringPath column, String oldUid, String newUid) {
projectTransactionManager.execute(connection -> projectTransactionManager
.update(fileEntity, connection)
.set(column, newUid)
.where(column.eq(oldUid))
.execute()
);
}
public void migrateFilesToPlm3() {
logger.info("Starting file migration from Plume-file 2.0 to 3.0");
for (FileTypeDatabase fileType : fileTypesProvider.fileTypesAvailable()) {
for (FileMetadataQuerydsl file : fileDaoDisk.fetchFilesByFileType(fileType.name(), fileType.getFileEntity(), fileType.getJoinColumn())) {
try {
// The original name is used to retrieve the data, because it was used by PLM-File 2.0 to save the file.
InputStream fileData = this.fileService.fetchData(file.getFileOriginalName()).orElse(null);
if (fileData == null) {
logger.warn("Failed to read file {}, skipping : {}", file.getUniqueName(), file);
continue;
}
String newFileUniqueName = this.fileService.add(fileType, fileData, file.getFileOriginalName());
this.fileDaoDisk.updateFileReference((RelationalPath<?>) fileType.getFileEntity(), fileType.getJoinColumn(), file.getUniqueName(), newFileUniqueName);
} catch (UncheckedIOException e) {
logger.warn("Failed to read file {}, skipping : {}", file.getUniqueName(), file, e);
}
}
}
}
}