#22455, integrated with roles: (Data-Member as default), Data-Manager,
Data-Editor
This commit is contained in:
parent
5898e29529
commit
93c3d1d07d
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/geoportal-data-entry-app-2.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/geoportal-data-entry-app-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/geoportal-data-entry-app-2.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/geoportal-data-entry-app-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -35,5 +35,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/geoportal-data-entry-app-2.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/geoportal-data-entry-app-2.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.1-SNAPSHOT
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-2.1.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -17,8 +17,12 @@
|
|||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-2.0.1-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-2.1.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -37,7 +41,9 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -56,7 +62,9 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -75,7 +83,9 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -94,7 +104,9 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -113,7 +125,9 @@
|
|||
|
||||
|
||||
<property name="context-root" value="geoportal-data-entry-app"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -132,7 +146,9 @@
|
|||
|
||||
|
||||
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -151,7 +167,9 @@
|
|||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
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).
|
||||
|
||||
## [v2.1.0-SNAPSHOT] - 2021-11-24
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#22455] Integrated with roles: (Data-Member as default), Data-Manager, Data-Editor
|
||||
|
||||
|
||||
## [v2.0.1] - 2021-11-17
|
||||
|
||||
- [#22369] Just to include the bug fix for Policy and LicenseID in the geoportal-common
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>geoportal-data-entry-app</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.0.1</version>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<name>GeoPortal Data Entry App</name>
|
||||
<description>The GeoPortal Data Entry App is an application to build the web forms for data entries needed to GeoNa project</description>
|
||||
<scm>
|
||||
|
|
|
@ -17,8 +17,6 @@ public class ConstantsGeoPortalDataEntryApp {
|
|||
|
||||
public static final String HOURS_MINUTES_SEPARATOR = ConstantsMPFormBuilder.HOURS_MINUTES_SEPARATOR;
|
||||
|
||||
public static final String ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT = "Error on inizialization stage, please contact the support!";
|
||||
|
||||
/**
|
||||
* The Enum RECORD_TYPE.
|
||||
*
|
||||
|
@ -31,14 +29,14 @@ public class ConstantsGeoPortalDataEntryApp {
|
|||
}
|
||||
|
||||
/**
|
||||
* The Enum ACTION_ON_ITEM.
|
||||
* The Enum ACTION_PERFORMED_ON_ITEM.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 6, 2021
|
||||
* Nov 25, 2021
|
||||
*/
|
||||
public enum ACTION_ON_ITEM {
|
||||
SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, SHOW_EDIT_MODE, DELETE_RECORD, UPDATED_RECORD
|
||||
public enum ACTION_PERFORMED_ON_ITEM {
|
||||
UPDATED_PROJECT
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,10 +65,20 @@ public class ConstantsGeoPortalDataEntryApp {
|
|||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the json field name.
|
||||
*
|
||||
* @return the json field name
|
||||
*/
|
||||
public String getJsonFieldName() {
|
||||
return jsonFieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name.
|
||||
*
|
||||
* @return the display name
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
|
|
@ -11,19 +11,23 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
|||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.resource.Images;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainTabPanel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.ModalWindow;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.EditModeRecord;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
|
||||
|
@ -34,11 +38,16 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil;
|
|||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG;
|
||||
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.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GcubeUserRole;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.RoleRights;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.RoleRights.OPERATION_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
||||
|
@ -58,6 +67,7 @@ import com.google.gwt.user.client.Window;
|
|||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
|
@ -82,7 +92,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
private LinkedHashMap<String, GeoNaFormCardModel> mapForms = new LinkedHashMap<String, GeoNaFormCardModel>();
|
||||
|
||||
private GeonaDataEntryMainForm geoNaMainForm;
|
||||
private GeonaDataEntryMainForm geoNaMainForm = null;
|
||||
|
||||
private Collection<GeoNaFormCardModel> orderedCards;
|
||||
|
||||
|
@ -94,6 +104,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
private GeonaRecordsPaginatedView grpw = null;
|
||||
|
||||
private UserRights myRights = null;
|
||||
|
||||
private LoaderIcon loader = new LoaderIcon("Loading Application...");
|
||||
|
||||
/**
|
||||
* This is the entry point method.
|
||||
*/
|
||||
|
@ -104,34 +118,82 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
SortFilter initialSortFilter = new SortFilter(RECORD_FIELD.NAME, ORDER.ASC);
|
||||
|
||||
RootPanel.get(DIV_PORTLET_ID).add(loader);
|
||||
|
||||
mainTabPanel = new GeonaMainTabPanel(appManagerBus, sortByOptions, initialSortFilter);
|
||||
mainTabPanel.setLoaderVisible("Loading...", true);
|
||||
|
||||
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
||||
mainTabPanel.addFormPanel(geoNaMainForm);
|
||||
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().getMyRightsInTheContext(new AsyncCallback<UserRights>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT);
|
||||
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(GeonaISConfig result) {
|
||||
public void onSuccess(UserRights result) {
|
||||
try {
|
||||
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
||||
} catch (Exception e) {
|
||||
|
||||
if (result != null && result.getgRSecondaryType() != null && result.getScope() != null) {
|
||||
callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType());
|
||||
} else
|
||||
Window.alert(
|
||||
ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT);
|
||||
}
|
||||
|
||||
initGUI();
|
||||
myRights = result;
|
||||
|
||||
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() {
|
||||
bindEvents();
|
||||
mainTabPanel.addFormPanel(geoNaMainForm);
|
||||
RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel);
|
||||
|
||||
Window.addResizeHandler(new ResizeHandler() {
|
||||
@Override
|
||||
public void onResize(ResizeEvent event) {
|
||||
|
@ -143,21 +205,29 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
updateSize();
|
||||
}
|
||||
|
||||
private static native void click(Element element)/*-{
|
||||
element.click();
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Update window size
|
||||
*/
|
||||
public void updateSize() {
|
||||
|
||||
RootPanel workspace = RootPanel.get(DIV_PORTLET_ID);
|
||||
int topBorder = workspace.getAbsoluteTop();
|
||||
int footer = 85; // footer is bottombar + sponsor
|
||||
int headerSize = 90;
|
||||
// int headerSize = 30;
|
||||
int rootHeight = Window.getClientHeight() - topBorder - headerSize - footer;// - ((footer ==
|
||||
// null)?0:(footer.getOffsetHeight()-15));
|
||||
try {
|
||||
RootPanel workspace = RootPanel.get(DIV_PORTLET_ID);
|
||||
int topBorder = workspace.getAbsoluteTop();
|
||||
int footer = 85; // footer is bottombar + sponsor
|
||||
int headerSize = 90;
|
||||
// int headerSize = 30;
|
||||
int rootHeight = Window.getClientHeight() - topBorder - headerSize - footer;// - ((footer ==
|
||||
// null)?0:(footer.getOffsetHeight()-15));
|
||||
|
||||
GWT.log("New workspace dimension Height: " + rootHeight);
|
||||
mainTabPanel.setInternalHeight(rootHeight);
|
||||
GWT.log("New workspace dimension Height: " + rootHeight);
|
||||
mainTabPanel.setInternalHeight(rootHeight);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
// appController.getMainPanel().setHeight(rootHeight);
|
||||
// appController.getMainPanel().setWidth(rootWidth);
|
||||
|
||||
|
@ -430,14 +500,54 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
|
||||
|
||||
SortFilter sortFilter = getListOfRecordsEvent.getSortFilter();
|
||||
if(sortFilter==null){
|
||||
if (sortFilter == null) {
|
||||
sortFilter = mainTabPanel.getCurrentSortFilter();
|
||||
}
|
||||
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null,
|
||||
sortFilter);
|
||||
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null, sortFilter);
|
||||
mainTabPanel.showListOfConcessioniView(grpw);
|
||||
}
|
||||
});
|
||||
|
||||
appManagerBus.addHandler(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() {
|
||||
|
||||
@Override
|
||||
public <T extends RecordDV> void onDoActionPerformedFired(
|
||||
ActionPerformedOnItemEvent<T> actionPerformedOnItemEvent) {
|
||||
if (actionPerformedOnItemEvent != null) {
|
||||
|
||||
ACTION_PERFORMED_ON_ITEM action = actionPerformedOnItemEvent.getAction();
|
||||
List<T> items = actionPerformedOnItemEvent.getSelectItems();
|
||||
|
||||
if (items == null) {
|
||||
if (grpw != null) {
|
||||
items = (List<T>) grpw.getSelectItems();
|
||||
}
|
||||
}
|
||||
|
||||
if (items == null || items.size() == 0) {
|
||||
Window.alert("No item selected");
|
||||
return;
|
||||
}
|
||||
|
||||
T item = items.get(0);
|
||||
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
if (item instanceof ConcessioneDV) {
|
||||
final ConcessioneDV concessione = (ConcessioneDV) item;
|
||||
GWT.log("onDoActionPerformedFired item: " + concessione);
|
||||
switch (action) {
|
||||
case UPDATED_PROJECT:
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
mainTabPanel.getCurrentSortFilter()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
appManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() {
|
||||
|
||||
|
@ -470,10 +580,41 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
if (item instanceof ConcessioneDV) {
|
||||
|
||||
final ConcessioneDV concessione = (ConcessioneDV) item;
|
||||
GWT.log("ActionOnItemEvente item: " + concessione);
|
||||
GWT.log("onDoActionFired item: " + concessione);
|
||||
|
||||
// Checking if the user is NOT authorized to perform this action in two ways:
|
||||
// 1. the map of actions allowed for the user does not contain the action;
|
||||
RoleRights roleRights = myRights.getRoleRights();
|
||||
OPERATION_TYPE operationType = roleRights.getListPermessions().get(action);
|
||||
boolean allowedOperationForUser = operationType != null? true:false;
|
||||
if (!allowedOperationForUser) {
|
||||
|
||||
String msg = "You are not authorized to perform the action: "+ action.getLabel();
|
||||
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), "Forbidden: "+action, msg, AlertType.WARNING);
|
||||
modalW.show();
|
||||
return;
|
||||
}
|
||||
// 2. the user cannot access to action (e.g. the user cannot write an item of another user)
|
||||
// if so an error is shown
|
||||
GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
|
||||
boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType, concessione);
|
||||
if (!allowedWriteActionOnItem) {
|
||||
String title = "Forbidden: missing write access";
|
||||
String msg = "You do not have write access to item: "+ concessione.getNome();
|
||||
if(!userRole.isWriteOwn()) {
|
||||
msg = "You do not have write access to item: "+ concessione.getNome();
|
||||
}else if (!userRole.isWriteAny()){
|
||||
title = "Forbidden: missing ownership";
|
||||
msg = "You are not the creator of: "+ concessione.getNome() +". You cannot access to it";
|
||||
}
|
||||
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg, AlertType.WARNING);
|
||||
modalW.show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (action) {
|
||||
case SHOW_ON_MAP:
|
||||
case VIEW_ON_MAP:
|
||||
final Modal modal = new Modal(true, true);
|
||||
modal.setCloseVisible(true);
|
||||
final HorizontalPanel hpGetLink = new HorizontalPanel();
|
||||
|
@ -508,10 +649,12 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
break;
|
||||
|
||||
case SHOW_REPORT:
|
||||
case VIEW_REPORT:
|
||||
|
||||
final Modal modal2 = new Modal(true, true);
|
||||
modal2.setTitle("<span style='font-size:20px;'>Report: <span style='color:#555; font-size:20px;'>" + concessione.getNome()
|
||||
+ "</span></span>");
|
||||
modal2.setTitle(
|
||||
"<span style='font-size:20px;'>Report: <span style='color:#555; font-size:20px;'>"
|
||||
+ concessione.getNome() + "</span></span>");
|
||||
modal2.setWidth(800);
|
||||
modal2.setCloseVisible(true);
|
||||
if (concessione.getValidationReport() == null) {
|
||||
|
@ -525,10 +668,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
break;
|
||||
|
||||
case SHOW_EDIT_MODE:
|
||||
case EDIT_PROJECT:
|
||||
final Modal modal3 = new Modal(true, true);
|
||||
modal3.setTitle("<span style='font-size:20px;'>Edit: <span style='color:#555; font-size:20px;'>" + concessione.getNome()
|
||||
+ "</span></span>");
|
||||
modal3.setTitle(
|
||||
"<span style='font-size:20px;'>Edit: <span style='color:#555; font-size:20px;'>"
|
||||
+ concessione.getNome() + "</span></span>");
|
||||
modal3.setWidth(950);
|
||||
modal3.setHeight("700px");
|
||||
modal3.setCloseVisible(true);
|
||||
|
@ -540,12 +684,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
modal3.show();
|
||||
break;
|
||||
|
||||
case UPDATED_RECORD:
|
||||
appManagerBus.fireEvent(
|
||||
new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
mainTabPanel.getCurrentSortFilter()));
|
||||
break;
|
||||
case DELETE_RECORD:
|
||||
// case UPDATED_PROJECT:
|
||||
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
// mainTabPanel.getCurrentSortFilter()));
|
||||
// break;
|
||||
case DELETE_PROJECT:
|
||||
|
||||
String htmlMsg = "Going to delete the project with:";
|
||||
htmlMsg += "<ul>";
|
||||
|
@ -614,6 +757,56 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction, ConcessioneDV concessione) {
|
||||
|
||||
boolean writeAnyAPassed = false;
|
||||
boolean writeOwnPassed = false;
|
||||
|
||||
// Case ADMIN
|
||||
if (userRole.isWriteAny()) {
|
||||
writeAnyAPassed = true;
|
||||
}
|
||||
|
||||
// Case EDITOR
|
||||
// Going to check if the user can RW the record is owner of.
|
||||
if (userRole.isWriteOwn()) {
|
||||
String ownerUser = concessione.getCreationUser();
|
||||
if (ownerUser == null || ownerUser.isEmpty()) {
|
||||
writeOwnPassed = false;
|
||||
}else if (ownerUser.compareTo(myRights.getMyUsername()) == 0) {
|
||||
// if my username is equal the owner of the concessione
|
||||
writeOwnPassed = true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean operationAllowed = false;
|
||||
switch (allowedAction) {
|
||||
case READ:
|
||||
//Access to READ operation is allowed to everyone
|
||||
operationAllowed = true;
|
||||
GWT.log(OPERATION_TYPE.READ+ " ALLOWED? "+operationAllowed);
|
||||
break;
|
||||
case READ_WRITE:
|
||||
//Access to READ_WRITE operation
|
||||
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
||||
GWT.log(OPERATION_TYPE.READ_WRITE+ " ALLOWED? "+operationAllowed);
|
||||
break;
|
||||
case WRITE:
|
||||
//Access to WRITE operation
|
||||
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
||||
GWT.log(OPERATION_TYPE.WRITE+ " ALLOWED? "+operationAllowed);
|
||||
break;
|
||||
case UNKNOWN:
|
||||
operationAllowed = false;
|
||||
GWT.log(OPERATION_TYPE.UNKNOWN+ " ALLOWED? "+operationAllowed);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return operationAllowed;
|
||||
}
|
||||
|
||||
private void purgeFileUploaded() {
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
|||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
|
@ -118,13 +119,24 @@ public interface GeoportalDataEntryService extends RemoteService {
|
|||
/**
|
||||
* Update record.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param jsonUpdate the json update
|
||||
* @param recordType the record type
|
||||
* @param itemId the item id
|
||||
* @param recordType the record type
|
||||
* @param section the section
|
||||
* @param pathIndex the path index
|
||||
* @param keepCurrentContent the keep current content
|
||||
* @param gDBean the g D bean
|
||||
* @return the updated JSON string representing the itemId
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex,
|
||||
List<WorkspaceContentDV> keepCurrentContent, GenericDatasetBean gDBean) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the my rights in the context.
|
||||
*
|
||||
* @return the my rights in the context
|
||||
* @throws Exception
|
||||
*/
|
||||
UserRights getMyRightsInTheContext() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
|||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -74,4 +75,7 @@ public interface GeoportalDataEntryServiceAsync
|
|||
void updateSectionForRecord(String itemId, String recordType, String section, int pathIndex,
|
||||
List<WorkspaceContentDV> keepCurrentContent, GenericDatasetBean gDBean,
|
||||
AsyncCallback<ConcessioneDV> callback);
|
||||
|
||||
|
||||
void getMyRightsInTheContext(AsyncCallback<UserRights> callback);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.events;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ACTION_ON_ITEM;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class ActionOnItemEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 15, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class ActionPerformedOnItemEvent<T extends RecordDV> extends GwtEvent<ActionPerformedOnItemEventHandler> {
|
||||
public static Type<ActionPerformedOnItemEventHandler> TYPE = new Type<ActionPerformedOnItemEventHandler>();
|
||||
private List<T> selectItems;
|
||||
private ACTION_PERFORMED_ON_ITEM action;
|
||||
|
||||
/**
|
||||
* Instantiates a new action performed on item event.
|
||||
*
|
||||
* @param selectItems the select items
|
||||
* @param doAction the do action
|
||||
*/
|
||||
public ActionPerformedOnItemEvent(List<T> selectItems, ACTION_PERFORMED_ON_ITEM doAction) {
|
||||
this.selectItems = selectItems;
|
||||
this.action = doAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<ActionPerformedOnItemEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.
|
||||
* EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(ActionPerformedOnItemEventHandler handler) {
|
||||
handler.onDoActionPerformedFired(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the select items.
|
||||
*
|
||||
* @return the select items
|
||||
*/
|
||||
public List<T> getSelectItems() {
|
||||
return selectItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the action.
|
||||
*
|
||||
* @return the action
|
||||
*/
|
||||
public ACTION_PERFORMED_ON_ITEM getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface ActionPerformedOnItemEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 25, 2021
|
||||
*/
|
||||
public interface ActionPerformedOnItemEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On do action performed fired.
|
||||
* @param <T>
|
||||
*
|
||||
* @param actionPerformedOnItemEvent the action performed on item event
|
||||
*/
|
||||
<T extends RecordDV> void onDoActionPerformedFired(ActionPerformedOnItemEvent<T> actionPerformedOnItemEvent);
|
||||
}
|
|
@ -10,4 +10,7 @@ public interface Images extends ClientBundle {
|
|||
|
||||
@Source("loading.gif")
|
||||
ImageResource loading();
|
||||
|
||||
@Source("access_denied.png")
|
||||
ImageResource accessDenied();
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 962 B |
|
@ -3,7 +3,6 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
||||
|
@ -11,12 +10,14 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProject
|
|||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Dropdown;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.github.gwtbootstrap.client.ui.Tab;
|
||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
|
@ -78,6 +79,9 @@ public class GeonaMainTabPanel extends Composite {
|
|||
@UiField
|
||||
NavLink buttonReloadConcessioni;
|
||||
|
||||
@UiField
|
||||
TabPanel tabPanel;
|
||||
|
||||
@UiField
|
||||
Tab tabNewProject;
|
||||
|
||||
|
@ -149,7 +153,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, currentSortFilter));
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -158,10 +162,8 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null, currentSortFilter);
|
||||
showListOfConcessioniView(grpw);
|
||||
|
||||
|
||||
instanceAndShowListOfConcessioni();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -209,7 +211,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
listConcessioni = grpw.getSelectItems();
|
||||
}
|
||||
appManagerBus
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.SHOW_ON_MAP));
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.VIEW_ON_MAP));
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -223,7 +225,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
listConcessioni = grpw.getSelectItems();
|
||||
}
|
||||
appManagerBus
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.SHOW_REPORT));
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.VIEW_REPORT));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -236,8 +238,8 @@ public class GeonaMainTabPanel extends Composite {
|
|||
if (grpw != null && grpw.getSelectItems() != null) {
|
||||
listConcessioni = grpw.getSelectItems();
|
||||
}
|
||||
appManagerBus
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.SHOW_EDIT_MODE));
|
||||
appManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.EDIT_PROJECT));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -250,7 +252,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
listConcessioni = grpw.getSelectItems();
|
||||
}
|
||||
appManagerBus
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.DELETE_RECORD));
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.DELETE_PROJECT));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -335,4 +337,22 @@ public class GeonaMainTabPanel extends Composite {
|
|||
return currentSortFilter;
|
||||
}
|
||||
|
||||
public void removeTab(int index) {
|
||||
tabPanel.remove(index);
|
||||
}
|
||||
|
||||
public void setTabActive(int index) {
|
||||
tabPanel.selectTab(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dirty solution.
|
||||
* I created this one because I had problem on firing click event for Tab element
|
||||
*
|
||||
*/
|
||||
public void instanceAndShowListOfConcessioni(){
|
||||
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null, currentSortFilter);
|
||||
showListOfConcessioniView(grpw);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
|
||||
public class ModalWindow {
|
||||
|
||||
private HorizontalPanel hp = new HorizontalPanel();
|
||||
private Modal modal;
|
||||
|
||||
public ModalWindow(Image icon, String title, String msg, AlertType alertType) {
|
||||
|
||||
modal = new Modal(false);
|
||||
modal.hide(false);
|
||||
modal.setTitle(title);
|
||||
modal.setCloseVisible(true);
|
||||
|
||||
|
||||
Alert alert = new Alert();
|
||||
alert.setType(alertType);
|
||||
alert.setClose(false);
|
||||
alert.setText(msg);
|
||||
alert.getElement().getStyle().setMarginLeft(10, Unit.PX);
|
||||
|
||||
|
||||
if (icon != null)
|
||||
hp.add(icon);
|
||||
hp.add(alert);
|
||||
|
||||
ModalFooter modalFooter = new ModalFooter();
|
||||
final Button buttClose = new Button("Close");
|
||||
modalFooter.add(buttClose);
|
||||
|
||||
buttClose.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
modal.hide();
|
||||
}
|
||||
});
|
||||
|
||||
modal.add(hp);
|
||||
modal.add(modalFooter);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
modal.show();
|
||||
}
|
||||
|
||||
}
|
|
@ -7,11 +7,11 @@ import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
|
|||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.JSONEditorWrapper;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
|
@ -66,7 +66,7 @@ public class EditModeRecord extends Composite {
|
|||
private JSONEditorWrapper jsEditor;
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
|
||||
private final HandlerManager editorManagerBus = new HandlerManager(null);
|
||||
|
||||
/**
|
||||
|
@ -159,7 +159,7 @@ public class EditModeRecord extends Composite {
|
|||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
|
||||
|
||||
buttonJSONUpdate.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -181,8 +181,8 @@ public class EditModeRecord extends Composite {
|
|||
// TODO: handle exception
|
||||
}
|
||||
|
||||
editorManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>(null, ACTION_ON_ITEM.UPDATED_RECORD));
|
||||
editorManagerBus.fireEvent(new ActionPerformedOnItemEvent<ConcessioneDV>(null,
|
||||
ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT));
|
||||
|
||||
}
|
||||
|
||||
|
@ -195,38 +195,38 @@ public class EditModeRecord extends Composite {
|
|||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
DialogInform di = new DialogInform(null, "Project updated!", "Project '" + result.getNome() + "' updated correctly");
|
||||
|
||||
DialogInform di = new DialogInform(null, "Project updated!",
|
||||
"Project '" + result.getNome() + "' updated correctly");
|
||||
di.setZIndex(100000);
|
||||
di.center();
|
||||
editorManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>(Arrays.asList(result), ACTION_ON_ITEM.UPDATED_RECORD));
|
||||
editorManagerBus.fireEvent(new ActionPerformedOnItemEvent<ConcessioneDV>(
|
||||
Arrays.asList(result), ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
editorManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() {
|
||||
|
||||
editorManagerBus.addHandler(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() {
|
||||
|
||||
@Override
|
||||
public <T extends RecordDV> void onDoActionFired(ActionOnItemEvent<T> showItemEvent) {
|
||||
|
||||
ACTION_ON_ITEM action = showItemEvent.getAction();
|
||||
List<T> items = showItemEvent.getSelectItems();
|
||||
|
||||
if(items!=null) {
|
||||
public <T extends RecordDV> void onDoActionPerformedFired(
|
||||
ActionPerformedOnItemEvent<T> actionPerformedOnItemEvent) {
|
||||
ACTION_PERFORMED_ON_ITEM action = actionPerformedOnItemEvent.getAction();
|
||||
List<T> items = actionPerformedOnItemEvent.getSelectItems();
|
||||
|
||||
if (items != null) {
|
||||
selectedConcessione = (BaseConcessioneDV) items.get(0);
|
||||
instanceJSONEditor();
|
||||
|
||||
if(action.equals(ACTION_ON_ITEM.UPDATED_RECORD)) {
|
||||
appManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>((List<ConcessioneDV>) items, ACTION_ON_ITEM.UPDATED_RECORD));
|
||||
|
||||
if (action.equals(ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT)) {
|
||||
appManagerBus.fireEvent(new ActionPerformedOnItemEvent<ConcessioneDV>(
|
||||
(List<ConcessioneDV>) items, ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelaz
|
|||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.StringUtil;
|
||||
|
@ -262,7 +262,7 @@ public class UpdateFileset extends Composite {
|
|||
buttonUpdate.setEnabled(true);
|
||||
showUploadFileGUI();
|
||||
editorManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>(Arrays.asList(fullConcessione), ACTION_ON_ITEM.UPDATED_RECORD));
|
||||
new ActionPerformedOnItemEvent<ConcessioneDV>(Arrays.asList(fullConcessione), ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT));
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -351,7 +351,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
// @Override
|
||||
// public void update(int index, T object, String value) {
|
||||
// GWT.log("clicked show");
|
||||
// eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.SHOW_ON_MAP));
|
||||
// eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.VIEW_ON_MAP));
|
||||
// }
|
||||
// });
|
||||
// sortedCellTable.addColumn(showOnMapColumn);
|
||||
|
@ -370,7 +370,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
// @Override
|
||||
// public void update(int index, T object, String value) {
|
||||
//
|
||||
// eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.SHOW_REPORT));
|
||||
// eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.VIEW_REPORT));
|
||||
// }
|
||||
// });
|
||||
// sortedCellTable.addColumn(showReportRecordColumn);
|
||||
|
@ -389,7 +389,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
// @Override
|
||||
// public void update(int index, T object, String value) {
|
||||
//
|
||||
// eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.DELETE_RECORD));
|
||||
// eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.DELETE_PROJECT));
|
||||
// }
|
||||
// });
|
||||
// sortedCellTable.addColumn(deleteRecordColumn);
|
||||
|
|
|
@ -25,19 +25,32 @@ 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;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService;
|
||||
import org.gcube.portlets.user.geoportaldataentry.server.MongoServiceUtil.ConcessioneValidationReportStatusComparator;
|
||||
import org.gcube.portlets.user.geoportaldataentry.server.config.GNARoleRitghtsConfigReader;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GNAUserRightsConfigNotFoundException;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GcubeUserRole;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.RoleRights;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.RoleRights.OPERATION_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
|
||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -760,19 +773,19 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
String toEditPath = null;
|
||||
AddSectionToConcessioneRequest request = null;
|
||||
List<TempFile> files = new ArrayList<TempFile>();
|
||||
|
||||
|
||||
// Managing files already present as current content and kept by user
|
||||
List<TempFile> keepFiles = serviceUtil.toTemFilesFromWSC(keepCurrentContent);
|
||||
if (keepFiles != null) {
|
||||
files.addAll(keepFiles);
|
||||
LOG.debug(keepFiles.size() +" current corrent file/s has/have been added to list of files");
|
||||
LOG.debug(keepFiles.size() + " current corrent file/s has/have been added to list of files");
|
||||
}
|
||||
|
||||
// Managing new files uploaded by user
|
||||
List<TempFile> newFiles = serviceUtil.toTemFiles(gDBean.getFilesUploaded());
|
||||
if (newFiles != null) {
|
||||
files.addAll(newFiles);
|
||||
LOG.debug(newFiles.size() +" new file/s has/have been added to list of files");
|
||||
LOG.debug(newFiles.size() + " new file/s has/have been added to list of files");
|
||||
}
|
||||
|
||||
// if (files == null || files.isEmpty())
|
||||
|
@ -808,21 +821,21 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
Concessione concessione = clientMongo.cleanFileSet(itemId, toEditPath);
|
||||
|
||||
LOG.debug("Sending new Fileset ..");
|
||||
if(files.size()>0) {
|
||||
if (files.size() > 0) {
|
||||
// StorageUtils storage=new StorageUtils();
|
||||
// Building TempFile
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
LOG.info("Registering FileSet into recordId " + itemId + " with request path: " + toEditPath + " and: "
|
||||
+ files.size() + " file/s");
|
||||
LOG.info("Registering FileSet into recordId " + itemId + " with request path: " + toEditPath
|
||||
+ " and: " + files.size() + " file/s");
|
||||
concessione = clientMongo.registerFileSet(itemId, request);
|
||||
}else {
|
||||
} else {
|
||||
LOG.info("Fileset is empty, skipping registerFileSet");
|
||||
}
|
||||
|
||||
LOG.info("Publishings itemId: "+itemId);
|
||||
|
||||
LOG.info("Publishings itemId: " + itemId);
|
||||
concessione = clientMongo.publish(itemId);
|
||||
|
||||
LOG.debug("returning concessione: "+concessione);
|
||||
|
||||
LOG.debug("returning concessione: " + concessione);
|
||||
return ConvertToDataViewModel.toConcessione(concessione);
|
||||
}
|
||||
|
||||
|
@ -835,4 +848,88 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserRights getMyRightsInTheContext() throws Exception {
|
||||
LOG.info("getMyRightsInTheContext called");
|
||||
|
||||
GCubeUser user = null;
|
||||
|
||||
try {
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
user = pContext.getCurrentUser(this.getThreadLocalRequest());
|
||||
|
||||
List<RoleRights> listUserRightsForRole = GNARoleRitghtsConfigReader.readRoleRightsConfig();
|
||||
// DEV MODE
|
||||
if (!SessionUtil.isIntoPortal()) {
|
||||
LOG.warn("OUT OF PORTAL - DEV MODE detected");
|
||||
GcubeUserRole myRole = GcubeUserRole.DATA_MEMBER;
|
||||
|
||||
for (RoleRights roleRight : listUserRightsForRole) {
|
||||
if (roleRight.getUserRole().equals(myRole)) {
|
||||
UserRights userRights = new UserRights(user.getUsername(), roleRight);
|
||||
LOG.warn("DEV MODE returning: " + userRights);
|
||||
return userRights;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String scope = pContext.getCurrentScope(this.getThreadLocalRequest());
|
||||
long groupId = pContext.getCurrentGroupId(this.getThreadLocalRequest());
|
||||
|
||||
if (user == null || scope == null) {
|
||||
LOG.warn("called getMyRightsInTheContext with invalid parameter user: " + user + ", in the scope: "
|
||||
+ scope, ", returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
LOG.info("reading GcubeUserRole for user: " + user.getUsername() + ", in the scope: " + scope);
|
||||
// The following snippet should pass in the service-side
|
||||
RoleManager roleManager = new LiferayRoleManager();
|
||||
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(user.getUserId(), groupId);
|
||||
List<GcubeUserRole> listMyRoles = new ArrayList<GcubeUserRole>();
|
||||
for (GCubeRole gCubeRole : roles) {
|
||||
if (gCubeRole.getRoleName().equalsIgnoreCase(GcubeUserRole.DATA_EDITOR.getName())) {
|
||||
listMyRoles.add(GcubeUserRole.DATA_EDITOR);
|
||||
}
|
||||
if (gCubeRole.getRoleName().equalsIgnoreCase(GcubeUserRole.DATA_MANAGER.getName())) {
|
||||
listMyRoles.add(GcubeUserRole.DATA_MANAGER);
|
||||
}
|
||||
}
|
||||
|
||||
// Mapping to roles "known"
|
||||
LOG.info(
|
||||
"For user: " + user.getUsername() + " in the scope: " + scope + " read the role/s: " + listMyRoles);
|
||||
|
||||
GcubeUserRole myRole = null;
|
||||
if (listMyRoles.contains(GcubeUserRole.DATA_MANAGER))
|
||||
myRole = GcubeUserRole.DATA_MANAGER;
|
||||
else if (listMyRoles.contains(GcubeUserRole.DATA_EDITOR))
|
||||
myRole = GcubeUserRole.DATA_EDITOR;
|
||||
else
|
||||
myRole = GcubeUserRole.DATA_MEMBER;
|
||||
|
||||
LOG.info("using highest role: " + myRole);
|
||||
|
||||
RoleRights toRoleRight = null;
|
||||
for (RoleRights roleRight : listUserRightsForRole) {
|
||||
if (roleRight.getUserRole().equals(myRole)) {
|
||||
toRoleRight = roleRight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UserRights userRights = new UserRights(scope, toRoleRight);
|
||||
LOG.info("returning: " + userRights);
|
||||
return userRights;
|
||||
} catch (UserRetrievalFault | GroupRetrievalFault | GNAUserRightsConfigNotFoundException 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
,francescomangiacrapa,francesco-xps,26.11.2021 11:54,file:///home/francescomangiacrapa/.config/libreoffice/4;
|
|
@ -0,0 +1,152 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.geoportaldataentry.server.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class CSVFile.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Jan 29, 2019
|
||||
*/
|
||||
public class CSVFile implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6408321963787244600L;
|
||||
private CSVRow headerRow;
|
||||
private List<CSVRow> valueRows;
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* Instantiates a new CSV file.
|
||||
*/
|
||||
public CSVFile(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new csv file.
|
||||
*
|
||||
* @param fileName the file name
|
||||
* @param headerRow the header row
|
||||
* @param valueRows the value rows
|
||||
*/
|
||||
public CSVFile(String fileName, CSVRow headerRow, List<CSVRow> valueRows) {
|
||||
this.fileName = fileName;
|
||||
this.headerRow = headerRow;
|
||||
this.valueRows = valueRows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the header row.
|
||||
*
|
||||
* @return the headerRow
|
||||
*/
|
||||
public CSVRow getHeaderRow() {
|
||||
|
||||
return headerRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the value row.
|
||||
*
|
||||
* @param row the row
|
||||
*/
|
||||
public void addValueRow(CSVRow row) {
|
||||
if(valueRows==null)
|
||||
valueRows = new ArrayList<CSVRow>();
|
||||
|
||||
valueRows.add(row);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value rows.
|
||||
*
|
||||
* @param valueRows the new value rows
|
||||
*/
|
||||
public void setValueRows(List<CSVRow> valueRows) {
|
||||
this.valueRows = valueRows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the value rows.
|
||||
*
|
||||
* @return the valueRows
|
||||
*/
|
||||
public List<CSVRow> getValueRows() {
|
||||
|
||||
return valueRows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the header row.
|
||||
*
|
||||
* @param headerRow the headerRow to set
|
||||
*/
|
||||
public void setHeaderRow(CSVRow headerRow) {
|
||||
|
||||
this.headerRow = headerRow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the file name.
|
||||
*
|
||||
* @return the fileName
|
||||
*/
|
||||
public String getFileName() {
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the file name.
|
||||
*
|
||||
* @param fileName the fileName to set
|
||||
*/
|
||||
public void setFileName(String fileName) {
|
||||
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CSVFile [headerRow=");
|
||||
builder.append(headerRow);
|
||||
builder.append(", valueRows=");
|
||||
builder.append(valueRows);
|
||||
builder.append(", fileName=");
|
||||
builder.append(fileName);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
package org.gcube.portlets.user.geoportaldataentry.server.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* The Class CSVReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Jan 29, 2019
|
||||
*/
|
||||
public class CSVReader {
|
||||
|
||||
public static final char DEFAULT_SEPARATOR = ',';
|
||||
public static final char DEFAULT_QUOTE = '"';
|
||||
private File file;
|
||||
private CSVFile csvFile;
|
||||
|
||||
/**
|
||||
* Instantiates a new CSV reader.
|
||||
*
|
||||
* @param file the file
|
||||
* @throws FileNotFoundException the file not found exception
|
||||
*/
|
||||
public CSVReader(File file) throws FileNotFoundException {
|
||||
|
||||
this.file = file;
|
||||
this.csvFile = new CSVFile();
|
||||
readCSV(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read csv.
|
||||
*
|
||||
* @param file the file
|
||||
* @throws FileNotFoundException the file not found exception
|
||||
*/
|
||||
private void readCSV(File file) throws FileNotFoundException {
|
||||
|
||||
Scanner scanner = new Scanner(file);
|
||||
csvFile.setFileName(file.getName());
|
||||
int i = 0;
|
||||
while (scanner.hasNext()) {
|
||||
CSVRow csvRow = new CSVRow();
|
||||
List<String> line = parseLine(scanner.nextLine());
|
||||
csvRow.setListValues(line);
|
||||
|
||||
if(i==0){
|
||||
csvFile.setHeaderRow(csvRow);
|
||||
}else{
|
||||
csvFile.addValueRow(csvRow);
|
||||
}
|
||||
i++;
|
||||
|
||||
}
|
||||
scanner.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the line.
|
||||
*
|
||||
* @param cvsLine the cvs line
|
||||
* @return the list
|
||||
*/
|
||||
public static List<String> parseLine(String cvsLine) {
|
||||
|
||||
return parseLine(cvsLine, DEFAULT_SEPARATOR, DEFAULT_QUOTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the line.
|
||||
*
|
||||
* @param cvsLine the cvs line
|
||||
* @param separators the separators
|
||||
* @return the list
|
||||
*/
|
||||
public static List<String> parseLine(String cvsLine, char separators) {
|
||||
|
||||
return parseLine(cvsLine, separators, DEFAULT_QUOTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the line.
|
||||
*
|
||||
* @param cvsLine the cvs line
|
||||
* @param separators the separators
|
||||
* @param customQuote the custom quote
|
||||
* @return the list
|
||||
*/
|
||||
private static List<String> parseLine(String cvsLine, char separators, char customQuote) {
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
// if empty, return!
|
||||
if (cvsLine == null || cvsLine.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
if (customQuote == ' ') {
|
||||
customQuote = DEFAULT_QUOTE;
|
||||
}
|
||||
if (separators == ' ') {
|
||||
separators = DEFAULT_SEPARATOR;
|
||||
}
|
||||
StringBuffer curVal = new StringBuffer();
|
||||
boolean inQuotes = false;
|
||||
boolean startCollectChar = false;
|
||||
boolean doubleQuotesInColumn = false;
|
||||
char[] chars = cvsLine.toCharArray();
|
||||
for (char ch : chars) {
|
||||
if (inQuotes) {
|
||||
startCollectChar = true;
|
||||
if (ch == customQuote) {
|
||||
inQuotes = false;
|
||||
doubleQuotesInColumn = false;
|
||||
}
|
||||
else {
|
||||
// Fixed : allow "" in custom quote enclosed
|
||||
if (ch == '\"') {
|
||||
if (!doubleQuotesInColumn) {
|
||||
curVal.append(ch);
|
||||
doubleQuotesInColumn = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
curVal.append(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ch == customQuote) {
|
||||
inQuotes = true;
|
||||
// Fixed : allow "" in empty quote enclosed
|
||||
if (chars[0] != '"' && customQuote == '\"') {
|
||||
curVal.append('"');
|
||||
}
|
||||
// double quotes in column will hit this!
|
||||
if (startCollectChar) {
|
||||
curVal.append('"');
|
||||
}
|
||||
}
|
||||
else if (ch == separators) {
|
||||
result.add(curVal.toString());
|
||||
curVal = new StringBuffer();
|
||||
startCollectChar = false;
|
||||
}
|
||||
else if (ch == '\r') {
|
||||
// ignore LF characters
|
||||
continue;
|
||||
}
|
||||
else if (ch == '\n') {
|
||||
// the end, break!
|
||||
break;
|
||||
}
|
||||
else {
|
||||
curVal.append(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.add(curVal.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the csv file.
|
||||
*
|
||||
* @return the csvFile
|
||||
*/
|
||||
public CSVFile getCsvFile() {
|
||||
|
||||
return csvFile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the file.
|
||||
*
|
||||
* @return the file
|
||||
*/
|
||||
public File getFile() {
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.geoportaldataentry.server.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* The Class CSVRow.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Jan 29, 2019
|
||||
*/
|
||||
public class CSVRow implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6254861811998867626L;
|
||||
|
||||
private List<String> listValues;
|
||||
|
||||
/**
|
||||
* Instantiates a new CSV row.
|
||||
*/
|
||||
public CSVRow(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list values.
|
||||
*
|
||||
* @return the listValues
|
||||
*/
|
||||
public List<String> getListValues() {
|
||||
|
||||
return listValues;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param listValues the listValues to set
|
||||
*/
|
||||
public void setListValues(List<String> listValues) {
|
||||
|
||||
this.listValues = listValues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the value.
|
||||
*
|
||||
* @param value the value
|
||||
*/
|
||||
public void addValue(String value) {
|
||||
if(listValues==null)
|
||||
listValues = new ArrayList<String>();
|
||||
|
||||
listValues.add(value);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CSVRow [listValues=");
|
||||
builder.append(listValues);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.server.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class FileUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
|
||||
* Apr 21, 2020
|
||||
*/
|
||||
public class FileUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Input stream to temp file.
|
||||
*
|
||||
* @param inputStream the input stream
|
||||
* @param fileName the file name
|
||||
* @return the file
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
// InputStream -> Temp File
|
||||
public static File inputStreamToTempFile(InputStream inputStream, String fileName)
|
||||
throws IOException {
|
||||
|
||||
File tempFile = File.createTempFile(fileName, ".tmp");
|
||||
//File tempFile = File.createTempFile("MyAppName-", ".tmp");
|
||||
try (FileOutputStream outputStream = new FileOutputStream(tempFile)) {
|
||||
|
||||
int read;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
return tempFile;
|
||||
|
||||
}finally {
|
||||
tempFile.deleteOnExit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy input stream to file.
|
||||
*
|
||||
* @param is the is
|
||||
* @param to the to
|
||||
* @return the file
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static File copyInputStreamToFile(InputStream is, String to) throws IOException {
|
||||
Path dest = Paths.get(to);
|
||||
Files.copy(is, dest);
|
||||
return new File(to);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.server.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GNAUserRightsConfigNotFoundException;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GcubeUserRole;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.RoleRights;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.RoleRights.OPERATION_TYPE;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
||||
/**
|
||||
* The Class GNARoleRitghtsConfigReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 25, 2021
|
||||
*/
|
||||
public class GNARoleRitghtsConfigReader {
|
||||
|
||||
private static final String USER_RIGHTS_CONFIG_FILENAME = "GNA_RoleRights_Configurations.csv";
|
||||
private static Logger LOG = LoggerFactory.getLogger(GNARoleRitghtsConfigReader.class);
|
||||
|
||||
public static final String WRITE_OWN_CONFIG = "WRITE_OWN";
|
||||
public static final String WRITE_ANY_CONFIG = "WRITE_ANY";
|
||||
|
||||
/**
|
||||
* Read user rights config.
|
||||
*
|
||||
* @return the list
|
||||
* @throws GNAUserRightsConfigNotFoundException the GNA user rights config not
|
||||
* found exception
|
||||
*/
|
||||
public static List<RoleRights> readRoleRightsConfig() throws GNAUserRightsConfigNotFoundException {
|
||||
|
||||
File configurationFile = null;
|
||||
|
||||
try {
|
||||
|
||||
InputStream in = (InputStream) GNARoleRitghtsConfigReader.class.getResourceAsStream(USER_RIGHTS_CONFIG_FILENAME);
|
||||
configurationFile = FileUtil.inputStreamToTempFile(in, USER_RIGHTS_CONFIG_FILENAME);
|
||||
CSVReader reader = new CSVReader(configurationFile);
|
||||
CSVFile csvFile = reader.getCsvFile();
|
||||
List<RoleRights> listUserRights = new ArrayList<RoleRights>();
|
||||
|
||||
List<String> headerKeys = csvFile.getHeaderRow().getListValues();
|
||||
List<CSVRow> rows = csvFile.getValueRows();
|
||||
|
||||
// MAPPING OPERATION TYPE AS READ, WRITE, etc.
|
||||
Map<String, OPERATION_TYPE> mapOperationTypes = new HashMap<String, RoleRights.OPERATION_TYPE>();
|
||||
CSVRow operationTypeRow = rows.get(0);
|
||||
List<String> rowValues = operationTypeRow.getListValues();
|
||||
for (int j = 1; j < rowValues.size(); j++) {
|
||||
String operationType = rowValues.get(j);
|
||||
RoleRights.OPERATION_TYPE ot = RoleRights.OPERATION_TYPE.UNKNOWN;
|
||||
if (operationType.equalsIgnoreCase("R")) {
|
||||
ot = RoleRights.OPERATION_TYPE.READ;
|
||||
} else if (operationType.equalsIgnoreCase("RW")) {
|
||||
ot = RoleRights.OPERATION_TYPE.READ_WRITE;
|
||||
} else if (operationType.equalsIgnoreCase("W")) {
|
||||
ot = RoleRights.OPERATION_TYPE.WRITE;
|
||||
}
|
||||
|
||||
mapOperationTypes.put(headerKeys.get(j), ot);
|
||||
}
|
||||
|
||||
LOG.debug("Map of operation types: " + mapOperationTypes);
|
||||
|
||||
//Starting from index 1 (means the second row in the CSV)
|
||||
for (int i = 1; i < rows.size(); i++) {
|
||||
LOG.trace(i + " row");
|
||||
RoleRights useRights = new RoleRights();
|
||||
CSVRow row = rows.get(i);
|
||||
|
||||
// to map properties
|
||||
rowValues = row.getListValues();
|
||||
|
||||
LOG.debug("rowValues: " + rowValues);
|
||||
Map<String, String> mapUserRolePermissions = new HashMap<String, String>();
|
||||
|
||||
GcubeUserRole gCubeUserRole = toGcubeUserRole(rowValues.get(0));
|
||||
|
||||
if (gCubeUserRole == null) {
|
||||
LOG.warn("The Role " + rowValues.get(0) + " not found into roleName of: " + GcubeUserRole.values());
|
||||
continue;
|
||||
}
|
||||
|
||||
useRights.setUserRole(gCubeUserRole);
|
||||
|
||||
for (int j = 1; j < rowValues.size(); j++) {
|
||||
mapUserRolePermissions.put(headerKeys.get(j), rowValues.get(j));
|
||||
}
|
||||
LOG.debug("Role: " + useRights.getUserRole());
|
||||
LOG.debug("Permissions read: " + mapUserRolePermissions);
|
||||
|
||||
Map<ACTION_ON_ITEM, OPERATION_TYPE> listPermessions = new HashMap<ACTION_ON_ITEM, OPERATION_TYPE>();
|
||||
|
||||
for (ACTION_ON_ITEM value : ACTION_ON_ITEM.values()) {
|
||||
String yesno = mapUserRolePermissions.get(value.name());
|
||||
|
||||
if (yesno != null && yesno.equalsIgnoreCase("yes")) {
|
||||
listPermessions.put(value, mapOperationTypes.get(value.name()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
useRights.setListPermessions(listPermessions);
|
||||
|
||||
// String writeOwn = mapUserRolePermissions.get(WRITE_OWN_CONFIG);
|
||||
// if (writeOwn != null && writeOwn.equalsIgnoreCase("yes")) {
|
||||
// useRights.setWriteOwn(true);
|
||||
// }
|
||||
//
|
||||
// String writeAny = mapUserRolePermissions.get(WRITE_ANY_CONFIG);
|
||||
// if (writeAny != null && writeAny.equalsIgnoreCase("yes")) {
|
||||
// useRights.setWriteAny(true);
|
||||
// }
|
||||
|
||||
listUserRights.add(useRights);
|
||||
|
||||
}
|
||||
Log.info("Returning user rights config: " + listUserRights);
|
||||
return listUserRights;
|
||||
|
||||
} catch (IOException e) {
|
||||
LOG.error("An error occurred on reading the property file " + USER_RIGHTS_CONFIG_FILENAME, e);
|
||||
throw new GNAUserRightsConfigNotFoundException("Error on reading the base layers. Is the file '"
|
||||
+ USER_RIGHTS_CONFIG_FILENAME + "' in the application path?");
|
||||
} finally {
|
||||
|
||||
if (configurationFile != null) {
|
||||
try {
|
||||
configurationFile.delete();
|
||||
} catch (Exception e) {
|
||||
// silent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* To gcube user role.
|
||||
*
|
||||
* @param name the name
|
||||
* @return the gcube user role
|
||||
*/
|
||||
public static GcubeUserRole toGcubeUserRole(String name) {
|
||||
|
||||
for (GcubeUserRole gCubeUserRole : GcubeUserRole.values()) {
|
||||
if (gCubeUserRole.getName().equalsIgnoreCase(name))
|
||||
return gCubeUserRole;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
,CREATE_NEW_PROJECT,VIEW_ON_MAP,VIEW_REPORT,EDIT_PROJECT,DELETE_PROJECT
|
||||
OPERATION_TYPE,W,R,RW,RW,RW
|
||||
Data-Member,no,yes,no,no,no
|
||||
Data-Editor,yes,yes,yes,yes,yes
|
||||
Data-Manager,yes,yes,yes,yes,yes
|
|
|
@ -0,0 +1,29 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
/**
|
||||
* The Class ACTION_ON_ITEM.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 24, 2021
|
||||
*/
|
||||
public enum ACTION_ON_ITEM {
|
||||
|
||||
CREATE_NEW_PROJECT("Create New Project"),
|
||||
VIEW_ON_MAP("View on Map"),
|
||||
SHOW_METADATA("Show Metadata"),
|
||||
VIEW_REPORT("View the Report"),
|
||||
EDIT_PROJECT("Edit the Project"),
|
||||
DELETE_PROJECT("Delete the Project");
|
||||
|
||||
String label;
|
||||
|
||||
ACTION_ON_ITEM(String label){
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
public class ActionOnItemType {
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class GNAUserRightsConfigNotFoundException extends Exception {
|
||||
public GNAUserRightsConfigNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
/**
|
||||
* The Enum GcubeUserRole.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 25, 2021
|
||||
*/
|
||||
public enum GcubeUserRole {
|
||||
|
||||
DATA_MEMBER("Data-Member", false, false),
|
||||
DATA_EDITOR("Data-Editor", true, false),
|
||||
DATA_MANAGER("Data-Manager", true, true);
|
||||
|
||||
private String name;
|
||||
private boolean writeOwn;
|
||||
private boolean writeAny;
|
||||
|
||||
/**
|
||||
* Instantiates a new gcube user role.
|
||||
*
|
||||
* @param name the name
|
||||
*/
|
||||
private GcubeUserRole(String name, boolean writeOwn, boolean writeAny) {
|
||||
this.name = name;
|
||||
this.writeOwn = writeOwn;
|
||||
this.writeAny = writeAny;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isWriteOwn() {
|
||||
return writeOwn;
|
||||
}
|
||||
|
||||
public boolean isWriteAny() {
|
||||
return writeAny;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setWriteOwn(boolean writeOwn) {
|
||||
this.writeOwn = writeOwn;
|
||||
}
|
||||
|
||||
public void setWriteAny(boolean writeAny) {
|
||||
this.writeAny = writeAny;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Class RoleRights.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 26, 2021
|
||||
*/
|
||||
public class RoleRights implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -304157165851633221L;
|
||||
|
||||
/**
|
||||
* The Enum OPERATION_TYPE.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 26, 2021
|
||||
*/
|
||||
public static enum OPERATION_TYPE {
|
||||
READ, WRITE, READ_WRITE, UNKNOWN
|
||||
}
|
||||
|
||||
private Map<ACTION_ON_ITEM, OPERATION_TYPE> listPermessions;
|
||||
private GcubeUserRole userRole;
|
||||
|
||||
/**
|
||||
* Instantiates a new user rights.
|
||||
*/
|
||||
public RoleRights() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new role rights.
|
||||
*
|
||||
* @param myUsername the my username
|
||||
* @param listPermessions the list permessions
|
||||
* @param userRole the user role
|
||||
*/
|
||||
public RoleRights(Map<ACTION_ON_ITEM, OPERATION_TYPE> listPermessions, GcubeUserRole userRole) {
|
||||
this.listPermessions = listPermessions;
|
||||
this.userRole = userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list permessions.
|
||||
*
|
||||
* @return the list permessions
|
||||
*/
|
||||
public Map<ACTION_ON_ITEM, OPERATION_TYPE> getListPermessions() {
|
||||
return listPermessions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user role.
|
||||
*
|
||||
* @return the user role
|
||||
*/
|
||||
public GcubeUserRole getUserRole() {
|
||||
return userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list permessions.
|
||||
*
|
||||
* @param listPermessions the list permessions
|
||||
*/
|
||||
public void setListPermessions(Map<ACTION_ON_ITEM, OPERATION_TYPE> listPermessions) {
|
||||
this.listPermessions = listPermessions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user role.
|
||||
*
|
||||
* @param userRole the new user role
|
||||
*/
|
||||
public void setUserRole(GcubeUserRole userRole) {
|
||||
this.userRole = userRole;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("RoleRights [listPermessions=");
|
||||
builder.append(listPermessions);
|
||||
builder.append(", userRole=");
|
||||
builder.append(userRole);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class UserRights.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 24, 2021
|
||||
*/
|
||||
public class UserRights implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -304157165851633221L;
|
||||
|
||||
private String myUsername;
|
||||
|
||||
private RoleRights roleRights;
|
||||
|
||||
/**
|
||||
* Instantiates a new user rights.
|
||||
*/
|
||||
public UserRights() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UserRights(String myUsername, RoleRights roleRights) {
|
||||
super();
|
||||
this.myUsername = myUsername;
|
||||
this.roleRights = roleRights;
|
||||
}
|
||||
|
||||
public String getMyUsername() {
|
||||
return myUsername;
|
||||
}
|
||||
|
||||
public RoleRights getRoleRights() {
|
||||
return roleRights;
|
||||
}
|
||||
|
||||
public void setMyUsername(String myUsername) {
|
||||
this.myUsername = myUsername;
|
||||
}
|
||||
|
||||
public void setRoleRights(RoleRights roleRights) {
|
||||
this.roleRights = roleRights;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("UserRights [myUsername=");
|
||||
builder.append(myUsername);
|
||||
builder.append(", roleRights=");
|
||||
builder.append(roleRights);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -10,35 +10,40 @@ import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
|||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.geoportaldataentry.server.config.GNARoleRitghtsConfigReader;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.RoleRights;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestClass {
|
||||
|
||||
|
||||
private static String TOKEN = "";
|
||||
private static String CONTEXT ="/gcube/devsec/devVRE";
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
private static String CONTEXT = "/gcube/devsec/devVRE";
|
||||
private static String USERNAME = "francesco.mangiacrapa";
|
||||
|
||||
// LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20");
|
||||
// System.out.println(ldt.toString());
|
||||
//
|
||||
// String latitudine = "-899.2986";
|
||||
// // System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
//
|
||||
// String longitude = "0";
|
||||
// System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
//
|
||||
// GeoportalDataEntryServiceImpl g = new GeoportalDataEntryServiceImpl();
|
||||
// g.getLinksFor("", ConstantsGeoPortalDataEntryApp.RECORD_TYPE.CONCESSIONE.toString());
|
||||
|
||||
// getListOfConcessioni();
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
|
||||
// LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20");
|
||||
// System.out.println(ldt.toString());
|
||||
//
|
||||
// String latitudine = "-899.2986";
|
||||
// // System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
//
|
||||
// String longitude = "0";
|
||||
// System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
//
|
||||
// GeoportalDataEntryServiceImpl g = new GeoportalDataEntryServiceImpl();
|
||||
// g.getLinksFor("", ConstantsGeoPortalDataEntryApp.RECORD_TYPE.CONCESSIONE.toString());
|
||||
|
||||
getListOfConcessioni();
|
||||
|
||||
}
|
||||
|
||||
public static void getListOfConcessioni() throws Exception {
|
||||
//@Test
|
||||
public void getListConcessioniTest() throws Exception {
|
||||
MongoConcessioni clientMongo = mongoConcessioni().build();
|
||||
Iterator<Concessione> concessioni = clientMongo.getList();
|
||||
List<Concessione> listOfConcessioni = new ArrayList<Concessione>();
|
||||
|
@ -46,13 +51,20 @@ public class TestClass {
|
|||
while (concessioni.hasNext()) {
|
||||
Concessione concessione = (Concessione) concessioni.next();
|
||||
listOfConcessioni.add(concessione);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
for (Concessione concessione : listOfConcessioni) {
|
||||
System.out.println(++i+" "+concessione);
|
||||
System.out.println(++i + " " + concessione);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readUserRights() throws Exception {
|
||||
new GNARoleRitghtsConfigReader();
|
||||
List<RoleRights> listUserRights = GNARoleRitghtsConfigReader.readRoleRightsConfig();
|
||||
System.out.println(listUserRights);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue