Author: olamy
Date: Tue Feb 28 18:36:17 2012
New Revision: 1294769
URL: http://svn.apache.org/viewvc?rev=1294769&view=rev
Log:
http 204 No content if put in cache failed: no pointer
Modified:
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java
incubator/directmemory/trunk/src/site/xdoc/server.xml
Modified:
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java?rev=1294769&r1=1294768&r2=1294769&view=diff
==============================================================================
---
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java
(original)
+++
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java
Tue Feb 28 18:36:17 2012
@@ -131,7 +131,13 @@ public class DirectMemoryServlet
//if exists free first ?
//if ( cacheService.retrieveByteArray( key ) == null )
- cacheService.putByteArray( key, request.getCacheContent(),
request.getExpiresIn() );
+ Pointer p = cacheService.putByteArray( key, request.getCacheContent(),
request.getExpiresIn() );
+ if ( p == null )
+ {
+ resp.sendError( HttpServletResponse.SC_NO_CONTENT, "Content not
put in cache for key: " + key );
+ return;
+ }
+
}
protected ContentTypeHandler findPutCacheContentTypeHandler(
HttpServletRequest req, HttpServletResponse response )
@@ -143,6 +149,11 @@ public class DirectMemoryServlet
// application/json
return contentTypeHandlers.get( MediaType.APPLICATION_JSON );
}
+ else if ( StringUtils.startsWith( contentType, MediaType.TEXT_PLAIN ) )
+ {
+ // text/plain
+ return contentTypeHandlers.get( MediaType.TEXT_PLAIN );
+ }
return contentTypeHandlers.get( contentType );
}
@@ -232,6 +243,10 @@ public class DirectMemoryServlet
// application/json
return contentTypeHandlers.get( MediaType.APPLICATION_JSON );
}
+ else if ( StringUtils.startsWith( acceptContentType,
MediaType.TEXT_PLAIN ) )
+ {
+ return contentTypeHandlers.get( MediaType.TEXT_PLAIN );
+ }
return contentTypeHandlers.get( acceptContentType );
}
Modified: incubator/directmemory/trunk/src/site/xdoc/server.xml
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/src/site/xdoc/server.xml?rev=1294769&r1=1294768&r2=1294769&view=diff
==============================================================================
--- incubator/directmemory/trunk/src/site/xdoc/server.xml (original)
+++ incubator/directmemory/trunk/src/site/xdoc/server.xml Tue Feb 28 18:36:17
2012
@@ -56,6 +56,7 @@
"cacheContent":"rO0ABXNyACtvcmcuYXBhY2hlLmRpcmVjdG1lbW9yeS5zZXJ2ZXIuY29tbW9ucy5XaW5l5dYKhxyAjeECAAFMAARuYW1ldAASTGphdmEvbGFuZy9TdHJpbmc7eHB0AAhCb3JkZWF1eA=="}
</source>
To put this content in DirectMemory Cache Server, just use a PUT
request on path ${webPath}/DirectMemoryServlet/${key}.<br/>
+ Note: if the content was not put in cache, you will receive a 204
(Not Content)
</p>
</subsection>
<subsection name="JSON GET Content">
@@ -80,7 +81,8 @@
PUT Request to put content in cache Content-Type:
application/x-java-serialized-object.<br/>
To put this content in DirectMemory Cache Server, just use a PUT
request on path ${webPath}/DirectMemoryServlet/${key}.<br/>
ExpiresIn value can be set with http header:
X-DirectMemory-ExpiresIn<br/>
- The http request body will contains the serialized object value.
+ The http request body will contains the serialized object value.<br/>
+ Note: if the content was not put in cache, you will receive a 204
(Not Content)
</p>
</subsection>
<subsection name="Binary GET Content">
@@ -102,7 +104,8 @@
To put this content in DirectMemory Cache Server, just use a PUT
request on path ${webPath}/DirectMemoryServlet/${key}.<br/>
ExpiresIn value can be set with http header:
X-DirectMemory-ExpiresIn<br/>
The http request body will contains a String value which will be
serialized on server side and stored in directMemory.<br/>
- You can specify the Serializer to use with the http header:
"X-DirectMemory-Serializer" (must contains the full class name).
+ You can specify the Serializer to use with the http header:
"X-DirectMemory-Serializer" (must contains the full class name).<br/>
+ Note: if the content was not put in cache, you will receive a 204
(Not Content)
</p>
</subsection>
<subsection name="text/plain GET Content">