added check configurations. Improved GUI
This commit is contained in:
parent
12bca95bf8
commit
2ca89206e6
|
@ -0,0 +1,162 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
* The Class CkanContentModeratorCheckConfig.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Feb 22, 2022
|
||||
*/
|
||||
public class CkanContentModeratorCheckConfig {
|
||||
|
||||
private int configurationLoaded = 0;
|
||||
private static final int CONFIGURATION_EXPECTED = 2;
|
||||
private int MAX_RETRY_ON_LOADING_CONFIG = 20;
|
||||
private int attemptLC = 0;
|
||||
private Boolean contentModerationEnabled = null;
|
||||
private Boolean moderatorRoleAssigned = null;
|
||||
|
||||
/**
|
||||
* Instantiates a new ckan content moderator check config.
|
||||
*/
|
||||
public CkanContentModeratorCheckConfig() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check configs.
|
||||
*
|
||||
* @param whenDone the when done
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public void checkConfigs(final Command whenDone) throws Exception {
|
||||
|
||||
configurationLoaded = 0;
|
||||
attemptLC = 0;
|
||||
|
||||
CkanContentModeratorWidgetController.contentModeratorService
|
||||
.isContentModeratorEnabled(new AsyncCallback<Boolean>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
contentModerationEnabled = false;
|
||||
incrementConfigurationLoaded();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
incrementConfigurationLoaded();
|
||||
GWT.log("isContentModeratorEnabled: "+result);
|
||||
contentModerationEnabled = result;
|
||||
}
|
||||
});
|
||||
|
||||
CkanContentModeratorWidgetController.contentModeratorService
|
||||
.isModeratorRoleAssigned(new AsyncCallback<Boolean>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
moderatorRoleAssigned = false;
|
||||
incrementConfigurationLoaded();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
incrementConfigurationLoaded();
|
||||
GWT.log("isModeratorRoleAssigned: "+result);
|
||||
moderatorRoleAssigned = result;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (whenDone != null) {
|
||||
|
||||
final Timer timer = new Timer() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
attemptLC++;
|
||||
GWT.log("checking configuration loaded, attempt "+attemptLC+" of "+MAX_RETRY_ON_LOADING_CONFIG);
|
||||
boolean configsLoaded = getConfigurationLoaded() == CONFIGURATION_EXPECTED;
|
||||
GWT.log("configsLoaded: "+configsLoaded);
|
||||
if (configsLoaded) {
|
||||
GWT.log("ContentModeratorCheckConfig loaded correclty");
|
||||
whenDone.execute();
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
if (attemptLC > MAX_RETRY_ON_LOADING_CONFIG) {
|
||||
GWT.log("MAX_RETRY_ON_LOADING_CONFIG reached, timer cancelled");
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
timer.scheduleRepeating(500);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment configuration loaded.
|
||||
*/
|
||||
private void incrementConfigurationLoaded() {
|
||||
configurationLoaded++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement configuration loaded.
|
||||
*/
|
||||
private synchronized void decrementConfigurationLoaded() {
|
||||
configurationLoaded--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration loaded.
|
||||
*
|
||||
* @return the configuration loaded
|
||||
*/
|
||||
private synchronized int getConfigurationLoaded() {
|
||||
return configurationLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is moderator role assigned.
|
||||
*
|
||||
* @return the boolean
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Boolean isModeratorRoleAssigned() throws Exception {
|
||||
if (moderatorRoleAssigned == null)
|
||||
throw new Exception(
|
||||
"Please, first check if the Moderator role is assigned in this context by calling checkContentModeratorConfiguration");
|
||||
|
||||
return moderatorRoleAssigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is content moderation enabled.
|
||||
*
|
||||
* @return true, if is content moderation enabled
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public boolean isContentModerationEnabled() throws Exception {
|
||||
|
||||
if (contentModerationEnabled == null)
|
||||
throw new Exception(
|
||||
"Please, first check if the content moderation is enabled in this context by calling checkContentModeratorConfiguration");
|
||||
|
||||
return contentModerationEnabled;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,6 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CMSUserRole;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.ModerationUserRole;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.OperationReport;
|
||||
|
@ -27,7 +26,7 @@ public interface CkanContentModeratorService extends RemoteService {
|
|||
*
|
||||
* @return true, if is content moderator enabled
|
||||
*/
|
||||
public boolean isContentModeratorEnabled();
|
||||
public Boolean isContentModeratorEnabled();
|
||||
|
||||
/**
|
||||
* Sets the status. Currently, this only used to change the status from Rejected
|
||||
|
@ -75,10 +74,10 @@ public interface CkanContentModeratorService extends RemoteService {
|
|||
/**
|
||||
* Gets the data for status.
|
||||
*
|
||||
* @param status the status
|
||||
* @param startIndex the start index
|
||||
* @param lenght the lenght
|
||||
* @param serverIndex the server index
|
||||
* @param status the status
|
||||
* @param star@Override tIndex the start index
|
||||
* @param lenght the lenght
|
||||
* @param serverIndex the server index
|
||||
* @return the data for status
|
||||
* @throws Exception the exception
|
||||
* @par@Override am lenght the lenght
|
||||
|
@ -102,4 +101,12 @@ public interface CkanContentModeratorService extends RemoteService {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
ModerationUserRole getCMSRolesForUserInTheContext() throws Exception;
|
||||
|
||||
/**
|
||||
* Checks if is moderator role assigned.
|
||||
*
|
||||
* @return the moderation user role
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
Boolean isModeratorRoleAssigned() throws Exception;
|
||||
}
|
||||
|
|
|
@ -96,4 +96,11 @@ public interface CkanContentModeratorServiceAsync {
|
|||
*/
|
||||
void getCMSRolesForUserInTheContext(AsyncCallback<ModerationUserRole> callback);
|
||||
|
||||
/**
|
||||
* Checks if is moderator role assigned.
|
||||
*
|
||||
* @param callback the callback
|
||||
*/
|
||||
void isModeratorRoleAssigned(AsyncCallback<Boolean> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import com.google.gwt.user.client.ui.ComplexPanel;
|
|||
*/
|
||||
public class CkanContentModeratorWidget {
|
||||
|
||||
CkanContentModeratorWidgetController cmsController;
|
||||
private CkanContentModeratorWidgetController cmsController;
|
||||
|
||||
/**
|
||||
* Instantiates a new ckan content moderator widget.
|
||||
|
@ -24,36 +24,10 @@ public class CkanContentModeratorWidget {
|
|||
* @param displayFields the display fields
|
||||
* @param sortByField the sort by field
|
||||
*/
|
||||
public CkanContentModeratorWidget(ItemStatus status, DISPLAY_FIELD[] displayFields, DISPLAY_FIELD sortByField) {
|
||||
public CkanContentModeratorWidget(ItemStatus status, DISPLAY_FIELD[] displayFields, DISPLAY_FIELD sortByField,
|
||||
Command onConfigurationLoaded) {
|
||||
cmsController = new CkanContentModeratorWidgetController(status, displayFields, sortByField);
|
||||
|
||||
try {
|
||||
cmsController.checkContentModeratorConfiguration(null);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is content moderator enabled.
|
||||
*
|
||||
* @return true, if is content moderator enabled
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public boolean isContentModeratorEnabled() throws Exception {
|
||||
return cmsController.isContentModeratorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check content moderator configuration.
|
||||
*
|
||||
* @param onSuccess the on success
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public void checkContentModeratorConfiguration(final Command onSuccess) throws Exception {
|
||||
cmsController.checkContentModeratorConfiguration(onSuccess);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,4 +38,5 @@ public class CkanContentModeratorWidget {
|
|||
public ComplexPanel getPanel() {
|
||||
return cmsController.getMainPanel();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItems
|
|||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowMessageEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowMessageEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.CkanFramePanel;
|
||||
|
@ -26,11 +28,10 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTabl
|
|||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.ComplexPanel;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
|
||||
|
@ -51,7 +52,7 @@ public class CkanContentModeratorWidgetController {
|
|||
|
||||
private ContentModeratorToolbar toolbar;
|
||||
private MainTabPanel mainTabPanel = new MainTabPanel();
|
||||
private Boolean isContentModeratorEnabled = null;
|
||||
|
||||
public final static HandlerManager eventBus = new HandlerManager(null);
|
||||
private HomeView howeView;
|
||||
|
||||
|
@ -169,71 +170,46 @@ public class CkanContentModeratorWidgetController {
|
|||
howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus());
|
||||
mainTabPanel.selectTab(0);
|
||||
}
|
||||
|
||||
if(statusSelectedEvent.getDisplayMessage()!=null) {
|
||||
final Alert alert = new Alert(statusSelectedEvent.getDisplayMessage());
|
||||
alert.setType(statusSelectedEvent.getAlertType());
|
||||
alert.setClose(true);
|
||||
alert.setAnimation(true);
|
||||
infoPanel.add(alert);
|
||||
|
||||
//Cleans the info panel after 10 sec.
|
||||
Timer t = new Timer() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
infoPanel.clear();
|
||||
}
|
||||
};
|
||||
|
||||
t.schedule(10000);
|
||||
|
||||
|
||||
if (statusSelectedEvent.getDisplayMessage() != null) {
|
||||
showMessage(statusSelectedEvent.getDisplayMessage(), statusSelectedEvent.getAlertType());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is content moderator enabled.
|
||||
*
|
||||
* @return true, if is content moderator enabled
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public boolean isContentModeratorEnabled() throws Exception {
|
||||
|
||||
if (isContentModeratorEnabled == null)
|
||||
throw new Exception("Please, first check if the content moderator is enabled in this context");
|
||||
|
||||
return isContentModeratorEnabled;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check content moderator configuration.
|
||||
*
|
||||
* @param whenDone the when done
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public void checkContentModeratorConfiguration(final Command whenDone) throws Exception {
|
||||
|
||||
contentModeratorService.isContentModeratorEnabled(new AsyncCallback<Boolean>() {
|
||||
eventBus.addHandler(ShowMessageEvent.TYPE, new ShowMessageEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
whenDone.execute();
|
||||
public void onShowMessage(ShowMessageEvent showMessageEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
isContentModeratorEnabled = result;
|
||||
if (whenDone != null)
|
||||
whenDone.execute();
|
||||
if (showMessageEvent.getMsg() != null) {
|
||||
showMessage(showMessageEvent.getMsg(), showMessageEvent.getAlerType());
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showMessage(String msg, AlertType alertType) {
|
||||
|
||||
final Alert alert = new Alert(msg);
|
||||
alertType = alertType != null ? alertType : AlertType.INFO;
|
||||
alert.setType(alertType);
|
||||
alert.setClose(true);
|
||||
alert.setAnimation(true);
|
||||
infoPanel.add(alert);
|
||||
|
||||
// Cleans the info panel after 12 sec.
|
||||
Timer t = new Timer() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
infoPanel.clear();
|
||||
}
|
||||
};
|
||||
|
||||
t.schedule(12000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
|
@ -14,41 +13,10 @@ public class CkanContentModeratorWidgetEntryPoint implements EntryPoint {
|
|||
private static final String SERVER_ERROR = "An error occurred while "
|
||||
+ "attempting to contact the server. Please check your network " + "connection and try again.";
|
||||
|
||||
/**
|
||||
* Create a remote service proxy to talk to the server-side Greeting service.
|
||||
*/
|
||||
private final CkanContentModeratorServiceAsync greetingService = GWT.create(CkanContentModeratorService.class);
|
||||
|
||||
/**
|
||||
* This is the entry point method.
|
||||
*/
|
||||
public void onModuleLoad() {
|
||||
/*StyleInjector.inject(DataTableClientBundle.INSTANCE.dataTable().getText());
|
||||
|
||||
// MaterialDataTable<String> table = new MaterialDataTable<String>();
|
||||
// table.getTableTitle().setText("Customers");
|
||||
// List<String> users = new ArrayList<String>();
|
||||
// users.add("Pippo");
|
||||
// table.setRowData(0, users);
|
||||
|
||||
final CustomizedView cvTable = new CustomizedView();
|
||||
RootPanel.get().add(cvTable);
|
||||
// table.getView().refresh();
|
||||
|
||||
greetingService.getListItemsForStatus(ItemStatus.PENDING, 20, 0, new AsyncCallback<List<CatalogueDataset>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<CatalogueDataset> result) {
|
||||
cvTable.setData(result);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(caught.getMessage());
|
||||
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class ShowMessageEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Feb 22, 2022
|
||||
*/
|
||||
public class ShowMessageEvent extends GwtEvent<ShowMessageEventHandler> {
|
||||
public static Type<ShowMessageEventHandler> TYPE = new Type<ShowMessageEventHandler>();
|
||||
private String msg;
|
||||
private AlertType alerType;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
*
|
||||
* @param msg the msg
|
||||
* @param alerType the aler type
|
||||
*/
|
||||
public ShowMessageEvent(String msg, AlertType alerType) {
|
||||
this.msg = msg;
|
||||
this.alerType = alerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<ShowMessageEventHandler> 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(ShowMessageEventHandler handler) {
|
||||
handler.onShowMessage(this);
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public AlertType getAlerType() {
|
||||
return alerType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
/**
|
||||
* The Interface ShowMessageEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Feb 22, 2022
|
||||
*/
|
||||
public interface ShowMessageEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On show message.
|
||||
*
|
||||
* @param showMessageEvent the show message event
|
||||
*/
|
||||
void onShowMessage(ShowMessageEvent showMessageEvent);
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorWidgetController;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ContentModeratorWidgetConstants;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowMessageEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||
|
@ -13,6 +14,7 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.LoadingPan
|
|||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.SearchedData;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.cellview.client.SimplePager;
|
||||
|
@ -30,7 +32,6 @@ import com.google.gwt.view.client.Range;
|
|||
import com.google.gwt.view.client.SelectionModel;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeonaRecordsPaginatedView.
|
||||
*
|
||||
|
@ -56,7 +57,7 @@ public class ContentModeratorPaginatedView {
|
|||
/**
|
||||
* Instantiates a new content moderator paginated view.
|
||||
*
|
||||
* @param eventbus the eventbus
|
||||
* @param eventbus the eventbus
|
||||
* @param theStatus the the status
|
||||
* @param displayFields the display fields
|
||||
* @param sortByField the sort by field
|
||||
|
@ -147,7 +148,8 @@ public class ContentModeratorPaginatedView {
|
|||
*/
|
||||
private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
|
||||
// initFirstRangeChanged = resetStore;
|
||||
GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"+ resetStore + "]");
|
||||
GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
|
||||
+ resetStore + "]");
|
||||
// showLoading(true);
|
||||
|
||||
int newStartIndex = startIdx;
|
||||
|
@ -181,14 +183,14 @@ public class ContentModeratorPaginatedView {
|
|||
* @param result the new new page result
|
||||
*/
|
||||
private void setNewPageResult(SearchedData result) {
|
||||
GWT.log("setNewPageResult: "+result);
|
||||
GWT.log("setNewPageResult: " + result);
|
||||
serverStartIndex = result.getServerEndIndex();
|
||||
SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel();
|
||||
|
||||
|
||||
if (sm instanceof SingleSelectionModel) {
|
||||
SingleSelectionModel<CatalogueDataset> ssm = (SingleSelectionModel<CatalogueDataset>) sm;
|
||||
ssm.clear();
|
||||
}else if (sm instanceof MultiSelectionModel) {
|
||||
} else if (sm instanceof MultiSelectionModel) {
|
||||
MultiSelectionModel<CatalogueDataset> msm = (MultiSelectionModel<CatalogueDataset>) sm;
|
||||
msm.clear();
|
||||
}
|
||||
|
@ -240,6 +242,8 @@ public class ContentModeratorPaginatedView {
|
|||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
showLoading(false);
|
||||
eventBus.fireEvent(new ShowMessageEvent(caught.getMessage(), AlertType.ERROR));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -248,7 +252,7 @@ public class ContentModeratorPaginatedView {
|
|||
/**
|
||||
* Select items.
|
||||
*
|
||||
* @param select the select
|
||||
* @param select the select
|
||||
* @param limitToPage the limit to page
|
||||
*/
|
||||
public void selectItems(boolean select, boolean limitToPage) {
|
||||
|
|
|
@ -276,23 +276,7 @@ public class HomeView extends Composite {
|
|||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
confirmPanelContainer.clear();
|
||||
|
||||
performCMSAction(doActionCMS);
|
||||
// TODO DO ACTION UPDATE STATUS OR DELETE PERMANENTLY
|
||||
|
||||
// int count = selectedItems.size();
|
||||
// String msg = "";
|
||||
// if (count > 0) {
|
||||
// if (count == 1) {
|
||||
// msg += "One item";
|
||||
// } else {
|
||||
// msg += count + " items";
|
||||
// }
|
||||
//
|
||||
// msg += " moved to " + toStatus + " status";
|
||||
// }
|
||||
// eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -416,9 +400,13 @@ public class HomeView extends Composite {
|
|||
msg += " moved to " + toStatus + " status.";
|
||||
}
|
||||
|
||||
int errorCount = result.getErrorListItems().size();
|
||||
int errorCount = result.getErrorMapItems().size();
|
||||
if (errorCount > 0) {
|
||||
msg += " <br/>Error occurred on updating status to " + errorCount + " item/s";
|
||||
msg += " <br/>Error occurred on updating status to " + errorCount + " item/s:";
|
||||
for (String key : result.getErrorMapItems().keySet()) {
|
||||
msg += "<br/> "+ key+". Error: "+ result.getErrorMapItems().get(key);
|
||||
}
|
||||
|
||||
alert = AlertType.WARNING;
|
||||
}
|
||||
|
||||
|
@ -465,10 +453,12 @@ public class HomeView extends Composite {
|
|||
msg += " moved to " + toStatus + " status.";
|
||||
}
|
||||
|
||||
int errorCount = result.getErrorListItems().size();
|
||||
int errorCount = result.getErrorMapItems().size();
|
||||
if (errorCount > 0) {
|
||||
msg += " <br/>Error occurred on approving " + errorCount + " item/s";
|
||||
alert = AlertType.WARNING;
|
||||
msg += " <br/>Error occurred on approving " + errorCount + " item/s:";
|
||||
for (String key : result.getErrorMapItems().keySet()) {
|
||||
msg += "<br/> "+ key+". Error: "+ result.getErrorMapItems().get(key);
|
||||
}
|
||||
}
|
||||
|
||||
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
||||
|
@ -507,10 +497,12 @@ public class HomeView extends Composite {
|
|||
msg += " moved to " + toStatus + " status.";
|
||||
}
|
||||
|
||||
int errorCount = result.getErrorListItems().size();
|
||||
int errorCount = result.getErrorMapItems().size();
|
||||
if (errorCount > 0) {
|
||||
msg += " <br/>Error occurred on rejecting " + errorCount + " item/s";
|
||||
alert = AlertType.WARNING;
|
||||
msg += " <br/>Error occurred on rejecting " + errorCount + " item/s:";
|
||||
for (String key : result.getErrorMapItems().keySet()) {
|
||||
msg += "<br/> "+ key+". Error: "+ result.getErrorMapItems().get(key);
|
||||
}
|
||||
}
|
||||
|
||||
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
@ -39,7 +41,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
* @return true, if is content moderator enabled
|
||||
*/
|
||||
@Override
|
||||
public boolean isContentModeratorEnabled() {
|
||||
public Boolean isContentModeratorEnabled() {
|
||||
LOG.info("called isContentModeratorEnabled");
|
||||
String scope = setContexts();
|
||||
boolean isContentModeratorEnabled = false;
|
||||
|
@ -54,7 +56,27 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
return isContentModeratorEnabled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is moderator role is assigned to working user in the context.
|
||||
*
|
||||
* @return the moderation user role
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public Boolean isModeratorRoleAssigned() throws Exception {
|
||||
LOG.info("called isModeratorRoleAssigned");
|
||||
ModerationUserRole userRole = getCMSRolesForUserInTheContext();
|
||||
|
||||
boolean isCatalogueModerator = false;
|
||||
if (userRole != null && userRole.getRoles() != null
|
||||
&& userRole.getRoles().contains(CMSUserRole.CATALOGUE_MODERATOR)) {
|
||||
LOG.info("called isModeratorRoleAssigned");
|
||||
isCatalogueModerator = true;
|
||||
}
|
||||
LOG.info("is " + CMSUserRole.CATALOGUE_MODERATOR.getRoleName() + " assigned? " + isCatalogueModerator);
|
||||
return isCatalogueModerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CMS roles for user in the context.
|
||||
*
|
||||
|
@ -66,10 +88,10 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
LOG.info("called getCMSRolesForUserInTheContext");
|
||||
setContexts();
|
||||
List<CMSUserRole> roles = GcubeContextUtil.getCMSRoleForUserInTheScope(getThreadLocalRequest());
|
||||
|
||||
|
||||
GcubeContextUtil.getCurrentUser(getThreadLocalRequest());
|
||||
ModerationUserRole userRole = new ModerationUserRole(getServletInfo(), roles);
|
||||
LOG.info("return: "+userRole);
|
||||
LOG.info("return: " + userRole);
|
||||
return userRole;
|
||||
}
|
||||
|
||||
|
@ -120,9 +142,8 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw new Exception(
|
||||
"Error occurred on reading items for status: " + theStatus + ". Caused by: " + e.getMessage());
|
||||
LOG.error("Error occurred on reading items for status: " + theStatus, e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
LOG.info("returning " + datasetList.size() + " dataset");
|
||||
|
@ -135,7 +156,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
* @param theStatus the the status
|
||||
* @param itemNames the item names
|
||||
* @return the operation report
|
||||
* @throws Exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public OperationReport setStatus(ItemStatus theStatus, List<String> itemNames) throws Exception {
|
||||
|
@ -144,7 +165,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
try {
|
||||
String scope = setContexts();
|
||||
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
|
||||
List<String> errorListItems = new ArrayList<String>();
|
||||
Map<String, String> errorMapItems = new HashMap<String, String>();
|
||||
List<String> changedStatusListItems = new ArrayList<String>();
|
||||
for (String itemName : itemNames) {
|
||||
try {
|
||||
|
@ -152,11 +173,11 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
changedStatusListItems.add(itemName);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error when setting status (updating) the itemName: " + itemName, e);
|
||||
errorListItems.add(itemName);
|
||||
errorMapItems.put(itemName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return new OperationReport(theStatus.getLabel(), errorListItems, changedStatusListItems);
|
||||
return new OperationReport(theStatus.getLabel(), changedStatusListItems, errorMapItems);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
|
@ -182,7 +203,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
|
||||
CatalogueContentModeratorSystem cmsInstance = catalogueImpl.getCatalogueContentModerator();
|
||||
|
||||
List<String> errorListItems = new ArrayList<String>();
|
||||
Map<String, String> errorMapItems = new HashMap<String, String>();
|
||||
List<String> approvedListItems = new ArrayList<String>();
|
||||
for (String itemName : itemNames) {
|
||||
try {
|
||||
|
@ -190,11 +211,11 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
approvedListItems.add(itemName);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error when approving itemName: " + itemName, e);
|
||||
errorListItems.add(itemName);
|
||||
errorMapItems.put(itemName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return new OperationReport(ItemStatus.APPROVED.getLabel(), errorListItems, approvedListItems);
|
||||
return new OperationReport(ItemStatus.APPROVED.getLabel(), approvedListItems, errorMapItems);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
|
@ -221,7 +242,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
|
||||
CatalogueContentModeratorSystem cmsInstance = catalogueImpl.getCatalogueContentModerator();
|
||||
|
||||
List<String> errorListItems = new ArrayList<String>();
|
||||
Map<String, String> errorMapItems = new HashMap<String, String>();
|
||||
List<String> passedListItems = new ArrayList<String>();
|
||||
for (String itemName : itemNames) {
|
||||
try {
|
||||
|
@ -229,11 +250,11 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
passedListItems.add(itemName);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error when rejecting itemName: " + itemName, e);
|
||||
errorListItems.add(itemName);
|
||||
errorMapItems.put(itemName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return new OperationReport(ItemStatus.REJECTED.getLabel(), errorListItems, passedListItems);
|
||||
return new OperationReport(ItemStatus.REJECTED.getLabel(), passedListItems, errorMapItems);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
|
@ -257,7 +278,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
|
||||
CatalogueContentModeratorSystem cmsInstance = catalogueImpl.getCatalogueContentModerator();
|
||||
|
||||
List<String> errorListItems = new ArrayList<String>();
|
||||
Map<String, String> errorMapItems = new HashMap<String, String>();
|
||||
List<String> passedListItems = new ArrayList<String>();
|
||||
for (String itemName : itemNames) {
|
||||
try {
|
||||
|
@ -265,11 +286,11 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
passedListItems.add(itemName);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error when deleting permanently the itemName: " + itemName, e);
|
||||
errorListItems.add(itemName);
|
||||
errorMapItems.put(itemName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return new OperationReport("Permanently Delete", errorListItems, passedListItems);
|
||||
return new OperationReport("Permanently Delete", passedListItems, errorMapItems);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
|
@ -293,69 +314,37 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
throws Exception {
|
||||
LOG.info("called getDataForStatus [status: " + status + ", offset: " + offset + ", limit: " + limit
|
||||
+ ", serverIndex: " + serverStartIndex);
|
||||
|
||||
|
||||
String scope = setContexts();
|
||||
int searchStartIndex = offset;
|
||||
CatalogueContentModeratorSystem cmsInstance = CatalogueCMSFactory.getFactory().getCMSPerScope(scope);
|
||||
SearchedData searchedData = new SearchedData(offset, limit, searchStartIndex, false);
|
||||
long totalItemsForStatus = cmsInstance.countListItemsForStatus(status);
|
||||
LOG.info("totalItemsForStatus " + status + " are : " + totalItemsForStatus);
|
||||
List<CatalogueDataset> listDataset = new ArrayList<CatalogueDataset>();
|
||||
try {
|
||||
String scope = setContexts();
|
||||
// int searchStartIndex = limit < serverStartIndex? serverStartIndex : offset;
|
||||
|
||||
int searchStartIndex = offset;
|
||||
|
||||
CatalogueContentModeratorSystem cmsInstance = CatalogueCMSFactory.getFactory().getCMSPerScope(scope);
|
||||
SearchedData searchedData = new SearchedData(offset, limit, searchStartIndex, false);
|
||||
long totalItemsForStatus = cmsInstance.countListItemsForStatus(status);
|
||||
LOG.info("totalItemsForStatus " + status + " are : " + totalItemsForStatus);
|
||||
List<CatalogueDataset> listDataset = new ArrayList<CatalogueDataset>();
|
||||
try {
|
||||
LOG.debug("getListItemsForStatus with searchStartIndex: " + searchStartIndex + ", limit: " + limit);
|
||||
listDataset = getListItemsForStatus(status, searchStartIndex, limit);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error occurred on gettin items for status: " + status, e);
|
||||
}
|
||||
|
||||
int listDatasetSize = listDataset.size();
|
||||
LOG.debug("Returned " + listDatasetSize + " with above parameters");
|
||||
searchedData.setData(listDataset);
|
||||
searchedData.setTotalItems(totalItemsForStatus);
|
||||
|
||||
if (listDatasetSize == limit || listDatasetSize == 0) {
|
||||
LOG.debug("Page completed returning " + listDatasetSize + " items");
|
||||
int newOffset = searchStartIndex + offset;
|
||||
searchedData.setServerSearchFinished(newOffset > totalItemsForStatus || listDatasetSize == 0);
|
||||
LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
|
||||
return searchedData;
|
||||
}
|
||||
|
||||
/*
|
||||
* int offsetStartIndex = searchStartIndex; boolean pageOffsetOut = false;
|
||||
* while(listDatasetSize < offset && !searchedData.isServerSearchFinished() &&
|
||||
* !pageOffsetOut){ //&& SEARCH NOT ULTIMATED
|
||||
* LOG.debug("MyLg new WHILE Items count: "
|
||||
* +totalItemsForStatus+" is less than limit..");
|
||||
*
|
||||
* int newOffsetStartIndex = offsetStartIndex+limit+1;
|
||||
* LOG.debug("MyLg NewStartIndex is startIndex+limit: "+newOffsetStartIndex);
|
||||
*
|
||||
* //THERE ARE OTHER CHILDREN OVER NEW START INDEX if(newOffsetStartIndex <
|
||||
* totalItemsForStatus){ //newLimit = limit - childrenToReturn.size();
|
||||
* LOG.debug("MyLg getting items with index start: "+newOffsetStartIndex +
|
||||
* ", limit: "+offset);
|
||||
*
|
||||
* int diff = (int) (offset - totalItemsForStatus); //How items are remaining
|
||||
* //int offset = 0; LOG.debug("MyLg new search start: "+newOffsetStartIndex +
|
||||
* ", diff: "+diff+ ", retrieved: "+listDatasetSize); if(diff >=
|
||||
* listDatasetSize){ }else{ pageOffsetOut = true; } offsetStartIndex =
|
||||
* newOffsetStartIndex; LOG.debug("MyLg items count is: "+totalItemsForStatus +
|
||||
* " serverEndIndex: "+offsetStartIndex);
|
||||
* searchedData.setServerEndIndex(offsetStartIndex); }else{ LOG.
|
||||
* debug("New start index (oldStartIndex+limit) is grather than total items count, search is finished"
|
||||
* ); searchedData.setServerSearchFinished(true); } }
|
||||
*/
|
||||
LOG.debug("Returning: " + searchedData);
|
||||
return searchedData;
|
||||
|
||||
LOG.debug("getListItemsForStatus with searchStartIndex: " + searchStartIndex + ", limit: " + limit);
|
||||
listDataset = getListItemsForStatus(status, searchStartIndex, limit);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error during folder retrieving", e);
|
||||
throw new Exception("Sorry, an error occurred on loading items");
|
||||
String error = "Error occurred on getting items for status: " + status;
|
||||
LOG.error(error, e);
|
||||
throw new Exception(error+". Cause: "+e.getMessage());
|
||||
}
|
||||
|
||||
int listDatasetSize = listDataset.size();
|
||||
LOG.debug("Returned " + listDatasetSize + " with above parameters");
|
||||
searchedData.setData(listDataset);
|
||||
searchedData.setTotalItems(totalItemsForStatus);
|
||||
|
||||
if (listDatasetSize == limit || listDatasetSize == 0) {
|
||||
LOG.debug("Page completed returning " + listDatasetSize + " items");
|
||||
int newOffset = searchStartIndex + offset;
|
||||
searchedData.setServerSearchFinished(newOffset > totalItemsForStatus || listDatasetSize == 0);
|
||||
LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
|
||||
return searchedData;
|
||||
}
|
||||
|
||||
LOG.debug("Returning: " + searchedData);
|
||||
return searchedData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,10 +31,6 @@ public class ModerationUserRole implements Serializable {
|
|||
this.roles = roles;
|
||||
}
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
|
|
@ -2,25 +2,27 @@ package org.gcube.portlets.widgets.ckancontentmoderator.shared;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class OperationReport implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 879318163198093725L;
|
||||
private static final long serialVersionUID = 4960774282956107668L;
|
||||
private String operationType;
|
||||
private List<String> errorListItems = new ArrayList<String>();
|
||||
private Map<String, String> errorMapItems = new HashMap<String, String>();
|
||||
private List<String> passedListItems = new ArrayList<String>();
|
||||
|
||||
public OperationReport() {
|
||||
}
|
||||
|
||||
public OperationReport(String operationType, List<String> errorListItems, List<String> passedListItems) {
|
||||
super();
|
||||
public OperationReport(String operationType, List<String> passedListItems, Map<String, String> errorMapItems) {
|
||||
this.operationType = operationType;
|
||||
this.errorListItems = errorListItems;
|
||||
this.errorMapItems = errorMapItems;
|
||||
this.passedListItems = passedListItems;
|
||||
}
|
||||
|
||||
|
@ -28,8 +30,8 @@ public class OperationReport implements Serializable {
|
|||
return operationType;
|
||||
}
|
||||
|
||||
public List<String> getErrorListItems() {
|
||||
return errorListItems;
|
||||
public Map<String, String> getErrorMapItems() {
|
||||
return errorMapItems;
|
||||
}
|
||||
|
||||
public List<String> getPassedListItems() {
|
||||
|
@ -40,8 +42,8 @@ public class OperationReport implements Serializable {
|
|||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
public void setErrorListItems(List<String> errorListItems) {
|
||||
this.errorListItems = errorListItems;
|
||||
public void setErrorMapItems(Map<String, String> errorMapItems) {
|
||||
this.errorMapItems = errorMapItems;
|
||||
}
|
||||
|
||||
public void setPassedListItems(List<String> passedListItems) {
|
||||
|
@ -53,8 +55,8 @@ public class OperationReport implements Serializable {
|
|||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("OperationReport [operationType=");
|
||||
builder.append(operationType);
|
||||
builder.append(", errorListItems=");
|
||||
builder.append(errorListItems);
|
||||
builder.append(", errorMapItems=");
|
||||
builder.append(errorMapItems);
|
||||
builder.append(", passedListItems=");
|
||||
builder.append(passedListItems);
|
||||
builder.append("]");
|
||||
|
|
Loading…
Reference in New Issue