ODatabaseDocumentTx db = null;
try {
db = getProfiledDatabaseInstance(iRequest);
final OFunction f = db.getMetadata().getFunctionLibrary().getFunction(parts[2]);
if (f == null)
throw new IllegalArgumentException("Function '" + parts[2] + "' is not configured");
if (iRequest.httpMethod.equalsIgnoreCase("GET") && !f.isIdempotent()) {
iResponse.send(OHttpUtils.STATUS_BADREQ_CODE, OHttpUtils.STATUS_BADREQ_DESCRIPTION, OHttpUtils.CONTENT_TEXT_PLAIN,
"GET method is not allowed to execute function '" + parts[2]
+ "' because has been declared as non idempotent. Use POST instead.", null, true);
return false;
}
final Object[] args = new String[parts.length - 3];
for (int i = 3; i < parts.length; ++i)
args[i - 3] = parts[i];
// BIND CONTEXT VARIABLES
final OBasicCommandContext context = new OBasicCommandContext();
context.setVariable("session", OHttpSessionManager.getInstance().getSession(iRequest.sessionId));
context.setVariable("request", new OHttpRequestWrapper(iRequest, (String[]) args));
context.setVariable("response", new OHttpResponseWrapper(iResponse));
handleResult(iRequest, iResponse, f.executeInContext(context, args));
} catch (OCommandScriptException e) {
// EXCEPTION
final StringBuilder msg = new StringBuilder(256);