You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/06/15 15:57:14 UTC

incubator-juneau git commit: JUNEAU-55

Repository: incubator-juneau
Updated Branches:
  refs/heads/master 0d10af30f -> feaa916d9


JUNEAU-55

This closes #3

Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/feaa916d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/feaa916d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/feaa916d

Branch: refs/heads/master
Commit: feaa916d9cc68dd4cc3a7411565c1f07b18646fb
Parents: 0d10af3
Author: JamesBognar <ja...@apache.org>
Authored: Thu Jun 15 11:57:11 2017 -0400
Committer: JamesBognar <ja...@apache.org>
Committed: Thu Jun 15 11:57:11 2017 -0400

----------------------------------------------------------------------
 .../juneau/remoteable/RemoteableMethodMeta.java |  4 +--
 .../apache/juneau/rest/client/RestClient.java   | 28 +++++++++++++++++++-
 2 files changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/feaa916d/juneau-core/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java b/juneau-core/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java
index 78340b7..8430ae8 100644
--- a/juneau-core/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java
+++ b/juneau-core/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java
@@ -74,8 +74,8 @@ public class RemoteableMethodMeta {
 			RemoteMethod rm = m.getAnnotation(RemoteMethod.class);
 
 			httpMethod = rm == null ? "POST" : rm.httpMethod();
-			if (! isOneOf(httpMethod, "GET", "POST"))
-				throw new RemoteableMetadataException(m, "Invalid value specified for @RemoteMethod.httpMethod() annotation.  Valid values are [GET,POST].");
+			if (! isOneOf(httpMethod, "DELETE", "GET", "POST", "PUT"))
+				throw new RemoteableMetadataException(m, "Invalid value specified for @RemoteMethod.httpMethod() annotation.  Valid values are [DELTE,GET,POST,PUT].");
 
 			String path = rm == null || rm.path().isEmpty() ? null : rm.path();
 			String methodPaths = r == null ? "NAME" : r.methodPaths();

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/feaa916d/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
----------------------------------------------------------------------
diff --git a/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java b/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 32fd4da..484d934 100644
--- a/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++ b/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -207,6 +207,21 @@ public class RestClient extends CoreObject {
 	}
 
 	/**
+	 * Same as {@link #doPut(Object, Object)} but don't specify the input yet.
+	 * <p>
+	 * You must call either {@link RestCall#input(Object)} or {@link RestCall#formData(String, Object)}
+	 * to set the contents on the result object.
+	 *
+	 * @param url The URL of the remote REST resource.  Can be any of the following:  {@link String}, {@link URI}, {@link URL}.
+	 * @return A {@link RestCall} object that can be further tailored before executing the request
+	 * 	and getting the response as a parsed object.
+	 * @throws RestCallException
+	 */
+	public RestCall doPut(Object url) throws RestCallException {
+		return doCall("PUT", url, true);
+	}
+
+	/**
 	 * Perform a <code>POST</code> request against the specified URL.
 	 *
 	 * @param url The URL of the remote REST resource.  Can be any of the following:  {@link String}, {@link URI}, {@link URL}.
@@ -547,7 +562,18 @@ public class RestClient extends CoreObject {
 						try {
 							String url = rmm.getUrl();
 							String httpMethod = rmm.getHttpMethod();
-							RestCall rc = (httpMethod.equals("POST") ? doPost(url) : doGet(url));
+							RestCall rc;
+							// this could be a switch at language level 7
+							if (httpMethod.equals("DELETE")) {
+								rc = doDelete(url);
+							} else if (httpMethod.equals("POST")) {
+								rc = doPost(url);
+							} else if (httpMethod.equals("GET")) {
+								rc = doGet(url);
+							} else if (httpMethod.equals("PUT")) {
+								rc = doPut(url);
+							} else throw new RuntimeException("Unsupported method.");
+
 							rc.serializer(serializer).parser(parser);
 
 							for (RemoteMethodArg a : rmm.getPathArgs())