minor changes to class ApplicationProfileScopePerUrlReader (method getScopePerUrl is now static)

The utility method to merge a key and the scope has been moved within the library

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@131387 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-09-15 13:43:15 +00:00
parent 40459ae18b
commit fbb3a28851
2 changed files with 20 additions and 4 deletions

View File

@ -39,16 +39,20 @@ public class ApplicationProfileScopePerUrlReader {
* @param url
* @return the scope to be used for the given url
*/
public String getScopePerUrl(String url){
public static String getScopePerUrl(String url){
logger.debug("Request scope for ckan portlet at url " + url);
if(url == null || url.isEmpty())
throw new IllegalArgumentException("The url passed is null or empty!");
String scopeToReturn = null;
String scope = ScopeProvider.instance.get();
String rootScopeForInfrastructure = "/" + PortalContext.getConfiguration().getInfrastructureName();
if(url == null || url.isEmpty()){
logger.debug("The url passed is null or empty! Returning current scope [" + scope + "]");
return scope;
}
// set this scope
ScopeProvider.instance.set(rootScopeForInfrastructure);

View File

@ -66,5 +66,17 @@ public class UtilMethods {
return false;
}
}
/**
* Builds a string made of key + scope
* @param key
* @param scope
* @return
*/
public static String concatenateSessionKeyScope(String key, String scope){
if(key == null || scope == null)
throw new IllegalArgumentException("Key or scope null");
return key.concat(scope);
}
}