com.kallasoft.smugmug.api.json.v1_2_1.images
Class UploadHTTPPut

java.lang.Object
  extended by com.kallasoft.smugmug.api.json.AbstractMethod
      extended by com.kallasoft.smugmug.api.json.v1_2_0.images.UploadHTTPPut
          extended by com.kallasoft.smugmug.api.json.v1_2_1.images.UploadHTTPPut
All Implemented Interfaces:
Method

public class UploadHTTPPut
extends UploadHTTPPut

This class is a convenience class extending the base UploadHTTPPut implementation.

Version:
1.2.1
Author:
Riyad Kalla
See Also:
UploadHTTPPut

Nested Class Summary
 class UploadHTTPPut.UploadHTTPPutResponse
          This class is a convenience class extending the base UploadHTTPPut.UploadHTTPPutResponse implementation.
 
Field Summary
 
Fields inherited from class com.kallasoft.smugmug.api.json.v1_2_0.images.UploadHTTPPut
HTTP_HEADERS
 
Constructor Summary
UploadHTTPPut()
          Construct a new method instance that can be executed.
UploadHTTPPut(String methodName, String[] arguments)
          Construct a new method instance that can be executed with the given arguments.
 
Method Summary
 AbstractResponse execute(String url, String[] argumentValues)
          Unimplemented method, throws UnsupportedOperationException.
 UploadHTTPPut.UploadHTTPPutResponse execute(String url, String[] httpHeaderValues, byte[] imageData)
          Used to perform a Binary-only upload using HTTP PUT.
 UploadHTTPPut.UploadHTTPPutResponse execute(String url, String sessionID, Integer albumID, Integer imageID, String fileName, InputStream inputStream)
          Convenience method that delegates to UploadHTTPPut.execute(String, String, Integer, Integer, String, InputStream, String, String, Double, Double, Double).
 UploadHTTPPut.UploadHTTPPutResponse execute(String url, String sessionID, Integer albumID, Integer imageID, String fileName, InputStream inputStream, String caption, String keywords, Double latitude, Double longitude, Double altitude)
          Convenience method used to take a InputStream and load the bytes of the image file before calling UploadHTTPPut.execute(String, String[], byte[]).
 
Methods inherited from class com.kallasoft.smugmug.api.json.v1_2_0.images.UploadHTTPPut
executeUploadImpl, prepareUploadArgumentValues, setupHTTPHeaders
 
Methods inherited from class com.kallasoft.smugmug.api.json.AbstractMethod
executeImpl, getArguments, getMethodName, setupPostParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UploadHTTPPut

public UploadHTTPPut()
Construct a new method instance that can be executed.


UploadHTTPPut

public UploadHTTPPut(String methodName,
                     String[] arguments)
Construct a new method instance that can be executed with the given arguments.

Parameters:
methodName - The name of the SmugMug JSON API method that this Method represents.
arguments - The names of the arguments that this method accepts.
Method Detail

execute

public AbstractResponse execute(String url,
                                String[] argumentValues)
                         throws UnsupportedOperationException
Description copied from class: UploadHTTPPut
Unimplemented method, throws UnsupportedOperationException.

This method is implemented to throw an exception because the underlying implementation from AbstractMethod is implemented to do textual communication only, but this method implements it's own Binary-Only upload method using HTTP PUT.

Use any of the other execute methods to perform a binary upload to SmugMug.

Specified by:
execute in interface Method
Overrides:
execute in class UploadHTTPPut
Parameters:
url - The URL of the SmugMug server to communicate with.
argumentValues - The argument values to pass to this method.
Returns:
nothing. This method simply throws an exception.
Throws:
UnsupportedOperationException - if it is called. Please use one of the other execute methods to perform an upload.
See Also:
UploadHTTPPut.execute(String, String[], byte[]), UploadHTTPPut.execute(String, String, Integer, Integer, String, InputStream), UploadHTTPPut.execute(String, String, Integer, Integer, String, InputStream, String, String, Double, Double, Double)

execute

public UploadHTTPPut.UploadHTTPPutResponse execute(String url,
                                                   String[] httpHeaderValues,
                                                   byte[] imageData)
                                            throws IllegalArgumentException,
                                                   NetworkException,
                                                   RuntimeException
Description copied from class: UploadHTTPPut
Used to perform a Binary-only upload using HTTP PUT.

Only one argument of either "X-Smug-AlbumID" (httpHeaderValues[5]) or "X-Smug-ImageID" (httpHeaderValues[6]) can be specified. If "X-Smug-AlbumID" is specified this operation will be a new-image-upload operation but if "X-Smug-ImageID" is specified the operation will be an image-replacement operation.

NOTE: This method forcibly sets the X-Smug-ResponseType header value to "JSON" and the X-Smug-Version header value to "1.2.0". Sub-classes are encouraged to set their own values, but this class of the API only supports these values.

Overrides:
execute in class UploadHTTPPut
Parameters:
url - The URL of the SmugMug server to communicate with. This usually must be equal to the the SmugMug Upload URL, otherwise the image will not be processed.
httpHeaderValues - The HTTP header values that will be sent along with this upload. These values represent all the upload arguments to be associated with the uploaded image, see UploadHTTPPut.HTTP_HEADERS.
imageData - A byte array containing the actual image data that will be uploaded.
Returns:
the response that includes an ID for the image after it's upload completes.
Throws:
IllegalArgumentException - if url is null or empty.
NetworkException - if anything other than a HTTP status code of 200 (OK) is returned from the server. This is not the same as a network exception and normally represents a failure on the SmugMug server side.
RuntimeException - if the given fileName (httpHeaderValues[7]), represented by the X-Smug-FileName header value, cannot be property URL encoded before being sent to SmugMug in the upload operation.
See Also:
UploadHTTPPut.HTTP_HEADERS

execute

public UploadHTTPPut.UploadHTTPPutResponse execute(String url,
                                                   String sessionID,
                                                   Integer albumID,
                                                   Integer imageID,
                                                   String fileName,
                                                   InputStream inputStream)
Description copied from class: UploadHTTPPut
Convenience method that delegates to UploadHTTPPut.execute(String, String, Integer, Integer, String, InputStream, String, String, Double, Double, Double).

Only one argument of either "X-Smug-AlbumID" (httpHeaderValues[5]) or "X-Smug-ImageID" (httpHeaderValues[6]) can be specified. If "X-Smug-AlbumID" is specified this operation will be a new-image-upload operation but if "X-Smug-ImageID" is specified the operation will be an image-replacement operation.

NOTE: This method forcibly sets the X-Smug-ResponseType header value to "JSON" and the X-Smug-Version header value to "1.2.0". Sub-classes are encouraged to set their own values, but this class of the API only supports these values.

Overrides:
execute in class UploadHTTPPut
Parameters:
url - The URL of the SmugMug server to communicate with. This usually must be equal to the the SmugMug Upload URL, otherwise the image will not be processed.
sessionID - The logged in SessionID that represents the user's session.
albumID - The ID of the album to upload the image into. Only albumID or imageID can be specified, but not both.
imageID - The ID of the image to replace. Only albumID or imageID can be specified, but not both.
fileName - The name of the file whose stream will be read for data and uploaded.
inputStream - The InputStream to load the image data from and upload to SmugMug.
Returns:
the response that includes an ID for the image after it's upload completes.
See Also:
UploadHTTPPut.execute(String, String[], byte[]), UploadHTTPPut.HTTP_HEADERS

execute

public UploadHTTPPut.UploadHTTPPutResponse execute(String url,
                                                   String sessionID,
                                                   Integer albumID,
                                                   Integer imageID,
                                                   String fileName,
                                                   InputStream inputStream,
                                                   String caption,
                                                   String keywords,
                                                   Double latitude,
                                                   Double longitude,
                                                   Double altitude)
                                            throws IllegalArgumentException,
                                                   RuntimeException
Description copied from class: UploadHTTPPut
Convenience method used to take a InputStream and load the bytes of the image file before calling UploadHTTPPut.execute(String, String[], byte[]).

Only one argument of either "X-Smug-AlbumID" (httpHeaderValues[5]) or "X-Smug-ImageID" (httpHeaderValues[6]) can be specified. If "X-Smug-AlbumID" is specified this operation will be a new-image-upload operation but if "X-Smug-ImageID" is specified the operation will be an image-replacement operation.

This method will automatically set the "Content-Length" and "Content-MD5" headers after loading the image and computing the values on the fly.

NOTE: This method forcibly sets the X-Smug-ResponseType header value to "JSON" and the X-Smug-Version header value to "1.2.0". Sub-classes are encouraged to set their own values, but this class of the API only supports these values.

Overrides:
execute in class UploadHTTPPut
Parameters:
url - The URL of the SmugMug server to communicate with. This usually must be equal to the the SmugMug Upload URL, otherwise the image will not be processed.
sessionID - The logged in SessionID that represents the user's session.
albumID - The ID of the album to upload the image into. Only albumID or imageID can be specified, but not both.
imageID - The ID of the image to replace. Only albumID or imageID can be specified, but not both.
fileName - The name of the file whose stream will be read for data and uploaded.
inputStream - The InputStream to load and upload to SmugMug.
caption - A caption for the image.
keywords - The keywords assigned to the image.
latitude - The latitude used to geocode the image.
longitude - The longitude used to geocode the image.
altitude - The altitude (in meters) used to geocode the image.
Returns:
the response that includes an ID for the image after it's upload completes.
Throws:
IllegalArgumentException - if inputStream is null
RuntimeException - if the bytes of the image could not be loaded.
See Also:
UploadHTTPPut.execute(String, String[], byte[]), UploadHTTPPut.HTTP_HEADERS