- Integrated new Uri-Resolver-Manager [#27160]

- Added Get Shareable Link facility [#27120]
This commit is contained in:
Francesco Mangiacrapa 2024-04-05 15:54:09 +02:00
parent b86439cba6
commit c8c500c736
14 changed files with 203 additions and 39 deletions

View File

@ -116,6 +116,8 @@
@ -255,6 +257,8 @@
@ -394,6 +398,8 @@
@ -533,6 +539,8 @@
@ -624,6 +632,8 @@
@ -649,6 +659,11 @@
<dependent-module archiveName="geoportal-data-common-2.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="uri-resolver-manager-1.8.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/uri-resolver-manager/uri-resolver-manager">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -905,6 +920,8 @@
@ -1044,6 +1061,8 @@
@ -1183,6 +1202,8 @@

View File

@ -4,9 +4,11 @@
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).
## [v3.3.0-SNAPSHOT] - 2024-03-26
## [v3.3.0-SNAPSHOT] - 2024-04-05
- Implemented the init facility to resolve a public link on an item [#27120]
- Integrated new Uri-Resolver-Manager [#27160]
- Added Get Shareable Link facility [#27120]
## [v3.2.2] - 2024-01-11

View File

@ -26,9 +26,11 @@ public class ConstantsGeoPortalDataEntryApp {
public static final String DIV_LOADERS_ID = "geoportal-loaders";
public static final String GET_GEONA_ITEM_TYPE = "git";
public static final String GET_PARAMETER_ITEM_TYPE = "git";
public static final String GET_GEONA_ITEM_ID = "gid";
public static final String GET_PARAMETER_ITEM_ID = "gid";
public static final String GET_PARAMETER_ACTION = "act";
public static final String DATE_FORMAT = ConstantsMPFormBuilder.DATE_FORMAT;

View File

@ -28,8 +28,6 @@ public class GeoPortalClientCaches {
private TreeMap<String, List<GeoNaFormCardModel>> mapGcubeProfilePerItemType;
//private Map<String, List<HandlerDeclarationDV>> mapHandlersConfigurationsForProfileId;
private Map<String, UseCaseDescriptorDV> mapUseCaseDescriptor;
private Map<String, CacheSearchingFilterParametersFromConfig> mapSearchingFilterParametersForProfileId;

View File

@ -74,6 +74,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig;
import org.gcube.portlets.user.geoportaldataentry.shared.ProjectNotFoundException;
import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node;
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
import org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidget;
@ -192,8 +193,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
mainTabPanel.addFormPanel(geoNaMainForm);
paramGeonaItemType = Window.Location.getParameter(ConstantsGeoPortalDataEntryApp.GET_GEONA_ITEM_TYPE);
paramGeonaItemID = Window.Location.getParameter(ConstantsGeoPortalDataEntryApp.GET_GEONA_ITEM_ID);
paramGeonaItemType = Window.Location.getParameter(ConstantsGeoPortalDataEntryApp.GET_PARAMETER_ITEM_TYPE);
paramGeonaItemID = Window.Location.getParameter(ConstantsGeoPortalDataEntryApp.GET_PARAMETER_ITEM_ID);
ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_PORTLET.add(mainTabPanel);
@ -255,7 +256,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onFailure(Throwable caught) {
String errorMsg = "Sorry, an error occurred on istancing the application. Please, contact the support";
String errorMsg = "Sorry, an error occurred on istancing the application. Please, contact the support. Error is: "+caught.getMessage();
Alert alert = new Alert(errorMsg, AlertType.ERROR);
alert.setClose(false);
try {
@ -326,7 +327,26 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onFailure(Throwable caught) {
Window.alert("Error " + caught.getMessage());
if(caught instanceof ProjectNotFoundException) {
Modal errorModal = new Modal(true, true);
errorModal.setCloseVisible(true);
errorModal.setTitle("Oops...");
Image geoportalError = new Image(Images.ICONS.warningError());
FlowPanel errorPanelMsg = new FlowPanel();
errorPanelMsg.getElement().addClassName("general_warning");
errorPanelMsg.add(geoportalError);
errorPanelMsg.add(new HTML("D4S GeoPortal"));
HTML erroMessage = new HTML(
"Oops something went wrong, either the project does not exist or you are not authorized to access it");
errorPanelMsg.add(erroMessage);
errorModal.add(errorPanelMsg);
errorModal.show();
}
else {
Window.alert("Error " + caught.getMessage());
}
initExecutor.execute();
}
@ -396,7 +416,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
HTML erroMessage = new HTML(
"The <span class='general_info_facility'>List of Projects</span> only shows the <br/><br/><b>\""
+ result.getFirstEntryOfMap().getValue()
+ "\"</b><br/><br/>project resolved by shared link<br/><br/>To view all projects select <span class='general_info_facility'>Reload Projects</span> button");
+ "\"</b><br/><br/>project resolved by shareable link<br/><br/>To view all projects select <span class='general_info_facility'>Reload Projects</span> button");
errorPanelMsg.add(erroMessage);
errorModal.add(errorPanelMsg);
errorModal.show();
@ -1620,7 +1640,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal.add(hpGetLink);
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(resultDocumentDV.getId(),
resultDocumentDV.getProfileID(), new AsyncCallback<GeoportalItemReferences>() {
resultDocumentDV.getProfileID(), GeoportalItemReferences.SHARE_LINK_TO.DATA_VIEWER, new AsyncCallback<GeoportalItemReferences>() {
@Override
public void onFailure(Throwable caught) {
try {
@ -1631,7 +1651,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
alert.setClose(false);
hpGetLink.add(alert);
modal.add(alert);
// newBrowserWindow.close();
}
@ -1669,6 +1689,66 @@ public class GeoPortalDataEntryApp implements EntryPoint {
break;
}
case GET_SHAREABLE_LINK: {
final Modal modal = new Modal(true, true);
modal.setTitle("Share the Project by link...");
modal.setCloseVisible(true);
final HorizontalPanel hpGetLink = new HorizontalPanel();
final LoaderIcon lc = new LoaderIcon("Just moment getting link...");
hpGetLink.add(lc);
modal.add(hpGetLink);
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(resultDocumentDV.getId(),
resultDocumentDV.getProfileID(), GeoportalItemReferences.SHARE_LINK_TO.DATA_ENTRY, new AsyncCallback<GeoportalItemReferences>() {
@Override
public void onFailure(Throwable caught) {
try {
hpGetLink.setVisible(false);
modal.remove(hpGetLink);
} catch (Exception e) {
// TODO: handle exception
}
Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
alert.setClose(false);
modal.add(alert);
// newBrowserWindow.close();
}
@Override
public void onSuccess(GeoportalItemReferences result) {
try {
hpGetLink.setVisible(false);
modal.remove(hpGetLink);
} catch (Exception e) {
// TODO: handle exception
}
String theURL = result.getRestrictedLink().getShortURL() != null
? result.getRestrictedLink().getShortURL()
: result.getRestrictedLink().getCompleteURL();
// newBrowserWindow.setUrl(theURL);
Anchor anchor = new Anchor(theURL);
anchor.setHref(theURL);
anchor.setTarget("_blank");
anchor.setTitle(
"Shareable link of the project with id: " + resultDocumentDV.getId());
com.github.gwtbootstrap.client.ui.Label label = new com.github.gwtbootstrap.client.ui.Label(
"Shareable link");
label.setType(LabelType.SUCCESS);
modal.add(label);
modal.add(new HTML("<br>"));
modal.add(anchor);
}
});
modal.show();
break;
}
case VIEW_REPORT: {
final Modal modal2 = new Modal(true, true);

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences.SHARE_LINK_TO;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
@ -56,12 +57,13 @@ public interface GeoportalDataEntryService extends RemoteService {
/**
* Gets the links for.
*
* @param itemId the item id
* @param itemId the item id is the mongoId
* @param profileID the profile ID
* @param shareLinkTo the share link to
* @return the links for
* @throws Exception the exception
*/
GeoportalItemReferences getLinksFor(String itemId, String profileID) throws Exception;
GeoportalItemReferences getLinksFor(String itemId, String profileID, SHARE_LINK_TO shareLinkTo) throws Exception;
/**
* Gets the list projects.
@ -237,4 +239,6 @@ public interface GeoportalDataEntryService extends RemoteService {
ProjectView getProjectView(String profileID, String projectID) throws Exception;
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences.SHARE_LINK_TO;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
@ -59,7 +60,8 @@ public interface GeoportalDataEntryServiceAsync {
void getGeonaInitConfig(AsyncCallback<GeoportalISConfig> callback);
void getLinksFor(String itemId, String profileID, AsyncCallback<GeoportalItemReferences> callback);
void getLinksFor(String itemId, String profileID, SHARE_LINK_TO shareLinkTo,
AsyncCallback<GeoportalItemReferences> callback);
void getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter,
boolean reloadFromService, AsyncCallback<ResultSetPaginatedData> callback);

View File

@ -19,4 +19,7 @@ public interface Images extends ClientBundle {
@Source("information_icon.png")
ImageResource info();
@Source("warning_error.png")
ImageResource warningError();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -107,6 +107,9 @@ public class GeonaMainTabPanel extends Composite {
@UiField
NavLink navShowOnMap;
@UiField
NavLink navShareLink;
@UiField
NavLink navShowReport;
@ -250,6 +253,21 @@ public class GeonaMainTabPanel extends Composite {
}
});
navShareLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
List<DocumentDV> listDocuments = null;
if (grpw != null && grpw.getSelectItems() != null) {
listDocuments = grpw.getSelectItems();
}
appManagerBus
.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.GET_SHAREABLE_LINK));
}
});
navViewAsDocument.addClickHandler(new ClickHandler() {
@Override

View File

@ -107,6 +107,8 @@
<b:Divider addStyleNames="{style.divider-border-right}" />
<b:NavLink ui:field="navShowOnMap" title="Show on Map"
icon="MAP_MARKER">Show on Map</b:NavLink>
<b:NavLink ui:field="navShareLink" title=">Get Shareable Link"
icon="SHARE">Get Shareable link</b:NavLink>
<b:Divider addStyleNames="{style.divider-border-right}" />
<b:NavLink ui:field="navShowReport"
title="Show Publication Report" icon="FILE_TEXT_ALT">Publication Report</b:NavLink>

View File

@ -78,7 +78,7 @@ public class LifecycleInformationPanel extends FlowPanel {
final LoaderIcon lc = new LoaderIcon("Get link...");
hpGetLink.add(lc);
add(hpGetLink);
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(projectID, profileID,
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(projectID, profileID, GeoportalItemReferences.SHARE_LINK_TO.DATA_VIEWER,
new AsyncCallback<GeoportalItemReferences>() {
@Override

View File

@ -71,6 +71,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig;
import org.gcube.portlets.user.geoportaldataentry.shared.ProjectNotFoundException;
import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node;
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
@ -361,7 +362,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
}
// Registering fileset in the section according to mapFilesToRegistrer
if (mapFilesToRegistrer != null && mapFilesToRegistrer.size()>0) {
if (mapFilesToRegistrer != null && mapFilesToRegistrer.size() > 0) {
LOG.info("Cluster of fileset per fieldDefinition is: " + mapFilesToRegistrer);
String theJSONDocument = currentProject.getTheDocument().toJson();
MongoServiceUtil mongoService = new MongoServiceUtil();
@ -844,19 +845,22 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
/**
* Gets the links for.
*
* @param itemId the item id is the mongoId
* @param profileID the profile ID
* @param itemId the item id is the mongoId
* @param profileID the profile ID
* @param shareLinkTo the share link to
* @return the links for
* @throws Exception the exception
*/
@Override
public GeoportalItemReferences getLinksFor(String itemId, String profileID) throws Exception {
public GeoportalItemReferences getLinksFor(String itemId, String profileID,
GeoportalItemReferences.SHARE_LINK_TO shareLinkTo) throws Exception {
LOG.info("getLinksFor called");
String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
//GNADataViewerConfigProfile grViewerProfile = SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest());
// GNADataViewerConfigProfile grViewerProfile =
// SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest());
GeoportalCommon gc = new GeoportalCommon();
GeoportalItemReferences item = new GeoportalItemReferences(itemId, profileID);
GeoportalItemReferences item = new GeoportalItemReferences(itemId, profileID, shareLinkTo);
item = gc.getPublicLinksFor(scope, item, true);
LOG.info("Returning: " + item);
return item;
@ -903,7 +907,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
searchedData.setTotalItems(totalProjectForProfile);
LOG.info("Total Docs read from config: " + totalProjectForProfile);
boolean isSearchForIds = filter.getProfileID()!=null && filter.getProjectID()!=null;
boolean isSearchForIds = filter.getProfileID() != null && filter.getProjectID() != null;
// Saving client PROJECTION
LinkedHashMap<String, Object> originalProjection = filter.getProjection();
@ -930,8 +934,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
totalItems = listProjectIDs.size();
searchedData.setTotalItems(totalItems);
LOG.info("Total Docs read from query per ID: " + totalItems);
}else if(isSearchForIds) {
//searching one item for IDs
} else if (isSearchForIds) {
// searching one item for IDs
searchedData.setTotalItems(1);
}
@ -941,9 +945,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// LIMIT IS FROM CLIENT
Iterator<Project> projects = null;
if(!isSearchForIds) {
if (!isSearchForIds) {
projects = client.queryOnMongo(theProfileID, totalItems, start, limit, filter);
}else {
} else {
Project project = client.getProjectByID(filter.getProfileID(), filter.getProjectID());
projects = Arrays.asList(project).iterator();
}
@ -1446,14 +1450,21 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
ProjectsCaller projects = GeoportalClientCaller.projects();
Project project = projects.getProjectByID(profileID, projectID);
if (project == null) {
throw new ProjectNotFoundException(
"Project with coordinates id: " + projectID + " and type: " + profileID + " not found");
}
ResultDocumentDV documentDV = ConvertToDataValueObjectModel.toResultDocumentDV(project);
LOG.info("returning: " + documentDV.getId());
return documentDV;
} catch (ProjectNotFoundException e) {
LOG.error(ProjectNotFoundException.class.getSimpleName(), e);
throw e;
} catch (Exception e) {
String error = "Error occurred on reading the project with id: " + projectID;
LOG.error(error, e);
throw new Exception(
throw new ProjectNotFoundException(
error + ". Error: " + e.getMessage() + ". Refresh and try again or contact the support");
}

View File

@ -0,0 +1,21 @@
package org.gcube.portlets.user.geoportaldataentry.shared;
public class ProjectNotFoundException extends Exception {
/**
*
*/
private static final long serialVersionUID = 4918313646452701634L;
public ProjectNotFoundException() {
}
public ProjectNotFoundException(String error){
super(error);
}
public ProjectNotFoundException(Throwable error){
super(error);
}
}