|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kallasoft.smugmug.api.json.AbstractMethod
public abstract class AbstractMethod
Class used to represent the base implementation of a Method in the
kallasoft SmugMug Java API.
All custom method implementations should extend this class and provide the additional detail required to support the new method.
The executeImpl(String, String[]) implementation represents the
actual implementation of calling the SmugMug JSON API and getting a
JSON-formatted reply that it returns to the caller.
executeImpl(String, String[]) is the nuts and bolts of the
implementation to Method.execute(String, String[]) but it cannot
return a specific AbstractResponse instance custom for each
Method implementation, so instead it returns the JSON-formatted reply
for the caller to parse into an appropriate AbstractResponse instance
and return.
The implementation of executeImpl(String, String[]) is fully
optimized according to the HttpClient
Performance Guide to provide the best performance, memory management,
error reporting and resource-cleanup. Because of this, implementors are
encouraged to extend this class when implementing their own methods to take
advantage of it.
| Constructor Summary | |
|---|---|
AbstractMethod(String methodName,
String[] arguments)
Construct a method that represents the given method name which takes the given arguments. |
|
| Method Summary | |
|---|---|
protected String |
executeImpl(String url,
String[] argumentValues)
The core implementation of the kallasoft SmugMug Java API that takes the given URL and argument values, and communicates with the SmugMug JSON API then returns the JSON-formatted reply to the caller. |
String[] |
getArguments()
Used to get a list of the argument names for this method. |
String |
getMethodName()
Used to get the name of the SmugMug JSON API method that this Method represents and will call when executed. |
protected void |
setupPostParameters(org.apache.commons.httpclient.methods.PostMethod postMethod,
String[] argumentValues)
Used to take the given PostMethod and setup all the name/value
pairs for it before it is executed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.kallasoft.smugmug.api.json.Method |
|---|
execute |
| Constructor Detail |
|---|
public AbstractMethod(String methodName,
String[] arguments)
throws IllegalArgumentException
methodName - The name of the SmugMug JSON API method that this
Method represents.arguments - The names of the arguments that this method accepts.
IllegalArgumentException - if methodName is null or empty.| Method Detail |
|---|
public String getMethodName()
MethodMethod represents and will call when executed. For
example, smugmug.login.withPassword.
getMethodName in interface Methodpublic String[] getArguments()
MethodAPIKey, SessionID and AlbumID.
getArguments in interface Method
protected void setupPostParameters(org.apache.commons.httpclient.methods.PostMethod postMethod,
String[] argumentValues)
throws IllegalArgumentException
PostMethod and setup all the name/value
pairs for it before it is executed.
Any null values for arguments or
argumentValues cause that pair of name/value to be
ignored. For example, consider the pairs:
null)null, scott)null.
If more arguments exist than values, all the arguments without matching values will be ignored.
postMethod - The PostMethod that will be setup with all the
appropriate name/value pairs in order to call the SmugMug
server.argumentValues - The values to pass to the API call for each of the arguments
it takes.
IllegalArgumentException - if postMethod is null.
IllegalArgumentException - if methodName is null or empty.
IllegalArgumentException - if either arguments or argumentValues is null.
IllegalArgumentException - if arguments.length < argumentValues.length
protected String executeImpl(String url,
String[] argumentValues)
throws IllegalArgumentException,
NetworkException
Custom Method implementors are encouraged to use this method
internally, parsing the JSON reply into the appropriate
AbstractResponse then returning that to their caller.
The implementation of this method is fully optimized according to the HttpClient Performance Guide to provide the best performance, memory management, error reporting and resource-cleanup. Because of this, implementors are encouraged to extend this class when implementing their own methods to take advantage of it.
url - The URL of the SmugMug API to call.argumentValues - The values to pass to the API call for each of the arguments
it takes.
IllegalArgumentException - if url is null or empty.
NetworkException - if anything other than a HTTP status code of 200 is returned
from the server. This is not the same as a network exception
and normally represents a failure on the SmugMug server side.
NetworkException - if any network-based error occurs while trying to communicate
with the SmugMug server. This can wrap many different kinds
of more specific network-based exceptions. The handler can
call getCause() to retrieve a more specific
reason for the exception if necessary.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||