/**********************************************************************************
Feedzeo!
A free and open source RSS/Atom/RDF feed aggregator
Copyright (C) 2005-2006 Anand Rao (anandrao@users.sourceforge.net)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
************************************************************************************/
/*
* AppWebAPIHandler.java
*
* This class handles the interaction between WebServer and application;
* Takes care of CGI commands got from the Webserver
*
* Created on October 22, 2005, 4:30 PM
*/
package app;
import java.util.*;
import java.io.*;
import NanoHttpd.*;
import util.*;
import data.DataElement;
/**
*
* @author Anand Rao
*/
public class AppWebAPIHandler extends FileServer implements HTTPRequestHandlerIF {
private boolean DEBUG=false; // debug flag
private String rootDir;
private AppCommandIF cmdExecuter;
/** Creates a new instance of AppWebAPIHandler */
public AppWebAPIHandler(String rootDir, AppCommandIF cmdIF) {
super(rootDir);
this.rootDir = rootDir;
cmdExecuter = cmdIF;
}
/* command=addlink&ctgy=<category>&link=<linkaddr>&output=<html|no> */
private Response handleAddLinkCmd(int code, Properties params)
{
Response errResponseNoTxt = new Response(HTTPCodes.HTTP_INTERNALERROR);
String category = params.getProperty("ctgy");
String link = params.getProperty("link");
String outputfrmt = params.getProperty("output");
if ((link == null) || (category == null)) {
if (outputfrmt.equalsIgnoreCase("html")) {
String op="<HTML><BODY> <div class=cmdResponse>Invalid argument passed</div>"
+ "</BODY></HTML>";
return new Response(HTTPCodes.HTTP_BADREQUEST,
MimeTypes.MIME_HTML, op);
}
return errResponseNoTxt;
}
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code) );
CmdInfo.addElement(category);
CmdInfo.addElement(link);
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
if (outputfrmt.equalsIgnoreCase("html")) {
String op = "<HTML><BODY> <div class=cmdResponse> Feed: <I>"+link+"</I> added"
+" successfully </div>" + "</BODY></HTML>";
return new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_HTML, op);
}
}
else { // cmd failed
if (outputfrmt.equalsIgnoreCase("html")) {
String op = "<HTML><BODY> <div class=cmdResponse> Error adding feed:"+
"<I>"+link+"</I> </B>" + "</BODY></HTML>";
return new Response(HTTPCodes.HTTP_INTERNALERROR, MimeTypes.MIME_HTML, op);
}
}
return errResponseNoTxt;
}
/* command=getcategories&output=<html|plain> */
private Response handleGetCategoriesCmd(int code, Properties params)
{
StringBuffer buf = new StringBuffer();
String outputfrmt = params.getProperty("output");
if (outputfrmt == null)
outputfrmt= new String("plain");
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code) );
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
Vector catlist = res.getResult();
int NumCategories = res.getSize();
Response resp;
if (outputfrmt.equalsIgnoreCase("html")) {
buf.append("<HTML><BODY>");
for (int i = 0;i < NumCategories; i++) {
buf.append("<B ");
buf.append(HTMLHelper.getClassString(
DataElement.CATEGORY_TITLE_ELEM)
+ " >");
buf.append((String)catlist.elementAt(i));
buf.append("</B>");
buf.append("<BR>");
}
buf.append("</BODY> </HTML>");
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_HTML, buf.toString());
}
else {
for (int i = 0;i < NumCategories; i++) {
buf.append((String) catlist.elementAt(i));
buf.append("\n");
}
// remove the last '\n'
buf.deleteCharAt(buf.length() - 1);
//System.out.println("WEBAPI GETCAT RES:"+buf.toString());
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_PLAINTEXT,
buf.toString());
}
return resp;
} // success result
else { //error
if (outputfrmt.equalsIgnoreCase("html")) {
String errStr = "<HTML><BODY> <div class=cmdResponse> Error getting "+
"category names " +"</div>" + "</BODY></HTML>";
Response errResponse = new Response(HTTPCodes.HTTP_INTERNALERROR,
MimeTypes.MIME_HTML, errStr);
return errResponse;
}
else {
return new Response (HTTPCodes.HTTP_INTERNALERROR, MimeTypes.MIME_PLAINTEXT,
"Error getting category names");
}
}
}
/* command=getfeednames&ctgy=<category name>&output=<html|plain> */
private Response handleGetFeedNamesCmd(int code, Properties params) {
String outputfrmt = params.getProperty("output");
if (outputfrmt == null)
outputfrmt= new String("plain");
String category = params.getProperty("ctgy");
if (category == null) { // return error
if (outputfrmt.equalsIgnoreCase("html")) {
String op="<HTML><BODY> <div class=cmdResponse>Invalid argument passed</div>"
+ "</BODY></HTML>";
return new Response(HTTPCodes.HTTP_BADREQUEST,
MimeTypes.MIME_HTML, op);
}
else {
return new Response (HTTPCodes.HTTP_BADREQUEST, MimeTypes.MIME_PLAINTEXT,
"Invalid argument passed");
}
}
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code) );
CmdInfo.addElement(category);
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
Vector feedNames = res.getResult();
int numFeeds = res.getSize();
StringBuffer op = new StringBuffer();
Response resp;
if (outputfrmt.equalsIgnoreCase("html")) {
op.append("<HTML><BODY>");
for (int i=0;i < numFeeds; i++) {
op.append("<B ");
op.append(HTMLHelper.getClassString(DataElement.FEED_TITLE_ELEM));
op.append(" >");
op.append((String)feedNames.elementAt(i));
op.append("</B>");
op.append("<BR>");
}
op.append("</BODY></HTML>");
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_HTML, op.toString());
}
else { //return o/p as plain text
for (int i=0;i < numFeeds; i++) {
op.append((String)feedNames.elementAt(i));
op.append("\n");
}
// remove the last '\n'
op.deleteCharAt(op.length() - 1);
//System.out.println("WEBAPI GETFEEDNAMES RES:"+op.toString());
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_PLAINTEXT,
op.toString());
}
return resp;
}
else { //error
if (outputfrmt.equalsIgnoreCase("html")) {
String errStr = "<HTML><BODY> <div class=cmdResponse> Error getting "+
"feed names " +"</div>" + "</BODY></HTML>";
Response errResponse = new Response(HTTPCodes.HTTP_INTERNALERROR,
MimeTypes.MIME_HTML, errStr);
return errResponse;
}
else {
return new Response (HTTPCodes.HTTP_INTERNALERROR, MimeTypes.MIME_PLAINTEXT,
"Error getting feed names");
}
}
}
/*
* Get feed names with the page link for the generated page;
* If boolean allCategories is true, then the returned response
* contains all the feed names across all categories
* command=getfeednameswpagelink&ctgy=<category name>&output=<html|plain>
* OR
* command=getallfeednameswpagelink&output=<html|plain>
*/
private Response handleGetFeedNamesWithPageLinkCmd(int code, Properties params,
boolean allCategories)
{
String category=null;
String outputfrmt = params.getProperty("output");
if (outputfrmt == null)
outputfrmt= new String("plain");
if (allCategories == false) {
category = params.getProperty("ctgy");
if (category == null) {
if (outputfrmt.equalsIgnoreCase("html")) {
String op="<HTML><BODY> <div class=cmdResponse>Invalid argument "+
"passed</div>"+ "</BODY></HTML>";
return new Response(HTTPCodes.HTTP_BADREQUEST,
MimeTypes.MIME_HTML, op);
}
else {
return new Response (HTTPCodes.HTTP_BADREQUEST, MimeTypes.MIME_PLAINTEXT,
"Invalid argument passed");
}
}
}
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code));
if (category != null)
CmdInfo.addElement(category);
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
StringBuffer buf = new StringBuffer();
Vector feedlist = res.getResult();
Response resp;
/*
* the result is given back in the form
* feedname, pagelink
* ....
*/
if (outputfrmt.equalsIgnoreCase("plain")) {
for (int i=0;i < res.getSize(); i++) {
buf.append((String)feedlist.elementAt(i));
buf.append("\n");
}
// remove the last '\n'
buf.deleteCharAt(buf.length() - 1);
//System.out.println("WEBAPI GETFEEDPAGELNK RES:"+buf.toString());
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_PLAINTEXT,
buf.toString());
}
else {
/*
* send out
* <HTML> <BODY>
* <a class=feedpagelink href=link> Feedname </a>
* ...
* </BODY> </HTML>
*/
buf.append("<HTML> <BODY>");
for (int i=0;i < res.getSize(); i++) {
StringTokenizer st = new StringTokenizer((String)feedlist.elementAt(i),
"\t");
String feedname = st.nextToken();
String link = st.nextToken();
if (DEBUG) {
System.out.println("FEEDLIST:"+ (String)feedlist.elementAt(i));
System.out.println("NAME:"+feedname+" LINK:"+link);
}
buf.append("<A class=feedpagelink "+
HTMLHelper.toHREFString(link) + ">"+
feedname+ "</A>");
buf.append("<BR>");
}
buf.append("</BODY> </HTML> ");
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_HTML, buf.toString());
}
return resp;
}
else { //error
if (outputfrmt.equalsIgnoreCase("html")) {
String errStr = "<HTML><BODY> <div class=cmdResponse> Error getting "+
"feednames and pagelinks " +"</div>" + "</BODY></HTML>";
Response errResponse = new Response(HTTPCodes.HTTP_INTERNALERROR,
MimeTypes.MIME_HTML, errStr);
return errResponse;
}
else {
return new Response (HTTPCodes.HTTP_INTERNALERROR, MimeTypes.MIME_PLAINTEXT,
"Error getting feednames and pagelinks");
}
}
}
/*
* Get feed names with the tabledata page link for the generated page;
* If boolean allCategories is true, then the returned response
* contains all the feed names across all categories
* command=getfeednameswtabledatapagelink&ctgy=<category name>&output=<html|plain>
* OR
* command=getallfeednameswtabledatapagelink&output=<html|plain>
*/
private Response handleGetFeedNamesWithTableDataPageLinkCmd(int code, Properties params,
boolean allCategories)
{
String category=null;
String outputfrmt = params.getProperty("output");
if (outputfrmt == null)
outputfrmt= new String("plain");
if (allCategories == false) {
category = params.getProperty("ctgy");
if (category == null) {
if (outputfrmt.equalsIgnoreCase("html")) {
String op="<HTML><BODY> <div class=cmdResponse>Invalid argument "+
"passed</div>"+ "</BODY></HTML>";
return new Response(HTTPCodes.HTTP_BADREQUEST,
MimeTypes.MIME_HTML, op);
}
else {
return new Response (HTTPCodes.HTTP_BADREQUEST, MimeTypes.MIME_PLAINTEXT,
"Invalid argument passed");
}
}
}
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code));
if (category != null)
CmdInfo.addElement(category);
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
StringBuffer buf = new StringBuffer();
Vector feedlist = res.getResult();
Response resp;
/*
* the result is given back in the form
* feedname, pagelink
* ....
*/
if (outputfrmt.equalsIgnoreCase("plain")) {
for (int i=0;i < res.getSize(); i++) {
buf.append((String)feedlist.elementAt(i));
buf.append("\n");
}
// remove the last '\n'
buf.deleteCharAt(buf.length() - 1);
//System.out.println("WEBAPI TABLEDATA RES:"+buf.toString());
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_PLAINTEXT,
buf.toString());
}
else {
/*
* send out
* <HTML> <BODY>
* <a class=feedtabledatapagelink href=link> Feedname </a>
* ...
* </BODY> </HTML>
*/
buf.append("<HTML> <BODY>");
for (int i=0;i < res.getSize(); i++) {
StringTokenizer st = new StringTokenizer((String)feedlist.elementAt(i),
"\t");
String feedname = st.nextToken();
String link = st.nextToken();
if (DEBUG) {
System.out.println("FEEDLIST:"+ (String)feedlist.elementAt(i));
System.out.println("NAME:"+feedname+" LINK:"+link);
}
buf.append("<A class=feedtabledatapagelink "+
HTMLHelper.toHREFString(link) + ">"+
feedname+ "</A>");
buf.append("<BR>");
}
buf.append("</BODY> </HTML> ");
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_HTML, buf.toString());
}
return resp;
}
else { //error
if (outputfrmt.equalsIgnoreCase("html")) {
String errStr = "<HTML><BODY> <div class=cmdResponse> Error getting "+
"feednames and tabledata " +"</div>" + "</BODY></HTML>";
Response errResponse = new Response(HTTPCodes.HTTP_INTERNALERROR,
MimeTypes.MIME_HTML, errStr);
return errResponse;
}
else {
return new Response (HTTPCodes.HTTP_INTERNALERROR, MimeTypes.MIME_PLAINTEXT,
"Error getting feednames and tabledata");
}
}
}
private Response handleGetStyleInfoCmd(int code, Properties params) {
String errStr = "<HTML><BODY> <div class=cmdResponse> Error retrieving style information "
+"</div>" + "</BODY></HTML>";
Response errResponse = new Response(HTTPCodes.HTTP_INTERNALERROR,
MimeTypes.MIME_HTML, errStr);
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code));
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
String styledata = (String) (res.getResult()).elementAt(0);
return new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_PLAINTEXT, styledata);
}
return errResponse;
}
private Response handleSaveStyleInfoCmd(int code, Properties params) {
String errStr = "<HTML><BODY> <div class=cmdResponse> Error saving style information "
+"</div>" + "</BODY></HTML>";
Response errResponse = new Response(HTTPCodes.HTTP_INTERNALERROR,
MimeTypes.MIME_HTML, errStr);
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code));
CmdInfo.addElement(params.getProperty("data"));
//System.out.println("handleSaveStyleInfoCmd: data= "+params.getProperty("data"));
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
StringBuffer sb = new StringBuffer();
sb.append("<html> <body> <b> Style information saved sucessfully </b> </body> </html>");
return new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_HTML, sb.toString());
}
return errResponse;
}
/*
* Get feed names with feedsource link for the generated page;
* command=getfeednameswfeedsourcelink&ctgy=<category name>
*/
private Response handleGetFeedNamesWithFeedSourceLinkCmd(int code, Properties params)
{
String category=null;
category = params.getProperty("ctgy");
if (category == null) {
return new Response (HTTPCodes.HTTP_BADREQUEST, MimeTypes.MIME_PLAINTEXT,
"Invalid argument passed");
}
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code));
if (category != null)
CmdInfo.addElement(category);
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
StringBuffer buf = new StringBuffer();
Vector feedlist = res.getResult();
Response resp;
/*
* the result is given back in the form
* feedname, feedsourcelink
* ....
*/
for (int i=0;i < res.getSize(); i++) {
buf.append((String)feedlist.elementAt(i));
buf.append("\n");
}
// remove the last '\n'
buf.deleteCharAt(buf.length() - 1);
//System.out.println("WEBAPI GETFEEDNAMESOURCELNK RES:"+buf.toString());
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_PLAINTEXT,
buf.toString());
return resp;
}
else { //error
return new Response (HTTPCodes.HTTP_INTERNALERROR, MimeTypes.MIME_PLAINTEXT,
"Error getting feednames and feedsource link");
}
}
/* command=dellink&ctgy=<category>&link=<linkaddr>&output=<html|no> */
private Response handleDeleteLinkCmd(int code, Properties params)
{
Response errResponseNoTxt = new Response(HTTPCodes.HTTP_INTERNALERROR);
String category = params.getProperty("ctgy");
String link = params.getProperty("link");
String outputfrmt = params.getProperty("output");
if ((link == null) || (category == null)) {
if (outputfrmt.equalsIgnoreCase("html")) {
String op="<HTML><BODY> <div class=cmdResponse>Invalid argument passed</div>"
+ "</BODY></HTML>";
return new Response(HTTPCodes.HTTP_BADREQUEST,
MimeTypes.MIME_HTML, op);
}
return errResponseNoTxt;
}
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code));
CmdInfo.addElement(category);
CmdInfo.addElement(link);
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
if (outputfrmt.equalsIgnoreCase("html")) {
String op = "<HTML><BODY> <div class=cmdResponse> Feed:<I>"+link+"</I> deleted"
+" successfully </div>" + "</BODY></HTML>";
return new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_HTML, op);
}
}
else { // cmd failed
if (outputfrmt.equalsIgnoreCase("html")) {
String op = "<HTML><BODY> <div class=cmdResponse> Error deleting feed:"+
"<I>"+link+"</I> </B>" + "</BODY></HTML>";
return new Response(HTTPCodes.HTTP_INTERNALERROR, MimeTypes.MIME_HTML, op);
}
}
return errResponseNoTxt;
}
/* command=getfeednameswtabledatapagelinkfrmsourceurl&ctgy=<category>&link=<linkaddr> */
private Response handleGetFeednamesPageLinkFromSourceUrlCmd(int code, Properties params)
{
Response errResponseNoTxt = new Response(HTTPCodes.HTTP_INTERNALERROR);
String category = params.getProperty("ctgy");
String link = params.getProperty("link");
if ((link == null) || (category == null)) {
return errResponseNoTxt;
}
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code));
CmdInfo.addElement(category);
CmdInfo.addElement(link);
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
StringBuffer buf = new StringBuffer();
Vector feedlist = res.getResult();
Response resp;
/*
* the result is given back in the form
* feedname, pagelink
* ....
*/
for (int i=0;i < res.getSize(); i++) {
buf.append((String)feedlist.elementAt(i));
buf.append("\n");
}
// remove the last '\n'
buf.deleteCharAt(buf.length() - 1);
//System.out.println("WEBAPI GETFEEDNAMEPGLNKFRMSOURCEURL RES:"+buf.toString());
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_PLAINTEXT,
buf.toString());
return resp;
}
else { //error
return new Response (HTTPCodes.HTTP_INTERNALERROR, MimeTypes.MIME_PLAINTEXT,
"Error getting feednames and page link");
}
}
/* command=opmlimport&ctgy=<category>&source=<inputfile> */
private Response handleOpmlImportCmd(int code, Properties params)
{
Response errResponseNoTxt = new Response(HTTPCodes.HTTP_INTERNALERROR);
String category = params.getProperty("ctgy");
String source = params.getProperty("source");
if ((source == null) || (category == null)) {
return errResponseNoTxt;
}
Vector CmdInfo = new Vector();
CmdInfo.addElement( new Integer(code));
CmdInfo.addElement(category);
CmdInfo.addElement(source);
CmdResult res = cmdExecuter.handleCommand(CmdInfo);
if (res.getReturnCode() == CmdResult.SUCESS_CODE) {
Response resp;
StringBuffer buf = new StringBuffer();
Vector retVect = res.getResult();
buf.append("<html> <body> <div class=cmdResponse> ");
for (int i=0;i < res.getSize(); i++) {
buf.append((String) retVect.elementAt(i));
buf.append("<br>");
}
buf.append(" </div> </body> </html>");
resp = new Response(HTTPCodes.HTTP_OK, MimeTypes.MIME_HTML,
buf.toString());
return resp;
}
else { //error
return new Response (HTTPCodes.HTTP_INTERNALERROR, MimeTypes.MIME_HTML,
"<html> <body> <div class=cmdResponse> Error occured during OPML import </div> </body> </html>");
}
}
private Response handleCGIRequest(String uri, String method,
Properties header, Properties params)
{
String command = params.getProperty("command");
if (command == null) return new Response();
System.out.println("CGI cmd:"+command);
int code = AppCmd.getOpCode(command);
switch (code) {
case AppCmd.ADD_LINK:
return handleAddLinkCmd(code, params);
case AppCmd.OPML_IMPORT:
return handleOpmlImportCmd(code, params);
case AppCmd.GET_CATEGORIES:
return handleGetCategoriesCmd(code, params);
case AppCmd.GET_FEEDNAMES:
return handleGetFeedNamesCmd(code, params);
case AppCmd.GET_FEEDNAMES_W_PAGE_LINK:
return handleGetFeedNamesWithPageLinkCmd(code, params, false);
case AppCmd.GET_ALL_FEEDNAMES_W_PAGE_LINK:
return handleGetFeedNamesWithPageLinkCmd(code, params, true);
case AppCmd.GET_FEEDNAMES_W_TABLEDATA_PAGE_LINK:
return handleGetFeedNamesWithTableDataPageLinkCmd(code, params, false);
case AppCmd.GET_ALL_FEEDNAMES_W_TABLEDATA_PAGE_LINK:
return handleGetFeedNamesWithTableDataPageLinkCmd(code, params, true);
case AppCmd.GET_STYLE_INFO:
return handleGetStyleInfoCmd(code, params);
case AppCmd.SAVE_STYLE_INFO:
return handleSaveStyleInfoCmd(code, params);
case AppCmd.GET_FEEDNAMES_W_FEEDSOURCE_LINK:
return handleGetFeedNamesWithFeedSourceLinkCmd(code, params);
case AppCmd.DEL_LINK:
return handleDeleteLinkCmd(code, params);
case AppCmd.GET_FEEDNAMES_W_TABLEDATA_PAGE_LINK_FRM_SOURCEURL:
return handleGetFeednamesPageLinkFromSourceUrlCmd(code, params);
default:
break;
}
return new Response();
}
public Response serve(String uri, String method, Properties header,
Properties parms)
{
Enumeration e = parms.propertyNames();
if (DEBUG) {
int i=0; Enumeration tmp = parms.propertyNames();
while (tmp.hasMoreElements()) {
System.out.println("PARAM["+i+"]="+"<"+tmp.nextElement()+">");
i++;
}
}
if (e.hasMoreElements()) // the user passed a CGI request
// which results in parameters being
// sent through HTTP message.
return handleCGIRequest(uri, method, header, parms);
else return serveFile( uri, header, new File(rootDir), true );
}
}
|