integrating the url shortener
This commit is contained in:
parent
e6f232298e
commit
eb8ea01bfb
|
@ -1,4 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/home/francesco-mangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0-SNAPSHOT
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -127,6 +127,12 @@
|
|||
<version>[1.1.0, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-url-shortener</artifactId>
|
||||
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
|
|
|
@ -204,7 +204,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
@Override
|
||||
public void onSuccess(ConcessioneDV result) {
|
||||
GWT.log("Showing: "+result);
|
||||
mainPanel.renderProductIntoTab(theTab, result);
|
||||
mainPanel.renderProductIntoTab(theTab, result, showDetailsEvent.getGeonaItemRef());
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,17 +16,51 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
|||
|
||||
/**
|
||||
* The client side stub for the RPC service.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Nov 17, 2020
|
||||
*/
|
||||
@RemoteServiceRelativePath("geoportaldataviewerservice")
|
||||
public interface GeoportalDataViewerService extends RemoteService {
|
||||
|
||||
/**
|
||||
* Parses the wms request.
|
||||
*
|
||||
* @param wmsRequest the wms request
|
||||
* @param layerName the layer name
|
||||
* @return the geo information for WMS request
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the data result.
|
||||
*
|
||||
* @param layerObjects the layer objects
|
||||
* @param mapSrsName the map srs name
|
||||
* @param mapBBOX the map BBOX
|
||||
* @param maxWFSFeature the max WFS feature
|
||||
* @param zoomLevel the zoom level
|
||||
* @return the data result
|
||||
*/
|
||||
List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX,
|
||||
int maxWFSFeature, double zoomLevel);
|
||||
|
||||
/**
|
||||
* Gets the concessione for id.
|
||||
*
|
||||
* @param id the id
|
||||
* @return the concessione for id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
ConcessioneDV getConcessioneForId(Long id) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the my login.
|
||||
*
|
||||
* @return the my login
|
||||
*/
|
||||
String getMyLogin();
|
||||
|
||||
/**
|
||||
|
@ -38,17 +72,41 @@ public interface GeoportalDataViewerService extends RemoteService {
|
|||
*/
|
||||
GeoInformationForWMSRequest getLayerForType(String layerType) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the geo na data view profile.
|
||||
*
|
||||
* @return the geo na data view profile
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the uploaded images for id.
|
||||
*
|
||||
* @param itemType the item type
|
||||
* @param id the id
|
||||
* @param maxImages the max images
|
||||
* @return the uploaded images for id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
List<UploadedImageDV> getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the public links for.
|
||||
*
|
||||
* @param item the item
|
||||
* @return the public links for
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the short url.
|
||||
*
|
||||
* @param longUrl the long url
|
||||
* @return the short url
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
String getShortUrl(String longUrl) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -49,4 +49,6 @@ public interface GeoportalDataViewerServiceAsync {
|
|||
void getUploadedImagesForId(String itemType, Long id, int maxImages, AsyncCallback<List<UploadedImageDV>> callback);
|
||||
|
||||
void getPublicLinksFor(GeoNaItemRef item, AsyncCallback<GeoNaItemRef> asyncCallback);
|
||||
|
||||
void getShortUrl(String longUrl, AsyncCallback<String> callback);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Map;
|
|||
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni.ConcessioneView;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
|
@ -125,10 +126,10 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
|
||||
}
|
||||
|
||||
public void renderProductIntoTab(Tab tab, ConcessioneDV cdv) {
|
||||
public void renderProductIntoTab(Tab tab, ConcessioneDV cdv, GeoNaItemRef geonaItemRef) {
|
||||
tab.clear();
|
||||
tab.setHeading(cdv.getNome());
|
||||
tab.add(new ConcessioneView(cdv));
|
||||
tab.add(new ConcessioneView(geonaItemRef, cdv));
|
||||
mapProducts.put(cdv.getId(), tab);
|
||||
selectTabForProductId(cdv.getId());
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs;
|
|||
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.PublicLink;
|
||||
|
||||
|
@ -14,7 +13,6 @@ import com.github.gwtbootstrap.client.ui.Modal;
|
|||
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.github.gwtbootstrap.client.ui.Tooltip;
|
||||
import com.github.gwtbootstrap.client.ui.Well;
|
||||
import com.github.gwtbootstrap.client.ui.constants.VisibilityChange;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
|
@ -72,11 +70,8 @@ public class DialogShareableLink extends Composite {
|
|||
@UiField
|
||||
Alert actionAlert;
|
||||
|
||||
@UiField
|
||||
Well alertFilePublicLink;
|
||||
|
||||
@UiField
|
||||
Well alertFolderPublicLink;
|
||||
// @UiField
|
||||
// Well alertFilePublicLink;
|
||||
|
||||
@UiField
|
||||
Fieldset fieldSetPrivate;
|
||||
|
@ -104,9 +99,9 @@ public class DialogShareableLink extends Composite {
|
|||
|
||||
@UiField
|
||||
Button publicLongLinkCopyButton;
|
||||
|
||||
@UiField
|
||||
Well wellPrivateLinkDescription;
|
||||
//
|
||||
// @UiField
|
||||
// Well wellPrivateLinkDescription;
|
||||
|
||||
@UiField
|
||||
Button showPrivateLongLinkButton;
|
||||
|
@ -155,15 +150,17 @@ public class DialogShareableLink extends Composite {
|
|||
this.fileVersion = version;
|
||||
this.actionAlert.setAnimation(true);
|
||||
|
||||
showShareableLinkOptions(item, version);
|
||||
//cgRemovePublicLink.setVisible(false);
|
||||
// fieldSetPrivate.setVisible(false);
|
||||
// fieldPrivateSharing.setVisible(false);
|
||||
cgPublicLink.setVisible(true);
|
||||
fieldSetPrivate.setVisible(true);
|
||||
showMessage("", false);
|
||||
|
||||
//alertFilePublicLink.setVisible(true);
|
||||
loadAndShowPublicLinksForItem(item);
|
||||
//getElement().setClassName("gwt-DialogBoxNew");
|
||||
String title = "Share";
|
||||
try {
|
||||
title+= " "+StringUtil.ellipsize(item.getItemName(), 15);
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
modalBox.setTitle(title);
|
||||
modalBox.setTitle("Share Link...");
|
||||
ModalFooter modalFooter = new ModalFooter();
|
||||
final Button buttClose = new Button("Close");
|
||||
modalFooter.add(buttClose);
|
||||
|
@ -186,9 +183,7 @@ public class DialogShareableLink extends Composite {
|
|||
modalBox.add(this);
|
||||
modalBox.add(modalFooter);
|
||||
modalBox.show();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -383,37 +378,13 @@ public class DialogShareableLink extends Composite {
|
|||
//alert("Copied the text: " + copyText.value);
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Show shareable link options.
|
||||
*
|
||||
* @param item the item
|
||||
* @param version the version
|
||||
*/
|
||||
public void showShareableLinkOptions(GeoNaItemRef item, String version) {
|
||||
|
||||
//cgRemovePublicLink.setVisible(false);
|
||||
fieldSetPrivate.setVisible(false);
|
||||
fieldPrivateSharing.setVisible(false);
|
||||
cgPublicLink.setVisible(false);
|
||||
alertFilePublicLink.setVisible(false);
|
||||
alertFolderPublicLink.setVisible(false);
|
||||
showMessage("", false);
|
||||
|
||||
cgPublicLink.setVisible(true);
|
||||
|
||||
alertFilePublicLink.setVisible(true);
|
||||
loadAndShowPublicLinksForItem(item, textPublicLink);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load and show public links for item.
|
||||
*
|
||||
* @param item the item
|
||||
* @param toTextBox the to text box
|
||||
*/
|
||||
private void loadAndShowPublicLinksForItem(GeoNaItemRef item, final TextBox toTextBox) {
|
||||
private void loadAndShowPublicLinksForItem(GeoNaItemRef item) {
|
||||
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getPublicLinksFor(item,
|
||||
new AsyncCallback<GeoNaItemRef>() {
|
||||
|
@ -422,16 +393,26 @@ public class DialogShareableLink extends Composite {
|
|||
public void onSuccess(GeoNaItemRef itemReferences) {
|
||||
openPublicLink = itemReferences.getOpenLink();
|
||||
restrictedPublicLink = itemReferences.getRestrictedLink();
|
||||
String toURL = openPublicLink.getShortURL() != null && !openPublicLink.getShortURL().isEmpty()
|
||||
String toPublicURL = openPublicLink.getShortURL() != null && !openPublicLink.getShortURL().isEmpty()
|
||||
? openPublicLink.getShortURL()
|
||||
: openPublicLink.getCompleteURL();
|
||||
toTextBox.setValue(toURL);
|
||||
|
||||
textPublicLink.setValue(toPublicURL);
|
||||
textPublicLongLink.setValue(openPublicLink.getCompleteURL());
|
||||
|
||||
String toPrivateURL = restrictedPublicLink.getShortURL() != null && !restrictedPublicLink.getShortURL().isEmpty()
|
||||
? restrictedPublicLink.getShortURL()
|
||||
: restrictedPublicLink.getCompleteURL();
|
||||
|
||||
textPrivateLink.setValue(toPrivateURL);
|
||||
textPrivateLongLink.setValue(restrictedPublicLink.getCompleteURL());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
openPublicLink = null;
|
||||
disableTextBox(toTextBox);
|
||||
disableTextBox(textPublicLink);
|
||||
disableTextBox(textPrivateLink);
|
||||
showError(caught.getMessage());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.margin-left-25 {
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
.text-bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
@ -30,10 +34,6 @@
|
|||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.font-size-14 {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.to-top-alignment {
|
||||
vertical-align: top;
|
||||
padding-top: 0px !important;
|
||||
|
@ -53,12 +53,13 @@
|
|||
<g:VerticalPanel ui:field="fieldPrivateSharing"
|
||||
addStyleNames="{style.margin-bottom-20}">
|
||||
<g:HorizontalPanel>
|
||||
<b:Label type="INFO" addStyleNames="{style.font-size-14}">Link shareable with
|
||||
<b:Label type="INFO" addStyleNames="sharelabel">With
|
||||
coworkers</b:Label>
|
||||
</g:HorizontalPanel>
|
||||
<g:VerticalPanel
|
||||
addStyleNames="{style.margin-left-5}">
|
||||
<g:Label ui:field="labelLinkPrivateSharing">(Only the) Members of the VRE are enacted to view</g:Label>
|
||||
<g:Label ui:field="labelLinkPrivateSharing">(Only the) Members of the VRE are enacted
|
||||
to access it. Login required</g:Label>
|
||||
</g:VerticalPanel>
|
||||
</g:VerticalPanel>
|
||||
|
||||
|
@ -69,12 +70,9 @@
|
|||
<b:ControlGroup ui:field="cgPrivateLink"
|
||||
addStyleNames="my-control-group">
|
||||
|
||||
<b:Well ui:field="wellPrivateLinkDescription">
|
||||
By sharing the following Restricted Link with
|
||||
your
|
||||
coworkers,
|
||||
you will enact the users of the VRE
|
||||
to view this product. Login required</b:Well>
|
||||
<!-- <b:Well ui:field="wellPrivateLinkDescription"> -->
|
||||
<!-- The following Restricted Link for this product -->
|
||||
<!-- is accessible by the users of the VRE. Login required</b:Well> -->
|
||||
<b:ControlLabel>Restricted Link</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:InputAddOn prependIcon="LINK"
|
||||
|
@ -87,7 +85,7 @@
|
|||
</b:Tooltip>
|
||||
</b:InputAddOn>
|
||||
<b:Button ui:field="showPrivateLongLinkButton"
|
||||
type="LINK" addStyleNames="margin-left-5">Show as Long URL</b:Button>
|
||||
type="LINK" addStyleNames="{style.margin-left-25}">Show as Long URL</b:Button>
|
||||
</b:Controls>
|
||||
|
||||
</b:ControlGroup>
|
||||
|
@ -114,12 +112,14 @@
|
|||
<g:VerticalPanel ui:field="filedEnableDisableSharing"
|
||||
addStyleNames="{style.margin-bottom-20}">
|
||||
<g:HorizontalPanel>
|
||||
<b:Label type="INFO" addStyleNames="{style.font-size-14}">Link shareable with
|
||||
<b:Label type="INFO" addStyleNames="sharelabel">With
|
||||
everyone</b:Label>
|
||||
</g:HorizontalPanel>
|
||||
<g:VerticalPanel
|
||||
addStyleNames="{style.margin-left-5}">
|
||||
<g:Label ui:field="labelLinkSharing"></g:Label>
|
||||
<g:Label ui:field="labelLinkSharing">Anyone with
|
||||
this link can access it. No
|
||||
login is required</g:Label>
|
||||
</g:VerticalPanel>
|
||||
</g:VerticalPanel>
|
||||
|
||||
|
@ -127,17 +127,8 @@
|
|||
<b:Fieldset ui:field="fieldSetPublic">
|
||||
<b:ControlGroup ui:field="cgPublicLink"
|
||||
addStyleNames="my-control-group">
|
||||
<b:Well ui:field="alertFolderPublicLink" visible="true">By sharing
|
||||
the following Public
|
||||
Link, you will
|
||||
enact anyone
|
||||
with the
|
||||
link to
|
||||
view
|
||||
the
|
||||
product. No login required</b:Well>
|
||||
<b:Well ui:field="alertFilePublicLink" visible="true">Anyone with
|
||||
this link can access it, no login is required.</b:Well>
|
||||
<!-- <b:Well ui:field="alertFilePublicLink" visible="true">Anyone with -->
|
||||
<!-- this link can access it, no login is required.</b:Well> -->
|
||||
<b:ControlLabel>Open Link</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:InputAddOn prependIcon="GLOBE"
|
||||
|
@ -150,7 +141,7 @@
|
|||
</b:Tooltip>
|
||||
</b:InputAddOn>
|
||||
<b:Button ui:field="showPublicLongLinkButton" type="LINK"
|
||||
addStyleNames="margin-left-5">Show as Long URL</b:Button>
|
||||
addStyleNames="{style.margin-left-25}">Show as Long URL</b:Button>
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShare
|
|||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.images.ImageView;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.PageHeader;
|
||||
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||
import com.github.gwtbootstrap.client.ui.Thumbnails;
|
||||
|
@ -80,14 +80,17 @@ public class ConcessioneView extends Composite {
|
|||
|
||||
private CustomFlexTable customTable = new CustomFlexTable();
|
||||
|
||||
public ConcessioneView() {
|
||||
private GeoNaItemRef geonaItemRef;
|
||||
|
||||
private ConcessioneView() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
pageViewDetails.getElement().setId("page-view-details");
|
||||
}
|
||||
|
||||
public ConcessioneView(ConcessioneDV concessioneDV) {
|
||||
public ConcessioneView(GeoNaItemRef item, ConcessioneDV concessioneDV) {
|
||||
this();
|
||||
this.concessioneDV = concessioneDV;
|
||||
this.geonaItemRef = item;
|
||||
|
||||
titolo.setText(concessioneDV.getNome());
|
||||
introduzione.setText(concessioneDV.getIntroduzione());
|
||||
|
@ -164,13 +167,7 @@ public class ConcessioneView extends Composite {
|
|||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
DialogShareableLink dg = new DialogShareableLink(null, null);
|
||||
Modal modal = new Modal(true);
|
||||
modal.setTitle("Share with...");
|
||||
modal.setCloseVisible(true);
|
||||
modal.hide(false);
|
||||
modal.add(dg);
|
||||
modal.show();
|
||||
DialogShareableLink dg = new DialogShareableLink(geonaItemRef, null);
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.server;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -11,6 +13,7 @@ import org.gcube.application.geoportal.managers.ManagerFactory;
|
|||
import org.gcube.application.geoportal.model.Record;
|
||||
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
||||
import org.gcube.application.geoportal.model.content.UploadedImage;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
|
||||
|
@ -31,6 +34,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
|
|||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
|
||||
import org.gcube.spatial.data.geoutility.bean.LayerStyles;
|
||||
import org.gcube.spatial.data.geoutility.bean.LayerZAxis;
|
||||
|
@ -401,7 +405,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE,
|
||||
item.getItemType());
|
||||
|
||||
item.setRestrictedLink(new PublicLink(link, null));
|
||||
String shortUrl = getShortUrl(link);
|
||||
item.setRestrictedLink(new PublicLink(link, shortUrl));
|
||||
|
||||
//Open Link
|
||||
link = String.format("%s?%s=%s&%s=%s",
|
||||
|
@ -411,20 +416,43 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE,
|
||||
item.getItemType());
|
||||
|
||||
item.setOpenLink(new PublicLink(link, null));
|
||||
shortUrl = getShortUrl(link);
|
||||
item.setOpenLink(new PublicLink(link, shortUrl));
|
||||
|
||||
LOG.info("returning: " + item);
|
||||
return item;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on getPublicLinksFor for: " + item, e);
|
||||
throw new Exception("Share link not available for this item. Try later or contact the support");
|
||||
throw new Exception("Share link not available for this item. Try later or contact the support. Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortUrl(String longUrl) throws Exception {
|
||||
LOG.info("getShortUrl called for " + longUrl);
|
||||
|
||||
if(longUrl==null)
|
||||
return longUrl;
|
||||
|
||||
UrlShortener shortener = SessionUtil.getUrlShortener(this.getThreadLocalRequest());
|
||||
|
||||
try {
|
||||
|
||||
if (shortener != null && shortener.isAvailable()) {
|
||||
String toShort = longUrl;
|
||||
return shortener.shorten(toShort);
|
||||
}
|
||||
return longUrl;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on shortening the longURL "+longUrl, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSessionExpired() throws Exception {
|
||||
return SessionUtil.isSessionExpired(this.getThreadLocalRequest());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.server.util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
|
@ -30,6 +32,8 @@ public class SessionUtil {
|
|||
|
||||
/** The log. */
|
||||
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
|
||||
|
||||
public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
|
||||
|
||||
/**
|
||||
* Checks if is into portal.
|
||||
|
@ -117,4 +121,30 @@ public class SessionUtil {
|
|||
return gm.getGroup(groupId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the url shortener.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @return the url shortener
|
||||
*/
|
||||
public static UrlShortener getUrlShortener(HttpServletRequest httpServletRequest) {
|
||||
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
UrlShortener shortener = null;
|
||||
try {
|
||||
shortener = (UrlShortener) session.getAttribute(URL_SHORTENER_SERVICE);
|
||||
|
||||
if (shortener == null) {
|
||||
shortener = new UrlShortener();
|
||||
session.setAttribute(URL_SHORTENER_SERVICE, shortener);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error occurred when instancing the "+UrlShortener.class.getSimpleName(), e);
|
||||
}
|
||||
|
||||
return shortener;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
content: "✖";
|
||||
}
|
||||
|
||||
.data-click-img{
|
||||
.data-click-img {
|
||||
max-width: 395px;
|
||||
}
|
||||
|
||||
|
@ -78,23 +78,23 @@
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
#page-view-details{
|
||||
#page-view-details {
|
||||
margin: 10px;
|
||||
text-rendering: optimizelegibility;
|
||||
font-family: Lato, 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
#page-view-details > h1 {
|
||||
#page-view-details>h1 {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
#page-view-details > p {
|
||||
#page-view-details>p {
|
||||
font-size: 24px;
|
||||
padding: 10px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
#page-view-details .my-custom-flex-table{
|
||||
#page-view-details .my-custom-flex-table {
|
||||
margin-left: 20px;
|
||||
margin-right: 40px;
|
||||
font-size: 14px;
|
||||
|
@ -104,10 +104,10 @@
|
|||
padding: 5px;
|
||||
}
|
||||
|
||||
#page-view-details .my-custom-flex-table tbody tr > td:first-child {
|
||||
#page-view-details .my-custom-flex-table tbody tr>td:first-child {
|
||||
color: gray;
|
||||
font-weight: bold;
|
||||
width: 200px;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.ol-mouse-position {
|
||||
|
@ -121,11 +121,38 @@
|
|||
margin: 1px;
|
||||
will-change: contents, width;
|
||||
transition: all .25s;
|
||||
background: rgba(0,60,136,.5);
|
||||
background: rgba(0, 60, 136, .5);
|
||||
border-radius: 2px;
|
||||
padding-left: 2px;
|
||||
padding-right: 2px;
|
||||
padding-bottom: 1px;
|
||||
padding-top: 1px;
|
||||
|
||||
}
|
||||
|
||||
.my-control-group .controls {
|
||||
margin-left: 70px !important;
|
||||
}
|
||||
|
||||
.my-control-group .control-label {
|
||||
width: 100px !important;
|
||||
text-align: left !important;
|
||||
padding-left: 10px !important;
|
||||
}
|
||||
|
||||
.my-control-group .add-on {
|
||||
width: 20px !important;
|
||||
}
|
||||
|
||||
.my-control-group .gwt-TextBox {
|
||||
width: 305px !important;
|
||||
}
|
||||
|
||||
.my-control-group .gwt-TextBox:hover {
|
||||
cursor: text !important;
|
||||
}
|
||||
|
||||
.sharelabel {
|
||||
font-size: 14px !important;
|
||||
padding-top: 4px !important;
|
||||
margin-bottom: 5px;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||
|
||||
public class TestShortener {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
String toShort = "https://next.d4science.org/group/nextnext/geona-data-viewer?gid=20&git=concessione";
|
||||
String[] splitted = toShort.split("\\?");
|
||||
String link = toShort;
|
||||
// if (splitted.length > 1) {
|
||||
// String encodedQuery = splitted[1];
|
||||
// try {
|
||||
// encodedQuery = URLEncoder.encode(splitted[1], "UTF-8");
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// e.printStackTrace();
|
||||
//
|
||||
// }
|
||||
// link = String.format("%s?%s", splitted[0], encodedQuery);
|
||||
// }
|
||||
// ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||
// UrlShortener shortener = new UrlShortener();
|
||||
// System.out.println(shortener.shorten(link));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue