Catalogue at root VO or VO level works in read only mode [#26854]

This commit is contained in:
Francesco Mangiacrapa 2024-02-23 15:30:05 +01:00
parent 36f32bf438
commit c9811d3fb0
7 changed files with 270 additions and 122 deletions

View File

@ -30,5 +30,10 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/gcube-ckan-datacatalog-2.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/gcube-ckan-datacatalog-2.3.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -46,6 +46,10 @@
@ -115,6 +119,10 @@
@ -184,6 +192,10 @@
@ -253,6 +265,10 @@
@ -275,7 +291,8 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<dependent-module archiveName="metadata-profile-form-builder-widget-2.1.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-form-builder-widget/metadata-profile-form-builder-widget">
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="catalogue-util-library-1.4.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-metadata-publisher-widget-2.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-metadata-publisher-widget/ckan-metadata-publisher-widget">
@ -328,6 +345,10 @@
@ -397,6 +418,10 @@
@ -466,6 +491,10 @@
@ -535,6 +564,10 @@

View File

@ -9,6 +9,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Supported the Edit facility [#26639]
- Support the Delete facility [#26793]
- Revisited the Navigation Bar
- Revisited the "Select Item Resources" step when publishing from Workspace [#26874]
- Catalogue at root VO or VO level works in read only mode [#26854]
## [v2.2.7] - 2023-12-21

View File

@ -65,8 +65,9 @@ public class CkanMetadataManagementPanel extends FlowPanel {
private Button types = new Button("Types");
// user's own
private InlineHTML separatorMyInfo = null;
private InlineHTML separatorAdminButtons = null;
private InlineHTML pipe_MyInfo_start = null;
private InlineHTML pipe_PublishItem_start = null;
private InlineHTML pipe_SelectedItemOptions_start = null;
private DropdownButton dropMyOptionButtons = new DropdownButton("My...");
private NavLink myDatasets = new NavLink("My Items");
@ -146,6 +147,9 @@ public class CkanMetadataManagementPanel extends FlowPanel {
shareLink.setEnabled(false);
uploadToZenodo.setEnabled(false);
// hide upload to zenodo
uploadToZenodo.setVisible(false);
// hide publish/update/delete
editMeta.setVisible(false);
deleteItem.setVisible(false);
@ -168,6 +172,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
nav.add(messageModerationEnanbled);
nav.setId("the_catalogue_nav_bar");
nav.addStyleName("nav_bar_catalogue");
// add to navigation bar
nav.add(home);
@ -176,10 +181,10 @@ public class CkanMetadataManagementPanel extends FlowPanel {
nav.add(items);
nav.add(types);
nav.add(statistics);
separatorMyInfo = new InlineHTML(
pipe_MyInfo_start = new InlineHTML(
"<span style=\"font-weight:bold;vertical-alignment:middle;margin:0 5px;\">|</span>");
separatorMyInfo.setVisible(true);
nav.add(separatorMyInfo);
pipe_MyInfo_start.setVisible(true);
nav.add(pipe_MyInfo_start);
dropMyOptionButtons.setBaseIcon(IconType.USER);
dropMyOptionButtons.add(myOrganizations);
@ -188,14 +193,16 @@ public class CkanMetadataManagementPanel extends FlowPanel {
dropMyOptionButtons.setType(ButtonType.LINK);
nav.add(dropMyOptionButtons);
separatorAdminButtons = new InlineHTML(
pipe_PublishItem_start = new InlineHTML(
"<span style=\"font-weight:bold;vertical-alignment:middle;margin:0 5px;\">|</span>");
separatorAdminButtons.setVisible(true);
nav.add(separatorAdminButtons);
pipe_PublishItem_start.setVisible(false);
nav.add(pipe_PublishItem_start);
nav.add(insertMeta);
nav.add(new InlineHTML("<span style=\"font-weight:bold;vertical-alignment:middle;margin:0 5px;\">|</span>"));
pipe_SelectedItemOptions_start = new InlineHTML(
"<span style=\"font-weight:bold;vertical-alignment:middle;margin:0 5px;\">|</span>");
pipe_SelectedItemOptions_start.setVisible(true);
nav.add(pipe_SelectedItemOptions_start);
nav.add(editMeta);
nav.add(deleteItem);
@ -384,19 +391,12 @@ public class CkanMetadataManagementPanel extends FlowPanel {
}
/**
* Those buttons can be only visible when the logged user has role
* EDITOR/ADMIN/SYSADMIN
* Enable publish button.
*
* @param show the show
* @param enable the enable
*/
public void visibilityPublishUpdateDeleteButtons(boolean show) {
// editMeta.setVisible(show); TODO
// separatorAdminButtons.setVisible(show);
insertMeta.setVisible(show);
editMeta.setVisible(show);
deleteItem.setVisible(show);
public void enablePublishItemButton(boolean enable) {
insertMeta.setEnabled(enable);
}
/**
@ -491,6 +491,20 @@ public class CkanMetadataManagementPanel extends FlowPanel {
uploadToZenodo.setVisible(value);
}
/**
* Visibility publish item button.
*
* @param value the value
* @param alsoThePipe the also the pipe. If true set bool value also the related
* pipe 'pipe_PublishItem_start'
*/
public void visibilityPublishItemButton(boolean bool, boolean alsoThePipe) {
insertMeta.setVisible(bool);
if (alsoThePipe) {
pipe_PublishItem_start.setVisible(bool);
}
}
/**
* Visibility edit item button.
*
@ -514,8 +528,9 @@ public class CkanMetadataManagementPanel extends FlowPanel {
*/
public void doNotShowUserRelatedInfo() {
separatorMyInfo.setVisible(false);
separatorAdminButtons.setVisible(false);
pipe_MyInfo_start.setVisible(false);
pipe_PublishItem_start.setVisible(false);
pipe_SelectedItemOptions_start.setVisible(false);
shareLink.setVisible(false);
uploadToZenodo.setVisible(false);
insertMeta.setVisible(false);
@ -540,8 +555,8 @@ public class CkanMetadataManagementPanel extends FlowPanel {
groups.setVisible(false);
items.setVisible(false);
types.setVisible(false);
separatorMyInfo.setVisible(false);
separatorAdminButtons.setVisible(false);
pipe_MyInfo_start.setVisible(false);
pipe_PublishItem_start.setVisible(false);
dropMyOptionButtons.setVisible(false);
// myDatasets.setVisible(false);
// myOrganizations.setVisible(false);

View File

@ -181,25 +181,57 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
@Override
public void onFailure(Throwable caught) {
showPublishUpdateDeleteButtons(false);
managementPanel.visibilityEditItemButton(false);
managementPanel.visibilityDeleteItemButton(false);
managementPanel.visibilityPublishItemButton(false, true);
}
@Override
public void onSuccess(RolesCkanGroupOrOrg result) {
GWT.log("isUserLoggedInVRE: "+ckanAccessPoint.isUserLoggedInVRE());
GWT.log("getLoggedInScope: "+ckanAccessPoint.getLoggedInScope());
if (ckanAccessPoint.isUserLoggedInVRE()) {
switch (result) {
case ADMIN:
showPublishUpdateDeleteButtons(true);
case ADMIN: {
managementPanel.visibilityPublishItemButton(true, true);
managementPanel.visibilityEditItemButton(true);
managementPanel.visibilityDeleteItemButton(true);
managementPanel.enablePublishItemButton(true);
break;
case EDITOR:
showPublishUpdateDeleteButtons(true);
}
case EDITOR: {
managementPanel.visibilityPublishItemButton(true, true);
managementPanel.visibilityEditItemButton(true);
managementPanel.visibilityDeleteItemButton(true);
managementPanel.enablePublishItemButton(true);
break;
case MEMBER:
showPublishUpdateDeleteButtons(false);
}
case MEMBER: {
managementPanel.visibilityEditItemButton(false);
managementPanel.visibilityDeleteItemButton(false);
// Disable the button "Publish Item" is to inform the user that he/she has
// not the rights to publish
managementPanel.visibilityPublishItemButton(true, true);
managementPanel.enablePublishItemButton(false);
break;
default:
showPublishUpdateDeleteButtons(false);
}
default: {
managementPanel.visibilityEditItemButton(false);
managementPanel.visibilityDeleteItemButton(false);
// Disable the button "Publish Item" is to inform the user that he/she has
// not the rights to publish
managementPanel.visibilityPublishItemButton(true, true);
managementPanel.enablePublishItemButton(false);
break;
}
}
} else {
managementPanel.visibilityPublishItemButton(false, true);
managementPanel.visibilityEditItemButton(false);
managementPanel.visibilityDeleteItemButton(false);
}
}
});
@ -414,15 +446,15 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
updateSize();
}
/**
* show or hide the Publish/Update/Delete buttons according to the role.
*
* @param show the show
*/
public void showPublishUpdateDeleteButtons(boolean show) {
managementPanel.visibilityPublishUpdateDeleteButtons(show);
}
// /**
// * show or hide the Publish/Update/Delete buttons according to the role.
// *
// * @param show the show
// */
// public void showPublishUpdateDeleteButtons(boolean show) {
//
// managementPanel.visibilityUpdateDeleteButtons(show);
// }
/**
* Instance ckan frame.

View File

@ -88,7 +88,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
try{
// just get the current scope and set it into ScopeProvider...
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
String loggedInScope = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
// retrieve scope per current portlet url
String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
@ -112,7 +112,15 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
pathInfoParameter = isViewPerVREEnabled(browserLocationURL);
}
//#26854
CkanConnectorAccessPoint ckAP = getCkanConnectorAccessPoint(browserLocationURL, pathInfoParameter, queryStringParameters, scopePerCurrentUrl);
ckAP.setLoggedInScope(loggedInScope);
ckAP.setOperativeScope(scopePerCurrentUrl);
if(loggedInScope!=null) {
ScopeBean scopeBeanLS = new ScopeBean(loggedInScope);
boolean loggedInVRE = scopeBeanLS.is(Type.VRE);
ckAP.setUserLoggedInVRE(loggedInVRE);
}
SessionUtil.saveCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl, ckAP);
logger.info("Built the URI to CKAN (connector in case of user logged): "+ckAP.buildURI());
logger.debug("returning ckanConnectorUri: "+ckAP);
@ -238,8 +246,8 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
RolesCkanGroupOrOrg toReturn = RolesCkanGroupOrOrg.MEMBER;
if(!SessionUtil.isIntoPortal()){
logger.warn("OUT FROM PORTAL DETECTED RETURNING ROLE: "+RolesCkanGroupOrOrg.ADMIN);
toReturn = RolesCkanGroupOrOrg.ADMIN;
logger.warn("OUT FROM PORTAL DETECTED RETURNING ROLE: "+toReturn);
}else{
HttpSession httpSession = this.getThreadLocalRequest().getSession();

View File

@ -10,12 +10,10 @@ import java.util.Set;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server.GcubeCkanDataCatalogServiceImpl;
/**
* The Class CkanConnectorAccessPoint.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 23, 2016
*/
public class CkanConnectorAccessPoint implements Serializable {
@ -37,6 +35,10 @@ public class CkanConnectorAccessPoint implements Serializable{
private boolean outsideLoginOnPortal = false;
private String catalogueBaseUrl = null;
private String operativeScope = null;
private String loggedInScope = null;
private boolean isUserLoggedInVRE = false;
/**
* Instantiates a new ckan connector access point.
*/
@ -62,10 +64,10 @@ public class CkanConnectorAccessPoint implements Serializable{
* @param value the value
*/
public void addGenericParameter(String key, String value) {
queryStringParameters=queryStringParameters==null?key+"="+value:queryStringParameters+"&"+key+"="+value;
queryStringParameters = queryStringParameters == null ? key + "=" + value
: queryStringParameters + "&" + key + "=" + value;
}
/**
* Adds the query string.
*
@ -108,7 +110,8 @@ public class CkanConnectorAccessPoint implements Serializable{
for (Entry<String, String> entry : set) {
vres += entry.getKey().toLowerCase() + "|" + entry.getValue() + ",";
}
vres = vres.substring(0, vres.length()-1); //remove last "," and to lower case. A CKAN Organization ID must be lower case
vres = vres.substring(0, vres.length() - 1); // remove last "," and to lower case. A CKAN Organization ID
// must be lower case
}
if (vres.length() > 0) {
@ -125,9 +128,8 @@ public class CkanConnectorAccessPoint implements Serializable{
pathInfoParameter = pathInfo;
}
/**
* Builds the URI to contact the CKAN (connector in case of user logged)
* Builds the URI to contact the CKAN (connector in case of user logged).
*
* @return the string
*/
@ -142,6 +144,55 @@ public class CkanConnectorAccessPoint implements Serializable{
return url;
}
/**
* Gets the operative scope.
*
* @return the operative scope
*/
public String getOperativeScope() {
return operativeScope;
}
/**
* Gets the logged in scope.
*
* @return the logged in scope
*/
public String getLoggedInScope() {
return loggedInScope;
}
public boolean isUserLoggedInVRE() {
return isUserLoggedInVRE;
}
/**
* Sets the user logged in VRE.
*
* @param isUserLoggedInVRE the new user logged in VRE
*/
public void setUserLoggedInVRE(boolean isUserLoggedInVRE) {
this.isUserLoggedInVRE = isUserLoggedInVRE;
}
/**
* Sets the operative scope.
*
* @param operativeScope the new operative scope
*/
public void setOperativeScope(String operativeScope) {
this.operativeScope = operativeScope;
}
/**
* Sets the logged in scope.
*
* @param loggedInScope the new logged in scope
*/
public void setLoggedInScope(String loggedInScope) {
this.loggedInScope = loggedInScope;
}
/**
* Gets the base url with context.
*
@ -152,7 +203,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return baseUrl + serviceContext;
}
/**
* Gets the path info parameter.
*
@ -163,7 +213,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return pathInfoParameter;
}
/**
* Gets the query string parameters.
*
@ -174,7 +223,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return queryStringParameters;
}
/**
* Gets the gcube token value.
*
@ -185,7 +233,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return gcubeTokenValue;
}
/**
* Gets the list of v res.
*
@ -200,9 +247,14 @@ public class CkanConnectorAccessPoint implements Serializable{
* Check url path separator.
*
* @param url the url
* @param head - checks the {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR} in head adding if do not exist
* @param tail - checks the {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR} in tail adding if do not exist
* @return the string - if null return an empty string otherwise a string with {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR}
* @param head - checks the
* {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR} in
* head adding if do not exist
* @param tail - checks the
* {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR} in
* tail adding if do not exist
* @return the string - if null return an empty string otherwise a string with
* {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR}
*/
public static String checkURLPathSeparator(String url, boolean head, boolean tail) {
@ -217,7 +269,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return url;
}
/**
* Gets the base url.
*
@ -228,7 +279,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return baseUrl;
}
/**
* Check null string.
*
@ -243,8 +293,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return value;
}
/**
* Checks if is outside login on portal.
*
@ -255,7 +303,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return outsideLoginOnPortal;
}
/**
* Sets the outside login on portal.
*
@ -275,8 +322,14 @@ public class CkanConnectorAccessPoint implements Serializable{
return catalogueBaseUrl;
}
/* (non-Javadoc)
/**
* To string.
*
* @return the string
*/
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override