parent
506d129cbc
commit
040b2c3817
|
@ -4,6 +4,13 @@
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [v6.35.2-SNAPSHOT] - 2022-07-27
|
||||||
|
|
||||||
|
#### Bug fixed
|
||||||
|
|
||||||
|
- [#23676] Fixed - Added extension .txt to ASC files when dowloaded
|
||||||
|
- [#23789] Fixed - Notebook files (.ipynb) are downloaded with .txt attached.
|
||||||
|
|
||||||
## [v6.35.1] - 2022-06-27
|
## [v6.35.1] - 2022-06-27
|
||||||
|
|
||||||
- [#23523] Updated to maven-portal-bom 3.6.4
|
- [#23523] Updated to maven-portal-bom 3.6.4
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>workspace-tree-widget</artifactId>
|
<artifactId>workspace-tree-widget</artifactId>
|
||||||
<version>6.35.1</version>
|
<version>6.35.2-SNAPSHOT</version>
|
||||||
<name>gCube Workspace Tree Widget</name>
|
<name>gCube Workspace Tree Widget</name>
|
||||||
<description>
|
<description>
|
||||||
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
|
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>maven-portal-bom</artifactId>
|
<artifactId>maven-portal-bom</artifactId>
|
||||||
<version>3.6.4</version>
|
<version>3.7.0-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.tika.mime.MediaType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
// TODO: Auto-generated Javadoc
|
||||||
/**
|
/**
|
||||||
* The Class MimeTypeUtil.
|
* The Class MimeTypeUtil.
|
||||||
|
@ -120,7 +119,6 @@ public class MimeTypeUtility {
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load preview mime types.
|
* Load preview mime types.
|
||||||
|
@ -169,7 +167,6 @@ public class MimeTypeUtility {
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String getNameWithExtension(String name, String mimeType) throws IOException {
|
public static String getNameWithExtension(String name, String mimeType) throws IOException {
|
||||||
|
|
||||||
logger.debug("Deriving the file extension for file name: " + name + ", with mimeType: " + mimeType);
|
logger.debug("Deriving the file extension for file name: " + name + ", with mimeType: " + mimeType);
|
||||||
|
|
||||||
if (mimeType == null || mimeType.isEmpty()) {
|
if (mimeType == null || mimeType.isEmpty()) {
|
||||||
|
@ -178,52 +175,29 @@ public class MimeTypeUtility {
|
||||||
}
|
}
|
||||||
|
|
||||||
String declaredExtension = FilenameUtils.getExtension(name);
|
String declaredExtension = FilenameUtils.getExtension(name);
|
||||||
logger.debug("The name " + name + " contains the extension: " + declaredExtension);
|
logger.info("The name " + name + " contains the extension: " + declaredExtension);
|
||||||
|
|
||||||
if (declaredExtension.equals("exe"))
|
if (declaredExtension != null && !declaredExtension.isEmpty()) {
|
||||||
|
logger.debug(
|
||||||
|
"The name contains a not empty extension: " + declaredExtension + ", so returning the name like it is");
|
||||||
return name;
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("The name does not contains the extension, deriving it from mimeType");
|
||||||
List<String> extensions = MimeTypeUtility.getExtension(mimeType);
|
List<String> extensions = MimeTypeUtility.getExtension(mimeType);
|
||||||
logger.trace("Extension/s available for input mimetype: " + mimeType + " into map is/are: " + extensions);
|
logger.debug("Extension/s available for input mimetype: " + mimeType + " into map is/are: " + extensions);
|
||||||
|
|
||||||
String toMimeTypeExtension = "";
|
String toMimeTypeExtension = "";
|
||||||
if (extensions != null) {
|
String fullName = name;
|
||||||
toMimeTypeExtension = extensions.get(extensions.size() - 1); // I'm reading the last extension in the map
|
if (extensions != null && extensions.size() > 0) {
|
||||||
// (myme type - list of extensions)
|
// I'm reading the last extension in the map (myme type - list of extensions)
|
||||||
logger.debug("Using the last extension read into list of available extensions: " + toMimeTypeExtension);
|
toMimeTypeExtension = extensions.get(extensions.size() - 1);
|
||||||
|
logger.info("Using the last extension read into list of available extensions: " + toMimeTypeExtension);
|
||||||
|
fullName = String.format("%s%s%s", name, DOT_STRING, toMimeTypeExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MANAGING ALREADY DECLARED EXTENSION IN THE FILE NAME
|
logger.info("returning full name:" + fullName);
|
||||||
if (!declaredExtension.isEmpty() && !toMimeTypeExtension.isEmpty()) {
|
return fullName;
|
||||||
String dEextL = declaredExtension.toLowerCase();
|
|
||||||
String mtExtL = toMimeTypeExtension.toLowerCase();
|
|
||||||
|
|
||||||
// The extension writes in the file name is matching the mime type extension
|
|
||||||
// declared in the map
|
|
||||||
if (dEextL.equals(mtExtL)) {
|
|
||||||
logger.trace("The Extension declared in the name " + name
|
|
||||||
+ " is matching derived mime type extension so returning the input name: " + name);
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if(!dEextL.trim().contains(" ")) {
|
|
||||||
// logger.trace("The Extension declared in the name "+name+" seems a valid suffix (without other spaces) so returning the input name: "+name);
|
|
||||||
// return name;
|
|
||||||
// }
|
|
||||||
|
|
||||||
logger.debug("No logic seems to match the extension declared in the name " + declaredExtension
|
|
||||||
+ " as a valid extension so I'm adding the extension derived from mime type map: "
|
|
||||||
+ toMimeTypeExtension);
|
|
||||||
}
|
|
||||||
|
|
||||||
// CHECKING THE FOLLOWING IN ORDER TO AVOID THE DOT AS LAST CHAR OF FILENAME
|
|
||||||
if (toMimeTypeExtension.isEmpty()) {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
String fullname = String.format("%s%s%s", name, DOT_STRING, toMimeTypeExtension);
|
|
||||||
logger.trace("returning full name:" + fullname);
|
|
||||||
return fullname;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,11 +288,10 @@ public class MimeTypeUtility {
|
||||||
public static Map<String, String> getExtensionToMimeTypeMap() {
|
public static Map<String, String> getExtensionToMimeTypeMap() {
|
||||||
return extension_mimetype_map;
|
return extension_mimetype_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the preview mimetype extension map with the
|
* Gets the preview mimetype extension map with the mime types allowed for
|
||||||
* mime types allowed for preview displaying
|
* preview displaying
|
||||||
*
|
*
|
||||||
* @return the preview mimetype extension map
|
* @return the preview mimetype extension map
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -181,6 +181,7 @@ text/iuls=uls
|
||||||
text/plain=bas
|
text/plain=bas
|
||||||
text/plain=c
|
text/plain=c
|
||||||
text/plain=h
|
text/plain=h
|
||||||
|
text/plain=asc
|
||||||
text/plain=txt
|
text/plain=txt
|
||||||
text/richtext=rtx
|
text/richtext=rtx
|
||||||
text/scriptlet=sct
|
text/scriptlet=sct
|
||||||
|
|
|
@ -149,6 +149,7 @@ text/iuls=uls
|
||||||
text/plain=bas
|
text/plain=bas
|
||||||
text/plain=c
|
text/plain=c
|
||||||
text/plain=h
|
text/plain=h
|
||||||
|
text/plain=asc
|
||||||
text/plain=txt
|
text/plain=txt
|
||||||
text/richtext=rtx
|
text/richtext=rtx
|
||||||
text/scriptlet=sct
|
text/scriptlet=sct
|
||||||
|
|
Loading…
Reference in New Issue