private void internalProcessCommandExecution(AsyncContext asyncCtx,
JsonRpcRequest message) {
Assert.notNull(message.getParams(), "", 1); // TODO
Assert.notNull(message.getParams().getCommand(), "", 1); // TODO
ContentCommandResult result = null;
try {
result = interalRawCallToOnContentCommand(new ContentCommand(
message.getParams().getCommand().getType(), message
.getParams().getCommand().getData()));
} catch (Throwable t) {
getLogger().error(
"Error invoking onContentCommand on handler. Cause "
+ t.getMessage(), t);
int errorCode = 1; // TODO: define error code
if (t instanceof KurentoMediaFrameworkException) {
errorCode = ((KurentoMediaFrameworkException) t).getCode();
}
if (!registered) {
// An error with a command acting a session creation (e.g.
// register) makes the session to terminate. This avoids
// security problems where a client may force and exception, in
// which case it should not be given access to the session.
internalTerminateWithError(asyncCtx, errorCode, t.getMessage(),
message);
} else {
// An error executing a command in other scenarion is not
// considered faltal and the session may continue
protocolManager.sendJsonError(asyncCtx, JsonRpcResponse
.newError(errorCode, t.getMessage(), message.getId()));
}
callOnUncaughtExceptionThrown(t);
return;
}
try {
protocolManager.sendJsonAnswer(
asyncCtx,
JsonRpcResponse.newExecuteResponse(sessionId,
result.getResult(), message.getId()));
registered = true;
} catch (Throwable t) {
getLogger()