bool FlowController::ExecDataAccess(Context &ctx, long &execTime) {
	StartTrace(FlowController.ExecDataAccess);
	execTime = 0;
	bool boRet = false;
	if (ctx.GetQuery().IsDefined("DataAccess")) {
		String daName = ctx.GetQuery()["DataAccess"].AsString();
		Trace("using DA: " << daName);
		DataAccess da(daName);
		DiffTimer timer;
		boRet = da.StdExec(ctx);
		execTime = timer.Diff();
	}
	return boRet;
}
void SessionInfoRenderer::RenderAll(std::ostream &reply, Context &c, const ROAnything &config)
{
	String roleName;
	c.GetRole()->GetName(roleName);
	reply << "/sessionId \"" << c.GetSession()->GetId() << "\"" << std::endl;
	reply << "/role " << roleName << std::endl;
	reply << "/delayed " << ROAnything(c.GetQuery())["delayedIndex"].AsLong(-1) << std::endl;
}
bool LoginAction::DoAction(String &action, Context &c)
{
	Anything query = c.GetQuery();

	if (query["LoginName"] == "Coast") {
		action = "GoCustomerAction";
	} else {
		action = "Logout";
	}

	return true;
}
String RendererDispatcher::FindServiceName(Context &ctx) {
	StartTrace(RendererDispatcher.FindServiceName);
	ROAnything uriPrefixList(ctx.Lookup("URIPrefix2ServiceMap"));
	String requestURI(ctx.Lookup("REQUEST_URI", ""));
	Anything query(ctx.GetQuery());
	SubTraceAny(uriPrefixList, uriPrefixList, "Service Prefixes: ");
	long matchedPrefix = FindURIPrefixInList(requestURI, uriPrefixList);
	if (matchedPrefix >= 0) {
		String service;
		Renderer::RenderOnString(service, ctx, uriPrefixList[matchedPrefix]);
		query["Service"] = service;
		query["URIPrefix"] = uriPrefixList.SlotName(matchedPrefix);
		SubTraceAny(query, query, "Query: ");
		Trace("Service [" << service << "]");
		return service;
	} else if (uriPrefixList.GetSize() > 0) {
		query["Error"] = String("Service[").Append(requestURI.SubString(0, requestURI.StrChr('/', 1))).Append("]NotFound");
	}
	String defaultHandler(ServiceDispatcher::FindServiceName(ctx));
	Trace("Service:<" << defaultHandler << ">");
	return defaultHandler;
}
void ConfiguredActionTest::DoTestWithContext(Anything testCase, const String &testCaseName, Context &ctx) {
	StartTrace(ConfiguredActionTest.DoTestWithContext);
	TraceAny(testCase, "Config of " << testCaseName);

	AlterTestStoreHook(testCase);
	coast::testframework::PutInStore(testCase["SessionStore"], ctx.GetSessionStore());
	coast::testframework::PutInStore(testCase["RoleStore"], ctx.GetRoleStoreGlobal());
	// Can not use real Session Store because Lookup does not find it ! - fix me
	TraceAny(ctx.GetRoleStoreGlobal(), "SessionStore");
	coast::testframework::PutInStore(testCase["TmpStore"], ctx.GetTmpStore());
	coast::testframework::PutInStore(testCase["Query"], ctx.GetQuery());
	coast::testframework::PutInStore(testCase["Env"], ctx.GetEnvStore());

	if (!testCase.IsDefined("Server") && GetConfig().IsDefined("Server")) {
		testCase["Server"] = GetConfig()["Server"].DeepClone();
	}
	if (testCase.IsDefined("Server")) {
		Server *s = Server::FindServer(testCase["Server"].AsCharPtr("Server"));
		ctx.SetServer(s);
	}
	if (testCase.IsDefined("Page")) {
		ctx.Push(testCase["Page"].AsCharPtr("Page"), Page::FindPage(testCase["Page"].AsCharPtr("Page")));
	}
	if (testCase.IsDefined("Role")) {
		ctx.Push(testCase["Role"].AsCharPtr("Role"), Role::FindRole(testCase["Role"].AsCharPtr("Role")));
	}
	TraceAny(testCase["TmpStore"], "Language");
	if (testCase["TmpStore"].IsDefined("Language")) {
		ctx.SetLanguage(testCase["TmpStore"]["Language"].AsCharPtr("D"));
	}

	bool expected = testCase["ExpectedResult"].AsBool(true);

	String token = testCase["StartToken"].AsString("TheAction");
	t_assertm(expected == Action::ExecAction(token, ctx, testCase["TheAction"]), (const char *)testCaseName);
	TraceAny(ctx.GetTmpStore(), "tmp store after action");
	String expectedToken = testCase["ExpectedToken"].AsString("TheAction");
	assertEqualm(expectedToken, token, (const char *)testCaseName);
}