updated interaction with CkanContentModeratorWidget

This commit is contained in:
Francesco Mangiacrapa 2022-02-22 14:50:18 +01:00
parent f13fa8eb34
commit 83831c8344
6 changed files with 68 additions and 41 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -18,7 +19,8 @@
<wb-module deploy-name="gcube-ckan-datacatalog-2.2.0-SNAPSHOT">
@ -37,7 +39,8 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -56,7 +59,8 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -75,7 +79,8 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
@ -92,7 +97,8 @@
<dependent-module archiveName="ckan-content-moderator-widget-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-content-moderator-widget/ckan-content-moderator-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -111,7 +117,8 @@
<property name="context-root" value="gcube-ckan-datacatalog"/>
@ -130,7 +137,8 @@
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -149,7 +157,8 @@
</wb-module>

View File

@ -242,7 +242,7 @@ public class CkanEventHandlerManager {
@Override
public void onClickedManageProduct(ClickedCMSManageProductButtonEvent showManageProductWidgetEvent) {
final CkanContentModeratorWidget cms = new CkanContentModeratorWidget(ItemStatus.PENDING, DISPLAY_FIELD.values(), DISPLAY_FIELD.NAME);
final CkanContentModeratorWidget cms = new CkanContentModeratorWidget(ItemStatus.PENDING, DISPLAY_FIELD.values(), DISPLAY_FIELD.NAME, null);
final Modal modal = new ExtModal(true, true);
modal.setTitle("Manage Items");
modal.setWidth(1200);

View File

@ -16,6 +16,7 @@ import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInOrgGro
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.ManageProductResponse;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherServiceAsync;
import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorCheckConfig;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ResizeEvent;
@ -26,6 +27,7 @@ import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -57,7 +59,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
private static String latestSelectedProductIdentifier;
public static final int IFRAME_FIX_HEIGHT = 1800;
private JSONObject obj;
private boolean reloadCatServiceConfig = true; //only first time the gCat service config is reloaded
private boolean reloadCatServiceConfig = true; // only first time the gCat service config is reloaded
/**
* Instantiates a new g cube ckan data catalog panel.
@ -222,8 +224,44 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
}
final CkanContentModeratorCheckConfig checkConfig = new CkanContentModeratorCheckConfig();
final Command whenDone = new Command() {
@Override
public void execute() {
GWT.log("onConfigurationLoaded executed");
boolean isContentModerationEnabled = false;
boolean isModeratorRoleAssingned = false;
try {
isContentModerationEnabled = checkConfig.isContentModerationEnabled();
isModeratorRoleAssingned = checkConfig.isModeratorRoleAssigned();
} catch (Exception e) {
GWT.log("Command - Check configs error: "+e.getMessage());
}
GWT.log("Moderation is enabled? " + isContentModerationEnabled);
GWT.log("Moderator role is assigned? " + isModeratorRoleAssingned);
if (isContentModerationEnabled && isModeratorRoleAssingned) {
GWT.log("The moderator role is assigned to user,and the moderation is enabled in the context");
managementPanel.showManageCMSProductsButton(isContentModerationEnabled);
managementPanel.enableManageCMSProductsButton(isContentModerationEnabled);
}
}
};
try {
checkConfig.checkConfigs(whenDone);
} catch (Exception e) {
GWT.log("Check configs error: "+e.getMessage());
}
/**
* Just check if it is enabled.. then we need to listen for dom events coming
* (GRSF) Just check if it is enabled.. then we need to listen for dom events
* coming
*/
GCubeCkanDataCatalog.service
.isManageProductEnabled(new AsyncCallback<ManageProductResponse>() {
@ -242,26 +280,6 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
managementPanel.showManageGRSFProductButton(false);
}
});
GCubeCkanDataCatalog.service.checkModerationEnabled(reloadCatServiceConfig,
new AsyncCallback<ManageProductResponse>() {
@Override
public void onFailure(Throwable caught) {
managementPanel.showManageCMSProductsButton(
false);
}
@Override
public void onSuccess(ManageProductResponse moderationResponse) {
reloadCatServiceConfig = false;
//here the moderationProductResponse is not null.
moderationProductResponse = moderationResponse;
managementPanel.showManageCMSProductsButton(moderationProductResponse.isManageEnabled());
managementPanel.enableManageCMSProductsButton(moderationProductResponse.isManageEnabled());
}
});
}
@ -292,20 +310,19 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
// listen for DOM messages
listenForPostMessage();
CkanToZenodoPublisherServiceAsync.Util.getInstance().checkZenodoEnvironment(new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
managementPanel.visibilityPublishOnZenodoButton(false);
}
@Override
public void onSuccess(Boolean result) {
GWT.log("checkZenodoEnvironment result: "+result);
GWT.log("checkZenodoEnvironment result: " + result);
managementPanel.visibilityPublishOnZenodoButton(result);
}
});
@ -509,7 +526,8 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
managementPanel.enablePublishOnZenodoButton(productId != null && !productId.isEmpty());
managementPanel.enableManageGRSFProductButton(
productId != null && !productId.isEmpty() && manageProductResponse.isManageEnabled());
//managementPanel.enableManageCMSProductsButton(productId != null && !productId.isEmpty() && moderationProductResponse.isManageEnabled());
// managementPanel.enableManageCMSProductsButton(productId != null &&
// !productId.isEmpty() && moderationProductResponse.isManageEnabled());
}
} else {
// The data hasn't been sent from your site!

View File

@ -333,10 +333,10 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
// String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
//
// CkanConnectorAccessPoint ckanAP = SessionUtil.getCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl);
// logger.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
// LOG.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
//
// String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
// logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
// LOG.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
//
// CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanAP.getBaseUrl(), ckanConnectorLogut);
// ckan.addGubeToken(ckanAP.getGcubeTokenValue());

View File

@ -33,7 +33,7 @@ public class SessionUtil {
public static final String CKAN_END_POINT = "CKAN_END_POINT";
public static final String CKAN_ACCESS_POINT = "CKAN_ACCESS_POINT";
public static final String GCUBE_REQUEST_URL = "gcube-request-url";
//private static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
//private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
private static final Log logger = LogFactoryUtil.getLog(SessionUtil.class);
/**

View File

@ -42,7 +42,7 @@ import com.liferay.portal.kernel.log.LogFactoryUtil;
*/
public class UserUtil {
//private static Logger logger = LoggerFactory.getLogger(UserUtil.class);
//private static Logger LOG = LoggerFactory.getLogger(UserUtil.class);
private static final Log logger = LogFactoryUtil.getLog(UserUtil.class);
private static final String ADD_USER_TO_OTHER_ORG_KEY = "ADD_USER_TO_OTHER_ORG_KEY";