Updated uri resolver
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@114487 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
231f41bd7b
commit
b724f0f1b1
|
@ -232,17 +232,18 @@ public class ResourcesPanel extends FramedPanel {
|
|||
ResourceTD resource = value.getResourceTD();
|
||||
String resourceData = "";
|
||||
if (resource instanceof InternalURITD) {
|
||||
/*InternalURITD internalURITD = (InternalURITD) resource;
|
||||
if (internalURITD.getStringValue() != null
|
||||
&& !internalURITD.getStringValue().isEmpty()) {
|
||||
resourceData = "<tr>"
|
||||
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>File Id: </b></td>"
|
||||
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
|
||||
+ SafeHtmlUtils
|
||||
.htmlEscape(internalURITD
|
||||
.getStringValue()) + "</td>"
|
||||
+ "</tr>";
|
||||
}*/
|
||||
/*
|
||||
* InternalURITD internalURITD = (InternalURITD)
|
||||
* resource; if (internalURITD.getStringValue() !=
|
||||
* null &&
|
||||
* !internalURITD.getStringValue().isEmpty()) {
|
||||
* resourceData = "<tr>" +
|
||||
* "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>File Id: </b></td>"
|
||||
* +
|
||||
* "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
|
||||
* + SafeHtmlUtils .htmlEscape(internalURITD
|
||||
* .getStringValue()) + "</td>" + "</tr>"; }
|
||||
*/
|
||||
|
||||
} else {
|
||||
if (resource instanceof StringResourceTD) {
|
||||
|
@ -710,8 +711,8 @@ public class ResourcesPanel extends FramedPanel {
|
|||
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||
internalURITD.getUrl(), ApplicationType.GIS);
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
|
||||
new AsyncCallback<String>() {
|
||||
TDGWTServiceAsync.INSTANCE.getUriFromResolver(
|
||||
uriResolverSession, new AsyncCallback<String>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
|
@ -720,22 +721,20 @@ public class ResourcesPanel extends FramedPanel {
|
|||
} else {
|
||||
Log.error("Error with uri resolver: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
UtilsGXT3
|
||||
.alert("Error",
|
||||
"Error retrieving uri from resolver");
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(String link) {
|
||||
Log.debug("Retrieved link: " + link);
|
||||
Window.open(link, resourceTDDescriptor.getName(),
|
||||
"");
|
||||
Window.open(link,
|
||||
resourceTDDescriptor.getName(), "");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
if (resource instanceof TableResourceTD) {
|
||||
|
||||
|
@ -753,11 +752,12 @@ public class ResourcesPanel extends FramedPanel {
|
|||
protected void requestOpenGenericFile(
|
||||
final ResourceTDDescriptor resourceTDDescriptor) {
|
||||
ResourceTD resource = resourceTDDescriptor.getResourceTD();
|
||||
if (resource instanceof StringResourceTD) {
|
||||
StringResourceTD genericFileResourceTD = (StringResourceTD) resource;
|
||||
if (resource instanceof InternalURITD) {
|
||||
InternalURITD genericFileResourceTD = (InternalURITD) resource;
|
||||
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||
genericFileResourceTD.getStringValue(),
|
||||
ApplicationType.SMP, resourceTDDescriptor.getName());
|
||||
genericFileResourceTD.getUrl(), ApplicationType.SMP_ID,
|
||||
resourceTDDescriptor.getName(),
|
||||
genericFileResourceTD.getMimeType());
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
|
||||
new AsyncCallback<String>() {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package org.gcube.portlets.user.td.resourceswidget.client.charts;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTD;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
|
||||
import org.gcube.portlets.user.td.resourceswidget.client.graphics.Vector2D;
|
||||
import org.gcube.portlets.user.td.resourceswidget.client.properties.ZoomLevelPropertiesCombo;
|
||||
import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundle;
|
||||
|
@ -10,7 +13,10 @@ import org.gcube.portlets.user.td.resourceswidget.client.store.ZoomLevelElement;
|
|||
import org.gcube.portlets.user.td.resourceswidget.client.store.ZoomLevelStore;
|
||||
import org.gcube.portlets.user.td.resourceswidget.client.store.ZoomLevelType;
|
||||
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.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -28,6 +34,7 @@ import com.google.gwt.safehtml.shared.UriUtils;
|
|||
import com.google.gwt.user.client.Event;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HasValue;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
|
@ -69,7 +76,8 @@ public class ChartViewerPanel extends FramedPanel {
|
|||
private static final String COMBO_ZOOM_LEVEL_WIDTH = "100px";
|
||||
private static final int IMAGE_WIDTH = 1024;
|
||||
private static final int IMAGE_HEIGHT = 768;
|
||||
//private static final String RETRIEVE_CHART_FILE_SERVLET = "RetrieveChartFileServlet";
|
||||
// private static final String RETRIEVE_CHART_FILE_SERVLET =
|
||||
// "RetrieveChartFileServlet";
|
||||
private static final String RETRIEVE_FILE_AND_DISCOVER_MIME_TYPE_SERVLET = "RetrieveFileAndDiscoverMimeTypeServlet";
|
||||
private static final String ATTRIBUTE_STORAGE_URI = "storageURI";
|
||||
|
||||
|
@ -93,9 +101,13 @@ public class ChartViewerPanel extends FramedPanel {
|
|||
private Vector2D displacement;
|
||||
|
||||
private ChartViewerDialog parent;
|
||||
private EventBus eventBus;
|
||||
private ResourceTDDescriptor resourceTDDescriptor;
|
||||
private boolean test;
|
||||
|
||||
private InternalURITD internalURITD;
|
||||
private String chartLink;
|
||||
|
||||
private ImageResource chartImageResource;
|
||||
private ImageResource testImageResource;
|
||||
|
||||
|
@ -133,19 +145,19 @@ public class ChartViewerPanel extends FramedPanel {
|
|||
EventBus eventBus, boolean test) {
|
||||
super();
|
||||
ResourceBundle.INSTANCE.resourceCSS().ensureInjected();
|
||||
|
||||
this.eventBus = eventBus;
|
||||
this.parent = parent;
|
||||
this.resourceTDDescriptor = resourceTDDescriptor;
|
||||
this.test = test;
|
||||
forceLayoutOnResize = true;
|
||||
|
||||
mask();
|
||||
if (test) {
|
||||
testImageResource = ResourceBundle.INSTANCE.testImage();
|
||||
create();
|
||||
} else {
|
||||
retrieveChart();
|
||||
create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String encodeUrlDelimiters(String s) {
|
||||
|
@ -167,7 +179,6 @@ public class ChartViewerPanel extends FramedPanel {
|
|||
}
|
||||
|
||||
protected void retrieveChart() {
|
||||
InternalURITD internalURITD;
|
||||
ResourceTD resource = resourceTDDescriptor.getResourceTD();
|
||||
if (resource instanceof InternalURITD) {
|
||||
internalURITD = (InternalURITD) resource;
|
||||
|
@ -179,7 +190,42 @@ public class ChartViewerPanel extends FramedPanel {
|
|||
return;
|
||||
}
|
||||
Log.debug("InteranlURI: " + internalURITD);
|
||||
final String storageURI = encodeUrlDelimiters(internalURITD.getUrl());
|
||||
retrieveUrlFromResolver();
|
||||
|
||||
}
|
||||
|
||||
protected void retrieveUrlFromResolver() {
|
||||
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||
internalURITD.getUrl(), ApplicationType.SMP_ID,
|
||||
resourceTDDescriptor.getName(), internalURITD.getMimeType());
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
|
||||
new AsyncCallback<String>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error with uri resolver: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
"Error retrieving uri from resolver: "
|
||||
+ caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(String link) {
|
||||
Log.debug("Retrieved link: " + link);
|
||||
chartLink = link;
|
||||
createChartImageResource();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void createChartImageResource() {
|
||||
|
||||
final String path = GWT.getModuleBaseURL()
|
||||
+ RETRIEVE_FILE_AND_DISCOVER_MIME_TYPE_SERVLET;
|
||||
|
@ -205,7 +251,7 @@ public class ChartViewerPanel extends FramedPanel {
|
|||
public SafeUri getSafeUri() {
|
||||
|
||||
SafeUri uri = UriUtils.fromString(path + "?"
|
||||
+ ATTRIBUTE_STORAGE_URI + "=" + storageURI);
|
||||
+ ATTRIBUTE_STORAGE_URI + "=" + chartLink);
|
||||
|
||||
Log.debug("Image uri:" + uri.asString());
|
||||
return uri;
|
||||
|
@ -233,11 +279,14 @@ public class ChartViewerPanel extends FramedPanel {
|
|||
|
||||
};
|
||||
|
||||
create();
|
||||
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
init();
|
||||
createPanel();
|
||||
unmask();
|
||||
drawInit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue