diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorCheckConfigs.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorCheckConfigs.java
index 6ef9f58..90b677d 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorCheckConfigs.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorCheckConfigs.java
@@ -123,9 +123,7 @@ public class CkanContentModeratorCheckConfigs {
};
timer.scheduleRepeating(500);
-
}
-
}
/**
diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/ContentModeratorToolbar.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/ContentModeratorToolbar.ui.xml
index 4b35248..c81f686 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/ContentModeratorToolbar.ui.xml
+++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/ContentModeratorToolbar.ui.xml
@@ -36,7 +36,7 @@
- Close All Tabs
+ Close All Tabs
diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/MainTabPanel.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/MainTabPanel.java
index 28957bb..777a027 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/MainTabPanel.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/MainTabPanel.java
@@ -3,14 +3,17 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import java.util.ArrayList;
import java.util.List;
+import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.UtilFunct;
+import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.LoadEvent;
@@ -18,6 +21,7 @@ import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
@@ -87,6 +91,26 @@ public class MainTabPanel extends Composite {
public void onLoad(LoadEvent event) {
tab.setIcon(IconType.BOOK);
setNoSpinner(tab);
+
+ Icon icon = new Icon(IconType.REMOVE);
+ icon.setTitle("Close this tab");
+ icon.getElement().getStyle().setCursor(Cursor.POINTER);
+ ClickHandler clickHandler = new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ try {
+ mainTabPanel.remove(tab);
+ results.remove(tab);
+ mainTabPanel.selectTab(results.size() - 1);
+ }catch (Exception e) {
+ //silent
+ }
+ }
+ };
+
+ icon.addDomHandler(clickHandler, ClickEvent.getType());
+ tab.addDecorate(icon);
}
});
}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/public/content-moderator-widget.css b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/public/content-moderator-widget.css
index c0d5b9c..381028e 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/public/content-moderator-widget.css
+++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/public/content-moderator-widget.css
@@ -35,4 +35,6 @@
.as_simple_link {
background: none !important;
border: none !important;
+ padding: 0 !important;
+ margin: 0 !important;
}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceImpl.java
index c3bd140..3b20ab9 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceImpl.java
@@ -248,20 +248,42 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
String scope = setContexts();
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
GCubeUser user = GcubeContextUtil.getCurrentUser(this.getThreadLocalRequest());
+
+ boolean moderationCheckPassed = false;
+
if (user != null) {
CkanDataset ckanDataset = catalogueImpl.getDataset(itemName, user.getUsername());
ds = null;
if (ckanDataset != null) {
ds = toPatchedCatalogueDataset(ckanDataset, catalogueImpl.getCatalogueUrl());
+
+ Boolean userModerator = isModeratorRoleAssigned();
+ moderationCheckPassed = userModerator?true:false;
+ LOG.info("Moderation check: is the user a Moderator? "+moderationCheckPassed);
+ //The user is not a Moderator, yes otherwise
+ if(!moderationCheckPassed) {
+ String datasetAuthorMail = ds.getAuthorEmail();
+ String userMail = user.getEmail();
+ if(datasetAuthorMail!=null && userMail!=null && datasetAuthorMail.compareTo(userMail)==0) {
+ //The user is the owner of the dataset, so he/she can view the dataset (moderation check passed)
+ moderationCheckPassed = true;
+ }
+ LOG.info("Moderation check: is the user the owner of the dataset? "+moderationCheckPassed);
+ }
}
}
+
+ if(!moderationCheckPassed) {
+ LOG.info("Moderation ckeck not passed, returning null");
+ ds = null;
+ }
} catch (Exception e) {
LOG.error("Error occurred on reading item for name: " + itemName, e);
throw e;
}
- LOG.info("returning: " + ds);
+ LOG.info("getItemForName "+itemName+", returning: " + ds);
return ds;
}