lumis.portal.urlshortener
Class GoogleURLShortener

Package class diagram package GoogleURLShortener
java.lang.Object
  extended by lumis.portal.urlshortener.GoogleURLShortener
All Implemented Interfaces:
IURLShortener

public class GoogleURLShortener
extends Object

IURLShortener that uses Google URL shortening service (Goo.gl). Besides the API URL, the Google service requires an API key.

Since:
6.1.0

Field Summary
static String PARAMETER_API_KEY
          API key property bag key.
static String PARAMETER_URL
          This is the URL parameter to be used in API URLs.
 
Constructor Summary
GoogleURLShortener()
           
 
Method Summary
 String expand(String url)
          Expands the given URL.
 String getApiKey()
          Returns the API key from the parameters.
protected  String getApiURL()
          Returns the URL shortener API URL to be used.
protected  String postData(String url)
          Post data to Google's shortening service and returns the parsed shortened URL.
 String shorten(String url)
          Shortens a given URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETER_API_KEY

public static final String PARAMETER_API_KEY
API key property bag key.

Since:
6.1.0
See Also:
Constant Field Values

PARAMETER_URL

public static final String PARAMETER_URL
This is the URL parameter to be used in API URLs. This parameter will be replaced by the URL to be shortened.

Since:
6.1.0
See Also:
Constant Field Values
Constructor Detail

GoogleURLShortener

public GoogleURLShortener()
Method Detail

getApiURL

protected String getApiURL()
Returns the URL shortener API URL to be used.

Returns:

shorten

public String shorten(String url)
               throws PortalException
Description copied from interface: IURLShortener
Shortens a given URL.

Specified by:
shorten in interface IURLShortener
Parameters:
url - the URL to be shortened.
Returns:
the shortened URL.
Throws:
PortalException - if some error occur in shortening process.

postData

protected String postData(String url)
                   throws Exception
Post data to Google's shortening service and returns the parsed shortened URL.

Parameters:
url - the long URL.
Returns:
the shortened URL.
Throws:
Exception
Since:
6.1.0

getApiKey

public String getApiKey()
                 throws PortalException
Returns the API key from the parameters.

Returns:
the API key from the parameters.
Throws:
PortalException - if the API key is not set in parameters.
Since:
6.1.0

expand

public String expand(String url)
              throws PortalException
Expands the given URL.

Parameters:
url - the URL to be expanded.
Returns:
the expanded URL.
Throws:
PortalException


Lumisportal  6.2.0.120405 - Copyright © 2006–2012 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.