some serious new feature implementation:
- cookie-based persistent logins - expanded activity reporting - "top" and "fixed" left menus are now dynamically generated from XML config, not hard coded - error reporting enhanced and protection increased - "About Venice" page first draft - new means of "framing" static content within the Venice "frame" - base page now includes the "footer" itself, "content" pages don't anymore - general cleanup of some heavyweight old containers, replaced with faster Collections framework containers - probably more, there's a LOT of stuff in here
This commit is contained in:
@@ -36,6 +36,8 @@ public class Account extends VeniceServlet
|
||||
|
||||
private static final String DISPLAY_LOGIN_ATTR = "com.silverwrist.venice.servlets.internal.DisplayLogin";
|
||||
|
||||
private static final int COOKIE_LIFETIME = 60*60*24*365; // one year
|
||||
|
||||
private static Category logger = Category.getInstance(Account.class.getName());
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
@@ -159,6 +161,11 @@ public class Account extends VeniceServlet
|
||||
if (user.isLoggedIn())
|
||||
{ // this is a Logout command
|
||||
clearUserContext(request);
|
||||
|
||||
// delete the "login" cookie
|
||||
Cookie del_login_info = rdat.createCookie(Variables.LOGIN_COOKIE,"",0);
|
||||
Variables.saveCookie(request,del_login_info);
|
||||
|
||||
throw new RedirectResult("top"); // take 'em back to the "top" page
|
||||
|
||||
} // end if
|
||||
@@ -299,7 +306,15 @@ public class Account extends VeniceServlet
|
||||
{ // use the user context to authenticate
|
||||
user.authenticate(dlg.getFieldValue("user"),dlg.getFieldValue("pass"));
|
||||
|
||||
// TODO: here is where the persistent cookie gets sent, if it does...
|
||||
// If they want a cookie, give it to them!
|
||||
final String yes = "Y";
|
||||
if (yes.equals(dlg.getFieldValue("saveme")))
|
||||
{ // create the authentication cookie and save it
|
||||
Cookie auth_cookie = rdat.createCookie(Variables.LOGIN_COOKIE,user.getAuthenticationToken(),
|
||||
COOKIE_LIFETIME);
|
||||
Variables.saveCookie(request,auth_cookie);
|
||||
|
||||
} // end if
|
||||
|
||||
// assuming it worked OK, redirect them back where they came from
|
||||
// (or to the verification page if they need to go there)
|
||||
|
||||
@@ -486,15 +486,43 @@ public class ConfOperations extends VeniceServlet
|
||||
|
||||
} // end if ("A" command)
|
||||
|
||||
if (cmd.equals("RP") || cmd.equals("RR"))
|
||||
{ // "RP" = "Report Posters," "RR" = "Report Readers" (requires conference parameter)
|
||||
if (cmd.equals("QR"))
|
||||
{ // "QR" = "Reports Menu" (requires conference parameter)
|
||||
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
|
||||
on_error = "confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=Q";
|
||||
|
||||
try
|
||||
{ // display the "Conference Reports" display
|
||||
setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=QR");
|
||||
return new ReportConferenceMenu(sig,conf);
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // unable to get the data for the list
|
||||
return new ErrorBox("Database Error","Database error getting topic list: " + de.getMessage(),on_error);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // some sort of access error - display an error dialog
|
||||
return new ErrorBox("Access Error",ae.getMessage(),on_error);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if ("QR" command)
|
||||
|
||||
if (cmd.equals("RP") || cmd.equals("RR"))
|
||||
{ // "RP" = "Report Posters," "RR" = "Report Readers" (requires conference parameter, optional topic)
|
||||
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
|
||||
TopicContext topic = getTopicParameter(request,conf,false,on_error);
|
||||
on_error = "confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=QR";
|
||||
|
||||
try
|
||||
{ // generate the listing on this page
|
||||
setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=" + cmd);
|
||||
return new ConferenceActivity(sig,conf,cmd.equals("RP"));
|
||||
String my_loc = "confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
|
||||
if (topic!=null)
|
||||
my_loc += ("&top=" + topic.getTopicNumber());
|
||||
setMyLocation(request,my_loc + "&cmd=" + cmd);
|
||||
return new ConferenceActivity(sig,conf,topic,cmd.equals("RP"));
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
|
||||
63
src/com/silverwrist/venice/servlets/FrameStatic.java
Normal file
63
src/com/silverwrist/venice/servlets/FrameStatic.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class FrameStatic extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(FrameStatic.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "FrameStatic servlet - Displays a static page inside the Venice \"frame\"\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class VeniceServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
|
||||
UserContext user, RenderData rdat)
|
||||
throws ServletException, IOException, VeniceServletResult
|
||||
{
|
||||
setMyLocation(request,"frame" + request.getPathInfo());
|
||||
return StaticRender.getStaticRender(request.getPathInfo().substring(1));
|
||||
|
||||
} // end doVeniceGet
|
||||
|
||||
} // end class FrameStatic
|
||||
@@ -31,7 +31,7 @@ public class UserDisplay extends VeniceServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(UserDisplay.class.getName());
|
||||
private static Category logger = Category.getInstance(UserDisplay.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Community System.
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
@@ -23,6 +23,7 @@ import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
import com.silverwrist.venice.servlets.format.menus.LeftMenu;
|
||||
|
||||
public class Variables
|
||||
{
|
||||
@@ -35,19 +36,21 @@ public class Variables
|
||||
protected static final String ENGINE_ATTRIBUTE = "com.silverwrist.venice.core.Engine";
|
||||
protected static final String COUNTRYLIST_ATTRIBUTE = "com.silverwrist.venice.db.CountryList";
|
||||
protected static final String LANGUAGELIST_ATTRIBUTE = "com.silverwrist.venice.db.LanguageList";
|
||||
protected static final String TOPMENU_ATTRIBUTE = "com.silverwrist.venice.servlets.MenuTop";
|
||||
|
||||
// HttpSession ("session") attributes
|
||||
protected static final String USERCTXT_ATTRIBUTE = "user.context";
|
||||
protected static final String MENU_ATTRIBUTE = "current.menu";
|
||||
|
||||
// ServletRequest ("request" attributes)
|
||||
protected static final String COOKIEJAR_ATTRIBUTE = "com.silverwrist.venice.servlets.CookieJar";
|
||||
|
||||
// Servlet initialization parameters
|
||||
protected static final String ENGINE_INIT_PARAM = "venice.config";
|
||||
|
||||
// Cookie name
|
||||
public static final String LOGIN_COOKIE = "VeniceLogin";
|
||||
public static final String LOGIN_COOKIE = "VeniceAuth";
|
||||
|
||||
private static Category logger = Category.getInstance(Variables.class.getName());
|
||||
private static Category logger = Category.getInstance(Variables.class);
|
||||
private static Integer engine_gate = new Integer(0);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
@@ -90,7 +93,8 @@ public class Variables
|
||||
|
||||
} // end getVeniceEngine
|
||||
|
||||
public static UserContext getUserContext(ServletContext ctxt, ServletRequest request, HttpSession session)
|
||||
public static UserContext getUserContext(ServletContext ctxt, HttpServletRequest request,
|
||||
HttpSession session)
|
||||
throws ServletException
|
||||
{
|
||||
Object uctmp = session.getAttribute(USERCTXT_ATTRIBUTE);
|
||||
@@ -101,6 +105,33 @@ public class Variables
|
||||
{ // use the Venice engine to create a new user context and save it off
|
||||
VeniceEngine engine = getVeniceEngine(ctxt);
|
||||
UserContext user = engine.createUserContext(request.getRemoteAddr());
|
||||
|
||||
// Did the user send a Venice authentication cookie? If so, try to use it.
|
||||
Cookie[] cookies = request.getCookies();
|
||||
Cookie venice_cookie = null;
|
||||
for (int i=0; (venice_cookie==null) && (i<cookies.length); i++)
|
||||
{ // look for a Venice authentication cookie
|
||||
if (LOGIN_COOKIE.equals(cookies[i].getName()))
|
||||
venice_cookie = cookies[i];
|
||||
|
||||
} // end for
|
||||
|
||||
if (venice_cookie!=null)
|
||||
{ // we've found the cookie - now attempt to authenticate with it
|
||||
if (!(user.authenticateWithToken(venice_cookie.getValue())))
|
||||
{ // the authentication failed - this cookie MUST be bogus, delete it!
|
||||
Cookie zapper = new Cookie(LOGIN_COOKIE,"");
|
||||
zapper.setMaxAge(0);
|
||||
zapper.setPath(request.getContextPath());
|
||||
saveCookie(request,zapper);
|
||||
|
||||
} // end if
|
||||
// else we're authenticated - let the cookie stay!
|
||||
|
||||
} // end if
|
||||
// else don't bother trying to authenticate
|
||||
|
||||
// save the user context off as usual and return it
|
||||
session.setAttribute(USERCTXT_ATTRIBUTE,user);
|
||||
return user;
|
||||
|
||||
@@ -185,18 +216,31 @@ public class Variables
|
||||
public static void setMenuTop(ServletContext ctxt, HttpSession session)
|
||||
{
|
||||
Object obj = session.getAttribute(MENU_ATTRIBUTE);
|
||||
if ((obj==null) || !(obj instanceof MenuTop))
|
||||
{ // look for the common MenuTop object and set it to the session context
|
||||
obj = ctxt.getAttribute(TOPMENU_ATTRIBUTE);
|
||||
if (obj==null)
|
||||
{ // we don't have a common MenuTop yet...make one
|
||||
MenuTop mt = new MenuTop();
|
||||
ctxt.setAttribute(TOPMENU_ATTRIBUTE,mt);
|
||||
obj = mt;
|
||||
boolean do_change;
|
||||
if ((obj==null) || !(obj instanceof LeftMenu))
|
||||
do_change = true;
|
||||
else
|
||||
{ // look to see if this is the "top" menu
|
||||
LeftMenu mnu = (LeftMenu)obj;
|
||||
do_change = !(mnu.getIdentifier().equals("top"));
|
||||
|
||||
} // end if
|
||||
} // end else
|
||||
|
||||
session.setAttribute(MENU_ATTRIBUTE,obj);
|
||||
if (do_change)
|
||||
{ // get the new menu from the RenderConfig object and save it
|
||||
try
|
||||
{ // but note that getting the rendering configuration can throw a ServletException
|
||||
RenderConfig cfg = RenderConfig.getRenderConfig(ctxt);
|
||||
LeftMenu new_mnu = cfg.getLeftMenu("top");
|
||||
session.setAttribute(MENU_ATTRIBUTE,new_mnu);
|
||||
|
||||
} // end try
|
||||
catch (ServletException e)
|
||||
{ // if we fail, just clear it out
|
||||
logger.warn("caught ServletException in setMenuTop",e);
|
||||
session.removeAttribute(MENU_ATTRIBUTE);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
@@ -237,4 +281,41 @@ public class Variables
|
||||
|
||||
} // end failIfNull
|
||||
|
||||
public static void saveCookie(ServletRequest request, Cookie cookie)
|
||||
{
|
||||
ArrayList cookiejar = null;
|
||||
Object o = request.getAttribute(COOKIEJAR_ATTRIBUTE);
|
||||
if ((o==null) || !(o instanceof ArrayList))
|
||||
{ // create a new cookie jar and save it
|
||||
cookiejar = new ArrayList();
|
||||
request.setAttribute(COOKIEJAR_ATTRIBUTE,cookiejar);
|
||||
|
||||
} // end if
|
||||
else // found our cookie jar
|
||||
cookiejar = (ArrayList)o;
|
||||
|
||||
// save the cookie in the cookie jar (to be flushed later)
|
||||
cookiejar.add(cookie);
|
||||
|
||||
} // end saveCookie
|
||||
|
||||
public static void flushCookies(ServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
Object o = request.getAttribute(COOKIEJAR_ATTRIBUTE);
|
||||
request.removeAttribute(COOKIEJAR_ATTRIBUTE);
|
||||
if (o instanceof ArrayList)
|
||||
{ // found the cookie jar - now take the cookies out and add them to the response
|
||||
ArrayList cookiejar = (ArrayList)o;
|
||||
Iterator it = cookiejar.iterator();
|
||||
while (it.hasNext())
|
||||
{ // add each cookie in turn
|
||||
Cookie cookie = (Cookie)(it.next());
|
||||
response.addCookie(cookie);
|
||||
|
||||
} // end while
|
||||
|
||||
} // end if
|
||||
|
||||
} // end flushCookies
|
||||
|
||||
} // end class Variables
|
||||
|
||||
@@ -67,8 +67,7 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
} // end if
|
||||
else
|
||||
{ // a null SIGContext is permitted
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("no SIG specified");
|
||||
logger.debug("no SIG specified");
|
||||
return null;
|
||||
|
||||
} // end else
|
||||
@@ -78,7 +77,15 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
SIGContext rc = null;
|
||||
try
|
||||
{ // turn the string into a SIGID, and thence to a SIGContext
|
||||
rc = user.getSIGContext(Integer.parseInt(str));
|
||||
int tmp_id = Integer.parseInt(str);
|
||||
rc = user.getSIGContext(tmp_id);
|
||||
if (rc==null)
|
||||
{ // trap any null results (may not be possible with SIGs, but you never know)
|
||||
logger.error("SIG #" + tmp_id + " was not found!");
|
||||
throw new ErrorBox(null,"The specified SIG (#" + tmp_id + ") was not found in the database.",on_error);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found SIG #" + rc.getSIGID());
|
||||
|
||||
@@ -112,8 +119,7 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
} // end if
|
||||
else
|
||||
{ // a null TopicContext is permitted
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("no topic specified");
|
||||
logger.debug("no topic specified");
|
||||
return null;
|
||||
|
||||
} // end else
|
||||
@@ -122,8 +128,17 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
|
||||
TopicContext rc = null;
|
||||
try
|
||||
{ // turn the string into a TopicID, and thence to a TopicContext
|
||||
rc = conf.getTopic(Short.parseShort(str));
|
||||
{ // turn the string into a topic number, and thence to a TopicContext
|
||||
short tmp_id = Short.parseShort(str);
|
||||
rc = conf.getTopic(tmp_id);
|
||||
if (rc==null)
|
||||
{ // the topic was not found!
|
||||
logger.error("ConfID #" + conf.getConfID() + " did not have topic #" + tmp_id);
|
||||
throw new ErrorBox(null,"Topic #" + tmp_id + " was not found in the '" + conf.getName()
|
||||
+ "' conference.",on_error);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found topic #" + rc.getTopicID());
|
||||
|
||||
@@ -162,8 +177,7 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
} // end if
|
||||
else
|
||||
{ // a null TopicMessageContext is permitted
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("no message specified");
|
||||
logger.debug("no message specified");
|
||||
return null;
|
||||
|
||||
} // end else
|
||||
@@ -173,7 +187,16 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
TopicMessageContext rc = null;
|
||||
try
|
||||
{ // turn the string into a postid, and thence to a TopicMessageContext
|
||||
rc = conf.getMessageByPostID(Long.parseLong(str));
|
||||
long tmp_id = Long.parseLong(str);
|
||||
rc = conf.getMessageByPostID(tmp_id);
|
||||
if (rc==null)
|
||||
{ // the message was not found
|
||||
logger.error("ConfID #" + conf.getConfID() + " does not contain postid " + tmp_id);
|
||||
throw new ErrorBox(null,"The post with ID number " + tmp_id + " was not found in the '"
|
||||
+ conf.getName() + "' conference.",on_error);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found post #" + rc.getPostID());
|
||||
|
||||
@@ -212,8 +235,7 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
} // end if
|
||||
else
|
||||
{ // a null TopicMessageContext is permitted
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("no message specified");
|
||||
logger.debug("no message specified");
|
||||
return null;
|
||||
|
||||
} // end else
|
||||
@@ -223,7 +245,16 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
TopicMessageContext rc = null;
|
||||
try
|
||||
{ // turn the string into a post number, and thence to a TopicMessageContext
|
||||
rc = topic.getMessage(Integer.parseInt(str));
|
||||
int tmp_id = Integer.parseInt(str);
|
||||
rc = topic.getMessage(tmp_id);
|
||||
if (rc==null)
|
||||
{ // could not find the message
|
||||
logger.error("TopicID " + topic.getTopicID() + " does not contain message #" + tmp_id);
|
||||
throw new ErrorBox(null,"There is no message #" + tmp_id + " in the '" + topic.getName() + "' topic.",
|
||||
on_error);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found post #" + rc.getPostID());
|
||||
|
||||
@@ -360,8 +391,7 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
} // end if
|
||||
else
|
||||
{ // a null ConferenceContext is permitted
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("no conference specified");
|
||||
logger.debug("no conference specified");
|
||||
return null;
|
||||
|
||||
} // end else
|
||||
@@ -371,7 +401,16 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
ConferenceContext rc = null;
|
||||
try
|
||||
{ // turn the string into a ConfID, and thence to a ConferenceContext
|
||||
rc = sig.getConferenceContext(Integer.parseInt(str));
|
||||
int tmp_id = Integer.parseInt(str);
|
||||
rc = sig.getConferenceContext(tmp_id);
|
||||
if (rc==null)
|
||||
{ // couldn't find the conference
|
||||
logger.error("SIG #" + sig.getSIGID() + " does not contain conference #" + tmp_id);
|
||||
throw new ErrorBox(null,"The conference #" + tmp_id + " could not be found in the '" + sig.getName()
|
||||
+ "' SIG.",on_error);
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("found conf #" + rc.getConfID());
|
||||
|
||||
@@ -517,45 +556,79 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
{
|
||||
ServletContext ctxt = getServletContext();
|
||||
VeniceEngine engine = Variables.getVeniceEngine(ctxt);
|
||||
UserContext user = Variables.getUserContext(ctxt,request,request.getSession(true));
|
||||
RenderData rdat = RenderConfig.createRenderData(ctxt,request,response);
|
||||
VeniceContent content = null;
|
||||
|
||||
// Make all log messages for the request carry the remote address.
|
||||
NDC.push(request.getRemoteAddr());
|
||||
try
|
||||
{ // run the actual "get" in the servlet
|
||||
content = doVeniceGet(request,engine,user,rdat);
|
||||
{ // get the user context
|
||||
UserContext user = Variables.getUserContext(ctxt,request,request.getSession(true));
|
||||
boolean record_uname = user.isLoggedIn();
|
||||
if (record_uname)
|
||||
NDC.push(user.getUserName());
|
||||
|
||||
try
|
||||
{ // and now we proceed!
|
||||
RenderData rdat = RenderConfig.createRenderData(ctxt,user,request,response);
|
||||
|
||||
try
|
||||
{ // run the actual "get" in the servlet
|
||||
content = doVeniceGet(request,engine,user,rdat);
|
||||
|
||||
} // end try
|
||||
catch (VeniceServletResult res)
|
||||
{ // special VeniceServletResult catch here - figure out what result it is
|
||||
if (res instanceof VeniceContent)
|
||||
content = (VeniceContent)res; // this is content
|
||||
else if (res instanceof ContentResult)
|
||||
{ // this contains content
|
||||
ContentResult cres = (ContentResult)res;
|
||||
content = cres.getContent();
|
||||
|
||||
} // end else if
|
||||
else if (res instanceof ExecuteResult)
|
||||
{ // direct-execution result
|
||||
ExecuteResult xres = (ExecuteResult)res;
|
||||
Variables.flushCookies(request,response);
|
||||
xres.execute(rdat);
|
||||
return;
|
||||
|
||||
} // end else if
|
||||
else // unrecognized VeniceServletResult
|
||||
content = null;
|
||||
|
||||
} // end catch
|
||||
catch (RuntimeException re)
|
||||
{ // record that we caught a runtime exception in here!
|
||||
logger.error("VeniceServlet.doGet caught " + re.getClass().getName() + " in doVeniceGet",re);
|
||||
throw re;
|
||||
|
||||
} // end catch
|
||||
|
||||
Variables.flushCookies(request,response);
|
||||
if (content!=null)
|
||||
{ // display the content!
|
||||
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),content);
|
||||
base.transfer(ctxt,rdat);
|
||||
|
||||
} // end if
|
||||
else // there is no content - display the null response
|
||||
rdat.nullResponse();
|
||||
|
||||
} // end try
|
||||
finally
|
||||
{ // pop the username from the NDC if we used it
|
||||
if (record_uname)
|
||||
NDC.pop();
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end try
|
||||
catch (VeniceServletResult res)
|
||||
{ // special VeniceServletResult catch here - figure out what result it is
|
||||
if (res instanceof VeniceContent)
|
||||
content = (VeniceContent)res; // this is content
|
||||
else if (res instanceof ContentResult)
|
||||
{ // this contains content
|
||||
ContentResult cres = (ContentResult)res;
|
||||
content = cres.getContent();
|
||||
finally
|
||||
{ // pop the nested diagnostic context
|
||||
NDC.pop();
|
||||
|
||||
} // end else if
|
||||
else if (res instanceof ExecuteResult)
|
||||
{ // direct-execution result
|
||||
ExecuteResult xres = (ExecuteResult)res;
|
||||
xres.execute(rdat);
|
||||
return;
|
||||
|
||||
} // end else if
|
||||
else // unrecognized VeniceServletResult
|
||||
content = null;
|
||||
|
||||
} // end catch
|
||||
|
||||
if (content!=null)
|
||||
{ // display the content!
|
||||
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),content);
|
||||
base.transfer(ctxt,rdat);
|
||||
|
||||
} // end if
|
||||
else // there is no content - display the null response
|
||||
rdat.nullResponse();
|
||||
} // end finally
|
||||
|
||||
} // end doGet
|
||||
|
||||
@@ -564,68 +637,103 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
{
|
||||
ServletContext ctxt = getServletContext();
|
||||
VeniceEngine engine = Variables.getVeniceEngine(ctxt);
|
||||
UserContext user = Variables.getUserContext(ctxt,request,request.getSession(true));
|
||||
RenderData rdat = RenderConfig.createRenderData(ctxt,user,request,response);
|
||||
ServletMultipartHandler mphandler = null;
|
||||
VeniceContent content = null;
|
||||
|
||||
if (ServletMultipartHandler.canHandle(request))
|
||||
{ // if this is a multipart/form-data request, invoke our special handler code
|
||||
// Make all log messages for the request carry the remote address.
|
||||
NDC.push(request.getRemoteAddr());
|
||||
try
|
||||
{ // get the user context
|
||||
UserContext user = Variables.getUserContext(ctxt,request,request.getSession(true));
|
||||
boolean record_uname = user.isLoggedIn();
|
||||
if (record_uname)
|
||||
NDC.push(user.getUserName());
|
||||
|
||||
try
|
||||
{ // create the multipart handler
|
||||
mphandler = new ServletMultipartHandler(request);
|
||||
{ // and now we proceed!
|
||||
RenderData rdat = RenderConfig.createRenderData(ctxt,user,request,response);
|
||||
|
||||
if (ServletMultipartHandler.canHandle(request))
|
||||
{ // if this is a multipart/form-data request, invoke our special handler code
|
||||
try
|
||||
{ // create the multipart handler
|
||||
mphandler = new ServletMultipartHandler(request);
|
||||
|
||||
} // end try
|
||||
catch (ServletMultipartException e)
|
||||
{ // this is an error message we need to generate and just bail out on
|
||||
logger.error("ServletMultipartException caught in doVenicePost!",e);
|
||||
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),
|
||||
new ErrorBox(null,"Internal Error: " + e.getMessage(),null));
|
||||
base.transfer(ctxt,rdat);
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // call the appropriate doVenicePost method
|
||||
if (mphandler!=null)
|
||||
content = doVenicePost(request,mphandler,engine,user,rdat);
|
||||
else
|
||||
content = doVenicePost(request,engine,user,rdat);
|
||||
|
||||
} // end try
|
||||
catch (VeniceServletResult res)
|
||||
{ // special VeniceServletResult catch here - figure out what result it is
|
||||
if (res instanceof VeniceContent)
|
||||
content = (VeniceContent)res; // this is content
|
||||
else if (res instanceof ContentResult)
|
||||
{ // this contains content
|
||||
ContentResult cres = (ContentResult)res;
|
||||
content = cres.getContent();
|
||||
|
||||
} // end else if
|
||||
else if (res instanceof ExecuteResult)
|
||||
{ // direct-execution result
|
||||
ExecuteResult xres = (ExecuteResult)res;
|
||||
Variables.flushCookies(request,response);
|
||||
xres.execute(rdat);
|
||||
return;
|
||||
|
||||
} // end else if
|
||||
else // unrecognized VeniceServletResult
|
||||
content = null;
|
||||
|
||||
} // end catch
|
||||
catch (RuntimeException re)
|
||||
{ // record that we caught a runtime exception in here!
|
||||
logger.error("VeniceServlet.doPost caught " + re.getClass().getName() + " in doVenicePost",re);
|
||||
throw re;
|
||||
|
||||
} // end catch
|
||||
|
||||
Variables.flushCookies(request,response);
|
||||
if (content!=null)
|
||||
{ // display the content!
|
||||
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),content);
|
||||
base.transfer(ctxt,rdat);
|
||||
|
||||
} // end if
|
||||
else // there is no content - display the null response
|
||||
rdat.nullResponse();
|
||||
|
||||
} // end try
|
||||
catch (ServletMultipartException e)
|
||||
{ // this is an error message we need to generate and just bail out on
|
||||
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),
|
||||
new ErrorBox(null,"Internal Error: " + e.getMessage(),null));
|
||||
base.transfer(ctxt,rdat);
|
||||
return;
|
||||
finally
|
||||
{ // pop the username from the NDC if we used it
|
||||
if (record_uname)
|
||||
NDC.pop();
|
||||
|
||||
} // end if
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // call the appropriate doVenicePost method
|
||||
if (mphandler!=null)
|
||||
content = doVenicePost(request,mphandler,engine,user,rdat);
|
||||
else
|
||||
content = doVenicePost(request,engine,user,rdat);
|
||||
} // end finally
|
||||
|
||||
} // end try
|
||||
catch (VeniceServletResult res)
|
||||
{ // special VeniceServletResult catch here - figure out what result it is
|
||||
if (res instanceof VeniceContent)
|
||||
content = (VeniceContent)res; // this is content
|
||||
else if (res instanceof ContentResult)
|
||||
{ // this contains content
|
||||
ContentResult cres = (ContentResult)res;
|
||||
content = cres.getContent();
|
||||
|
||||
} // end else if
|
||||
else if (res instanceof ExecuteResult)
|
||||
{ // direct-execution result
|
||||
ExecuteResult xres = (ExecuteResult)res;
|
||||
xres.execute(rdat);
|
||||
return;
|
||||
|
||||
} // end else if
|
||||
else // unrecognized VeniceServletResult
|
||||
content = null;
|
||||
|
||||
} // end catch
|
||||
|
||||
if (content!=null)
|
||||
{ // display the content!
|
||||
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),content);
|
||||
base.transfer(ctxt,rdat);
|
||||
|
||||
} // end if
|
||||
else // there is no content - display the null response
|
||||
rdat.nullResponse();
|
||||
finally
|
||||
{ // pop the nested diagnostic context
|
||||
NDC.pop();
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end doPost
|
||||
|
||||
} // end class VeniceServlet
|
||||
|
||||
@@ -145,7 +145,6 @@ public class AuditDataViewer implements ContentRender
|
||||
} // end while
|
||||
|
||||
out.write("</TABLE>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.io.IOException;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.servlets.Variables;
|
||||
import com.silverwrist.venice.servlets.format.menus.LeftMenu;
|
||||
|
||||
public class BaseJSPData
|
||||
{
|
||||
@@ -114,6 +116,22 @@ public class BaseJSPData
|
||||
|
||||
} // end transfer
|
||||
|
||||
public void renderMenu(HttpSession session, Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
ComponentRender menu = Variables.getMenu(session);
|
||||
if (menu==null)
|
||||
menu = (ComponentRender)(rdat.getLeftMenu("top"));
|
||||
menu.renderHere(out,rdat);
|
||||
|
||||
} // end renderMenu
|
||||
|
||||
public void renderFixedMenu(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
ComponentRender menu = (ComponentRender)(rdat.getLeftMenu("fixed"));
|
||||
menu.renderHere(out,rdat);
|
||||
|
||||
} // end renderFixedMenu
|
||||
|
||||
public void renderContent(ServletContext ctxt, Writer out, RenderData rdat)
|
||||
throws IOException, ServletException
|
||||
{
|
||||
@@ -142,7 +160,7 @@ public class BaseJSPData
|
||||
rdat.flushOutput(); // now make sure the included page is properly flushed
|
||||
return;
|
||||
|
||||
} // end if
|
||||
} // end else if
|
||||
else // this is the fallback if we don't recognize the content
|
||||
new ErrorBox(null,"Internal Error: Content of invalid type",null).renderHere(out,rdat);
|
||||
|
||||
|
||||
@@ -39,24 +39,39 @@ public class ConferenceActivity implements JSPRender
|
||||
|
||||
private SIGContext sig; // the SIG we're in
|
||||
private ConferenceContext conf; // the conference being listed
|
||||
private TopicContext topic; // the topic being listed
|
||||
private boolean posters; // is this a list of posters?
|
||||
private List records; // the actual data records
|
||||
private String locator = null; // our locator
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public ConferenceActivity(SIGContext sig, ConferenceContext conf, boolean posters)
|
||||
public ConferenceActivity(SIGContext sig, ConferenceContext conf, TopicContext topic, boolean posters)
|
||||
throws DataException, AccessError
|
||||
{
|
||||
this.sig = sig;
|
||||
this.conf = conf;
|
||||
this.topic = topic;
|
||||
this.posters = posters;
|
||||
if (posters)
|
||||
this.records = conf.getActivePosters();
|
||||
if (topic!=null)
|
||||
{ // do the report on the topic
|
||||
if (posters)
|
||||
this.records = topic.getActivePosters();
|
||||
else
|
||||
this.records = topic.getActiveReaders();
|
||||
|
||||
} // end if
|
||||
else
|
||||
this.records = conf.getActiveReaders();
|
||||
{ // do the report on the conference
|
||||
if (posters)
|
||||
this.records = conf.getActivePosters();
|
||||
else
|
||||
this.records = conf.getActiveReaders();
|
||||
|
||||
} // end else
|
||||
|
||||
} // end constructor
|
||||
|
||||
@@ -78,10 +93,22 @@ public class ConferenceActivity implements JSPRender
|
||||
|
||||
public String getPageTitle(RenderData rdat)
|
||||
{
|
||||
if (posters)
|
||||
return "Users Posting in Conference " + conf.getName();
|
||||
if (topic!=null)
|
||||
{ // it's a topic report
|
||||
if (posters)
|
||||
return "Users Posting in Topic " + topic.getName();
|
||||
else
|
||||
return "Users Reading Topic " + topic.getName();
|
||||
|
||||
} // end if
|
||||
else
|
||||
return "Users Reading Conference " + conf.getName();
|
||||
{ // it's a conference report
|
||||
if (posters)
|
||||
return "Users Posting in Conference " + conf.getName();
|
||||
else
|
||||
return "Users Reading Conference " + conf.getName();
|
||||
|
||||
} // end else
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
@@ -113,12 +140,29 @@ public class ConferenceActivity implements JSPRender
|
||||
|
||||
} // end getConfName
|
||||
|
||||
public String getTopicName()
|
||||
{
|
||||
if (topic==null)
|
||||
return null;
|
||||
else
|
||||
return topic.getName();
|
||||
|
||||
} // end getTopicName
|
||||
|
||||
public String getLocator()
|
||||
{
|
||||
return "sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
|
||||
if (locator==null)
|
||||
locator = "sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
|
||||
return locator;
|
||||
|
||||
} // end getLocator
|
||||
|
||||
public boolean isTopicReport()
|
||||
{
|
||||
return (topic!=null);
|
||||
|
||||
} // end isTopicReport
|
||||
|
||||
public boolean isPosterReport()
|
||||
{
|
||||
return posters;
|
||||
|
||||
@@ -122,7 +122,6 @@ public class ConfirmBox implements ContentRender
|
||||
out.write("<IMG SRC=\"" + rdat.getFullImagePath("bn_no.gif")
|
||||
+ "\" ALT=\"No\" WIDTH=80 HEIGHT=24 BORDER=0></A>\n");
|
||||
out.write("</FONT></TD></TR></TABLE><P>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
|
||||
@@ -216,7 +216,6 @@ public class ContentDialog implements Cloneable, ContentRender
|
||||
} // end if
|
||||
|
||||
out.write("</FONT></FORM>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
|
||||
@@ -135,7 +135,6 @@ public class ContentMenuPanel implements Cloneable, ContentRender
|
||||
} // end while
|
||||
|
||||
out.write("</TABLE>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ public class ErrorBox extends VeniceServletResult implements ContentRender
|
||||
else
|
||||
out.write("<A HREF=\"" + rdat.getEncodedServletPath(back) + "\">Go back.</A>\n");
|
||||
out.write("<P></FONT></TD></TR></TABLE><P>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ public class LoginDialog extends ContentDialog
|
||||
addFormField(new CDPasswordFormFieldCommand("pass","Password",null,false,32,128,
|
||||
new CDImageButton("remind","bn_reminder.gif","Reminder",
|
||||
80,24)));
|
||||
//addFormField(new CDCheckBoxFormField("saveme","Save my user name and password for automatic logins",
|
||||
// null,"Y"));
|
||||
addFormField(new CDCheckBoxFormField("saveme","Remember me for next time so I can log in automatically",
|
||||
null,"Y"));
|
||||
addCommandButton(new CDImageButton("login","bn_log_in.gif","Log In",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class ManageConference implements JSPRender
|
||||
|
||||
private SIGContext sig; // the SIG we're in
|
||||
private ConferenceContext conf; // the conference being listed
|
||||
private String locator = null; // the locator we use
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
@@ -116,7 +117,9 @@ public class ManageConference implements JSPRender
|
||||
|
||||
public String getLocator()
|
||||
{
|
||||
return "sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
|
||||
if (locator==null)
|
||||
locator = "sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
|
||||
return locator;
|
||||
|
||||
} // end getLocator
|
||||
|
||||
@@ -128,8 +131,7 @@ public class ManageConference implements JSPRender
|
||||
|
||||
public boolean displayAdminSection()
|
||||
{
|
||||
return conf.canChangeConference();
|
||||
// TODO: needs to have "delete" permission OR'ed in
|
||||
return conf.canChangeConference() || conf.canDeleteConference();
|
||||
|
||||
} // end displayAdminSection
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MenuTop implements ComponentRender
|
||||
{
|
||||
public MenuTop()
|
||||
{ // constructor does nothing
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<B>Front Page</B><BR>\n");
|
||||
out.write("<A HREF=\"\">Calendar</A><BR>\n"); // TODO: fill this link in
|
||||
out.write("<A HREF=\"\">Chat</A>\n"); // TODO: fill this link in
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class MenuTop
|
||||
@@ -31,6 +31,7 @@ import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.ConfigException;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.servlets.Variables;
|
||||
import com.silverwrist.venice.servlets.format.menus.LeftMenu;
|
||||
|
||||
public class RenderConfig
|
||||
{
|
||||
@@ -57,7 +58,8 @@ public class RenderConfig
|
||||
private String image_url;
|
||||
private String static_url;
|
||||
private String site_logo;
|
||||
private Hashtable stock_messages;
|
||||
private HashMap stock_messages;
|
||||
private HashMap menus;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
@@ -171,9 +173,10 @@ public class RenderConfig
|
||||
} // end if
|
||||
|
||||
// Initialize the stock messages list.
|
||||
stock_messages = new Hashtable();
|
||||
stock_messages = new HashMap();
|
||||
NodeList msg_nodes = msg_sect.getChildNodes();
|
||||
for (int i=0; i<msg_nodes.getLength(); i++)
|
||||
int i;
|
||||
for (i=0; i<msg_nodes.getLength(); i++)
|
||||
{ // examine all subnodes to add them to the message text
|
||||
Node msgn = msg_nodes.item(i);
|
||||
if (msgn.getNodeType()==Node.ELEMENT_NODE)
|
||||
@@ -191,6 +194,56 @@ public class RenderConfig
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(stock_messages.size() + " stock messages loaded from config");
|
||||
|
||||
Element menu_sect = root_h.getSubElement("menu-definitions");
|
||||
if (menu_sect==null)
|
||||
{ // no <menu-definitions/> section - bail out now!
|
||||
logger.fatal("config document has no <menu-definitions/> section");
|
||||
throw new ConfigException("no <menu-definitions/> section found in config file",root);
|
||||
|
||||
} // end if
|
||||
|
||||
// Initialize the menus list.
|
||||
menus = new HashMap();
|
||||
NodeList menu_nodes = menu_sect.getChildNodes();
|
||||
for (i=0; i<menu_nodes.getLength(); i++)
|
||||
{ // look for <menudef> subnodes and use them to initialize menus
|
||||
Node mn = menu_nodes.item(i);
|
||||
if (mn.getNodeType()==Node.ELEMENT_NODE)
|
||||
{ // found an element - now check it's name
|
||||
if (mn.getNodeName().equals("menudef"))
|
||||
{ // root of a menu definition - get its ID, build it, and save it
|
||||
Element mel = (Element)mn;
|
||||
String menuid = mel.getAttribute("id");
|
||||
if (menuid==null)
|
||||
{ // no menu ID attribute
|
||||
logger.fatal("<menudef/> seen with no \"id\" attribute");
|
||||
throw new ConfigException("<menudef/> seen with no \"id\" attribute",mel);
|
||||
|
||||
} // end if
|
||||
|
||||
// create the menu and add it to the mapping
|
||||
LeftMenu menu = new LeftMenu(mel,menuid);
|
||||
menus.put(menuid,menu);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("menu \"" + menuid + "\" defined");
|
||||
|
||||
} // end if (found the root of a menu definition)
|
||||
else
|
||||
{ // unknown element - bail out!
|
||||
logger.fatal("config document has unknown node <" + mn.getNodeName() +
|
||||
"/> inside <menu-definitions/>");
|
||||
throw new ConfigException("unknown node name <" + mn.getNodeName() + "/> in <menu-definitions/>",
|
||||
menu_sect);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if
|
||||
|
||||
} // end for
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(menus.size() + " menu definitions loaded from config");
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
@@ -337,20 +390,6 @@ public class RenderConfig
|
||||
|
||||
} // end getRequiredBullet
|
||||
|
||||
void writeFooter(Writer out) throws IOException
|
||||
{
|
||||
out.write("<HR WIDTH=\"80%\">\n<TABLE ALIGN=CENTER BORDER=0 CELLPADDING=0 CELLSPACING=6><TR VALIGN=TOP>"
|
||||
+ "\n<TD ALIGN=RIGHT>\n");
|
||||
out.write(getStdFontTag(null,1));
|
||||
out.write(getStockMessage("footer-text"));
|
||||
out.write("</FONT>\n</TD>\n<TD ALIGN=LEFT>\n<A HREF=\"http://venice.sourceforge.net\" TARGET=\"_blank\">"
|
||||
+ "<IMG SRC=\"");
|
||||
out.write(getFullImagePath("powered-by-venice.gif"));
|
||||
out.write("\" ALT=\"Powered by Venice\" WIDTH=140 HEIGHT=80 BORDER=0 HSPACE=0 VSPACE=0></A>\n</TD>\n"
|
||||
+ "</TR></TABLE>\n");
|
||||
|
||||
} // end writeFooter
|
||||
|
||||
void writeContentHeader(Writer out, String primary, String secondary) throws IOException
|
||||
{
|
||||
out.write(getStdFontTag("#3333AA",5) + "<B>" + StringUtil.encodeHTML(primary) + "</B></FONT>");
|
||||
@@ -374,6 +413,12 @@ public class RenderConfig
|
||||
|
||||
} // end writeStockMessage
|
||||
|
||||
public LeftMenu getLeftMenu(String identifier)
|
||||
{
|
||||
return (LeftMenu)(menus.get(identifier));
|
||||
|
||||
} // end getLeftMenu
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static operations for use by VeniceServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
@@ -410,14 +455,14 @@ public class RenderConfig
|
||||
HttpServletResponse response) throws ServletException
|
||||
{
|
||||
UserContext uc = Variables.getUserContext(ctxt,request,request.getSession(true));
|
||||
return new RenderData(getRenderConfig(ctxt),uc,request,response);
|
||||
return new RenderData(getRenderConfig(ctxt),uc,ctxt,request,response);
|
||||
|
||||
} // end createRenderData
|
||||
|
||||
public static RenderData createRenderData(ServletContext ctxt, UserContext uc, HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException
|
||||
{
|
||||
return new RenderData(getRenderConfig(ctxt),uc,request,response);
|
||||
return new RenderData(getRenderConfig(ctxt),uc,ctxt,request,response);
|
||||
|
||||
} // end createRenderData
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.silverwrist.venice.core.IDUtils;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.db.PostLinkRewriter;
|
||||
import com.silverwrist.venice.db.UserNameRewriter;
|
||||
import com.silverwrist.venice.servlets.format.menus.LeftMenu;
|
||||
|
||||
public class RenderData
|
||||
{
|
||||
@@ -47,6 +48,7 @@ public class RenderData
|
||||
*/
|
||||
|
||||
private RenderConfig rconf;
|
||||
private ServletContext ctxt;
|
||||
private HttpServletRequest request;
|
||||
private HttpServletResponse response;
|
||||
private boolean can_gzip = false;
|
||||
@@ -60,9 +62,11 @@ public class RenderData
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
RenderData(RenderConfig rconf, UserContext uc, HttpServletRequest request, HttpServletResponse response)
|
||||
RenderData(RenderConfig rconf, UserContext uc, ServletContext ctxt, HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
{
|
||||
this.rconf = rconf;
|
||||
this.ctxt = ctxt;
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
|
||||
@@ -167,7 +171,13 @@ public class RenderData
|
||||
{
|
||||
return "/format/" + name;
|
||||
|
||||
} // end getFullFormatJSPPath
|
||||
} // end getFormatJSPPath
|
||||
|
||||
public String getStaticIncludePath(String name)
|
||||
{
|
||||
return "/static/" + name;
|
||||
|
||||
} // end getStaticIncludePath
|
||||
|
||||
public String getStdFontTag(String color, int size)
|
||||
{
|
||||
@@ -193,12 +203,6 @@ public class RenderData
|
||||
|
||||
} // end getRequiredBullet
|
||||
|
||||
public void writeFooter(Writer out) throws IOException
|
||||
{
|
||||
rconf.writeFooter(out);
|
||||
|
||||
} // end writeFooter
|
||||
|
||||
public void writeContentHeader(Writer out, String primary, String secondary) throws IOException
|
||||
{
|
||||
rconf.writeContentHeader(out,primary,secondary);
|
||||
@@ -250,6 +254,12 @@ public class RenderData
|
||||
|
||||
} // end writeStockMessage
|
||||
|
||||
public LeftMenu getLeftMenu(String identifier)
|
||||
{
|
||||
return rconf.getLeftMenu(identifier);
|
||||
|
||||
} // end getLeftMenu
|
||||
|
||||
public String formatDateForDisplay(Date date)
|
||||
{
|
||||
if (display_date==null)
|
||||
@@ -491,4 +501,19 @@ public class RenderData
|
||||
|
||||
} // end rewritePostData
|
||||
|
||||
public String mapToPath(String path)
|
||||
{
|
||||
return ctxt.getRealPath(path);
|
||||
|
||||
} // end mapToPath
|
||||
|
||||
public Cookie createCookie(String name, String value, int age)
|
||||
{
|
||||
Cookie rc = new Cookie(name,value);
|
||||
rc.setMaxAge(age);
|
||||
rc.setPath(request.getContextPath());
|
||||
return rc;
|
||||
|
||||
} // end createCookie
|
||||
|
||||
} // end class RenderData
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class ReportConferenceMenu implements JSPRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ReportConferenceMenu";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private SIGContext sig; // the SIG we're in
|
||||
private ConferenceContext conf; // the conference being listed
|
||||
private List topics; // the topics in this conference
|
||||
private String locator = null; // the locator
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public ReportConferenceMenu(SIGContext sig, ConferenceContext conf) throws DataException, AccessError
|
||||
{
|
||||
this.sig = sig;
|
||||
this.conf = conf;
|
||||
this.topics = conf.getTopicList(ConferenceContext.GET_ALL,ConferenceContext.SORT_NUMBER);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static ReportConferenceMenu retrieve(ServletRequest request)
|
||||
{
|
||||
return (ReportConferenceMenu)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VeniceContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getPageTitle(RenderData rdat)
|
||||
{
|
||||
return "Conference Reports: " + conf.getName();
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "report_conf.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public int getConfID()
|
||||
{
|
||||
return conf.getConfID();
|
||||
|
||||
} // end getConfID
|
||||
|
||||
public String getConfName()
|
||||
{
|
||||
return conf.getName();
|
||||
|
||||
} // end getConfName
|
||||
|
||||
public String getLocator()
|
||||
{
|
||||
if (locator==null)
|
||||
locator = "sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
|
||||
return locator;
|
||||
|
||||
} // end getLocator
|
||||
|
||||
public Iterator getTopics()
|
||||
{
|
||||
return topics.iterator();
|
||||
|
||||
} // end getTopics
|
||||
|
||||
} // end class ReportConferenceMenu
|
||||
184
src/com/silverwrist/venice/servlets/format/StaticRender.java
Normal file
184
src/com/silverwrist/venice/servlets/format/StaticRender.java
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.*;
|
||||
import com.silverwrist.util.cachemap.CacheMap;
|
||||
|
||||
public class StaticRender implements ContentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static CacheMap cache = new CacheMap(15,25);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String name;
|
||||
private boolean processed = false;
|
||||
private String title = null;
|
||||
private String content = null;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected StaticRender(String name)
|
||||
{
|
||||
this.name = name;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static String searchBetweenTags(StringBuffer data, String search, String tagname)
|
||||
{
|
||||
tagname = tagname.toUpperCase();
|
||||
String start = "<" + tagname;
|
||||
String end = "</" + tagname + ">";
|
||||
|
||||
int startpos = search.indexOf(start);
|
||||
if (startpos<0)
|
||||
return null;
|
||||
startpos += start.length();
|
||||
|
||||
int bkt_pos = search.indexOf('>',startpos);
|
||||
if (bkt_pos<0)
|
||||
return null;
|
||||
|
||||
int end_pos = search.indexOf(end,++bkt_pos);
|
||||
if (end_pos<0)
|
||||
return data.substring(bkt_pos);
|
||||
else
|
||||
return data.substring(bkt_pos,end_pos);
|
||||
|
||||
} // end searchBetweenTags
|
||||
|
||||
private synchronized void process(RenderData rdat)
|
||||
{
|
||||
if (processed)
|
||||
return; // check and set flag
|
||||
|
||||
// Map the content path to a real filename.
|
||||
String real_path = rdat.mapToPath(rdat.getStaticIncludePath(name));
|
||||
if (real_path==null)
|
||||
{ // not found!
|
||||
title = name;
|
||||
content = "File not mappable: " + name;
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
// Read in the whole thing.
|
||||
StringBuffer raw_file = new StringBuffer();
|
||||
try
|
||||
{ // read in from the file
|
||||
FileReader rdr = new FileReader(real_path);
|
||||
char[] buffer = new char[4096];
|
||||
int rd = rdr.read(buffer);
|
||||
while (rd>=0)
|
||||
{ // read in the raw characters
|
||||
if (rd>0)
|
||||
raw_file.append(buffer,0,rd);
|
||||
rd = rdr.read(buffer);
|
||||
|
||||
} // end while
|
||||
|
||||
rdr.close();
|
||||
|
||||
} // end try
|
||||
catch (IOException ioe)
|
||||
{ // I/O exception - just discard
|
||||
title = name;
|
||||
content = "I/O error reading " + name + ": " + ioe.getMessage();
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
|
||||
// make the upper-case search page and use that to locate the page title and body
|
||||
String search_page = raw_file.toString().toUpperCase();
|
||||
title = searchBetweenTags(raw_file,search_page,"TITLE");
|
||||
content = searchBetweenTags(raw_file,search_page,"BODY");
|
||||
if (content==null)
|
||||
{ // no content?
|
||||
content = "No content seen on " + name;
|
||||
processed = false;
|
||||
|
||||
} // end if
|
||||
|
||||
processed = true; // set the flag to indicate we've got everything
|
||||
|
||||
} // end process
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VeniceContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getPageTitle(RenderData rdat)
|
||||
{
|
||||
process(rdat);
|
||||
if (title==null)
|
||||
return name;
|
||||
else
|
||||
return title;
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ContentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
process(rdat);
|
||||
if (content!=null)
|
||||
out.write(content);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static StaticRender getStaticRender(String name)
|
||||
{
|
||||
StaticRender rc = (StaticRender)(cache.get(name));
|
||||
if (rc==null)
|
||||
{ // create a new object and cache it
|
||||
rc = new StaticRender(name);
|
||||
cache.put(name,rc);
|
||||
|
||||
} // end if
|
||||
|
||||
return rc;
|
||||
|
||||
} // end getStaticRender
|
||||
|
||||
} // end class StaticRender
|
||||
@@ -149,7 +149,6 @@ public class TextMessageDialog implements ContentRender
|
||||
} // end for
|
||||
|
||||
out.write("</DIV>\n");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
|
||||
@@ -243,7 +243,6 @@ public class TopDisplay implements ContentRender
|
||||
|
||||
// Finish up.
|
||||
out.write("</TD>\n</TR></TABLE>");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format.menus;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.servlets.format.RenderData;
|
||||
|
||||
class AbsoluteLeftMenuItem extends LeftMenuItem
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
String url;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
AbsoluteLeftMenuItem(Element elt)
|
||||
{
|
||||
super(elt);
|
||||
DOMElementHelper h = new DOMElementHelper(elt);
|
||||
url = h.getSubElementText("absolute");
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class LeftMenuItem
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void appendURL(StringBuffer sbuf, RenderData rdat)
|
||||
{
|
||||
sbuf.append(url);
|
||||
|
||||
} // end appendURL
|
||||
|
||||
} // end class AbsoluteLeftMenuItem
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format.menus;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.servlets.format.RenderData;
|
||||
|
||||
class FrameLeftMenuItem extends LeftMenuItem
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
String url;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
FrameLeftMenuItem(Element elt)
|
||||
{
|
||||
super(elt);
|
||||
DOMElementHelper h = new DOMElementHelper(elt);
|
||||
url = h.getSubElementText("frame");
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class LeftMenuItem
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void appendURL(StringBuffer sbuf, RenderData rdat)
|
||||
{
|
||||
sbuf.append(rdat.getEncodedServletPath("frame/" + url));
|
||||
|
||||
} // end appendURL
|
||||
|
||||
} // end class FrameLeftMenuItem
|
||||
188
src/com/silverwrist/venice/servlets/format/menus/LeftMenu.java
Normal file
188
src/com/silverwrist/venice/servlets/format/menus/LeftMenu.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format.menus;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.apache.log4j.*;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.core.ConfigException;
|
||||
import com.silverwrist.venice.servlets.format.ComponentRender;
|
||||
import com.silverwrist.venice.servlets.format.RenderData;
|
||||
|
||||
public class LeftMenu implements ComponentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class representing a header component
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static class Header implements ComponentRender
|
||||
{
|
||||
private String txt; // the actual stored text
|
||||
|
||||
Header(Element elt)
|
||||
{
|
||||
DOMElementHelper h = new DOMElementHelper(elt);
|
||||
StringBuffer buf = new StringBuffer("<B>");
|
||||
buf.append(StringUtil.encodeHTML(h.getElementText())).append("</B><BR>\n");
|
||||
txt = buf.toString();
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write(txt);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class Header
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class representing a separator component
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static class Separator implements ComponentRender
|
||||
{
|
||||
Separator()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<BR>\n");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class Separator
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(LeftMenu.class);
|
||||
private static final Separator separator_singleton = new Separator();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String identifier;
|
||||
private ArrayList menu_items = new ArrayList();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public LeftMenu(Element elt, String identifier) throws ConfigException
|
||||
{
|
||||
if (!(elt.getNodeName().equals("menudef")))
|
||||
{ // just some shorts-checking here to make sure the element is OK
|
||||
logger.fatal("huh?!? this should have been a <menudef/> if it got here!");
|
||||
throw new ConfigException("not a <menudef/> element");
|
||||
|
||||
} // end if
|
||||
|
||||
NodeList items = elt.getChildNodes();
|
||||
for (int i=0; i<items.getLength(); i++)
|
||||
{ // examine each of the child elements closely
|
||||
Node n = items.item(i);
|
||||
if (n.getNodeType()==Node.ELEMENT_NODE)
|
||||
{ // we've found a child element - what type is it?
|
||||
if (n.getNodeName().equals("menuitem"))
|
||||
{ // investigate the contents of the subelement
|
||||
DOMElementHelper h = new DOMElementHelper((Element)n);
|
||||
if (!(h.hasChildElement("text")))
|
||||
{ // no menu item text!
|
||||
logger.fatal("<menuitem/> element has no <text/> subelement");
|
||||
throw new ConfigException("<menuitem/> element has no <text/> subelement",h.getElement());
|
||||
|
||||
} // end if
|
||||
|
||||
LeftMenuItem mitem = null;
|
||||
if (h.hasChildElement("servlet"))
|
||||
mitem = new ServletLeftMenuItem(h.getElement());
|
||||
else if (h.hasChildElement("absolute"))
|
||||
mitem = new AbsoluteLeftMenuItem(h.getElement());
|
||||
else if (h.hasChildElement("frame"))
|
||||
mitem = new FrameLeftMenuItem(h.getElement());
|
||||
else
|
||||
{ // we don't know what type of menu this is!
|
||||
logger.fatal("unknown <menuitem/> type seen in menu");
|
||||
throw new ConfigException("unknown <menuitem/> type seen in menu",h.getElement());
|
||||
|
||||
} // end else
|
||||
|
||||
menu_items.add(mitem);
|
||||
|
||||
} // end if
|
||||
else if (n.getNodeName().equals("header"))
|
||||
menu_items.add(new Header((Element)n)); // add a new header
|
||||
else if (n.getNodeName().equals("separator"))
|
||||
menu_items.add(separator_singleton); // all separators are exactly the same
|
||||
else
|
||||
{ // menu definition has an unknown item
|
||||
logger.fatal("unknown element <" + n.getNodeName() + "/> inside <menudef/>");
|
||||
throw new ConfigException("unknown element <" + n.getNodeName() + "/> inside <menudef/>",n);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if (an element node)
|
||||
|
||||
} // end for (each child node)
|
||||
|
||||
this.identifier = identifier;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
Iterator it = menu_items.iterator();
|
||||
while (it.hasNext())
|
||||
{ // render each menu item in turn
|
||||
ComponentRender cr = (ComponentRender)(it.next());
|
||||
cr.renderHere(out,rdat);
|
||||
|
||||
} // end while
|
||||
|
||||
} // end renderHere
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getIdentifier()
|
||||
{
|
||||
return identifier;
|
||||
|
||||
} // end getIdentifier
|
||||
|
||||
} // end class LeftMenu
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format.menus;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.servlets.format.ComponentRender;
|
||||
import com.silverwrist.venice.servlets.format.RenderData;
|
||||
|
||||
abstract class LeftMenuItem implements ComponentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String text;
|
||||
private boolean disabled = false;
|
||||
private boolean new_window = false;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected LeftMenuItem(Element elt)
|
||||
{
|
||||
DOMElementHelper h = new DOMElementHelper(elt);
|
||||
text = StringUtil.encodeHTML(h.getSubElementText("text"));
|
||||
if (h.hasChildElement("disabled"))
|
||||
disabled = true;
|
||||
if (h.hasChildElement("new-window"))
|
||||
new_window = true;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract functions which MUST be overridden
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected abstract void appendURL(StringBuffer sbuf, RenderData rdat);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
if (disabled)
|
||||
buf.append("<FONT COLOR=\"#CCCCCC\">");
|
||||
else
|
||||
{ // write the <A> tag
|
||||
buf.append("<A HREF=\"");
|
||||
appendURL(buf,rdat);
|
||||
buf.append('"');
|
||||
if (new_window)
|
||||
buf.append(" TARGET=\"_blank\"");
|
||||
buf.append('>');
|
||||
|
||||
} // end else (writing <A> tag)
|
||||
|
||||
buf.append(text);
|
||||
if (disabled)
|
||||
buf.append("</FONT>");
|
||||
else
|
||||
buf.append("</A>");
|
||||
buf.append("<BR>\n");
|
||||
out.write(buf.toString());
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class LeftMenuItem
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format.menus;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.servlets.format.RenderData;
|
||||
|
||||
class ServletLeftMenuItem extends LeftMenuItem
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
String url;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ServletLeftMenuItem(Element elt)
|
||||
{
|
||||
super(elt);
|
||||
DOMElementHelper h = new DOMElementHelper(elt);
|
||||
url = h.getSubElementText("servlet");
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class LeftMenuItem
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void appendURL(StringBuffer sbuf, RenderData rdat)
|
||||
{
|
||||
sbuf.append(rdat.getEncodedServletPath(url));
|
||||
|
||||
} // end appendURL
|
||||
|
||||
} // end class ServletLeftMenuItem
|
||||
Reference in New Issue
Block a user