Included the file size to reduce/optimize the time to upload files to
the storage hub [#28150]
This commit is contained in:
parent
93ae600b30
commit
0808d1e12c
|
@ -1,5 +1,9 @@
|
||||||
# Changelog for org.gcube.application.cms-plugin-framework
|
# Changelog for org.gcube.application.cms-plugin-framework
|
||||||
|
|
||||||
|
## [v1.0.6-SNAPSHOT] - 2024-10-01
|
||||||
|
|
||||||
|
- Included the file size to reduce/optimize the time to upload files to the storage hub [#28150]
|
||||||
|
|
||||||
## [v1.0.5] - 2024-07-03
|
## [v1.0.5] - 2024-07-03
|
||||||
|
|
||||||
- Implemented Event Broker [#26321]
|
- Implemented Event Broker [#26321]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>cms-plugin-framework</artifactId>
|
<artifactId>cms-plugin-framework</artifactId>
|
||||||
<version>1.0.5</version>
|
<version>1.0.6-SNAPSHOT</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.gcube.application.cms</groupId>
|
<groupId>org.gcube.application.cms</groupId>
|
||||||
|
|
|
@ -52,6 +52,8 @@ public class WorkspaceManager {
|
||||||
|
|
||||||
private String fileDescription;
|
private String fileDescription;
|
||||||
private FolderContainer parent;
|
private FolderContainer parent;
|
||||||
|
//Added by Francesco, see #28150
|
||||||
|
private Long size;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +179,14 @@ public class WorkspaceManager {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private static FileContainer createFileRoutine(FileOptions opts) throws StorageHubException {
|
private static FileContainer createFileRoutine(FileOptions opts) throws StorageHubException {
|
||||||
|
// Updated by Francesco, see #28150
|
||||||
|
log.debug("Uploading file name: {}, in the parent folder id: {}, filesize is: {}", opts.getFileName(),
|
||||||
|
opts.getParent().getId(), opts.getSize());
|
||||||
opts.setFileName(Files.fixFilename(opts.getFileName()));
|
opts.setFileName(Files.fixFilename(opts.getFileName()));
|
||||||
return opts.getParent().uploadFile(opts.getIs(), opts.getFileName(), opts.getFileDescription());
|
if (opts.getSize() == null)
|
||||||
|
return opts.getParent().uploadFile(opts.getIs(), opts.getFileName(), opts.getFileDescription());
|
||||||
|
else
|
||||||
|
return opts.getParent().uploadFile(opts.getIs(), opts.getFileName(), opts.getFileDescription(),
|
||||||
|
opts.getSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# Changelog for org.gcube.application.geoportal-common
|
# Changelog for org.gcube.application.geoportal-common
|
||||||
|
|
||||||
|
## [v1.1.1-SNAPSHOT] - 2024-10-01
|
||||||
|
- Included the file size to reduce/optimize the time to upload files to the storage hub [#28150]
|
||||||
|
|
||||||
## [v1.1.0] - 2024-04-08
|
## [v1.1.0] - 2024-04-08
|
||||||
- Added message to StepExecutionRequest [#27192]
|
- Added message to StepExecutionRequest [#27192]
|
||||||
- Fixed pom. Duplicate declaration of `registry-publisher` dependency
|
- Fixed pom. Duplicate declaration of `registry-publisher` dependency
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>geoportal-common</artifactId>
|
<artifactId>geoportal-common</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<name>Geoportal Common</name>
|
<name>Geoportal Common</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|
|
@ -15,8 +15,20 @@ public class TempFile {
|
||||||
private String url;
|
private String url;
|
||||||
private String filename;
|
private String filename;
|
||||||
|
|
||||||
public void validate()throws InvalidRequestException {
|
// Added by Francesco, see #28150
|
||||||
if((id==null || id.isEmpty() )&&(url==null||url.isEmpty())) throw new InvalidRequestException("Invalid temp file "+this+" : ID null or empty and no url defined");
|
private Long size;
|
||||||
if(filename==null || filename.isEmpty()) throw new InvalidRequestException("Invalid temp file "+this+" : filename null or empty");
|
|
||||||
|
public void validate() throws InvalidRequestException {
|
||||||
|
if ((id == null || id.isEmpty()) && (url == null || url.isEmpty()))
|
||||||
|
throw new InvalidRequestException("Invalid temp file " + this + " : ID null or empty and no url defined");
|
||||||
|
if (filename == null || filename.isEmpty())
|
||||||
|
throw new InvalidRequestException("Invalid temp file " + this + " : filename null or empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TempFile(String id, String url, String filename) {
|
||||||
|
this.id = id;
|
||||||
|
this.url = url;
|
||||||
|
this.filename = filename;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,12 @@ public class FileSets {
|
||||||
|
|
||||||
FileSets.RequestBuilder builder = FileSets.build(parentPath,fieldName,fieldDefinition);
|
FileSets.RequestBuilder builder = FileSets.build(parentPath,fieldName,fieldDefinition);
|
||||||
for (File f : toUpload) {
|
for (File f : toUpload) {
|
||||||
if(!f.isDirectory())
|
if(!f.isDirectory()) {
|
||||||
builder.add(FileSets.asTemp(storage, new InputStreamDescriptor(new FileInputStream(f), f.getName())));
|
TempFile file = FileSets.asTemp(storage, new InputStreamDescriptor(new FileInputStream(f), f.getName()));
|
||||||
|
//Added by Francesco, see #28150
|
||||||
|
file.setSize(f.length());
|
||||||
|
builder.add(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return builder.getTheRequest();
|
return builder.getTheRequest();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1562,7 +1562,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
||||||
else
|
else
|
||||||
fileUrl = storage.getURL(f.getId());
|
fileUrl = storage.getURL(f.getId());
|
||||||
|
|
||||||
log.info("Got URL {} from ID {}", fileUrl, f.getId());
|
log.info("Got URL {} from ID {}, filesize {}", fileUrl, f.getId(), f.getSize());
|
||||||
is = new URL(fileUrl).openStream();
|
is = new URL(fileUrl).openStream();
|
||||||
RegisteredFile registered = ws.registerFile(new WorkspaceManager.FileOptions(f.getFilename(), is,
|
RegisteredFile registered = ws.registerFile(new WorkspaceManager.FileOptions(f.getFilename(), is,
|
||||||
"Imported via gcube CMS service ", sectionFolder));
|
"Imported via gcube CMS service ", sectionFolder));
|
||||||
|
|
Loading…
Reference in New Issue