2001-02-09 02:10:46 -07:00
|
|
|
/*
|
|
|
|
* 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.util.StringUtil;
|
|
|
|
import com.silverwrist.venice.ValidationException;
|
|
|
|
import com.silverwrist.venice.core.*;
|
|
|
|
import com.silverwrist.venice.servlets.format.*;
|
|
|
|
|
|
|
|
public class TopicOperations extends VeniceServlet
|
|
|
|
{
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
|
|
* Static data members
|
|
|
|
*--------------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static final String DELETE_CONFIRM_ATTR = "servlets.TopicOperations.delete.confirm";
|
|
|
|
private static final String DELETE_CONFIRM_PARAM = "confirm";
|
|
|
|
|
|
|
|
private static Category logger = Category.getInstance(TopicOperations.class.getName());
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
|
|
* Overrides from class HttpServlet
|
|
|
|
*--------------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
public String getServletInfo()
|
|
|
|
{
|
|
|
|
String rc = "TopicOperations servlet - General topic operations (freeze, archive, etc.)\n"
|
|
|
|
+ "Part of the Venice Web Communities System\n";
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
} // end getServletInfo
|
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
/*--------------------------------------------------------------------------------
|
|
|
|
* Overrides from class VeniceServlet
|
|
|
|
*--------------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
|
|
|
|
UserContext user, RenderData rdat)
|
|
|
|
throws ServletException, IOException, VeniceServletResult
|
2001-02-09 02:10:46 -07:00
|
|
|
{
|
2001-02-10 00:20:27 -07:00
|
|
|
// get the SIG
|
|
|
|
SIGContext sig = getSIGParameter(request,user,true,"top");
|
|
|
|
changeMenuSIG(request,sig);
|
|
|
|
String locator = "sig=" + sig.getSIGID();
|
|
|
|
String location = "sigprofile?" + locator;
|
|
|
|
|
|
|
|
// get the conference
|
|
|
|
ConferenceContext conf = getConferenceParameter(request,sig,true,location);
|
|
|
|
locator += "&conf=" + conf.getConfID();
|
|
|
|
location = "confdisp?" + locator;
|
|
|
|
|
|
|
|
// get the topic
|
|
|
|
TopicContext topic = getTopicParameter(request,conf,true,location);
|
|
|
|
locator += "&top=" + topic.getTopicNumber();
|
|
|
|
location = "confdisp?" + locator;
|
|
|
|
|
|
|
|
// figure out what command we want to perform...
|
|
|
|
String cmd = getStandardCommandParam(request);
|
|
|
|
|
|
|
|
if (cmd.equals("HY") || cmd.equals("HN"))
|
|
|
|
{ // we want to set the hide status of the topic
|
2001-02-09 02:10:46 -07:00
|
|
|
try
|
2001-02-10 00:20:27 -07:00
|
|
|
{ // call down to set the topic!
|
|
|
|
topic.setHidden(cmd.equals("HY"));
|
2001-02-09 02:10:46 -07:00
|
|
|
|
|
|
|
} // end try
|
|
|
|
catch (DataException de)
|
2001-02-10 00:20:27 -07:00
|
|
|
{ // there was a database error
|
|
|
|
return new ErrorBox("Database Error","Database error setting hide status: " + de.getMessage(),
|
|
|
|
location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
|
|
|
} // end catch
|
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
// go back to the topic view
|
|
|
|
throw new RedirectResult(location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end if ("hide" or "show")
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
if (cmd.equals("FY") || cmd.equals("FN"))
|
|
|
|
{ // we want to set the frozen status of the topic
|
|
|
|
try
|
|
|
|
{ // call down to set the topic!
|
|
|
|
topic.setFrozen(cmd.equals("FY"));
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end try
|
|
|
|
catch (DataException de)
|
|
|
|
{ // there was a database error
|
|
|
|
return new ErrorBox("Database Error","Database error setting freeze status: " + de.getMessage(),
|
|
|
|
location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end catch
|
|
|
|
catch (AccessError ae)
|
|
|
|
{ // naughty naughty = you can't do this!
|
|
|
|
return new ErrorBox("Access Error",ae.getMessage(),location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end catch
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
// go back to the topic view
|
|
|
|
throw new RedirectResult(location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end if ("freeze" or "unfreeze")
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
if (cmd.equals("AY") || cmd.equals("AN"))
|
|
|
|
{ // we want to change the archived status of the topic
|
|
|
|
try
|
|
|
|
{ // call down to set the topic!
|
|
|
|
topic.setArchived(cmd.equals("AY"));
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end try
|
|
|
|
catch (DataException de)
|
|
|
|
{ // there was a database error
|
|
|
|
return new ErrorBox("Database Error","Database error setting archive status: " + de.getMessage(),
|
|
|
|
location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end catch
|
|
|
|
catch (AccessError ae)
|
|
|
|
{ // naughty naughty = you can't do this!
|
|
|
|
return new ErrorBox("Access Error",ae.getMessage(),location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end catch
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
// go back to the topic view
|
|
|
|
throw new RedirectResult(location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end if ("archive" or "unarchive")
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
if (cmd.equals("DEL"))
|
|
|
|
{ // Delete Topic requires a confirmation!
|
|
|
|
if (ConfirmBox.isConfirmed(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM))
|
|
|
|
{ // OK, go ahead, delete the topic!
|
|
|
|
location = "confdisp?sig=" + sig.getSIGID() + "&conf=" + conf.getConfID();
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
try
|
|
|
|
{ // delete the bloody topic!
|
|
|
|
topic.delete();
|
2001-02-09 02:10:46 -07:00
|
|
|
|
|
|
|
} // end try
|
|
|
|
catch (DataException de)
|
|
|
|
{ // there was a database error
|
2001-02-10 00:20:27 -07:00
|
|
|
return new ErrorBox("Database Error","Database error deleting topic: " + de.getMessage(),location);
|
|
|
|
|
2001-02-09 02:10:46 -07:00
|
|
|
} // end catch
|
|
|
|
catch (AccessError ae)
|
|
|
|
{ // naughty naughty = you can't do this!
|
2001-02-10 00:20:27 -07:00
|
|
|
return new ErrorBox("Access Error",ae.getMessage(),location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
|
|
|
} // end catch
|
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
// go back to the conference view
|
|
|
|
throw new RedirectResult(location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end if (confirmed)
|
2001-02-09 02:10:46 -07:00
|
|
|
else
|
2001-02-10 00:20:27 -07:00
|
|
|
{ // not a proper confirmation - better display one
|
|
|
|
String message = "You are about to delete topic " + String.valueOf(topic.getTopicNumber())
|
|
|
|
+ " from the \"" + conf.getName() + "\" conference! Are you sure you want to do this?";
|
|
|
|
return new ConfirmBox(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM,"Delete Topic",message,
|
|
|
|
"topicops?" + locator + "&cmd=DEL",location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
|
|
|
} // end else
|
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end if (delete)
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
// unrecognized command
|
|
|
|
logger.error("invalid command to TopicOperations.doGet: " + cmd);
|
|
|
|
return new ErrorBox("Internal Error","Invalid command to TopicOperations.doGet",location);
|
2001-02-09 02:10:46 -07:00
|
|
|
|
2001-02-10 00:20:27 -07:00
|
|
|
} // end doVeniceGet
|
2001-02-09 02:10:46 -07:00
|
|
|
|
|
|
|
} // end class TopicOperations
|