- 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

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -138,7 +140,9 @@
<wb-module deploy-name="geoportal-data-entry-app-3.3.0-SNAPSHOT">
@ -277,7 +281,9 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -416,7 +422,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -555,7 +563,9 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -649,7 +659,12 @@
<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>
@ -788,7 +803,9 @@
<property name="context-root" value="geoportal-data-entry-app"/>
@ -927,7 +944,9 @@
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -1066,7 +1085,9 @@
</wb-module>

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();
}
@ -1668,6 +1688,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: {

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

@ -106,6 +106,9 @@ public class GeonaMainTabPanel extends Composite {
@UiField
NavLink navShowOnMap;
@UiField
NavLink navShareLink;
@UiField
NavLink navShowReport;
@ -249,6 +252,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() {

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;
@ -902,8 +906,8 @@ 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);
}
@ -939,11 +943,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// SETTING ORIGINAL PROJECTION FROM CLIENT
filter.setProjection(originalProjection);
// 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);
}
}