From 8dd267730cfdd2c61c6900b8fa43d8c951cd6bfd Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 21 Dec 2021 16:51:56 +0100 Subject: [PATCH] ported to GNADataEntryConfigProfile --- .../client/GeoPortalDataEntryApp.java | 125 ++++++++++++++++-- .../client/GeoportalDataEntryService.java | 18 +-- .../GeoportalDataEntryServiceAsync.java | 55 +++----- .../server/GeoportalDataEntryServiceImpl.java | 88 ++++++------ .../server/SessionUtil.java | 40 +++++- .../shared/GNADataEntryExtConfigProfile.java | 46 +++++++ 6 files changed, 265 insertions(+), 107 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GNADataEntryExtConfigProfile.java 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 e354a9e..1cc19fd 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 @@ -45,6 +45,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_ import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.NewBrowserWindow; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; +import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.UserRights; @@ -119,7 +120,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { RootPanel.get(DIV_PORTLET_ID).add(loader); - GeoportalDataEntryServiceAsync.Util.getInstance().listDisplayFields(new AsyncCallback>() { + /*GeoportalDataEntryServiceAsync.Util.getInstance().listDisplayFields(new AsyncCallback>() { @Override public void onFailure(Throwable caught) { @@ -129,10 +130,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onSuccess(List result) { - for (ItemField itemField : result) { - if(itemField.isDisplayIntoTable()) { + if(itemField.isDisplayAsResult()) { displayFields.add(itemField); } @@ -159,10 +159,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { mainTabPanel.addFormPanel(geoNaMainForm); } - }); + });*/ - - GeoportalDataEntryServiceAsync.Util.getInstance().getMyRightsInTheContext(new AsyncCallback() { + GeoportalDataEntryServiceAsync.Util.getInstance().readDataViewerConfig(new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -176,18 +175,49 @@ public class GeoPortalDataEntryApp implements EntryPoint { } RootPanel.get(DIV_PORTLET_ID).add(alert); Window.alert(errorMsg); - + } @Override - public void onSuccess(UserRights result) { + public void onSuccess(GNADataEntryExtConfigProfile gNADataEntryConfig) { + try { RootPanel.get(DIV_PORTLET_ID).remove(loader); } catch (Exception e) { } - myRights = result; + List itemFields = gNADataEntryConfig.getListItemFields(); + + for (ItemField itemField : itemFields) { + if(itemField.isDisplayAsResult()) { + displayFields.add(itemField); + } + + if(itemField.isSearchable()) { + searchByFields.add(itemField); + } + + if(itemField.isSortable()) { + sortByFields.add(itemField); + } + } + + + GWT.log("List display fields: "+itemFields); + SearchingFilter initialSortFilter = new SearchingFilter(); + initialSortFilter.setOrder(ORDER.ASC); + initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true))); + + displayFields = itemFields; + mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields, initialSortFilter); + mainTabPanel.setLoaderVisible("Loading...", true); + + geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); + mainTabPanel.addFormPanel(geoNaMainForm); + + //PERMISSIONS + myRights = gNADataEntryConfig.getUserRights(); initGUI(); GcubeUserRole userRole = myRights.getRoleRights().getUserRole(); String msg = "Logged in as "; @@ -231,9 +261,84 @@ public class GeoPortalDataEntryApp implements EntryPoint { } }); - + } }); + + + +// GeoportalDataEntryServiceAsync.Util.getInstance().getMyRightsInTheContext(new AsyncCallback() { +// +// @Override +// public void onFailure(Throwable caught) { +// String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support"; +// Alert alert = new Alert(errorMsg, AlertType.ERROR); +// alert.setClose(false); +// try { +// RootPanel.get(DIV_PORTLET_ID).remove(loader); +// } catch (Exception e) { +// +// } +// RootPanel.get(DIV_PORTLET_ID).add(alert); +// Window.alert(errorMsg); +// +// } +// +// @Override +// public void onSuccess(UserRights result) { +// try { +// RootPanel.get(DIV_PORTLET_ID).remove(loader); +// } catch (Exception e) { +// +// } +// +// myRights = result; +// initGUI(); +// GcubeUserRole userRole = myRights.getRoleRights().getUserRole(); +// String msg = "Logged in as "; +// if(userRole != null && userRole.getName()!=null) { +// msg+= userRole.getName().substring(userRole.getName().indexOf("-")+1, userRole.getName().length()); +// }else +// msg+="Member"; +// +// mainTabPanel.setRoleLabel(msg); +// +// +// RoleRights roleRights = myRights.getRoleRights(); +// boolean canCreateNewItem = roleRights.getListPermessions().keySet().contains(ACTION_ON_ITEM.CREATE_NEW_PROJECT); +// +// if (!canCreateNewItem) { +// // removing Tab "Create New Project" +// mainTabPanel.removeTab(0); +// // activating Tab "List of Project" +// mainTabPanel.setTabActive(0); +// mainTabPanel.instanceAndShowListOfConcessioni(); +// return; +// } +// +// GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback() { +// +// @Override +// public void onFailure(Throwable caught) { +// Window.alert( +// "Sorry, an error occurrend when loading configurations. Please, contact the support"); +// } +// +// @Override +// public void onSuccess(GeonaISConfig result) { +// +// if (result != null && result.getgRSecondaryType() != null +// && result.getScope() != null) { +// callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType()); +// } else +// Window.alert( +// "Sorry, no configuration found in the context. Please, contact the support"); +// +// } +// }); +// +// } +// }); } private void initGUI() { 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 f4879b1..d2d8bb0 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,7 +3,6 @@ package org.gcube.portlets.user.geoportaldataentry.client; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; -import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; @@ -11,9 +10,9 @@ import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceCo import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; +import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; -import org.gcube.portlets.user.geoportaldataentry.shared.UserRights; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.google.gwt.user.client.rpc.RemoteService; @@ -133,18 +132,11 @@ public interface GeoportalDataEntryService extends RemoteService { List keepCurrentContent, GenericDatasetBean gDBean) throws Exception; /** - * Gets the my rights in the context. + * Read data viewer config. * - * @return the my rights in the context - * @throws Exception + * @return the GNA data entry ext config profile + * @throws Exception the exception */ - UserRights getMyRightsInTheContext() throws Exception; - - /** - * List display fields. - * - * @return the list - */ - List listDisplayFields(); + GNADataEntryExtConfigProfile readDataViewerConfig() 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 9d60dda..c3593de 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,7 +3,6 @@ package org.gcube.portlets.user.geoportaldataentry.client; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; -import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; @@ -11,75 +10,57 @@ import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceCo import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; +import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; -import org.gcube.portlets.user.geoportaldataentry.shared.UserRights; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; -public interface GeoportalDataEntryServiceAsync -{ +public interface GeoportalDataEntryServiceAsync { - /** - * Utility class to get the RPC Async interface from client-side code - */ - public static final class Util - { - private static GeoportalDataEntryServiceAsync instance; + /** + * Utility class to get the RPC Async interface from client-side code + */ + public static final class Util { + private static GeoportalDataEntryServiceAsync instance; - public static final GeoportalDataEntryServiceAsync getInstance() - { - if ( instance == null ) - { - instance = (GeoportalDataEntryServiceAsync) GWT.create( GeoportalDataEntryService.class ); - } - return instance; - } - - private Util() - { - // Utility class should not be instantiated - } - } + public static final GeoportalDataEntryServiceAsync getInstance() { + if (instance == null) { + instance = (GeoportalDataEntryServiceAsync) GWT.create(GeoportalDataEntryService.class); + } + return instance; + } + private Util() { + // Utility class should not be instantiated + } + } void saveGeonaDataForms(List listGeonaFormObjects, AsyncCallback callback); - void getGeonaInitConfig(AsyncCallback callback); - void getLinksFor(String itemId, RECORD_TYPE recordType, AsyncCallback callback); - void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService, AsyncCallback callback); - void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); - void getJSONRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); - void updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType, AsyncCallback callback); - void readFileSetPaths(AsyncCallback callback); - void getRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); - void updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, List keepCurrentContent, GenericDatasetBean gDBean, AsyncCallback callback); + void readDataViewerConfig(AsyncCallback asyncCallback); - void getMyRightsInTheContext(AsyncCallback callback); - - - void listDisplayFields(AsyncCallback> callback); } 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 9725262..b48dca5 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 @@ -17,19 +17,18 @@ import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.TempFile; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.GeoportalCommon; +//import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.MongoServiceCommon; -import org.gcube.application.geoportalcommon.config.GNADataConfigProfileReader; -import org.gcube.application.geoportalcommon.shared.GNADataConfigProfile; -import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile; +import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; -import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM; import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole; import org.gcube.application.geoportalcommon.shared.config.RoleRights; import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE; -import org.gcube.application.geoportalcommon.shared.exception.GNAUserRightsConfigException; +import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; @@ -39,6 +38,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitl import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; +import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.UserRights; @@ -68,6 +68,29 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen public static final String GEONA_GENERIC_RESOURCE_SECONDARY_TYPE = "GEONA_GENERIC_RESOURCE_SECONDARY_TYPE"; private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataEntryServiceImpl.class); + /** + * Gets the GNA data entry config profile. + * + * @return the GNA data entry config profile + * @throws Exception the exception + */ + private GNADataEntryConfigProfile getGNADataEntryConfigProfile() throws Exception { + + GNADataEntryConfigProfile profile = SessionUtil.getGNADataEntryConfigProfile(getThreadLocalRequest()); + if (profile == null) { + LOG.info(GNADataEntryConfigProfile.class.getSimpleName() + " is null, loading configurations from IS"); + //to be sure + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + GeoportalCommon gCommon = new GeoportalCommon(); + profile = gCommon.readGNADataEntryConfig(); + SessionUtil.setGNADataEntryConfigProfile(getThreadLocalRequest(), profile); + } else { + LOG.info(GNADataEntryConfigProfile.class.getSimpleName() + " read from session"); + } + + return profile; + } + /** * Save geona data forms. * @@ -398,7 +421,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.info("getLinksFor called"); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - GeoNaDataViewerProfile grViewerProfile = SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest()); + GNADataViewerConfigProfile grViewerProfile = SessionUtil + .getGeportalViewerResourceProfile(getThreadLocalRequest()); GeoportalCommon gc = new GeoportalCommon(grViewerProfile); GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase()); item = gc.getPublicLinksFor(item, false); @@ -424,7 +448,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen try { SessionUtil.getCurrentContext(getThreadLocalRequest(), true); - MongoServiceCommon serviceCommon = new MongoServiceCommon(); // TODO MUST BE REPLACED BY COUNT @@ -725,41 +748,38 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen "Error occurred on updating the project with id: " + itemId + ". Error: " + e.getMessage()); } } - - /** - * Gets the my rights in the context. - * - * @return the my rights in the context - * @throws Exception the exception - */ + @Override - public UserRights getMyRightsInTheContext() throws Exception { - LOG.info("getMyRightsInTheContext called"); + public GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception { + LOG.info("readDataViewerConfig called"); GCubeUser user = null; - + GNADataEntryExtConfigProfile gnaDEExtConfig = new GNADataEntryExtConfigProfile(); try { PortalContext pContext = PortalContext.getConfiguration(); user = pContext.getCurrentUser(this.getThreadLocalRequest()); - SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - GNADataConfigProfileReader gnaConfigReader = new GNADataConfigProfileReader(); - GNADataConfigProfile config = gnaConfigReader.readProfileFromInfrastrucure(); + String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + + GNADataEntryConfigProfile config = getGNADataEntryConfigProfile(); List listUserRightsForRole = config.getPermissionsForRole(); + gnaDEExtConfig.setListItemFields(config.getListItemFields()); + gnaDEExtConfig.setPermissionsForRole(listUserRightsForRole); + // DEV MODE if (!SessionUtil.isIntoPortal()) { LOG.warn("OUT OF PORTAL - DEV MODE detected"); - GcubeUserRole myRole = GcubeUserRole.DATA_MEMBER; + GcubeUserRole myRole = GcubeUserRole.DATA_EDITOR; for (RoleRights roleRight : listUserRightsForRole) { if (roleRight.getUserRole().equals(myRole)) { UserRights userRights = new UserRights(user.getUsername(), roleRight); LOG.warn("DEV MODE returning: " + userRights); - return userRights; + gnaDEExtConfig.setUserRights(userRights); + return gnaDEExtConfig; } } } - String scope = pContext.getCurrentScope(this.getThreadLocalRequest()); long groupId = pContext.getCurrentGroupId(this.getThreadLocalRequest()); if (user == null || scope == null) { @@ -805,29 +825,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } UserRights userRights = new UserRights(user.getUsername(), toRoleRight); LOG.info("returning: " + userRights); - return userRights; - } catch (UserRetrievalFault | GroupRetrievalFault | GNAUserRightsConfigException e) { + gnaDEExtConfig.setUserRights(userRights); + return gnaDEExtConfig; + } catch (UserRetrievalFault | GroupRetrievalFault | GNAConfigException e) { LOG.error("An error occurred during getMyRightsInTheContext: " + user, e); Map permissions = new HashMap(); RoleRights roleRights = new RoleRights(permissions, GcubeUserRole.DATA_MEMBER); UserRights ur = new UserRights(user.getUsername(), roleRights); LOG.warn("Returning default user rights: " + ur); - return ur; + gnaDEExtConfig.setUserRights(ur); + return gnaDEExtConfig; } - } - - // TODO THIS PART REQUIRES THE JSON MAPPING based on keys read from gCube Meta - /** - * List display fields. - * - * @return the list - */ - @Override - public List listDisplayFields() { - GeoportalCommon gc = new GeoportalCommon(); - return gc.getGNADataConfig().getListItemFields(); - } - } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index 99cb439..80e1177 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -13,7 +13,8 @@ import javax.servlet.http.HttpSession; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportalcommon.GeoportalCommon; -import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile; +import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; @@ -38,6 +39,8 @@ import com.liferay.portal.service.UserLocalServiceUtil; */ public class SessionUtil { + private static final String GNA_DATAENTRY_CONFIG_PROFILE = "GNA_DATAENTRY_CONFIG_PROFILE"; + private static final String LATEST_RESULT_SET_SORTED = "LATEST_RESULT_SET_SORTED"; private static final String GEONA_DATAVIEWER_PROFILE = "GEONA_DATAVIEWER_PROFILE"; private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI"; /** The log. */ @@ -147,7 +150,7 @@ public class SessionUtil { SessionUtil.getCurrentContext(httpServletRequest, true); MongoServiceUtil serviceUtil = new MongoServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); - + Iterator concessioni = clientMongo.getList(); if (concessioni != null) { while (concessioni.hasNext()) { @@ -173,15 +176,15 @@ public class SessionUtil { * @return the geportal viewer resource profile * @throws Exception the exception */ - public static GeoNaDataViewerProfile getGeportalViewerResourceProfile(HttpServletRequest httpServletRequest) + public static GNADataViewerConfigProfile getGeportalViewerResourceProfile(HttpServletRequest httpServletRequest) throws Exception { HttpSession session = httpServletRequest.getSession(); - GeoNaDataViewerProfile geoNaDataViewerProfile = (GeoNaDataViewerProfile) session + GNADataViewerConfigProfile geoNaDataViewerProfile = (GNADataViewerConfigProfile) session .getAttribute(GEONA_DATAVIEWER_PROFILE); if (geoNaDataViewerProfile == null) { GeoportalCommon gc = new GeoportalCommon(); - geoNaDataViewerProfile = gc.getGeoNaDataViewProfile(null); + geoNaDataViewerProfile = gc.readGNADataViewerConfig(null); session.setAttribute(GEONA_DATAVIEWER_PROFILE, geoNaDataViewerProfile); } @@ -197,18 +200,41 @@ public class SessionUtil { */ public static ResultSetSorted getLatestResultSetSorted(HttpServletRequest httpServletRequest) { HttpSession session = httpServletRequest.getSession(); - return (ResultSetSorted) session.getAttribute("LATEST_RESULT_SET_SORTED"); + return (ResultSetSorted) session.getAttribute(LATEST_RESULT_SET_SORTED); } /** * Gets the latest sort filter. * * @param httpServletRequest the http servlet request + * @param rsSorted the rs sorted * @return the latest sort filter */ public static void setLatestResultSetSorted(HttpServletRequest httpServletRequest, ResultSetSorted rsSorted) { HttpSession session = httpServletRequest.getSession(); - session.setAttribute("LATEST_RESULT_SET_SORTED", rsSorted); + session.setAttribute(LATEST_RESULT_SET_SORTED, rsSorted); } + /** + * Gets the GNA data entry config profile. + * + * @param httpServletRequest the http servlet request + * @return the GNA data entry config profile + */ + public static GNADataEntryConfigProfile getGNADataEntryConfigProfile(HttpServletRequest httpServletRequest) { + HttpSession session = httpServletRequest.getSession(); + return (GNADataEntryConfigProfile) session.getAttribute(GNA_DATAENTRY_CONFIG_PROFILE); + } + + /** + * Sets the GNA data entry config profile. + * + * @param httpServletRequest the http servlet request + * @param gNADEConfigProfile the g NADE config profile + */ + public static void setGNADataEntryConfigProfile(HttpServletRequest httpServletRequest, + GNADataEntryConfigProfile gNADEConfigProfile) { + HttpSession session = httpServletRequest.getSession(); + session.setAttribute(GNA_DATAENTRY_CONFIG_PROFILE, gNADEConfigProfile); + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GNADataEntryExtConfigProfile.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GNADataEntryExtConfigProfile.java new file mode 100644 index 0000000..944d3b7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GNADataEntryExtConfigProfile.java @@ -0,0 +1,46 @@ +package org.gcube.portlets.user.geoportaldataentry.shared; + +import java.io.Serializable; + +import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile; + +/** + * The Class GNADataEntryExtConfigProfile. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Dec 21, 2021 + */ +public class GNADataEntryExtConfigProfile extends GNADataEntryConfigProfile implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3185317083819447952L; + private UserRights userRights = null; + + /** + * Instantiates a new GNA data entry config profile. + */ + public GNADataEntryExtConfigProfile() { + + } + + public UserRights getUserRights() { + return userRights; + } + + public void setUserRights(UserRights userRights) { + this.userRights = userRights; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("GNADataEntryExtConfigProfile [userRights="); + builder.append(userRights); + builder.append("]"); + return builder.toString(); + } + +}