in progress integration with CMS

This commit is contained in:
Francesco Mangiacrapa 2022-02-17 17:01:25 +01:00
parent 788939f8b6
commit 8e2b30707b
13 changed files with 176 additions and 109 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/gcube-ckan-datacatalog-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/gcube-ckan-datacatalog-2.2.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/gcube-ckan-datacatalog-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/gcube-ckan-datacatalog-2.2.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/gcube-ckan-datacatalog-2.1.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/gcube-ckan-datacatalog-2.2.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,6 +1,6 @@
>>>>>>>=refs/heads/task_20699
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francescomangiacrapa/git/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-2.1.0-SNAPSHOT
lastWarOutDir=/home/francescomangiacrapa/git/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-2.2.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -13,8 +13,16 @@
<wb-module deploy-name="gcube-ckan-datacatalog-2.1.0-SNAPSHOT">
<wb-module deploy-name="gcube-ckan-datacatalog-2.2.0-SNAPSHOT">
@ -29,7 +37,11 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -44,7 +56,11 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -59,20 +75,28 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<dependent-module archiveName="catalogue-util-library-1.0.3.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/catalogue-util-library/catalogue-util-library">
<dependent-module archiveName="catalogue-util-library-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/catalogue-util-library/catalogue-util-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="ckan-content-moderator-widget-0.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-content-moderator-widget/ckan-content-moderator-widget">
<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>
@ -87,7 +111,11 @@
<property name="context-root" value="gcube-ckan-datacatalog"/>
@ -102,7 +130,11 @@
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -117,7 +149,11 @@
</wb-module>

View File

@ -5,7 +5,7 @@ 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.2.0-SNAPSHOT] - 2022-01-21
## [v2.2.0-SNAPSHOT] - 2022-01-27
#### Enhancements

View File

@ -123,7 +123,7 @@
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>ckan-content-moderator-widget</artifactId>
<version>[0.0.1, 1.0.0-SNAPSHOT)</version>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>

View File

@ -10,28 +10,25 @@ import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.ManageProductRes
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The Interface GcubeCkanDataCatalogService.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Nov 4, 2016
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Nov 4, 2016
*/
@RemoteServiceRelativePath("ckandatacatalogue")
public interface GcubeCkanDataCatalogService extends RemoteService {
/**
* Get the ckan connector access point.
*
* @param browserLocationURL the browser location URL
* @param pathInfoParameters the path info parameters
* @param browserLocationURL the browser location URL
* @param pathInfoParameters the path info parameters
* @param queryStringParameters the query string parameters
* @return the c kan connector
* @throws Exception the exception
*/
CkanConnectorAccessPoint getCKanConnector(
String browserLocationURL, String pathInfoParameters, String queryStringParameters) throws Exception;
CkanConnectorAccessPoint getCKanConnector(String browserLocationURL, String pathInfoParameters,
String queryStringParameters) throws Exception;
/**
* Get the current role in CKAN for this user.
@ -62,32 +59,41 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
*/
String logoutFromCkanURL();
// /**
// * Remove auth cookie for ckan of this user.
// *
// * @return the string
// */
// String logoutURIFromCkan();
// /**
// * Remove auth cookie for ckan of this user.
// *
// * @return the string
// */
// String logoutURIFromCkan();
/**
* Check if the manage product needs to be shown (e.g., for GRSF products)
* @return
*
* @return the manage product response
*/
ManageProductResponse isManageProductEnabled();
/**
* Check if the view per VRE is enabled, so the management panels but publish/share link must be removed.
* Check if the view per VRE is enabled, so the management panels but
* publish/share link must be removed.
*
* @param browserLocationURL the browser location URL
* @return the string
*/
String isViewPerVREEnabled(String browserLocationURL);
/**
* Outside login portal.
*
* @return true, if successful
*/
boolean outsideLoginPortal();
/**
* Check moderation enabled.
*
* @param reloadConfig the reload config
* @return the manage product response
*/
ManageProductResponse checkModerationEnabled(boolean reloadConfig);
}

View File

@ -12,14 +12,10 @@ import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.ManageProductRes
import com.google.gwt.user.client.rpc.AsyncCallback;
// TODO: Auto-generated Javadoc
/**
* The Interface GcubeCkanDataCatalogServiceAsync.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Nov 4, 2016
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Nov 4, 2016
*/
public interface GcubeCkanDataCatalogServiceAsync {
@ -34,14 +30,13 @@ public interface GcubeCkanDataCatalogServiceAsync {
/**
* Gets the CKAN connector.
*
* @param browserLocationURL the browser location URL that performs the call
* @param pathInfoParameters the path info parameters
* @param browserLocationURL the browser location URL that performs the call
* @param pathInfoParameters the path info parameters
* @param queryStringParameters the query string parameters
* @param callback the callback
* @param callback the callback
* @return the c kan connector
*/
void getCKanConnector(
String browserLocationURL, String pathInfoParameters, String queryStringParameters,
void getCKanConnector(String browserLocationURL, String pathInfoParameters, String queryStringParameters,
AsyncCallback<CkanConnectorAccessPoint> callback);
/**
@ -57,8 +52,7 @@ public interface GcubeCkanDataCatalogServiceAsync {
* @param callback the callback
* @return the ckan organizations names and urls for user
*/
void getCkanOrganizationsNamesAndUrlsForUser(
AsyncCallback<List<BeanUserInOrgGroupRole>> callback);
void getCkanOrganizationsNamesAndUrlsForUser(AsyncCallback<List<BeanUserInOrgGroupRole>> callback);
/**
* Retrieve the list of groups to whom the user belongs and their urls.
@ -66,10 +60,8 @@ public interface GcubeCkanDataCatalogServiceAsync {
* @param callback the callback
* @return the ckan groups names and urls for user
*/
void getCkanGroupsNamesAndUrlsForUser(
AsyncCallback<List<BeanUserInOrgGroupRole>> callback);
void getCkanGroupsNamesAndUrlsForUser(AsyncCallback<List<BeanUserInOrgGroupRole>> callback);
/**
* Checks if is manage product enabled.
*
@ -77,20 +69,26 @@ public interface GcubeCkanDataCatalogServiceAsync {
*/
void isManageProductEnabled(AsyncCallback<ManageProductResponse> callback);
/**
* Checks if is view per VRE enabled.
*
* @param browserLocationURL the browser location URL
* @param callback the callback
* @param callback the callback
*/
void isViewPerVREEnabled(String browserLocationURL, AsyncCallback<String> callback);
/**
* Outside login portal.
*
* @param callback the callback
*/
void outsideLoginPortal(AsyncCallback<Boolean> callback);
/**
* Check moderation enabled.
*
* @param reloadConfig the reload config
* @param callback the callback
*/
void checkModerationEnabled(boolean reloadConfig, AsyncCallback<ManageProductResponse> callback);
}

View File

@ -15,7 +15,7 @@ public class ClickedCMSManageProductButtonEvent extends GwtEvent<ClickedCMSManag
public static Type<ClickedCMSManageProductButtonEventHandler> TYPE = new Type<ClickedCMSManageProductButtonEventHandler>();
/**
* Instantiates a new clicked CMS manage product button event.
* Instantiates a new clicked Content Moderation System (CMS) manage product button event.
*/
public ClickedCMSManageProductButtonEvent() {
}

View File

@ -74,8 +74,8 @@ public class CkanMetadataManagementPanel extends FlowPanel {
private Button uploadToZenodo = new Button("Upload to Zenodo");
private Button insertMeta = new Button("Publish Item");
private Button editMeta = new Button("Edit Item");
private Button manageGRSFProduct = new Button("Manage GRSF Item");
private Button manageCMS = new Button("Manage Items");
private Button manageGRSFProduct = new Button("Manage GRSF Item"); //GRSF Manage
private Button manageCModS = new Button("Manage Items"); //Moderation
private HandlerManager eventBus;
/**
@ -108,8 +108,8 @@ public class CkanMetadataManagementPanel extends FlowPanel {
manageGRSFProduct.setType(ButtonType.PRIMARY);
manageGRSFProduct.getElement().getStyle().setFloat(Float.RIGHT);
manageCMS.setType(ButtonType.PRIMARY);
manageCMS.getElement().getStyle().setFloat(Float.RIGHT);
manageCModS.setType(ButtonType.PRIMARY);
manageCModS.getElement().getStyle().setFloat(Float.RIGHT);
// set icons
home.setIcon(IconType.HOME);
@ -126,7 +126,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
editMeta.setIcon(IconType.EDIT_SIGN);
statistics.setIcon(IconType.BAR_CHART);
manageGRSFProduct.setIcon(IconType.CHECK_SIGN);
manageCMS.setIcon(IconType.CHECK_SIGN);
manageCModS.setIcon(IconType.CHECK_SIGN);
// hide edit and insert
shareLink.setEnabled(false);
@ -135,16 +135,16 @@ public class CkanMetadataManagementPanel extends FlowPanel {
insertMeta.setVisible(false);
manageGRSFProduct.setVisible(false);
manageGRSFProduct.setEnabled(false);
manageCMS.setVisible(false);
manageCMS.setEnabled(false);
manageCModS.setVisible(false);
manageCModS.setEnabled(false);
// manage GRSF item info
manageGRSFProduct.setTitle(MANAGE_GRSF_ITEM_TOOLTIP);
manageGRSFProduct.getElement().getStyle().setFontWeight(FontWeight.BOLD);
// manage CMS item info
manageCMS.setTitle(MANAGE_CMS_ITEMS_TOOLTIP);
manageCMS.getElement().getStyle().setFontWeight(FontWeight.BOLD);
manageCModS.setTitle(MANAGE_CMS_ITEMS_TOOLTIP);
manageCModS.getElement().getStyle().setFontWeight(FontWeight.BOLD);
// add to navigation bar
nav.add(home);
@ -167,7 +167,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
nav.add(insertMeta);
nav.add(editMeta);
nav.add(manageGRSFProduct);
nav.add(manageCMS);
nav.add(manageCModS);
nav.setClose(false);
nav.setType(AlertType.INFO);
nav.getElement().getStyle().setMarginBottom(0, Unit.PX);
@ -300,7 +300,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
}
});
manageCMS.addClickHandler(new ClickHandler() {
manageCModS.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
@ -373,12 +373,12 @@ public class CkanMetadataManagementPanel extends FlowPanel {
}
/**
* Button to manage the CMS products..
* Button to manage the products under moderation via Content Moderation System (CMS)
*
* @param value true or false
*/
public void showManageCMSProductsButton(boolean value) {
manageCMS.setVisible(value);
manageCModS.setVisible(value);
}
/**
@ -387,7 +387,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
* @param value the value
*/
public void enableManageCMSProductsButton(boolean value) {
manageCMS.setEnabled(value);
manageCModS.setEnabled(value);
}
/**
@ -432,7 +432,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
myOrganizations.setVisible(false);
myGroups.setVisible(false);
manageGRSFProduct.setVisible(false);
manageCMS.setVisible(false);
manageCModS.setVisible(false);
}
@ -453,7 +453,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
myGroups.setVisible(false);
statistics.setVisible(false);
manageGRSFProduct.setVisible(false);
manageCMS.setVisible(false);
manageCModS.setVisible(false);
}

View File

@ -52,10 +52,12 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
private HandlerManager eventBus;
private CkanConnectorAccessPoint ckanAccessPoint;
private ManageProductResponse manageProductResponse = null;
private ManageProductResponse moderationProductResponse = null;
private String viewPerVREPath = null;
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
/**
* Instantiates a new g cube ckan data catalog panel.
@ -227,17 +229,11 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
.isManageProductEnabled(new AsyncCallback<ManageProductResponse>() {
@Override
public void onSuccess(ManageProductResponse result) {
manageProductResponse = result;
public void onSuccess(ManageProductResponse manageResponse) {
manageProductResponse = manageResponse;
if (manageProductResponse != null) {
if(manageProductResponse.isGRSFManageEnabled()) {
managementPanel.showManageCMSProductsButton(
manageProductResponse.isManageEnabled());
}else if(manageProductResponse.isManageEnabled()) {
managementPanel.showManageCMSProductsButton(manageProductResponse.isManageEnabled());
managementPanel.enableManageCMSProductsButton(manageProductResponse.isManageEnabled());
}
managementPanel.showManageGRSFProductButton(
manageProductResponse.isManageEnabled());
}
}
@ -246,6 +242,26 @@ 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());
}
});
}
@ -492,7 +508,8 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
managementPanel.enableShareItemButton(productId != null && !productId.isEmpty());
managementPanel.enablePublishOnZenodoButton(productId != null && !productId.isEmpty());
managementPanel.enableManageGRSFProductButton(
productId != null && !productId.isEmpty() && manageProductResponse.isGRSFManageEnabled());
productId != null && !productId.isEmpty() && manageProductResponse.isManageEnabled());
//managementPanel.enableManageCMSProductsButton(productId != null && !productId.isEmpty() && moderationProductResponse.isManageEnabled());
}
} else {
// The data hasn't been sent from your site!

View File

@ -517,8 +517,25 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
}
else{
try{
boolean toReturn = catalogue.isManageProductEnabled();
logger.info("isManageProductEnabled: "+toReturn);
boolean isManageProductEnabled = catalogue.isManageProductEnabled();
logger.info("isManageProductEnabled: "+isManageProductEnabled);
//TO BE SURE THAT THE CURRENT CONTEXT IS A GRSF SCOPE FOR ENABLING THE "MANAGE GRSF ITEM"
boolean isGRSFContext = false;
if (scopePerCurrentUrl != null) {
if (scopePerCurrentUrl.toLowerCase().contains("grsf")) {
isGRSFContext = true;
}
}
logger.info("isGRSFContext: "+isGRSFContext);
boolean toReturn = false;
if(isGRSFContext && isManageProductEnabled) {
toReturn = true;
}
logger.info("returning manage enabled: "+toReturn);
ManageProductResponse mpr = new ManageProductResponse(toReturn, scopePerCurrentUrl);
logger.info("Will manage product be enabled for this user? " + mpr);
return mpr;
@ -528,6 +545,16 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
}
}
}
@Override
public ManageProductResponse checkModerationEnabled(boolean reloadConfig) {
logger.info("Checking if the moderation is enabled in the current context, reload config? "+reloadConfig);
String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl);
boolean moderationEnabled = catalogue.isModerationEnabled(reloadConfig);
return new ManageProductResponse(moderationEnabled, scopePerCurrentUrl);
}
/**
* Ask to liferay.

View File

@ -7,15 +7,16 @@ import java.io.Serializable;
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2021
* Feb 17, 2022
*/
public class ManageProductResponse implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private boolean isManageEnabled;
private static final long serialVersionUID = 4042294108868246495L;
// Is GRSF MANAGE in the GRSF context, Is gCat moderation in the other contexts
private boolean isManageEnabled = false;
private String scope;
/**
@ -72,24 +73,6 @@ public class ManageProductResponse implements Serializable {
this.scope = scope;
}
public boolean isGRSFScope() {
if (this.scope != null) {
if (this.scope.toLowerCase().contains("grsf")) {
return true;
}
}
return false;
}
public boolean isGRSFManageEnabled() {
if (isGRSFScope() && isManageEnabled)
return true;
return false;
}
/**
* To string.
*

View File

@ -62,13 +62,13 @@
</servlet>
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-name>ckanContentModeratorServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.ckancontentmoderator.server.CkanContentModeratorServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/gCubeCkanDataCatalog/greet</url-pattern>
<servlet-name>ckanContentModeratorServlet</servlet-name>
<url-pattern>/gCubeCkanDataCatalog/ckanContentModeratorService</url-pattern>
</servlet-mapping>