// Invoke the get operation on the service implementation
Message requestMessage = messageFactory.createMessage();
// String id = path.substring(1);
Message responseMessage = null;
HTTPCacheContext cacheContext = null;
try {
cacheContext = HTTPCacheContext.createCacheContextFromRequest(request);
} catch (ParseException e) {
}
// Route message based on availability of cache info and cache methods
if (( cacheContext != null ) && (cacheContext.isEnabled()) && (conditionalPostInvoker != null )) {
requestMessage.setBody(new Object[] {cacheContext});
responseMessage = conditionalPostInvoker.invoke(requestMessage);
} else {
requestMessage.setBody(new Object[] {});
responseMessage = postInvoker.invoke(requestMessage);
}
if (responseMessage.isFault()) {
Object body = responseMessage.getBody();
int index = -1;
if ( -1 < (index = body.getClass().getName().indexOf( "NotModifiedException")) ) {
if ( index > -1 )
response.sendError( HttpServletResponse.SC_NOT_MODIFIED, body.toString().substring( index ));
else
response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
return;
} else if ( -1 < (index = body.getClass().getName().indexOf( "PreconditionFailedException")) ) {
if ( index > -1 )
response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED, body.toString().substring( index ));
else
response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED );
return;
}
throw new ServletException((Throwable)responseMessage.getBody());
}
// Test if the ETag and LastModified are returned as a cache context.
Object body = responseMessage.getBody();
if ( body.getClass() == HTTPCacheContext.class ) {
// Transfer to header if so.
HTTPCacheContext cc = (HTTPCacheContext)responseMessage.getBody();
if (( cc != null ) && ( cc.isEnabled() )) {
String eTag = cc.getETag();
if ( eTag != null )
response.setHeader( "ETag", cc.getETag() );
String lastModified = cc.getLastModified();
if ( lastModified != null)
response.setHeader( "LastModified", cc.getLastModified() );
}
}
}