1925: Uri-Resolver: resolve gCubeStorage smp uri like http uri

Task-Url: https://support.d4science.org/issues/1925

Added temporary method to generate new public link format: http://host/storageID

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@122215 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-01-13 14:38:33 +00:00
parent 7c96bd1c9c
commit 300f3e0822
10 changed files with 251 additions and 151 deletions

View File

@ -16,7 +16,7 @@ Author
Version and Release Date Version and Release Date
------------------------ ------------------------
v. 6.10.1 December 2015 v. 6.11.0 January 2016
Description Description

View File

@ -1,4 +1,8 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-11-0"
date="2016-01-13">
<Change>[Feature #1925] New public link available</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-10-1" <Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-10-1"
date="2015-12-16"> date="2015-12-16">
<Change>Bug Fixing - #1804; #1808; #1822; #1333</Change> <Change>Bug Fixing - #1804; #1808; #1822; #1333</Change>

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-tree-widget</artifactId> <artifactId>workspace-tree-widget</artifactId>
<version>6.10.1-SNAPSHOT</version> <version>6.11.0-SNAPSHOT</version>
<name>gCube Workspace Tree Widget</name> <name>gCube Workspace Tree Widget</name>
<description> <description>
gCube Workspace Tree Widget. gCube Workspace Tree Widget.

View File

@ -57,7 +57,7 @@ import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.WorkspaceHandledException; import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.WorkspaceHandledException;
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer; import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil; import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil;
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter; import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener; import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
import org.gcube.portlets.user.workspace.server.util.AclTypeComparator; import org.gcube.portlets.user.workspace.server.util.AclTypeComparator;
import org.gcube.portlets.user.workspace.server.util.DifferenceBetweenInfoContactModel; import org.gcube.portlets.user.workspace.server.util.DifferenceBetweenInfoContactModel;
@ -172,7 +172,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
* *
* @return the uri resolver * @return the uri resolver
*/ */
protected UriResolverReaderParameter getUriResolver() { protected UriResolverReaderParameterForResolverIndex getUriResolver() {
return WsUtil.getUriResolver(this.getThreadLocalRequest().getSession()); return WsUtil.getUriResolver(this.getThreadLocalRequest().getSession());
} }
@ -2343,19 +2343,22 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
if(storageID==null || storageID.isEmpty()) if(storageID==null || storageID.isEmpty())
throw new Exception("Sorry, public link on "+wsItem.getName() +" is not available"); throw new Exception("Sorry, public link on "+wsItem.getName() +" is not available");
UriResolverReaderParameter uriResolver = getUriResolver(); UriResolverReaderParameterForResolverIndex uriResolver = getUriResolver();
String uriRequest = ""; String uriRequest = "";
if(uriResolver!=null && uriResolver.isAvailable()){ if(uriResolver!=null && uriResolver.isAvailable()){
String itemName = StringUtil.removeSpecialCharacters(folderItem.getName()); /*String itemName = StringUtil.removeSpecialCharacters(folderItem.getName());
itemName = StringUtil.replaceAllWhiteSpace(itemName, "_"); itemName = StringUtil.replaceAllWhiteSpace(itemName, "_");
uriRequest = uriResolver.resolveAsUriRequest(storageID, itemName, folderItem.getMimeType(), true); uriRequest = uriResolver.resolveAsUriRequest(storageID, itemName, folderItem.getMimeType(), true);*/
uriRequest = uriResolver.resolveAsStorageIdRequest(storageID, true);
/*
//VALIDATE CONNECTION //VALIDATE CONNECTION
if(!HttpRequestUtil.urlExists(uriRequest+"&validation=true")) if(!HttpRequestUtil.urlExists(uriRequest+"&validation=true"))
throw new Exception("Sorry, The Public Link for selected file is unavailable"); throw new Exception("Sorry, The Public Link for selected file is unavailable");
*/
String shortURL = null; String shortURL = null;
if(shortenUrl) if(shortenUrl)

View File

@ -6,7 +6,6 @@ package org.gcube.portlets.user.workspace.server.resolver;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor; import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor; import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
@ -23,81 +22,94 @@ import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.impl.XQuery; import org.gcube.resources.discovery.client.queries.impl.XQuery;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * The Class UriResolverReaderParameter.
* @Jun 26, 2013
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 12, 2016
*/ */
public class UriResolverReaderParameter { public class UriResolverReaderParameterForResolverIndex {
protected static final String CONTENT_TYPE_PARAMETER = "contentType_parameter";
protected static final String FILE_NAME_PARAMETER = "fileName_parameter";
protected static final String SMP_ID_PARAMETER = "SMP_ID_parameter";
//Base Address //Base Address
// private String uri = "";
private String baseUri = ""; private String baseUri = "";
//Query URL parameter //Query URL parameter
private String storageIDParameter = ""; private String storageIDParameter = "";
private String fileNameParameter = ""; private String fileNameParameter = "";
private String contentTypeParameter = ""; private String contentTypeParameter = "";
private String query = ""; private String query = "";
private boolean isAvailable = false; private boolean isAvailable = false;
public static Logger logger = Logger.getLogger(UriResolverReaderParameter.class); public static Logger logger = Logger.getLogger(UriResolverReaderParameterForResolverIndex.class);
/** /**
* @throws Exception * The Enum RESOLVER_TYPE.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 12, 2016
*/ */
public UriResolverReaderParameter(String scope) throws Exception { public static enum RESOLVER_TYPE {SMP_URI, SMP_ID};
/**
* Instantiates a new uri resolver reader parameter for resolver index.
*
* @param scope the scope
* @param resolverType the resolver type
* @throws Exception the exception
*/
public UriResolverReaderParameterForResolverIndex(String scope, RESOLVER_TYPE resolverType) throws Exception {
logger.trace("UriResolverReaderParameter is istancing with scope: "+scope); logger.trace("UriResolverReaderParameter is istancing with scope: "+scope);
ScopeUtilFilter scopeUtil = new ScopeUtilFilter(scope,true); ScopeUtilFilter scopeUtil = new ScopeUtilFilter(scope,true);
ScopeProvider.instance.set(scopeUtil.getScopeRoot()); ScopeProvider.instance.set(scopeUtil.getScopeRoot());
XQuery query = queryFor(ServiceEndpoint.class); XQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq 'HTTP-URI-Resolver'").setResult("$resource/Profile/AccessPoint"); query.addCondition("$resource/Profile/Name/text() eq 'HTTP-URI-Resolver'").setResult("$resource/Profile/AccessPoint");
DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class); DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
List<AccessPoint> endpoints = client.submit(query); List<AccessPoint> endpoints = client.submit(query);
if (endpoints.size() == 0) if (endpoints.size() == 0)
throw new Exception("No Resolver available"); throw new Exception("No Resolver available");
//Base Address
//THE FIRST ACCESS POINT (endpoints.get(0)) IS SMP-URI, THE SECOND (endpoints.get(1)) IS SMP-ID //THE FIRST ACCESS POINT (endpoints.get(0)) IS SMP-URI, THE SECOND (endpoints.get(1)) IS SMP-ID
AccessPoint ap2 = endpoints.get(1); int useResolverIndex;
baseUri = ap2!=null?endpoints.get(1).address():"";
switch(resolverType){
case SMP_ID:
useResolverIndex = 1;
break;
case SMP_URI:
useResolverIndex = 0;
break;
default:
useResolverIndex = 1;
}
AccessPoint ap2 = endpoints.get(useResolverIndex);
baseUri = ap2!=null?endpoints.get(useResolverIndex).address():"";
if(ap2!=null){ if(ap2!=null){
storageIDParameter = ap2.propertyMap()!=null?ap2.propertyMap().get(SMP_ID_PARAMETER).value():"";
storageIDParameter = ap2.propertyMap()!=null?ap2.propertyMap().get("SMP_ID_parameter").value():""; fileNameParameter = ap2.propertyMap()!=null?ap2.propertyMap().get(FILE_NAME_PARAMETER).value():"";
fileNameParameter = ap2.propertyMap()!=null?ap2.propertyMap().get("fileName_parameter").value():""; contentTypeParameter = ap2.propertyMap()!=null?ap2.propertyMap().get(CONTENT_TYPE_PARAMETER).value():"";
contentTypeParameter = ap2.propertyMap()!=null?ap2.propertyMap().get("contentType_parameter").value():"";
} }
// uriRequest = uri+"?"+smpParameter;
isAvailable = true; isAvailable = true;
//Query URL parameter
// System.out.println(endpoints.get(0).propertyMap().get("parameter").value());
} }
/** /**
* Resolve - open stream with http get method * Resolve - open stream with http get method.
* @param smp *
* @return * @param smp the smp
* @throws IOException * @param fileName the file name
* @param contentType the content type
* @return the input stream
* @throws Exception the exception
*/ */
public InputStream resolveAsInputStream(String smp, String fileName, String contentType) throws Exception{ public InputStream resolveAsInputStream(String smp, String fileName, String contentType) throws Exception{
String query = resolveAsUriRequest(smp, fileName, contentType, true); String query = resolveAsUriRequest(smp, fileName, contentType, true);
URL url = new URL(query); URL url = new URL(query);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true); connection.setDoOutput(true);
@ -107,19 +119,19 @@ public class UriResolverReaderParameter {
connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("charset", "utf-8");
connection.connect(); connection.connect();
return connection.getInputStream(); return connection.getInputStream();
} }
/** /**
* * Resolve as uri request.
* @param storageID *
* @param fileName * @param storageID the storage id
* @param contentType * @param fileName the file name
* @param contentType the content type
* @param encodeParams - if true, translates a string into <code>application/x-www-form-urlencoded</code> * @param encodeParams - if true, translates a string into <code>application/x-www-form-urlencoded</code>
* format using a specific encoding scheme * format using a specific encoding scheme
* @return the http url to get file * @return the http url to get file
* @throws Exception * @throws Exception the exception
*/ */
public String resolveAsUriRequest(String storageID, String fileName, String contentType, boolean encodeParams) throws Exception{ public String resolveAsUriRequest(String storageID, String fileName, String contentType, boolean encodeParams) throws Exception{
@ -136,27 +148,53 @@ public class UriResolverReaderParameter {
query+="&"+contentTypeParameter+"="+contentType; query+="&"+contentTypeParameter+"="+contentType;
} }
else{ else{
Map<String, String> hashParameters = getHashParemeters(storageID, fileName, contentType); Map<String, String> hashParameters = getHashParameters(storageID, fileName, contentType);
query = UrlEncoderUtil.encodeQuery(hashParameters); query = UrlEncoderUtil.encodeQueryValues(hashParameters);
} }
String uriRequest = baseUri+"?"+query; String uriRequest = baseUri+"?"+query;
logger.trace("resolve url request: "+uriRequest); logger.trace("resolve url request: "+uriRequest);
return uriRequest; return uriRequest;
} }
/** /**
* * Resolve as storage id request.
* @param storageID *
* @param fileName * @param storageID the storage id
* @param contentType * @param encodeParams the encode params
* @return * @return the string
* @throws Exception * @throws Exception the exception
*/ */
public Map<String, String> getHashParemeters(String storageID, String fileName, String contentType) throws Exception{ public String resolveAsStorageIdRequest(String storageID, boolean encodeParams) throws Exception{
if(storageID==null || storageID.isEmpty())
throw new Exception("storage ID is null or empty");
if(!encodeParams)//ENCODE URI
query = storageID;
else
query = UrlEncoderUtil.encodeQueryValue(storageID);
if(baseUri.endsWith("/id"))
baseUri = baseUri.substring(0, baseUri.length()-3);
String uriRequest = baseUri+"/"+query;
logger.trace("resolve storageID request: "+uriRequest);
return uriRequest;
}
/**
* Gets the hash parameters.
*
* @param storageID the storage id
* @param fileName the file name
* @param contentType the content type
* @return the hash parameters
* @throws Exception the exception
*/
public Map<String, String> getHashParameters(String storageID, String fileName, String contentType) throws Exception{
Map<String, String> hashParameters = new HashMap<String, String>(); Map<String, String> hashParameters = new HashMap<String, String>();
@ -175,12 +213,64 @@ public class UriResolverReaderParameter {
} }
/**
* Checks if is available.
*
* @return true, if is available
*/
public boolean isAvailable() { public boolean isAvailable() {
return isAvailable; return isAvailable;
} }
/**
* Gets the base uri.
*
* @return the base uri
*/
public String getBaseUri() {
return baseUri;
}
/**
* Gets the storage id parameter.
*
* @return the storageIDParameter
*/
public String getStorageIDParameter() {
return storageIDParameter;
}
/**
* Gets the file name parameter.
*
* @return the file name parameter
*/
public String getFileNameParameter() {
return fileNameParameter;
}
/**
* Gets the content type parameter.
*
* @return the content type parameter
*/
public String getContentTypeParameter() {
return contentTypeParameter;
}
/**
* Gets the query.
*
* @return the query
*/
public String getQuery() {
return query;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -198,55 +288,20 @@ public class UriResolverReaderParameter {
return builder.toString(); return builder.toString();
} }
public String getBaseUri() { /*
return baseUri;
}
/**
* @return the storageIDParameter
*/
public String getStorageIDParameter() {
return storageIDParameter;
}
public String getFileNameParameter() {
return fileNameParameter;
}
public String getContentTypeParameter() {
return contentTypeParameter;
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String scope = "/gcube/devsec"; String scope = "/gcube/devsec";
System.out.println(new UriResolverReaderParameter(scope).toString()); System.out.println(new UriResolverReaderParameter(scope).toString());
// UriResolverReaderParameter uriResolver = new UriResolverReaderParameter(scope);
/* // String fileName = "Wikipedia_logo_silver.png";
UriResolverReaderParameter uriResolver = new UriResolverReaderParameter(scope); // String uriRequest = uriResolver.resolveAsUriRequest("smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV+gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y", fileName, "image/png", true);
// System.out.println("uriRequest "+uriRequest);
String fileName = "Wikipedia_logo_silver.png";
String uriRequest = uriResolver.resolveAsUriRequest("smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV+gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y", fileName, "image/png", true);
System.out.println("uriRequest "+uriRequest);
*/
//
// InputStream is = uriResolver.resolve("smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV+gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y", fileName, "image/png"); // InputStream is = uriResolver.resolve("smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV+gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y", fileName, "image/png");
// File file = new File(fileName); // File file = new File(fileName);
//
// FileOutputStream out = new FileOutputStream(file); // FileOutputStream out = new FileOutputStream(file);
//
//
// IOUtils.copy(is, out); // IOUtils.copy(is, out);
// is.close(); // is.close();
//
// out.close(); // out.close();
} }*/
public String getQuery() {
return query;
}
} }

View File

@ -56,7 +56,7 @@ public class HttpCallerUtil {
// Create an instance of HttpClient. // Create an instance of HttpClient.
HttpClient client = new HttpClient(); HttpClient client = new HttpClient();
String query = UrlEncoderUtil.encodeQuery(parameters); String query = UrlEncoderUtil.encodeQueryValues(parameters);
String fullUrl = urlService+"/"+urlMethod+"?"+query; String fullUrl = urlService+"/"+urlMethod+"?"+query;

View File

@ -5,52 +5,72 @@ package org.gcube.portlets.user.workspace.server.shortener;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * The Class UrlEncoderUtil.
* @Jun 4, 2013
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 13, 2016
*/ */
public class UrlEncoderUtil { public class UrlEncoderUtil {
public static String charset = "UTF-8"; public static String charset = "UTF-8";
public static Logger logger = Logger.getLogger(UrlEncoderUtil.class); public static Logger logger = Logger.getLogger(UrlEncoderUtil.class);
/** /**
* * Encode query.
* @param url *
* @param parameters * @param parameters the parameters
* @return * @return the string
*/ */
public static String encodeQuery(String... parameters){ public static String encodeQuery(String... parameters){
String query = ""; String query = "";
for (String string : parameters) { for (String string : parameters) {
try { try {
query+=URLEncoder.encode(string, charset)+"&"; query+=URLEncoder.encode(string, charset)+"&";
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
logger.error(e); logger.error(e);
return query; return query;
} }
} }
return removeLastChar(query); return removeLastChar(query);
} }
/** /**
* * Encode query value.
* @param url *
* @param parameters * @param value the value
* @return * @return the string
*/ */
public static String encodeQuery(Map<String, String> parameters){ public static String encodeQueryValue(String value){
if(value==null || value.isEmpty())
return value;
try {
return URLEncoder.encode(value, charset);
}
catch (UnsupportedEncodingException e) {
logger.error(e);
return null;
}
}
/**
* Encode query values.
*
* @param parameters the parameters
* @return the string
*/
public static String encodeQueryValues(Map<String, String> parameters){
String query = ""; String query = "";
@ -58,20 +78,22 @@ public class UrlEncoderUtil {
return query; return query;
for (String key : parameters.keySet()) { for (String key : parameters.keySet()) {
try { try {
query+=String.format(key+"=%s", URLEncoder.encode(parameters.get(key), charset))+"&"; query+=String.format(key+"=%s", URLEncoder.encode(parameters.get(key), charset))+"&";
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
logger.error(e); logger.error(e);
return query; return query;
} }
} }
return removeLastChar(query); return removeLastChar(query);
} }
/**
* Removes the last char.
*
* @param string the string
* @return the string
*/
public static String removeLastChar(String string){ public static String removeLastChar(String string){
if(string == null) if(string == null)
@ -83,20 +105,33 @@ public class UrlEncoderUtil {
return string; return string;
} }
/**
* Gets the charset.
*
* @return the charset
*/
public static String getCharset() {
return charset;
}
/**
* Sets the charset.
*
* @param charset the charset to set
*/
public static void setCharset(String charset) {
UrlEncoderUtil.charset = charset;
}
/*
public static void main(String[] args) { public static void main(String[] args) {
// System.out.println(UrlEncoderUtil.encodeQuery("request=GetStyles", "layers=test Name", "service=WMS", "version=1.1.1"));
// System.out.println(UrlEncoderUtil.encodeQuery("request=GetStyles", "layers=test Name", "service=WMS", "version=1.1.1"));
HashMap<String, String> parameters = new HashMap<String, String>(); HashMap<String, String> parameters = new HashMap<String, String>();
parameters.put("request", "GetStyles"); parameters.put("request", "GetStyles");
parameters.put("layers", "test Name"); parameters.put("layers", "test Name");
parameters.put("version", "1.1.1"); parameters.put("version", "1.1.1");
System.out.println(UrlEncoderUtil.encodeQuery(parameters)); System.out.println(UrlEncoderUtil.encodeQuery(parameters));
}*/
}
} }

View File

@ -21,7 +21,8 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.user.workspace.client.model.InfoContactModel; import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder; import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer; import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter; import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener; import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader; import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter; import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
@ -353,16 +354,16 @@ public class WsUtil {
* @param session * @param session
* @return * @return
*/ */
public static UriResolverReaderParameter getUriResolver(HttpSession httpSession) { public static UriResolverReaderParameterForResolverIndex getUriResolver(HttpSession httpSession) {
ASLSession session = getAslSession(httpSession); ASLSession session = getAslSession(httpSession);
UriResolverReaderParameter uriResolver = null; UriResolverReaderParameterForResolverIndex uriResolver = null;
try{ try{
uriResolver = (UriResolverReaderParameter) session.getAttribute(WsUtil.URI_RESOLVER_SERVICE); uriResolver = (UriResolverReaderParameterForResolverIndex) session.getAttribute(WsUtil.URI_RESOLVER_SERVICE);
if(uriResolver==null){ if(uriResolver==null){
uriResolver = new UriResolverReaderParameter(session.getScope().toString()); uriResolver = new UriResolverReaderParameterForResolverIndex(session.getScope().toString(),RESOLVER_TYPE.SMP_ID);
session.setAttribute(URI_RESOLVER_SERVICE, uriResolver); session.setAttribute(URI_RESOLVER_SERVICE, uriResolver);
} }

View File

@ -17,7 +17,8 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder; import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter; import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
import org.gcube.portlets.user.workspace.server.util.HttpRequestUtil; import org.gcube.portlets.user.workspace.server.util.HttpRequestUtil;
import org.gcube.portlets.user.workspace.server.util.StringUtil; import org.gcube.portlets.user.workspace.server.util.StringUtil;
@ -120,7 +121,7 @@ public class SinglePublicLinkTest {
if(storageID==null || storageID.isEmpty()) if(storageID==null || storageID.isEmpty())
throw new Exception("Sorry, public link on "+wsItem.getName() +" is not available"); throw new Exception("Sorry, public link on "+wsItem.getName() +" is not available");
UriResolverReaderParameter uriResolver = new UriResolverReaderParameter(DEFAULT_SCOPE); UriResolverReaderParameterForResolverIndex uriResolver = new UriResolverReaderParameterForResolverIndex(DEFAULT_SCOPE, RESOLVER_TYPE.SMP_ID);
String uriRequest = ""; String uriRequest = "";

View File

@ -24,7 +24,8 @@ import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder; import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter; import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener; import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.impl.XQuery; import org.gcube.resources.discovery.client.queries.impl.XQuery;
@ -186,7 +187,7 @@ public class UriResolverReaderRR {
System.out.println("smpUri "+smpUri); System.out.println("smpUri "+smpUri);
System.out.println("get uriResolver..."); System.out.println("get uriResolver...");
UriResolverReaderParameter uriResolver = new UriResolverReaderParameter(DEFAULT_SCOPE); UriResolverReaderParameterForResolverIndex uriResolver = new UriResolverReaderParameterForResolverIndex(DEFAULT_SCOPE, RESOLVER_TYPE.SMP_ID);
// String url = uriResolver.resolveAsUriRequest(smpUri, "testResponse!@#$$%^^&&.html", folderItem.getMimeType(), true); // String url = uriResolver.resolveAsUriRequest(smpUri, "testResponse!@#$$%^^&&.html", folderItem.getMimeType(), true);
String url = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), true); String url = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), true);