From 822d1bc75e70538f01638955bf766316e416499c Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Fri, 12 Nov 2010 17:12:46 +0000 Subject: [PATCH] moved contents of wsdef to greaze-definition. --- wsclient/pom.xml | 6 +- .../gson/rest/client/ResourceDepotClient.java | 18 +- .../gson/rest/client/RestClientStub.java | 12 +- .../gson/rest/client/RestRequestSender.java | 14 +- .../rest/client/RestResponseReceiver.java | 16 +- .../query/client/ResourceQueryClient.java | 24 +-- .../gson/webservice/client/QueueConsumer.java | 6 +- .../gson/webservice/client/QueueEntry.java | 4 +- .../gson/webservice/client/RequestSender.java | 10 +- .../webservice/client/ResponseCallback.java | 8 +- .../webservice/client/ResponseReceiver.java | 14 +- .../webservice/client/WebServiceClient.java | 12 +- .../client/WebServiceClientAsync.java | 6 +- .../google/gson/rest/definition/HasId.java | 29 --- .../com/google/gson/rest/definition/ID.java | 7 - .../gson/rest/definition/IDFactory.java | 43 ---- .../google/gson/rest/definition/MetaData.java | 124 ----------- .../gson/rest/definition/ResourceDepot.java | 27 --- .../gson/rest/definition/ResourceMap.java | 55 ----- .../google/gson/rest/definition/RestCall.java | 47 ---- .../gson/rest/definition/RestCallSpec.java | 138 ------------ .../gson/rest/definition/RestRequest.java | 89 -------- .../gson/rest/definition/RestRequestSpec.java | 48 ----- .../gson/rest/definition/RestResource.java | 26 --- .../gson/rest/definition/RestResponse.java | 93 -------- .../rest/definition/RestResponseSpec.java | 48 ----- .../gson/rest/definition/ValueBasedId.java | 203 ------------------ .../google/gson/rest/query/ResourceQuery.java | 33 --- .../gson/rest/query/TypedKeysQuery.java | 37 ---- .../gson/webservice/definition/CallPath.java | 123 ----------- .../webservice/definition/CallPathMap.java | 77 ------- .../webservice/definition/ContentBody.java | 46 ---- .../definition/ContentBodySpec.java | 77 ------- .../gson/webservice/definition/HeaderMap.java | 63 ------ .../webservice/definition/HeaderMapSpec.java | 83 ------- .../webservice/definition/HttpMethod.java | 45 ---- .../gson/webservice/definition/ParamMap.java | 98 --------- .../webservice/definition/ParamMapSpec.java | 41 ---- .../gson/webservice/definition/TypeUtils.java | 92 -------- .../gson/webservice/definition/TypedKey.java | 72 ------- .../gson/webservice/definition/Util.java | 75 ------- .../definition/WebServiceSystemException.java | 35 --- .../definition/internal/utils/Pair.java | 64 ------ .../internal/utils/Preconditions.java | 43 ---- .../definition/procedural/RequestBody.java | 72 ------- .../procedural/RequestBodyGsonConverter.java | 74 ------- .../procedural/RequestBodySpec.java | 48 ----- .../definition/procedural/RequestSpec.java | 54 ----- .../definition/procedural/ResponseBody.java | 68 ------ .../procedural/ResponseBodyGsonConverter.java | 74 ------- .../procedural/ResponseBodySpec.java | 47 ---- .../definition/procedural/ResponseSpec.java | 53 ----- .../definition/procedural/WebServiceCall.java | 49 ----- .../procedural/WebServiceCallSpec.java | 145 ------------- .../procedural/WebServiceRequest.java | 79 ------- .../procedural/WebServiceResponse.java | 112 ---------- .../definition/procedural/WebServiceSpec.java | 28 --- .../google/gson/rest/definition/IdTest.java | 55 ----- .../rest/definition/IdTypeAdapterTest.java | 133 ------------ .../webservice/definition/CallPathTest.java | 82 ------- .../webservice/definition/TypedKeyTest.java | 23 -- wsexample/client/pom.xml | 6 +- .../gson/example/client/ExampleClient.java | 12 +- .../gson/example/rest/client/OrderClient.java | 4 +- wsexample/definition/pom.xml | 6 +- .../com/google/gson/example/model/Cart.java | 4 +- .../com/google/gson/example/model/Order.java | 4 +- .../google/gson/example/model/TypedKeys.java | 2 +- .../example/service/SampleJsonService.java | 6 +- .../gson/example/service/ServicePaths.java | 2 +- wsexample/server/pom.xml | 6 +- .../gson/wsexample/server/MainServlet.java | 2 +- .../wsexample/server/ProcedureDispatcher.java | 20 +- .../gson/wsexample/server/RestDispatcher.java | 16 +- wsf/pom.xml | 6 +- .../com/google/gson/rest/server/IdMap.java | 6 +- .../google/gson/rest/server/MetaDataMap.java | 6 +- .../google/gson/rest/server/Repository.java | 4 +- .../gson/rest/server/RepositoryInMemory.java | 6 +- .../gson/rest/server/ResponseBuilderMap.java | 6 +- .../gson/rest/server/RestRequestReceiver.java | 16 +- .../gson/rest/server/RestResponseBuilder.java | 12 +- .../gson/rest/server/RestResponseSender.java | 12 +- .../gson/wsf/inject/CallPathProvider.java | 2 +- .../procedural/RequestBodySpecProvider.java | 4 +- .../procedural/RequestSpecProvider.java | 4 +- .../WebServiceCallServerProvider.java | 8 +- .../WebServiceCallSpecProvider.java | 6 +- .../server/procedural/RequestReceiver.java | 16 +- .../server/procedural/ResponseBuilder.java | 6 +- .../wsf/server/procedural/ResponseSender.java | 8 +- .../WebServiceCallServerBuilder.java | 6 +- 92 files changed, 187 insertions(+), 3464 deletions(-) delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/HasId.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/ID.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/IDFactory.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/MetaData.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/ResourceDepot.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/ResourceMap.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/RestCall.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/RestCallSpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/RestRequest.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/RestRequestSpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/RestResource.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/RestResponse.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/RestResponseSpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/definition/ValueBasedId.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/query/ResourceQuery.java delete mode 100644 wsdef/src/main/java/com/google/gson/rest/query/TypedKeysQuery.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/CallPath.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/CallPathMap.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/ContentBody.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/ContentBodySpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMap.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMapSpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/HttpMethod.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/ParamMap.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/ParamMapSpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/TypeUtils.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/TypedKey.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/Util.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceSystemException.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Pair.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Preconditions.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBody.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodyGsonConverter.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodySpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestSpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBody.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodyGsonConverter.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodySpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseSpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCall.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCallSpec.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceRequest.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceResponse.java delete mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceSpec.java delete mode 100644 wsdef/src/test/java/com/google/gson/rest/definition/IdTest.java delete mode 100644 wsdef/src/test/java/com/google/gson/rest/definition/IdTypeAdapterTest.java delete mode 100644 wsdef/src/test/java/com/google/gson/webservice/definition/CallPathTest.java delete mode 100644 wsdef/src/test/java/com/google/gson/webservice/definition/TypedKeyTest.java diff --git a/wsclient/pom.xml b/wsclient/pom.xml index 5c5ca637..cf19c5dd 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -56,9 +56,9 @@ compile - com.google.code.gson - wsdef - 0.1 + com.google.code.greaze + greaze-definition + 0.5 compile diff --git a/wsclient/src/main/java/com/google/gson/rest/client/ResourceDepotClient.java b/wsclient/src/main/java/com/google/gson/rest/client/ResourceDepotClient.java index c9e790f2..6d93179f 100644 --- a/wsclient/src/main/java/com/google/gson/rest/client/ResourceDepotClient.java +++ b/wsclient/src/main/java/com/google/gson/rest/client/ResourceDepotClient.java @@ -17,16 +17,16 @@ package com.google.gson.rest.client; import java.lang.reflect.Type; +import com.google.greaze.definition.CallPath; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HttpMethod; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.ResourceDepot; +import com.google.greaze.definition.rest.RestCallSpec; +import com.google.greaze.definition.rest.RestRequest; +import com.google.greaze.definition.rest.RestResource; +import com.google.greaze.definition.rest.RestResponse; import com.google.gson.Gson; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.ResourceDepot; -import com.google.gson.rest.definition.RestCallSpec; -import com.google.gson.rest.definition.RestRequest; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.rest.definition.RestResponse; -import com.google.gson.webservice.definition.CallPath; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HttpMethod; /** * A client class to access a rest resource diff --git a/wsclient/src/main/java/com/google/gson/rest/client/RestClientStub.java b/wsclient/src/main/java/com/google/gson/rest/client/RestClientStub.java index e6a85899..54691108 100644 --- a/wsclient/src/main/java/com/google/gson/rest/client/RestClientStub.java +++ b/wsclient/src/main/java/com/google/gson/rest/client/RestClientStub.java @@ -15,15 +15,15 @@ */ package com.google.gson.rest.client; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.RestCallSpec; +import com.google.greaze.definition.rest.RestRequest; +import com.google.greaze.definition.rest.RestResource; +import com.google.greaze.definition.rest.RestResponse; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestCallSpec; -import com.google.gson.rest.definition.RestRequest; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.rest.definition.RestResponse; import com.google.gson.webservice.client.ServerConfig; -import com.google.gson.webservice.definition.WebServiceSystemException; import java.io.IOException; import java.net.HttpURLConnection; diff --git a/wsclient/src/main/java/com/google/gson/rest/client/RestRequestSender.java b/wsclient/src/main/java/com/google/gson/rest/client/RestRequestSender.java index b6db8b6f..b7585355 100644 --- a/wsclient/src/main/java/com/google/gson/rest/client/RestRequestSender.java +++ b/wsclient/src/main/java/com/google/gson/rest/client/RestRequestSender.java @@ -22,14 +22,14 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HeaderMapSpec; +import com.google.greaze.definition.HttpMethod; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.RestRequest; +import com.google.greaze.definition.rest.RestResource; import com.google.gson.Gson; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestRequest; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.WebServiceSystemException; import com.google.gson.wsclient.internal.utils.Streams; /** diff --git a/wsclient/src/main/java/com/google/gson/rest/client/RestResponseReceiver.java b/wsclient/src/main/java/com/google/gson/rest/client/RestResponseReceiver.java index a7f6d01e..5abdba68 100644 --- a/wsclient/src/main/java/com/google/gson/rest/client/RestResponseReceiver.java +++ b/wsclient/src/main/java/com/google/gson/rest/client/RestResponseReceiver.java @@ -25,15 +25,15 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; +import com.google.greaze.definition.ContentBodySpec; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HeaderMapSpec; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.RestResource; +import com.google.greaze.definition.rest.RestResponse; +import com.google.greaze.definition.rest.RestResponseSpec; import com.google.gson.Gson; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.rest.definition.RestResponse; -import com.google.gson.rest.definition.RestResponseSpec; -import com.google.gson.webservice.definition.ContentBodySpec; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.WebServiceSystemException; import com.google.gson.wsclient.internal.utils.ConnectionPreconditions; /** diff --git a/wsclient/src/main/java/com/google/gson/rest/query/client/ResourceQueryClient.java b/wsclient/src/main/java/com/google/gson/rest/query/client/ResourceQueryClient.java index 13dbfd90..fe6aecbb 100644 --- a/wsclient/src/main/java/com/google/gson/rest/query/client/ResourceQueryClient.java +++ b/wsclient/src/main/java/com/google/gson/rest/query/client/ResourceQueryClient.java @@ -17,20 +17,20 @@ package com.google.gson.rest.query.client; import java.util.List; +import com.google.greaze.definition.CallPath; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HttpMethod; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.RestResource; +import com.google.greaze.definition.rest.query.ResourceQuery; +import com.google.greaze.definition.rest.query.TypedKeysQuery; +import com.google.greaze.definition.webservice.RequestBody; +import com.google.greaze.definition.webservice.ResponseBody; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; +import com.google.greaze.definition.webservice.WebServiceResponse; import com.google.gson.Gson; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.rest.query.ResourceQuery; -import com.google.gson.rest.query.TypedKeysQuery; import com.google.gson.webservice.client.WebServiceClient; -import com.google.gson.webservice.definition.CallPath; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.procedural.RequestBody; -import com.google.gson.webservice.definition.procedural.ResponseBody; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; -import com.google.gson.webservice.definition.procedural.WebServiceResponse; /** * A client to invoke {@link ResourceQuery}s associated with a REST resource diff --git a/wsclient/src/main/java/com/google/gson/webservice/client/QueueConsumer.java b/wsclient/src/main/java/com/google/gson/webservice/client/QueueConsumer.java index 350cc57e..82300a7c 100644 --- a/wsclient/src/main/java/com/google/gson/webservice/client/QueueConsumer.java +++ b/wsclient/src/main/java/com/google/gson/webservice/client/QueueConsumer.java @@ -17,9 +17,9 @@ package com.google.gson.webservice.client; import java.util.concurrent.BlockingQueue; -import com.google.gson.webservice.definition.WebServiceSystemException; -import com.google.gson.webservice.definition.procedural.WebServiceCall; -import com.google.gson.webservice.definition.procedural.WebServiceResponse; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.webservice.WebServiceCall; +import com.google.greaze.definition.webservice.WebServiceResponse; /** * A consumer that executes in its own thread consuming queue entries and invoking web-service calls diff --git a/wsclient/src/main/java/com/google/gson/webservice/client/QueueEntry.java b/wsclient/src/main/java/com/google/gson/webservice/client/QueueEntry.java index 42789728..8742ab79 100644 --- a/wsclient/src/main/java/com/google/gson/webservice/client/QueueEntry.java +++ b/wsclient/src/main/java/com/google/gson/webservice/client/QueueEntry.java @@ -15,8 +15,8 @@ */ package com.google.gson.webservice.client; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; /** * A holder class for an entry stored in queue. It contains references to the request, callspec, diff --git a/wsclient/src/main/java/com/google/gson/webservice/client/RequestSender.java b/wsclient/src/main/java/com/google/gson/webservice/client/RequestSender.java index 9ac72859..64a4f93f 100644 --- a/wsclient/src/main/java/com/google/gson/webservice/client/RequestSender.java +++ b/wsclient/src/main/java/com/google/gson/webservice/client/RequestSender.java @@ -22,12 +22,12 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HeaderMapSpec; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.webservice.RequestBody; +import com.google.greaze.definition.webservice.WebServiceRequest; import com.google.gson.Gson; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.WebServiceSystemException; -import com.google.gson.webservice.definition.procedural.RequestBody; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; import com.google.gson.wsclient.internal.utils.Streams; /** diff --git a/wsclient/src/main/java/com/google/gson/webservice/client/ResponseCallback.java b/wsclient/src/main/java/com/google/gson/webservice/client/ResponseCallback.java index 97262eed..c4e0283d 100644 --- a/wsclient/src/main/java/com/google/gson/webservice/client/ResponseCallback.java +++ b/wsclient/src/main/java/com/google/gson/webservice/client/ResponseCallback.java @@ -15,10 +15,10 @@ */ package com.google.gson.webservice.client; -import com.google.gson.webservice.definition.WebServiceSystemException; -import com.google.gson.webservice.definition.procedural.WebServiceCall; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.webservice.WebServiceCall; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; /** * A client-supplied callback to be used with {@link WebServiceClientAsync}. When a web-service diff --git a/wsclient/src/main/java/com/google/gson/webservice/client/ResponseReceiver.java b/wsclient/src/main/java/com/google/gson/webservice/client/ResponseReceiver.java index d1b8c445..4e6648f1 100644 --- a/wsclient/src/main/java/com/google/gson/webservice/client/ResponseReceiver.java +++ b/wsclient/src/main/java/com/google/gson/webservice/client/ResponseReceiver.java @@ -25,14 +25,14 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HeaderMapSpec; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.webservice.ResponseBody; +import com.google.greaze.definition.webservice.ResponseBodySpec; +import com.google.greaze.definition.webservice.ResponseSpec; +import com.google.greaze.definition.webservice.WebServiceResponse; import com.google.gson.Gson; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.WebServiceSystemException; -import com.google.gson.webservice.definition.procedural.ResponseBody; -import com.google.gson.webservice.definition.procedural.ResponseBodySpec; -import com.google.gson.webservice.definition.procedural.ResponseSpec; -import com.google.gson.webservice.definition.procedural.WebServiceResponse; import com.google.gson.wsclient.internal.utils.ConnectionPreconditions; /** diff --git a/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClient.java b/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClient.java index 25c720d2..cc82f200 100644 --- a/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClient.java +++ b/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClient.java @@ -22,14 +22,14 @@ import java.net.URL; import java.util.logging.Level; import java.util.logging.Logger; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.webservice.ResponseBody; +import com.google.greaze.definition.webservice.ResponseBodyGsonConverter; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; +import com.google.greaze.definition.webservice.WebServiceResponse; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.webservice.definition.WebServiceSystemException; -import com.google.gson.webservice.definition.procedural.ResponseBody; -import com.google.gson.webservice.definition.procedural.ResponseBodyGsonConverter; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; -import com.google.gson.webservice.definition.procedural.WebServiceResponse; /** * Main class used by clients to access a Gson Web service. diff --git a/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClientAsync.java b/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClientAsync.java index 885304e8..9795165c 100644 --- a/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClientAsync.java +++ b/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClientAsync.java @@ -19,9 +19,9 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.logging.Level; -import com.google.gson.webservice.definition.WebServiceSystemException; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; /** * A client for invoking a JSON-based Web-service in an asynchronous manner. The call is queued, diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/HasId.java b/wsdef/src/main/java/com/google/gson/rest/definition/HasId.java deleted file mode 100644 index 39b4831a..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/HasId.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -/** - * An interface to indicate that an object has an Id - * - * @author inder - * - * @param type of object - */ -public interface HasId { - public I getId(); - public void setId(I id); - public boolean hasId(); -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/ID.java b/wsdef/src/main/java/com/google/gson/rest/definition/ID.java deleted file mode 100644 index 55bba6e8..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/ID.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.gson.rest.definition; - -public interface ID { - public static final long INVALID_ID = -1L; - - public long getValue(); -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/IDFactory.java b/wsdef/src/main/java/com/google/gson/rest/definition/IDFactory.java deleted file mode 100644 index 87d30e91..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/IDFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import java.lang.reflect.Type; - -/** - * A factory to create {@link ValueBasedId)s - * - * @author inder - * - * @param - */ -public class IDFactory { - private final Class classOfI; - private final Type typeOfId; - - public IDFactory(Class classOfI, Type typeOfId) { - this.classOfI = classOfI; - this.typeOfId = typeOfId; - } - - @SuppressWarnings("unchecked") - public I createId(long value) { - if (classOfI.isAssignableFrom(ValueBasedId.class)) { - return (I)ValueBasedId.get(value, typeOfId); - } - throw new UnsupportedOperationException(); - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/MetaData.java b/wsdef/src/main/java/com/google/gson/rest/definition/MetaData.java deleted file mode 100644 index f3c7a002..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/MetaData.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.reflect.TypeToken; - -/** - * Metadata associated with a repository for a rest resource. Metadata is of two types: persistent - * and transient. All metadata is persistent by default, and must be a name-value pair of strings. - * Transient metadata can be an arbitrary key-value pair of objects and is available through - * {@link #getFromTransient(Object)}, {@link #putInTransient(Object, Object)}, - * and {@link #removeFromTransient(Object)} methods. - * - * @author inder - * - * @param The resource - */ -public final class MetaData> { - - private final Map map; - private final transient Map mapTransient; - - public static > MetaData create() { - return new MetaData(); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - private static MetaData createTypeUnsafe(Map values) { - return new MetaData(values); - } - - public MetaData() { - this(new HashMap()); - } - - private MetaData(Map values) { - this.map = values == null ? new HashMap() : values; - this.mapTransient = new HashMap(); - } - - public String getString(String key) { - return map.get(key); - } - - public void putString(String key, String value) { - map.put(key, value); - } - - public boolean getBoolean(String key) { - String value = map.get(key); - return value == null ? false : Boolean.parseBoolean(value); - } - - public void putBoolean(String key, boolean value) { - map.put(key, String.valueOf(value)); - } - - public void remove(String key) { - map.remove(key); - } - - public Object getFromTransient(Object key) { - return mapTransient.get(key); - } - - public void putInTransient(Object key, Object value) { - mapTransient.put(key, value); - } - - public void removeFromTransient(Object key) { - mapTransient.remove(key); - } - - @Override - public String toString() { - return new StringBuilder().append(map).append(',').append(mapTransient).toString(); - } - - /** - * Gson Type adapter for {@link MetaData}. The serialized representation on wire is just a - * Map - */ - public static final class GsonTypeAdapter implements JsonSerializer>, - JsonDeserializer>{ - - private static final Type MAP_TYPE = new TypeToken>(){}.getType(); - - @Override - public MetaData deserialize(JsonElement json, Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - Map map = context.deserialize(json, MAP_TYPE); - return MetaData.createTypeUnsafe(map); - } - - @Override - public JsonElement serialize(MetaData src, Type typeOfSrc, - JsonSerializationContext context) { - return context.serialize(src.map, MAP_TYPE); - } - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/ResourceDepot.java b/wsdef/src/main/java/com/google/gson/rest/definition/ResourceDepot.java deleted file mode 100644 index 6e045b3b..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/ResourceDepot.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -public interface ResourceDepot> { - - public R get(I resourceId); - - public R post(R resource); - - public R put(R resource); - - public void delete(I resourceId); -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/ResourceMap.java b/wsdef/src/main/java/com/google/gson/rest/definition/ResourceMap.java deleted file mode 100644 index 9cce3187..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/ResourceMap.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import com.google.gson.webservice.definition.CallPath; -import com.google.gson.webservice.definition.internal.utils.Preconditions; - -import java.util.HashMap; -import java.util.Map; - -/** - * A {@link Map} of {@link CallPath} to {@link RestCallSpec} - * - * @author inder - */ -public final class ResourceMap { - - public static final class Builder { - private final Map resources = - new HashMap(); - - public Builder set(CallPath baseCallPath, RestCallSpec spec) { - Preconditions.checkArgument(resources.get(baseCallPath) == null); - resources.put(baseCallPath, spec); - return this; - } - - public ResourceMap build() { - return new ResourceMap(resources); - } - } - - private final Map resources; - - public ResourceMap(Map resources) { - this.resources = resources; - } - - public RestCallSpec get(CallPath callPath) { - return resources.get(callPath); - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/RestCall.java b/wsdef/src/main/java/com/google/gson/rest/definition/RestCall.java deleted file mode 100644 index 717cb4a5..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/RestCall.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -/** - * The data associated with a Rest Web service call. This includes http request header parameters - * (form and URL parameters), request body, response header parameters, and resource response body. - * - * @author inder - */ -public final class RestCall> { - - private final RestCallSpec callSpec; - private final RestRequest request; - private final RestResponse response; - - public RestCall(RestCallSpec callSpec, RestRequest request, RestResponse response) { - this.callSpec = callSpec; - this.request = request; - this.response = response; - } - - public RestCallSpec getSpec() { - return callSpec; - } - - public RestRequest getRequest() { - return request; - } - - public RestResponse getResponse() { - return response; - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/RestCallSpec.java b/wsdef/src/main/java/com/google/gson/rest/definition/RestCallSpec.java deleted file mode 100644 index bf54f487..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/RestCallSpec.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import com.google.gson.webservice.definition.CallPath; -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.TypedKey; -import com.google.gson.webservice.definition.internal.utils.Preconditions; - -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * Specification for a REST service - * - * @author inder - */ -public final class RestCallSpec { - public static class Builder { - private final CallPath callPath; - private final Set supportedHttpMethods = new LinkedHashSet(); - private final HeaderMapSpec.Builder reqParamsSpecBuilder = new HeaderMapSpec.Builder(); - private final HeaderMapSpec.Builder resParamsSpecBuilder = new HeaderMapSpec.Builder(); - private final Type resourceType; - private double version; - - public Builder(CallPath callPath, Type resourceType) { - this.callPath = callPath; - supportedHttpMethods.addAll(HttpMethod.ALL_METHODS); - this.resourceType = resourceType; - this.version = -1D; - } - - public Builder disableHttpMethod(HttpMethod httpMethod) { - supportedHttpMethods.remove(httpMethod); - return this; - } - - public Builder setVersion(double version) { - this.version = version; - return this; - } - - public Builder addRequestParam(TypedKey param) { - reqParamsSpecBuilder.put(param.getName(), param.getClassOfT()); - return this; - } - - public Builder addResponseParam(TypedKey param) { - resParamsSpecBuilder.put(param.getName(), param.getClassOfT()); - return this; - } - - public RestCallSpec build() { - if (supportedHttpMethods.isEmpty()) { - supportedHttpMethods.addAll(Arrays.asList(HttpMethod.values())); - } - RestRequestSpec requestSpec = - new RestRequestSpec(reqParamsSpecBuilder.build(), resourceType); - RestResponseSpec responseSpec = - new RestResponseSpec(resParamsSpecBuilder.build(), resourceType); - return new RestCallSpec(supportedHttpMethods, callPath, - requestSpec, responseSpec, resourceType, version); - } - } - - private final Set supportedHttpMethods; - private final CallPath path; - private final RestRequestSpec requestSpec; - private final RestResponseSpec responseSpec; - private final Type resourceType; - private final double version; - - private RestCallSpec(Set supportedHttpMethods, CallPath path, - RestRequestSpec requestSpec, RestResponseSpec responseSpec, - Type resourceType, double version) { - Preconditions.checkArgument(!supportedHttpMethods.isEmpty()); - Preconditions.checkNotNull(path); - this.supportedHttpMethods = supportedHttpMethods; - this.path = path; - this.requestSpec = requestSpec; - this.responseSpec = responseSpec; - this.resourceType = resourceType; - this.version = version; - } - - public CallPath getPath() { - return path; - } - - public Set getSupportedHttpMethods() { - return supportedHttpMethods; - } - - public RestResponseSpec getResponseSpec() { - return responseSpec; - } - - public RestRequestSpec getRequestSpec() { - return requestSpec; - } - - public Type getResourceType() { - return resourceType; - } - - public double getVersion() { - return version; - } - - @Override - public String toString() { - return String.format( - "path: %s, version: %.2f, resourceType: %s, requestSpec: %s, responseSpec: %s", - path, version, resourceType, requestSpec, responseSpec); - } - - public RestCallSpec createCopy(CallPath callPath) { - return new RestCallSpec(supportedHttpMethods, callPath, requestSpec, - responseSpec, resourceType, version); - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/RestRequest.java b/wsdef/src/main/java/com/google/gson/rest/definition/RestRequest.java deleted file mode 100644 index 1f41bd81..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/RestRequest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import java.lang.reflect.Type; - -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.TypedKey; - -/** - * The data associated with a Web service request. This includes HTTP request header parameters - * (form and URL parameters), and request body. - * - * @author inder - */ -public final class RestRequest> { - public static final String JSON_CONTENT_TYPE = "application/json"; - - private final HttpMethod method; - private final HeaderMap headers; - private final I id; - private final R body; - private final RestRequestSpec spec; - - public RestRequest(HttpMethod method, HeaderMap requestHeaders, - I resourceId, R requestBody, Type resourceType) { - this.method = method; - this.id = resourceId; - this.body = requestBody; - this.headers = requestHeaders; - this.spec = new RestRequestSpec(requestHeaders.getSpec(), resourceType); - } - - public I getId() { - return id; - } - - public HttpMethod getMethod() { - return method; - } - - public RestRequestSpec getSpec() { - return spec; - } - - public HttpMethod getHttpMethod() { - return method; - } - - public R getBody() { - return body; - } - - public HeaderMap getHeaders() { - return headers; - } - - public String getContentType() { - return JSON_CONTENT_TYPE; - } - - public T getHeader(TypedKey key) { - return headers.get(key); - } - - @SuppressWarnings("unchecked") - public T getHeader(String headerName) { - return (T) headers.get(headerName); - } - - @Override - public String toString() { - return String.format("{method:%s,headers:%s,body:%s}", method, headers, body); - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/RestRequestSpec.java b/wsdef/src/main/java/com/google/gson/rest/definition/RestRequestSpec.java deleted file mode 100644 index c9629909..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/RestRequestSpec.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import java.lang.reflect.Type; - -import com.google.gson.webservice.definition.HeaderMapSpec; - -/** - * Specification for a {@link RestRequest}. - * - * @author inder - */ -public final class RestRequestSpec { - private final HeaderMapSpec headersSpec; - private final Type resourceType; - - public RestRequestSpec(HeaderMapSpec headersSpec, Type resourceClass) { - this.headersSpec = headersSpec; - this.resourceType = resourceClass; - } - - public Type getResourceType() { - return resourceType; - } - - public HeaderMapSpec getHeadersSpec() { - return headersSpec; - } - - @Override - public String toString() { - return String.format("{headersSpec:%s,resourceType:%s}", headersSpec, resourceType); - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/RestResource.java b/wsdef/src/main/java/com/google/gson/rest/definition/RestResource.java deleted file mode 100644 index c486a7ce..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/RestResource.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -/** - * An interface implemented by an object that is intended to be a rest resource - * - * @author inder - * - * @param the rest resource type - */ -public interface RestResource extends HasId { -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/RestResponse.java b/wsdef/src/main/java/com/google/gson/rest/definition/RestResponse.java deleted file mode 100644 index de1ed967..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/RestResponse.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import java.lang.reflect.Type; - -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.TypedKey; - -/** - * The data associated with a REST Web service response. This includes http response header - * parameters, and the response body. - * - * @author inder - */ -public final class RestResponse> { - - private final HeaderMap headers; - private final R body; - private final RestResponseSpec spec; - - public static class Builder> { - private final HeaderMap.Builder headers; - private RS body; - private final RestResponseSpec spec; - - public Builder(RestResponseSpec spec) { - this.spec = spec; - headers = new HeaderMap.Builder(spec.getHeadersSpec()); - } - - public Builder putHeader(TypedKey paramName, T content) { - headers.put(paramName.getName(), content, paramName.getClassOfT()); - return this; - } - - public Builder setBody(RS body) { - this.body = body; - return this; - } - - public RestResponse build() { - return new RestResponse(spec, headers.build(), body); - } - } - - private RestResponse(RestResponseSpec spec, HeaderMap headers, R body) { - this.spec = spec; - this.headers = headers; - this.body = body; - } - - public RestResponse(HeaderMap responseHeaders, R responseBody, Type responseBodyType) { - this.spec = new RestResponseSpec(responseHeaders.getSpec(), responseBodyType); - this.headers = responseHeaders; - this.body = responseBody; - } - - public RestResponseSpec getSpec() { - return spec; - } - - public HeaderMap getHeaders() { - return headers; - } - - public R getBody() { - return body; - } - - @SuppressWarnings("unchecked") - public T getHeader(String headerName) { - return (T) headers.get(headerName); - } - - @Override - public String toString() { - return String.format("{headers:%s, body:%s}", headers, body); - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/RestResponseSpec.java b/wsdef/src/main/java/com/google/gson/rest/definition/RestResponseSpec.java deleted file mode 100644 index 60d2b9d3..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/RestResponseSpec.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import java.lang.reflect.Type; - -import com.google.gson.webservice.definition.HeaderMapSpec; - -/** - * Specification for a {@link RestResponse}. - * - * @author inder - */ -public final class RestResponseSpec { - private final HeaderMapSpec headersSpec; - private final Type resourceType; - - public RestResponseSpec(HeaderMapSpec headersSpec, Type resourceType) { - this.headersSpec = headersSpec; - this.resourceType = resourceType; - } - - public Type getResourceType() { - return resourceType; - } - - public HeaderMapSpec getHeadersSpec() { - return headersSpec; - } - - @Override - public String toString() { - return String.format("{headersSpec:%s,resourceType:%s}", headersSpec, resourceType); - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/definition/ValueBasedId.java b/wsdef/src/main/java/com/google/gson/rest/definition/ValueBasedId.java deleted file mode 100644 index 60e814f4..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/definition/ValueBasedId.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.webservice.definition.internal.utils.Preconditions; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.WildcardType; - -/** - * An id for a rest resource - * - * @author inder - * - * @param type variable for the rest resource - */ -public final class ValueBasedId implements ID { - private final long value; - private final Type typeOfId; - - private ValueBasedId(long value, Type typeOfId) { - this.value = value; - this.typeOfId = typeOfId; - } - - @Override - public long getValue() { - return value; - } - - public static long getValue(ValueBasedId id) { - return id == null ? INVALID_ID : id.getValue(); - } - - public String getValueAsString() { - return String.valueOf(value); - } - - public Type getTypeOfId() { - return typeOfId; - } - - @Override - public int hashCode() { - return (int) value; - } - - public static boolean isValid(ValueBasedId id) { - return id != null && id.value != INVALID_ID; - } - - /** - * A more efficient comparison method for ids that take into account of ids being nullable. - * Since the method is parameterized and both ids are of the same type, this method compares - * only id values, not their types. Note that this shortcut doesn't work if you pass raw ids - * to this method - */ - public static boolean equals(/* @Nullable */ ValueBasedId id1, - /* @Nullable */ ValueBasedId id2) { - if ((id1 == null && id2 != null) || (id1 != null && id2 == null)) { - return false; - } - if (id1 == null && id2 == null) { - return true; - } - return id1.value == id2.value; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - @SuppressWarnings("unchecked") - ValueBasedId other = (ValueBasedId)obj; - if (typeOfId == null) { - if (other.typeOfId != null) return false; - } else if (!equivalentTypes(typeOfId, other.typeOfId)) return false; - if (value != other.value) return false; - return true; - } - - /** - * Returns true for equivalentTypes(Class, Class) - * Visible for testing only - */ - @SuppressWarnings("rawtypes") - static boolean equivalentTypes(Type type1, Type type2) { - if (type1 instanceof ParameterizedType && type2 instanceof Class) { - return areEquivalentTypes((ParameterizedType)type1, (Class)type2); - } else if (type2 instanceof ParameterizedType && type1 instanceof Class) { - return areEquivalentTypes((ParameterizedType)type2, (Class)type1); - } - return type1.equals(type2); - } - - /** - * Visible for testing only - */ - @SuppressWarnings("rawtypes") - static boolean areEquivalentTypes(ParameterizedType type, Class clazz) { - Class rawClass = (Class) type.getRawType(); - if (!clazz.equals(rawClass)) { - return false; - } - for (Type typeVariable : type.getActualTypeArguments()) { - if (typeVariable instanceof WildcardType) { - continue; - } - // This is a real parameterized type, not just ? - return false; - } - return true; - } - - public static ValueBasedId get(long value, Type typeOfId) { - return new ValueBasedId(value, typeOfId); - } - - @Override - public String toString() { - String typeAsString = getSimpleTypeName(typeOfId); - return String.format("{value:%s,type:%s}", value, typeAsString); - } - - @SuppressWarnings("rawtypes") - private static String getSimpleTypeName(Type type) { - if (type == null) { - return "null"; - } - if (type instanceof Class) { - return ((Class)type).getSimpleName(); - } else if (type instanceof ParameterizedType) { - ParameterizedType pType = (ParameterizedType) type; - StringBuilder sb = new StringBuilder(getSimpleTypeName(pType.getRawType())); - sb.append('<'); - boolean first = true; - for (Type argumentType : pType.getActualTypeArguments()) { - if (first) { - first = false; - } else { - sb.append(','); - } - sb.append(getSimpleTypeName(argumentType)); - } - sb.append('>'); - return sb.toString(); - } else if (type instanceof WildcardType) { - return "?"; - } - return type.toString(); - } - - /** - * Type adapter for converting an Id to its serialized form - * - * @author inder - * - */ - public static final class GsonTypeAdapter implements JsonSerializer>, - JsonDeserializer> { - - @Override - public JsonElement serialize(ValueBasedId src, Type typeOfSrc, - JsonSerializationContext context) { - return new JsonPrimitive(src.getValue()); - } - - @Override - public ValueBasedId deserialize(JsonElement json, Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - if (!(typeOfT instanceof ParameterizedType)) { - throw new JsonParseException("Id of unknown type: " + typeOfT); - } - ParameterizedType parameterizedType = (ParameterizedType) typeOfT; - // Since Id takes only one TypeVariable, the actual type corresponding to the first - // TypeVariable is the Type we are looking for - Type typeOfId = parameterizedType.getActualTypeArguments()[0]; - return ValueBasedId.get(json.getAsLong(), typeOfId); - } - } -} diff --git a/wsdef/src/main/java/com/google/gson/rest/query/ResourceQuery.java b/wsdef/src/main/java/com/google/gson/rest/query/ResourceQuery.java deleted file mode 100644 index 63b5f63e..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/query/ResourceQuery.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.query; - -import java.util.List; - -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestResource; - -/** - * A query for a list of rest resources. - * - * @author Inderjeet Singh - */ -public interface ResourceQuery, QUERY> { - /** - * Returns a list of resources matching the query - */ - public List query(QUERY query); -} diff --git a/wsdef/src/main/java/com/google/gson/rest/query/TypedKeysQuery.java b/wsdef/src/main/java/com/google/gson/rest/query/TypedKeysQuery.java deleted file mode 100644 index 29a2aa79..00000000 --- a/wsdef/src/main/java/com/google/gson/rest/query/TypedKeysQuery.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.query; - -import java.util.List; - -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.webservice.definition.TypedKey; - -/** - * List of {@link TypedKey}s associated with REST queries - * - * @author Inderjeet Singh - * - * @param ID type of the REST resource - * @param The type of the REST resource - */ -@SuppressWarnings("rawtypes") -public class TypedKeysQuery> { - - // TODO(inder): This should really be TypedKey> - public static TypedKey RESOURCE_LIST = new TypedKey("resourceList", List.class); -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/CallPath.java b/wsdef/src/main/java/com/google/gson/webservice/definition/CallPath.java deleted file mode 100644 index dfbe8271..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/CallPath.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - -import com.google.gson.rest.definition.ID; -import com.google.gson.webservice.definition.internal.utils.Pair; - -/** - * Encapsulation of a Web service path that is sent by the client. - * - * @author inder - */ -public final class CallPath { - - /** Visible for testing only */ - static final double IGNORE_VERSION = -1D; - private final String path; - private final double version; - private final long resourceId; - - public CallPath(String path) { - if (path == null || path.trim().equals("")) { - this.path = path; - version = IGNORE_VERSION; - resourceId = ID.INVALID_ID; - } else { - Pair path2 = extractVersion(path); - this.version = path2.first; - Pair path3 = extractId(path2.second); - this.resourceId = path3.first; - this.path = path3.second; - } - } - - /** - * Returns path after consuming version number from the begining - */ - private static Pair extractVersion(String path) { - int index1 = path.indexOf('/'); - int index2 = path.substring(index1+1).indexOf('/'); - String versionStr = path.substring(index1+1, index2+1); - double extractedVersion = -1.0D; - String revisedPath = path; - try { - // Skip over the version number from the URL - extractedVersion = Double.parseDouble(versionStr); - revisedPath = path.substring(index2+1); - } catch (NumberFormatException e) { - // Assume that version number wasn't specified - } - return Pair.create(extractedVersion, revisedPath); - } - - private static Pair extractId(String path) { - Pair originalPath = Pair.create(ID.INVALID_ID, path); - int end = path.endsWith("/") ? path.length() - 1 : path.length(); - int begin = path.substring(0, end-1).lastIndexOf('/') + 1; - if (begin < 0 || end < 0 || begin >= end) { - return originalPath; - } - try { - String id = path.substring(begin, end); - String pathWithoutId = path.substring(0, begin-1); - return Pair.create(Long.parseLong(id), pathWithoutId); - } catch (NumberFormatException e) { - return originalPath; - } - } - - public String get() { - return path; - } - - public double getVersion() { - return version; - } - - public long getResourceId() { - return resourceId; - } - - @Override - public int hashCode() { - return path.hashCode(); - } - - public boolean matches(CallPath callPath) { - return path.startsWith(callPath.get()); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - return getClass() == obj.getClass() && equal(path, ((CallPath)obj).path); - } - - private static boolean equal(String s1, String s2) { - return s1 == s2 || (s1 != null && s2 != null && s1.equals(s2)); - } - - @Override - public String toString() { - return String.format("path:%s, version:%2.f, resourceId: %d", path, version, resourceId); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/CallPathMap.java b/wsdef/src/main/java/com/google/gson/webservice/definition/CallPathMap.java deleted file mode 100644 index f12f90c0..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/CallPathMap.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - -import java.util.HashMap; -import java.util.Map; - -/** - * A generic Map of calls with relative path where the call is available as the key. - * - * @author inder - * - * @param The target of the call path. - */ -public final class CallPathMap { - - public static class Builder { - private final Map contents = new HashMap(); - private final T nullValue; - - public Builder(T nullValue) { - this.nullValue = nullValue; - } - public Builder put(CallPath path, R content) { - contents.put(path, content); - return this; - } - - public CallPathMap build() { - return new CallPathMap(contents, nullValue); - } - } - - private final Map contents; - private final T nullValue; - - private CallPathMap(Map contents, T nullValue) { - this.contents = contents; - this.nullValue = nullValue; - } - - public T get(CallPath path) { - T content = contents.get(path); - return content == null ? nullValue : content; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("{"); - boolean first = true; - for (Map.Entry entry : contents.entrySet()) { - if (first) { - first = false; - } else { - sb.append(","); - } - CallPath path = entry.getKey(); - sb.append(path.get()).append(":"); - sb.append(entry.getValue().toString()); - } - sb.append("}"); - return sb.toString(); - } -} \ No newline at end of file diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/ContentBody.java b/wsdef/src/main/java/com/google/gson/webservice/definition/ContentBody.java deleted file mode 100644 index 7875c168..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/ContentBody.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - - -import java.util.Map; - -/** - * Body of a request or response. The body contains a map of name-value pairs. - * There is a {@link ContentBodySpec} associated with the body as well and only the name-value - * pairs consistent with the specification are permitted. - * - * @author inder - */ -public class ContentBody extends ParamMap { - - public ContentBody(ContentBodySpec spec, Map contents) { - super(spec, contents); - } - - @Override - public ContentBodySpec getSpec() { - return (ContentBodySpec) spec; - } - - public String getContentType() { - return getSpec().getContentType(); - } - - public String getCharacterEncoding() { - return getSpec().getCharacterEncoding(); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/ContentBodySpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/ContentBodySpec.java deleted file mode 100644 index acbb89c8..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/ContentBodySpec.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - - -import java.lang.reflect.Type; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -/** - * Base class for the specification of a {@link ContentBody}. - * - * @author inder - */ -public class ContentBodySpec implements ParamMapSpec { - - public static final String JSON_CONTENT_TYPE = "application/json"; - public static final String JSON_CHARACTER_ENCODING = "utf-8"; - - private final Map paramsSpec; - - protected ContentBodySpec(Map paramsSpec) { - this.paramsSpec = Collections.unmodifiableMap(paramsSpec); - } - - @Override - public Type getTypeFor(String paramName) { - return paramsSpec.get(paramName); - } - - @Override - public boolean checkIfCompatible(String paramName, Type type) { - return type.equals(getTypeFor(paramName)); - } - - @Override - public boolean checkIfCompatible(String paramName, Object object) { - return checkIfCompatible(paramName, object.getClass()); - } - - @Override - public Set> entrySet() { - return paramsSpec.entrySet(); - } - - @Override - public int size() { - return paramsSpec.size(); - } - - public String getContentType() { - return JSON_CONTENT_TYPE; - } - - public String getCharacterEncoding() { - return JSON_CHARACTER_ENCODING; - } - - @Override - public String toString() { - return Util.toStringMapKeys(paramsSpec); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMap.java b/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMap.java deleted file mode 100644 index 922e047e..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMap.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - - -import java.lang.reflect.Type; -import java.util.Map; - -/** - * Map of request or response header objects. There is a {@link HeaderMapSpec} associated with the - * map as well and only those headers are allowed that are consistent with the specification. - * - * @author inder - */ -public final class HeaderMap extends ParamMap { - - public static class Builder extends ParamMap.Builder { - public Builder(HeaderMapSpec spec) { - super(spec); - } - - @Override - public Builder put(TypedKey paramKey, T content) { - return put(paramKey.getName(), content); - } - - @Override - public Builder put(String paramName, Object content) { - return (Builder) super.put(paramName, content); - } - - @Override - public Builder put(String paramName, Object content, Type typeOfContent) { - return (Builder) super.put(paramName, content, typeOfContent); - } - - public HeaderMap build() { - return new HeaderMap(spec, contents); - } - } - - private HeaderMap(HeaderMapSpec spec, Map contents) { - super(spec, contents); - } - - @Override - public HeaderMapSpec getSpec() { - return (HeaderMapSpec) super.getSpec(); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMapSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMapSpec.java deleted file mode 100644 index a4ad9cfa..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMapSpec.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - - -import java.lang.reflect.Type; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -/** - * Specification of a header map for {@link HeaderMap}. - * - * @author inder - */ -public final class HeaderMapSpec implements ParamMapSpec { - - public static class Builder { - private final Map map = new LinkedHashMap(); - - public void put(String headerName, Type headerType) { - map.put(headerName, headerType); - } - - public HeaderMapSpec build() { - return new HeaderMapSpec(map); - } - } - private final Map map; - - private HeaderMapSpec(Map map) { - this.map = map; - } - - @Override - public Type getTypeFor(String headerName) { - return map.get(headerName); - } - - @Override - public Set> entrySet() { - return map.entrySet(); - } - - @Override - public boolean checkIfCompatible(String headerName, Type targetType) { - Type typeOfHeader = getTypeFor(headerName); - if (typeOfHeader == null) { - return false; - } - Class rawClassOfHeader = TypeUtils.toRawClass(typeOfHeader); - Class rawClassOfTargetType = TypeUtils.toRawClass(targetType); - return rawClassOfHeader.isAssignableFrom(rawClassOfTargetType); - } - - @Override - public boolean checkIfCompatible(String headerName, Object headerValue) { - return checkIfCompatible(headerName, headerValue.getClass()); - } - - @Override - public String toString() { - return Util.toStringMapKeys(map); - } - - @Override - public int size() { - return map.size(); - } -} \ No newline at end of file diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/HttpMethod.java b/wsdef/src/main/java/com/google/gson/webservice/definition/HttpMethod.java deleted file mode 100644 index 705c3e09..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/HttpMethod.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * An enum of Http methods to provide strongly-typed versions instead of strings. - * - * @author inder - */ -public enum HttpMethod { - GET, - POST, - PUT, - DELETE; - - public static HttpMethod getMethod(String method) { - return valueOf(method.trim().toUpperCase()); - } - - public static final List ALL_METHODS = - Collections.unmodifiableList(Arrays.asList(values())); - - /** - * This header is used to indicate the real method that is channeled through the current - * request. For example, you can use it to send PUT requests under a POST. - */ - public static final String SIMULATED_METHOD_HEADER = "SimulatedMethod"; -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMap.java b/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMap.java deleted file mode 100644 index 2f25bcfa..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMap.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - -import com.google.gson.webservice.definition.internal.utils.Preconditions; - -import java.lang.reflect.Type; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -public class ParamMap { - - public static class Builder { - protected final Map contents = new LinkedHashMap(); - protected final T spec; - - public Builder(T spec) { - this.spec = spec; - } - - /** - * If value is a generic type, use {@link #put(String, Object, Type)} instead. - */ - public Builder put(String paramName, Object content) { - return put(paramName, content, content.getClass()); - } - - public Builder put(String paramName, Object content, Type typeOfContent) { - Preconditions.checkArgument(spec.checkIfCompatible(paramName, typeOfContent)); - contents.put(paramName, content); - return this; - } - - public Builder put(TypedKey paramKey, K param) { - contents.put(paramKey.getName(), param); - return this; - } - } - - protected final Map contents; - protected final ParamMapSpec spec; - - protected ParamMap(ParamMapSpec spec, Map contents) { - this.spec = spec; - this.contents = contents; - } - - public ParamMapSpec getSpec() { - return spec; - } - - public Object get(String paramName) { - return contents.get(paramName); - } - - @SuppressWarnings("unchecked") - public T get(TypedKey key) { - return (T) get(key.getName(), key.getClassOfT()); - } - - @SuppressWarnings("unchecked") - public T get(String key, Type typeOfValue) { - Preconditions.checkArgument(spec.checkIfCompatible(key, typeOfValue), - "Incompatible key %s for type %s", key, typeOfValue); - return (T) contents.get(key); - } - - public Type getSpec(String headerName) { - return spec.getTypeFor(headerName); - } - - public Set> entrySet() { - return contents.entrySet(); - } - - public int size() { - return contents.size(); - } - - @Override - public String toString() { - return Util.toStringMap(contents); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMapSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMapSpec.java deleted file mode 100644 index 447be9d7..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMapSpec.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - - -import java.lang.reflect.Type; -import java.util.Map; -import java.util.Set; - -/** - * Specification of a parameter map. Both {@link ContentBody} and {@link HeaderMap} are - * parameter maps. - * - * @author inder - */ -interface ParamMapSpec { - - Type getTypeFor(String paramName); - - boolean checkIfCompatible(String paramName, Type type); - - boolean checkIfCompatible(String paramName, Object object); - - public Set> entrySet(); - - public int size(); - -} \ No newline at end of file diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/TypeUtils.java b/wsdef/src/main/java/com/google/gson/webservice/definition/TypeUtils.java deleted file mode 100644 index 108a6d4a..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/TypeUtils.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Copied from com.google.gson.TypeUtils -package com.google.gson.webservice.definition; - -import java.lang.reflect.Array; -import java.lang.reflect.GenericArrayType; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; - -/** - * Utility class containing some methods for obtaining information on types. - * - * @author Inderjeet Singh - * @author Joel Leitch - */ -final class TypeUtils { - - /** - * Returns the actual type matching up with the first type variable. - * So, for a {@code typeInfo} instance defined as: - *
-   *   class Foo {
-   *   }
-   *   Type fooType = new TypeToken>() {}.getType();
-   * 
- * TypeUtils.getActualTypeForFirstTypeVariable(fooType) will return Integer.class. - */ - static Type getActualTypeForFirstTypeVariable(Type type) { - if (type instanceof Class) { - return Object.class; - } else if (type instanceof ParameterizedType) { - return ((ParameterizedType)type).getActualTypeArguments()[0]; - } else if (type instanceof GenericArrayType) { - return getActualTypeForFirstTypeVariable(((GenericArrayType)type).getGenericComponentType()); - } else { - throw new IllegalArgumentException("Type \'" + type + "\' is not a Class, " - + "ParameterizedType, or GenericArrayType. Can't extract class."); - } - } - - static boolean isArray(Type type) { - if (type instanceof Class) { - return ((Class)type).isArray(); - } else if (type instanceof GenericArrayType) { - return true; - } else { - return false; - } - } - - /** - * This method returns the actual raw class associated with the specified type. - */ - static Class toRawClass(Type type) { - if (type instanceof Class) { - return (Class) type; - } else if (type instanceof ParameterizedType) { - ParameterizedType actualType = (ParameterizedType)type; - return toRawClass(actualType.getRawType()); - } else if (type instanceof GenericArrayType) { - GenericArrayType actualType = (GenericArrayType) type; - Class rawClass = toRawClass(actualType.getGenericComponentType()); - return wrapWithArray(rawClass); - } else { - throw new IllegalArgumentException("Type \'" + type + "\' is not a Class, " - + "ParameterizedType, or GenericArrayType. Can't extract class."); - } - } - - static Class wrapWithArray(Class rawClass) { - return Array.newInstance(rawClass, 0).getClass(); - } - - private TypeUtils() { - // Class with just some static utility methods, should not be instantiated - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/TypedKey.java b/wsdef/src/main/java/com/google/gson/webservice/definition/TypedKey.java deleted file mode 100644 index fd46576f..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/TypedKey.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - -import com.google.gson.webservice.definition.internal.utils.Preconditions; - -/** - * A typed key for use in a {@link ParamMap} or a {@link ParamMapSpec}. - * - * @author inder - * - * @param Intended type of the content for the key - */ -public class TypedKey { - private final String name; - private final Class classOfT; - - public TypedKey(String name, Class classOfT) { - Preconditions.checkNotNull(name); - Preconditions.checkNotNull(classOfT); - - this.name = name; - this.classOfT = classOfT; - } - - public String getName() { - return name; - } - - public Class getClassOfT() { - return classOfT; - } - - - @Override - public int hashCode() { - return name.hashCode() + classOfT.getCanonicalName().hashCode() >> 1; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - TypedKey other = (TypedKey) obj; - return name.equals(other.name) && classOfT.equals(other.classOfT); - } - - @Override - public String toString() { - return String.format("{name:%s, classOfT:%s}", name, classOfT); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/Util.java b/wsdef/src/main/java/com/google/gson/webservice/definition/Util.java deleted file mode 100644 index 3e989eae..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/Util.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - -import java.lang.reflect.Type; -import java.util.Map; - -final class Util { - private Util() { } - - public static boolean isAssignableFrom(Type typeOfValue, Type expectedType) { - return typeOfValue.equals(expectedType); - } - - public static String toStringMapKeys(Map map) { - StringBuilder sb = new StringBuilder("["); - boolean first = true; - for (Map.Entry entry : map.entrySet()) { - if (first) { - first = false; - } else { - sb.append(","); - } - sb.append(entry.getKey()); - } - sb.append("]"); - return sb.toString(); - } - - public static String toStringMapOfTypes(Map map) { - StringBuilder sb = new StringBuilder("["); - boolean first = true; - for (Map.Entry entry : map.entrySet()) { - if (first) { - first = false; - } else { - sb.append(","); - } - sb.append(entry.getKey()).append(":"); - Class clazz = (Class) entry.getValue(); - sb.append(clazz.getSimpleName()); - } - sb.append("]"); - return sb.toString(); - } - - public static String toStringMap(Map map) { - StringBuilder sb = new StringBuilder("["); - boolean first = true; - for (Map.Entry entry : map.entrySet()) { - if (first) { - first = false; - } else { - sb.append(","); - } - sb.append(entry.getKey()).append(":").append(entry.getValue()); - } - sb.append("]"); - return sb.toString(); - } - -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceSystemException.java b/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceSystemException.java deleted file mode 100644 index e183757d..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceSystemException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - -/** - * Base class for all exceptions thrown by the Web service to indicate a system error condition. - * This should never be thrown to indicate bad user input. - * - * @author inder - */ -public class WebServiceSystemException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public WebServiceSystemException(Exception cause) { - super(cause); - } - - public WebServiceSystemException(String msg, Exception cause) { - super(msg, cause); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Pair.java b/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Pair.java deleted file mode 100644 index d3454d8d..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Pair.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.internal.utils; - -/** - * A simple object that holds onto a pair of object references, first and second. - * - * @author Inderjeet Singh - * - * @param - * @param - */ -public final class Pair { - - public final FIRST first; - public final SECOND second; - - public Pair(FIRST first, SECOND second) { - this.first = first; - this.second = second; - } - - public static Pair create(F first, S second) { - return new Pair(first, second); - } - - @Override - public int hashCode() { - return 17 * ((first != null) ? first.hashCode() : 0) - + 17 * ((second != null) ? second.hashCode() : 0); - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof Pair)) { - return false; - } - - Pair that = (Pair) o; - return equal(this.first, that.first) && equal(this.second, that.second); - } - - private static boolean equal(Object a, Object b) { - return a == b || (a != null && a.equals(b)); - } - - @Override - public String toString() { - return String.format("{%s,%s}", first, second); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Preconditions.java b/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Preconditions.java deleted file mode 100644 index 547f79bd..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Preconditions.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.internal.utils; - -public final class Preconditions { - - public static void checkArgument(boolean condition) { - if (!condition) { - throw new IllegalArgumentException(); - } - } - - public static void checkArgument(boolean condition, String msg, Object... msgArgs) { - if (!condition) { - throw new IllegalArgumentException(String.format(msg, msgArgs)); - } - } - - public static void checkNotNull(Object obj) { - if (obj == null) { - throw new IllegalArgumentException(); - } - } - - public static void checkNotNull(Object obj, String msg, Object... msgArgs) { - if (obj == null) { - throw new IllegalArgumentException(String.format(msg, msgArgs)); - } - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBody.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBody.java deleted file mode 100644 index 44a0c82f..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBody.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import com.google.gson.webservice.definition.ContentBody; -import com.google.gson.webservice.definition.ParamMap; -import com.google.gson.webservice.definition.TypedKey; -import com.google.gson.webservice.definition.ParamMap.Builder; - -import java.lang.reflect.Type; -import java.util.Map; - -/** - * Definition of the request body of a {@link WebServiceCall}. The request body is what is sent out - * in the output stream of the request (for example, with - * {@link java.net.HttpURLConnection#getOutputStream()}) , and is read by the - * javax.servlet.http.HttpServletRequest#getInputStream(). - * This class omits the default constructor for use by Gson. Instead the user must use - * {@link com.google.gson.webservice.definition.procedural.RequestBodyGsonConverter} - * - * @author inder - */ -public final class RequestBody extends ContentBody { - - public static class Builder extends ParamMap.Builder { - - public Builder(RequestBodySpec spec) { - super(spec); - } - - @Override - public Builder put(String paramName, Object content) { - return (Builder) super.put(paramName, content); - } - - @Override - public Builder put(String paramName, Object content, Type typeOfContent) { - return (Builder) super.put(paramName, content, typeOfContent); - } - - @Override - public Builder put(TypedKey paramKey, T param) { - return (Builder) super.put(paramKey, param); - } - - public RequestBody build() { - return new RequestBody(spec, contents); - } - } - - private RequestBody(RequestBodySpec spec, Map contents) { - super(spec, contents); - } - - @Override - public RequestBodySpec getSpec() { - return (RequestBodySpec) spec; - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodyGsonConverter.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodyGsonConverter.java deleted file mode 100644 index f817617e..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodyGsonConverter.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import java.lang.reflect.Type; -import java.util.Map; - -import com.google.gson.InstanceCreator; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -/** - * Gson type adapter for {@link RequestBody}. - * - * @author inder - */ -public class RequestBodyGsonConverter implements JsonSerializer, - JsonDeserializer, InstanceCreator { - - private final RequestBodySpec spec; - - public RequestBodyGsonConverter(RequestBodySpec spec) { - this.spec = spec; - } - - @Override - public JsonElement serialize(RequestBody src, Type typeOfSrc, - JsonSerializationContext context) { - JsonObject root = new JsonObject(); - for(Map.Entry entry : src.entrySet()) { - String key = entry.getKey(); - Type entryType = src.getSpec().getTypeFor(key); - JsonElement value = context.serialize(entry.getValue(), entryType); - root.add(key, value); - } - return root; - } - - @Override - public RequestBody deserialize(JsonElement json, Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - RequestBody.Builder builder = new RequestBody.Builder(spec); - for (Map.Entry entry : json.getAsJsonObject().entrySet()) { - String key = entry.getKey(); - Type entryType = spec.getTypeFor(key); - Object value = context.deserialize(entry.getValue(), entryType); - builder.put(key, value); - } - return builder.build(); - } - - @Override - public RequestBody createInstance(Type type) { - return new RequestBody.Builder(spec).build(); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodySpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodySpec.java deleted file mode 100644 index 6f835fcc..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodySpec.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - - -import com.google.gson.webservice.definition.ContentBodySpec; - -import java.lang.reflect.Type; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Specification of a {@link RequestBody}. - * - * @author inder - */ -public final class RequestBodySpec extends ContentBodySpec { - - public static class Builder { - private final Map paramsSpec = new LinkedHashMap(); - public Builder add(String paramName, Type type) { - paramsSpec.put(paramName, type); - return this; - } - - public RequestBodySpec build() { - RequestBodySpec spec = new RequestBodySpec(paramsSpec); - return spec; - } - } - - public RequestBodySpec(Map paramsSpec) { - super(paramsSpec); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestSpec.java deleted file mode 100644 index 3520cc86..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestSpec.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.internal.utils.Preconditions; - -/** - * Specification for a {@link WebServiceRequest}. - * - * @author inder - */ -public final class RequestSpec { - - private final HeaderMapSpec headersSpec; - private final RequestBodySpec bodySpec; - - public RequestSpec(HeaderMapSpec headersSpec, RequestBodySpec bodySpec) { - Preconditions.checkNotNull(headersSpec); - Preconditions.checkNotNull(bodySpec); - - this.headersSpec = headersSpec; - this.bodySpec = bodySpec; - } - - public HeaderMapSpec getHeadersSpec() { - return headersSpec; - } - - public RequestBodySpec getBodySpec() { - return bodySpec; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("{headersSpec:"); - sb.append(headersSpec).append(",bodySpec:"); - sb.append(bodySpec).append("}"); - return sb.toString(); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBody.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBody.java deleted file mode 100644 index 5a0f4bb3..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBody.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import com.google.gson.webservice.definition.ContentBody; -import com.google.gson.webservice.definition.ParamMap; -import com.google.gson.webservice.definition.TypedKey; - -import java.lang.reflect.Type; -import java.util.Map; - -/** - * body of the response. This is written out as JSON to be sent out to the client. - * This class omits the default constructor for use by Gson. Instead the user must use - * {@link com.google.gson.webservice.definition.procedural.ResponseBodyGsonConverter} - * - * @author inder - */ -public final class ResponseBody extends ContentBody { - - public static class Builder extends ParamMap.Builder { - - public Builder(ResponseBodySpec spec) { - super(spec); - } - - @Override - public Builder put(String paramName, Object content) { - return (Builder) super.put(paramName, content); - } - - @Override - public Builder put(String paramName, Object content, Type typeOfContent) { - return (Builder) super.put(paramName, content, typeOfContent); - } - - @Override - public Builder put(TypedKey paramKey, T param) { - return (Builder) super.put(paramKey, param); - } - - public ResponseBody build() { - return new ResponseBody(spec, contents); - } - } - - private ResponseBody(ResponseBodySpec spec, Map contents) { - super(spec, contents); - } - - @Override - public ResponseBodySpec getSpec() { - return (ResponseBodySpec) spec; - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodyGsonConverter.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodyGsonConverter.java deleted file mode 100644 index ccdb25e1..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodyGsonConverter.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import java.lang.reflect.Type; -import java.util.Map; - -import com.google.gson.InstanceCreator; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -/** - * Gson type adapter for {@link ResponseBody}. - * - * @author inder - */ -public final class ResponseBodyGsonConverter implements JsonSerializer, - JsonDeserializer, InstanceCreator { - - private final ResponseBodySpec spec; - - public ResponseBodyGsonConverter(ResponseBodySpec spec) { - this.spec = spec; - } - - @Override - public JsonElement serialize(ResponseBody src, Type typeOfSrc, - JsonSerializationContext context) { - JsonObject root = new JsonObject(); - for(Map.Entry entry : src.entrySet()) { - String key = entry.getKey(); - Type entryType = src.getSpec().getTypeFor(key); - JsonElement value = context.serialize(entry.getValue(), entryType); - root.add(key, value); - } - return root; - } - - @Override - public ResponseBody deserialize(JsonElement json, Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - ResponseBody.Builder responseBodyBuilder = new ResponseBody.Builder(spec); - for (Map.Entry entry : json.getAsJsonObject().entrySet()) { - String key = entry.getKey(); - Type entryType = spec.getTypeFor(key); - Object value = context.deserialize(entry.getValue(), entryType); - responseBodyBuilder.put(key, value, entryType); - } - return responseBodyBuilder.build(); - } - - @Override - public ResponseBody createInstance(Type type) { - return new ResponseBody.Builder(spec).build(); - } -} \ No newline at end of file diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodySpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodySpec.java deleted file mode 100644 index 2b3022e2..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodySpec.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import com.google.gson.webservice.definition.ContentBodySpec; - -import java.lang.reflect.Type; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Specification of a {@link ResponseBody}. - * - * @author inder - */ -public final class ResponseBodySpec extends ContentBodySpec { - - public static class Builder { - private final Map paramsSpec = new LinkedHashMap(); - public Builder add(String paramName, Type type) { - paramsSpec.put(paramName, type); - return this; - } - - public ResponseBodySpec build() { - ResponseBodySpec spec = new ResponseBodySpec(paramsSpec); - return spec; - } - } - - public ResponseBodySpec(Map paramsSpec) { - super(paramsSpec); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseSpec.java deleted file mode 100644 index 9ecc4d43..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseSpec.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.internal.utils.Preconditions; - -/** - * Specification for a {@link WebServiceResponse}. - * - * @author inder - */ -public final class ResponseSpec { - private final HeaderMapSpec headersSpec; - private final ResponseBodySpec bodySpec; - - public ResponseSpec(HeaderMapSpec headersSpec, ResponseBodySpec bodySpec) { - Preconditions.checkNotNull(headersSpec); - Preconditions.checkNotNull(bodySpec); - - this.headersSpec = headersSpec; - this.bodySpec = bodySpec; - } - - public ResponseBodySpec getBodySpec() { - return bodySpec; - } - - public HeaderMapSpec getHeadersSpec() { - return headersSpec; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("{headersSpec:"); - sb.append(headersSpec).append(",bodySpec:"); - sb.append(bodySpec).append("}"); - return sb.toString(); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCall.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCall.java deleted file mode 100644 index faa8f476..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCall.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - - -/** - * The data associated with a Web service call. This includes http request header parameters (form - * and URL parameters), {@link RequestBody}, response header parameters, and {@link ResponseBody}. - * - * @author inder - */ -public final class WebServiceCall { - - private final WebServiceCallSpec callSpec; - private final WebServiceRequest request; - private final WebServiceResponse response; - - public WebServiceCall(WebServiceCallSpec callSpec, WebServiceRequest request, - WebServiceResponse response) { - this.callSpec = callSpec; - this.request = request; - this.response = response; - } - - public WebServiceCallSpec getSpec() { - return callSpec; - } - - public WebServiceRequest getRequest() { - return request; - } - - public WebServiceResponse getResponse() { - return response; - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCallSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCallSpec.java deleted file mode 100644 index 693ad74f..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCallSpec.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import com.google.gson.webservice.definition.CallPath; -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.TypedKey; -import com.google.gson.webservice.definition.internal.utils.Preconditions; - -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * Specification for a Json web service call. The call includes the relative path where the call - * is available, the specification of requests, and responses. - * - * @author inder - */ -public final class WebServiceCallSpec { - - public static final WebServiceCallSpec NULL_SPEC = new Builder(new CallPath("")).build(); - - public static class Builder { - private final CallPath callPath; - private final Set supportedHttpMethods = new LinkedHashSet(); - private final HeaderMapSpec.Builder reqParamsSpecBuilder = new HeaderMapSpec.Builder(); - private final RequestBodySpec.Builder reqBodySpecBuilder = new RequestBodySpec.Builder(); - private final HeaderMapSpec.Builder resParamsSpecBuilder = new HeaderMapSpec.Builder(); - private final ResponseBodySpec.Builder resBodySpecBuilder = new ResponseBodySpec.Builder(); - - public Builder(CallPath callPath) { - this.callPath = callPath; - } - - /** - * If this method is not invoked, then it is assumed that the WebServiceCall supports all - * methods specified in {@link HttpMethod#values()}. - * - * @param httpMethods list of methods that this call supports. - * @return self to follow the Builder pattern. - */ - public Builder supportsHttpMethod(HttpMethod... httpMethods) { - supportedHttpMethods.addAll(Arrays.asList(httpMethods)); - return this; - } - - public Builder addRequestParam(TypedKey param) { - reqParamsSpecBuilder.put(param.getName(), param.getClassOfT()); - return this; - } - - public Builder addRequestBodyParam(TypedKey param) { - reqBodySpecBuilder.add(param.getName(), param.getClassOfT()); - return this; - } - - public Builder addResponseParam(TypedKey param) { - resParamsSpecBuilder.put(param.getName(), param.getClassOfT()); - return this; - } - - public Builder addResponseBodyParam(TypedKey param) { - resBodySpecBuilder.add(param.getName(), param.getClassOfT()); - return this; - } - - public WebServiceCallSpec build() { - if (supportedHttpMethods.isEmpty()) { - supportedHttpMethods.addAll(Arrays.asList(HttpMethod.values())); - } - RequestSpec requestSpec = - new RequestSpec(reqParamsSpecBuilder.build(), reqBodySpecBuilder.build()); - ResponseSpec responseSpec = - new ResponseSpec(resParamsSpecBuilder.build(), resBodySpecBuilder.build()); - WebServiceCallSpec callSpec = new WebServiceCallSpec(supportedHttpMethods, callPath, - requestSpec, responseSpec); - return callSpec; - } - } - - private final Set supportedHttpMethods; - private final CallPath path; - private final ResponseSpec responseSpec; - private final RequestSpec requestSpec; - - private WebServiceCallSpec(Set supportedHttpMethods, CallPath path, - RequestSpec requestSpec, ResponseSpec responseSpec) { - Preconditions.checkArgument(!supportedHttpMethods.isEmpty()); - Preconditions.checkNotNull(path); - - this.supportedHttpMethods = supportedHttpMethods; - this.path = path; - this.requestSpec = requestSpec; - this.responseSpec = responseSpec; - } - - public CallPath getPath() { - return path; - } - - public Set getSupportedHttpMethods() { - return supportedHttpMethods; - } - - public ResponseSpec getResponseSpec() { - return responseSpec; - } - - public RequestSpec getRequestSpec() { - return requestSpec; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("{path:"); - sb.append(path).append(",supportedHttpMethods:["); - boolean first = true; - for (HttpMethod method : supportedHttpMethods) { - if (first) { - first = false; - } else { - sb.append(","); - } - sb.append(method); - } - sb.append("],requestSpec:").append(requestSpec); - sb.append(",responseSpec:").append(responseSpec).append("}"); - return sb.toString(); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceRequest.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceRequest.java deleted file mode 100644 index b5db7852..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceRequest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import com.google.gson.webservice.definition.ContentBodySpec; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.TypedKey; - -/** - * The data associated with a Web service request. This includes HTTP request header parameters - * (form and URL parameters), and {@link RequestBody}. - * - * @author inder - */ -public final class WebServiceRequest { - private final HttpMethod method; - private final HeaderMap headers; - private final RequestBody body; - private final RequestSpec spec; - - public WebServiceRequest(HttpMethod method, HeaderMap requestHeaders, RequestBody requestBody) { - this.method = method; - this.body = requestBody; - this.headers = requestHeaders; - this.spec = new RequestSpec(requestHeaders.getSpec(), requestBody.getSpec()); - } - - public HttpMethod getMethod() { - return method; - } - - public RequestSpec getSpec() { - return spec; - } - - public HttpMethod getHttpMethod() { - return method; - } - - public RequestBody getBody() { - return body; - } - - public HeaderMap getHeaders() { - return headers; - } - - public String getContentType() { - return ContentBodySpec.JSON_CONTENT_TYPE; - } - - public T getHeader(TypedKey headerKey) { - return headers.get(headerKey); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("{"); - sb.append(method).append(","); - sb.append(",headers:").append(headers); - sb.append(",body:").append(body); - sb.append("}"); - return sb.toString(); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceResponse.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceResponse.java deleted file mode 100644 index 66132ef0..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceResponse.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.TypedKey; - -import java.lang.reflect.Type; - -/** - * The data associated with a Web service response. This includes http response header parameters, - * and {@link ResponseBody}. - * - * @author inder - */ -public final class WebServiceResponse { - - private final HeaderMap headers; - private final ResponseBody body; - private final ResponseSpec spec; - - public static class Builder { - private final HeaderMap.Builder headers; - private final ResponseBody.Builder body; - private final ResponseSpec spec; - - public Builder(ResponseSpec spec) { - this.spec = spec; - headers = new HeaderMap.Builder(spec.getHeadersSpec()); - body = new ResponseBody.Builder(spec.getBodySpec()); - } - - public Builder putHeader(String paramName, Object content) { - headers.put(paramName, content); - return this; - } - - public Builder putHeader(String paramName, Object content, Type typeOfContent) { - headers.put(paramName, content, typeOfContent); - return this; - } - - public Builder putBody(TypedKey paramName, T content) { - return putBody(paramName.getName(), content); - } - - public Builder putBody(String paramName, Object content) { - body.put(paramName, content); - return this; - } - - public Builder put(String paramName, Object content, Type typeOfContent) { - body.put(paramName, content, typeOfContent); - return this; - } - - public WebServiceResponse build() { - return new WebServiceResponse(spec, headers.build(), body.build()); - } - } - - private WebServiceResponse(ResponseSpec spec, HeaderMap headers, ResponseBody body) { - this.spec = spec; - this.headers = headers; - this.body = body; - } - - public WebServiceResponse(HeaderMap responseHeaders, ResponseBody responseBody) { - this.spec = new ResponseSpec(responseHeaders.getSpec(), responseBody.getSpec()); - this.headers = responseHeaders; - this.body = responseBody; - } - - public ResponseSpec getSpec() { - return spec; - } - - public HeaderMap getHeaders() { - return headers; - } - - public ResponseBody getBody() { - return body; - } - - @SuppressWarnings("unchecked") - public T getHeader(String headerName) { - return (T) headers.get(headerName); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("{headers:"); - sb.append(headers); - sb.append(",body:").append(body); - sb.append("}"); - return sb.toString(); - } -} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceSpec.java deleted file mode 100644 index 7cd5d899..00000000 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceSpec.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition.procedural; - -import com.google.gson.webservice.definition.CallPathMap; - -/** - * Specification of the Web service. This contains a specification of all the - * {@link WebServiceCall}s supported by this Web service. - * - * @author inder - */ -public interface WebServiceSpec { - public CallPathMap getCalls(); -} diff --git a/wsdef/src/test/java/com/google/gson/rest/definition/IdTest.java b/wsdef/src/test/java/com/google/gson/rest/definition/IdTest.java deleted file mode 100644 index 9a2e72bd..00000000 --- a/wsdef/src/test/java/com/google/gson/rest/definition/IdTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import java.lang.reflect.ParameterizedType; - -import junit.framework.TestCase; - -import com.google.gson.reflect.TypeToken; -import com.google.gson.rest.definition.ValueBasedId; - -/** - * Unit test for {@link ValueBasedId} - * - * @author inder - */ -public class IdTest extends TestCase { - - public void testRawTypeNotEqualToParameterizedOfConcreteType() { - ParameterizedType type = (ParameterizedType) new TypeToken>(){}.getType(); - assertFalse(ValueBasedId.areEquivalentTypes(type, ValueBasedId.class)); - } - - public void testRawTypeEqualToParameterizedOfWildcardType() { - ParameterizedType fooType = (ParameterizedType) new TypeToken>(){}.getType(); - assertTrue(ValueBasedId.areEquivalentTypes(fooType, ValueBasedId.class)); - } - - public void testStaticEquals() { - ValueBasedId id1 = ValueBasedId.get(3L, Foo.class); - ValueBasedId id2 = ValueBasedId.get(3L, Foo.class); - ValueBasedId id3 = ValueBasedId.get(4L, Foo.class); - assertTrue(ValueBasedId.equals(id1, id2)); - assertFalse(ValueBasedId.equals(null, id2)); - assertFalse(ValueBasedId.equals(id1, null)); - assertTrue(ValueBasedId.equals(null, null)); - assertFalse(ValueBasedId.equals(id1, id3)); - } - - private static class Foo { - } -} diff --git a/wsdef/src/test/java/com/google/gson/rest/definition/IdTypeAdapterTest.java b/wsdef/src/test/java/com/google/gson/rest/definition/IdTypeAdapterTest.java deleted file mode 100644 index 98f4b5ea..00000000 --- a/wsdef/src/test/java/com/google/gson/rest/definition/IdTypeAdapterTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.rest.definition; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import junit.framework.TestCase; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.google.gson.rest.definition.ValueBasedId; - -/** - * Unit tests for {@link ValueBasedId.GsonTypeAdapter} - * - * @author inder - */ -public class IdTypeAdapterTest extends TestCase { - private static final ValueBasedId STUDENT1_ID = ValueBasedId.get(5L, Student.class); - private static final ValueBasedId STUDENT2_ID = ValueBasedId.get(6L, Student.class); - private static final Student STUDENT1 = new Student(STUDENT1_ID, "first"); - private static final Student STUDENT2 = new Student(STUDENT2_ID, "second"); - private static final Type TYPE_COURSE_HISTORY = - new TypeToken>(){}.getType(); - private static final ValueBasedId> COURSE_ID = ValueBasedId.get(10L, TYPE_COURSE_HISTORY); - - private Gson gson; - private Course course; - - @Override - protected void setUp() { - gson = new GsonBuilder() - .registerTypeAdapter(ValueBasedId.class, new ValueBasedId.GsonTypeAdapter()) - .create(); - course = new Course(COURSE_ID, 4, - new Assignment(null, null), createList(STUDENT1, STUDENT2)); - } - - public void testSerializeId() { - String json = gson.toJson(course, TYPE_COURSE_HISTORY); - assertTrue(json.contains(String.valueOf(COURSE_ID.getValue()))); - assertTrue(json.contains(String.valueOf(STUDENT1_ID.getValue()))); - assertTrue(json.contains(String.valueOf(STUDENT2_ID.getValue()))); - } - - public void testDeserializeId() { - String json = "{courseId:1,students:[{id:1,name:'first'},{id:6,name:'second'}]," - + "numAssignments:4,assignment:{}}"; - Course target = gson.fromJson(json, TYPE_COURSE_HISTORY); - assertEquals(1, target.getStudents().get(0).id.getValue()); - assertEquals(6, target.getStudents().get(1).id.getValue()); - assertEquals(1, target.getId().getValue()); - } - - @SuppressWarnings("unused") - private static class Student { - ValueBasedId id; - String name; - - private Student() { - this(null, null); - } - public Student(ValueBasedId id, String name) { - this.id = id; - this.name = name; - } - } - @SuppressWarnings("unused") - private static class Course { - final List students; - private final ValueBasedId> courseId; - private final int numAssignments; - private final Assignment assignment; - - private Course() { - this(null, 0, null, new ArrayList()); - } - - public Course(ValueBasedId> courseId, int numAssignments, - Assignment assignment, List players) { - this.courseId = courseId; - this.numAssignments = numAssignments; - this.assignment = assignment; - this.students = players; - } - public ValueBasedId> getId() { - return courseId; - } - List getStudents() { - return students; - } - } - - @SuppressWarnings("unused") - private static class Assignment { - private final ValueBasedId> id; - private final T data; - - private Assignment() { - this(null, null); - } - public Assignment(ValueBasedId> id, T data) { - this.id = id; - this.data = data; - } - } - - @SuppressWarnings("unused") - private static class HistoryCourse { - int numClasses; - } - - private static List createList(T ...items) { - return Arrays.asList(items); - } -} diff --git a/wsdef/src/test/java/com/google/gson/webservice/definition/CallPathTest.java b/wsdef/src/test/java/com/google/gson/webservice/definition/CallPathTest.java deleted file mode 100644 index eae6d6db..00000000 --- a/wsdef/src/test/java/com/google/gson/webservice/definition/CallPathTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.webservice.definition; - -import com.google.gson.rest.definition.ID; - -import junit.framework.TestCase; - -/** - * Unit test for {@link CallPath} - * - * @author inder - */ -public class CallPathTest extends TestCase { - - public void testVersionIsSkipped() { - CallPath path = new CallPath("/1.0/rest/service1"); - assertEquals("/rest/service1", path.get()); - assertEquals(1D, path.getVersion()); - assertEquals(ID.INVALID_ID, path.getResourceId()); - } - - public void testVersionNotPresent() { - CallPath path = new CallPath("/rest/service1"); - assertEquals("/rest/service1", path.get()); - assertEquals(CallPath.IGNORE_VERSION, path.getVersion()); - assertEquals(ID.INVALID_ID, path.getResourceId()); - } - - public void testResourceIdPresent() { - CallPath path = new CallPath("/rest/service/3"); - assertEquals("/rest/service", path.get()); - assertEquals(3L, path.getResourceId()); - } - - public void testResourceIdWithEndSlashPresent() { - CallPath path = new CallPath("/rest/service/3/"); - assertEquals("/rest/service", path.get()); - assertEquals(3L, path.getResourceId()); - } - - public void testVersionAndResourceIdPresent() { - CallPath path = new CallPath("/3.1/rest/service53/323222"); - assertEquals(3.1D, path.getVersion()); - assertEquals("/rest/service53", path.get()); - assertEquals(323222L, path.getResourceId()); - } - - public void testNullPath() { - CallPath path = new CallPath(null); - assertEquals(CallPath.IGNORE_VERSION, path.getVersion()); - assertEquals(ID.INVALID_ID, path.getResourceId()); - assertNull(path.get()); - } - - public void testEmptyPath() { - CallPath path = new CallPath(""); - assertEquals(CallPath.IGNORE_VERSION, path.getVersion()); - assertEquals(ID.INVALID_ID, path.getResourceId()); - assertEquals("", path.get()); - } - - public void testWhiteSpacePath() { - CallPath path = new CallPath("\r\n"); - assertEquals(CallPath.IGNORE_VERSION, path.getVersion()); - assertEquals(ID.INVALID_ID, path.getResourceId()); - assertEquals("\r\n", path.get()); - } -} diff --git a/wsdef/src/test/java/com/google/gson/webservice/definition/TypedKeyTest.java b/wsdef/src/test/java/com/google/gson/webservice/definition/TypedKeyTest.java deleted file mode 100644 index 309f3aa4..00000000 --- a/wsdef/src/test/java/com/google/gson/webservice/definition/TypedKeyTest.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2010 Google Inc. All Rights Reserved. - -package com.google.gson.webservice.definition; - -import junit.framework.TestCase; - -/** - * Unit tests for {@link TypedKey} - * - * @author inder - */ -public class TypedKeyTest extends TestCase { - - public void testEqualsForSameName() { - assertEquals(new TypedKey("name", String.class), - new TypedKey(new String("name"), String.class)); - } - - public void testEqualsFailsForDifferentClasses() { - assertFalse(new TypedKey("name", Object.class).equals( - new TypedKey("name", String.class))); - } -} diff --git a/wsexample/client/pom.xml b/wsexample/client/pom.xml index e2602c00..fe13a865 100644 --- a/wsexample/client/pom.xml +++ b/wsexample/client/pom.xml @@ -56,9 +56,9 @@ compile - com.google.code.gson - wsdef - 0.1 + com.google.code.greaze + greaze-definition + 0.5 compile diff --git a/wsexample/client/src/main/java/com/google/gson/example/client/ExampleClient.java b/wsexample/client/src/main/java/com/google/gson/example/client/ExampleClient.java index 176dc3e7..84790b2d 100644 --- a/wsexample/client/src/main/java/com/google/gson/example/client/ExampleClient.java +++ b/wsexample/client/src/main/java/com/google/gson/example/client/ExampleClient.java @@ -15,6 +15,12 @@ */ package com.google.gson.example.client; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HttpMethod; +import com.google.greaze.definition.webservice.RequestBody; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; +import com.google.greaze.definition.webservice.WebServiceResponse; import com.google.gson.example.model.Cart; import com.google.gson.example.model.LineItem; import com.google.gson.example.model.Order; @@ -22,12 +28,6 @@ import com.google.gson.example.model.TypedKeys; import com.google.gson.example.service.SampleJsonService; import com.google.gson.webservice.client.ServerConfig; import com.google.gson.webservice.client.WebServiceClient; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.procedural.RequestBody; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; -import com.google.gson.webservice.definition.procedural.WebServiceResponse; import java.util.ArrayList; import java.util.List; diff --git a/wsexample/client/src/main/java/com/google/gson/example/rest/client/OrderClient.java b/wsexample/client/src/main/java/com/google/gson/example/rest/client/OrderClient.java index 037224f0..4e39948e 100644 --- a/wsexample/client/src/main/java/com/google/gson/example/rest/client/OrderClient.java +++ b/wsexample/client/src/main/java/com/google/gson/example/rest/client/OrderClient.java @@ -14,6 +14,8 @@ * limitations under the License. */package com.google.gson.example.rest.client; +import com.google.greaze.definition.CallPath; +import com.google.greaze.definition.rest.ValueBasedId; import com.google.gson.Gson; import com.google.gson.example.model.Cart; import com.google.gson.example.model.LineItem; @@ -21,11 +23,9 @@ import com.google.gson.example.model.Order; import com.google.gson.example.model.QueryOrdersByItemName; import com.google.gson.rest.client.ResourceDepotClient; import com.google.gson.rest.client.RestClientStub; -import com.google.gson.rest.definition.ValueBasedId; import com.google.gson.rest.query.client.ResourceQueryClient; import com.google.gson.webservice.client.ServerConfig; import com.google.gson.webservice.client.WebServiceClient; -import com.google.gson.webservice.definition.CallPath; import java.util.ArrayList; import java.util.List; diff --git a/wsexample/definition/pom.xml b/wsexample/definition/pom.xml index 13ca6fad..a77122f5 100644 --- a/wsexample/definition/pom.xml +++ b/wsexample/definition/pom.xml @@ -56,9 +56,9 @@ compile - com.google.code.gson - wsdef - 0.1 + com.google.code.greaze + greaze-definition + 0.5 compile diff --git a/wsexample/definition/src/main/java/com/google/gson/example/model/Cart.java b/wsexample/definition/src/main/java/com/google/gson/example/model/Cart.java index 2f441844..430cb072 100644 --- a/wsexample/definition/src/main/java/com/google/gson/example/model/Cart.java +++ b/wsexample/definition/src/main/java/com/google/gson/example/model/Cart.java @@ -15,8 +15,8 @@ */ package com.google.gson.example.model; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.rest.definition.ValueBasedId; +import com.google.greaze.definition.rest.RestResource; +import com.google.greaze.definition.rest.ValueBasedId; import java.util.List; diff --git a/wsexample/definition/src/main/java/com/google/gson/example/model/Order.java b/wsexample/definition/src/main/java/com/google/gson/example/model/Order.java index 6bf61f67..04d07f40 100644 --- a/wsexample/definition/src/main/java/com/google/gson/example/model/Order.java +++ b/wsexample/definition/src/main/java/com/google/gson/example/model/Order.java @@ -15,8 +15,8 @@ */ package com.google.gson.example.model; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.rest.definition.ValueBasedId; +import com.google.greaze.definition.rest.RestResource; +import com.google.greaze.definition.rest.ValueBasedId; /** * An order diff --git a/wsexample/definition/src/main/java/com/google/gson/example/model/TypedKeys.java b/wsexample/definition/src/main/java/com/google/gson/example/model/TypedKeys.java index bc03fcb7..5345afa2 100644 --- a/wsexample/definition/src/main/java/com/google/gson/example/model/TypedKeys.java +++ b/wsexample/definition/src/main/java/com/google/gson/example/model/TypedKeys.java @@ -15,7 +15,7 @@ */ package com.google.gson.example.model; -import com.google.gson.webservice.definition.TypedKey; +import com.google.greaze.definition.TypedKey; /** * Definition of various constants to be used for parameter names of request and response headers, diff --git a/wsexample/definition/src/main/java/com/google/gson/example/service/SampleJsonService.java b/wsexample/definition/src/main/java/com/google/gson/example/service/SampleJsonService.java index b438f3de..45ab1838 100644 --- a/wsexample/definition/src/main/java/com/google/gson/example/service/SampleJsonService.java +++ b/wsexample/definition/src/main/java/com/google/gson/example/service/SampleJsonService.java @@ -14,10 +14,10 @@ * limitations under the License. */ package com.google.gson.example.service; +import com.google.greaze.definition.CallPath; +import com.google.greaze.definition.HttpMethod; +import com.google.greaze.definition.webservice.WebServiceCallSpec; import com.google.gson.example.model.TypedKeys; -import com.google.gson.webservice.definition.CallPath; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; /** * An example of a web-service definition diff --git a/wsexample/definition/src/main/java/com/google/gson/example/service/ServicePaths.java b/wsexample/definition/src/main/java/com/google/gson/example/service/ServicePaths.java index c8c35842..d09439b3 100644 --- a/wsexample/definition/src/main/java/com/google/gson/example/service/ServicePaths.java +++ b/wsexample/definition/src/main/java/com/google/gson/example/service/ServicePaths.java @@ -15,7 +15,7 @@ */ package com.google.gson.example.service; -import com.google.gson.webservice.definition.CallPath; +import com.google.greaze.definition.CallPath; /** * An enum describing all paths for this service diff --git a/wsexample/server/pom.xml b/wsexample/server/pom.xml index 926e8f7e..2bdf8d0f 100644 --- a/wsexample/server/pom.xml +++ b/wsexample/server/pom.xml @@ -56,9 +56,9 @@ compile - com.google.code.gson - wsdef - 0.1 + com.google.code.greaze + greaze-definition + 0.5 compile diff --git a/wsexample/server/src/main/java/com/google/gson/wsexample/server/MainServlet.java b/wsexample/server/src/main/java/com/google/gson/wsexample/server/MainServlet.java index bd9163b4..ac6f9482 100644 --- a/wsexample/server/src/main/java/com/google/gson/wsexample/server/MainServlet.java +++ b/wsexample/server/src/main/java/com/google/gson/wsexample/server/MainServlet.java @@ -19,7 +19,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.google.gson.webservice.definition.CallPath; +import com.google.greaze.definition.CallPath; /** * An example servlet that receives JSON web-service requests diff --git a/wsexample/server/src/main/java/com/google/gson/wsexample/server/ProcedureDispatcher.java b/wsexample/server/src/main/java/com/google/gson/wsexample/server/ProcedureDispatcher.java index a1b95016..8660fe67 100644 --- a/wsexample/server/src/main/java/com/google/gson/wsexample/server/ProcedureDispatcher.java +++ b/wsexample/server/src/main/java/com/google/gson/wsexample/server/ProcedureDispatcher.java @@ -18,22 +18,22 @@ package com.google.gson.wsexample.server; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.webservice.RequestBody; +import com.google.greaze.definition.webservice.RequestBodyGsonConverter; +import com.google.greaze.definition.webservice.RequestSpec; +import com.google.greaze.definition.webservice.ResponseBody; +import com.google.greaze.definition.webservice.ResponseBodyGsonConverter; +import com.google.greaze.definition.webservice.ResponseSpec; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; +import com.google.greaze.definition.webservice.WebServiceResponse; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.example.model.Cart; import com.google.gson.example.model.Order; import com.google.gson.example.model.TypedKeys; import com.google.gson.example.service.SampleJsonService; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.procedural.RequestBody; -import com.google.gson.webservice.definition.procedural.RequestBodyGsonConverter; -import com.google.gson.webservice.definition.procedural.RequestSpec; -import com.google.gson.webservice.definition.procedural.ResponseBody; -import com.google.gson.webservice.definition.procedural.ResponseBodyGsonConverter; -import com.google.gson.webservice.definition.procedural.ResponseSpec; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; -import com.google.gson.webservice.definition.procedural.WebServiceResponse; import com.google.gson.wsf.server.procedural.RequestReceiver; import com.google.gson.wsf.server.procedural.ResponseSender; diff --git a/wsexample/server/src/main/java/com/google/gson/wsexample/server/RestDispatcher.java b/wsexample/server/src/main/java/com/google/gson/wsexample/server/RestDispatcher.java index 06a43f6d..3e137371 100644 --- a/wsexample/server/src/main/java/com/google/gson/wsexample/server/RestDispatcher.java +++ b/wsexample/server/src/main/java/com/google/gson/wsexample/server/RestDispatcher.java @@ -18,25 +18,25 @@ package com.google.gson.wsexample.server; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.google.greaze.definition.CallPath; +import com.google.greaze.definition.rest.IDFactory; +import com.google.greaze.definition.rest.MetaData; +import com.google.greaze.definition.rest.ResourceMap; +import com.google.greaze.definition.rest.RestCallSpec; +import com.google.greaze.definition.rest.RestRequest; +import com.google.greaze.definition.rest.RestResponse; +import com.google.greaze.definition.rest.ValueBasedId; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.example.model.Cart; import com.google.gson.example.model.Order; import com.google.gson.example.service.ServicePaths; -import com.google.gson.rest.definition.IDFactory; -import com.google.gson.rest.definition.MetaData; -import com.google.gson.rest.definition.ResourceMap; -import com.google.gson.rest.definition.RestCallSpec; -import com.google.gson.rest.definition.RestRequest; -import com.google.gson.rest.definition.RestResponse; -import com.google.gson.rest.definition.ValueBasedId; import com.google.gson.rest.server.Repository; import com.google.gson.rest.server.RepositoryInMemory; import com.google.gson.rest.server.ResponseBuilderMap; import com.google.gson.rest.server.RestRequestReceiver; import com.google.gson.rest.server.RestResponseBuilder; import com.google.gson.rest.server.RestResponseSender; -import com.google.gson.webservice.definition.CallPath; /** * A dispatcher for all the REST requests diff --git a/wsf/pom.xml b/wsf/pom.xml index ff89197a..c05d2f21 100755 --- a/wsf/pom.xml +++ b/wsf/pom.xml @@ -64,9 +64,9 @@ compile - com.google.code.gson - wsdef - 0.1 + com.google.code.greaze + greaze-definition + 0.5 compile diff --git a/wsf/src/main/java/com/google/gson/rest/server/IdMap.java b/wsf/src/main/java/com/google/gson/rest/server/IdMap.java index 3e03b720..8bc99dc6 100644 --- a/wsf/src/main/java/com/google/gson/rest/server/IdMap.java +++ b/wsf/src/main/java/com/google/gson/rest/server/IdMap.java @@ -21,9 +21,9 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; -import com.google.gson.rest.definition.HasId; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.IDFactory; +import com.google.greaze.definition.rest.HasId; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.IDFactory; /** * This class provides a type-safe map to access values associated with Ids diff --git a/wsf/src/main/java/com/google/gson/rest/server/MetaDataMap.java b/wsf/src/main/java/com/google/gson/rest/server/MetaDataMap.java index 38771a88..38465661 100644 --- a/wsf/src/main/java/com/google/gson/rest/server/MetaDataMap.java +++ b/wsf/src/main/java/com/google/gson/rest/server/MetaDataMap.java @@ -18,9 +18,9 @@ package com.google.gson.rest.server; import java.util.HashMap; import java.util.Map; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.MetaData; -import com.google.gson.rest.definition.RestResource; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.MetaData; +import com.google.greaze.definition.rest.RestResource; /** * A map of resources to their MetaData diff --git a/wsf/src/main/java/com/google/gson/rest/server/Repository.java b/wsf/src/main/java/com/google/gson/rest/server/Repository.java index bec767e1..e19fd659 100644 --- a/wsf/src/main/java/com/google/gson/rest/server/Repository.java +++ b/wsf/src/main/java/com/google/gson/rest/server/Repository.java @@ -15,8 +15,8 @@ */ package com.google.gson.rest.server; -import com.google.gson.rest.definition.HasId; -import com.google.gson.rest.definition.ID; +import com.google.greaze.definition.rest.HasId; +import com.google.greaze.definition.rest.ID; /** * An interface for a repository of rest resources. Meant for abstracting the server-side diff --git a/wsf/src/main/java/com/google/gson/rest/server/RepositoryInMemory.java b/wsf/src/main/java/com/google/gson/rest/server/RepositoryInMemory.java index b512aad1..259fbce1 100644 --- a/wsf/src/main/java/com/google/gson/rest/server/RepositoryInMemory.java +++ b/wsf/src/main/java/com/google/gson/rest/server/RepositoryInMemory.java @@ -16,9 +16,9 @@ package com.google.gson.rest.server; import com.google.common.base.Preconditions; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.MetaData; -import com.google.gson.rest.definition.RestResource; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.MetaData; +import com.google.greaze.definition.rest.RestResource; /** * An in-memory map of rest resources diff --git a/wsf/src/main/java/com/google/gson/rest/server/ResponseBuilderMap.java b/wsf/src/main/java/com/google/gson/rest/server/ResponseBuilderMap.java index e4c6b86a..8043b21b 100644 --- a/wsf/src/main/java/com/google/gson/rest/server/ResponseBuilderMap.java +++ b/wsf/src/main/java/com/google/gson/rest/server/ResponseBuilderMap.java @@ -19,9 +19,9 @@ import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestCallSpec; -import com.google.gson.rest.definition.RestResource; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.RestCallSpec; +import com.google.greaze.definition.rest.RestResource; /** * A map of {@link RestCallSpec}, {@link RestResponseBuilder} to help figure out which diff --git a/wsf/src/main/java/com/google/gson/rest/server/RestRequestReceiver.java b/wsf/src/main/java/com/google/gson/rest/server/RestRequestReceiver.java index 7461415d..8be43849 100644 --- a/wsf/src/main/java/com/google/gson/rest/server/RestRequestReceiver.java +++ b/wsf/src/main/java/com/google/gson/rest/server/RestRequestReceiver.java @@ -24,16 +24,16 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HeaderMapSpec; +import com.google.greaze.definition.HttpMethod; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.RestRequest; +import com.google.greaze.definition.rest.RestRequestSpec; +import com.google.greaze.definition.rest.RestResource; import com.google.gson.Gson; import com.google.gson.JsonParseException; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestRequest; -import com.google.gson.rest.definition.RestRequestSpec; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.WebServiceSystemException; /** * Receives and parses a request at the server side on a {@link HttpServletRequest}. diff --git a/wsf/src/main/java/com/google/gson/rest/server/RestResponseBuilder.java b/wsf/src/main/java/com/google/gson/rest/server/RestResponseBuilder.java index 9902fd89..ae9bd7d7 100644 --- a/wsf/src/main/java/com/google/gson/rest/server/RestResponseBuilder.java +++ b/wsf/src/main/java/com/google/gson/rest/server/RestResponseBuilder.java @@ -15,12 +15,12 @@ */ package com.google.gson.rest.server; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestCallSpec; -import com.google.gson.rest.definition.RestRequest; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.rest.definition.RestResponse; -import com.google.gson.webservice.definition.HttpMethod; +import com.google.greaze.definition.HttpMethod; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.RestCallSpec; +import com.google.greaze.definition.rest.RestRequest; +import com.google.greaze.definition.rest.RestResource; +import com.google.greaze.definition.rest.RestResponse; public class RestResponseBuilder> { protected final Repository resources; diff --git a/wsf/src/main/java/com/google/gson/rest/server/RestResponseSender.java b/wsf/src/main/java/com/google/gson/rest/server/RestResponseSender.java index 623dd521..e34dbd67 100644 --- a/wsf/src/main/java/com/google/gson/rest/server/RestResponseSender.java +++ b/wsf/src/main/java/com/google/gson/rest/server/RestResponseSender.java @@ -22,13 +22,13 @@ import java.util.logging.Logger; import javax.servlet.http.HttpServletResponse; +import com.google.greaze.definition.ContentBodySpec; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HeaderMapSpec; +import com.google.greaze.definition.rest.ID; +import com.google.greaze.definition.rest.RestResource; +import com.google.greaze.definition.rest.RestResponse; import com.google.gson.Gson; -import com.google.gson.rest.definition.ID; -import com.google.gson.rest.definition.RestResource; -import com.google.gson.rest.definition.RestResponse; -import com.google.gson.webservice.definition.ContentBodySpec; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HeaderMapSpec; /** * Sends a JSON web service response on {@link HttpServletResponse}. diff --git a/wsf/src/main/java/com/google/gson/wsf/inject/CallPathProvider.java b/wsf/src/main/java/com/google/gson/wsf/inject/CallPathProvider.java index 7f39b9a7..3e74ee0d 100644 --- a/wsf/src/main/java/com/google/gson/wsf/inject/CallPathProvider.java +++ b/wsf/src/main/java/com/google/gson/wsf/inject/CallPathProvider.java @@ -17,7 +17,7 @@ package com.google.gson.wsf.inject; import javax.servlet.http.HttpServletRequest; -import com.google.gson.webservice.definition.CallPath; +import com.google.greaze.definition.CallPath; import com.google.inject.Inject; import com.google.inject.Provider; diff --git a/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/RequestBodySpecProvider.java b/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/RequestBodySpecProvider.java index d68393a8..6bdd987f 100644 --- a/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/RequestBodySpecProvider.java +++ b/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/RequestBodySpecProvider.java @@ -15,8 +15,8 @@ */ package com.google.gson.wsf.inject.server.procedural; -import com.google.gson.webservice.definition.procedural.RequestBodySpec; -import com.google.gson.webservice.definition.procedural.RequestSpec; +import com.google.greaze.definition.webservice.RequestBodySpec; +import com.google.greaze.definition.webservice.RequestSpec; import com.google.inject.Inject; import com.google.inject.Provider; diff --git a/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/RequestSpecProvider.java b/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/RequestSpecProvider.java index 22a87317..495a300e 100644 --- a/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/RequestSpecProvider.java +++ b/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/RequestSpecProvider.java @@ -15,8 +15,8 @@ */ package com.google.gson.wsf.inject.server.procedural; -import com.google.gson.webservice.definition.procedural.RequestSpec; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; +import com.google.greaze.definition.webservice.RequestSpec; +import com.google.greaze.definition.webservice.WebServiceCallSpec; import com.google.inject.Inject; import com.google.inject.Provider; diff --git a/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/WebServiceCallServerProvider.java b/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/WebServiceCallServerProvider.java index b79e4178..02eb3df9 100755 --- a/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/WebServiceCallServerProvider.java +++ b/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/WebServiceCallServerProvider.java @@ -17,11 +17,11 @@ package com.google.gson.wsf.inject.server.procedural; import javax.servlet.http.HttpServletRequest; +import com.google.greaze.definition.webservice.WebServiceCall; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; +import com.google.greaze.definition.webservice.WebServiceResponse; import com.google.gson.Gson; -import com.google.gson.webservice.definition.procedural.WebServiceCall; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; -import com.google.gson.webservice.definition.procedural.WebServiceResponse; import com.google.gson.wsf.server.procedural.RequestReceiver; import com.google.gson.wsf.server.procedural.WebServiceCallServerBuilder; import com.google.inject.Inject; diff --git a/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/WebServiceCallSpecProvider.java b/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/WebServiceCallSpecProvider.java index 51113c57..dbd5bb20 100755 --- a/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/WebServiceCallSpecProvider.java +++ b/wsf/src/main/java/com/google/gson/wsf/inject/server/procedural/WebServiceCallSpecProvider.java @@ -15,9 +15,9 @@ */ package com.google.gson.wsf.inject.server.procedural; -import com.google.gson.webservice.definition.CallPath; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceSpec; +import com.google.greaze.definition.CallPath; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceSpec; import com.google.inject.Inject; import com.google.inject.Provider; diff --git a/wsf/src/main/java/com/google/gson/wsf/server/procedural/RequestReceiver.java b/wsf/src/main/java/com/google/gson/wsf/server/procedural/RequestReceiver.java index a8feec0e..5c24c2b2 100644 --- a/wsf/src/main/java/com/google/gson/wsf/server/procedural/RequestReceiver.java +++ b/wsf/src/main/java/com/google/gson/wsf/server/procedural/RequestReceiver.java @@ -24,16 +24,16 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HeaderMapSpec; +import com.google.greaze.definition.HttpMethod; +import com.google.greaze.definition.WebServiceSystemException; +import com.google.greaze.definition.webservice.RequestBody; +import com.google.greaze.definition.webservice.RequestBodySpec; +import com.google.greaze.definition.webservice.RequestSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; import com.google.gson.Gson; import com.google.gson.JsonParseException; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.HttpMethod; -import com.google.gson.webservice.definition.WebServiceSystemException; -import com.google.gson.webservice.definition.procedural.RequestBody; -import com.google.gson.webservice.definition.procedural.RequestBodySpec; -import com.google.gson.webservice.definition.procedural.RequestSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; /** * Receives and parses a request at the server side on a {@link HttpServletRequest}. diff --git a/wsf/src/main/java/com/google/gson/wsf/server/procedural/ResponseBuilder.java b/wsf/src/main/java/com/google/gson/wsf/server/procedural/ResponseBuilder.java index d3a59a6b..cb223e6c 100644 --- a/wsf/src/main/java/com/google/gson/wsf/server/procedural/ResponseBuilder.java +++ b/wsf/src/main/java/com/google/gson/wsf/server/procedural/ResponseBuilder.java @@ -15,9 +15,9 @@ */ package com.google.gson.wsf.server.procedural; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; -import com.google.gson.webservice.definition.procedural.WebServiceResponse; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; +import com.google.greaze.definition.webservice.WebServiceResponse; /** * An interface describing a class that can build a response diff --git a/wsf/src/main/java/com/google/gson/wsf/server/procedural/ResponseSender.java b/wsf/src/main/java/com/google/gson/wsf/server/procedural/ResponseSender.java index 7afe69d5..5e15727a 100644 --- a/wsf/src/main/java/com/google/gson/wsf/server/procedural/ResponseSender.java +++ b/wsf/src/main/java/com/google/gson/wsf/server/procedural/ResponseSender.java @@ -22,11 +22,11 @@ import java.util.logging.Logger; import javax.servlet.http.HttpServletResponse; +import com.google.greaze.definition.HeaderMap; +import com.google.greaze.definition.HeaderMapSpec; +import com.google.greaze.definition.webservice.ResponseBody; +import com.google.greaze.definition.webservice.WebServiceResponse; import com.google.gson.Gson; -import com.google.gson.webservice.definition.HeaderMap; -import com.google.gson.webservice.definition.HeaderMapSpec; -import com.google.gson.webservice.definition.procedural.ResponseBody; -import com.google.gson.webservice.definition.procedural.WebServiceResponse; /** * Sends a JSON web service response on {@link HttpServletResponse}. diff --git a/wsf/src/main/java/com/google/gson/wsf/server/procedural/WebServiceCallServerBuilder.java b/wsf/src/main/java/com/google/gson/wsf/server/procedural/WebServiceCallServerBuilder.java index b3ba944e..ea3cbdc9 100644 --- a/wsf/src/main/java/com/google/gson/wsf/server/procedural/WebServiceCallServerBuilder.java +++ b/wsf/src/main/java/com/google/gson/wsf/server/procedural/WebServiceCallServerBuilder.java @@ -15,9 +15,9 @@ */ package com.google.gson.wsf.server.procedural; -import com.google.gson.webservice.definition.procedural.WebServiceCallSpec; -import com.google.gson.webservice.definition.procedural.WebServiceRequest; -import com.google.gson.webservice.definition.procedural.WebServiceResponse.Builder; +import com.google.greaze.definition.webservice.WebServiceCallSpec; +import com.google.greaze.definition.webservice.WebServiceRequest; +import com.google.greaze.definition.webservice.WebServiceResponse.Builder; public class WebServiceCallServerBuilder {