Author: tchemit Date: 2009-11-12 20:10:51 +0100 (Thu, 12 Nov 2009) New Revision: 633 Modified: trunk/ trunk/src/main/java/org/nuiton/io/rest/DefaultRestClientConfiguration.java trunk/src/main/java/org/nuiton/io/rest/RestClient.java trunk/src/main/java/org/nuiton/io/rest/RestClientConfiguration.java trunk/src/main/java/org/nuiton/io/rest/RestDataNotFoundException.java trunk/src/main/java/org/nuiton/io/rest/RestException.java trunk/src/main/java/org/nuiton/io/rest/RestRequest.java trunk/src/main/java/org/nuiton/io/rest/RestRequestBuilder.java Log: - reformat code - add some javadoc Property changes on: trunk ___________________________________________________________________ Modified: svn:ignore - target *.iml + target *.iml *.ipr *.iws Modified: trunk/src/main/java/org/nuiton/io/rest/DefaultRestClientConfiguration.java =================================================================== --- trunk/src/main/java/org/nuiton/io/rest/DefaultRestClientConfiguration.java 2009-11-02 02:04:19 UTC (rev 632) +++ trunk/src/main/java/org/nuiton/io/rest/DefaultRestClientConfiguration.java 2009-11-12 19:10:51 UTC (rev 633) @@ -21,12 +21,13 @@ package org.nuiton.io.rest; import java.net.URL; + import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; /** * Default implementation of a {@link RestClientConfiguration}. - * + * * @author chemit * @since 1.0.3 */ Modified: trunk/src/main/java/org/nuiton/io/rest/RestClient.java =================================================================== --- trunk/src/main/java/org/nuiton/io/rest/RestClient.java 2009-11-02 02:04:19 UTC (rev 632) +++ trunk/src/main/java/org/nuiton/io/rest/RestClient.java 2009-11-12 19:10:51 UTC (rev 633) @@ -24,12 +24,13 @@ import java.io.InputStream; import java.util.Map; import java.util.TreeMap; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Abtract REST client. - * + * * @author chemit * @since 1.0.3 */ @@ -51,18 +52,17 @@ /** * Add the default available requests for this client. - * + * <p/> * <b>Note:</b> This method is invoked in the constructor of the client. - * */ protected abstract void addDefaultRequests(); /** * Open the client. - * + * <p/> * <b>Note:</b> At the end of this method, if every thing is ok, then * the method {@link #isOpen()} must returns {@code true}. - * + * * @param session the rest session * @throws IOException if any pb */ @@ -70,7 +70,7 @@ /** * Close the client. - * + * <p/> * <b>Note:</b> At the end of this method, if every thing is ok, then * the method {@link #isOpen()} must returns {@code false}. * @@ -91,7 +91,7 @@ /** * Add a request into the client. - * + * * @param builder the new request to add */ public void addRequestBuilder(RestRequestBuilder builder) { @@ -105,7 +105,7 @@ /** * Obtain a request given his id and the args given. * - * @param id id of the request + * @param id id of the request * @param args args passed to build the request * @return the new request */ @@ -161,10 +161,10 @@ /** * Open the client. - * + * <p/> * <b>Note:</b> this method will instanciate the {@link #session} and invoke * the method {@link #open(org.nuiton.io.rest.RestSession)}. - * + * * @throws RestException */ public void open() throws RestException { @@ -198,7 +198,7 @@ /** * Close the client. - * + * <p/> * <b>Note:</b> this method will erase the {@link #session} and invoke * the method {@link #close(org.nuiton.io.rest.RestSession)}. * @@ -220,16 +220,15 @@ /** * Is the client opened ? - * + * * @return {@code true} if the internal {@link #session} is opened, - * {@code false} otherwise. + * {@code false} otherwise. */ public boolean isOpen() { return session != null; } /** - * * @return the internal rest {@link #session} */ public RestSession getSession() { @@ -237,7 +236,6 @@ } /** - * * @return the internal {@link #configuration} */ public RestClientConfiguration getConfiguration() { @@ -246,9 +244,9 @@ /** * Use a new configuration. - * + * <p/> * TODO : this method should check client is not opened! - * + * * @param configuration the new configuration */ public void setConfiguration(RestClientConfiguration configuration) { Modified: trunk/src/main/java/org/nuiton/io/rest/RestClientConfiguration.java =================================================================== --- trunk/src/main/java/org/nuiton/io/rest/RestClientConfiguration.java 2009-11-02 02:04:19 UTC (rev 632) +++ trunk/src/main/java/org/nuiton/io/rest/RestClientConfiguration.java 2009-11-12 19:10:51 UTC (rev 633) @@ -24,29 +24,58 @@ /** * Contract of a {@link RestClient}. - * + * * @author chemit * @since 1.0.3 */ public interface RestClientConfiguration { - + /** + * @return base url of server + */ URL getRestUrl(); + /** + * @return the encoding used to encode request to send + */ String getEncoding(); + /** + * @return the username to connect to server + */ String getRestUsername(); + /** + * @return the password to connect to server + */ String getRestPassword(); + /** + * @return {@code true} to make verbose client (show request and parameters) + */ boolean isVerbose(); + /** + * @param restUrl the url of server to set + */ void setRestUrl(URL restUrl); + /** + * @param restPassword the password to connect to server to set + */ void setRestPassword(String restPassword); + /** + * @param restUsername the username to connect to server to set + */ void setRestUsername(String restUsername); + /** + * @param encoding the encodng used to encode request to set + */ void setEncoding(String encoding); + /** + * @param verbose the flag verbose to set + */ void setVerbose(boolean verbose); } Modified: trunk/src/main/java/org/nuiton/io/rest/RestDataNotFoundException.java =================================================================== --- trunk/src/main/java/org/nuiton/io/rest/RestDataNotFoundException.java 2009-11-02 02:04:19 UTC (rev 632) +++ trunk/src/main/java/org/nuiton/io/rest/RestDataNotFoundException.java 2009-11-12 19:10:51 UTC (rev 633) @@ -23,7 +23,7 @@ /** * Exception to be raised if a data does not exist ina 'askData' request, says * when the rest server returns a {@code 4XX} status code. - * + * * @author chemit * @since 1.0.3 */ Modified: trunk/src/main/java/org/nuiton/io/rest/RestException.java =================================================================== --- trunk/src/main/java/org/nuiton/io/rest/RestException.java 2009-11-02 02:04:19 UTC (rev 632) +++ trunk/src/main/java/org/nuiton/io/rest/RestException.java 2009-11-12 19:10:51 UTC (rev 633) @@ -22,7 +22,7 @@ /** * Base exception for any excpeiton in rest service. - * + * * @author chemit * @since 1.0.3 */ Modified: trunk/src/main/java/org/nuiton/io/rest/RestRequest.java =================================================================== --- trunk/src/main/java/org/nuiton/io/rest/RestRequest.java 2009-11-02 02:04:19 UTC (rev 632) +++ trunk/src/main/java/org/nuiton/io/rest/RestRequest.java 2009-11-12 19:10:51 UTC (rev 633) @@ -25,15 +25,23 @@ /** * The contract of a rest request. - * + * * @author chemit * @since 1.0.3 */ public interface RestRequest { - + /** + * @return the splitted path to add to url + */ String[] getPath(); + /** + * @return an array of pair (parameter name - parameter value) to pass to request + */ String[] getParameters(); + /** + * @return the map of attachment to pass to request + */ Map<String, File> getAttachments(); } Modified: trunk/src/main/java/org/nuiton/io/rest/RestRequestBuilder.java =================================================================== --- trunk/src/main/java/org/nuiton/io/rest/RestRequestBuilder.java 2009-11-02 02:04:19 UTC (rev 632) +++ trunk/src/main/java/org/nuiton/io/rest/RestRequestBuilder.java 2009-11-12 19:10:51 UTC (rev 633) @@ -22,13 +22,21 @@ /** * The contract of a request builder. - * + * * @author chemit * @since 1.0.3 */ public interface RestRequestBuilder { - + /** + * @return the unique name of the request builder + */ String getName(); + /** + * Create the request given the {@code args}. + * + * @param args args to create the request + * @return the created request + */ RestRequest create(Object... args); }
participants (1)
-
tchemit@users.nuiton.org