ported to GNADataEntryConfigProfile
This commit is contained in:
parent
03779582ad
commit
8dd267730c
|
@ -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<List<ItemField>>() {
|
||||
/*GeoportalDataEntryServiceAsync.Util.getInstance().listDisplayFields(new AsyncCallback<List<ItemField>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -129,10 +130,9 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
@Override
|
||||
public void onSuccess(List<ItemField> 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<UserRights>() {
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().readDataViewerConfig(new AsyncCallback<GNADataEntryExtConfigProfile>() {
|
||||
|
||||
@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<ItemField> 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<UserRights>() {
|
||||
//
|
||||
// @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<GeonaISConfig>() {
|
||||
//
|
||||
// @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() {
|
||||
|
|
|
@ -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<WorkspaceContentDV> 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<ItemField> listDisplayFields();
|
||||
GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -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<GeoNaFormDataObject> listGeonaFormObjects, AsyncCallback<CommitReport> callback);
|
||||
|
||||
|
||||
void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback);
|
||||
|
||||
|
||||
void getLinksFor(String itemId, RECORD_TYPE recordType, AsyncCallback<GeoNaItemRef> callback);
|
||||
|
||||
|
||||
void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService,
|
||||
AsyncCallback<ResultSetPaginatedData> callback);
|
||||
|
||||
|
||||
void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<Boolean> callback);
|
||||
|
||||
|
||||
void getJSONRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<String> callback);
|
||||
|
||||
|
||||
void updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType, AsyncCallback<ConcessioneDV> callback);
|
||||
|
||||
|
||||
void readFileSetPaths(AsyncCallback<FileSetPathsDV> callback);
|
||||
|
||||
|
||||
void getRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<ConcessioneDV> callback);
|
||||
|
||||
|
||||
void updateSectionForRecord(String itemId, String recordType, String section, int pathIndex,
|
||||
List<WorkspaceContentDV> keepCurrentContent, GenericDatasetBean gDBean,
|
||||
AsyncCallback<ConcessioneDV> callback);
|
||||
|
||||
void readDataViewerConfig(AsyncCallback<GNADataEntryExtConfigProfile> asyncCallback);
|
||||
|
||||
void getMyRightsInTheContext(AsyncCallback<UserRights> callback);
|
||||
|
||||
|
||||
void listDisplayFields(AsyncCallback<List<ItemField>> callback);
|
||||
}
|
||||
|
|
|
@ -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<RoleRights> 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<ACTION_ON_ITEM, OPERATION_TYPE> permissions = new HashMap<ACTION_ON_ITEM, RoleRights.OPERATION_TYPE>();
|
||||
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<ItemField> listDisplayFields() {
|
||||
GeoportalCommon gc = new GeoportalCommon();
|
||||
return gc.getGNADataConfig().getListItemFields();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Concessione> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue