protected int writeResponse(HttpCommand command, RescriptOperationBinding binding,
Object result, ExecutionContextWithTokens context, MediaType requestMediaType, long bytesRead) {
final HttpServletRequest request = command.getRequest();
final HttpServletResponse response = command.getResponse();
final RescriptIdentityTokenResolver tokenResolver = (RescriptIdentityTokenResolver)command.getIdentityTokenResolver();
if (command.getStatus() == TransportCommand.CommandStatus.InProcess) {
try {
if (result instanceof ResponseCode) {
ResponseCodeMapper.setResponseStatus(response, ((ResponseCode)result));
logAccess(command,
context, bytesRead,
0, requestMediaType,
null, (ResponseCode)result);
} else {
if (context != null && context.getIdentity() != null && tokenResolver != null) {
writeIdentity(context.getIdentityTokens(), new IdentityTokenIOAdapter() {
@Override
public void rewriteIdentityTokens(List<IdentityToken> identityTokens) {
tokenResolver.rewrite(identityTokens, response);
}
@Override
public boolean isRewriteSupported() {
return tokenResolver.isRewriteSupported();
}
});
}
//If the operation returns void, then return 200