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 java.lang.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 java.lang.String PARAMETER_API_KEY
          API key property bag key.
static java.lang.String PARAMETER_URL
          This is the URL parameter to be used in API URLs.
 
Constructor Summary
GoogleURLShortener()
           
 
Method Summary
 java.lang.String expand(java.lang.String url)
          Expands the given URL.
 java.lang.String getApiKey()
          Returns the API key from the parameters.
protected  java.lang.String getApiURL()
          Returns the URL shortener API URL to be used.
protected  java.lang.String postData(java.lang.String url)
          Post data to Google's shortening service and returns the parsed shortened URL.
 java.lang.String shorten(java.lang.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 java.lang.String PARAMETER_API_KEY
API key property bag key.

Since:
6.1.0
See Also:
Constant Field Values

PARAMETER_URL

public static final java.lang.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 java.lang.String getApiURL()
Returns the URL shortener API URL to be used.

Returns:

shorten

public java.lang.String shorten(java.lang.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 java.lang.String postData(java.lang.String url)
                             throws java.lang.Exception
Post data to Google's shortening service and returns the parsed shortened URL.

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

getApiKey

public java.lang.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 java.lang.String expand(java.lang.String url)
                        throws PortalException
Expands the given URL.

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


Lumisportal  6.1.0.111014 - Copyright © 2001-2007, Lumis. All Rights Reserved.