Added GUI classes for building ProjectViewer

This commit is contained in:
Francesco Mangiacrapa 2023-04-27 11:12:46 +02:00
parent 0c6c8cc959
commit f194a0b8a1
24 changed files with 1309 additions and 269 deletions

View File

@ -0,0 +1,7 @@
<root>
<facet id="jst.jaxrs">
<node name="libprov">
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
</node>
</facet>
</root>

View File

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

View File

@ -4,6 +4,8 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v0.1.0-SNAPSHOT]
## [v1.0.0-SNAPSHOT]
#### First release
- Created and integrated the widget [#25015]

41
pom.xml
View File

@ -8,7 +8,7 @@
<groupId>org.gcube.portlets.widgets.gdvw</groupId>
<artifactId>geoportal-data-viewer-widget</artifactId>
<packaging>jar</packaging>
<version>0.1.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
<name>org.gcube.portlets.widgets.gdvw.geoportal_data_viewer_widget</name>
<properties>
@ -20,6 +20,12 @@
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
</scm>
<developers>
<developer>
<name>Francesco Mangiacrapa</name>
@ -32,6 +38,18 @@
</developer>
</developers>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.7.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
@ -51,6 +69,27 @@
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.tdesjardins</groupId>
<artifactId>gwt-ol3</artifactId>
<version>8.1.0-gwt2_9</version>
</dependency>
<dependency>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-mapper</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -1,27 +1,19 @@
package org.gcube.portlets.widgets.gdvw.client;
import org.gcube.portlets.widgets.gdvw.shared.FieldVerifier;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.portlets.widgets.gdvw.client.project.ProjectViewer;
import com.google.gwt.core.client.EntryPoint;
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.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.core.client.ScriptInjector;
/**
* Entry point classes define <code>onModuleLoad()</code>.
* The Class GeoportalDataViewerWidget.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 27, 2023
*/
public class GeoportalDataViewerWidget implements EntryPoint {
public class GeoportalDataViewerWidget {
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
@ -29,119 +21,27 @@ public class GeoportalDataViewerWidget implements EntryPoint {
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network " + "connection and try again.";
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
private final GeoportalDataViewerWidgetServiceAsync geoportalDataViewerWidgetService = GWT
.create(GeoportalDataViewerWidgetService.class);
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final Button sendButton = new Button("Send");
final TextBox nameField = new TextBox();
nameField.setText("GWT User");
final Label errorLabel = new Label();
public GeoportalDataViewerWidget() {
// We can add style names to widgets
sendButton.addStyleName("sendButton");
ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js")
.setWindow(ScriptInjector.TOP_WINDOW).inject();
// Add the nameField and sendButton to the RootPanel
// Use RootPanel.get() to get the entire body element
RootPanel.get("nameFieldContainer").add(nameField);
RootPanel.get("sendButtonContainer").add(sendButton);
RootPanel.get("errorLabelContainer").add(errorLabel);
}
// Focus the cursor on the name field when the app loads
nameField.setFocus(true);
nameField.selectAll();
/**
* Gets the project viewer.
*
* @param projectView the project view
* @return the project viewer
*/
public ProjectViewer getProjectViewer(ProjectView projectView) {
// Create the popup dialog box
final DialogBox dialogBox = new DialogBox();
dialogBox.setText("Remote Procedure Call");
dialogBox.setAnimationEnabled(true);
final Button closeButton = new Button("Close");
// We can set the id of a widget by accessing its Element
closeButton.getElement().setId("closeButton");
final Label textToServerLabel = new Label();
final HTML serverResponseLabel = new HTML();
VerticalPanel dialogVPanel = new VerticalPanel();
dialogVPanel.addStyleName("dialogVPanel");
dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
dialogVPanel.add(textToServerLabel);
dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
dialogVPanel.add(serverResponseLabel);
dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
dialogVPanel.add(closeButton);
dialogBox.setWidget(dialogVPanel);
// Add a handler to close the DialogBox
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
sendButton.setEnabled(true);
sendButton.setFocus(true);
}
});
// Create a handler for the sendButton and nameField
class MyHandler implements ClickHandler, KeyUpHandler {
/**
* Fired when the user clicks on the sendButton.
*/
public void onClick(ClickEvent event) {
sendNameToServer();
}
/**
* Fired when the user types in the nameField.
*/
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
sendNameToServer();
}
}
/**
* Send the name from the nameField to the server and wait for a response.
*/
private void sendNameToServer() {
// First, we validate the input.
errorLabel.setText("");
String textToServer = nameField.getText();
if (!FieldVerifier.isValidName(textToServer)) {
errorLabel.setText("Please enter at least four characters");
return;
}
// Then, we send the input to the server.
sendButton.setEnabled(false);
textToServerLabel.setText(textToServer);
serverResponseLabel.setText("");
greetingService.greetServer(textToServer, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
dialogBox.setText("Remote Procedure Call - Failure");
serverResponseLabel.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(String result) {
dialogBox.setText("Remote Procedure Call");
serverResponseLabel.removeStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});
}
}
// Add a handler to send the name to the server
MyHandler handler = new MyHandler();
sendButton.addClickHandler(handler);
nameField.addKeyUpHandler(handler);
return new ProjectViewer(projectView);
}
}

View File

@ -0,0 +1,125 @@
package org.gcube.portlets.widgets.gdvw.client;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import com.google.gwt.dom.client.Element;
import com.google.gwt.i18n.client.DateTimeFormat;
/**
* The Class GeoportalDataViewerWidgetConstants.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 27, 2023
*/
public class GeoportalDataViewerWidgetConstants {
public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getFormat("dd MMMM yyyy");
public static DateTimeFormat DT_FORMAT = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT);
/**
* Prints the.
*
* @param msg the msg
*/
public static native void printJs(String msg)/*-{
//console.log("js console: " + msg);
}-*/;
/**
* Prints the.
*
* @param object the object
*/
public static native void printJsObj(Object object)/*-{
//console.log("js obj: " + JSON.stringify(object, null, 4));
}-*/;
/**
* Prints the.
*
* @param object the object
* @return the string
*/
public static native String toJsonObj(Object object)/*-{
return JSON.stringify(object);
}-*/;
/**
* Json to HTML.
*
* @param jsonTxt the json txt
* @return the string
*/
public static native String jsonToTableHTML(String jsonTxt)/*-{
try {
var jsonObj = JSON.parse(jsonTxt);
if (jsonObj.length == undefined)
jsonObj = [ jsonObj ]
//console.log(jsonObj.length)
// EXTRACT VALUE FOR HTML HEADER.
var col = [];
for (var i = 0; i < jsonObj.length; i++) {
for ( var key in jsonObj[i]) {
//console.log('key json' +key)
if (col.indexOf(key) === -1) {
col.push(key);
}
}
}
// CREATE DYNAMIC TABLE.
var table = document.createElement("table");
try {
table.classList.add("my-html-table");
} catch (e) {
console.log('invalid css add', e);
}
// ADD JSON DATA TO THE TABLE AS ROWS.
for (var i = 0; i < col.length; i++) {
tr = table.insertRow(-1);
var firstCell = tr.insertCell(-1);
//firstCell.style.cssText="font-weight: bold; text-align: center; vertical-align: middle;";
firstCell.innerHTML = col[i];
for (var j = 0; j < jsonObj.length; j++) {
var tabCell = tr.insertCell(-1);
var theValue = jsonObj[j][col[i]];
//console.log("the value: "+theValue);
if (theValue !== null
&& Object.prototype.toString.call(theValue) === '[object Array]') {
var formattedValueArray = "";
for (var k = 0; k < theValue.length; k++) {
var theValueArray = theValue[k];
//console.log(theValueArray);
formattedValueArray += theValueArray + "<br>";
}
tabCell.innerHTML = formattedValueArray;
} else {
tabCell.innerHTML = theValue;
}
}
}
return table.outerHTML;
} catch (e) {
console.log('invalid json', e);
return jsonTxt;
}
}-*/;
/**
* Click element.
*
* @param elem the elem
*/
public static native void clickElement(Element elem) /*-{
elem.click();
}-*/;
}

View File

@ -0,0 +1,24 @@
package org.gcube.portlets.widgets.gdvw.client;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client-side stub for the RPC service.
*/
@RemoteServiceRelativePath("greet")
public interface GeoportalDataViewerWidgetService extends RemoteService {
/**
* Gets the project view for id.
*
* @param profileID the profile ID
* @param projectID the project ID
* @return the project view for id
* @throws Exception the exception
*/
ProjectView getProjectView(ProjectDV theProjectDV) throws Exception;
}

View File

@ -0,0 +1,14 @@
package org.gcube.portlets.widgets.gdvw.client;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* The async counterpart of <code>GeoportalDataViewerWidgetService</code>.
*/
public interface GeoportalDataViewerWidgetServiceAsync {
void getProjectView(ProjectDV theProjectDV, AsyncCallback<ProjectView> callback);
}

View File

@ -1,12 +0,0 @@
package org.gcube.portlets.widgets.gdvw.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client-side stub for the RPC service.
*/
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
}

View File

@ -1,10 +0,0 @@
package org.gcube.portlets.widgets.gdvw.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* The async counterpart of <code>GreetingService</code>.
*/
public interface GreetingServiceAsync {
void greetServer(String input, AsyncCallback<String> callback) throws IllegalArgumentException;
}

View File

@ -0,0 +1,85 @@
package org.gcube.portlets.widgets.gdvw.client.project;
import java.util.Map.Entry;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
import org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidgetConstants;
public class ProjectUtil {
public static <T extends DocumentDV> String toHMLCode(T document, String projectID) {
String htmlCode = "";
if (document == null)
return htmlCode;
Entry<String, Object> firstEntrySet = document.getFirstEntryOfMap();
if (firstEntrySet != null) {
htmlCode += firstEntrySet.getKey() + ": <b>" + firstEntrySet.getValue() + "</b>";
}
if (projectID != null) {
htmlCode += " (id: " + projectID + ")";
}
return htmlCode;
}
public static <T extends DocumentDV> String toHMLCode(boolean showkey, T document, String projectID) {
String htmlCode = "";
if (document == null)
return htmlCode;
Entry<String, Object> firstEntrySet = document.getFirstEntryOfMap();
if (firstEntrySet != null) {
htmlCode += showkey ? firstEntrySet.getKey() + ": <b>" + firstEntrySet.getValue() + "</b>"
: firstEntrySet.getValue();
}
if (projectID != null) {
htmlCode += " (id: " + projectID + ")";
}
return htmlCode;
}
public static <T extends DocumentDV> String toHMLCode(T document) {
String htmlCode = "";
if (document == null)
return htmlCode;
Entry<String, Object> firstEntrySet = document.getFirstEntryOfMap();
if (firstEntrySet != null) {
htmlCode += firstEntrySet.getKey() + ": <b>" + firstEntrySet.getValue() + "</b>";
}
return htmlCode;
}
public static String toHTMLCode(TemporalReferenceDV tempRef) {
String htmlCode = "<span class='display-date'>";
if (tempRef != null) {
String dateToString = "";
if (tempRef.getStart() != null) {
dateToString += GeoportalDataViewerWidgetConstants.DATE_TIME_FORMAT.format(tempRef.getStart());
}
dateToString += " / ";
if (tempRef.getStart() != null) {
dateToString += GeoportalDataViewerWidgetConstants.DATE_TIME_FORMAT.format(tempRef.getEnd());
}
htmlCode += dateToString;
}
htmlCode += "</span>";
return htmlCode;
}
}

View File

@ -0,0 +1,179 @@
package org.gcube.portlets.widgets.gdvw.client.project;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import com.github.gwtbootstrap.client.ui.Button;
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.dom.client.UListElement;
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.Random;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class ProjectViewer.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 27, 2023
*/
public class ProjectViewer extends Composite {
private static ProjectViewerUiBinder uiBinder = GWT.create(ProjectViewerUiBinder.class);
/**
* The Interface ProjectViewerUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 9, 2022
*/
interface ProjectViewerUiBinder extends UiBinder<Widget, ProjectViewer> {
}
@UiField
HTMLPanel headerPanel;
@UiField
HTMLPanel pageViewDetails;
@UiField
HTMLPanel projectViewerMainPanel;
@UiField
HTMLPanel centroidPanel;
@UiField
HTMLPanel tableOfContentPanel;
@UiField
HTMLPanel toc_container;
@UiField
HTMLPanel toc_list_container;
@UiField
Button reduceToc;
@UiField
UListElement toc_list_anchors;
private ProjectView theProjectView;
private GeoportalItemReferences geoportalItemReferences;
private String projectViewerMainPanelID;
/**
* Instantiates a new project viewer.
*/
private ProjectViewer() {
initWidget(uiBinder.createAndBindUi(this));
pageViewDetails.getElement().addClassName("page-view-details");
projectViewerMainPanelID = "projectViewer-" + Random.nextInt();
projectViewerMainPanel.getElement().setId(projectViewerMainPanelID);
}
/**
* Instantiates a new project viewer.
*
* @param applicationBus the application bus
* @param projectView the project view
*/
public ProjectViewer(final ProjectView projectView) {
this();
GWT.log("Rendering " + projectView.getTheProjectDV().getId());
this.theProjectView = projectView;
final String theTitle = projectView.getTheProjectDV().getProfileName() != null
? projectView.getTheProjectDV().getProfileName()
: "Project ID: " + projectView.getTheProjectDV().getId();
headerPanel.add(new HTML(theTitle));
reduceToc.setType(ButtonType.LINK);
reduceToc.setIcon(IconType.PLUS_SIGN_ALT);
toc_list_container.setVisible(false);
reduceToc.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
boolean visible = toc_list_container.isVisible();
setTocContentVisible(!visible);
// if (visible) {
// toc_list_container.setVisible(false);
// reduceToc.setIcon(IconType.PLUS_SIGN_ALT);
// } else {
// toc_list_container.setVisible(true);
// reduceToc.setIcon(IconType.MINUS_SIGN_ALT);
// }
}
});
for (SectionView sectionView : projectView.getListSections()) {
if (!sectionView.isEmpty()) {
SectionViewer sectionViewer = new SectionViewer(sectionView, projectViewerMainPanelID);
String sectionId = sectionView.getSectionTitle().replaceAll("[^A-Za-z0-9]", "-") + "_"
+ Random.nextInt();
String divTarget = "<div class='anchor-target' id='" + sectionId + "'></div>";
sectionViewer.getElement().insertFirst(new HTML(divTarget).getElement());
addAnchorToSection(sectionId, sectionView.getSectionTitle());
pageViewDetails.add(sectionViewer);
}
}
if (toc_list_anchors.getChildCount() > 0) {
tableOfContentPanel.setVisible(true);
}
}
/**
* Adds the anchor to section.
*
* @param id the id
* @param text the text
*/
private void addAnchorToSection(String id, String text) {
String htmlAnchor = "<a href='#" + id + "'>" + text + "</a>";
toc_list_anchors.appendChild(new HTML("<li>" + htmlAnchor + "</li>").getElement());
}
/**
* Sets the toc content visible.
*
* @param bool the new toc content visible
*/
protected void setTocContentVisible(boolean bool) {
toc_list_container.setVisible(bool);
if (bool) {
reduceToc.setIcon(IconType.MINUS_SIGN_ALT);
} else {
reduceToc.setIcon(IconType.PLUS_SIGN_ALT);
}
}
/**
* Gets the project view.
*
* @return the project view
*/
public ProjectView getProjectView() {
return theProjectView;
}
}

View File

@ -0,0 +1,58 @@
<!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>
.margin-left-10 {
margin-left: 10px;
}
.font-size-h1-22 h1 {
font-size: 22px;
}
.align-to-right {
right: 20px;
position: absolute;
top: 20px !important;
}
.the-title {
background-color: rgba(0, 60, 136, .7);
color: white;
padding: 10px 10px;
font-size: 14px;
}
.width-100 {
width: 100%;
}
.display-item-list {
display: inline-table;
}
</ui:style>
<g:HTMLPanel ui:field="projectViewerMainPanel">
<!-- <g:HTMLPanel ui:field="sharePanel" -->
<!-- addStyleNames="{style.align-to-right}"> -->
<!-- </g:HTMLPanel> -->
<g:HTMLPanel ui:field="headerPanel"
addStyleNames="{style.the-title}"></g:HTMLPanel>
<g:HTMLPanel ui:field="pageViewDetails">
<g:HTMLPanel ui:field="centroidPanel"></g:HTMLPanel>
<g:HTMLPanel ui:field="tableOfContentPanel"
visible="false" addStyleNames="{style.display-item-list}">
<g:HTMLPanel ui:field="toc_container"
addStyleNames="toc_container">
<b:Button ui:field="reduceToc"
addStyleNames="toc_container_reduce_button"></b:Button>
<div class="toc_title">Contents</div>
<g:HTMLPanel ui:field="toc_list_container" addStyleNames="toc_list_container">
<ul ui:field="toc_list_anchors"></ul>
</g:HTMLPanel>
</g:HTMLPanel>
</g:HTMLPanel>
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,9 @@
<!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>
</ui:style>
<g:HTMLPanel ui:field="recordDVPanel">
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,163 @@
package org.gcube.portlets.widgets.gdvw.client.project;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
import org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidgetConstants;
import org.gcube.portlets.widgets.gdvw.client.project.ui.util.CustomFlexTable;
import org.gcube.portlets.widgets.gdvw.gallery.ImagesSectionGallery;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.PageHeader;
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.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class SectionViewer extends Composite {
private static SectionViewerUiBinder uiBinder = GWT.create(SectionViewerUiBinder.class);
interface SectionViewerUiBinder extends UiBinder<Widget, SectionViewer> {
}
private SectionView sectionView;
@UiField
HTMLPanel sectionPanelContainer;
@UiField
PageHeader sectionTitle;
public SectionViewer(SectionView sectionView, String topTargetId) {
initWidget(uiBinder.createAndBindUi(this));
this.sectionView = sectionView;
List<SubDocumentView> subDocuments = sectionView.getListSubDocuments();
sectionTitle.setTitle(sectionView.getSectionTitle());
sectionTitle.setText(sectionView.getSectionTitle());
if (subDocuments == null)
return;
Button goToTop = new Button("");
goToTop.setType(ButtonType.LINK);
goToTop.setIcon(IconType.DOUBLE_ANGLE_UP);
goToTop.setHref("#" + topTargetId);
goToTop.setTitle("Go to top");
goToTop.getElement().setClassName("go-top-right");
sectionTitle.add(goToTop);
boolean displayAsGallery = false;
try {
for (SubDocumentView subDocumentView : subDocuments) {
if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
GWT.log("Section with images: " + subDocumentView.getListImages());
displayAsGallery = true;
break;
}
}
//NOT IMPLEMENTED. ALWAYS FALSE
boolean displayAsMapOfLayers = false;
for (SubDocumentView subDocumentView : subDocuments) {
if (subDocumentView.getListLayers() != null && subDocumentView.getListLayers().size() > 0) {
GWT.log("Section with layers: " + subDocumentView.getListImages());
displayAsMapOfLayers = false;
break;
}
}
// Displaying the whole section as a Gallery
if (displayAsGallery) {
GWT.log("displayAsGallery the: " + sectionView);
ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
sectionPanelContainer.add(sectionGallery.getGalleryPanel());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
sectionGallery.fillGallery();
}
});
// Displaying the whole section as a Map of Layers
} else if (displayAsMapOfLayers) {
GWT.log("displayAsMapOfLayers the: " + sectionView);
for (SubDocumentView subDocumentView : subDocuments) {
// String table = GeoportalDataViewerWidgetConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
// sectionPanelContainer.add(new HTML(table));
List<GCubeSDIViewerLayerDV> layers = subDocumentView.getListLayers();
if (layers != null) {
for (GCubeSDIViewerLayerDV gCubeLayer : layers) {
// LayersSectionViewer layerSectionViewer = new LayersSectionViewer(gCubeLayer,
// subDocumentView);
// sectionPanelContainer.add(layerSectionViewer);
//showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
}
}
}
} else {
GWT.log("displaying default the: " + sectionView);
for (SubDocumentView subDocumentView : subDocuments) {
String table = GeoportalDataViewerWidgetConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
sectionPanelContainer.add(new HTML(table));
List<FilesetDV> files = subDocumentView.getListFiles();
if (files != null) {
for (FilesetDV fileset : files) {
showLinkToDownloadWsContent(fileset.getGcubeProfileFieldName(), fileset.getListPayload());
}
}
}
}
} catch (Exception e) {
GWT.log("Error on rendering the section: "+e.getMessage());
}
}
private void showLinkToDownloadWsContent(String title, List<PayloadDV> listPayloads) {
if (listPayloads != null) {
CustomFlexTable customTable = new CustomFlexTable();
int i = 0;
String fieldLabel = title;
for (PayloadDV payload : listPayloads) {
if (i > 0) {
fieldLabel = "";
}
String downloadLabel = "download";
if (payload.getName() != null) {
downloadLabel = payload.getName();
}
customTable.addNextKeyWidget(fieldLabel,
new HTML("<a href=\"" + payload.getLink() + "\">" + downloadLabel + "</a>"));
}
sectionPanelContainer.add(customTable);
}
}
}

View File

@ -0,0 +1,39 @@
<!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>
.margin-left-10 {
margin-left: 10px;
}
.font-size-h1-22 h1 {
font-size: 22px;
margin-top: 5px;
}
.align-to-right {
right: 20px;
position: absolute;
}
.the-title h1 {
font-size: 28px;
}
.margin-bottom-10 {
margin-bottom: 10px;
}
.width-100 {
width: 100%;
}
</ui:style>
<g:HTMLPanel ui:field="sectionPanelContainer">
<g:HTMLPanel
addStyleNames="{style.margin-left-10}">
<b:PageHeader addStyleNames="{style.font-size-h1-22}" ui:field="sectionTitle"></b:PageHeader>
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,102 @@
package org.gcube.portlets.widgets.gdvw.client.project.ui.util;
import java.util.List;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class CustomFlexTable.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 11, 2020
*/
public class CustomFlexTable extends FlexTable {
/**
* Instantiates a new custom flex table.
*/
public CustomFlexTable() {
this.getElement().addClassName("my-html-table");
}
/**
* Adds the next key values.
*
* @param key the key
* @param listValues the list values
* @param separator the separator
*/
public void addNextKeyValues(String key, List<String> listValues, String separator) {
GWT.log("adding key "+key +", values: "+listValues);
if(key==null)
return;
Label keyLabel = new Label(key);
int row = getRowCount() + 1;
setWidget(row, 0, keyLabel);
if(listValues==null)
return;
String valuesAsString = "";
for (String value : listValues) {
String theValue = value;
if(theValue==null)
theValue = "";
if(theValue.startsWith("http://") || (theValue.startsWith("https://"))){
theValue = "<a href=\""+value+"\" target=\"_blank\">"+value+"</a>";
}
valuesAsString+=theValue+separator;
}
valuesAsString = valuesAsString.substring(0, valuesAsString.lastIndexOf(separator));
HTML valuesLabel = new HTML(valuesAsString);
setWidget(row, 1, valuesLabel);
}
/**
* Adds the next key value.
*
* @param key the key
* @param value the value
*/
public void addNextKeyValue(String key, String value) {
if(key==null)
return;
Label keyLabel = new Label(key);
// keyLabel.getElement().getStyle().setMarginRight(5, Unit.PX);
int row = getRowCount() + 1;
setWidget(row, 0, keyLabel);
if(value==null)
return;
HTML valueLabel = new HTML(value);
setWidget(row, 1, valueLabel);
}
/**
* Adds the next key widget.
*
* @param key the key
* @param value the value
*/
public void addNextKeyWidget(String key, Widget value) {
Label keyLabel = new Label(key);
int row = getRowCount() + 1;
setWidget(row, 0, keyLabel);
setWidget(row, 1, value);
}
}

View File

@ -0,0 +1,213 @@
package org.gcube.portlets.widgets.gdvw.gallery;
import java.util.Set;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.HTMLPanel;
/**
* The Class ImagesSectionGallery.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Jul 21, 2021
*/
public class ImagesSectionGallery {
private HTMLPanel galleryPanel;
private String galleryDivId;
private SectionView sectionView;
/**
* Instantiates a new images section gallery.
*
* @param sectionView the section view
*/
public ImagesSectionGallery(SectionView sectionView) {
this.galleryDivId = "nanogallery" + Random.nextInt() + Random.nextInt();
this.galleryPanel = new HTMLPanel("<div id='" + galleryDivId + "'></div>");
this.sectionView = sectionView;
}
/**
* Show gallery.
*
* @param json_array_images the json array images
* @param galleryDivId the gallery div id
*/
private native void showGallery(JavaScriptObject json_array_images, String galleryDivId) /*-{
//console.log("showing: " + json_array_images)
var waitForJQuery = setInterval(
function() {
if (typeof $wnd.$ != 'undefined') {
$wnd
.$("#" + galleryDivId)
.nanogallery2(
{
thumbnailHeight : '200 XS150 SM150', // RESPONSIVE THUMBNAIL HEIGHT: default=200px, XS resolution=150px, SM resolution=150px
thumbnailWidth : '218 XS150 SM150', // RESPONSIVE THUMBNAIL WIDTH: auto
thumbnailAlignment : 'left',
thumbnailBorderHorizontal : 0,
thumbnailBorderVertical : 0,
thumbnailGutterWidth : '10 XS10 SM10',
thumbnailGutterHeight : '10 XS10 SM10',
// THUMBNAIL TOOLS & LABEL
thumbnailLabel : {
display : true,
position : 'onBottom',
align : 'left'
},
thumbnailToolbarImage : {
bottomLeft : 'display'
},
// replace the default DISPLAY tool icon
icons : {
thumbnailDisplay : '<i class="fa fa-long-arrow-right" aria-hidden="true"></i> display'
},
// DISPLAY ANIMATION
galleryDisplayTransition : 'slideUp',
galleryDisplayTransitionDuration : 1000,
thumbnailDisplayTransition : 'scaleDown',
thumbnailDisplayTransitionDuration : 300,
thumbnailDisplayInterval : 50,
// THUMBNAIL'S HOVER ANIMATION
//thumbnailBuildInit2 : 'tools_font-size_1.5em|title_font-size_1.5em',
thumbnailHoverEffect2 : 'imageScaleIn80|tools_opacity_0_1|tools_translateX_-30px_0px|title_opacity_1_0|title_translateX_0px_-30px',
touchAnimation : true,
touchAutoOpenDelay : 800,
// GALLERY THEME
galleryTheme : {
thumbnail : {
borderRadius : '2px !important',
background : '#ffffff !important',
titleShadow : 'none !important',
titleColor : '#696969 !important',
labelBackground : '#f3f3f3 !important'
},
thumbnailIcon : {
color : '#000',
shadow : 'none'
},
},
viewerToolbar : {
display : true,
standard : 'minimizeButton, label',
minimized : 'minimizeButton, label, fullscreenButton, downloadButton'
},
viewerTools : {
topLeft : 'pageCounter',
topRight : 'playPauseButton, zoomButton, fullscreenButton, downloadButton, closeButton'
},
// DEEP LINKING
locationHash : false,
items : json_array_images
})
clearInterval(waitForJQuery);
}
}, 200);
}-*/;
/**
* Gets the gallery panel.
*
* @return the gallery panel
*/
public HTMLPanel getGalleryPanel() {
return galleryPanel;
}
/**
* Fill gallery.
*/
public void fillGallery() {
JSONArray jsonArray = new JSONArray();
int index = 0;
for (SubDocumentView subdoc : sectionView.getListSubDocuments()) {
JSONValue meta = JSONParser.parseStrict(subdoc.getMetadataAsJSON());
for (FilesetDV image : subdoc.getListImages()) {
try {
if (image.getListPayload() != null) {
for (PayloadDV payloadDV : image.getListPayload()) {
JSONObject json = new JSONObject();
json.put("src", new JSONString(payloadDV.getLink()));
json.put("srct", new JSONString(payloadDV.getLink()));
json.put("downloadURL", new JSONString(payloadDV.getLink()));
try {
json.put("title", new JSONString(getFirstValueOfJSON(meta)));
} catch (Exception e) {
GWT.log("Error on reading the title from: " + meta);
json.put("title", new JSONString(meta.toString()));
}
json.put("description", new JSONString(meta.toString()));
jsonArray.set(jsonArray.size(), json);
index++;
}
}
} catch (Exception e) {
GWT.log("Error on adding the image to gallery from: " + image);
}
}
}
if(jsonArray.size()>0) {
showGallery(jsonArray.getJavaScriptObject(), galleryDivId);
}
}
/**
* Gets the first value of JSON.
*
* @param metadata the metadata
* @return the first value of JSON
*/
public String getFirstValueOfJSON(JSONValue metadata) {
String value = "";
if (metadata == null)
return value;
if (metadata.isArray() != null) {
JSONArray array = (JSONArray) metadata;
for (int i = 0; i < array.size(); i++) {
JSONObject object = (JSONObject) array.get(i);
Set<String> set = object.keySet();
value = object.get(set.iterator().next()).toString();
}
} else if (metadata.isObject() != null) {
JSONObject object = (JSONObject) metadata;
Set<String> set = object.keySet();
value = object.get(set.iterator().next()).toString();
} else if (metadata.isString() != null) {
value = metadata.toString();
}
return value;
}
}

View File

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='geoportal_data_viewer_widget'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidget'/>
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidget'/> -->
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- allow Super Dev Mode -->
<add-linker name="xsiframe"/>
<!-- allow Super Dev Mode -->
<add-linker name="xsiframe" />
</module>

View File

@ -0,0 +1,62 @@
package org.gcube.portlets.widgets.gdvw.server;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportaldatamapper.Geoportal_JSON_Mapper;
import org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidgetService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server-side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class GeoportalDataViewerWidgetServiceImpl extends RemoteServiceServlet implements GeoportalDataViewerWidgetService {
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerWidgetServiceImpl.class);
/**
* Gets the project view for id.
*
* @param profileID the profile ID
* @param projectID the project ID
* @return the project view for id
* @throws Exception the exception
*/
@Override
public ProjectView getProjectView(ProjectDV theProjectDV) throws Exception {
LOG.info("called getProjectView");
if (theProjectDV == null)
throw new Exception("Bad Parameter: input project is null");
try {
LOG.info("getProjectView for theProjectDV: {}, ProfileID: {}", theProjectDV.getId(),
theProjectDV.getProfileID());
String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
String userName = null;
try {
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
} catch (Exception e) {
LOG.info("User not found in session, the userName for checking the policy will be null");
}
ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, scope, userName);
if (LOG.isTraceEnabled()) {
Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
}
LOG.info("returning project view for id: " + projectView.getTheProjectDV().getId());
return projectView;
} catch (Exception e) {
String erroMsg = "Error occurred on creating projectView for id: " + theProjectDV.getId();
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
}
}

View File

@ -1,46 +0,0 @@
package org.gcube.portlets.widgets.gdvw.server;
import org.gcube.portlets.widgets.gdvw.client.GreetingService;
import org.gcube.portlets.widgets.gdvw.shared.FieldVerifier;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server-side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService {
public String greetServer(String input) throws IllegalArgumentException {
// Verify that the input is valid.
if (!FieldVerifier.isValidName(input)) {
// If the input is not valid, throw an IllegalArgumentException back to
// the client.
throw new IllegalArgumentException("Name must be at least 4 characters long");
}
String serverInfo = getServletContext().getServerInfo();
String userAgent = getThreadLocalRequest().getHeader("User-Agent");
// Escape data from the client to avoid cross-site script vulnerabilities.
input = escapeHtml(input);
userAgent = escapeHtml(userAgent);
return "Hello, " + input + "!<br><br>I am running " + serverInfo + ".<br><br>It looks like you are using:<br>"
+ userAgent;
}
/**
* Escape an html string. Escaping data received from the client helps to
* prevent cross-site script vulnerabilities.
*
* @param html the html string to escape
* @return the escaped string
*/
private String escapeHtml(String html) {
if (html == null) {
return null;
}
return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
}
}

View File

@ -0,0 +1,128 @@
/**
*
*/
package org.gcube.portlets.widgets.gdvw.server;
import javax.servlet.http.HttpServletRequest;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class SessionUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 27, 2023
*/
public class SessionUtil {
/** The log. */
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
/**
* 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.
*
* @param request the request
* @return a GcubeUser object
*/
public static GCubeUser getCurrentUser(HttpServletRequest request) {
if (request == null)
throw new IllegalArgumentException("HttpServletRequest is null!");
PortalContext pContext = PortalContext.getConfiguration();
GCubeUser user = pContext.getCurrentUser(request);
LOG.debug("Returning user " + user);
return user;
}
/**
* Retrieve the current scope by using the portal manager.
*
* @param request the request
* @param setInThread the set in thread
* @return a GcubeUser object
*/
public static String getCurrentContext(HttpServletRequest request, boolean setInThread) {
if (request == null)
throw new IllegalArgumentException("HttpServletRequest is null!");
PortalContext pContext = PortalContext.getConfiguration();
String context = pContext.getCurrentScope(request);
if (context != null && setInThread)
ScopeProvider.instance.set(context);
LOG.debug("Returning context " + context);
return context;
}
/**
* Retrieve the current scope by using the portal manager.
*
* @param request the request
* @param setInThread the set in thread
* @return a GcubeUser object
*/
public static String getCurrentToken(HttpServletRequest request, boolean setInThread) {
if (request == null)
throw new IllegalArgumentException("HttpServletRequest is null!");
PortalContext pContext = PortalContext.getConfiguration();
String scope = pContext.getCurrentScope(request);
GCubeUser user = pContext.getCurrentUser(request);
String token = PortalContext.getConfiguration().getCurrentUserToken(scope, user.getUsername());
if (token != null) {
LOG.debug("Returning token " + token.substring(1, 10) + "_MASKED_TOKEN_");
if (setInThread)
SecurityTokenProvider.instance.set(token);
}
return token;
}
/**
* Retrieve the group given the scope.
*
* @param scope the scope
* @return the group from scope
* @throws UserManagementSystemException the user management system exception
* @throws GroupRetrievalFault the group retrieval fault
*/
public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault {
if (scope == null || scope.isEmpty())
throw new IllegalArgumentException("Scope is missing here!!");
GroupManager gm = new LiferayGroupManager();
long groupId = gm.getGroupIdFromInfrastructureScope(scope);
return gm.getGroup(groupId);
}
}

View File

@ -1,42 +0,0 @@
package org.gcube.portlets.widgets.gdvw.shared;
/**
* <p>
* FieldVerifier validates that the name the user enters is valid.
* </p>
* <p>
* This class is in the <code>shared</code> package because we use it in both
* the client code and on the server. On the client, we verify that the name is
* valid before sending an RPC request so the user doesn't have to wait for a
* network round trip to get feedback. On the server, we verify that the name is
* correct to ensure that the input is correct regardless of where the RPC
* originates.
* </p>
* <p>
* When creating a class that is used on both the client and the server, be sure
* that all code is translatable and does not use native JavaScript. Code that
* is not translatable (such as code that interacts with a database or the file
* system) cannot be compiled into client-side JavaScript. Code that uses native
* JavaScript (such as Widgets) cannot be run on the server.
* </p>
*/
public class FieldVerifier {
/**
* Verifies that the specified name is valid for our service.
*
* In this example, we only require that the name is at least four
* characters. In your application, you can use more complex checks to ensure
* that usernames, passwords, email addresses, URLs, and other fields have the
* proper syntax.
*
* @param name the name to validate
* @return true if valid, false if invalid
*/
public static boolean isValidName(String name) {
if (name == null) {
return false;
}
return name.length() > 3;
}
}

View File

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='geoportal_data_viewer_widget'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidget'/>
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidget'/> -->
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- allow Super Dev Mode -->
<add-linker name="xsiframe"/>
<!-- allow Super Dev Mode -->
<add-linker name="xsiframe" />
</module>