package edu.vt.marian.WebGate;
import java.io.*;
import java.net.*;
import java.util.*;
import edu.vt.marian.common.*;
import edu.vt.marian.uip.*;
/** Class name: Response
A Response is created from a request and current system configuration.
Author: Jianxin Zhao
Finished time: ????, 1998
Known bugs: none
Platform: jdk1.1.5 under UNIX
-----------------------------------------------------------------------
Modified By: Richard Baker and Kevin Minnick
Date Modified: May 1, 2000
Platform Modified With: Microsoft Visual J++ 6.0 under Windows NT
Reason For Modification: Richard Baker added functionality for creating a folder,
moving a folder, renaming a folder, deleting a folder,
deleting all folders, opening a folder, closing a folder,
and moving a query.
-----------------------------------------------------------------------
Modified By: Robert France
Date Modified: November, 2000
Platform Modified With: UNIX and vi. Live with it.
Reason For Modification: Removed duplicate code; broke into smaller
objects for better compilation and maintenance.
-----------------------------------------------------------------------
TO BE DONE: I'm sure that there is still duplicate code in here, but
it's hard to even find it all. It's also probable that many additions
to the outgoing sp can be moved into the constructor as I've moved the
"user_name" binding.
A thorough reorganization would break the "request type" string up
into "interaction object name" (like "main_menu", "result_list", etc.)
and "user action" (like "get_more", "help", etc.).
Once that was done, this class could profitably be broken into
subclasses, or perhaps one class with access to classes for each interaction
object. Until that time, I'm going to leave it as one monumental class.
Additional tasks: work out better how much of the query form is
created dynamically within WebGate (or created by WebGate as an
interpretation of the solicitQuery() message from the server) and how
much is in the HTML page schema. Right now there are duplications.
Figure out what should happen when returning from a help page. Right
now I believe that process_*_help_quit routines get invoked for each
such page, but they are uniformly commented out. So what should be
happening?
*/
public class Response
{
/** this is just for debugging
*/
Debug debug;
/** this is the status of this response
*/
private String status;
/** this is the time when this response is created
*/
private Date time;
/** this is the html template file directory
*/
private String html_file_dir;
/** this is the html template filename
*/
private String html_file_name;
/** combined with html template file, this is used to send back response
in html format
*/
private StringPool sp;
/** the uip manager this object may communicate with
*/
private uip_manager uipm;
/** the user_manager this object may communicate with
*/
private user_manager userm;
/** the log manager this object may communicate with
*/
private log_manager lm;
/** this is the email address of the system super user, due to time
constraint this is set by hard code now, it may be chaged to be
read from file or changed online by the super user in the future
*/
private String super_user_email;
/** this is the directory of the images used in the system, due to time
constraint this is set by hard code now, it may be chaged to be
read from file or changed online by the super user in the future
*/
private String image_directory;
/** this is used to form html pages
*/
private final static String tag = "@webgate:";
/** this constructor will create the response object based on the request,
the user managerm the uip manager and the log manager of the system.
log manager is needed because sometimes supper user may want to
query log data of certain type.
*/
public Response(request req, user_manager userm, uip_manager uipm,
log_manager lm, Debug debug)
{
// first initialize data member
init();
this.debug = debug;
this.userm = userm;
this.uipm = uipm;
this.lm = lm;
// Create a new StringPool for outgoing bindings and add those
// that every transaction uses.
sp = new StringPool(debug);
sp.AddValue("client_name", req.get_client_name());
sp.AddValue("comments", "mailto:" + super_user_email);
sp.AddValue("image_directory", image_directory);
// In virtually every transaction, we inherit the user's name
// from the request. The only time this doesn't happen is
// when we don't know the user's name, in which case it should
// not be in the request StringPool at all. -- RKF Nov00
String user_name = req.get_user_name();
if (user_name != null)
sp.AddValue("user_name", "user_name=" + user_name);
processRequest(req);
set_generate_time(); //**DEVEL: should we bypass this on the
// final else branch above?
}
void processRequest(request req)
{
// do corresponding processing according to the request type
String type = req.get_type();
if (type == null)
{
processNull(req);
}
else if (type.equals("open_folder"))
{
process_open_folder(req);
}
else if (type.equals("close_folder"))
{
process_close_folder(req);
}
else if (type.equals("new_folder"))
{
process_new_folder(req);
}
else if (type.equals("rename_folder"))
{
process_rename_folder(req);
}
else if (type.equals("delete_folder"))
{
process_delete_folder(req);
}
else if (type.equals("view_folder_list_new_folder"))
{
process_view_folder_list_new_folder(req);
}
else if (type.equals("view_folder_list_delete_folder"))
{
process_view_folder_list_delete_folder(req);
}
else if (type.equals("delete_all_folders"))
{
process_delete_all_folders(req);
}
else if (type.equals("view_folder_list_rename_folder"))
{
process_view_folder_list_rename_folder(req);
}
else if (type.equals("change_password_page"))
{
process_change_password_page(req);
}
else if (type.equals("change_password_help"))
{
processHelp(req, "change_password.html");
}
else if (type.equals("change_password_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("change_password_confirm_ok"))
{
process_change_password_confirm_ok(req);
}
else if (type.equals("change_password_help_quit"))
{
process_change_password_help_quit(req);
}
else if (type.equals("documents_circulation_new_query"))
{
processNewQuery(req);
}
else if (type.equals("documents_circulation_view_previous_queries"))
{
process_documents_circulation_view_previous_queries(req);
}
else if (type.equals("documents_circulation_done"))
{
processDone(req);
}
else if (type.equals("documents_circulation_help"))
{
processHelp(req, "documents_circulation.html");
}
else if (type.equals("documents_circulation_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("documents_circulation_help_quit"))
{
process_documents_circulation_help_quit(req);
}
else if (type.equals("documents_full_description_circulation"))
{
process_documents_full_description_circulation(req);
}
else if (type.equals("documents_full_description_new_query"))
{
processNewQuery(req);
}
else if (type.equals("documents_full_description_view_previous_queries"))
{
process_documents_full_description_view_previous_queries(req);
}
else if (type.equals("documents_full_description_done"))
{
processDone(req);
}
else if (type.equals("documents_full_description_help"))
{
processHelp(req, "documents_full_description.html");
}
else if (type.equals("documents_full_description_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("documents_full_description_help_quit"))
{
process_documents_full_description_help_quit(req);
}
else if (type.equals("edit_preference_page"))
{
process_edit_preference_page(req);
}
else if (type.equals("edit_preference_help"))
{
processHelp(req, "edit_preference.html");
}
else if (type.equals("edit_preference_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("edit_preference_help_quit"))
{
process_edit_preference_help_quit(req);
}
else if (type.equals("help_quit"))
{
processHelpQuit(req);
}
else if (type.equals("history_documents_circulation_new_query"))
{
processNewQuery(req);
}
else if (type.equals("history_documents_circulation_view_previous_queries"))
{
process_history_documents_circulation_view_previous_queries(req);
}
else if (type.equals("history_documents_circulation_help"))
{
processHelp(req, "history_documents_circulation.html");
}
else if (type.equals("history_documents_circulation_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("history_documents_circulation_help_quit"))
{
process_history_documents_circulation_help_quit(req);
}
else if (type.equals("history_documents_full_description_circulation"))
{
process_history_documents_full_description_circulation(req);
}
else if (type.equals("history_documents_full_description_new_query"))
{
processNewQuery(req);
}
else if (type.equals("history_documents_full_description_view_previous_queries"))
{
process_history_documents_full_description_view_previous_queries(req);
}
else if (type.equals("history_documents_full_description_done"))
{
processDone(req);
}
else if (type.equals("history_documents_full_description_help"))
{
processHelp(req, "history_documents_full_description.html");
}
else if (type.equals("history_documents_full_description_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("history_documents_full_description_help_quit"))
{
process_history_documents_full_description_help_quit(req);
}
else if (type.equals("history_query_information_page"))
{
process_history_query_information_page(req);
}
else if (type.equals("history_query_information_help"))
{
processHelp(req, "history_query_information.html");
}
else if (type.equals("history_query_information_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("history_query_information_help_quit"))
{
process_history_query_information_help_quit(req);
}
else if (type.equals("history_query_results_page"))
{
process_history_query_results_page(req);
}
else if (type.equals("history_query_results_anchor"))
{
process_history_query_results_anchor(req);
}
else if (type.equals("history_query_results_new_query"))
{
processNewQuery(req);
}
else if (type.equals("history_query_results_done"))
{
processDone(req);
}
else if (type.equals("history_query_results_help"))
{
processHelp(req, "history_query_results.html");
}
else if (type.equals("history_query_results_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("history_query_results_help_quit"))
{
process_history_query_results_help_quit(req);
}
else if (type.equals("history_server_description_ok"))
{
process_history_server_description_ok(req);
}
else if (type.equals("history_server_description_help"))
{
processHelp(req, "history_server_description.html");
}
else if (type.equals("history_server_description_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("history_server_description_help_quit"))
{
process_history_server_description_help_quit(req);
}
else if (type.equals("log_file_contents_ok"))
{
process_log_file_contents_ok(req);
}
else if (type.equals("log_file_contents_help"))
{
processHelp(req, "log_file_contents.html");
}
else if (type.equals("log_file_contents_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("log_file_contents_help_quit"))
{
process_log_file_contents_help_quit(req);
}
else if (type.equals("log_file_query_page"))
{
process_log_file_query_page(req);
}
else if (type.equals("main_menu_change_password"))
{
process_main_menu_change_password(req);
}
else if (type.equals("main_menu_new_query"))
{
processNewQuery(req);
}
else if (type.equals("main_menu_view_previous_query"))
{
process_main_menu_view_previous_query(req);
}
else if (type.equals("main_menu_edit_preference"))
{
process_main_menu_edit_preference(req);
}
else if (type.equals("main_menu_help"))
{
processHelp(req, "main_menu.html");
}
else if (type.equals("main_menu_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("main_menu_help_quit"))
{
process_main_menu_help_quit(req);
}
else if (type.equals("new_user_login_page"))
{
process_new_user_login_page(req);
}
else if (type.equals("new_user_login_help"))
{
processHelp(req, "new_user_login.html");
}
else if (type.equals("new_user_login_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("new_user_login_help_quit"))
{
process_new_user_login_help_quit(req);
}
else if (type.equals("old_user_login_page"))
{
process_old_user_login_page(req);
}
else if (type.equals("old_user_login_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("old_user_login_help_quit"))
{
process_old_user_login_help_quit(req);
}
else if (type.equals("query_history_page"))
{
process_query_history_page(req);
}
else if (type.equals("query_history_help"))
{
processHelp(req, "query_history.html");
}
else if (type.equals("query_history_new_query"))
{
processNewQuery(req);
}
else if (type.equals("query_history_done"))
{
processDone(req);
}
else if (type.equals("query_history_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("query_history_help_quit"))
{
process_query_history_help_quit(req);
}
else if (type.equals("query_information_page"))
{
process_query_information_page(req);
}
else if (type.equals("query_information_help"))
{
processHelp(req, "query_information.html");
}
else if (type.equals("query_information_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("query_information_help_quit"))
{
process_query_information_help_quit(req);
}
else if (type.equals("query_results_page"))
{
process_query_results_page(req);
}
else if (type.equals("query_results_anchor"))
{
process_query_results_anchor(req);
}
else if (type.equals("query_results_new_query"))
{
processNewQuery(req);
}
else if (type.equals("query_results_view_previous_queries"))
{
process_query_results_view_previous_queries(req);
}
else if (type.equals("query_results_done"))
{
processDone(req);
}
else if (type.equals("query_results_help"))
{
processHelp(req, "query_results.html");
}
else if (type.equals("query_results_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("query_results_help_quit"))
{
process_query_results_help_quit(req);
}
else if (type.equals("start"))
{
processStart(req);
}
else if (type.equals("server_description_ok"))
{
process_server_description_ok(req);
}
else if (type.equals("server_description_help"))
{
processHelp(req, "server_description.html");
}
else if (type.equals("server_description_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("server_description_help_quit"))
{
process_server_description_help_quit(req);
}
else if (type.equals("shut_down_complete"))
{
process_shut_down_complete(req);
}
else if (type.equals("super_user_change_password"))
{
process_super_user_change_password(req);
}
else if (type.equals("super_user_log_analysis"))
{
process_super_user_log_analysis(req);
}
else if (type.equals("super_user_user_manage"))
{
process_super_user_user_manage(req);
}
else if (type.equals("super_user_shut_down"))
{
process_super_user_shut_down(req);
}
else if (type.equals("super_user_help"))
{
processHelp(req, "super_user.html");
}
else if (type.equals("super_user_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("super_user_change_password_page"))
{
process_super_user_change_password_page(req);
}
else if (type.equals("super_user_change_password_help"))
{
processHelp(req, "super_user_change_password.html");
}
else if (type.equals("super_user_change_password_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("super_user_change_password_confirm_ok"))
{
process_super_user_change_password_confirm_ok(req);
}
else if (type.equals("super_user_change_password_help_quit"))
{
process_super_user_change_password_help_quit(req);
}
else if (type.equals("super_user_help_quit"))
{
process_super_user_help_quit(req);
}
else if (type.equals("system_user_information_page"))
{
process_system_user_information_page(req);
}
else if (type.equals("system_user_information_ok"))
{
process_system_user_information_ok(req);
}
else if (type.equals("system_user_information_help"))
{
processHelp(req, "system_user_information.html");
}
else if (type.equals("system_user_information_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("system_user_information_help_quit"))
{
process_system_user_information_help_quit(req);
}
else if (type.equals("welcome_new_user"))
{
process_welcome_new_user(req);
}
else if (type.equals("welcome_old_user"))
{
process_welcome_old_user(req);
}
else if (type.equals("welcome_help"))
{
processHelp(req, "welcome.html");
}
else if (type.equals("welcome_quit_system"))
{
processQuitSystem(req);
}
else if (type.equals("query_results_view_folders"))
{
process_query_results_view_folders(req);
}
else if (type.equals("query_results_view_folder_list"))
{
process_query_results_view_folder_list(req);
}
else
{
debug.dumpTrace("ResponseType: unknown type '" +
type + "': ignoring.");
sp.AddValue("error_message",
"System error: unrecognized transaction '" + type +
"'. Please press \"Back\" button to try again.");
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Unknown response type");
return;
}
}
/** this constructor will create a response object from a stream, this
might be useful for remote management in the future.
(not implemented yet)
*/
public Response(DataInputStream dis, Debug debug)
{
debug.dumpTrace("Response.[constructor 2]: NOT YET IMPLEMENTED.");
}
/** this method will encode the input string, it's used to deal with
the special char "
*/
private String cgi_encode(String string)
{
if (string == null)
{
// this is an empry string, no need to process
return null;
}
String new_string = new String("");
int i;
char c;
for (i = 0; i < string.length(); i++)
{
c = string.charAt(i);
if (c == '\"')
{
new_string += """;
continue;
}
if (c == '&')
{
new_string += "&";
continue;
}
new_string += String.valueOf(c);
}
return new_string;
}
/** this method will set the status of this response
*/
private String set_status(String status)
{
if (status == null)
{
this.status = null;
return "ok";
}
this.status = new String(status);
return "OK";
}
/** this method will return the status (OK or ERROR) of this response,
at least this can be used when logging
*/
public String get_status()
{
if (status == null)
{
return null;
}
return new String(status);
}
/** this method will set the time when this response object is created
in fact it's the time when this method is called
*/
private String set_generate_time()
{
time = new Date();
return "OK";
}
/** this method will return the time when this response object is generated,
this may be used in logging and system performance measurement
*/
public String get_generate_time()
{
return time.toString();
}
/** this method will print the response to an output stream
*/
public String to_stream(DataOutputStream dos)
{
return null; // not implemented yet
}
/** this method will print the content of this object to a stream in
html format
*/
public String to_stream_in_html(OutputStream os)
{
PrintWriter pw = new PrintWriter(os);
userm.save(userm.get_dir());
debug.dumpTrace("Response.to_stream_in_html(): ready to configure page '" + html_file_name +
"' with values " + sp.toString() + ".");
// first print file name
pw.println(html_file_name);
// then the StringPool object
sp.to_stream(pw);
pw.flush();
return "ok";
}
/** this method will print the content of this object to a stream in
xml format, xml is a very hot language, maybe it can replace html
in the future especially in information retrieval domain
(not implemented yet)
*/
public String to_stream_in_xml(DataOutputStream dos)
{
return null; // not implemented yet
}
private void submitQuery(request req)
{
user u = userm.get_user_by_name(req.get_user_name());
// debug.dumpTrace("Response.submitQuery(): user name " + req.get_user_name() + " id " + u.get_id());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
// submit the query to the user
query_data qd = req.get_query_data(uipm);
int batch_size, time_out_value;
try
{
batch_size = Integer.parseInt(qd.get_preference_value("batch_size"));
}
catch (NumberFormatException e)
{
// probably the batch size is null or non integer
String err = new String("Invalid batch size " +
qd.get_preference_value("batch_size") +
" identified, it can not be empty or non integer. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid batch size identified");
return;
}
if ((batch_size > 200) || (batch_size <= 0))
{
// this is added since currently MARIAN server uip doesn't support rpc
// of more than 32k bytes long, also a number less than 1 doesn't make sense
String err = new String("Please enter a batch number between 1 and 200. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Batch size over 30 or less than 1");
return;
}
try
{
time_out_value = Integer.parseInt(qd.get_preference_value("time_out_value"));
}
catch (NumberFormatException e)
{
// probably the time out value is null or non integer
String err = new String("Invalid time out value " +
qd.get_preference_value("time_out_value") +
" identified, it can not be empty or non integer. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid time out value identified");
return;
}
String query_number = u.submit_query(qd);
sp.AddValue("query_number", "query_number=" + query_number);
// set state of each server of results to QUERY
query q = u.get_query(query_number);
Results r = q.get_results();
Vector servers = r.get_server_list();
r.set_status(servers, "QUERY");
// send rpc search_collection(...) to each server
rpc_function f = new rpc_function(debug);
f.set_name("search_collection");
parameter p = new parameter("user id",
"INTEGER", new Integer(u.get_id()), debug);
f.add_parameter(p);
p = new parameter("query number",
"INTEGER", new Integer(query_number), debug);
f.add_parameter(p);
p = new parameter("collection name", "STRING", "VTLS", debug);
f.add_parameter(p);
uipm.rpc_call(servers, f);
// debug.dumpTrace("Response.submitQuery(): search_collection sent out with user " + u.get_id() + " and query " + query_number);
// start timer
Date d = new Date();
long start_time = d.getTime() / 1000;
long current_time;
int num_docs;
String s;
int i;
Vector docs = new Vector();
WtdEntireObj weo;
Document doc;
uip_server us;
// Any Response from this point on will use this template page.
html_file_name = new String("query_results.htm");
String htmlLinkPrefix = " time_out_value)
{ // timer pop out
sp.AddValue("document_short_descriptions",
"Time out; you may see the results later.");
sp.AddValue("last_doc_number", "last_doc_number=0");
set_status("no documents returned when time out");
return;
}
// else continue;
}
}
else if (num_docs > batch_size)
{ // Some servers have returned; we have more than one batch. Show first (batch_size) docs & set "get_more".
sp.AddValue("document_short_descriptions",
r.shortDescListInHtml(htmlLinkPrefix,
batch_size, 0, batch_size-1) );
addGetMoreButton(sp);
sp.AddValue("last_doc_number", "last_doc_number=" + Integer.toString(batch_size - 1));
set_status("ok");
return;
}
else // (num_docs <= batch_size)
{
sp.AddValue("document_short_descriptions",
r.shortDescListInHtml(htmlLinkPrefix,
batch_size, 0, num_docs-1) );
sp.AddValue("last_doc_number", "last_doc_number=" + Integer.toString(num_docs - 1));
if ( ! r.all_in_state("QUERY_COMPLETE") )
{ // more documents may come in the future
// get more button should be effective in this case
addGetMoreButton(sp);
}
set_status("ok");
return;
}
} // end -- while
}
private void submitGetMore(request res)
{
String user_name = res.get_user_name();
int query_number = Integer.parseInt(res.get_query_number());
int last_doc_number = Integer.parseInt(res.get_last_doc_number());
// Set up StringPool values.
sp.AddValue("query_number", "query_number=" + query_number);
Vector doc_numbers = res.get_doc_numbers();
int i;
String s;
for (i = 0; i < doc_numbers.size(); i++)
{ // Add in which doc numbers user has checked.
s = (String) doc_numbers.elementAt(i);
sp.AddValue("doc_number_" + s, "checked");
}
user u = userm.get_user_by_name(user_name);
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
// get batch size and time out value
query q = u.get_query(Integer.toString(query_number));
query_data qd = q.get_query_data();
int batch_size = Integer.parseInt(qd.get_preference_value("batch_size"));
int time_out_value = Integer.parseInt(qd.get_preference_value("time_out_value"));
String htmlLinkPrefix = " (last_doc_number + 1)) ||
(r.all_in_state("QUERY_COMPLETE")) )
{ // Either we have more documents already
// received to show to the user, or no server
// has any more to give us (this second case
// is possible, but not likely).
if (number_docs > (last_doc_number + 1 + batch_size))
endIndex = last_doc_number + batch_size;
else
endIndex = number_docs - 1;
sp.AddValue("document_short_descriptions",
r.shortDescListInHtml(htmlLinkPrefix,
batch_size, 0, endIndex));
sp.AddValue("last_doc_number",
"last_doc_number=" +
Integer.toString(endIndex));
if ( (number_docs > (last_doc_number+1+batch_size)) ||
( ! r.all_in_state("QUERY_COMPLETE")) )
{
addGetMoreButton(sp);
}
// set response template page name
html_file_name = new String("query_results.htm");
set_status("ok");
return;
} // end -- if (number_docs > ...)
else // There are no documents already received that
{ // have not been shown to the user, and at
// least one server is not in QUERY_COMPLETE.
// Find the servers that have more to give.
servers = r.get_servers_in_state("QUERY_DONE");
if (servers.size() > 0)
{ // some servers are state QUERY_DONE:
// send them show_next_k(...) requests.
rpc_function f = new rpc_function(debug);
f.set_name("show_next_k");
parameter p = new parameter("user id",
"INTEGER", new Integer(u.get_id()), debug);
f.add_parameter(p);
p = new parameter("query number",
"INTEGER", new Integer(query_number), debug);
f.add_parameter(p);
p = new parameter("batch size",
"INTEGER", new Integer(batch_size), debug);
f.add_parameter(p);
// Set the status of these servers to
// QUERY before sending them the rpc function.
r.set_status(servers, "QUERY");
uipm.rpc_call(servers, f);
}
else // Some server is in state QUERY. Check
{ // for time-out.
d = new Date();
current_time = d.getTime() / 1000;
if ((current_time - start_time) > time_out_value)
{
// timer pop out
s = new String("Time out; you may see more results later.");
sp.AddValue("document_short_descriptions", s);
sp.AddValue("last_doc_number", "last_doc_number=0");
// set response template page name
html_file_name = new String("query_results.htm");
set_status("no further documents returned when time out");
return;
}
}
}
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
debug.dumpTrace("error in sleeping");
}
} // end -- while
}
public void submitGetCirculation(request req)
{
Vector doc_ids = new Vector();
WtdEntireObj weo;
Document doc;
uip_server us, us1;
Vector doc_numbers = req.get_doc_numbers();
if (doc_numbers.size() == 0)
{
// user selected nothing
String err = new String("No documents has been selected. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("no documents selected");
return;
}
// user did select some documents, we can only search
// search circulation information from one server, we fix it
// as the server where the first selected document came from
user u = userm.get_user_by_name(req.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
query q = u.get_query(req.get_query_number());
query_data qd = q.get_query_data();
Results r = q.get_results();
int batch_size = Integer.parseInt(qd.get_preference_value("batch_size"));
int time_out_value = Integer.parseInt(qd.get_preference_value("time_out_value"));
us = r.get_server_by_doc_number((String) doc_numbers.elementAt(0));
weo = r.get_doc((String) doc_numbers.elementAt(0));
doc_ids.addElement(weo.getID());
int i;
for (i = 1; i < doc_numbers.size(); i++)
{
us1 = r.get_server_by_doc_number((String) doc_numbers.elementAt(i));
if (us.equals(us1).equals("yes"))
{
weo = r.get_doc((String) doc_numbers.elementAt(i));
doc_ids.addElement(weo.getID());
}
}
// set the status of the Results object
r.set_status("CIRCULATION");
// now perform a rpc get_circulation_info(...) to the server
rpc_function f = new rpc_function(debug);
f.set_name("get_circulation_info");
parameter p = new parameter("user id",
"INTEGER", new Integer(u.get_id()), debug);
f.add_parameter(p);
p = new parameter("query number",
"INTEGER", new Integer(req.get_query_number()), debug);
f.add_parameter(p);
p = new parameter("doc vect", "DOC_ID_VECT", doc_ids, debug);
f.add_parameter(p);
Vector servers = new Vector();
servers.addElement(us);
uipm.rpc_call(servers, f);
// start timer
Date d = new Date();
long start_time = d.getTime() / 1000;
long current_time;
while (true)
{
// wait some time
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
debug.dumpTrace("error in sleeping");
}
if (r.get_status().equals("CIRCULATION_DONE"))
{
// the circulation information is ready, show it to user
// s = new String(" ");
}
/******* Why was this ever done in the first place? RKF 15Nov00
String temp1 = doc.presentLong(DigInfObj.HTML);
int beginIdx = 0, endIdx = 0;
String temp2 = new String();
while ((endIdx = temp1.indexOf('\n', beginIdx)) != -1)
{
sb.append(temp1.substring(beginIdx, endIdx));
sb.append(" " +
res.toString() +
" identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Strange request type");
return;
}
/** this method will process the request type "system_user_information_ok"
*/
private void process_system_user_information_ok(request res)
{
// set response template page name
html_file_name = new String("super_user.htm");
set_status("ok");
return;
}
/** this method will process the request type "system_user_information
_help_quit"
*/
private void process_system_user_information_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "shut_down_complete"
*/
private void process_shut_down_complete(request res)
{
// set response template page name
html_file_name = new String("shut_down_confirm.htm");
set_status("ok");
return;
}
/** this method will process the request type "super_user_change_password"
*/
private void process_super_user_change_password(request res)
{
// set response template page name
html_file_name = new String("super_user_change_password.htm");
set_status("ok");
return;
}
/** this method will process the request type "super_user_log_analysis"
*/
private void process_super_user_log_analysis(request res)
{
// set response template page name
html_file_name = new String("log_file_query.htm");
set_status("ok");
return;
}
/** this method will process the request type "super_user_user_manage"
*/
private void process_super_user_user_manage(request res)
{
// process system user information
int number_user = Integer.parseInt(userm.get_number_users());
int i;
String s = new String("");
user u = null;
for (i = 0; i < number_user; i++)
{
u = userm.get_user_at(Integer.toString(i));
if ((u != null) && ((u.get_priority() == null) ||
(! u.get_priority().equals("super user"))))
{
s += "" + "User name: " +
u.get_user_name() + " Time of creation: " +
(new Date(Long.parseLong(u.get_creation_time()))).toString()
+ " Queries performed so far: " + u.get_number_queries() + " " +
res.toString() +
" identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Strange request type");
return;
}
/** this method will process the request type "super_user_change_password
_confirm_ok"
*/
private void process_super_user_change_password_confirm_ok(request res)
{
// set response template page name
html_file_name = new String("super_user.htm");
set_status("ok");
return;
}
/** this method will process the request type "super_user_change_password
_help_quit"
*/
private void process_super_user_change_password_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "super_user_help_quit"
*/
private void process_super_user_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "server_description_ok"
*/
private void process_server_description_ok(request res)
{
return; // not implemented yet
}
/** this method will process the request type "server_description_help_quit"
*/
private void process_server_description_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "query_results_page"
*/
private void process_query_results_page(request res)
{
if (res.contains("Get More Results").equals("yes"))
{ // user want to see more documents of this query
submitGetMore(res);
return;
}
else if (res.contains("Show Full Descriptions of Selected Document(s)").equals("yes"))
{
// user want to see the long description of selected documents
sp.AddValue("query_number", "query_number=" + res.get_query_number());
sp.AddValue("last_doc_number", "last_doc_number=" + res.get_last_doc_number());
// process doc numbers
sp.AddValue("doc_numbers", makeSelectedDocString(res));
// process document full descriptions
sp.AddValue("document_full_descriptions",
longDescListInHtml(res));
// set response template page name
html_file_name = new String("documents_full_description.htm");
set_status("ok");
return;
}
else if (res.contains("Show Circulation of Selected Document(s)").equals("yes"))
{
// user want to see the circulation information of selected
// documents
sp.AddValue("query_number", "query_number=" + res.get_query_number());
sp.AddValue("last_doc_number", "last_doc_number=" + res.get_last_doc_number());
// process doc numbers
sp.AddValue("doc_numbers", makeSelectedDocString(res));
// process circulation information
submitGetCirculation(res);
return;
}
else if (res.contains("help").equals("yes"))
{
// set response template page name
html_file_name = new String("query_results_help.htm");
set_status("ok");
return;
}
// should not reach here
String err = new String("Strange request type " +
res.toString() +
" identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Strange request type");
return;
}
/** this method will process the request type "query_results_anchor"
*/
private void process_query_results_anchor(request res)
{
// user wants to see the long description of clicked document
sp.AddValue("query_number", "query_number=" + res.get_query_number());
sp.AddValue("last_doc_number", "last_doc_number=" + res.get_last_doc_number());
// get the only one doc number.
Vector doc_numbers = res.get_doc_numbers();
String doc_number = (String) doc_numbers.elementAt(0);
String s = "doc_number_" + doc_number + "=on";
sp.AddValue("doc_numbers", s);
// process document full descriptions
sp.AddValue("document_full_descriptions",
longDescListInHtml(res));
// set response template page name
html_file_name = new String("documents_full_description.htm");
set_status("ok");
return;
}
/** this method will process the request type "query_results_view_previous
_queries"
*/
private void process_query_results_view_previous_queries(request res)
{
// process query history information
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
//code added by KWM 04/2000
String s = create_query_history_table(u);
sp.AddValue("query_history_information", s);
//insert the drop down box for manipulating folders
s = create_folder_dropdown_box(u);
sp.AddValue("folder_drop_down_box", s);
//insert the drop down box for manipulating folders
s = create_folder_dropdown_box(u);
sp.AddValue("folder_drop_down_box", s);
// set response template page name
html_file_name = new String("query_history.htm");
set_status("ok");
return;
}
/** this method will process the request type "query_results_help_quit"
*/
private void process_query_results_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "query_information_page"
*/
private void process_query_information_page(request res)
{
if (res.contains("Submit Query").equals("yes"))
{
// our client pressed the do search button
submitQuery(res);
return;
}
else if (res.contains("help").equals("yes"))
{
// user want to see the online help for this page
// set response template page name
html_file_name = new String("query_information_help.htm");
set_status("ok");
return;
}
// should not reach here
String err = new String("Strange request type " +
res.toString() +
" identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Strange request type");
return;
}
/** this method will process the request type "query_information_help_quit"
*/
private void process_query_information_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "query_history_page"
*/
private void process_query_history_page(request res)
{
boolean itemIsQuery = false;
boolean itemIsFolder = false;
String itemNumberStr = "";
int itemNumber = 0;
String requestNumber = res.get_number();
if (requestNumber != null)
{
//see if the user selected a folder or a query to delete
for (int i = 1; i < requestNumber.length(); i++)
itemNumberStr += requestNumber.charAt(i);
itemNumber = Integer.parseInt(itemNumberStr);
if (requestNumber.charAt(0) == 'f')
{
itemIsFolder = true;
}
else
{
itemIsQuery = true;
sp.AddValue("query_number", "query_number=" + itemNumber);
}
}
// Identify the user.
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
// Now figure out the transactionand process it.
if (res.contains("Edit Selected Query").equals("yes"))
{
// user want to edit previous query he performed
// last query number will be added in the future
if (! itemIsQuery )
{
if ( itemIsFolder)
{ // user selected a folder
sp.AddValue("error_message",
"You can only view the results of queries. Please press \"Back\" button to continue.");
}
else
{ // probably user selected nothing
sp.AddValue("error_message",
"Nothing has been selected. Please press \"Back\" button to try again.");
}
// set response template page name
html_file_name = new String("error_message.htm");
set_status("No query selected");
return;
}
query q = u.get_query(itemNumberStr);
query_data qd = q.get_query_data();
// process query title
sp.AddValue("query_title", "value=\"" + q.get_title() + "\"");
// process query fields
Vector servers = qd.get_server_list();
uip_server us = null;
String s = null;
if (servers.size() > 0)
{
// if user selected no server to do the search at that time,
// then all the information he/she entered in query fields
// are not remembered
us = (uip_server) servers.elementAt(0);
// field text 1 type
s = qd.get_value(us, "text1_type");
if (s.equals("Personal Authors"))
{
sp.AddValue("text1_personal_authors", "selected");
}
if (s.equals("Corporate Authors"))
{
sp.AddValue("text1_corporate_authors", "selected");
}
if (s.equals("Conference as Author"))
{
sp.AddValue("text1_conference_as_author", "selected");
}
if (s.equals("Any Authors"))
{
sp.AddValue("text1_any_authors", "selected");
}
if (s.equals("Any part of description"))
{
sp.AddValue("text1_any_part_of_description", "selected");
}
// field text 1
sp.AddValue("text1", qd.get_value(us, "text1"));
// field text 2 type
s = qd.get_value(us, "text2_type");
if (s.equals("Words in Title"))
{
sp.AddValue("text2_words_in_title", "selected");
}
if (s.equals("Words in Subject"))
{
sp.AddValue("text2_words_in_subject", "selected");
}
if (s.equals("Title+Subject"))
{
sp.AddValue("text2_title_subject", "selected");
}
if (s.equals("Words in Notes"))
{
sp.AddValue("text2_words_in_notes", "selected");
}
if (s.equals("Title+Notes"))
{
sp.AddValue("text2_title_notes", "selected");
}
if (s.equals("Title+Subject+Notes"))
{
sp.AddValue("text2_title_subject_notes", "selected");
}
if (s.equals("Any Authors"))
{
sp.AddValue("text2_any_authors", "selected");
}
if (s.equals("Any part of description"))
{
sp.AddValue("text2_any_part_of_description", "selected");
}
// field text 2
sp.AddValue("text2", qd.get_value(us, "text2"));
// field text 3 type
s = qd.get_value(us, "text3_type");
if (s.equals("Words in Title"))
{
sp.AddValue("text3_words_in_title", "selected");
}
if (s.equals("Words in Subject"))
{
sp.AddValue("text3_words_in_subject", "selected");
}
if (s.equals("Title+Subject"))
{
sp.AddValue("text3_title_subject", "selected");
}
if (s.equals("Words in Notes"))
{
sp.AddValue("text3_words_in_notes", "selected");
}
if (s.equals("Title+Notes"))
{
sp.AddValue("text3_title_notes", "selected");
}
if (s.equals("Title+Subject+Notes"))
{
sp.AddValue("text3_title_subject_notes", "selected");
}
if (s.equals("Any Authors"))
{
sp.AddValue("text3_any_authors", "selected");
}
if (s.equals("Any part of description"))
{
sp.AddValue("text3_any_part_of_description", "selected");
}
// field text 3
sp.AddValue("text3", qd.get_value(us, "text3"));
} // end -- if (servers.size() > 0)
// process server list
Vector new_servers = uipm.get_current_servers();
int i, j;
boolean selected;
uip_server us1;
s = new String("");
for (i = 0; i < new_servers.size(); i++)
{
us = (uip_server) new_servers.elementAt(i);
selected = false;
for (j = 0; j < servers.size(); j++)
{
us1 = (uip_server) servers.elementAt(j);
if (us.equals(us1).equals("yes"))
{
// this server has been selected, also is availabe now
s += "" + us.get_short_description() + " There may be more documents match this query, but you need to do new query to get them " +
res.toString() +
" identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Strange request type");
return;
}
/** this method will process the request type "query_history_help_quit"
*/
private void process_query_history_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "change_password_page"
*/
private void process_change_password_page(request res)
{
if (res.contains("Submit").equals("yes"))
{
// user want to submit the information
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// this is not a valid user name
String err = new String("Please make sure you enter the correct user name. Press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name");
return;
}
// user name is valid
if ((res.get_password() == null) || res.get_password().equals("")
|| (! u.get_password().equals(res.get_password())))
{
// the old password the user entered is not correct
String err = new String("Please make sure you enter the correct old password. Press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid old password");
return;
}
// old password is also valid
if ((res.get_new_password() == null) || res.get_new_password().equals("")
|| (res.get_new_password().length() <= 4)
|| (res.get_password_confirm() == null)
|| res.get_password_confirm().equals("")
|| (! res.get_new_password().equals(res.get_password_confirm())))
{
// the new password and password confirm are not the same
String err = new String("Please make sure you enter the same value in the fields \"New Password\" and \"Confirm Password\". Press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("New password and password confirm not the same");
return;
}
// new password and password confirmation are the same
if (res.get_new_password().equals(res.get_password()))
{
// the new password and the old password are same
String err = new String("Please make sure you enter a new password different from the old one. Press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("New password and old password confirm are same");
return;
}
// new password is not the same as the old one
u.set_password(res.get_new_password());
// set response template page name
html_file_name = new String("change_password_confirm.htm");
set_status("ok");
return;
}
else if (res.contains("help").equals("yes"))
{
// user want to see online help
// set response template page name
html_file_name = new String("change_password_help.htm");
set_status("ok");
return;
}
// should not reach here
String err = new String("Strange request type " +
res.toString() +
" identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Strange request type");
return;
}
/** this method will process the request type "change_password_
confirm_ok"
*/
private void process_change_password_confirm_ok(request res)
{
// set response template page name
html_file_name = new String("main_menu.htm");
set_status("ok");
return;
}
/** this method will process the request type "change_password_help_quit"
*/
private void process_change_password_help_quit(request res)
{
/*
sp.AddValue("password", res.get_password());
sp.AddValue("new_password", res.get_new_password());
sp.AddValue("password_confirm", res.get_password_confirm());
// set response template page name
html_file_name = new String("change_password.htm");
set_status("ok");
*/ return;
}
/** this method will process the request type "old_user_login_page"
*/
private void process_old_user_login_page(request res)
{
// Checking for "Login" in the submit string has been removed to
// allow user login by pressing Enter key. (LS, 11/22/98).
// the user want to login the system
if ((res.get_user_name() == null) ||
(res.get_user_name().equals("")))
{
// empty user name
String err = new String("User name can not be empty. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("empty user name");
return;
}
// user name not empty
if ((res.get_password() == null) || (res.get_password().equals("")))
{
// empty password
String err = new String("Password can not be empty. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("empty password");
return;
}
user u = userm.get_user_by_name(res.get_user_name());
if ((u == null) || (! u.get_password().equals(res.get_password())))
{
// probably, incorrect user name and/or password
String err = new String("Invalid User Name and/or Password. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("incorrect username and/or password");
return;
}
// user got correctly
sp.AddValue("user_name", "user_name=" + res.get_user_name());
// set response template page name
if ((u.get_priority() != null) && (u.get_priority().equals("super user")))
{
// this is super user, process seperately
html_file_name = new String("super_user.htm");
}
else
{
// this is a normal user
html_file_name = new String("main_menu.htm");
}
set_status("ok");
return;
}
/** this method will process the request type "old_user_login_help_quit"
*/
private void process_old_user_login_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "new_user_login_page"
*/
private void process_new_user_login_page(request res)
{
// Checking for "Login" in the submit string has been removed to
// allow user login by pressing Enter key. (LS, 11/22/98).
// the user want to submit the information to create a new user
if ((res.get_user_name() == null) || (res.get_user_name().equals("")))
{
// empty user name
String err = new String("User name can not be empty. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("empty user name");
return;
}
// user name not empty
if ((res.get_user_name().indexOf(" ") != -1) || (res.get_user_name().indexOf("/") != -1))
{
// user name contain space
String err = new String("User name can not contain space or /. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("user name contains space");
return;
}
// user name doesn't contain space
if ((res.get_password() == null) || (res.get_password().equals("")))
{
// empty password
String err = new String("Password can not be empty. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("empty password");
return;
}
// password not empty
if ((res.get_password_confirm() == null) ||
(res.get_password_confirm().equals("")))
{
// empty password confirmation
String err = new String("Password confirmation can not be empty. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("empty password confirm");
return;
}
// password confirm not empty
if (! res.get_password().equals(res.get_password_confirm()))
{
// password and password are not the same
String err = new String("Password and password confirmation should be the same. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("different password and confirmation");
return;
}
// debug.dumpTrace(res.get_user_name() + "--" + res.get_password());
// password and confirm are the same
user u = userm.new_user(res.get_user_name(), res.get_full_name(), res.get_password());
if (u == null)
{
// probably, duplicated username
String err = new String("Please change to another user name. Press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("duplicated user name");
return;
}
// set default preferences
u.add_preference("sort_rule", "closest");
u.add_preference("display_style", "full screen");
u.add_preference("batch_size", "20");
u.add_preference("time_out_value", "20");
// user created correctly
sp.AddValue("user_name", "user_name=" + res.get_user_name());
// set response template page name
html_file_name = new String("main_menu.htm");
set_status("ok");
return;
}
/** this method will process the request type "new_user_login_help_quit"
*/
private void process_new_user_login_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "main_menu_change_password"
*/
private void process_main_menu_change_password(request res)
{
// set response template page name
html_file_name = new String("change_password.htm");
set_status("ok");
return;
}
/** this method will process the request type "main_menu_view_previous
_query"
*/
private void process_main_menu_view_previous_query(request res)
{
// process query history information
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
int number_queries = Integer.parseInt(u.get_number_queries());
if (number_queries == 0)
{
// there is no previous queries available, show corresponding
// message about this
String message = new String("You haven't performed any query before.");
sp.AddValue("query_history_information", message);
// set response template page name
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
//code modified by kwm on 04/2000
// there is at least one query to show
/*
int i;
query q;
Results r;
String s = new String("");
for (i = 0; i < number_queries; i++)
{
q = u.get_query(Integer.toString(i));
r = q.get_results();
s += "" + "Time: " + (new Date(Long.parseLong(q.get_creation_time()))).toString()
+ " Query: " + q.get_title() + " Num of docs returned: " +
r.get_number_docs() + " There may be more documents match this query, but you need to do new query to get them " +
res.toString() +
" identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Strange request type");
return;
}
/** this method will process the request type "history_query_results
_anchor"
*/
private void process_history_query_results_anchor(request res)
{
// user wants to see the long description of clicked document
sp.AddValue("query_number", "query_number=" + res.get_query_number());
sp.AddValue("last_doc_number", "last_doc_number=" + res.get_last_doc_number());
// get the only one doc number.
Vector doc_numbers = res.get_doc_numbers();
String doc_number = (String) doc_numbers.elementAt(0);
String s = "doc_number_" + doc_number + "=on";
sp.AddValue("doc_numbers", s);
// process document full descriptions
sp.AddValue("document_full_descriptions",
longDescListInHtml(res) );
// set response template page name
html_file_name = new String("history_documents_full_description.htm");
set_status("ok");
return;
}
/** this method will process the request type "history_query_results_
done"
*/
private void process_history_query_results_done(request res)
{
// process query history information
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
//int number_queries = Integer.parseInt(u.get_number_queries());
//code modified by kwm on 04/2000
/*
int i;
query q;
Results r;
String s = new String("");
for (i = 0; i < number_queries; i++)
{
q = u.get_query(Integer.toString(i));
r = q.get_results();
s += "" + "Time: " + (new Date(Long.parseLong(q.get_creation_time()))).toString()
+ " Query: " + q.get_title() + " Num of docs returned: " +
r.get_number_docs() + " There may be more documents match this query, but you need to do new query to get them " +
res.toString() +
" identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Strange request type");
return;
}
/** this method will process the request type "history_query_information
_help_quit"
*/
private void process_history_query_information_help_quit(request res)
{
/*
sp.AddValue("query_number", "query_number=" + res.get_query_number());
sp.AddValue("last_query_number", "last_query_number=" +
res.get_last_query_number());
// process query data
// query title
sp.AddValue("query_title", "value=\"" + qd.get_title() + "\"");
Vector servers = qd.get_server_list();
uip_server server = (uip_server) servers.elementAt(0);
// field text1_type
switch (qd.get_value(server, "text1_type"))
{
case "Personal Authors":
sp.AddValue("text1_personal_quthors", "selected");
break;
case "Corporate Authors":
sp.AddValue("text1_corporate_authors", "selected");
break;
case "Conference as Author":
sp.AddValue("text1_conference_as_authors", "selected");
break;
case "Any Authors":
sp.AddValue("text1_any_authors", "selected");
break;
case "Any part of description":
sp.AddValue("text1_any_part_of_description", "selected");
break;
default:
}
// field text1
sp.AddValue("text1", "value=\"" + qd.get_value(server, "text1")
+ "\"");
// field text2_type
switch (qd.get_value(server, "text2_type"))
{
case "Words in Title":
sp.AddValue("text2_words_in_title", "selected");
break;
case "Words in Subject":
sp.AddValue("text2_words_in_subject", "selected");
break;
case "Title+Subject":
sp.AddValue("text2_title_subject", "selected");
break;
case "Words in Notes":
sp.AddValue("text2_words_in_notes", "selected");
break;
case "Title+Notes":
sp.AddValue("text2_title_notes", "selected");
break;
case "Title+Subject+Notes":
sp.AddValue("text2_title_subject_notes", "selected");
break;
case "Any Authors":
sp.AddValue("text2_any_authors", "selected");
break;
case "Any part of description":
sp.AddValue("text2_any_part_of_description", "selected");
break;
default:
}
// field text2
sp.AddValue("text2", "value=\"" + qd.get_value(server, "text2")
+ "\"");
// field text3_type
switch (qd.get_value(server, "text3_type"))
{
case "Words in Title":
sp.AddValue("text2_words_in_title", "selected");
break;
case "Words in Subject":
sp.AddValue("text2_words_in_subject", "selected");
break;
case "Title+Subject":
sp.AddValue("text2_title_subject", "selected");
break;
case "Words in Notes":
sp.AddValue("text2_words_in_notes", "selected");
break;
case "Title+Notes":
sp.AddValue("text2_title_notes", "selected");
break;
case "Title+Subject+Notes":
sp.AddValue("text2_title_subject_notes", "selected");
break;
case "Any Authors":
sp.AddValue("text2_any_authors", "selected");
break;
case "Any part of description":
sp.AddValue("text2_any_part_of_description", "selected");
break;
default:
}
// field text3
sp.AddValue("text3", "value=\"" + qd.get_value(server, "text3")
+ "\"");
// server list
Vector current_servers = uipm.get_current_servers();
String s = new String("\n \n \n");
// s += r.get_circulation();
// s += "
";
String temp1 = r.get_circulation();
int beginIdx = 0, endIdx = 0;
String temp2 = new String();
while ((endIdx = temp1.indexOf('\n', beginIdx)) != -1)
{
temp2 += temp1.substring(beginIdx, endIdx);
temp2 += "
\n";
beginIdx = endIdx + 1;
}
sp.AddValue("circulation_information",
temp2);
// set response template page name
html_file_name = new String("documents_circulation.htm");
set_status("ok");
return;
}
// circulation information is still not ready
d = new Date();
current_time = d.getTime() / 1000;
if ((current_time - start_time) > time_out_value)
{
// timer pop out
sp.AddValue("circulation_information",
"time out, you may see the results later");
// set response template page name
html_file_name = new String("documents_circulation.htm");
set_status("no circulation information returned when time out");
return;
}
} // end -- while (true)
}
public void addGetMoreButton(StringPool sp)
{
String s = new String("");
sp.AddValue("get_more", s);
}
public String makeSelectedDocString(request req)
{
// process doc numbers
Vector doc_numbers = req.get_doc_numbers();
if (doc_numbers.size() == 0)
{
// user selected nothing, send back a message to inform him/her
return( "Nothing has been selected." );
}
// user selected at least one document
int i;
StringBuffer sb = new StringBuffer();
String doc_number;
for (i = 0; i < doc_numbers.size(); i++)
{
doc_number = (String) doc_numbers.elementAt(i);
if (i == 0)
{
// the first selected document number
sb.append("doc_number_" + doc_number + "=on");
}
else
{
// not the first document number, add "/" between them
sb.append("/doc_number_" + doc_number + "=on");
}
}
return( sb.toString() );
}
public String longDescListInHtml(request req)
{
// process doc numbers
Vector doc_numbers = req.get_doc_numbers();
if (doc_numbers.size() == 0)
{
// user selected nothing, send back a message to inform him/her
return( "Nothing has been selected." );
}
// user selected at least one document
int i;
StringBuffer sb = new StringBuffer();
// process document full descriptions
user u = userm.get_user_by_name(req.get_user_name());
if (u == null) // probably the user name is invalid
{
return( "Invalid user name identified. Please press \"Back\" button to try again." );
}
// get batch size and time out value
query q = u.get_query(req.get_query_number());
query_data qd = q.get_query_data();
Results r = q.get_results();
WtdEntireObj weo;
Document doc;
sb = new StringBuffer();
for (i = 0; i < doc_numbers.size(); i++)
{
weo = r.get_doc((String) doc_numbers.elementAt(i));
if ((doc = weo.getDocument()) == null)
{
debug.dumpTrace("longDescListInHtml(): Doc '" + weo.toString()
+ "' cannot be extracted: ignoring.");
continue;
}
// If not the first document, add line between them
if (i > 0)
{
sb.append("
\n");
beginIdx = endIdx + 1;
}
**** REPLACED BY BELOW *********/
sb.append(doc.presentLong(DigInfObj.HTML));
}
return( sb.toString() );
}
/** this method will initialize the data members of this object
*/
private void init()
{
debug = null;
time = null;
status = null;
html_file_name = null;
html_file_dir = new String("pages");
uipm = null;
userm = null;
lm = null;
super_user_email = new String("france@vt.edu");
image_directory = new String("http://galahad.dlib.vt.edu/marian/images/");
}
/** this method will process the request type "welcome_new_user"
*/
private void process_welcome_new_user(request res)
{
// set reaponse template page name
html_file_name = new String("new_user_login.htm");
set_status("ok");
return;
}
/** this method will process the request type "welcome_old_user"
*/
private void process_welcome_old_user(request res)
{
// set reaponse template page name
html_file_name = new String("old_user_login.htm");
set_status("ok");
return;
}
/** this method will process the request type "system_user_information_page"
*/
private void process_system_user_information_page(request res)
{
if (res.contains("Delete").equals("yes"))
{
// the super user want to delete some users
// delete the users chosen by the super user from user manager
Vector users = res.get_user_names();
int i;
for (i = 0; i < users.size(); i++)
{
userm.delete_user((String) users.elementAt(i), "aaa");
}
// process system user information
int number_user = Integer.parseInt(userm.get_number_users());
String s = new String("");
user u = null;
for (i = 0; i < number_user; i++)
{
u = userm.get_user_at(Integer.toString(i));
if ((u != null) && ((u.get_priority() == null) ||
(! u.get_priority().equals("super user"))))
{
s += "" + "User name: " +
u.get_user_name() + " Time of creation: " +
(new Date(Long.parseLong(u.get_creation_time()))).toString()
+ " Queries performed so far: " + u.get_number_queries() + "
\n";
}
}
sp.AddValue("system_user_information", s);
// set response template page name
html_file_name = new String("system_user_information.htm");
set_status("ok");
return;
}
else if (res.contains("help").equals("yes"))
{
// set response template page name
html_file_name = new String("system_user_information_help.htm");
set_status("ok");
return;
}
// should not reach here
String err = new String("Strange request type
\n";
}
}
sp.AddValue("system_user_information", s);
// set response template page name
html_file_name = new String("system_user_information.htm");
set_status("ok");
return;
}
/** this method will process the request type "super_user_shut_down"
*/
private void process_super_user_shut_down(request res)
{
// set response template page name
html_file_name = new String("shut_down_complete.htm");
set_status("ok");
return; // not implemented yet
}
/** this method will process the request type "super_user_change_password
_page"
*/
private void process_super_user_change_password_page(request res)
{
if (res.contains("Submit").equals("yes"))
{
// user want to submit the information
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// this is not a valid user name
String err = new String("Please make sure you enter the correct user name. Press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name");
return;
}
// user name is valid
if ((res.get_password() == null) || res.get_password().equals("")
|| (! u.get_password().equals(res.get_password())))
{
// the old password the user entered is not correct
String err = new String("Please make sure you enter the correct old password. Press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid old password");
return;
}
// old password is also valid
if ((res.get_new_password() == null) || res.get_new_password().equals("")
|| (res.get_new_password().length() <= 4)
|| (res.get_password_confirm() == null)
|| res.get_password_confirm().equals("")
|| (! res.get_new_password().equals(res.get_password_confirm())))
{
// the new password and password confirm are not the same
String err = new String("Please make sure you enter the same value in the fields \"New Password\" and \"Confirm Password\". Press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("New password and password confirm not the same");
return;
}
// new password and password confirmation are the same
if (res.get_new_password().equals(res.get_password()))
{
// the new password and the old one are the same
String err = new String("Please make sure you enter a new password different from the old one. Press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("New password and the old one are the same");
return;
}
// new password is different from the old one
u.set_password(res.get_new_password());
// set response template page name
html_file_name = new String("super_user_change_password_confirm.htm");
set_status("ok");
return;
}
else if (res.contains("help").equals("yes"))
{
// set response template page name
html_file_name = new String("change_password_help.htm");
set_status("ok");
return;
}
// should not reach here
String err = new String("Strange request type
\n";
servers.removeElementAt(j);
j--;
selected = true;
break;
}
j++;
}
if (! selected)
{
// this server is not selected by the user in the previous query
s += "" + us.get_short_description() + "
\n";
}
}
// process those servers which are selected by the user in
// the previous query but not availabe now
for (i = 0; i < servers.size(); i++)
{
us = (uip_server) servers.elementAt(i);
s += us.get_hostname() + "_" + Integer.toString(us.get_port()) + "
\n";
}
sp.AddValue("server_list", s);
// process preferences
s = qd.get_preference_value("batch_size");
sp.AddValue("batch_size", "value=\"" + s + "\"");
s = qd.get_preference_value("time_out_value");
sp.AddValue("time_out_value", "value=\"" + s + "\"");
s = qd.get_preference_value("sort_rule");
sp.AddValue("sort_rule", "value=\"" + s + "\"");
s = qd.get_preference_value("display_style");
sp.AddValue("display_style", "value=\"" + s + "\"");
// set response template page name
html_file_name = new String("history_query_information.htm");
set_status("ok");
return;
}
else if (res.contains("See Previous Results of Selected Query").equals("yes"))
{
// user want to see the result documents of the selected query
// last query number will be added in the future
if (! itemIsQuery )
{
if ( itemIsFolder)
{ // user selected a folder
sp.AddValue("error_message",
"You can only view the results of queries. Please press \"Back\" button to continue.");
}
else
{ // probably user selected nothing
sp.AddValue("error_message",
"Nothing has been selected. Please press \"Back\" button to try again.");
}
// set response template page name
html_file_name = new String("error_message.htm");
set_status("No query selected");
return;
}
// process document short descriptions
String err;
query q = u.get_query(itemNumberStr);
if (q == null)
{
// probably, the query number is not valid
err = new String("Invalid query number " + itemNumberStr +
" identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid query number");
return;
}
query_data qd = q.get_query_data();
Results r = q.get_results();
int batch_size = Integer.parseInt(qd.get_preference_value("batch_size"));
int number_docs = Integer.parseInt(r.get_number_docs());
if (number_docs == 0)
{
// there is no documents to show to user
err = new String("Result is empty. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("empty results");
return;
}
// there are some documents to show to user
int endIndex;
if (number_docs > batch_size)
endIndex = batch_size-1;
else
endIndex = number_docs-1;
String htmlLinkPrefix = " batch_size)
{ // get_more button should be effective in this case
addGetMoreButton(sp);
}
else if (! r.all_in_state("QUERY_COMPLETE"))
{
sp.AddValue("get_more",
"
\n";
}*/
String s = create_query_history_table(u);
sp.AddValue("query_history_information", s);
//insert the drop down box for manipulating folders
s = create_folder_dropdown_box(u);
sp.AddValue("folder_drop_down_box", s);
// set response template page name
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
/** this method will process the request type "main_menu_edit_preference"
*/
private void process_main_menu_edit_preference(request res)
{
// process preference values
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably invalid user name
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("invalid user name");
return;
}
// process preference sort rule
if (u.get_preference_value("sort_rule") != null)
{
// fill the previous one
sp.AddValue("sort_rule", "value=\"" +
u.get_preference_value("sort_rule") + "\"");
}
else
{
// no value, use default
sp.AddValue("sort_rule", "value=closest");
}
// process preference display style
if (u.get_preference_value("display_style") != null)
{
// fill the previous one
sp.AddValue("display_style", "value=\"" +
u.get_preference_value("display_style") + "\"");
}
else
{
// no value, use default
sp.AddValue("display_style", "value=\"full screen\"");
}
// process preference time out value
if (u.get_preference_value("time_out_value") != null)
{
// fill the previous one
sp.AddValue("time_out_value", "value=\"" +
u.get_preference_value("time_out_value") + "\"");
}
else
{
// no value, use default
sp.AddValue("time_out_value", "value=60");
}
// process preference batch size
if (u.get_preference_value("batch_size") != null)
{
// fill the previous one
sp.AddValue("batch_size", "value=\"" +
u.get_preference_value("batch_size") + "\"");
}
else
{
// no value, use default
sp.AddValue("batch_size", "value=20");
}
// set response template page name
html_file_name = new String("edit_preference.htm");
set_status("ok");
return; // not implemented yet
}
/** this method will process the request type "main_menu_help_quit"
*/
private void process_main_menu_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "log_file_contents_ok"
*/
private void process_log_file_contents_ok(request res)
{
// set response template page name
html_file_name = new String("super_user.htm");
set_status("ok");
return;
}
/** this method will process the request type "log_file_contents_help_quit"
*/
private void process_log_file_contents_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "log_file_query_page"
*/
private void process_log_file_query_page(request res)
{
// process log file contents
int number_logs;
try
{
number_logs = Integer.parseInt(res.get_number_logs());
}
catch (NumberFormatException e)
{
// non integer is input
String err = new String("Please enter an integer. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Non integer identified");
return;
}
if (number_logs <= 0)
{
// out of range number is entered
String err = new String("Please enter a positive integer. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("integer less than 1 is identified");
return;
}
String s = lm.get_log_data_in_html(number_logs);
sp.AddValue("log_file_contents", s);
// set response template page name
html_file_name = new String("log_file_contents.htm");
set_status("ok");
return;
}
/** this method will process the request type "history_server_description
_ok"
*/
private void process_history_server_description_ok(request res)
{
return; // not implemented yet
}
/** this method will process the request type "history_server_description
_help_quit"
*/
private void process_history_server_description_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "history_query_results
_page"
*/
private void process_history_query_results_page(request res)
{
if (res.contains("Get More Results").equals("yes"))
{
// user want to see more results of this query
// last query number will be added in the future
if (res.get_query_number() == null)
{
// probably user selected nothing
String err = new String("Nothing has been selected. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("nothing is selected");
return;
}
// user did select some query
sp.AddValue("query_number", "query_number=" + res.get_query_number());
// process doc numbers
Vector doc_numbers = res.get_doc_numbers();
int i;
String s;
for (i = 0; i < doc_numbers.size(); i++)
{
s = (String) doc_numbers.elementAt(i);
sp.AddValue("doc_number_" + s, "checked");
}
// process document short descriptions
String err;
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
query q = u.get_query(res.get_query_number());
if (q == null)
{
// probably, the query number is not valid
err = new String("Invalid query number identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid query number");
return;
}
query_data qd = q.get_query_data();
Results r = q.get_results();
int batch_size = Integer.parseInt(qd.get_preference_value("batch_size"));
int number_docs = Integer.parseInt(r.get_number_docs());
int last_doc_number = Integer.parseInt(res.get_last_doc_number());
if (number_docs == 0)
{
// there is no documents to show to user
err = new String("Result is empty. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("empty results");
return;
}
String htmlLinkPrefix = " (batch_size + last_doc_number + 1))
endIndex = last_doc_number + batch_size;
else
endIndex = number_docs - 1;
sp.AddValue("document_short_descriptions",
r.shortDescListInHtml(htmlLinkPrefix,
batch_size, 0, endIndex) );
sp.AddValue("last_doc_number", "last_doc_number=" +
Integer.toString(endIndex + 1));
if (number_docs > (batch_size + last_doc_number + 1))
{
addGetMoreButton(sp);
}
else if (! r.all_in_state("QUERY_COMPLETE"))
{
sp.AddValue("get_more",
"
\n";
}*/
String s = create_query_history_table(u);
sp.AddValue("query_history_information", s);
//insert the drop down box for manipulating folders
s = create_folder_dropdown_box(u);
sp.AddValue("folder_drop_down_box", s);
// set response template page name
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
/** this method will process the request type "history_query_results_help
_quit"
*/
private void process_history_query_results_help_quit(request res)
{
return; // not implemented yet
}
/** this method will process the request type "history_query_information
_page"
*/
private void process_history_query_information_page(request res)
{
if (res.contains("Submit Query").equals("yes"))
{ // our client pressed the do search button
submitQuery(res);
return;
}
else if (res.contains("See Previous Results at That Time").equals("yes"))
{ // user want to see the result documents of the selected query
// NOTE: last query number will be added in the future
if (res.get_query_number() == null)
{
// probably user selected nothing
String err = new String("Nothing has been selected. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("nothing is selected");
return;
}
// user did select some query
sp.AddValue("query_number", "query_number=" + res.get_query_number());
// process document short descriptions
String err;
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
query q = u.get_query(res.get_query_number());
if (q == null)
{
// probably, the query number is not valid
err = new String("Invalid query number identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid query number");
return;
}
query_data qd = q.get_query_data();
Results r = q.get_results();
int batch_size = Integer.parseInt(qd.get_preference_value("batch_size"));
int number_docs = Integer.parseInt(r.get_number_docs());
if (number_docs == 0)
{
// there is no documents to show to user
err = new String("Result is empty. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("empty results");
return;
}
// there are some documents to show to user
int endIndex;
if (number_docs > batch_size)
endIndex = batch_size-1;
else
endIndex = number_docs-1;
String htmlLinkPrefix = " batch_size)
{ // get_more button should be effective in this case
addGetMoreButton(sp);
}
else if ( ! r.all_in_state("QUERY_COMPLETE") )
{
sp.AddValue("get_more",
"");
int i, j;
boolean checked;
uip_server server1, server2;
for (i = 0; i < current_servers.size(); i++)
{
server1 = (uip_server) current_servers.elementAt(i);
checked = false;
for (j = 0; j < servers.size(); j++)
{
server2 = (uip_server) servers.elementAt(j);
if (server1.equals(servers).equals("yes"))
{
// user checked this server before
s += "\n
\n";
sp.AddValue("server_list", s);
// preferences
Vector names = qd.get_preference_names();
String name;
for (i = 0; i < names.size(): i++)
{
name = (String) names.elementAt(i);
sp.AddValue(name, "value=\"" +
qd.get_preference_value(name) + "\"");
}
// set response template page name
html_file_name = new String("history_query_information.htm");
set_status("ok");
*/ return;
}
/**
* This method lets the user view the folders and thier contents (history).
*/
private void process_query_results_view_folders(request res)
{
// user wants to view the folders
html_file_name = new String("main_frameset.htm");
set_status("ok");
}
/**
* This method updates the folder list.
*/
private void process_query_results_view_folder_list(request res)
{
// update the folder list
user u = userm.get_user_by_name(res.get_user_name());
sp.AddValue("folder_list", u.get_folder_list_html());
html_file_name = new String("folders.htm");
set_status("ok");
}
/**
* This method opens the current folder.
*/
private void process_open_folder(request res)
{
// user wants to open the current folder
// process open folder
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
u.open_folder(res.get_folder_number());
sp.AddValue("folder_list", u.get_folder_list_html());
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
/**
* This method closes the current folder.
*/
private void process_close_folder(request res)
{
// user wants to close the current folder
// process close folder
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
u.close_folder(res.get_folder_number());
sp.AddValue("folder_list", u.get_folder_list_html());
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
/**
* This method lets the user type in the name of the new folder he/she
* wants to create.
*/
private void process_view_folder_list_new_folder(request res)
{
// user wants to create a new folder
html_file_name = new String("new_folder.htm");
set_status("ok");
}
/**
* This method lets the user type in the new name of the current folder.
*/
private void process_view_folder_list_rename_folder(request res)
{
// user wants to rename the current folder
user u = userm.get_user_by_name(res.get_user_name());
if (u.get_curr_folder().get_number().equals("0"))
{
// cannot rename the top level folder
String err = new String("You cannot rename the top level folder. Its name is your user name, and must stay that way. Please press \"Back\" button to continue.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
// rename folder
sp.AddValue("folder_name", u.get_folder_name());
html_file_name = new String("rename_folder.htm");
set_status("ok");
}
/**
* This method confirms that the user wants to delete the current folder.
*/
private void process_view_folder_list_delete_folder(request res)
{
// user wants to delete the current folder
html_file_name = new String("delete_folder_confirm.htm");
set_status("ok");
}
/**
* This method creates a new folder.
*/
private void process_new_folder(request res)
{
// create a new folder
// process new folder
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
u.new_folder(res.get_folder_name());
sp.AddValue("folder_list", u.get_folder_list_html());
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
/**
* This method deletes the current folder.
*/
public void process_delete_folder(request res)
{
// delete the current folder
// process delete folder
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
u.delete_folder();
sp.AddValue("folder_list", u.get_folder_list_html());
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
/**
* This method deletes all the folders.
*/
public void process_delete_all_folders(request res)
{
// user wants to delete all folders
// process delete all folders
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
u.delete_folders();
sp.AddValue("folder_list", u.get_folder_list_html());
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
/**
* This method renames the current folder.
*/
private void process_rename_folder(request res)
{
// rename the current folder
// process rename folder
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
u.set_folder_name(res.get_folder_name());
sp.AddValue("folder_list", u.get_folder_list_html());
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
//code added 3/2000 by KWM to format the query results table
//this function creates the folder drop down box
private String create_folder_dropdown_box(user u)
{
String s = u.get_drop_box_html();
return s;
}
//code added 3/2000 by KWM to format the query results table
private String create_query_history_table(user u)
{
int i;
query q;
Results r;
Vector queries;
int number_queries = Integer.parseInt(u.get_number_queries());
String s = new String("");
Vector folders = u.get_folders();
folder f = u.get_curr_folder();
String[] children = u.get_children(f.get_number());
String query_title = new String("");
s = "
| \n" + " | Folder Name | \n" + "Time | \n" + "
| \n" + " | " + f.get_name() + " | \n" +
" " + (new Date(Long.parseLong(f.get_creation_time()))).toString() + " | \n" + "
| \n" + " | Query Title | \n" + "Time | \n" + "
| No queries in this folder. | \n"; } else { queries = u.get_queries(); for (i = 0; i < number_queries; i++) { q = (query)queries.elementAt(i); r = q.get_results(); query_title = q.get_title(); if (query_title == "" || query_title.length() < 1) query_title = "No results for query."; s += "||
| \n" + " | " + query_title + "(" + r.get_number_docs() + ")" + " | \n" + "" + (new Date(Long.parseLong(q.get_creation_time()))).toString() + " | \n" + "
" + res.toString() + "
identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Strange request type");
return;
}
/** this method will process the request type "edit_preference_help
_quit"
*/
private void process_edit_preference_help_quit(request res)
{
/*
// process preference
preference = res.get_preference();
Vector names = pre.get_names();
int i;
String name;
for (i = 0; i < names.size(); i++)
{
name = (String) names.elementAt(i);
sp.AddValue(name, pre.get_value(name));
}
// set response template page name
html_file_name = new Strinf("edit_preference.htm");
set_status("ok");
*/ return;
}
/** this method will process the request type "documents_full_description
_circulation"
*/
private void process_documents_full_description_circulation(request res)
{
sp.AddValue("query_number", "query_number=" + res.get_query_number());
sp.AddValue("last_doc_number", "last_doc_number=" + res.get_last_doc_number());
// process doc numbers
sp.AddValue("doc_numbers", makeSelectedDocString(res));
// process circulation information
submitGetCirculation(res);
}
/** this method will process the request type "documents_full_description
_view_previous_queries"
*/
private void process_documents_full_description_view_previous_queries(
request res)
{
// process query history information
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
//int number_queries = Integer.parseInt(u.get_number_queries());
//code modified on 04/2000 by kwm
/*int i;
query q;
Results r;
String s = new String("");
for (i = 0; i < number_queries; i++)
{
q = u.get_query(Integer.toString(i));
r = q.get_results();
s += "" + "Time: " + (new Date(Long.parseLong(q.get_creation_time()))).toString()
+ " Query: " + q.get_title() + " Num of docs returned: " +
r.get_number_docs() + "
\n";
}*/
String s = create_query_history_table(u);
sp.AddValue("query_history_information", s);
//insert the drop down box for manipulating folders
s = create_folder_dropdown_box(u);
sp.AddValue("folder_drop_down_box", s);
// set response template page name
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
/** this method will process the request type "documents_full_description
_help_quit"
*/
private void process_documents_full_description_help_quit(request res)
{
/*
sp.AddValue("query_number", "query_number=" + res.get_query_number());
Vector doc_numbers = res.get_doc_numbers();
sp.AddValue("doc_numbers", makeSelectedDocList(res));
sp.AddValue("last_doc_number", "last_doc_number=" +
res.get_last_doc_number());
// set response template page name
html_file_name = new String("documents_full_description.htm");
set_status("ok");
*/ return;
}
/** this method will process the request type "documents_circulation
_view_previous_queries"
*/
private void process_documents_circulation_view_previous_queries(
request res)
{
// process query history information
user u = userm.get_user_by_name(res.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
//int number_queries = Integer.parseInt(u.get_number_queries());
//code modified by kwm on 04/2000
String s = create_query_history_table(u);
/*int i;
query q;
Results r;
String s = new String("");
for (i = 0; i < number_queries; i++)
{
q = u.get_query(Integer.toString(i));
r = q.get_results();
s += "" + "Time: " + (new Date(Long.parseLong(q.get_creation_time()))).toString()
+ " Query: " + q.get_title() + " Num of docs returned: " +
r.get_number_docs() + "
\n";
}*/
sp.AddValue("query_history_information", s);
//insert the drop down box for manipulating folders
s = create_folder_dropdown_box(u);
sp.AddValue("folder_drop_down_box", s);
// set response template page name
html_file_name = new String("main_frameset.htm");
set_status("ok");
return;
}
/** this method will process the request type "documents_circulation_
help_quit"
*/
private void process_documents_circulation_help_quit(request res)
{
/*
sp.AddValue("query_number", "query_number=" + res.get_query_number());
sp.AddValue("doc_numbers", makeSelectedDocString(res));
sp.AddValue("last_doc_number", "last_doc_number=" +
res.get_last_doc_number());
// set response template page name
html_file_name = new String("documents_circulation.htm");
set_status("ok");
*/ return;
}
/** this method will process the null request type
*/
private void processNull(request req)
{
// set response template page name
html_file_name = new String("welcome.htm");
set_status("ok");
return;
}
/** this method will process the request type "start"
*/
private void processStart(request req)
{
// set response template page name
html_file_name = new String("welcome.htm");
set_status("ok");
return;
}
/** this method will process a request for help from any page.
*/
private void processHelp(request req, String helpPageName)
{
// set response template page name
html_file_name = new String(helpPageName);
set_status("ok");
return;
}
/** this method will process the request type "help_quit"
*/
private void processHelpQuit(request req)
{
// set response template page name
html_file_name = new String("welcome.htm");
set_status("ok");
return;
}
/** this method will process a request to quit the system from any page.
*/
private void processQuitSystem(request req)
{
// set response template page name
html_file_name = new String("quit_system_confirm.htm");
set_status("ok");
return;
}
/** this method will process a request for a new query from any page.
*/
private void processNewQuery(request req)
{
// process fields default value
sp.AddValue("text1_personal_authors", "selected");
sp.AddValue("text2_words_in_title", "selected");
sp.AddValue("text3_any_part_of_description", "selected");
// process server_list
int i;
uip_server us;
String s= new String("");
Vector servers = uipm.get_current_servers();
for (i = 0; i < servers.size(); i++)
{
us = (uip_server) servers.elementAt(i);
s += "" + us.get_short_description() + "
\n";
}
sp.AddValue("server_list", s);
// process preferences
user u = userm.get_user_by_name(req.get_user_name());
if (u == null)
{
// probably the user name is invalid
String err = new String("Invalid user name identified. Please press \"Back\" button to try again.");
sp.AddValue("error_message", err);
// set response template page name
html_file_name = new String("error_message.htm");
set_status("Invalid user name identified");
return;
}
s = u.get_preference_value("batch_size");
sp.AddValue("batch_size", "value=\"" + s + "\"");
s = u.get_preference_value("time_out_value");
sp.AddValue("time_out_value", "value=\"" + s + "\"");
s = u.get_preference_value("sort_rule");
sp.AddValue("sort_rule", "value=\"" + s + "\"");
s = u.get_preference_value("display_style");
sp.AddValue("display_style", "value=\"" + s + "\"");
// set response template page name
html_file_name = new String("query_information.htm");
set_status("ok");
return;
}
/** this method will process a "done" request from most pages.
*/
private void processDone(request req)
{
// set response template page name
html_file_name = new String("main_menu.htm");
set_status("ok");
return;
}
}