258: TabMan - the files associated to the resources are downloaded without extension

Task-Url: https://support.d4science.org/issues/258

Added extension to Name of Resource by mime type

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@115423 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-06-18 13:04:03 +00:00
parent e4481a3502
commit 88d3c8921a
2 changed files with 21 additions and 15 deletions

View File

@ -907,10 +907,18 @@ public class ResourcesListViewPanel extends FramedPanel {
final ResourceTDDescriptor resourceTDDescriptor) { final ResourceTDDescriptor resourceTDDescriptor) {
ResourceTD resource = resourceTDDescriptor.getResourceTD(); ResourceTD resource = resourceTDDescriptor.getResourceTD();
if (resource instanceof InternalURITD) { if (resource instanceof InternalURITD) {
InternalURITD genericFileResourceTD = (InternalURITD) resource; InternalURITD genericFileResourceTD = (InternalURITD) resource;
String name=resourceTDDescriptor.getName();
MimeTypeSupport mts=MimeTypeSupport.getMimeTypeSupportFromMimeName(genericFileResourceTD.getMimeType());
if(mts!=null){
name=name+mts.getExtension();
}
UriResolverSession uriResolverSession = new UriResolverSession( UriResolverSession uriResolverSession = new UriResolverSession(
genericFileResourceTD.getId(), ApplicationType.SMP_ID, genericFileResourceTD.getId(), ApplicationType.SMP_ID,
resourceTDDescriptor.getName(), name,
genericFileResourceTD.getMimeType()); genericFileResourceTD.getMimeType());
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession, TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
@ -936,20 +944,10 @@ public class ResourcesListViewPanel extends FramedPanel {
}); });
} else { } else {
if (resource instanceof InternalURITD) { Log.error("Error with resource: no valid resource");
UtilsGXT3
.alert("Error with resource", "Error no valid InternalUri");
} else {
if (resource instanceof TableResourceTD) {
} else {
Log.error("Error with resource: no valid resource");
UtilsGXT3.alert("Error with resource",
"Error no valid InternalUri");
}
}
} }
} }
} }

View File

@ -16,6 +16,7 @@ import org.gcube.portlets.user.td.resourceswidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.mime.MimeTypeSupport;
import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType; import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
@ -195,9 +196,16 @@ public class ChartViewerPanel extends FramedPanel {
} }
protected void retrieveUrlFromResolver() { protected void retrieveUrlFromResolver() {
String name=resourceTDDescriptor.getName();
MimeTypeSupport mts=MimeTypeSupport.getMimeTypeSupportFromMimeName(internalURITD.getMimeType());
if(mts!=null){
name=name+mts.getExtension();
}
UriResolverSession uriResolverSession = new UriResolverSession( UriResolverSession uriResolverSession = new UriResolverSession(
internalURITD.getId(), ApplicationType.SMP_ID, internalURITD.getId(), ApplicationType.SMP_ID,
resourceTDDescriptor.getName(), internalURITD.getMimeType()); name, internalURITD.getMimeType());
Log.debug("UriResolverSession: "+uriResolverSession); Log.debug("UriResolverSession: "+uriResolverSession);
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession, TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
new AsyncCallback<String>() { new AsyncCallback<String>() {