com.commsen.jwebthumb
Class WebThumbService

java.lang.Object
  extended by com.commsen.jwebthumb.WebThumbService

public class WebThumbService
extends java.lang.Object

This class provides convenient methods for webthumb's "request", "fetch" and "credits" API calls. It does not support "status" call. Please use "notifications" instead by extending WebThumbNotificationServlet and implementing WebThumbNotificationServlet.processThumb(String, String) method. For more details about webthumb's API please visit http://webthumb.bluga.net/apidoc

Author:
Milen Dyankov
See Also:
http://webthumb.bluga.net/apidoc

Constructor Summary
WebThumbService(java.lang.String apiKey)
           
 
Method Summary
 byte[] fetch(WebThumbFetchRequest webThumbFetchRequest)
          Fetches single file form webthumb site.
 void fetch(WebThumbFetchRequest webThumbFetchRequest, java.io.OutputStream outputStream)
          Fetches single file form webthumb site and writes its content to given output stream.
 WebThumbCredits getCredits()
          Lets you see how many credits you've used and how many subscription/reserve credits you have left.
 java.util.List<WebThumbStatus> getStatus(WebThumbStatusRequest webThumbStatusRequest)
          Checks the status of given job or list of jobs.
 java.util.List<WebThumbJob> sendRequest(java.util.List<WebThumbRequest> webThumbRequests)
          Sends thumbnail requests to webthumb site.
 WebThumbJob sendRequest(WebThumbRequest webThumbRequest)
          Sends single thumbnail request to webthumb site.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebThumbService

public WebThumbService(java.lang.String apiKey)
Method Detail

sendRequest

public WebThumbJob sendRequest(WebThumbRequest webThumbRequest)
                        throws WebThumbException
Sends single thumbnail request to webthumb site. For more information see webthumb's request API: http://webthumb.bluga.net/apidoc#request

Parameters:
webThumbRequest - object containing the request parameters
Returns:
job
Throws:
WebThumbException - if the request fails for whatever reason

sendRequest

public java.util.List<WebThumbJob> sendRequest(java.util.List<WebThumbRequest> webThumbRequests)
                                        throws WebThumbException
Sends thumbnail requests to webthumb site. For more information see webthumb's request API: http://webthumb.bluga.net/apidoc#request

Parameters:
webThumbRequests - list of objects containing the request parameters
Returns:
list of jobs
Throws:
WebThumbException - if the request fails for whatever reason

fetch

public byte[] fetch(WebThumbFetchRequest webThumbFetchRequest)
             throws WebThumbException
Fetches single file form webthumb site. Depending on what image format was requested (jpg|png|png8) and what file size is set in WebThumbFetchRequest returned byte array will be the content of the jpg, png, png8 or zip file.

Parameters:
webThumbFetchRequest - fetch request containing the job and size to be fetched
Returns:
the content of the jpg, png, png8 or zip file.
Throws:
WebThumbException - if the file can not be fetched for whatever reason

fetch

public void fetch(WebThumbFetchRequest webThumbFetchRequest,
                  java.io.OutputStream outputStream)
           throws WebThumbException
Fetches single file form webthumb site and writes its content to given output stream. Depending on what image format was requested (jpg|png|png8) and what file size is set in WebThumbFetchRequest it will be the content of the jpg, png, png8 or zip file.

Parameters:
webThumbFetchRequest - fetch request containing the job and size to be fetched
outputStream - output stream to write the result to
Throws:
WebThumbException - if the file can not be fetched for whatever reason
Since:
0.3

getStatus

public java.util.List<WebThumbStatus> getStatus(WebThumbStatusRequest webThumbStatusRequest)
                                         throws WebThumbException
Checks the status of given job or list of jobs. Make sure not to make more then 1 status request per second. More requests then that may get you temporarily blocked at the firewall. Best Practice is to make a status request at most every 10 seconds. If your need to make a lot of requests, please look into using notifications instead of polling for status. See WebThumbRequest.setNotify(String) and WebThumbNotificationServlet for more details!

Parameters:
webThumbStatusRequest - fetch request containing the job and size to be fetched
Returns:
list of job statuses
Throws:
WebThumbException - if the file can not be fetched for whatever reason
Since:
0.3

getCredits

public WebThumbCredits getCredits()
                           throws WebThumbException
Lets you see how many credits you've used and how many subscription/reserve credits you have left.

Returns:
Throws:
WebThumbException


Copyright © 2010 COMMSEN International. All Rights Reserved.