clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r897844 - in /incubator/clerezza: issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java...
Date Mon, 11 Jan 2010 12:01:02 GMT
Author: reto
Date: Mon Jan 11 12:01:00 2010
New Revision: 897844

URL: http://svn.apache.org/viewvc?rev=897844&view=rev
Log:
CLEREZZA-48: applayied patch agron, closing (deferring OPTIONS * request to other issue)

Added:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
      - copied unchanged from r897830, incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
Modified:
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExceptionMappingForProvidersTest.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExtendedMediaTypeTest.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponse.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponseToAcceptHeader.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestSourceProvider.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestWriterDeterminedContentType.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/WildcardWriterTest.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/SelectWriterBasedOnAcceptTest.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/WriterAcceptTest.java
    incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/mock/ResponseImpl.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/   (props
changed)
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/WebRequestImpl.java

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java
Mon Jan 11 12:01:00 2010
@@ -43,7 +43,6 @@
 
 import javax.activation.UnsupportedDataTypeException;
 import javax.security.auth.Subject;
-import javax.ws.rs.HttpMethod;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.GenericEntity;
@@ -64,7 +63,6 @@
 import org.wymiwyg.wrhapi.HandlerException;
 import org.wymiwyg.wrhapi.HeaderName;
 import org.wymiwyg.wrhapi.MessageBody;
-import org.wymiwyg.wrhapi.Method;
 import org.wymiwyg.wrhapi.Response;
 import org.wymiwyg.wrhapi.ResponseStatus;
 import org.wymiwyg.wrhapi.util.MessageBody2Write;
@@ -107,22 +105,6 @@
 		}
 		if (entity == null) {
 			response.setHeader(HeaderName.CONTENT_LENGTH, 0);
-
-            String method = request.getMethod();
-            if (method != null && Method.OPTIONS.toString().contains(method)) {
-                List<String> allowed = new ArrayList<String>();
-                for (Annotation annotation : annotations) {
-                    HttpMethod httpMethod = annotation.annotationType().getAnnotation(HttpMethod.class);
-                    String annotationValue;
-                    if (httpMethod != null) {
-                        annotationValue = annotation.annotationType().getSimpleName();
-                        allowed.add(annotationValue);
-                    }
-                }
-                response.setHeader(HeaderName.ALLOW, allowed.toString()
-                        .replace("[", "").replace("]", "").replace(" ", ""));
-            }
-
 			if (responseStatus == ResponseStatus.SUCCESS.getCode()) {
 				response.setResponseStatus(ResponseStatus.NO_CONTENT);
 				flushHeaders(headerMap, response);

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
Mon Jan 11 12:01:00 2010
@@ -38,11 +38,14 @@
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Encoded;
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.ext.MessageBodyReader;
 
 import org.slf4j.Logger;
@@ -55,6 +58,7 @@
 import org.apache.clerezza.triaxrs.util.TemplateEncoder;
 import org.apache.clerezza.triaxrs.util.URITemplate;
 import org.wymiwyg.wrhapi.HandlerException;
+import org.wymiwyg.wrhapi.HeaderName;
 
 /**
  * @scr.component
@@ -528,16 +532,28 @@
 	private ProcessableResponse responsDefaultOption(WebRequest request,
 			Set<Method> candidateMethods) {
         
+		ResponseBuilder builder = Response.ok();
 		List<Annotation> annotationList = new ArrayList<Annotation>();
-        Annotation[] annotations = {};
-        for (Method candidateMethod : candidateMethods){
-            Annotation[] declaredAnnotations = candidateMethod.getDeclaredAnnotations();
-            for (Annotation annotation : declaredAnnotations) {
-                annotationList.add(annotation);
-            }
-        }
-        return ProcessableResponse.createProcessableResponse(null,
-                annotationList.toArray(annotations), null, null, null);
+		for (Method candidateMethod : candidateMethods) {
+			Annotation[] declaredAnnotations = candidateMethod.getDeclaredAnnotations();
+			for (Annotation annotation : declaredAnnotations) {
+				annotationList.add(annotation);
+			}
+		}
+
+		String allowHeader = "";
+		for (Annotation annotation : annotationList) {
+			HttpMethod httpMethod = annotation.annotationType().getAnnotation(HttpMethod.class);
+			if (httpMethod != null) {
+				allowHeader += httpMethod.value()+",";
+			}
+		}
+		if(allowHeader.lastIndexOf(",") != -1){
+			allowHeader = allowHeader.substring(0, allowHeader.lastIndexOf(","));
+		}
+		builder.header(HeaderName.ALLOW.toString(), allowHeader);
+		return ProcessableResponse.createProcessableResponse(builder.build(),
+				null, null, null, null);
 	}
 
 	private String templateUrlEncode(String value) {

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/AutoGeneratedOptionsTest.java
Mon Jan 11 12:01:00 2010
@@ -23,24 +23,20 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-import java.util.Hashtable;
-
+import java.util.Map;
 import javax.ws.rs.GET;
 import javax.ws.rs.HttpMethod;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 
 import javax.ws.rs.Produces;
-import javax.ws.rs.ext.RuntimeDelegate;
 import org.apache.clerezza.triaxrs.JaxRsHandler;
-import org.apache.clerezza.triaxrs.delegate.RuntimeDelegateImpl;
 import org.apache.clerezza.triaxrs.mock.RequestImpl;
 import org.apache.clerezza.triaxrs.mock.RequestURIImpl;
 import org.apache.clerezza.triaxrs.mock.ResponseImpl;
 import org.apache.clerezza.triaxrs.testutils.HandlerCreator;
 
 import org.junit.Assert;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.wymiwyg.wrhapi.HeaderName;
@@ -54,6 +50,8 @@
 	private @interface PROPFIND {
 	}
 
+	@Target(ElementType.METHOD)
+	@Retention(RetentionPolicy.RUNTIME)
 	@HttpMethod("FOO")
 	private @interface TEST {
 	}
@@ -64,12 +62,10 @@
 		@PROPFIND
 		@Produces("*/*")
 		public void propfind() {
-			System.out.println("PROPFIND Method was executed");
 		}
 
 		@POST
 		public void postIt() {
-			System.out.println("PROPFIND Method was executed");
 		}
 
 		@TEST
@@ -83,7 +79,7 @@
 	}
 
 	@Test
-	public void testAutoGeneratedOptions() throws Exception {
+	public void testResponseToOptionsRequest() throws Exception {
 		JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);
 		RequestURIImpl uri = new RequestURIImpl();
 		RequestImpl request = new RequestImpl();
@@ -92,10 +88,13 @@
 		request.setRequestURI(uri);
 		request.setMethod(Method.OPTIONS);
 		handler.handle(request, response);
-		Hashtable<HeaderName, Object> headers = response.getHeaders();
-		Object allowHeader = headers.get(HeaderName.ALLOW);
+		Map<HeaderName,String[]> headers = response.getHeaders();
+		String[] allowHeader = headers.get(HeaderName.ALLOW);
 		Assert.assertNotNull(allowHeader);
-		String allow = allowHeader.toString();
+		String allow = "";
+		for(String st : allowHeader){
+			allow += st;
+		}
 		Assert.assertTrue(allow.contains("PROPFIND"));
 		Assert.assertFalse(allow.contains("GET"));
 		Assert.assertTrue(allow.contains("POST"));
@@ -103,7 +102,7 @@
 	}
 
 	@Test
-	public void testAutoGeneratedOptionsOnSubresource() throws Exception {
+	public void testResponseToOptionsRequestOnSubresource() throws Exception {
 		JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);
 		RequestURIImpl uri = new RequestURIImpl();
 		RequestImpl request = new RequestImpl();
@@ -112,12 +111,16 @@
 		request.setRequestURI(uri);
 		request.setMethod(Method.OPTIONS);
 		handler.handle(request, response);
-		Hashtable<HeaderName, Object> headers = response.getHeaders();
-		Object allowHeader = headers.get(HeaderName.ALLOW);
+		Map<HeaderName,String[]> headers = response.getHeaders();
+		String[] allowHeader = headers.get(HeaderName.ALLOW);
 		Assert.assertNotNull(allowHeader);
-		String allow = allowHeader.toString();
+		String allow = "";
+		for(String st : allowHeader){
+			allow += st;
+		}
 		Assert.assertFalse(allow.contains("PROPFIND"));
 		Assert.assertTrue(allow.contains("GET"));
 		Assert.assertFalse(allow.contains("POST"));
+		Assert.assertFalse(allow.contains("FOO"));
 	}
 }

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExceptionMappingForProvidersTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExceptionMappingForProvidersTest.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExceptionMappingForProvidersTest.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExceptionMappingForProvidersTest.java
Mon Jan 11 12:01:00 2010
@@ -181,7 +181,9 @@
 		assertTrue(exceptionMapperUsed);
 		assertEquals(ResponseStatus.SUCCESS, responseImpl.getStatus());
 		assertEquals(BODY, new String(responseImpl.getBodyBytes()));
-		assertEquals(new Long(BODY.length()), responseImpl.getHeaders().
-				get(HeaderName.CONTENT_LENGTH));
+
+		String[] contentLength = responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH);
+		assertTrue(contentLength.length == 1);
+		assertEquals(new Long(BODY.length()), new Long(contentLength[0]));
 	}
 }

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExtendedMediaTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExtendedMediaTypeTest.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExtendedMediaTypeTest.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/ExtendedMediaTypeTest.java
Mon Jan 11 12:01:00 2010
@@ -110,6 +110,8 @@
 		//replay(responseMock);
 		handler.handle(requestMock, responseImpl);
 		responseImpl.consumeBody();
-		Assert.assertEquals("text/html", responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE));
+		String[] contentType = responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE);
+		Assert.assertTrue(contentType.length == 1);
+        Assert.assertEquals("text/html", contentType[0]);
 	}
 }

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponse.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponse.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponse.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponse.java
Mon Jan 11 12:01:00 2010
@@ -113,7 +113,8 @@
 
 		assertTrue(postMethodInvoked);
 
-		String location = (String) response.getHeaders().get(HeaderName.LOCATION);
-		assertEquals("http://localhost:8000/newresource", location);
+		String[] location = response.getHeaders().get(HeaderName.LOCATION);
+		Assert.assertTrue(location.length == 1);
+		assertEquals("http://localhost:8000/newresource", location[0]);
 	}
 }
\ No newline at end of file

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponseToAcceptHeader.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponseToAcceptHeader.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponseToAcceptHeader.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestResponseToAcceptHeader.java
Mon Jan 11 12:01:00 2010
@@ -76,8 +76,9 @@
         replay(requestURI);
         handler.handle(requestMock, responseImpl);
         responseImpl.consumeBody();
-        Assert.assertEquals("text/plain", 
-                responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE));
+        String[] contentType = responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE);
+		Assert.assertTrue(contentType.length == 1);
+        Assert.assertEquals("text/plain", contentType[0]);
     }
 }
 

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestSourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestSourceProvider.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestSourceProvider.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestSourceProvider.java
Mon Jan 11 12:01:00 2010
@@ -24,8 +24,8 @@
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
 
-import java.util.Hashtable;
 
+import java.util.Map;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -169,13 +169,9 @@
 	}
 
 	private String getContentType() {
-		Hashtable<HeaderName, Object> headers = response.getHeaders();
-		Object object = headers.get(HeaderName.CONTENT_TYPE);
-		if (object instanceof String) {
-			return (String)object;
-		} else {
-			return "foo";
-		}
+		Map<HeaderName,String[]> headers = response.getHeaders();
+		String[] contentType = headers.get(HeaderName.CONTENT_TYPE);
+		return contentType[0];
 	}
 
 	@Test

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestWriterDeterminedContentType.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestWriterDeterminedContentType.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestWriterDeterminedContentType.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/TestWriterDeterminedContentType.java
Mon Jan 11 12:01:00 2010
@@ -104,6 +104,8 @@
 		replay(requestURI);
 		handler.handle(requestMock, responseImpl);
 		responseImpl.consumeBody();
-		Assert.assertEquals("text/html", responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE));
+		String[] contentType = responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE);
+		Assert.assertTrue(contentType.length == 1);
+		Assert.assertEquals("text/html", contentType[0]);
 	}
 }

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/WildcardWriterTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/WildcardWriterTest.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/WildcardWriterTest.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/WildcardWriterTest.java
Mon Jan 11 12:01:00 2010
@@ -139,6 +139,8 @@
 		replay(requestURI);
 		handler.handle(requestMock, responseImpl);
 		responseImpl.consumeBody();
-		Assert.assertEquals("text/html", responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE));
+		String[] contentType = responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE);
+		Assert.assertTrue(contentType.length == 1);
+		Assert.assertEquals("text/html", contentType[0]);
 	}
 }

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/SelectWriterBasedOnAcceptTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/SelectWriterBasedOnAcceptTest.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/SelectWriterBasedOnAcceptTest.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/SelectWriterBasedOnAcceptTest.java
Mon Jan 11 12:01:00 2010
@@ -198,10 +198,12 @@
 		assertTrue(string1Writer.writerCalled);
 		Assert.assertFalse(string2Writer.writerCalled);
 		Assert.assertArrayEquals(entity.getBytes(), responseImpl.getBodyBytes());
-		Assert.assertEquals("test/string1",
-				responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE).toString());
-		Assert.assertEquals(Integer.toString(entity.length()),
-				responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH).toString());
+		String[] contentType = responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE);
+		Assert.assertTrue(contentType.length == 1);
+		Assert.assertEquals("test/string1",contentType[0]);
+		String[] contentLength = responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH);
+		Assert.assertTrue(contentLength.length == 1);
+		Assert.assertEquals(Integer.toString(entity.length()), contentLength[0]);
 		Assert.assertEquals(ResponseStatus.SUCCESS, responseImpl.getStatus());
 
 	}
@@ -227,10 +229,12 @@
 		assertTrue(string2Writer.writerCalled);
 		Assert.assertFalse(string1Writer.writerCalled);
 		Assert.assertArrayEquals(entity.getBytes(), responseImpl.getBodyBytes());
-		Assert.assertEquals("test/string2", 
-				responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE).toString());
-		Assert.assertEquals(Integer.toString(entity.length()),
-				responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH).toString());
+		String[] contentType = responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE);
+		Assert.assertTrue(contentType.length == 1);
+		Assert.assertEquals("test/string2",contentType[0]);
+		String[] contentLength = responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH);
+		Assert.assertTrue(contentLength.length == 1);
+		Assert.assertEquals(Integer.toString(entity.length()), contentLength[0]);
 		Assert.assertEquals(ResponseStatus.SUCCESS, responseImpl.getStatus());
 	}
 
@@ -256,10 +260,12 @@
 		Assert.assertFalse(string1Writer.writerCalled);
 		Assert.assertFalse(stringWildcardWriter.writerCalled);
 		Assert.assertArrayEquals(entity.getBytes(), responseImpl.getBodyBytes());
-		Assert.assertEquals("test/string2",
-				responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE).toString());
-		Assert.assertEquals(Integer.toString(entity.length()),
-				responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH).toString());
+		String[] contentType = responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE);
+		Assert.assertTrue(contentType.length == 1);
+		Assert.assertEquals("test/string2",contentType[0]);
+		String[] contentLength = responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH);
+		Assert.assertTrue(contentLength.length == 1);
+		Assert.assertEquals(Integer.toString(entity.length()), contentLength[0]);
 		Assert.assertEquals(ResponseStatus.SUCCESS, responseImpl.getStatus());
 	}
 
@@ -285,8 +291,9 @@
 		Assert.assertFalse(string1Writer.writerCalled);
 		Assert.assertFalse(string2Writer.writerCalled);
 		Assert.assertArrayEquals(entity.getBytes(), responseImpl.getBodyBytes());
-		Assert.assertEquals(Integer.toString(entity.length()),
-				responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH).toString());
+		String[] contentLength = responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH);
+		Assert.assertTrue(contentLength.length == 1);
+		Assert.assertEquals(Integer.toString(entity.length()), contentLength[0]);
 		Assert.assertEquals(ResponseStatus.SUCCESS, responseImpl.getStatus());
 	}
 	

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/WriterAcceptTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/WriterAcceptTest.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/WriterAcceptTest.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/blackbox/writers/WriterAcceptTest.java
Mon Jan 11 12:01:00 2010
@@ -161,10 +161,13 @@
 		responseImpl.consumeBody();
 		assertTrue(writerCalled);
 		Assert.assertArrayEquals(entity.getBytes(), responseImpl.getBodyBytes());
-		Assert.assertEquals("test/string2", 
-				responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE).toString());
-		Assert.assertEquals(Integer.toString(entity.length()),
-				responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH).toString());
+
+		String[] contentType = responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE);
+		Assert.assertTrue(contentType.length == 1);
+		Assert.assertEquals("test/string2",contentType[0]);
+		String[] contentLength = responseImpl.getHeaders().get(HeaderName.CONTENT_LENGTH);
+		Assert.assertTrue(contentLength.length == 1);
+		Assert.assertEquals(Integer.toString(entity.length()), contentLength[0]);
 		Assert.assertEquals(ResponseStatus.SUCCESS, responseImpl.getStatus());
 	}
 	

Modified: incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/mock/ResponseImpl.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/mock/ResponseImpl.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/mock/ResponseImpl.java
(original)
+++ incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/test/java/org/apache/clerezza/triaxrs/mock/ResponseImpl.java
Mon Jan 11 12:01:00 2010
@@ -23,27 +23,23 @@
 import java.nio.channels.Channels;
 import java.util.Hashtable;
 
+import java.util.Map;
 import org.wymiwyg.wrhapi.HandlerException;
 import org.wymiwyg.wrhapi.HeaderName;
 import org.wymiwyg.wrhapi.MessageBody;
-import org.wymiwyg.wrhapi.Response;
 import org.wymiwyg.wrhapi.ResponseStatus;
+import org.wymiwyg.wrhapi.util.ResponseBase;
 
 /**
  *
  * @author szalay
  */
-public class ResponseImpl implements Response {
+public class ResponseImpl extends ResponseBase {
 
     private Hashtable<HeaderName, Object> headers = new Hashtable<HeaderName, Object>();
     private MessageBody body;
     private ResponseStatus status;
     private byte[] bodyBytes;
-    
-    @Override
-    public void addHeader(HeaderName arg0, Object arg1) throws HandlerException {
-        getHeaders().put(arg0, arg1);
-    }
 
     @Override
     public void setBody(MessageBody arg0) throws HandlerException {
@@ -51,17 +47,12 @@
     }
 
     @Override
-    public void setHeader(HeaderName arg0, Object arg1) throws HandlerException {
-        getHeaders().put(arg0, arg1);
-    }
-
-    @Override
     public void setResponseStatus(ResponseStatus arg0) throws HandlerException {
         this.status = arg0;
     }
 
-    public Hashtable<HeaderName, Object> getHeaders() {
-        return headers;
+    public Map<HeaderName, String[]> getHeaders() {
+        return getHeaderMap();
     }
 
     public MessageBody getBody() {

Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 11 12:01:00 2010
@@ -1 +1,2 @@
 /incubator/clerezza/issues/CLEREZZA-43/org.apache.clerezza.triaxrs:891792-892499
+/incubator/clerezza/issues/CLEREZZA-48/org.apache.clerezza.triaxrs:893435-897830

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/ResponseProcessor.java
Mon Jan 11 12:01:00 2010
@@ -43,6 +43,7 @@
 
 import javax.activation.UnsupportedDataTypeException;
 import javax.security.auth.Subject;
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.GenericEntity;
@@ -63,6 +64,7 @@
 import org.wymiwyg.wrhapi.HandlerException;
 import org.wymiwyg.wrhapi.HeaderName;
 import org.wymiwyg.wrhapi.MessageBody;
+import org.wymiwyg.wrhapi.Method;
 import org.wymiwyg.wrhapi.Response;
 import org.wymiwyg.wrhapi.ResponseStatus;
 import org.wymiwyg.wrhapi.util.MessageBody2Write;
@@ -106,6 +108,21 @@
 		if (entity == null) {
 			response.setHeader(HeaderName.CONTENT_LENGTH, 0);
 
+            String method = request.getMethod();
+            if (method != null && Method.OPTIONS.toString().contains(method)) {
+                List<String> allowed = new ArrayList<String>();
+                for (Annotation annotation : annotations) {
+                    HttpMethod httpMethod = annotation.annotationType().getAnnotation(HttpMethod.class);
+                    String annotationValue;
+                    if (httpMethod != null) {
+                        annotationValue = annotation.annotationType().getSimpleName();
+                        allowed.add(annotationValue);
+                    }
+                }
+                response.setHeader(HeaderName.ALLOW, allowed.toString()
+                        .replace("[", "").replace("]", "").replace(" ", ""));
+            }
+
 			if (responseStatus == ResponseStatus.SUCCESS.getCode()) {
 				response.setResponseStatus(ResponseStatus.NO_CONTENT);
 				flushHeaders(headerMap, response);

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
Mon Jan 11 12:01:00 2010
@@ -27,8 +27,10 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedSet;
@@ -525,7 +527,17 @@
 	
 	private ProcessableResponse responsDefaultOption(WebRequest request,
 			Set<Method> candidateMethods) {
-		throw new UnsupportedOperationException("Not yet implemented");
+        
+		List<Annotation> annotationList = new ArrayList<Annotation>();
+        Annotation[] annotations = {};
+        for (Method candidateMethod : candidateMethods){
+            Annotation[] declaredAnnotations = candidateMethod.getDeclaredAnnotations();
+            for (Annotation annotation : declaredAnnotations) {
+                annotationList.add(annotation);
+            }
+        }
+        return ProcessableResponse.createProcessableResponse(null,
+                annotationList.toArray(annotations), null, null, null);
 	}
 
 	private String templateUrlEncode(String value) {

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/WebRequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/WebRequestImpl.java?rev=897844&r1=897843&r2=897844&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/WebRequestImpl.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/WebRequestImpl.java
Mon Jan 11 12:01:00 2010
@@ -39,6 +39,7 @@
 import org.apache.clerezza.triaxrs.util.CaseInsensitiveMap;
 import org.wymiwyg.wrhapi.HandlerException;
 import org.wymiwyg.wrhapi.HeaderName;
+import org.wymiwyg.wrhapi.Method;
 import org.wymiwyg.wrhapi.Request;
 
 /**
@@ -228,7 +229,16 @@
 
 	@Override
 	public String getMethod() {
-		throw new UnsupportedOperationException("Not supported yet.");
+		try {
+            Method method = wrhapiRequest.getMethod();
+            if (method != null) {
+                return (method.toString()).substring(8);
+            } else {
+                return null;
+            }
+        } catch (HandlerException ex) {
+            throw new RuntimeException(ex);
+        }
 	}
 
 	@Override



Mime
View raw message