function dispatch(request)
{
var cmd = request.cmd;
if (!defined(cmd))
{
writeError('The command is not specified.');
return;
}
else
{
if (!cmd.length)
{
writeError('The command is not specified.');
return;
}
}
if (cmd == "getapp")
{
redirect("getapp.html");
}
if (cmd == "info")
{
if (!defined(request.name))
{
writeError('Unable to get ' + cmd + ' for application: ' +
'the application name is not specified');
return;
}
if (isInAppList(request.name))
{
redirect("info.html?name=" + request.name + "&frame=" + "no");
}
else
{
writeError('Unable to get ' + cmd + ' for application: "' +
request.name + '" is not installed');
return;
}
}
if ((cmd == "start") || (cmd == "stop") || (cmd == "restart"))
{
if (!defined(request.name))
{
writeError('Unable to ' + cmd + ' application: ' +
'the application name is not specified');
return;
}
if (isInAppList(request.name))
{
redirect("control.html?name=" + request.name +
"&cmd=" + cmd + "&frame=" + "no");
}
else
{
writeError('Unable to ' + cmd + ' application: "' +
request.name + '" is not installed');
return;
}
}
if (cmd == "remove")
{
if (!defined(request.name))
{
writeError('Unable to ' + cmd + ' application: ' +
'the application name is not specified');
return;
}
if (isInAppList(request.name))
{
redirect("kill.html?name=" + request.name + "&frame=" + "no");
}
else
{
writeError('Unable to ' + cmd + ' application: "' +
request.name + '" is not installed');
return;
}
}
if ((cmd == "add") || (cmd == "modify"))
{
if (!defined(request.name))
{
writeError('Unable to ' + cmd + ' application: ' +
'the application name is not specified');
return;
}
if (cmd == "modify")
{
if (!isInAppList(request.name))
{
writeError('Unable to ' + cmd + ' application: "' +
request.name + '" is not installed');
return;
}
}
if (!defined(request.obj))
{
writeError('Unable to ' + cmd + ' application: ' +
'the web file path is not specified');
return;
}
if (!defined(request.home))
{
writeError('Unable to ' + cmd + ' application: ' +
'the default page is not specified');
return;
}
var mode = request.mode;
if (!defined(mode))
{
writeError('Unable to ' + cmd + ' application: ' +
'the client object maintenance mode is not specified');
return;
}
if ((mode != "client-cookie") && (mode != "client-url") &&
(mode != "server-ip") && (mode != "server-cookie") &&
(mode != "server-url"))
{
writeError('Unable to ' + cmd + ' application: "' + mode +
'" is not a supported client object maintenance mode');
return;
}
if (!defined(request.maxdbconnect))
{
writeError('Unable to ' + cmd + ' application: ' +
'the built-in maximum database connection is not specified');
return;
}
if (!defined(request.start))
request.start = "";
if (!defined(request.library))
request.library = "";
redirect("modify.html?cmd=" + cmd + "&name=" + request.name +
"&obj=" + request.obj + "&home=" + request.home +
"&start=" + request.start + "&mode=" + request.mode +
"&library=" + request.library +
"&maxdbconnect=" + request.maxdbconnect + "&frame=" + "no");
}
else
{
writeError('"' + cmd + '" is not a supported command');
}
}
dispatch(request);