In progess on SHUB migration

task/18920
Francesco Mangiacrapa 4 years ago
parent 40c24e29c5
commit 3109a73acc

@ -17,6 +17,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>

@ -0,0 +1,6 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francesco/git/workspace-explorer-app/target/workspace-explorer-app-1.3.0-SNAPSHOT
launchConfigExternalUrlPrefix=
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

@ -0,0 +1,3 @@
eclipse.preferences.version=1
entryPointModules=
gwtSyncCodeServer=true

@ -4,6 +4,7 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
<property name="context-root" value="workspace-explorer-app"/>
<property name="java-output-path" value="/workspace-explorer-app/target/workspace-explorer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
</wb-module>

@ -3,4 +3,5 @@
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="2.5"/>
<installed facet="jst.jaxrs" version="2.0"/>
<installed facet="com.gwtplugins.gwt.facet" version="1.0"/>
</faceted-project>

@ -1,27 +1,39 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.workspace-explorer-app.1-2-0"
<Changeset
component="org.gcube.portlets-user.workspace-explorer-app.1-3-0"
date="2020-04-14">
<Change>[Task #18920] Migrated to SHUB
</Change>
</Changeset>
<Changeset
component="org.gcube.portlets-user.workspace-explorer-app.1-2-0"
date="2018-03-07">
<Change>[Feature #11374] Download items with double click
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.workspace-explorer-app.1-1-0"
<Changeset
component="org.gcube.portlets-user.workspace-explorer-app.1-1-0"
date="2017-10-11">
<Change>[Feature #9926] read the scope from environment variable
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.workspace-explorer-app.1-0-2"
<Changeset
component="org.gcube.portlets-user.workspace-explorer-app.1-0-2"
date="2017-10-10">
<Change>Removed markAsRead method. It is performed by HL</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.workspace-explorer-app.1-0-1"
<Changeset
component="org.gcube.portlets-user.workspace-explorer-app.1-0-1"
date="2017-07-03">
<Change>[Task #9104] removed log4j.properties file</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.workspace-explorer-app.1-0-0-1"
<Changeset
component="org.gcube.portlets-user.workspace-explorer-app.1-0-0-1"
date="2016-11-10">
<Change>Incident #5722: fixed</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.workspace-explorer-app.1-0-0"
<Changeset
component="org.gcube.portlets-user.workspace-explorer-app.1-0-0"
date="2016-09-13">
<Change>first release</Change>
</Changeset>

@ -59,6 +59,13 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
@ -114,33 +121,14 @@
<!-- END FWS -->
<!-- HOME LIBRARY -->
<!-- <dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-model</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId>
<version>[2.5.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<exclusions>
<exclusion>
<artifactId>asm-debug-all</artifactId>
<groupId>org.ow2.asm</groupId>
</exclusion>
</exclusions>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>1.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<version>[2.5.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<exclusions>
<exclusion>
<artifactId>asm-all</artifactId>
<groupId>asm</groupId>
</exclusion>
</exclusions>
</dependency>-->
<dependency>
<groupId>org.gcube.common</groupId>
@ -156,6 +144,12 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
@ -211,6 +205,14 @@
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
<plugins>

@ -130,18 +130,18 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
@Override
public void onClick(final ClickItemEvent clickItemEvent) {
isSelect = false;
Set<Item> items = wsExplorer.getItemsSelected();
List<Item> lstItems = toList(items);
//Return if item is not selectable
if(!itemIsSelectable(lstItems.get(0))){
notifyNotValidSelection();
return;
}
notifySelectedItem(lstItems.get(0));
isSelect = true;
// isSelect = false;
// Set<Item> items = wsExplorer.getItemsSelected();
// List<Item> lstItems = toList(items);
//
// //Return if item is not selectable
// if(!itemIsSelectable(lstItems.get(0))){
// notifyNotValidSelection();
// return;
// }
//
// notifySelectedItem(lstItems.get(0));
// isSelect = true;
}
});
@ -149,6 +149,8 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
@Override
public void onLoadFolder(LoadFolderEvent loadFolderEvent) {
GWT.log("LoadFolderEvent fired");
if(loadFolderEvent.getTargetFolder()==null)
return;
@ -243,8 +245,8 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
Window.alert("Sorry, an error occurred while contacting server, try again");
}
break;
case PREVIEW:
break;
// case PREVIEW:
// break;
case OPEN:
MaterialToast.fireToast("Showing...");
try {

@ -12,7 +12,7 @@ package org.gcube.portlets.user.workspaceexplorerapp.client.download;
*/
public enum DownloadType {
PREVIEW,
//PREVIEW,
OPEN,
DOWNLOAD;
}

@ -3,6 +3,7 @@
*/
package org.gcube.portlets.user.workspaceexplorerapp.server;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@ -21,20 +22,23 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalUrl;
import org.gcube.common.homelibrary.home.workspace.folder.items.Report;
import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate;
import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeries;
import org.gcube.common.homelibrary.util.Extensions;
import org.gcube.common.homelibrary.util.MimeTypeUtil;
import org.gcube.common.homelibrary.util.zip.ZipUtil;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.GCubeItem;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.ImageFile;
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.items.ImageFileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.items.ItemStreamDescriptor;
import org.gcube.common.storagehubwrapper.shared.tohl.items.PDFFileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.items.URLFileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.items.URLItem;
import org.gcube.portlets.user.workspaceexplorerapp.client.WorkspaceExplorerAppConstants;
import org.gcube.portlets.user.workspaceexplorerapp.server.workspace.AllowedMimeTypeToInline;
import org.gcube.portlets.user.workspaceexplorerapp.server.workspace.MimeTypeUtility;
import org.gcube.portlets.user.workspaceexplorerapp.server.workspace.WsUtil;
import org.gcube.portlets.user.workspaceexplorerapp.shared.HandlerResultMessage;
@ -115,21 +119,22 @@ public class DownloadWorkspaceExplorerServlet extends HttpServlet{
if(ids.size()>1){
List<WorkspaceItem> listWI = toWorkspaceItems(wa, ids);
try {
File tmpZip = ZipUtil.zipWorkspaceItems(listWI, null);
resp.setHeader( "Content-Disposition", "attachment; filename=\"gCube Workspace Files - " + new Date() +".zip\"" );
resp.setContentType("application/zip");
resp = setContentLength(resp, tmpZip.length());
OutputStream out = resp.getOutputStream();
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
IOUtils.copy(fileTmpZip, resp.getOutputStream());
fileTmpZip.close();
out.close();
tmpZip.delete();
//TODO MUST BE IMPLEMENTED
// File tmpZip = ZipUtil.zipWorkspaceItems(listWI, null);
// resp.setHeader( "Content-Disposition", "attachment; filename=\"gCube Workspace Files - " + new Date() +".zip\"" );
// resp.setContentType("application/zip");
// resp = setContentLength(resp, tmpZip.length());
// OutputStream out = resp.getOutputStream();
//
// FileInputStream fileTmpZip = new FileInputStream(tmpZip);
// IOUtils.copy(fileTmpZip, resp.getOutputStream());
// fileTmpZip.close();
//
// out.close();
// tmpZip.delete();
return;
}
catch (InternalErrorException e) {
catch (Exception e) {
logger.error("Error during folder compression "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder compression: "+e.getMessage());
return;
@ -157,304 +162,278 @@ public class DownloadWorkspaceExplorerServlet extends HttpServlet{
return;
}
String itemId = item.getId();
String versionID = null;
switch (item.getType()) {
case SHARED_FOLDER:
case FOLDER:{
try {
File tmpZip = ZipUtil.zipFolder((WorkspaceFolder) item);
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + item.getName() + ".zip\"" );
resp.setContentType("application/zip");
resp = setContentLength(resp, tmpZip.length());
case URL_ITEM: {
try{
logger.info("Downloading "+item.getType());
String urlValue = "URL not found";
if(item instanceof URLItem) {
URLItem theURL = (URLItem) item;
urlValue = theURL.getValue()==null?"URL not found":theURL.getValue().toString();
}
StringBuilder build = new StringBuilder();
build.append("#URL downloaded from D4Science, source filename: "+item.getName());
build.append("\n");
build.append(urlValue);
String fileContent = build.toString();
logger.info("Writing file content: \n"+fileContent);
ByteArrayInputStream is = new ByteArrayInputStream(fileContent.getBytes());
String contentDisposition = viewContent?"inline":"attachment";
String urlMimeType = "text/uri-list";
String itemName = MimeTypeUtility.getNameWithExtension(item.getName(), urlMimeType);
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(urlMimeType);
OutputStream out = resp.getOutputStream();
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
IOUtils.copy(fileTmpZip, resp.getOutputStream());
fileTmpZip.close();
IOUtils.copy(is, out);
is.close();
out.close();
tmpZip.delete();
return;
} catch (Exception e) {
logger.error("Error during folder compression "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder compression: "+e.getMessage());
}catch (Exception e) {
logger.error("Error during downloading the item "+itemId,e);
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data downloading: "+e.getMessage());
return;
}
}
case FOLDER_ITEM:{
FolderItem folderItem = (FolderItem) item;
switch (folderItem.getFolderItemType()) {
case REPORT_TEMPLATE:{
try{
ReportTemplate reportTemplate = (ReportTemplate)folderItem;
String extension = FilenameUtils.getExtension(item.getName());
String itemName = item.getName();
logger.trace("case REPORT_TEMPLATE extension is" +extension);
if(extension.compareToIgnoreCase(Extensions.REPORT_TEMPLATE.getName())!=0) //ADD EXTENSION?
itemName = "." + Extensions.REPORT_TEMPLATE.getName();
case FOLDER:
case SHARED_FOLDER:
case VRE_FOLDER:
case SMART_FOLDER: {
logger.trace("case REPORT_TEMPLATE itemName is" +extension);
String contentDisposition = viewContent?"inline":"attachment";
resp.setHeader( "Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
WorkspaceFolder workspaceFolder = (WorkspaceFolder) item;
ItemStreamDescriptor descr;
try {
descr = wa.downloadFolder(workspaceFolder.getId(), workspaceFolder.getName(), null);
}
catch (Exception e) {
logger.error("Error on downloading the folder with id "+itemId, e);
String error = e.getMessage()!=null?e.getMessage():"The folder is not available for downloading";
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": "+error);
return;
}
resp.setContentType("application/zip");
resp = setContentLength(resp, reportTemplate.getLength());
OutputStream out = resp.getOutputStream();
try{
//MODIFIED 22-05-2013 CLOSE STREAM
InputStream is = reportTemplate.getData();
IOUtils.copy(is, resp.getOutputStream());
is.close();
logger.info("Downloading the folder: "+workspaceFolder);
String contentDisposition = viewContent?"inline":"attachment";
String mimeType = "application/zip";
String itemName = MimeTypeUtility.getNameWithExtension(item.getName(), mimeType);
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(mimeType);
out.close();
} catch (Exception e) {
logger.error("Error during external item sending "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
return;
}
return;
OutputStream out = resp.getOutputStream();
InputStream is = descr.getStream();
IOUtils.copy(is, out);
}
case REPORT:{
try{
Report report = (Report)folderItem;
String extension = FilenameUtils.getExtension(item.getName());
String itemName = item.getName();
logger.trace("case REPORT extension is" +extension);
is.close();
out.close();
return;
} catch (Exception e) {
logger.error("Error during item downloading "+itemId,e);
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder data retrieving: "+e.getMessage());
return;
}
if(extension.compareToIgnoreCase(Extensions.REPORT.getName())!=0) //ADD EXTENSION?
itemName = "." + Extensions.REPORT.getName();
}
case FILE_ITEM:{
logger.trace("case REPORT itemName is" +extension);
String contentDisposition = viewContent?"inline":"attachment";
resp.setHeader( "Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
FileItem workspaceFileItem = (FileItem) item;
ItemStreamDescriptor descr;
try {
logger.info("Downloading the file id: "+workspaceFileItem.getId()+" with name: "+workspaceFileItem.getName()+" and versionID: "+versionID);
descr = wa.downloadFile(workspaceFileItem.getId(), workspaceFileItem.getName(), versionID, null);
}
catch (Exception e1) {
logger.error("Error on downloading the file with id "+itemId, e1);
String error = e1.getMessage()!=null?e1.getMessage():"The file is not available for downloading";
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": "+error);
return;
}
resp.setContentType("application/zip");
resp = setContentLength(resp, report.getLength());
OutputStream out = resp.getOutputStream();
switch (workspaceFileItem.getFileItemType()) {
//MODIFIED 22-05-2013 CLOSE STREAM
InputStream is = report.getData();
IOUtils.copy(is, resp.getOutputStream());
is.close();
case PDF_DOCUMENT:{
out.close();
} catch (Exception e) {
logger.error("Error during external item sending "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
return;
}
return;
}
case EXTERNAL_PDF_FILE:
case EXTERNAL_FILE:{
InputStream is = null;
OutputStream out = null;
try{
ExternalFile externalFile = (ExternalFile)folderItem;
String mimeType = externalFile.getMimeType();
logger.trace("EXTERNAL_FILE DOWNLOAD FOR "+externalFile.getId());
PDFFileItem pdfFile = (PDFFileItem) workspaceFileItem;
logger.info("Downloading: "+pdfFile);
String mimeType = pdfFile.getMimeType();
logger.trace("EXTERNAL_FILE DOWNLOAD FOR "+pdfFile.getId());
String contentDisposition = viewContent?"inline":"attachment";
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + item.getName() + "\"" );
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), mimeType);
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(mimeType);
resp = setContentLength(resp, externalFile.getLength());
is = externalFile.getData();
out = resp.getOutputStream();
//Fixing Incident: 18926, replacing pdfFile.getSize() with ItemStreamDescriptor.getSize()
if(descr.getSize()!=null && descr.getSize()>0) {
resp = setContentLength(resp, descr.getSize());
}
logger.info("The "+workspaceFileItem.getFileItemType()+" size is: "+descr.getSize());
//resp = setContentLength(resp, pdfFile.getSize());
InputStream is = descr.getStream();
OutputStream out = resp.getOutputStream();
IOUtils.copy(is, out);
is.close();
out.close();
} catch (Exception e) {
logger.error("Error during external item retrieving "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
logger.error("Error during external item retrieving "+itemId,e);
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
return;
}
return;
}
case EXTERNAL_IMAGE:{
case IMAGE_DOCUMENT:{
try{
ExternalImage externalImage = (ExternalImage)folderItem;
String mimeType = externalImage.getMimeType();
String itemName = MimeTypeUtil.getNameWithExtension(item.getName(), mimeType);
ImageFileItem imageFile = (ImageFileItem) workspaceFileItem;
logger.info("Downloading: "+imageFile);
String mimeType = imageFile.getMimeType();
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), mimeType);
String contentDisposition = viewContent?"inline":"attachment";
resp.setHeader( "Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(externalImage.getMimeType());
resp = setContentLength(resp, externalImage.getLength());
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(mimeType);
//Fixing Incident: 18926, replacing imageFile.getSize() with ItemStreamDescriptor.getSize()
if(descr.getSize()!=null && descr.getSize()>0) {
resp = setContentLength(resp, descr.getSize());
}
logger.info("The "+workspaceFileItem.getFileItemType()+" size is: "+descr.getSize());
//resp = setContentLength(resp, imageFile.getSize());
InputStream is = descr.getStream();
OutputStream out = resp.getOutputStream();
InputStream is = externalImage.getData();
IOUtils.copy(is, out);
is.close();
is.close();
out.close();
return;
} catch (Exception e) {
logger.error("Error during item retrieving "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
logger.error("Error during item retrieving "+itemId,e);
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
return;
}
}
case EXTERNAL_URL:{
case URL_DOCUMENT:{
try{
ExternalUrl externalUrl = (ExternalUrl)folderItem;
String itemName = MimeTypeUtil.getNameWithExtension(externalUrl.getName(), "text/uri-list");
URLFileItem externalUrl = (URLFileItem) workspaceFileItem;
logger.info("Downloading: "+externalUrl);
String urlMimeType = "text/uri-list";
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), urlMimeType);
String contentDisposition = viewContent?"inline":"attachment";
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType("text/uri-list");
resp = setContentLength(resp, externalUrl.getLength());
resp.setContentType(urlMimeType);
//resp = setContentLength(resp, externalUrl.getSize());
//MODIFIED 22-05-2013 CLOSE STREAM
StringReader sr = new StringReader(externalUrl.getUrl());
OutputStream out = resp.getOutputStream();
IOUtils.copy(sr, out);
InputStream is = descr.getStream();
IOUtils.copy(descr.getStream(), out);
sr.close();
is.close();
out.close();
return;
} catch (Exception e) {
logger.error("Error during item retrieving "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
logger.error("Error during item retrieving "+itemId,e);
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
return;
}
}
case QUERY:{
Query query = (Query)folderItem;
resp.setContentType("text/plain");
try {
resp = setContentLength(resp, query.getLength());
} catch (Exception e) {
logger.error("Error getting item lenght "+query,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
return;
}
//MODIFIED 22-05-2013 CLOSE STREAM
OutputStream out = resp.getOutputStream();
StringReader sr = new StringReader(query.getQuery());
IOUtils.copy(sr, out);
sr.close();
out.close();
return;
}
case TIME_SERIES:{
case GCUBE_ITEM:{
try{
TimeSeries ts = (TimeSeries)folderItem;
File tmpZip = ZipUtil.zipTimeSeries(ts);
// Document document = (Document)item;
org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem gcubeItem = (org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem) item; //Cast GCubeItem
logger.info("Downloading: "+gcubeItem);
String mimeType = "text/plain";
String contentDisposition = viewContent?"inline":"attachment";
resp.setHeader( "Content-Disposition", contentDisposition+"; filename=\"" + item.getName() + ".zip\"" );
resp.setContentType("application/zip");
resp = setContentLength(resp, tmpZip.length());
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + gcubeItem.getName() + ".txt\"" );
resp.setContentType(mimeType);
//MODIFIED 22-05-2013 CLOSE STREAM
OutputStream out = resp.getOutputStream();
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
IOUtils.copy(fileTmpZip, out);
fileTmpZip.close();
InputStream is = descr.getStream();
IOUtils.copy(is, out);
is.close();
out.close();
tmpZip.delete();
return;
} catch (Exception e) {
logger.error("Error during item retrieving "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
return;
}
}
case IMAGE_DOCUMENT:
case PDF_DOCUMENT:
case URL_DOCUMENT:
case DOCUMENT:{
try{
// Document document = (Document)item;
GCubeItem document = (GCubeItem) item; //Cast GCubeItem
if (!viewContent){
File tmpZip = ZipUtil.zipDocument(document);
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + item.getName() + ".zip\"" );
resp.setContentType("application/zip");
resp = setContentLength(resp, tmpZip.length());
//MODIFIED 22-05-2013 CLOSE STREAM
OutputStream out = resp.getOutputStream();
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
IOUtils.copy(fileTmpZip, out);
fileTmpZip.close();
out.close();
tmpZip.delete();
}
else{
String mimeType = document.getMimeType();
String itemName = MimeTypeUtil.getNameWithExtension(item.getName(), mimeType);
resp.setHeader( "Content-Disposition", "inline; filename=\"" + itemName + "\"" );
resp.setContentType(document.getMimeType());
resp = setContentLength(resp, document.getLength());
//MODIFIED 22-05-2013 CLOSE STREAM
OutputStream out = resp.getOutputStream();
InputStream is = document.getData();
IOUtils.copy(is, out);
is.close();
out.close();
}
return;
} catch (Exception e) {
logger.error("Error during item retrieving "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
logger.error("Error during item retrieving "+itemId,e);
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
return;
}
}
default:{
case METADATA:{
try{
// Metadata document = (Metadata)item;
GCubeItem metadata = (GCubeItem) item; //Cast GCubeItem
resp.setContentType("text/html");
resp = setContentLength(resp, metadata.getLength());
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), workspaceFileItem.getMimeType());
logger.info("Downloading default item: "+workspaceFileItem);
//String contentDisposition = viewContent?"inline":"attachment";
//Support #16430
//The 'inline' option may be badly managed by browser
String contentDisposition = "attachment";
List<String> allowedPrefixes = AllowedMimeTypeToInline.getAllowedMimeTypePrefixes();
if(viewContent) {
logger.info("Checking if the mime type "+workspaceFileItem.getMimeType()+" exists among Mime Type Prefixes");
for (String prefix : allowedPrefixes) {
if(workspaceFileItem.getMimeType().startsWith(prefix)) {
logger.info("yes, the prefix "+prefix+" is matching the mimetype "+workspaceFileItem.getMimeType()+", so returning 'Content-Disposition' at 'inline'");
contentDisposition = "inline";
break;
}
}
}
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
//Fixing Incident: 18926, replacing workspaceFileItem.getSize() with ItemStreamDescriptor.getSize()
if(descr.getSize()!=null && descr.getSize()>0) {
resp = setContentLength(resp, descr.getSize());
}
logger.info("The size is: "+descr.getSize());
//MODIFIED 22-05-2013 CLOSE STREAM
OutputStream out = resp.getOutputStream();
InputStream is = metadata.getData();
IOUtils.copy(is, out);
InputStream is = descr.getStream();
IOUtils.copy(descr.getStream(), out);
is.close();
out.close();
return;
} catch (Exception e) {
logger.error("Error during item retrieving "+itemIds,e);
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
logger.error("Error during item retrieving "+itemId,e);
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
return;
}
}
}
}
default:
break;
}
handleError(urlRedirectOnError, req, resp, itemIds,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving");
handleError(urlRedirectOnError, req, resp, itemId,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving");
return;
}
/**
* To list.
*

@ -346,7 +346,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
* BUT RETURNING ONLY /MY_SPECIAL_FOLDER
*/
if(wsItem.isFolder()){
if(ItemBuilder.isSpecialFolder((WorkspaceFolder) wsItem)){
if(ItemBuilder.isSpecialFolder((WorkspaceFolder) wsItem, lastItem.isRoot())){
return new ArrayList<Item>(Arrays.asList(arrayParents));
}
}
@ -400,7 +400,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
*/
@Override
public List<Item> getBreadcrumbsByItemIdentifierToParentLimit(String itemIdentifier, String parentLimit, boolean includeItemAsParent) throws Exception {
logger.trace("getBreadcrumbsByItemIdentifierToParentLimit by Item Identifier " + itemIdentifier +" and limit: "+parentLimit);
logger.trace("getBreadcrumbsByItemIdentifierToParentLimit by Item Identifier " + itemIdentifier +" and limit: "+parentLimit + " and includeItemAsParent: "+includeItemAsParent);
try {
Workspace workspace = getWorkspace();
@ -417,9 +417,14 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
if(parents==null) //avoiding null
parents = new ArrayList<WorkspaceItem>();
logger.trace("parents size: "+parents.size());
Item[] arrayParents;
if(logger.isDebugEnabled()) {
for (WorkspaceItem workspaceItem : parents) {
logger.debug("the parent is: "+workspaceItem.getName());
}
}
List<Item> arrayParents = new ArrayList<Item>();
parentLimit = parentLimit!=null?parentLimit:"";
switch (parents.size()) {
@ -439,42 +444,49 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
}
}
WorkspaceItem lastItem = parents.get(parents.size()-1);
//CONVERTING LAST ELEMENT IF NEEDED...
logger.debug("converting last element..");
if(includeItemAsParent && lastItem.isFolder()){ //FIX BUG #298
arrayParents = new Item[parents.size()];
logger.debug("including last item into path: "+lastItem.getName());
arrayParents[parents.size()-1] = ItemBuilder.buildFolderForBreadcrumbs((WorkspaceFolder) lastItem, null);
}else
arrayParents = new Item[parents.size()-1];
//WorkspaceItem lastItem = parents.get(parents.size()-1);
//Adding the item passed as last first parent
if(includeItemAsParent && wsItem.isFolder()) {
WorkspaceFolder wsItemAsFolder =(WorkspaceFolder) wsItem;
Item theItem = ItemBuilder.buildFolderForBreadcrumbs(wsItemAsFolder, null);
arrayParents.add(theItem);
}
/** HANDLE MY_SPECIAL_FOLDER TO AVOID COMPLETE PATH WORKSPACE/MY_SPECIAL_FOLDER
* BUT RETURNING ONLY /MY_SPECIAL_FOLDER
*/
WorkspaceItem theFirstParent = parents.get(0);
if(wsItem.isFolder()){
if(ItemBuilder.isSpecialFolder((WorkspaceFolder) wsItem)){
if(ItemBuilder.isSpecialFolder((WorkspaceFolder) wsItem, theFirstParent.isRoot())){
logger.debug("item id is special folder, returning");
return new ArrayList<Item>(Arrays.asList(arrayParents));
return new ArrayList<Item>(arrayParents);
}
if(itemIdentifier.compareTo(parentLimit)==0){
logger.debug("item and parent limit are identical element, returning");
return new ArrayList<Item>(Arrays.asList(arrayParents));
return new ArrayList<Item>(arrayParents);
}
}
//CONVERTING PATH
logger.debug("converting path from second-last..");
for (int i = parents.size()-2; i >= 0; i--) {
logger.debug("converting parents...");
//for (int i = parents.size()-2; i >= 0; i--) {
for (int i = 0; i<parents.size(); i++) {
logger.debug("converting index: "+i);
WorkspaceFolder wsParentFolder = (WorkspaceFolder) parents.get(i);
arrayParents[i] = ItemBuilder.buildFolderForBreadcrumbs(wsParentFolder, null);
if(arrayParents[i].isSpecialFolder()){ //SKIP HOME PARENT FOR MY_SPECIAL_FOLDER
logger.debug("the folder at index: "+i +" is "+wsParentFolder.getName());
Item itemParent = ItemBuilder.buildFolderForBreadcrumbs(wsParentFolder, null);
arrayParents.add(itemParent);
if(itemParent.isSpecialFolder()){ //SKIP HOME PARENT FOR MY_SPECIAL_FOLDER
logger.info("arrayParents index "+i+" is special folder, break");
break;
}else if(parentLimit.compareTo(arrayParents[i].getId())==0){
}else if(parentLimit.compareTo(itemParent.getId())==0){
logger.info("reached parent limit "+parentLimit+", break");
break;
}
@ -482,29 +494,40 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
//SET PARENTS
logger.debug("setting parents..");
for(int i=0; i<arrayParents.length-1; i++){
for(int i=0; i<arrayParents.size()-1; i++){
Item parent = arrayParents[i];
Item fileModel = arrayParents[i+1];
Item parent = arrayParents.get(i+1);
Item fileModel = arrayParents.get(i);
if(fileModel!=null) {
fileModel.setParent(parent);
}
}
logger.info("Limited list of parents returning size: "+arrayParents.length);
if(arrayParents[0]==null){ //EXIT BY BREAK IN CASE OF SPECIAL FOLDER OR REACHED PARENT LIMIT
List<Item> breadcrumbs = new ArrayList<Item>();
for (int i=1; i<arrayParents.length; i++) {
if(arrayParents[i]!=null) {
breadcrumbs.add(arrayParents[i]);
}
// if(arrayParents[0]==null){ //EXIT BY BREAK IN CASE OF SPECIAL FOLDER OR REACHED PARENT LIMIT
// List<Item> breadcrumbs = new ArrayList<Item>();
// for (int i=1; i<arrayParents.length; i++) {
// if(arrayParents[i]!=null) {
// breadcrumbs.add(arrayParents[i]);
// }
// }
// logger.debug("Returning the breadcrumb: "+breadcrumbs);
// return breadcrumbs;
// }
// else {
// return new ArrayList<Item>(Arrays.asList(arrayParents));
// }
Collections.reverse(arrayParents);
logger.info("Reversed the parent list");
if(logger.isDebugEnabled()) {
for (Item item : arrayParents) {
logger.info("Returning parent: "+item.getName());
}
return breadcrumbs;
}
else {
return new ArrayList<Item>(Arrays.asList(arrayParents));
}
// logger.info("Limited list of parents returning size: "+arrayParents.length);
return arrayParents;
//new ArrayList<Item>(Arrays.asList(arrayParents));
} catch (Exception e) {
logger.error("Error in get List Parents By Item Identifier ", e);
@ -780,7 +803,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
try{
String scope = WsUtil.getScope(this.getThreadLocalRequest().getSession());
ScopeProvider.instance.set(scope);
logger.info("Trying to decode encoded folder Id: "+encodedFolderId);
logger.info("Trying to decode encoded folder Id: "+encodedFolderId +" in the scope: "+scope);
String base64DecodedId = StringUtil.base64DecodeString(encodedFolderId);
// String useThis = "P+IpJ6F6cTaGENfKMQWmStGUE79gbri5bVGRnzOvb8YUNIsJqFrdhceBrF+/u00j";
logger.info("Base 64 decoded folder Id: "+base64DecodedId +", now decrypting...");

@ -0,0 +1,85 @@
package org.gcube.portlets.user.workspaceexplorerapp.server.workspace;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class AllowedMimeTypeToInline.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Apr 4, 2019
*/
public class AllowedMimeTypeToInline {
public static final String filename = "MimeTypePrefixToInline.properties";
protected static Logger logger = LoggerFactory.getLogger(WsUtil.class);
/**
* Load mime type prefix.
*
* @return the properties
*/
private static Properties loadMimeTypePrefix(){
Properties prop = new Properties();
InputStream input = null;
try {
input = AllowedMimeTypeToInline.class.getResourceAsStream(filename);
if(input==null){
logger.error("Sorry, unable to find " + filename);
return null;
}
//load a properties file from class path, inside static method
prop.load(input);
return prop;
} catch (IOException ex) {
logger.error("Sorry, error: ", ex);
return null;
} finally{
if(input!=null){
try {
input.close();
} catch (IOException e) {
//silent
}
}
}
}
/**
* Gets the allowed mime type prefixes.
*
* @return the allowed mime type prefixes
*/
public static List<String> getAllowedMimeTypePrefixes(){
Properties prop = loadMimeTypePrefix();
List<String> prefixes = new ArrayList<String>();
if(prop==null)
return prefixes;
for (Object keyObj : prop.keySet()) {
prefixes.add((String) keyObj);
}
return prefixes;
}
}

@ -411,7 +411,7 @@ public class ItemBuilder {
//name = shared.isVreFolder()?shared.getDisplayName():wsFolder.getName();
name = shared.isVreFolder()?shared.getName():wsFolder.getName(); //not implemented by SHUB
}else {if(isSpecialFolder(wsFolder)){
}else if(parent!=null && isSpecialFolder(wsFolder, parent.isRoot())){
//MANAGEMENT SPECIAL FOLDER
name = WorkspaceExplorerAppConstants.VRE_FOLDERS_LABEL;
isSpecialFolder = true;

@ -0,0 +1,6 @@
image=prefix to image file
text=prefix to text file
video=prefix to video file
application/pdf=prefix to pdf file
application/xml=prefix to xml file
application/json=prefix to json file

@ -0,0 +1,283 @@
/**
*
*/
package org.gcube.portlets.user.workspaceexplorerapp.server.workspace;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FilenameUtils;
import org.apache.tika.config.TikaConfig;
import org.apache.tika.detect.Detector;
import org.apache.tika.io.TikaInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.mime.MediaType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class MimeTypeUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Copied from org.gcube.common.homelibrary.util.MimeTypeUtil
* @author Federico De Faveri defaveri@isti.cnr.it
*
* Jul 5, 2019
*/
public class MimeTypeUtility {
private static final String DOT_STRING = ".";
protected static Logger logger = LoggerFactory.getLogger(MimeTypeUtility.class);
/**
*
*/
public static final String BINARY_MIMETYPE = "application/octet-stream";
public static final String[] ZIP_MIMETYPES = new String[] { "application/octet-stream", "application/x-compress",
"application/x-compressed", "application/x-zip-compressed", "application/x-gzip", "application/x-winzip",
"application/x-zip", "application/zip", "multipart/x-zip" };
protected static final Map<String, List<String>> mimetype_extension_map = new LinkedHashMap<String, List<String>>();
protected static final Map<String, String> extension_mimetype_map = new LinkedHashMap<String, String>();
static {
InputStream extensionToMimetype = MimeTypeUtility.class
.getResourceAsStream("/WsExtensionToMimeTypeMap.properties");
InputStream mimetypeToExtension = MimeTypeUtility.class
.getResourceAsStream("/WsMimeTypeToExtensionMap.properties");
try {
loadExtensions(extensionToMimetype);
loadMimeTypes(mimetypeToExtension);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Load extensions.
*
* @param is the is
* @throws IOException Signals that an I/O exception has occurred.
*/
protected static void loadExtensions(InputStream is) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = br.readLine();
while (line != null) {
String[] split = line.split("=");
if (split.length == 2) {
String mimeType = split[0];
String extension = split[1];
extension_mimetype_map.put(extension, mimeType);
}
line = br.readLine();
}
br.close();
}
/**
* Load mime types.
*
* @param is the is
* @throws IOException Signals that an I/O exception has occurred.
*/
protected static void loadMimeTypes(InputStream is) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = br.readLine();
while (line != null) {
String[] split = line.split("=");
if (split.length == 2) {
String mimeType = split[0];
String extension = split[1];
List<String> toExtensions = mimetype_extension_map.get(mimeType);
if (toExtensions == null) {
toExtensions = new ArrayList<String>();
}
toExtensions.add(extension);
mimetype_extension_map.put(mimeType, toExtensions);
// mimetype_extension_map.put(mimeType, extension);
}
line = br.readLine();
}
br.close();
}
/**
* Gets the extension.
*
* @param mimeType the mime type.
* @return the related list of Extensions.
*/
public static List<String> getExtension(String mimeType) {
return mimetype_extension_map.get(mimeType);
}
/**
* Gets the name with extension.
*
* @param name the file name.
* @param mimeType the mime type.
* @return the right name.
* @throws IOException Signals that an I/O exception has occurred.
*/
public static String getNameWithExtension(String name, String mimeType) throws IOException {
logger.debug("Deriving the file extension for file name: " + name + ", with mimeType: " + mimeType);
if (mimeType == null || mimeType.isEmpty()) {
logger.debug("Input mime type is null or empty returning passed name: " + name);
return name;
}
String declaredExtension = FilenameUtils.getExtension(name);
logger.debug("The name " + name + " contains the extension: " + declaredExtension);
if (declaredExtension.equals("exe"))
return name;
List<String> extensions = MimeTypeUtility.getExtension(mimeType);
logger.trace("Extension/s available for input mimetype: " + mimeType + " into map is/are: " + extensions);
String toMimeTypeExtension = "";
if (extensions != null) {
toMimeTypeExtension = extensions.get(extensions.size() - 1); // 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);
}
// MANAGING ALREADY DECLARED EXTENSION IN THE FILE NAME
if (!declaredExtension.isEmpty() && !toMimeTypeExtension.isEmpty()) {
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;
}
/**
* Check if the content type is a zip type.
*
* @param contentType the content type to check.
* @return <code>true</code> if is a zip file, <code>false</code> otherwise.
*/
public static boolean isZipContentType(String contentType) {
for (String zip_mimetype : ZIP_MIMETYPES)
if (zip_mimetype.equals(contentType))
return true;
return false;
}
/**
* Get mime type by file.
*
* @param filenameWithExtension the filename with extension
* @param tmpFile the tmp file
* @return the mime type of the given file
*/
public static String getMimeType(String filenameWithExtension, File tmpFile) {
MediaType mediaType = null;
try {
TikaConfig config = TikaConfig.getDefaultConfig();
Detector detector = config.getDetector();
TikaInputStream stream = TikaInputStream.get(tmpFile);
Metadata metadata = new Metadata();
metadata.add(Metadata.RESOURCE_NAME_KEY, filenameWithExtension);
mediaType = detector.detect(stream, metadata);
} catch (IOException e) {
logger.error("Error detecting mime type for file " + filenameWithExtension);
}
return mediaType.getBaseType().toString();
}
/**
* Get mime type by inpustream.
*
* @param filenameWithExtension the filename with extension
* @param input the input
* @return the mime type of the given file
* @throws IOException Signals that an I/O exception has occurred.
*/
public static String getMimeType(String filenameWithExtension, InputStream input) throws IOException {
MediaType mediaType = null;
try {
TikaConfig config = TikaConfig.getDefaultConfig();
Detector detector = config.getDetector();
TikaInputStream stream = TikaInputStream.get(input);
Metadata metadata = new Metadata();
metadata.add(Metadata.RESOURCE_NAME_KEY, filenameWithExtension);
mediaType = detector.detect(stream, metadata);
} catch (IOException e) {
logger.error("Error detecting mime type for file " + filenameWithExtension);
} finally {
// if (file!=null)
// file.close();
}
return mediaType.getBaseType().toString();
}
/**
* Gets the mime type to extension map.
*
* @return the mime type to extension map
*/
public static Map<String, List<String>> getMimeTypeToExtensionMap() {
return mimetype_extension_map;
}
/**
* Gets the extension to mime type map.
*
* @return the extension to mime type map
*/
public static Map<String, String> getExtensionToMimeTypeMap() {
return extension_mimetype_map;
}
}

@ -34,7 +34,7 @@ public class WsUtil {
try {
String scope = getScope(httpSession);
// TODO
String token = "MUST BE PROVIDED";
String token = "9b397e7a-c683-44dc-b65b-53725b98f7e5-98187548";
logger.debug("Getting " + StorageHubWrapper.class.getSimpleName() +
" by token: " + token.substring(0, 10) +" MASKED TOKEN" +
" by using the scope: " + scope);
@ -53,7 +53,7 @@ public class WsUtil {
* @return the workpace
* @throws Exception the exception
*/
protected static org.gcube.common.storagehubwrapper.server.tohl.Workspace getWorkspace(HttpSession httpSession) throws Exception {
public static org.gcube.common.storagehubwrapper.server.tohl.Workspace getWorkspace(HttpSession httpSession) throws Exception {
try {
StorageHubWrapper wrapper = getStorageHubWrapper(httpSession);

@ -0,0 +1,213 @@
application/envoy =evy
application/fractals=fif
application/futuresplash=spl
application/hta=hta
application/internet-property-stream=acx
application/mac-binhex40=hqx
application/msword=doc
application/msword=dot
application/octet-stream=*
application/octet-stream=bin
application/octet-stream=class
application/octet-stream=dms
application/octet-stream=exe
application/octet-stream=lha
application/octet-stream=lzh
application/oda=oda
application/olescript=axs
application/pdf=pdf
application/pics-rules=prf
application/pkcs10=p10
application/pkix-crl=crl
application/postscript=ai
application/postscript=eps
application/postscript=ps
application/rtf=rtf
application/set-payment-initiation=setpay
application/set-registration-initiation=setreg
application/vnd.ms-excel=xla
application/vnd.ms-excel=xlc
application/vnd.ms-excel=xlm
application/vnd.ms-excel=xls
application/vnd.ms-excel=xlt
application/vnd.ms-excel=xlw
application/vnd.ms-outlook=msg
application/vnd.ms-pkicertstore=sst
application/vnd.ms-pkiseccat=cat
application/vnd.ms-pkistl=stl
application/vnd.ms-powerpoint=pot
application/vnd.ms-powerpoint=pps
application/vnd.ms-powerpoint=ppt
application/vnd.ms-project=mpp
application/vnd.ms-works=wcm
application/vnd.ms-works=wdb
application/vnd.ms-works=wks
application/vnd.ms-works=wps
application/vnd.openxmlformats-officedocument.wordprocessingml.document=docx
application/vnd.ms-word.document.macroEnabled.12=docm
application/vnd.openxmlformats-officedocument.wordprocessingml.template=dotx
application/vnd.ms-powerpoint.template.macroEnabled.12=potm
application/vnd.openxmlformats-officedocument.presentationml.template=potx
application/vnd.ms-powerpoint.addin.macroEnabled.12=ppam
application/vnd.ms-powerpoint.slideshow.macroEnabled.12=ppsm
application/vnd.openxmlformats-officedocument.presentationml.slideshow=ppsx
application/vnd.ms-powerpoint.presentation.macroEnabled.12=pptm
application/vnd.openxmlformats-officedocument.presentationml.presentation=pptx
application/vnd.ms-excel.addin.macroEnabled.12=xlam
application/vnd.ms-excel.sheet.binary.macroEnabled.12=xlsb
application/vnd.ms-excel.sheet.macroEnabled.12=xlsm
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet=xlsx
application/vnd.ms-excel.template.macroEnabled.12=xltm
application/vnd.openxmlformats-officedocument.spreadsheetml.template=xltx
application/winhlp=hlp
application/x-bcpio=bcpio
application/x-cdf=cdf
application/x-compress=z
application/x-compressed=tgz
application/x-cpio=cpio
application/x-csh=csh
application/x-director=dcr
application/x-director=dir
application/x-director=dxr
application/x-dvi=dvi
application/x-gtar=gtar
application/x-gzip=gz
application/x-hdf=hdf
application/x-internet-signup=ins
application/x-internet-signup=isp
application/x-iphone=iii
application/x-javascript=js
application/x-latex=latex
application/x-msaccess=mdb
application/x-mscardfile=crd
application/x-msclip=clp
application/x-msdownload=dll
application/x-msmediaview=m13
application/x-msmediaview=m14
application/x-msmediaview=mvb
application/x-msmetafile=wmf
application/x-msmoney=mny
application/x-mspublisher=pub
application/x-msschedule=scd
application/x-msterminal=trm
application/x-mswrite=wri
application/x-netcdf=cdf
application/x-netcdf=nc
application/x-perfmon=pma
application/x-perfmon=pmc
application/x-perfmon=pml
application/x-perfmon=pmr
application/x-perfmon=pmw
application/x-pkcs12=p12
application/x-pkcs12=pfx
application/x-pkcs7-certificates=p7b
application/x-pkcs7-certificates=spc
application/x-pkcs7-certreqresp=p7r
application/x-pkcs7-mime=p7c
application/x-pkcs7-mime=p7m
application/x-pkcs7-signature=p7s
application/x-sh=sh
application/x-shar=shar
application/x-shockwave-flash=swf
application/x-stuffit=sit
application/x-sv4cpio=sv4cpio
application/x-sv4crc=sv4crc
application/x-tar=tar
application/x-tcl=tcl
application/x-tex=tex
application/x-texinfo=texi
application/x-texinfo=texinfo
application/x-troff=roff
application/x-troff=t
application/x-troff=tr
application/x-troff-man=man
application/x-troff-me=me
application/x-troff-ms=ms
application/x-ustar=ustar
application/x-wais-source=src
application/x-x509-ca-cert=cer
application/x-x509-ca-cert=crt
application/x-x509-ca-cert=der
application/ynd.ms-pkipko=pko
application/zip=zip
application/x-java-archive=jar
application/x-java-archive=war
audio/basic=au
audio/basic=snd
audio/mid=mid
audio/mid=rmi
audio/mpeg=mp3
audio/x-aiff=aif
audio/x-aiff=aifc
audio/x-aiff=aiff
audio/x-mpegurl=m3u
audio/x-pn-realaudio=ra
audio/x-pn-realaudio=ram
audio/x-wav=wav
image/bmp=bmp
image/cis-cod=cod
image/gif=gif
image/ief=ief
image/jpeg=jpe
image/jpeg=jpeg
image/jpeg=jpg
image/pipeg=jfif
image/svg+xml=svg
image/tiff=tif
image/tiff=tiff
image/x-cmu-raster=ras
image/x-cmx=cmx
image/x-icon=ico
image/x-portable-anymap=pnm
image/x-portable-bitmap=pbm
image/x-portable-graymap=pgm
image/x-portable-pixmap=ppm
image/x-rgb=rgb
image/x-xbitmap=xbm
image/x-xpixmap=xpm
image/x-xwindowdump=xwd
message/rfc822=mht
message/rfc822=mhtml
message/rfc822=nws
text/css=css
text/csv=csv
application/xml=xml
application/xhtml+xml=xhtml
text/h323=323
text/html=htm
text/html=html
text/html=stm
text/iuls=uls
text/plain=bas
text/plain=c
text/plain=h
text/plain=txt
text/richtext=rtx
text/scriptlet=sct
text/tab-separated-values=tsv
text/uri-list=txt
text/webviewhtml=htt
text/x-component=htc
text/x-setext=etx
text/x-vcard=vcf
video/mpeg=mp2
video/mpeg=mpa
video/mpeg=mpe
video/mpeg=mpeg
video/mpeg=mpg
video/mpeg=mpv2
video/quicktime=mov
video/quicktime=qt
video/x-la-asf=lsf
video/x-la-asf=lsx
video/x-ms-asf=asf
video/x-ms-asf=asr
video/x-ms-asf=asx
video/x-msvideo=avi
video/x-sgi-movie=movie
x-world/x-vrml=flr
x-world/x-vrml=vrml
x-world/x-vrml=wrl
x-world/x-vrml=wrz
x-world/x-vrml=xaf
x-world/x-vrml=xof

@ -0,0 +1,181 @@
application/envoy =evy
application/fractals=fif
application/futuresplash=spl
application/hta=hta
application/internet-property-stream=acx
application/mac-binhex40=hqx
application/msword=doc
application/octet-stream=bin
application/oda=oda
application/olescript=axs
application/pdf=pdf
application/pics-rules=prf
application/pkcs10=p10
application/pkix-crl=crl
application/postscript=ps
application/rtf=rtf
application/set-payment-initiation=setpay
application/set-registration-initiation=setreg
application/vnd.ms-excel=xls
application/vnd.ms-outlook=msg
application/vnd.ms-pkicertstore=sst
application/vnd.ms-pkiseccat=cat
application/vnd.ms-pkistl=stl
application/vnd.ms-powerpoint=ppt
application/vnd.ms-project=mpp
application/vnd.ms-works=wcm
application/vnd.ms-works=wdb
application/vnd.ms-works=wks
application/vnd.ms-works=wps
application/vnd.openxmlformats-officedocument.wordprocessingml.document=docx
application/winhlp=hlp
application/x-bcpio=bcpio
application/x-cdf=cdf
application/x-compress=z
application/x-compressed=tgz
application/x-compressed-tar=tar.gz
application/x-cpio=cpio
application/x-csh=csh
application/x-director=dcr
application/x-director=dir
application/x-director=dxr
application/x-dvi=dvi
application/x-gtar=gtar
application/x-gzip=gz
application/x-hdf=hdf
application/x-internet-signup=ins
application/x-internet-signup=isp
application/x-iphone=iii
application/x-javascript=js
application/json=json
application/x-latex=latex
application/x-msaccess=mdb
application/x-mscardfile=crd
application/x-msclip=clp
application/x-msdownload=dll
application/x-msmediaview=m13
application/x-msmediaview=m14
application/x-msmediaview=mvb
application/x-msmetafile=wmf
application/x-msmoney=mny
application/x-mspublisher=pub
application/x-msschedule=scd
application/x-msterminal=trm
application/x-mswrite=wri
application/x-netcdf=cdf
application/x-netcdf=nc
application/x-perfmon=pma
application/x-perfmon=pmc
application/x-perfmon=pml
application/x-perfmon=pmr
application/x-perfmon=pmw
application/x-pkcs12=p12
application/x-pkcs12=pfx
application/x-pkcs7-certificates=p7b
application/x-pkcs7-certificates=spc
application/x-pkcs7-certreqresp=p7r
application/x-pkcs7-mime=p7c
application/x-pkcs7-mime=p7m
application/x-pkcs7-signature=p7s
application/x-sh=sh
application/x-shar=shar
application/x-shockwave-flash=swf
application/x-stuffit=sit
application/x-sv4cpio=sv4cpio
application/x-sv4crc=sv4crc
application/x-tar=tar
application/x-tcl=tcl
application/x-tex=tex
application/x-texinfo=texi
application/x-texinfo=texinfo
application/x-tika-java-web-archive=war
application/x-troff=roff
application/x-troff=t
application/x-troff=tr
application/x-troff-man=man
application/x-troff-me=me
application/x-troff-ms=ms
application/x-ustar=ustar
application/x-wais-source=src
application/x-x509-ca-cert=cer
application/x-x509-ca-cert=crt
application/x-x509-ca-cert=der
application/ynd.ms-pkipko=pko
application/zip=zip
audio/basic=au
audio/basic=snd
audio/mid=mid
audio/mid=rmi
audio/mpeg=mp3
audio/x-aiff=aif
audio/x-aiff=aifc
audio/x-aiff=aiff
audio/x-mpegurl=m3u
audio/x-pn-realaudio=ra
audio/x-pn-realaudio=ram
audio/x-wav=wav
image/bmp=bmp
image/cis-cod=cod
image/gif=gif
image/ief=ief
image/jpeg=jpe
image/jpeg=jpeg
image/jpeg=jpg
image/pipeg=jfif
image/svg+xml=svg
image/tiff=tif
image/tiff=tiff
image/x-cmu-raster=ras
image/x-cmx=cmx
image/x-icon=ico
image/x-portable-anymap=pnm
image/x-portable-bitmap=pbm
image/x-portable-graymap=pgm
image/x-portable-pixmap=ppm
image/x-rgb=rgb
image/x-xbitmap=xbm
image/x-xpixmap=xpm
image/x-xwindowdump=xwd
message/rfc822=mht
message/rfc822=mhtml
message/rfc822=nws
text/css=css
text/csv=csv
text/h323=323
text/html=htm
text/html=stm
text/html=html
text/iuls=uls
text/plain=bas
text/plain=c
text/plain=h
text/plain=txt
text/richtext=rtx
text/scriptlet=sct
text/tab-separated-values=tsv
text/uri-list=txt
text/webviewhtml=htt
text/x-component=htc
text/x-setext=etx
text/x-vcard=vcf
video/mpeg=mp2
video/mpeg=mpa
video/mpeg=mpe
video/mpeg=mpeg
video/mpeg=mpg
video/mpeg=mpv2
video/quicktime=mov
video/quicktime=qt
video/x-la-asf=lsf
video/x-la-asf=lsx
video/x-ms-asf=asf
video/x-ms-asf=asr
video/x-ms-asf=asx
video/x-msvideo=avi
video/x-sgi-movie=movie
x-world/x-vrml=flr
x-world/x-vrml=vrml
x-world/x-vrml=wrl
x-world/x-vrml=wrz
x-world/x-vrml=xaf
x-world/x-vrml=xof

@ -0,0 +1,6 @@
/devNext.gcubekey
/devsec.gcubekey
/gcube.gcubekey
/pred4s.gcubekey
/preprod.gcubekey
/log4j.properties
Loading…
Cancel
Save