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"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </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"/> <classpathentry kind="output" path="target/gcube-ckan-datacatalog-2.3.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -68,7 +72,11 @@
<wb-module deploy-name="gcube-ckan-datacatalog-2.3.0-SNAPSHOT"> <wb-module deploy-name="gcube-ckan-datacatalog-2.3.0-SNAPSHOT">
@ -137,7 +145,11 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -206,7 +218,11 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -275,13 +291,18 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <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> <dependency-type>uses</dependency-type>
</dependent-module> </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"> <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">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
@ -350,7 +371,11 @@
<property name="context-root" value="gcube-ckan-datacatalog"/> <property name="context-root" value="gcube-ckan-datacatalog"/>
@ -419,7 +444,11 @@
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -488,7 +517,11 @@
</wb-module> </wb-module>

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] - Supported the Edit facility [#26639]
- Support the Delete facility [#26793] - Support the Delete facility [#26793]
- Revisited the Navigation Bar - 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 ## [v2.2.7] - 2023-12-21

View File

@ -65,9 +65,10 @@ public class CkanMetadataManagementPanel extends FlowPanel {
private Button types = new Button("Types"); private Button types = new Button("Types");
// user's own // user's own
private InlineHTML separatorMyInfo = null; private InlineHTML pipe_MyInfo_start = null;
private InlineHTML separatorAdminButtons = null; private InlineHTML pipe_PublishItem_start = null;
private InlineHTML pipe_SelectedItemOptions_start = null;
private DropdownButton dropMyOptionButtons = new DropdownButton("My..."); private DropdownButton dropMyOptionButtons = new DropdownButton("My...");
private NavLink myDatasets = new NavLink("My Items"); private NavLink myDatasets = new NavLink("My Items");
private NavLink myOrganizations = new NavLink("My Organizations"); private NavLink myOrganizations = new NavLink("My Organizations");
@ -119,7 +120,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
manageCModS.setType(ButtonType.PRIMARY); manageCModS.setType(ButtonType.PRIMARY);
manageCModS.getElement().getStyle().setFloat(Float.RIGHT); manageCModS.getElement().getStyle().setFloat(Float.RIGHT);
manageCModS.getElement().getStyle().setMarginRight(20, Unit.PX); manageCModS.getElement().getStyle().setMarginRight(20, Unit.PX);
messageModerationEnanbled.setTitle(MESSAGE_MODERATED_CATALOGUE); messageModerationEnanbled.setTitle(MESSAGE_MODERATED_CATALOGUE);
messageModerationEnanbled.getElement().setInnerHTML("<i class='icon-user'></i> " + MESSAGE_MODERATED_CATALOGUE); messageModerationEnanbled.getElement().setInnerHTML("<i class='icon-user'></i> " + MESSAGE_MODERATED_CATALOGUE);
messageModerationEnanbled.addStyleName("moderation-enabled-flag"); messageModerationEnanbled.addStyleName("moderation-enabled-flag");
@ -145,13 +146,16 @@ public class CkanMetadataManagementPanel extends FlowPanel {
// disabling share and upload // disabling share and upload
shareLink.setEnabled(false); shareLink.setEnabled(false);
uploadToZenodo.setEnabled(false); uploadToZenodo.setEnabled(false);
// hide upload to zenodo
uploadToZenodo.setVisible(false);
// hide publish/update/delete // hide publish/update/delete
editMeta.setVisible(false); editMeta.setVisible(false);
deleteItem.setVisible(false); deleteItem.setVisible(false);
insertMeta.setVisible(false); insertMeta.setVisible(false);
//hide manage GRSF product and Moderation // hide manage GRSF product and Moderation
manageGRSFProduct.setVisible(false); manageGRSFProduct.setVisible(false);
manageGRSFProduct.setEnabled(false); manageGRSFProduct.setEnabled(false);
manageCModS.setVisible(false); manageCModS.setVisible(false);
@ -168,6 +172,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
nav.add(messageModerationEnanbled); nav.add(messageModerationEnanbled);
nav.setId("the_catalogue_nav_bar");
nav.addStyleName("nav_bar_catalogue"); nav.addStyleName("nav_bar_catalogue");
// add to navigation bar // add to navigation bar
nav.add(home); nav.add(home);
@ -176,10 +181,10 @@ public class CkanMetadataManagementPanel extends FlowPanel {
nav.add(items); nav.add(items);
nav.add(types); nav.add(types);
nav.add(statistics); nav.add(statistics);
separatorMyInfo = new InlineHTML( pipe_MyInfo_start = new InlineHTML(
"<span style=\"font-weight:bold;vertical-alignment:middle;margin:0 5px;\">|</span>"); "<span style=\"font-weight:bold;vertical-alignment:middle;margin:0 5px;\">|</span>");
separatorMyInfo.setVisible(true); pipe_MyInfo_start.setVisible(true);
nav.add(separatorMyInfo); nav.add(pipe_MyInfo_start);
dropMyOptionButtons.setBaseIcon(IconType.USER); dropMyOptionButtons.setBaseIcon(IconType.USER);
dropMyOptionButtons.add(myOrganizations); dropMyOptionButtons.add(myOrganizations);
@ -187,16 +192,18 @@ public class CkanMetadataManagementPanel extends FlowPanel {
dropMyOptionButtons.add(myDatasets); dropMyOptionButtons.add(myDatasets);
dropMyOptionButtons.setType(ButtonType.LINK); dropMyOptionButtons.setType(ButtonType.LINK);
nav.add(dropMyOptionButtons); nav.add(dropMyOptionButtons);
separatorAdminButtons = new InlineHTML(
"<span style=\"font-weight:bold;vertical-alignment:middle;margin:0 5px;\">|</span>");
separatorAdminButtons.setVisible(true);
nav.add(separatorAdminButtons);
pipe_PublishItem_start = new InlineHTML(
"<span style=\"font-weight:bold;vertical-alignment:middle;margin:0 5px;\">|</span>");
pipe_PublishItem_start.setVisible(false);
nav.add(pipe_PublishItem_start);
nav.add(insertMeta); 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(editMeta);
nav.add(deleteItem); nav.add(deleteItem);
nav.add(shareLink); nav.add(shareLink);
@ -204,7 +211,7 @@ public class CkanMetadataManagementPanel extends FlowPanel {
nav.add(manageGRSFProduct); nav.add(manageGRSFProduct);
nav.add(manageCModS); nav.add(manageCModS);
addHandlers(); addHandlers();
add(nav); add(nav);
} }
@ -384,19 +391,12 @@ public class CkanMetadataManagementPanel extends FlowPanel {
} }
/** /**
* Those buttons can be only visible when the logged user has role * Enable publish button.
* EDITOR/ADMIN/SYSADMIN
* *
* @param show the show * @param enable the enable
*/ */
public void visibilityPublishUpdateDeleteButtons(boolean show) { public void enablePublishItemButton(boolean enable) {
insertMeta.setEnabled(enable);
// editMeta.setVisible(show); TODO
// separatorAdminButtons.setVisible(show);
insertMeta.setVisible(show);
editMeta.setVisible(show);
deleteItem.setVisible(show);
} }
/** /**
@ -491,6 +491,20 @@ public class CkanMetadataManagementPanel extends FlowPanel {
uploadToZenodo.setVisible(value); 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. * Visibility edit item button.
* *
@ -514,8 +528,9 @@ public class CkanMetadataManagementPanel extends FlowPanel {
*/ */
public void doNotShowUserRelatedInfo() { public void doNotShowUserRelatedInfo() {
separatorMyInfo.setVisible(false); pipe_MyInfo_start.setVisible(false);
separatorAdminButtons.setVisible(false); pipe_PublishItem_start.setVisible(false);
pipe_SelectedItemOptions_start.setVisible(false);
shareLink.setVisible(false); shareLink.setVisible(false);
uploadToZenodo.setVisible(false); uploadToZenodo.setVisible(false);
insertMeta.setVisible(false); insertMeta.setVisible(false);
@ -540,8 +555,8 @@ public class CkanMetadataManagementPanel extends FlowPanel {
groups.setVisible(false); groups.setVisible(false);
items.setVisible(false); items.setVisible(false);
types.setVisible(false); types.setVisible(false);
separatorMyInfo.setVisible(false); pipe_MyInfo_start.setVisible(false);
separatorAdminButtons.setVisible(false); pipe_PublishItem_start.setVisible(false);
dropMyOptionButtons.setVisible(false); dropMyOptionButtons.setVisible(false);
// myDatasets.setVisible(false); // myDatasets.setVisible(false);
// myOrganizations.setVisible(false); // myOrganizations.setVisible(false);

View File

@ -181,24 +181,56 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
showPublishUpdateDeleteButtons(false); managementPanel.visibilityEditItemButton(false);
managementPanel.visibilityDeleteItemButton(false);
managementPanel.visibilityPublishItemButton(false, true);
} }
@Override @Override
public void onSuccess(RolesCkanGroupOrOrg result) { public void onSuccess(RolesCkanGroupOrOrg result) {
switch (result) { GWT.log("isUserLoggedInVRE: "+ckanAccessPoint.isUserLoggedInVRE());
case ADMIN: GWT.log("getLoggedInScope: "+ckanAccessPoint.getLoggedInScope());
showPublishUpdateDeleteButtons(true);
break; if (ckanAccessPoint.isUserLoggedInVRE()) {
case EDITOR:
showPublishUpdateDeleteButtons(true); switch (result) {
break; case ADMIN: {
case MEMBER: managementPanel.visibilityPublishItemButton(true, true);
showPublishUpdateDeleteButtons(false); managementPanel.visibilityEditItemButton(true);
break; managementPanel.visibilityDeleteItemButton(true);
default: managementPanel.enablePublishItemButton(true);
showPublishUpdateDeleteButtons(false); break;
break; }
case EDITOR: {
managementPanel.visibilityPublishItemButton(true, true);
managementPanel.visibilityEditItemButton(true);
managementPanel.visibilityDeleteItemButton(true);
managementPanel.enablePublishItemButton(true);
break;
}
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: {
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(); updateSize();
} }
/** // /**
* show or hide the Publish/Update/Delete buttons according to the role. // * show or hide the Publish/Update/Delete buttons according to the role.
* // *
* @param show the show // * @param show the show
*/ // */
public void showPublishUpdateDeleteButtons(boolean show) { // public void showPublishUpdateDeleteButtons(boolean show) {
//
managementPanel.visibilityPublishUpdateDeleteButtons(show); // managementPanel.visibilityUpdateDeleteButtons(show);
} // }
/** /**
* Instance ckan frame. * Instance ckan frame.

View File

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

View File

@ -10,14 +10,12 @@ import java.util.Set;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server.GcubeCkanDataCatalogServiceImpl; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server.GcubeCkanDataCatalogServiceImpl;
/** /**
* The Class CkanConnectorAccessPoint. * The Class CkanConnectorAccessPoint.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 23, 2016
* Jun 23, 2016
*/ */
public class CkanConnectorAccessPoint implements Serializable{ public class CkanConnectorAccessPoint implements Serializable {
/** /**
* *
@ -37,6 +35,10 @@ public class CkanConnectorAccessPoint implements Serializable{
private boolean outsideLoginOnPortal = false; private boolean outsideLoginOnPortal = false;
private String catalogueBaseUrl = null; private String catalogueBaseUrl = null;
private String operativeScope = null;
private String loggedInScope = null;
private boolean isUserLoggedInVRE = false;
/** /**
* Instantiates a new ckan connector access point. * Instantiates a new ckan connector access point.
*/ */
@ -46,10 +48,10 @@ public class CkanConnectorAccessPoint implements Serializable{
/** /**
* Instantiates a new ckan connector access point. * Instantiates a new ckan connector access point.
* *
* @param baseUrl the base url * @param baseUrl the base url
* @param serviceContext the service context * @param serviceContext the service context
*/ */
public CkanConnectorAccessPoint(String baseUrl, String serviceContext){ public CkanConnectorAccessPoint(String baseUrl, String serviceContext) {
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
this.catalogueBaseUrl = baseUrl.split("ckan-connector")[0]; this.catalogueBaseUrl = baseUrl.split("ckan-connector")[0];
this.serviceContext = serviceContext; this.serviceContext = serviceContext;
@ -58,29 +60,29 @@ public class CkanConnectorAccessPoint implements Serializable{
/** /**
* Adds the generic parameter. * Adds the generic parameter.
* *
* @param key the key * @param key the key
* @param value the value * @param value the value
*/ */
public void addGenericParameter(String key, String 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. * Adds the query string.
* *
* @param queryString the query string * @param queryString the query string
*/ */
public void addQueryString(String queryString){ public void addQueryString(String queryString) {
if(queryString==null || queryString.isEmpty()) if (queryString == null || queryString.isEmpty())
return; return;
if(queryString.startsWith("&") || queryString.startsWith("?")){ if (queryString.startsWith("&") || queryString.startsWith("?")) {
queryString = queryString.substring(1, queryString.length()); //removes '&' or '?' queryString = queryString.substring(1, queryString.length()); // removes '&' or '?'
} }
queryStringParameters=queryStringParameters==null?queryString:queryStringParameters+"&"+queryString; queryStringParameters = queryStringParameters == null ? queryString : queryStringParameters + "&" + queryString;
} }
/** /**
@ -88,8 +90,8 @@ public class CkanConnectorAccessPoint implements Serializable{
* *
* @param value the value * @param value the value
*/ */
public void addGubeToken(String value){ public void addGubeToken(String value) {
if(!outsideLoginOnPortal){ if (!outsideLoginOnPortal) {
this.gcubeTokenValue = value; this.gcubeTokenValue = value;
addGenericParameter(GCUBE_TOKEN_PARAMETER, value); addGenericParameter(GCUBE_TOKEN_PARAMETER, value);
} }
@ -100,18 +102,19 @@ public class CkanConnectorAccessPoint implements Serializable{
* *
* @param listVREs the list vr es * @param listVREs the list vr es
*/ */
public void addListOfVREs(Map<String, String> listVREs){ public void addListOfVREs(Map<String, String> listVREs) {
this.mapVresRoles = listVREs; this.mapVresRoles = listVREs;
String vres = ""; String vres = "";
if(listVREs!=null && listVREs.size()>0){ if (listVREs != null && listVREs.size() > 0) {
Set<Entry<String, String>> set = listVREs.entrySet(); Set<Entry<String, String>> set = listVREs.entrySet();
for (Entry<String, String> entry : set) { for (Entry<String, String> entry : set) {
vres += entry.getKey().toLowerCase() + "|" + entry.getValue() + ","; 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){ if (vres.length() > 0) {
addGenericParameter(LIST_OF_VRES_PARAMETER, vres); addGenericParameter(LIST_OF_VRES_PARAMETER, vres);
} }
} }
@ -121,27 +124,75 @@ public class CkanConnectorAccessPoint implements Serializable{
* *
* @param pathInfo the path info * @param pathInfo the path info
*/ */
public void addPathInfo(String pathInfo){ public void addPathInfo(String pathInfo) {
pathInfoParameter = pathInfo; 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 * @return the string
*/ */
public String buildURI(){ public String buildURI() {
String path = ""; String path = "";
String query = ""; String query = "";
path = checkURLPathSeparator(pathInfoParameter, true, false); path = checkURLPathSeparator(pathInfoParameter, true, false);
query = checkNullString(queryStringParameters); query = checkNullString(queryStringParameters);
String url = getBaseUrlWithContext()+path; String url = getBaseUrlWithContext() + path;
url+= !query.isEmpty()?"?"+query:""; url += !query.isEmpty() ? "?" + query : "";
return url; 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. * Gets the base url with context.
* *
@ -149,10 +200,9 @@ public class CkanConnectorAccessPoint implements Serializable{
*/ */
public String getBaseUrlWithContext() { public String getBaseUrlWithContext() {
return baseUrl+serviceContext; return baseUrl + serviceContext;
} }
/** /**
* Gets the path info parameter. * Gets the path info parameter.
* *
@ -163,7 +213,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return pathInfoParameter; return pathInfoParameter;
} }
/** /**
* Gets the query string parameters. * Gets the query string parameters.
* *
@ -174,7 +223,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return queryStringParameters; return queryStringParameters;
} }
/** /**
* Gets the gcube token value. * Gets the gcube token value.
* *
@ -185,7 +233,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return gcubeTokenValue; return gcubeTokenValue;
} }
/** /**
* Gets the list of v res. * Gets the list of v res.
* *
@ -199,25 +246,29 @@ public class CkanConnectorAccessPoint implements Serializable{
/** /**
* Check url path separator. * Check url path separator.
* *
* @param url the url * @param url the url
* @param head - checks the {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR} in head adding if do not exist * @param head - checks the
* @param tail - checks the {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR} in tail adding if do not exist * {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR} in
* @return the string - if null return an empty string otherwise a string with {@link GcubeCkanDataCatalogServiceImpl.URL_PATH_SEPARATOR} * 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){ public static String checkURLPathSeparator(String url, boolean head, boolean tail) {
if(url!=null && url.length()>0){ if (url != null && url.length() > 0) {
if(head) if (head)
url=url.startsWith(URL_PATH_SEPARATOR)?url:URL_PATH_SEPARATOR+url; url = url.startsWith(URL_PATH_SEPARATOR) ? url : URL_PATH_SEPARATOR + url;
if(tail) if (tail)
url=url.endsWith(URL_PATH_SEPARATOR)?url:url+URL_PATH_SEPARATOR; url = url.endsWith(URL_PATH_SEPARATOR) ? url : url + URL_PATH_SEPARATOR;
}else } else
url = ""; url = "";
return url; return url;
} }
/** /**
* Gets the base url. * Gets the base url.
* *
@ -228,23 +279,20 @@ public class CkanConnectorAccessPoint implements Serializable{
return baseUrl; return baseUrl;
} }
/** /**
* Check null string. * Check null string.
* *
* @param value the value * @param value the value
* @return the string if is not null otherwise an empty string * @return the string if is not null otherwise an empty string
*/ */
public static String checkNullString(String value){ public static String checkNullString(String value) {
if(value==null) if (value == null)
return ""; return "";
else else
return value; return value;
} }
/** /**
* Checks if is outside login on portal. * Checks if is outside login on portal.
* *
@ -255,7 +303,6 @@ public class CkanConnectorAccessPoint implements Serializable{
return outsideLoginOnPortal; return outsideLoginOnPortal;
} }
/** /**
* Sets the outside login on portal. * Sets the outside login on portal.
* *
@ -275,8 +322,14 @@ public class CkanConnectorAccessPoint implements Serializable{
return catalogueBaseUrl; return catalogueBaseUrl;
} }
/**
/* (non-Javadoc) * To string.
*
* @return the string
*/
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
@Override @Override