in progress on Share With facility

This commit is contained in:
Francesco Mangiacrapa 2020-11-17 12:07:11 +01:00
parent cb132e93d5
commit e6f232298e
17 changed files with 1092 additions and 24 deletions

View File

@ -6,6 +6,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEven
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
@ -150,7 +151,8 @@ public class GeoportalDataViewer implements EntryPoint {
Window.alert("Missing parameter "+GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE +" (GeoNa Data Type) where to search the item id: "+paramGeonaItemID);
return;
}
eventBus.fireEvent(new ShowDetailsEvent(paramGeonaItemType, new Long(paramGeonaItemID), null, null));
GeoNaItemRef gir = new GeoNaItemRef(new Long(paramGeonaItemID), paramGeonaItemType);
eventBus.fireEvent(new ShowDetailsEvent(gir, null, null));
}
}

View File

@ -2,8 +2,9 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -21,7 +22,7 @@ public interface GeoportalDataViewerService extends RemoteService {
GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception;
List<GeoNaDataObject> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX,
List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX,
int maxWFSFeature, double zoomLevel);
ConcessioneDV getConcessioneForId(Long id) throws Exception;
@ -48,4 +49,6 @@ public interface GeoportalDataViewerService extends RemoteService {
*/
List<UploadedImageDV> getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception;
GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception;
}

View File

@ -2,8 +2,9 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -35,7 +36,7 @@ public interface GeoportalDataViewerServiceAsync {
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
void getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel,
AsyncCallback<List<GeoNaDataObject>> callback);
AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
void getConcessioneForId(Long id, AsyncCallback<ConcessioneDV> callback);
@ -46,4 +47,6 @@ public interface GeoportalDataViewerServiceAsync {
void getGeoNaDataViewProfile(AsyncCallback<GeoNaDataViewerProfile> callback);
void getUploadedImagesForId(String itemType, Long id, int maxImages, AsyncCallback<List<UploadedImageDV>> callback);
void getPublicLinksFor(GeoNaItemRef item, AsyncCallback<GeoNaItemRef> asyncCallback);
}

View File

@ -15,7 +15,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEven
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
@ -129,14 +129,14 @@ public class LayerManager {
GWT.log("Bounds is: "+mapBBOX);
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaDataObject>>() {
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(List<GeoNaDataObject> listGeonaDataObjects) {
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
@ -151,7 +151,7 @@ public class LayerManager {
FeatureRow feature = null;
//TODO SWTCH FOR EARCH ITEM TYPE
for (GeoNaDataObject geoNaDataObject : listGeonaDataObjects) {
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
List<FeatureRow> features = geoNaDataObject.getFeatures();
//USING ONLY THE FIRST FEATURE IN THE LIST

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import com.google.gwt.event.shared.GwtEvent;
@ -36,6 +37,21 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
}
/**
* Instantiates a new show details event.
*
* @param gir the gir
* @param itemName the item name
* @param featureRow the feature row
*/
public ShowDetailsEvent(GeoNaItemRef gir, String itemName, FeatureRow featureRow) {
this.geonaItemType = gir.getItemType();
this.geonaID = gir.getItemId();
this.itemName = itemName;
this.featureRow = featureRow;
}
/**
* Gets the associated type.
*
@ -101,6 +117,16 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
public void setItemName(String itemName) {
this.itemName = itemName;
}
/**
* Gets the geona item ref.
*
* @return the geona item ref
*/
public GeoNaItemRef getGeonaItemRef() {
return new GeoNaItemRef(geonaID, geonaItemType);
}

View File

@ -13,4 +13,7 @@ public interface Images extends ClientBundle {
@Source("map-marker-icon.png")
ImageResource mapMarkerIcon();
@Source("icon_share.png")
ImageResource shareIcon();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

View File

@ -0,0 +1,472 @@
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;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.Fieldset;
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;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class DialogShareableLink.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 19, 2019
*/
public class DialogShareableLink extends Composite {
private static DialogShareableLinkUiBinder uiBinder = GWT.create(DialogShareableLinkUiBinder.class);
private Modal modalBox = new Modal();
@UiField
ControlGroup cgPublicLink;
@UiField
ControlGroup cgPrivateLongLink;
@UiField
ControlGroup cgPublicLongLink;
@UiField
TextBox textPublicLink;
@UiField
TextBox textPrivateLink;
@UiField
TextBox textPrivateLongLink;
@UiField
TextBox textPublicLongLink;
@UiField
Alert errorAlert;
@UiField
Alert actionAlert;
@UiField
Well alertFilePublicLink;
@UiField
Well alertFolderPublicLink;
@UiField
Fieldset fieldSetPrivate;
@UiField
Fieldset fieldSetPublic;
@UiField
VerticalPanel fieldPrivateSharing;
// @UiField
// VerticalPanel filedEnableDisableSharing;
@UiField
Label labelLinkSharing;
@UiField
Button privateLinkCopyButton;
@UiField
Button privateLongLinkCopyButton;
@UiField
Button publicLinkCopyButton;
@UiField
Button publicLongLinkCopyButton;
@UiField
Well wellPrivateLinkDescription;
@UiField
Button showPrivateLongLinkButton;
@UiField
Button showPublicLongLinkButton;
// @UiField
// HTMLPanel panelFieldsContainer;
private GeoNaItemRef geonItemRef;
private String fileVersion;
private boolean itemIsPublicStatus;
private PublicLink openPublicLink;
private PublicLink restrictedPublicLink;
private final String privateShareToFileDescription = "By sharing the following Private Link "
+ "with your coworkers, you will enact the users of the group the folder is shared with, "
+ "to access the file and the shared folder content. Login required";
/**
* The Interface DialogShareableLinkUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 19, 2019
*/
interface DialogShareableLinkUiBinder extends UiBinder<Widget, DialogShareableLink> {
}
/**
* Instantiates a new dialog shareable link.
*
* @param item the item
* @param version the version
*/
public DialogShareableLink(GeoNaItemRef item, String version) {
initWidget(uiBinder.createAndBindUi(this));
this.geonItemRef = item;
this.fileVersion = version;
this.actionAlert.setAnimation(true);
showShareableLinkOptions(item, version);
//getElement().setClassName("gwt-DialogBoxNew");
String title = "Share";
try {
title+= " "+StringUtil.ellipsize(item.getItemName(), 15);
} catch (Exception e) {
}
modalBox.setTitle(title);
ModalFooter modalFooter = new ModalFooter();
final Button buttClose = new Button("Close");
modalFooter.add(buttClose);
buttClose.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
modalBox.hide();
}
});
addEvents();
textPrivateLink.setId(Random.nextInt()+Random.nextInt()+"");
textPrivateLongLink.setId(Random.nextInt()+Random.nextInt()+"");
textPublicLink.setId(Random.nextInt()+Random.nextInt()+"");
textPublicLongLink.setId(Random.nextInt()+Random.nextInt()+"");
modalBox.add(this);
modalBox.add(modalFooter);
modalBox.show();
}
/**
* Adds the events.
*/
private void addEvents() {
showPrivateLongLinkButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
showPrivateLongLinkButton.setVisible(false);
cgPrivateLongLink.setVisible(true);
textPrivateLongLink.setText(restrictedPublicLink.getCompleteURL());
}
});
showPublicLongLinkButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if(openPublicLink!=null && openPublicLink.getCompleteURL()!=null) {
showPublicLongLinkButton.setVisible(false);
cgPublicLongLink.setVisible(true);
textPublicLongLink.setText(openPublicLink.getCompleteURL());
}else {
textPublicLongLink.setText("Not available");
showPublicLongLinkButton.setText("Not available");
showPublicLongLinkButton.addStyleName("href-disabled");
publicLongLinkCopyButton.setEnabled(false);
// showPublicLongLinkButton.setVisible(false);
disableTextBox(textPublicLongLink);
}
}
});
privateLinkCopyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copied to clipboard");
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() {
@Override
public void run() {
Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get());
}
};
timer.schedule(1000);
copyToClipboard(textPrivateLink.getId());
}
});
privateLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
privateLongLinkCopyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement();
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() {
@Override
public void run() {
Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get());
}
};
timer.schedule(1000);
copyToClipboard(textPrivateLongLink.getId());
}
});
privateLongLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
publicLinkCopyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement();
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() {
@Override
public void run() {
Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get());
}
};
timer.schedule(1000);
copyToClipboard(textPublicLink.getId());
}
});
publicLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
publicLongLinkCopyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement();
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() {
@Override
public void run() {
Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get());
}
};
timer.schedule(1000);
copyToClipboard(textPublicLongLink.getId());
}
});
publicLongLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
textPrivateLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
textPrivateLink.selectAll();
}
});
textPrivateLongLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
textPrivateLongLink.selectAll();
}
});
textPublicLongLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
textPublicLongLink.selectAll();
}
});
}
/**
* Copy to clipboard.
*
* @param myDivId the my div id
*/
private native void copyToClipboard(String myDivId) /*-{
var copyText = $doc.getElementById(myDivId);
console.log("text copied is :"+copyText.value);
copyText.select();
//For mobile devices
copyText.setSelectionRange(0, 99999);
$doc.execCommand("copy");
//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) {
GeoportalDataViewerServiceAsync.Util.getInstance().getPublicLinksFor(item,
new AsyncCallback<GeoNaItemRef>() {
@Override
public void onSuccess(GeoNaItemRef itemReferences) {
openPublicLink = itemReferences.getOpenLink();
restrictedPublicLink = itemReferences.getRestrictedLink();
String toURL = openPublicLink.getShortURL() != null && !openPublicLink.getShortURL().isEmpty()
? openPublicLink.getShortURL()
: openPublicLink.getCompleteURL();
toTextBox.setValue(toURL);
}
@Override
public void onFailure(Throwable caught) {
openPublicLink = null;
disableTextBox(toTextBox);
showError(caught.getMessage());
}
});
}
/**
* Disable text box.
*
* @param textBox the text box
*/
private void disableTextBox(TextBox textBox) {
textBox.setEnabled(false);
textBox.getElement().getStyle().setOpacity(0.3);
}
/**
* Show error.
*
* @param msg the msg
*/
private void showError(String msg) {
errorAlert.setVisible(true);
errorAlert.setText(msg);
}
/**
* Show message.
*
* @param msg the msg
* @param visible the visible
*/
private void showMessage(String msg, boolean visible) {
actionAlert.setVisible(visible);
actionAlert.setText(msg==null?"":msg);
}
}

View File

@ -0,0 +1,178 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.back-color-info {
background-color: #fafaff !important;
}
.margin-bottom-20 {
margin-bottom: 20px;
}
.padding-left-10 {
padding-left: 10px;
}
.margin-left-5 {
margin-left: 5px;
}
.text-bold {
font-weight: bold;
}
.not-active {
pointer-events: none;
cursor: default;
opacity: .5;
padding-left: 10px;
}
.font-size-14 {
font-size: 14px;
}
.to-top-alignment {
vertical-align: top;
padding-top: 0px !important;
}
.no-border {
border: 0px;
}
</ui:style>
<g:HTMLPanel>
<b:Form type="HORIZONTAL">
<b:Alert ui:field="actionAlert" close="false" type="INFO"
visible="false">
<b:Icon type="ROTATE_RIGHT" spin="true" />
</b:Alert>
<g:VerticalPanel ui:field="fieldPrivateSharing"
addStyleNames="{style.margin-bottom-20}">
<g:HorizontalPanel>
<b:Label type="INFO" addStyleNames="{style.font-size-14}">Link shareable 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:VerticalPanel>
</g:VerticalPanel>
<b:Fieldset ui:field="fieldSetPrivate"
styleName="{style.noBorder}">
<g:HTMLPanel>
<!-- <b:Legend>sharing....</b:Legend> -->
<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:ControlLabel>Restricted Link</b:ControlLabel>
<b:Controls>
<b:InputAddOn prependIcon="LINK"
addStyleNames="my-prepend-width">
<b:TextBox ui:field="textPrivateLink" readOnly="true">
</b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY" ui:field="privateLinkCopyButton"
type="PRIMARY"></b:Button>
</b:Tooltip>
</b:InputAddOn>
<b:Button ui:field="showPrivateLongLinkButton"
type="LINK" addStyleNames="margin-left-5">Show as Long URL</b:Button>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup addStyleNames="my-control-group"
ui:field="cgPrivateLongLink" visible="false">
<b:ControlLabel></b:ControlLabel>
<b:Controls>
<b:InputAddOn prependIcon="LINK"
addStyleNames="my-prepend-width">
<b:TextBox ui:field="textPrivateLongLink"
readOnly="true">
</b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY"
ui:field="privateLongLinkCopyButton" type="PRIMARY"></b:Button>
</b:Tooltip>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</g:HTMLPanel>
</b:Fieldset>
<g:VerticalPanel ui:field="filedEnableDisableSharing"
addStyleNames="{style.margin-bottom-20}">
<g:HorizontalPanel>
<b:Label type="INFO" addStyleNames="{style.font-size-14}">Link shareable with
everyone</b:Label>
</g:HorizontalPanel>
<g:VerticalPanel
addStyleNames="{style.margin-left-5}">
<g:Label ui:field="labelLinkSharing"></g:Label>
</g:VerticalPanel>
</g:VerticalPanel>
<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:ControlLabel>Open Link</b:ControlLabel>
<b:Controls>
<b:InputAddOn prependIcon="GLOBE"
addStyleNames="my-prepend-width">
<b:TextBox ui:field="textPublicLink" readOnly="true">
</b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY" ui:field="publicLinkCopyButton"
type="PRIMARY"></b:Button>
</b:Tooltip>
</b:InputAddOn>
<b:Button ui:field="showPublicLongLinkButton" type="LINK"
addStyleNames="margin-left-5">Show as Long URL</b:Button>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup addStyleNames="my-control-group"
ui:field="cgPublicLongLink" visible="false">
<b:ControlLabel></b:ControlLabel>
<b:Controls>
<b:InputAddOn prependIcon="GLOBE"
addStyleNames="my-prepend-width">
<b:TextBox ui:field="textPublicLongLink"
readOnly="true">
</b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY"
ui:field="publicLongLinkCopyButton" type="PRIMARY"></b:Button>
</b:Tooltip>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</b:Fieldset>
<b:Alert close="false" ui:field="errorAlert" type="ERROR"
visible="false"></b:Alert>
</b:Form>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink;
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;
@ -13,10 +14,16 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerCo
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;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -61,6 +68,11 @@ public class ConcessioneView extends Composite {
@UiField
HTMLPanel piantaFineScavoPanel;
@UiField
HTMLPanel sharePanel;
Button shareButton;
private ConcessioneDV concessioneDV;
@ -144,7 +156,26 @@ public class ConcessioneView extends Composite {
customTable.addNextKeyValue("Titolare Copyright", concessioneDV.getTitolareCopyright());
}
shareButton = new Button("Share");
shareButton.setType(ButtonType.LINK);
shareButton.setIcon(IconType.SHARE);
shareButton.addClickHandler(new ClickHandler() {
@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();
}
});
sharePanel.add(shareButton);
concessioniPanel.add(customTable);
@ -154,6 +185,8 @@ public class ConcessioneView extends Composite {
addUploadedImages();
addPosizionamentoAreaIndagine();
addPiantaFineScavo();
}
private void addPosizionamentoAreaIndagine() {

View File

@ -11,8 +11,16 @@
.font-size-h1-22 h1 {
font-size: 22px;
}
.align-to-right {
right: 20px;
position: absolute;
}
</ui:style>
<g:HTMLPanel ui:field="pageViewDetails">
<g:HTMLPanel ui:field="sharePanel"
addStyleNames="{style.align-to-right}">
</g:HTMLPanel>
<b:PageHeader ui:field="titolo"></b:PageHeader>
<b:Paragraph ui:field="introduzione"></b:Paragraph>
<g:HorizontalPanel>

View File

@ -11,13 +11,16 @@ 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.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.PublicLink;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
@ -122,14 +125,14 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @return the data result
*/
@Override
public List<GeoNaDataObject> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX,
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX,
int maxWFSFeature, double zoomLevel) {
LOG.info("getDataResult called");
List<GeoNaDataObject> listDAO = new ArrayList<GeoNaDataObject>(layerObjects.size());
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
for (LayerObject layerObject : layerObjects) {
GeoNaDataObject geoDAO = new GeoNaDataObject();
GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX, maxWFSFeature);
LOG.debug("For layer name: "+layerObject.getLayerItem().getName() +" got features: "+features);
geoDAO.setFeatures(features);
@ -363,7 +366,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
*/
@Override
public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception{
LOG.info("Called getAvailableLayers");
LOG.info("getGeoNaDataViewProfile called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app");
@ -373,4 +376,55 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
@Override
public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception {
LOG.info("getPublicLinksFor called for: " + item);
try {
if (item == null)
throw new Exception("Bad request, the item is null");
if(item.getItemId()==null)
throw new Exception("Bad request, the item id is null");
if(item.getItemType()==null)
throw new Exception("Bad request, the item type is null");
GeoNaDataViewerProfile geonaDataProfile = getGeoNaDataViewProfile();
//Restricted Link
String link = String.format("%s?%s=%s&%s=%s",
geonaDataProfile.getRestrictedPortletURL(),
GeoportalDataViewerConstants.GET_GEONA_ITEM_ID,
item.getItemId(),
GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE,
item.getItemType());
item.setRestrictedLink(new PublicLink(link, null));
//Open Link
link = String.format("%s?%s=%s&%s=%s",
geonaDataProfile.getOpenPortletURL(),
GeoportalDataViewerConstants.GET_GEONA_ITEM_ID,
item.getItemId(),
GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE,
item.getItemType());
item.setOpenLink(new PublicLink(link, null));
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");
}
}
public boolean isSessionExpired() throws Exception {
return SessionUtil.isSessionExpired(this.getThreadLocalRequest());
}
}

View File

@ -45,6 +45,20 @@ public class SessionUtil {
return false;
}
}
/**
* Checks if is session expired.
*
* @param httpServletRequest
* the http servlet request
* @return true, if is session expired
* @throws Exception
* the exception
*/
public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception {
LOG.trace("workspace session validating...");
return PortalContext.getConfiguration().getCurrentUser(httpServletRequest) == null;
}
/**
* Retrieve the current user by using the portal manager.

View File

@ -0,0 +1,156 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
/**
* The Class GeoNaItemRef.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 17, 2020
*/
public class GeoNaItemRef implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7021431511279022193L;
private Long itemId;
private String itemType;
private String itemName;
private PublicLink restrictedLink;
private PublicLink openLink;
/**
* Instantiates a new geo na object.
*/
public GeoNaItemRef() {
}
/**
* Instantiates a new geo na object.
*
* @param itemId the item id
* @param itemType the item type
*/
public GeoNaItemRef(Long itemId, String itemType) {
super();
this.itemId = itemId;
this.itemType = itemType;
}
/**
* Gets the item id.
*
* @return the item id
*/
public Long getItemId() {
return itemId;
}
/**
* Sets the item id.
*
* @param itemId the new item id
*/
public void setItemId(Long itemId) {
this.itemId = itemId;
}
/**
* Gets the item type.
*
* @return the item type
*/
public String getItemType() {
return itemType;
}
/**
* Sets the item type.
*
* @param itemType the new item type
*/
public void setItemType(String itemType) {
this.itemType = itemType;
}
/**
* Gets the item name.
*
* @return the item name
*/
public String getItemName() {
return itemName;
}
/**
* Sets the item name.
*
* @param itemName the new item name
*/
public void setItemName(String itemName) {
this.itemName = itemName;
}
/**
* Gets the restricted link.
*
* @return the restricted link
*/
public PublicLink getRestrictedLink() {
return restrictedLink;
}
/**
* Sets the restricted link.
*
* @param restrictedLink the new restricted link
*/
public void setRestrictedLink(PublicLink restrictedLink) {
this.restrictedLink = restrictedLink;
}
/**
* Gets the open link.
*
* @return the open link
*/
public PublicLink getOpenLink() {
return openLink;
}
/**
* Sets the open link.
*
* @param openLink the new open link
*/
public void setOpenLink(PublicLink openLink) {
this.openLink = openLink;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeoNaItemRef [itemId=");
builder.append(itemId);
builder.append(", itemType=");
builder.append(itemType);
builder.append(", itemName=");
builder.append(itemName);
builder.append(", restrictedLink=");
builder.append(restrictedLink);
builder.append(", openLink=");
builder.append(openLink);
builder.append("]");
return builder.toString();
}
}

View File

@ -9,13 +9,13 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
/**
* The Class GeoNaDataObject.
* The Class GeoNaSpatialQueryResult.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 13, 2020
* Nov 17, 2020
*/
public class GeoNaDataObject implements Serializable {
public class GeoNaSpatialQueryResult implements Serializable {
/**
*
@ -29,7 +29,7 @@ public class GeoNaDataObject implements Serializable {
/**
* Instantiates a new geo na data object.
*/
public GeoNaDataObject() {
public GeoNaSpatialQueryResult() {
}
@ -87,18 +87,15 @@ public class GeoNaDataObject implements Serializable {
this.mapImages = mapImages;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeoNaDataObject [features=");
builder.append("GeoNaSpatialQueryResult [features=");
builder.append(features);
builder.append(", sourceLayerObject=");
builder.append(sourceLayerObject);
builder.append(", mapImages=");
builder.append(mapImages);
builder.append("]");
return builder.toString();
}

View File

@ -0,0 +1,95 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
/**
* The Class PublicLink.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Sep 13, 2016
*/
public class PublicLink implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8157172818802297440L;
private String completeURL;
private String shortURL;
/**
* Instantiates a new public link.
*/
public PublicLink() {
}
/**
* Instantiates a new public link.
*
* @param completeURL the complete url
* @param shortURL the short url
*/
public PublicLink(String completeURL, String shortURL) {
super();
this.completeURL = completeURL;
this.shortURL = shortURL;
}
/**
* Gets the complete url.
*
* @return the completeURL
*/
public String getCompleteURL() {
return completeURL;
}
/**
* Gets the short url.
*
* @return the shortURL
*/
public String getShortURL() {
return shortURL;
}
/**
* Sets the complete url.
*
* @param completeURL the completeURL to set
*/
public void setCompleteURL(String completeURL) {
this.completeURL = completeURL;
}
/**
* Sets the short url.
*
* @param shortURL the shortURL to set
*/
public void setShortURL(String shortURL) {
this.shortURL = shortURL;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("PublicLink [completeURL=");
builder.append(completeURL);
builder.append(", shortURL=");
builder.append(shortURL);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,24 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.shared;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Sep 4, 2013
*
*/
public class SessionExpiredException extends Exception{
/**
*
*/
private static final long serialVersionUID = 8423680645305738442L;
/**
*
*/
public SessionExpiredException() {
super("Session expired");
}
}