fixed url shortener request
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@77452 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
18aeda5198
commit
e74a74eb4f
|
@ -50,7 +50,7 @@ import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
|||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||
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.shortner.UrlShortener;
|
||||
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
|
||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.server.shortner;
|
||||
package org.gcube.portlets.user.workspace.server.shortener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.server.shortner;
|
||||
package org.gcube.portlets.user.workspace.server.shortener;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.server.shortner;
|
||||
package org.gcube.portlets.user.workspace.server.shortener;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
|
@ -89,10 +89,22 @@ public final class UrlShortener {
|
|||
paramKeyValue = endpoints.get(0).propertyMap()!=null?endpoints.get(0).propertyMap().get(KEY).value():"";
|
||||
}
|
||||
|
||||
uriRequest = shortnerServerUrl+"?"+KEY+"="+paramKeyValue;
|
||||
String getParam = "";
|
||||
|
||||
//ACTIVE THIS AFTER RELEASE
|
||||
if(paramKeyValue!=null && !paramKeyValue.isEmpty()){
|
||||
// getParam = "?"+KEY +"="+paramKeyValue;
|
||||
getParam = "?"+KEY +"=AIzaSyDfMO0VY3o8GjRUqnTfqScjm_EsFEuBa3g";
|
||||
|
||||
}
|
||||
|
||||
uriRequest = shortnerServerUrl+getParam;
|
||||
|
||||
logger.trace("HTTP-URL-Shortener found, uriRequest: "+uriRequest);
|
||||
|
||||
//DEBUG
|
||||
System.out.println("HTTP-URL-Shortener found, uriRequest: "+uriRequest);
|
||||
|
||||
isAvailable = true;
|
||||
|
||||
}catch (Exception e) {
|
||||
|
@ -119,8 +131,10 @@ public final class UrlShortener {
|
|||
|
||||
try {
|
||||
|
||||
URL url = new URL(shortnerServerUrl);
|
||||
|
||||
logger.trace("shorten longUrl: "+longUrl);
|
||||
|
||||
URL url = new URL(uriRequest);
|
||||
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
|
@ -130,9 +144,12 @@ public final class UrlShortener {
|
|||
|
||||
jsonObj.put(LONG_URL, longUrl);
|
||||
|
||||
//ACTIVE THIS AFTER RELEASE
|
||||
if(paramKeyValue!=null && !paramKeyValue.isEmpty())
|
||||
jsonObj.put(KEY, paramKeyValue);
|
||||
// //ACTIVE THIS AFTER RELEASE
|
||||
// if(paramKeyValue!=null && !paramKeyValue.isEmpty()){
|
||||
// jsonObj.put(KEY, paramKeyValue);
|
||||
// }
|
||||
|
||||
logger.trace("request json : "+jsonObj.toJSONString());
|
||||
|
||||
OutputStreamWriter wr = new OutputStreamWriter(connection.getOutputStream());
|
||||
wr.write(jsonObj.toJSONString());
|
||||
|
@ -185,7 +202,7 @@ public final class UrlShortener {
|
|||
UrlShortener urlSh = new UrlShortener();
|
||||
System.out.println("UrlShortener: "+urlSh);
|
||||
|
||||
shorten = urlSh.shorten("https://dev.d4science.org/group/data-e-infrastructure-gateway/workspace?itemid=062c558c-c7ce-4de3-a4c7-e1411816cc12&operation=gotofolder");
|
||||
shorten = urlSh.shorten("https://dev.d4science.org/group/data-e-infrastructure-gateway/workspace?itemid=056648-c7ce-4de3-a4c7-e1411816cc12&operation=gotofolder");
|
||||
|
||||
System.out.println("Shorted: "+shorten);
|
||||
} catch (Exception e) {
|
|
@ -20,7 +20,7 @@ import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
|
|||
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
||||
import org.gcube.portlets.user.workspace.server.shortner.UrlShortener;
|
||||
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
|
||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue