cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r916914 - in /cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core: CacheControl.java Response.java
Date Sat, 27 Feb 2010 06:14:53 GMT
Author: bluk
Date: Sat Feb 27 06:14:52 2010
New Revision: 916914

URL: http://svn.apache.org/viewvc?rev=916914&view=rev
Log:
Add JAX-RS Response.Status and ResponseBuilder

Added:
    cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java
      - copied, changed from r916913, cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Response.java
Modified:
    cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Response.java

Copied: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java
(from r916913, cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Response.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java?p2=cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java&p1=cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Response.java&r1=916913&r2=916914&rev=916914&view=diff
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Response.java (original)
+++ cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java Sat
Feb 27 06:14:52 2010
@@ -19,10 +19,6 @@
 
 package javax.ws.rs.core;
 
-public class Response {
-
-    public class ResponseBuilder {
-
-    }
+public class CacheControl {
 
 }

Modified: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Response.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Response.java?rev=916914&r1=916913&r2=916914&view=diff
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Response.java (original)
+++ cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Response.java Sat Feb
27 06:14:52 2010
@@ -19,10 +19,118 @@
 
 package javax.ws.rs.core;
 
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+
 public class Response {
 
-    public class ResponseBuilder {
+    private final static RuntimeDelegate delegate = RuntimeDelegate.getInstance();
+
+    public abstract static class ResponseBuilder {
+        protected ResponseBuilder() {
+            // do nothing
+        }
+
+        public abstract Response build();
+
+        public abstract Response.ResponseBuilder cacheControl(CacheControl value);
+
+        @Override
+        public abstract Response.ResponseBuilder clone();
+
+        public abstract Response.ResponseBuilder contentLocation(URI value);
+
+        public abstract Response.ResponseBuilder cookie(NewCookie... values);
+
+        public abstract Response.ResponseBuilder entity(Object value);
+
+        public abstract Response.ResponseBuilder expires(Date value);
+
+        public abstract Response.ResponseBuilder header(String name, Object value);
+
+        public abstract Response.ResponseBuilder language(Locale value);
+
+        public abstract Response.ResponseBuilder language(String value);
+
+        public abstract Response.ResponseBuilder lastModified(Date value);
+
+        public abstract Response.ResponseBuilder location(URI value);
 
+        protected static Response.ResponseBuilder newInstance() {
+            return delegate.createResponseBuilder();
+        }
+
+        public abstract Response.ResponseBuilder status(int value);
+
+        public Response.ResponseBuilder status(Response.Status value) {
+            return delegate.createResponseBuilder().status(value.getStatusCode());
+        }
+
+        public abstract Response.ResponseBuilder tag(EntityTag value);
+
+        public abstract Response.ResponseBuilder tag(String value);
+
+        public abstract Response.ResponseBuilder type(MediaType value);
+
+        public abstract Response.ResponseBuilder type(String type);
+
+        public abstract Response.ResponseBuilder variant(Variant value);
+
+        public abstract Response.ResponseBuilder variants(List<Variant> values);
     }
 
+    public static enum Status {
+        ACCEPTED(Family.SUCCESSFUL, 202, "Accepted"), BAD_REQUEST(Family.CLIENT_ERROR, 400,
+            "Bad Request"), CONFLICT(Family.CLIENT_ERROR, 409, "Conflict"), CREATED(
+            Family.SUCCESSFUL, 201, "Created"), FORBIDDEN(Family.CLIENT_ERROR, 403, "Forbidden"),
GONE(
+            Family.CLIENT_ERROR, 410, "Gone"), INTERNAL_SERVER_ERROR(Family.SERVER_ERROR,
500,
+            "Internal Server Error"), MOVED_PERMANENTLY(Family.REDIRECTION, 303, "See Other"),
NO_CONTENT(
+            Family.SUCCESSFUL, 204, "No Content"), NOT_ACCEPTABLE(Family.CLIENT_ERROR, 406,
+            "Not Acceptable"), NOT_FOUND(Family.CLIENT_ERROR, 404, "Not Found"), NOT_MODIFIED(
+            Family.REDIRECTION, 304, "Not Modified"), OK(Family.SUCCESSFUL, 200, "OK"), PRECONDITION_FAILED(
+            Family.CLIENT_ERROR, 412, "Precondition Failed"), SEE_OTHER(Family.REDIRECTION,
303,
+            "See Other"), SERVICE_UNAVAILABLE(Family.SERVER_ERROR, 503, "Service Unavailable"),
TEMPORARY_REDIRECT(
+            Family.REDIRECTION, 307, "Temporary Redirect"), UNAUTHORIZED(Family.CLIENT_ERROR,
401,
+            "Unauthorized"), UNSUPPORTED_MEDIA_TYPE(Family.CLIENT_ERROR, 415,
+            "Unsupported Media Type"), ;
+        private final Family family;
+        private final int    statusCode;
+        private final String reasonPhrase;
+
+        private Status(Family family, int statusCode, String reasonPhrase) {
+            this.family = family;
+            this.statusCode = statusCode;
+            this.reasonPhrase = reasonPhrase;
+        }
+
+        public static enum Family {
+            CLIENT_ERROR, INFORMATIONAL, OTHER, REDIRECTION, SERVER_ERROR, SUCCESSFUL
+        }
+
+        public static Status fromStatusCode(int statusCode) {
+            for (Status s : values()) {
+                if (s.getStatusCode() == statusCode) {
+                    return s;
+                }
+            }
+            return null;
+        }
+
+        public int getStatusCode() {
+            return statusCode;
+        }
+
+        public Response.Status.Family getFamily() {
+            return family;
+        }
+
+        @Override
+        public String toString() {
+            return reasonPhrase;
+        }
+    }
 }



Mime
View raw message