From c8c500c7363cbe9d6614296cf4cca0f2e627cf77 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 5 Apr 2024 15:54:09 +0200 Subject: [PATCH] - Integrated new Uri-Resolver-Manager [#27160] - Added Get Shareable Link facility [#27120] --- .settings/org.eclipse.wst.common.component | 39 ++++++-- CHANGELOG.md | 4 +- .../ConstantsGeoPortalDataEntryApp.java | 6 +- .../client/GeoPortalClientCaches.java | 2 - .../client/GeoPortalDataEntryApp.java | 94 ++++++++++++++++-- .../client/GeoportalDataEntryService.java | 8 +- .../GeoportalDataEntryServiceAsync.java | 4 +- .../client/resource/Images.java | 3 + .../client/resource/warning_error.png | Bin 0 -> 2777 bytes .../client/ui/GeonaMainTabPanel.java | 18 ++++ .../client/ui/GeonaMainTabPanel.ui.xml | 2 + .../ui/report/LifecycleInformationPanel.java | 2 +- .../server/GeoportalDataEntryServiceImpl.java | 39 +++++--- .../shared/ProjectNotFoundException.java | 21 ++++ 14 files changed, 203 insertions(+), 39 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/warning_error.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ProjectNotFoundException.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index d10a6f1..19e8b2e 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,7 @@ - + + + @@ -138,7 +140,9 @@ - + + + @@ -277,7 +281,9 @@ - + + + @@ -416,7 +422,9 @@ - + + + @@ -555,7 +563,9 @@ - + + + @@ -649,7 +659,12 @@ uses - + + uses + + + + @@ -788,7 +803,9 @@ - + + + @@ -927,7 +944,9 @@ - + + + @@ -1066,7 +1085,9 @@ - + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 66d1c23..c7d2413 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index 82e046d..d5438c7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -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; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java index d706354..ee2aa37 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java @@ -28,8 +28,6 @@ public class GeoPortalClientCaches { private TreeMap> mapGcubeProfilePerItemType; - //private Map> mapHandlersConfigurationsForProfileId; - private Map mapUseCaseDescriptor; private Map mapSearchingFilterParametersForProfileId; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 8b7c41c..5ae9c5c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -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 List of Projects only shows the

\"" + result.getFirstEntryOfMap().getValue() - + "\"

project resolved by shared link

To view all projects select Reload Projects button"); + + "\"

project resolved by shareable link

To view all projects select Reload Projects 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() { + resultDocumentDV.getProfileID(), GeoportalItemReferences.SHARE_LINK_TO.DATA_VIEWER, new AsyncCallback() { @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() { + @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("
")); + modal.add(anchor); + + } + }); + + modal.show(); + + break; + } case VIEW_REPORT: { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java index 306be24..fd7afe5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java @@ -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; + + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java index a07a04a..35412ee 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java @@ -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 callback); - void getLinksFor(String itemId, String profileID, AsyncCallback callback); + void getLinksFor(String itemId, String profileID, SHARE_LINK_TO shareLinkTo, + AsyncCallback callback); void getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService, AsyncCallback callback); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/Images.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/Images.java index 650a74a..8b2ae69 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/Images.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/Images.java @@ -19,4 +19,7 @@ public interface Images extends ClientBundle { @Source("information_icon.png") ImageResource info(); + + @Source("warning_error.png") + ImageResource warningError(); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/warning_error.png b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/warning_error.png new file mode 100644 index 0000000000000000000000000000000000000000..801a01be3f0bcc88f9d503e3b3706b0e0a85f44e GIT binary patch literal 2777 zcmV;~3MTc5P)PSHcEExmHGqwPapay<1jsjm!QjVC{$~}!Y0R5}q z4NL;d3cl?Eun+iFk}_*XGe2mw0puAi;1KW-(5fKfC%|1zHi9Z&N)YH@{z2gDRR5gg zz$02#BWbJw0C%GXzb-q09RhN^q>)oVp0OGD3$R>B0ia59A2|cOFQjvVU_5}{@1Mlq!3UK%G8t0h zNHB^5A4BcI`_4@$U4tNqDIm{Sj&l81xYng0uLJK-QqH+nq#vPpfO`pN@BywurKWk0 z_Z}e6xCA%`tZ}VNNlu}{!vDHfWHAO@D^P&_$PfMu@NeLMs3ej#sL*ni;4{{ubpMi| zOmV#S0C~o>s4ZWq6z?Ob%%K-LH*EA_&MMT_@&l+voW%5a4)|b_a#TQ;5xg}39ZLNU zRnA?P^Qd3r!%52d0?)k-codnF#utH)_U)Fsqp0|DK7#K3Ov7s${BE(x3C~y8US!Vut7l1tH5_^ zbo}@ss&hzP)}ua?cX+o3$TNmer+pGD@-#{LX-$1@27WD|%M9?|B;}-lEHS+D0D3ik z0GYu*13W7r=l7^^u`a9dFn!D`13)EKd{#)--%&xbc&l( zoEkt!D>rEu3(5o3K19-s)5~gWGoL}=kn8j@*B)RDxW$m{L1YGQC2)y=oL)FjA9H2^ zIux43?19u(0y0K0_dT^xNu-h;%}OiaigCC7rt4ZuNl&j9uE3RYt-0_bKr4yuZ5djJ>JJ#`jwCL@4eY{Ohw+!JdbPKP>^HlL}v zvc`LDx&JmT)aH=2`bV3CaW`(Nd+Kgy$<5@izsWGqG_5f}6 z0`zXK!-MWntskAR1M_@kw2m?!{@Njeaxr< zSZ?CH7*z~lJ#GtU22kl^Ms+al0d7I2w5u*vwsT#%|4z0dmn7R0V+No@nMqUfOH#!H z_+S8FxT?sc2e=crGpDZsKhm~4xE1)2v`|q4Fi_ni zNtyMCFKd@hS{SG*lJ)@GF<_-ayt~9}eKY`27h;Y}3KTN{-PGZblsp5JnbUoV0D7@s zvZ_eZ1MJ4Hg;O`fB^FUWe~xtsHl-FZ0DX6lu~=1zAqs5m>L|u%0|3~mE2?T!+W&p8~#NU$x4d0xnO|YK^Sw7{Eco`l6c5cY*t=^hByO1?ZD0FB=~&QFc(V zgsrpzbX?hLqNziq8kMVxs(64g{J63;axou8HJm6#sWpHOIbO!ETRS7~Fa=zfq{Z9X zm5txW34icsQ7h+@ywgi?B`RxZ9bxPNEW`+^^7`STZz${m^a<2)>{ZK3GmGjS{B7V! z_r(!~{JynwA`qw>;juGaf@C53Xk_E%Uejn;i!X5mRsCxqIG6nooK#mLg_F-Po0Cd>r zq;;7PM3fC<8l`2pS%l;!pPzkOJ=*+fqR$TLQOo#u41 z!lE~XmL$YTpp)BCH3jpSX8;{xUx@K4t^m_`u=r*7V&2T{*MFLt3a6a9tiCoUG@5tfy;j zH@6X_Z|?dRVdTUYWfu5ElJc7>Z_YEe0ly{OL!n;G02`B(Q*f~dn4npM59;$hk!QVE zz>AS*YzCgDS%VKMES%flNnkF?^ElzJ{1;*d_#*JjB1fe9!ssXPtILTb=Ygw}l&Q7{ z_zKM(d{6`VH1J%WabvIEdwE7H<@!eg^!C<_k6N^=c*8uQm`=LgX0g66Ou4bMkhU z%<`_kpu9?V7R>+)AG7v){ZgUbudo-Ly$ct5{kg8c=TX1(6Q~5AKLKy(g?=Owi9{li fNF)-8L?ZtOlUW;}PvV$_00000NkvXXu0mjf@FNUS literal 0 HcmV?d00001 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index 6a85def..7873d82 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -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 listDocuments = null; + if (grpw != null && grpw.getSelectItems() != null) { + listDocuments = grpw.getSelectItems(); + } + + appManagerBus + .fireEvent(new OperationOnItemEvent(listDocuments, OPERATION_ON_ITEM.GET_SHAREABLE_LINK)); + + } + }); navViewAsDocument.addClickHandler(new ClickHandler() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 479d943..93cec0f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -107,6 +107,8 @@ Show on Map + Get Shareable link Publication Report diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/LifecycleInformationPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/LifecycleInformationPanel.java index 6a85ea7..49528d4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/LifecycleInformationPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/LifecycleInformationPanel.java @@ -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() { @Override diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index 6743d63..e020dfe 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -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 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 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"); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ProjectNotFoundException.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ProjectNotFoundException.java new file mode 100644 index 0000000..f4c11aa --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ProjectNotFoundException.java @@ -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); + } + +}