UriResolver scope provider updated

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@83665 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-10-22 14:43:50 +00:00
parent f3b17d0c73
commit f41541cb23
5 changed files with 24 additions and 10 deletions

View File

@ -19,6 +19,7 @@ import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.workspace.server.shortener.UrlEncoderUtil;
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.impl.XQuery;
@ -55,7 +56,9 @@ public class UriResolverReaderParameter {
logger.trace("UriResolverReaderParameter is istancing with scope: "+scope);
ScopeProvider.instance.set(scope);
ScopeUtilFilter scopeUtil = new ScopeUtilFilter(scope);
ScopeProvider.instance.set(scopeUtil.getScopeRoot());
XQuery query = queryFor(ServiceEndpoint.class);

View File

@ -24,6 +24,7 @@ import org.apache.log4j.Logger;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.impl.XQuery;
import org.json.simple.JSONObject;
@ -58,12 +59,14 @@ public final class UrlShortener {
* @throws IllegalStateException *
*
*/
public UrlShortener() throws Exception {
public UrlShortener(String scope) throws Exception {
try{
logger.trace("Tentative reading HTTP-URL-Shortener RR");
ScopeProvider.instance.set("/gcube");
ScopeUtilFilter scopeUtil = new ScopeUtilFilter(scope);
ScopeProvider.instance.set(scopeUtil.getScopeRoot());
XQuery query = queryFor(ServiceEndpoint.class);
@ -197,7 +200,7 @@ public final class UrlShortener {
try {
UrlShortener urlSh = new UrlShortener();
UrlShortener urlSh = new UrlShortener("/d4science.research-infrastructures.eu");
System.out.println("UrlShortener: "+urlSh);
shorten = urlSh.shorten("https://dev.d4science.org/group/data-e-infrastructure-gateway/workspace?itemid=056648-c7ce-4de3-a4c7-e1411816cc12&operation=gotofolder");

View File

@ -74,10 +74,10 @@ public class WsUtil {
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
user=TEST_USER;
// user=TEST_USER;
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
// user = "francesco.mangiacrapa";
user = "francesco.mangiacrapa";
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
logger.warn("session id: "+sessionID);
@ -285,7 +285,7 @@ public class WsUtil {
shortener = (UrlShortener) session.getAttribute(WsUtil.URL_SHORTENER_SERVICE);
if(shortener==null){
shortener = new UrlShortener();
shortener = new UrlShortener(session.getScope().toString());
session.setAttribute(URL_SHORTENER_SERVICE, shortener);
}

View File

@ -129,6 +129,10 @@ public class ScopeUtilFilter {
}
}
public String getScopeRoot() {
return scopeRoot;
}
public static void main(String[] args) {
String scope = "/gcube";
@ -136,6 +140,8 @@ public class ScopeUtilFilter {
ScopeUtilFilter filter = new ScopeUtilFilter(scope);
System.out.println("scope root is: "+filter.getScopeRoot());
filter.convertListScopeToPortlet(listTest);

View File

@ -49,9 +49,9 @@ public class UriResolverReaderRR {
* @throws Exception
*
*/
public UriResolverReaderRR() throws Exception {
public UriResolverReaderRR(String scope) throws Exception {
ScopeProvider.instance.set("/gcube/devsec");
ScopeProvider.instance.set(scope);
XQuery query = queryFor(ServiceEndpoint.class);
@ -163,6 +163,8 @@ public class UriResolverReaderRR {
try{
String scope = "/gcube/devsec";
ScopeProvider.instance.set("/gcube/devsec");
Workspace workspace = HomeLibrary
.getHomeManagerFactory()
.getHomeManager()
@ -202,7 +204,7 @@ public class UriResolverReaderRR {
// String smpUri = "smp://Home/test.user/Workspace/bla8200ceb0-c525-40e6-bad1-a63f83811d3d?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==";
UrlShortener urlShortner = new UrlShortener();
UrlShortener urlShortner = new UrlShortener(scope);
String shortUrl = urlShortner.shorten(url);
System.out.println("url shortUrl: "+shortUrl);