implemented most of the Manage Conference functions - set pseud, fixseen,

conference edit, alias management, poster and lurker reports
This commit is contained in:
Eric J. Bowersox
2001-02-12 01:50:10 +00:00
parent f706cdaf5f
commit 0070e4fb44
31 changed files with 1260 additions and 47 deletions

View File

@@ -21,6 +21,7 @@ import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.ValidationException;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.servlets.format.*;
@@ -56,6 +57,23 @@ public class ConfOperations extends VeniceServlet
} // end makeCreateConferenceDialog
private EditConferenceDialog makeEditConferenceDialog() throws ServletException
{
final String desired_name = "EditConferenceDialog";
DialogCache cache = DialogCache.getDialogCache(getServletContext());
if (!(cache.isCached(desired_name)))
{ // create a template and save it off
EditConferenceDialog template = new EditConferenceDialog();
cache.saveTemplate(template);
} // end if
// return a new copy
return (EditConferenceDialog)(cache.getNewDialog(desired_name));
} // end makeEditConferenceDialog
private static boolean validateNewTopic(ServletRequest request, String on_error) throws ErrorBox
{
boolean is_title_null, is_zp_null;
@@ -98,7 +116,7 @@ public class ConfOperations extends VeniceServlet
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
throws ServletException, IOException, VeniceServletResult
{
// get the SIG
SIGContext sig = getSIGParameter(request,user,true,"top");
@@ -167,6 +185,106 @@ public class ConfOperations extends VeniceServlet
} // end if ("FX" command)
if (cmd.equals("E"))
{ // "E" = "Edit Conference Settings" (requires conference parameter)
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=Q";
if (!(conf.canChangeConference()))
return new ErrorBox("Access Error","You are not permitted to change this conference's settings.",
on_error);
// create and return the Edit Conference dialog
EditConferenceDialog dlg = makeEditConferenceDialog();
try
{ // set up and return the dialog
dlg.setupDialog(sig,conf);
setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=E");
return dlg;
} // end try
catch (AccessError ae)
{ // some sort of access error - display an error dialog
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error retrieving the conference information
return new ErrorBox("Database Error","Database error getting conference information: "
+ de.getMessage(),on_error);
} // end catch
} // end if ("E" command)
if (cmd.equals("A"))
{ // "A" = "Manage Aliases" (requires conference parameter)
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=Q";
if (!(conf.canChangeConference()))
return new ErrorBox("Access Error","You are not permitted to change this conference's aliases.",
on_error);
// process alias removal link
String remove = request.getParameter("rem");
if (!(StringUtil.isStringEmpty(remove)))
{ // do removal of an alias
try
{ // go ahead and remove the alias!
conf.removeAlias(remove);
} // end try
catch (AccessError ae)
{ // some sort of access error - display an error dialog
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error creating the conference
return new ErrorBox("Database Error","Database error removing alias: " + de.getMessage(),
on_error);
} // end catch
} // end if (removing an alias)
// display the "Manage Conference Aliases" display
try
{ // generate the display box
setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=A");
return new ManageConferenceAliases(sig,conf);
} // end try
catch (DataException de)
{ // error generating the display box
return new ErrorBox("Database Error","Database error displaying aliases: " + de.getMessage(),
on_error);
} // end catch
} // end if ("A" command)
if (cmd.equals("RP") || cmd.equals("RR"))
{ // "RP" = "Report Posters," "RR" = "Report Readers" (requires conference parameter)
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=Q";
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"));
} // end try
catch (DataException de)
{ // unable to get the data for the list
return new ErrorBox("Database Error","Database error displaying conference users: " + de.getMessage(),
on_error);
} // end catch
} // end if ("RP" and "RR" commands)
// Any unrecognized command shows us the conference list.
on_error = "sigprofile?sig=" + sig.getSIGID();
try
@@ -190,7 +308,7 @@ public class ConfOperations extends VeniceServlet
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
UserContext user, RenderData rdat)
throws ServletException, IOException, VeniceServletResult
throws ServletException, IOException, VeniceServletResult
{
// get the SIG
SIGContext sig = getSIGParameter(request,user,true,"top");
@@ -331,12 +449,129 @@ public class ConfOperations extends VeniceServlet
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
// TODO: finish this later
try
{ // go set the pseud!
String pseud = request.getParameter("pseud");
if (pseud!=null)
conf.setDefaultPseud(pseud);
return null;
} // end try
catch (DataException de)
{ // oops - there was a problem!
return new ErrorBox("Database Error","Database error setting pseud: " + de.getMessage(),on_error);
} // end catch
return null; // don't change the view
} // end if ("P" command)
if (cmd.equals("E"))
{ // "E" = "Edit Conference Settings" (requires conference parameter)
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=Q";
if (!(conf.canChangeConference()))
return new ErrorBox("Access Error","You are not permitted to change this conference's settings.",
on_error);
// create the dialog class
EditConferenceDialog dlg = makeEditConferenceDialog();
if (dlg.isButtonClicked(request,"cancel"))
throw new RedirectResult(on_error); // they chickened out - go back to the conference list
if (dlg.isButtonClicked(request,"update"))
{ // they're changing the conference - do what you have to
dlg.loadValues(request); // load the form data
try
{ // run that baby!
dlg.doDialog(conf);
// success - return back to where we started from
throw new RedirectResult(on_error);
} // end try
catch (ValidationException ve)
{ // validation error - throw it back to the user
dlg.resetOnError(sig,conf,ve.getMessage() + " Please try again.");
} // 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
catch (DataException de)
{ // database error creating the conference
return new ErrorBox("Database Error","Database error updating conference: " + de.getMessage(),
on_error);
} // end catch
setMyLocation(request,"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=E");
return dlg; // redisplay the dialog
} // end if
} // end if ("E" command)
if (cmd.equals("A"))
{ // "A" = "Add Alias" (requires conference parameter)
ConferenceContext conf = getConferenceParameter(request,sig,true,on_error);
on_error = "confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=Q";
if (!(conf.canChangeConference()))
return new ErrorBox("Access Error","You are not permitted to change this conference's settings.",
on_error);
String new_alias = request.getParameter("alias");
if (StringUtil.isStringEmpty(new_alias))
return null; // this is a no-op
on_error = "confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=A";
String error_message = null;
if (IDUtils.isValidVeniceID(new_alias))
{ // the alias we have netered is perfectly valid...
try
{ // go ahead and add the alias!
conf.addAlias(new_alias);
} // end try
catch (AccessError ae)
{ // some sort of access error - display an error dialog
return new ErrorBox("Access Error",ae.getMessage(),on_error);
} // end catch
catch (DataException de)
{ // database error creating the conference
return new ErrorBox("Database Error","Database error adding alias: " + de.getMessage(),
on_error);
} // end catch
} // end if
else // alias is not valid
error_message = "The alias you have entered is not a valid identifier. Please try again.";
// redisplay the "Manage Conference Aliases" display
try
{ // generate the display box
setMyLocation(request,on_error);
return new ManageConferenceAliases(sig,conf);
} // end try
catch (DataException de)
{ // error generating the display box
return new ErrorBox("Database Error","Database error displaying aliases: " + de.getMessage(),
"confops?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID() + "&cmd=Q");
} // end catch
} // end if ("A" command)
// unrecognized command!
logger.error("invalid command to ConfOperations.doPost: " + cmd);
return new ErrorBox("Internal Error","Invalid command to ConfOperations.doPost",on_error);

View File

@@ -0,0 +1,139 @@
/*
* 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 ConferenceActivity implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ConferenceActivity";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private SIGContext sig; // the SIG we're in
private ConferenceContext conf; // the conference being listed
private boolean posters; // is this a list of posters?
private List records; // the actual data records
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public ConferenceActivity(SIGContext sig, ConferenceContext conf, boolean posters) throws DataException
{
this.sig = sig;
this.conf = conf;
this.posters = posters;
if (posters)
this.records = conf.getActivePosters();
else
this.records = conf.getActiveReaders();
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ConferenceActivity retrieve(ServletRequest request)
{
return (ConferenceActivity)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
if (posters)
return "Users Posting in Conference " + conf.getName();
else
return "Users Reading Conference " + conf.getName();
} // end getPageTitle
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "conf_activity.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public String getConfName()
{
return conf.getName();
} // end getConfName
public String getLocator()
{
return "sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
} // end getLocator
public boolean isPosterReport()
{
return posters;
} // end isPosterReport
public boolean anyElements()
{
return (records.size()>0);
} // end anyElements
public Iterator getRecordsIterator()
{
return records.iterator();
} // end getRecordsIterator
} // end class ConferenceActivity

View File

@@ -225,6 +225,12 @@ public class ContentDialog implements Cloneable, ContentRender
*--------------------------------------------------------------------------------
*/
public void setTitle(String title)
{
this.title = title;
} // end setTitle
public void setErrorMessage(String message)
{
this.error_message = message;

View File

@@ -0,0 +1,149 @@
/*
* 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 com.silverwrist.util.StringUtil;
import com.silverwrist.venice.ValidationException;
import com.silverwrist.venice.security.Role;
import com.silverwrist.venice.core.*;
public class EditConferenceDialog extends ContentDialog
{
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public EditConferenceDialog()
{
super("Edit Conference:",null,"editconfform","confops");
setHiddenField("cmd","E");
setHiddenField("sig","");
setHiddenField("conf","");
addFormField(new CDFormCategoryHeader("Basic Information"));
addFormField(new CDTextFormField("name","Conference Name",null,true,32,128));
addFormField(new CDTextFormField("descr","Description",null,false,32,255));
addFormField(new CDCheckBoxFormField("hide","Hide conference in the SIG's conference list",null,"Y"));
addFormField(new CDFormCategoryHeader("Security Information"));
addFormField(new CDRoleListFormField("read_lvl","Security level required to read conference",null,true,
Role.getConferenceReadList()));
addFormField(new CDRoleListFormField("post_lvl","Security level required to post to conference",null,true,
Role.getConferencePostList()));
addFormField(new CDRoleListFormField("create_lvl",
"Security level required to create new topics in conference",null,
true,Role.getConferenceCreateList()));
addFormField(new CDRoleListFormField("hide_lvl",
"Security level required to archive or freeze topics",
"(or to hide posts of which you are not the owner)",true,
Role.getConferenceHideList()));
addFormField(new CDRoleListFormField("nuke_lvl",
"Security level required to delete topics or nuke posts",
"(or to scribble posts of which you are not the owner)",true,
Role.getConferenceNukeList()));
addFormField(new CDRoleListFormField("change_lvl",
"Security level required to change conference attributes",null,true,
Role.getConferenceChangeList()));
addFormField(new CDRoleListFormField("delete_lvl",
"Security level required to delete conference",null,true,
Role.getConferenceDeleteList()));
addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
} // end constructor
protected EditConferenceDialog(EditConferenceDialog other)
{
super(other);
} // end constructor
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setupDialog(SIGContext sig, ConferenceContext conf) throws DataException, AccessError
{
setHiddenField("sig",String.valueOf(sig.getSIGID()));
setHiddenField("conf",String.valueOf(conf.getConfID()));
setTitle("Edit Conference: " + conf.getName());
setFieldValue("name",conf.getName());
setFieldValue("descr",conf.getDescription());
if (conf.getHideList())
setFieldValue("hide","Y");
else
setFieldValue("hide","");
setFieldValue("read_lvl",String.valueOf(conf.getReadLevel()));
setFieldValue("post_lvl",String.valueOf(conf.getPostLevel()));
setFieldValue("create_lvl",String.valueOf(conf.getCreateLevel()));
setFieldValue("hide_lvl",String.valueOf(conf.getHideLevel()));
setFieldValue("nuke_lvl",String.valueOf(conf.getNukeLevel()));
setFieldValue("change_lvl",String.valueOf(conf.getChangeLevel()));
setFieldValue("delete_lvl",String.valueOf(conf.getDeleteLevel()));
} // end setupDialog
public void doDialog(ConferenceContext conf) throws ValidationException, DataException, AccessError
{
final String yes = "Y"; // the "yes" string
validate(); // validate the dialog entries
int read_lvl, post_lvl, create_lvl, hide_lvl, nuke_lvl, change_lvl, delete_lvl;
try
{ // get all the security levels out of their form fields
read_lvl = Integer.parseInt(getFieldValue("read_lvl"));
post_lvl = Integer.parseInt(getFieldValue("post_lvl"));
create_lvl = Integer.parseInt(getFieldValue("create_lvl"));
hide_lvl = Integer.parseInt(getFieldValue("hide_lvl"));
nuke_lvl = Integer.parseInt(getFieldValue("nuke_lvl"));
change_lvl = Integer.parseInt(getFieldValue("change_lvl"));
delete_lvl = Integer.parseInt(getFieldValue("delete_lvl"));
} // end try
catch (NumberFormatException nfe)
{ // how rude!
throw new InternalStateError("somehow we got a non-numeric result from a numeric dropdown list!");
} // end catch
// sweep through the conference and set the appropriate changes
conf.setName(getFieldValue("name"));
conf.setDescription(getFieldValue("descr"));
conf.setHideList(yes.equals(getFieldValue("hide")));
conf.setSecurityLevels(read_lvl,post_lvl,create_lvl,hide_lvl,nuke_lvl,change_lvl,delete_lvl);
} // end doDialog
public void resetOnError(SIGContext sig, ConferenceContext conf, String message)
{
setHiddenField("sig",String.valueOf(sig.getSIGID()));
setHiddenField("conf",String.valueOf(conf.getConfID()));
setTitle("Edit Conference: " + conf.getName());
setErrorMessage(message);
} // end resetOnError
public Object clone()
{
return new EditConferenceDialog(this);
} // end clone
} // end class EditConferenceDialog

View File

@@ -120,6 +120,12 @@ public class ManageConference implements JSPRender
} // end getLocator
public String getDefaultPseud()
{
return conf.getDefaultPseud();
} // end getDefaultPseud
public boolean displayAdminSection()
{
return conf.canChangeConference();

View File

@@ -0,0 +1,154 @@
/*
* 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 ManageConferenceAliases implements JSPRender
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
// Attribute name for request attribute
protected static final String ATTR_NAME = "com.silverwrist.venice.content.ManageConferenceAliases";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private SIGContext sig; // the SIG we're in
private ConferenceContext conf; // the conference being listed
private List aliases; // list of aliases generated
private String error_message; // error message to display
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public ManageConferenceAliases(SIGContext sig, ConferenceContext conf) throws DataException
{
this.sig = sig;
this.conf = conf;
this.aliases = conf.getAliases();
this.error_message = null;
} // end constructor
public ManageConferenceAliases(SIGContext sig, ConferenceContext conf, String message) throws DataException
{
this.sig = sig;
this.conf = conf;
this.aliases = conf.getAliases();
this.error_message = message;
} // end constructor
/*--------------------------------------------------------------------------------
* External static functions
*--------------------------------------------------------------------------------
*/
public static ManageConferenceAliases retrieve(ServletRequest request)
{
return (ManageConferenceAliases)(request.getAttribute(ATTR_NAME));
} // end retrieve
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceContent
*--------------------------------------------------------------------------------
*/
public String getPageTitle(RenderData rdat)
{
return "Manage Conference Aliases: " + conf.getName();
} // end getPageTitle
/*--------------------------------------------------------------------------------
* Implementations from interface JSPRender
*--------------------------------------------------------------------------------
*/
public void store(ServletRequest request)
{
request.setAttribute(ATTR_NAME,this);
} // end store
public String getTargetJSPName()
{
return "manage_aliases.jsp";
} // end getTargetJSPName
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public int getSIGID()
{
return sig.getSIGID();
} // end getSIGID
public int getConfID()
{
return conf.getConfID();
} // end getConfID
public String getConfName()
{
return conf.getName();
} // end getConfName
public String getLocator()
{
return "sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
} // end getLocator
public boolean canRemoveAliases()
{
return (aliases.size()>1);
} // end canRemoveAliases
public Iterator getAliasIterator()
{
return aliases.iterator();
} // end getAliasIterator
public String getErrorMessage()
{
return error_message;
} // end getErrorMessage
} // end class ManageConferenceAliases