diff --git a/src/com/silverwrist/util/StringUtil.java b/src/com/silverwrist/util/StringUtil.java index 2bccddf..31381ad 100644 --- a/src/com/silverwrist/util/StringUtil.java +++ b/src/com/silverwrist/util/StringUtil.java @@ -278,5 +278,48 @@ public class StringUtil } // end join -} // end class StringUtil + public static final List splitList(String data, String delims) + { + if ((data==null) || (delims==null)) + return Collections.EMPTY_LIST; + ArrayList rc = new ArrayList(); + StringBuffer buf = new StringBuffer(); + boolean accumulate = false; + for (int i=0; i=0) + { // delimiter character - flush the string if we have one + if (accumulate) + { // flush the buffer + rc.add(buf.toString()); + buf.setLength(0); + accumulate = false; + } // end if + + } // end if + else + { // ordinary character - accumulate it + accumulate = true; + buf.append(ch); + + } // end else + + } // end for + + if (rc.isEmpty()) + return Collections.EMPTY_LIST; + else + return Collections.unmodifiableList(rc); + + } // end splitList + + public static final String[] splitArray(String data, String delims) + { + List tmp = splitList(data,delims); + return (String[])(tmp.toArray(new String[0])); + + } // end splitArray + +} // end class StringUtil diff --git a/src/com/silverwrist/venice/core/CommunityContext.java b/src/com/silverwrist/venice/core/CommunityContext.java index 765179f..fc46507 100644 --- a/src/com/silverwrist/venice/core/CommunityContext.java +++ b/src/com/silverwrist/venice/core/CommunityContext.java @@ -164,6 +164,8 @@ public interface CommunityContext extends SearchMode public abstract void delete() throws DataException, AccessError; + public abstract void deleteCommunity() throws DataException, AccessError; + public abstract void sendInvitation(String address, String personal_message) throws AccessError, DataException, EmailException; diff --git a/src/com/silverwrist/venice/core/ConferenceContext.java b/src/com/silverwrist/venice/core/ConferenceContext.java index 82369cd..e63d16d 100644 --- a/src/com/silverwrist/venice/core/ConferenceContext.java +++ b/src/com/silverwrist/venice/core/ConferenceContext.java @@ -147,6 +147,8 @@ public interface ConferenceContext public abstract void delete() throws DataException, AccessError; + public abstract void deleteConference() throws DataException, AccessError; + public abstract boolean canDeleteConference(); public abstract boolean isInHotlist(); diff --git a/src/com/silverwrist/venice/core/SideBoxDescriptor.java b/src/com/silverwrist/venice/core/SideBoxDescriptor.java index 1912056..4f843f5 100644 --- a/src/com/silverwrist/venice/core/SideBoxDescriptor.java +++ b/src/com/silverwrist/venice/core/SideBoxDescriptor.java @@ -21,6 +21,8 @@ public interface SideBoxDescriptor { public abstract int getID(); + public abstract int getSideBoxID(); + public abstract int getSequence(); public abstract String getTitle(boolean anonymous); diff --git a/src/com/silverwrist/venice/core/TopicContext.java b/src/com/silverwrist/venice/core/TopicContext.java index c34be8e..164b05c 100644 --- a/src/com/silverwrist/venice/core/TopicContext.java +++ b/src/com/silverwrist/venice/core/TopicContext.java @@ -81,6 +81,8 @@ public interface TopicContext public abstract void delete() throws DataException, AccessError; + public abstract void deleteTopic() throws DataException, AccessError; + public abstract List getActivePosters(int skip, int limit) throws DataException, AccessError; public abstract List getActivePosters(int limit) throws DataException, AccessError; diff --git a/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java b/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java index 374c3ed..0827b4b 100644 --- a/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java @@ -1193,6 +1193,12 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end delete + public void deleteCommunity() throws DataException, AccessError + { + this.delete(); + + } // end delete + public void sendInvitation(String address, String personal_message) throws AccessError, DataException, EmailException { diff --git a/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java b/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java index 15d40de..578a1ec 100644 --- a/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java @@ -875,7 +875,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend { if (!(getConferenceData().canReadConference(level))) { // the luser can't even read the conference... - logger.error("getTopic(): user not permitted to change membership"); + logger.error("getTopic(): user not permitted to read"); throw new AccessError("You are not permitted to read this conference."); } // end if @@ -1253,6 +1253,12 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend } // end delete + public void deleteConference() throws DataException, AccessError + { + this.delete(); + + } // end deleteConference + public boolean canDeleteConference() { ConferenceCommunityContext c = getConferenceDataNE(); diff --git a/src/com/silverwrist/venice/core/impl/SideBoxDescriptorImpl.java b/src/com/silverwrist/venice/core/impl/SideBoxDescriptorImpl.java index 6215464..b4bf747 100644 --- a/src/com/silverwrist/venice/core/impl/SideBoxDescriptorImpl.java +++ b/src/com/silverwrist/venice/core/impl/SideBoxDescriptorImpl.java @@ -66,6 +66,12 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor } // end getID + public int getSideBoxID() + { + return parent.getID(); + + } // end getSideBoxID + public int getSequence() { return sequence; diff --git a/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java index d1b931d..fff8580 100644 --- a/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java @@ -958,6 +958,12 @@ class TopicUserContextImpl implements TopicContext } // end delete + public void deleteTopic() throws DataException, AccessError + { + this.delete(); + + } // end deleteTopic + public List getActivePosters(int skip, int limit) throws DataException { Connection conn = null; diff --git a/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java b/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java index d1e3d7b..b14127c 100644 --- a/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java +++ b/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java @@ -84,6 +84,12 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend } // end getID + public int getSideBoxID() + { + return id; + + } // end getSideBoxID + public int getSequence() { return -1; diff --git a/src/com/silverwrist/venice/security/AuditRecord.java b/src/com/silverwrist/venice/security/AuditRecord.java index 461ad20..abe58bc 100644 --- a/src/com/silverwrist/venice/security/AuditRecord.java +++ b/src/com/silverwrist/venice/security/AuditRecord.java @@ -72,9 +72,10 @@ public class AuditRecord implements AuditData if (rc==null) { // OK, get it from the database ResultSet rs = stmt.executeQuery("SELECT username FROM users WHERE uid = " + uid + ";"); - if (!(rs.next())) - throw new DataException("user name not found for UID " + uid); - rc = rs.getString(1); + if (rs.next()) + rc = rs.getString(1); + else + rc = "(UID #" + uid + ")"; uname_cache.put(uid_x,rc); } // end if @@ -92,9 +93,10 @@ public class AuditRecord implements AuditData if (rc==null) { // OK, get it from the database ResultSet rs = stmt.executeQuery("SELECT signame FROM sigs WHERE sigid = " + cid + ";"); - if (!(rs.next())) - throw new DataException("community name not found for community ID " + cid); - rc = rs.getString(1); + if (rs.next()) + rc = rs.getString(1); + else + rc = "(CID #" + cid + ")"; commname_cache.put(cid_x,rc); } // end if diff --git a/src/com/silverwrist/venice/servlets/CommunityOperations.java b/src/com/silverwrist/venice/servlets/CommunityOperations.java index 0c44ce0..13c3077 100644 --- a/src/com/silverwrist/venice/servlets/CommunityOperations.java +++ b/src/com/silverwrist/venice/servlets/CommunityOperations.java @@ -318,7 +318,7 @@ public class CommunityOperations extends VeniceServlet if (user.isLoggedIn()) return new ErrorBox("Community Error","You are not permitted to create communities.","top"); else - return new ErrorBox("Community Error","You must be logged in to create a new community.","top"); + return new LogInOrCreate("sigops?cmd=C"); } // end if diff --git a/src/com/silverwrist/venice/servlets/ConfDisplay.java b/src/com/silverwrist/venice/servlets/ConfDisplay.java index a809d6c..6e17250 100644 --- a/src/com/silverwrist/venice/servlets/ConfDisplay.java +++ b/src/com/silverwrist/venice/servlets/ConfDisplay.java @@ -348,14 +348,15 @@ public class ConfDisplay extends VeniceServlet ConferenceContext conf = getConferenceParameter(request,comm,true,"top"); // get the topic, if we have it - TopicContext topic = getTopicParameter(request,conf,false,"top"); + TopicContext topic = getTopicParameter(request,user,conf,false,"top", + "confdisp?" + request.getQueryString()); if (topic!=null) { // we're handling messages within a single topic if (logger.isDebugEnabled()) logger.debug("MODE: display messages in topic"); String on_error = "confdisp?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID(); - setMyLocation(request,on_error + "&topic=" + topic.getTopicNumber()); + setMyLocation(request,on_error + "&top=" + topic.getTopicNumber()); // if this request is restoring the number of unread posts in another topic, try to do so boolean do_readnew = restorePosts(request,conf,topic); @@ -380,7 +381,10 @@ public class ConfDisplay extends VeniceServlet } // end catch catch (AccessError ae) { // we were unable to retrieve the message list - return new ErrorBox("Access Error",ae.getMessage(),on_error); + if (user.isLoggedIn()) + return new ErrorBox("Access Error",ae.getMessage(),on_error); + else + return new LogInOrCreate(getMyLocation(request)); } // end catch @@ -393,7 +397,7 @@ public class ConfDisplay extends VeniceServlet String my_location = "confdisp?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID(); boolean read_new = !(StringUtil.isStringEmpty(request.getParameter("rnm"))); if (read_new) - my_location += "&rn=1"; + my_location += "&rnm=1"; setMyLocation(request,my_location); // get any changes to view or sort options @@ -441,7 +445,10 @@ public class ConfDisplay extends VeniceServlet } // end catch catch (AccessError ae) { // we were unable to retrieve the message list - return new ErrorBox("Access Error",ae.getMessage(),on_error); + if (user.isLoggedIn()) + return new ErrorBox("Access Error",ae.getMessage(),on_error); + else + return new LogInOrCreate(getMyLocation(request)); } // end catch @@ -462,7 +469,10 @@ public class ConfDisplay extends VeniceServlet } // end catch catch (AccessError ae) { // we were unable to retrieve the topic list - return new ErrorBox("Access Error",ae.getMessage(),on_error); + if (user.isLoggedIn()) + return new ErrorBox("Access Error",ae.getMessage(),on_error); + else + return new LogInOrCreate(getMyLocation(request)); } // end catch diff --git a/src/com/silverwrist/venice/servlets/ConfOperations.java b/src/com/silverwrist/venice/servlets/ConfOperations.java index 4d207dd..4a12109 100644 --- a/src/com/silverwrist/venice/servlets/ConfOperations.java +++ b/src/com/silverwrist/venice/servlets/ConfOperations.java @@ -710,8 +710,8 @@ public class ConfOperations extends VeniceServlet String message = "You are about to permanently delete the \"" + conf.getName() + "\" conference! " + "Are you sure you want to do this?"; return new ConfirmBox(request,DELETE_CONFIRM_ATTR,DELETE_CONFIRM_PARAM,"Delete Conference",message, - "confops?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID() + "&cmd=DEL", - on_error); + "confops?sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID() + + "&cmd=DEL",on_error); } // end else @@ -732,7 +732,14 @@ public class ConfOperations extends VeniceServlet } // end catch catch (AccessError ae) { // some lack of access is causing problems - return new ErrorBox("Access Error",ae.getMessage(),on_error); + if (user.isLoggedIn()) + return new ErrorBox("Access Error",ae.getMessage(),on_error); + else + { // they might need to log in first + setMyLocation(request,"confops?sig=" + comm.getCommunityID()); + return new LogInOrCreate("confops?sig=" + comm.getCommunityID()); + + } // end else } // end catch diff --git a/src/com/silverwrist/venice/servlets/VeniceServlet.java b/src/com/silverwrist/venice/servlets/VeniceServlet.java index 50baae1..3ab4a4e 100644 --- a/src/com/silverwrist/venice/servlets/VeniceServlet.java +++ b/src/com/silverwrist/venice/servlets/VeniceServlet.java @@ -108,8 +108,9 @@ public abstract class VeniceServlet extends HttpServlet } // end getCommunityParameter - private static TopicContext getTopicParameter(String str, ConferenceContext conf, boolean required, - String on_error) throws ErrorBox + private static TopicContext getTopicParameter(String str, UserContext user, ConferenceContext conf, + boolean required, String on_error, String target) + throws ErrorBox, LogInOrCreate { if (StringUtil.isStringEmpty(str)) { // there's no topic parameter @@ -153,6 +154,9 @@ public abstract class VeniceServlet extends HttpServlet } // end catch catch (AccessError ae) { // these all get handled in pretty much the same way + logger.error("getTopicParameter(): Access error retrieving topic parameter"); + if ((user!=null) && (target!=null) && !(user.isLoggedIn())) + throw new LogInOrCreate(target); throw new ErrorBox("Access Error",ae.getMessage(),on_error); } // end catch @@ -454,19 +458,29 @@ public abstract class VeniceServlet extends HttpServlet } // end getConferenceParameter protected final static TopicContext getTopicParameter(ServletRequest request, ConferenceContext conf, - boolean required, String on_error) throws ErrorBox + boolean required, String on_error) + throws ErrorBox, LogInOrCreate { - return getTopicParameter(request.getParameter("top"),conf,required,on_error); + return getTopicParameter(request.getParameter("top"),null,conf,required,on_error,null); + + } // end getTopicParameter + + protected final static TopicContext getTopicParameter(ServletRequest request, UserContext user, + ConferenceContext conf, boolean required, + String on_error, String target) + throws ErrorBox, LogInOrCreate + { + return getTopicParameter(request.getParameter("top"),user,conf,required,on_error,target); } // end getTopicParameter protected final static TopicContext getTopicParameter(ServletMultipartHandler mphandler, ConferenceContext conf, boolean required, - String on_error) throws ErrorBox + String on_error) throws ErrorBox, LogInOrCreate { if (mphandler.isFileParam("top")) throw new ErrorBox(null,"Internal Error: topic should be a normal param",on_error); - return getTopicParameter(mphandler.getValue("top"),conf,required,on_error); + return getTopicParameter(mphandler.getValue("top"),null,conf,required,on_error,null); } // end getTopicParameter @@ -511,10 +525,16 @@ public abstract class VeniceServlet extends HttpServlet *-------------------------------------------------------------------------------- */ + protected String getMyLocation(HttpServletRequest request) + { + return (String)(request.getAttribute(LOCATION_ATTR)); + + } // end getMyLocation + protected String getMyLocation(HttpServletRequest request, VeniceEngine engine, UserContext user, RenderData rdat) { - return (String)(request.getAttribute(LOCATION_ATTR)); + return getMyLocation(request); } // end getMyLocation diff --git a/src/com/silverwrist/venice/servlets/format/LogInOrCreate.java b/src/com/silverwrist/venice/servlets/format/LogInOrCreate.java new file mode 100644 index 0000000..dee8524 --- /dev/null +++ b/src/com/silverwrist/venice/servlets/format/LogInOrCreate.java @@ -0,0 +1,112 @@ +/* + * 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 . + * + * 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 , + * 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.net.URLEncoder; +import java.io.Writer; +import java.io.IOException; +import javax.servlet.*; +import com.silverwrist.util.StringUtil; +import com.silverwrist.venice.servlets.VeniceServletResult; + +public class LogInOrCreate extends VeniceServletResult implements JSPRender, ColorSelectors +{ + /*-------------------------------------------------------------------------------- + * Static data members + *-------------------------------------------------------------------------------- + */ + + // Attribute name for request attribute + protected static final String ATTR_NAME = "com.silverwrist.venice.content.LogInOrCreate"; + + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private String target; + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + public LogInOrCreate(String target) + { + super(); + this.target = target; + + } // end constructor + + /*-------------------------------------------------------------------------------- + * External static functions + *-------------------------------------------------------------------------------- + */ + + public static LogInOrCreate retrieve(ServletRequest request) + { + return (LogInOrCreate)(request.getAttribute(ATTR_NAME)); + + } // end retrieve + + /*-------------------------------------------------------------------------------- + * Implementations from interface VeniceContent + *-------------------------------------------------------------------------------- + */ + + public String getPageTitle(RenderData rdat) + { + return "Log In or Create Account"; + + } // end getPageTitle + + public String getPageQID() + { + return null; + + } // end getPageQID + + /*-------------------------------------------------------------------------------- + * Implementations from interface JSPRender + *-------------------------------------------------------------------------------- + */ + + public void store(ServletRequest request) + { + request.setAttribute(ATTR_NAME,this); + + } // end store + + public String getTargetJSPName() + { + return "login_or_create.jsp"; + + } // end getTargetJSPName + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public String getTargetURL(RenderData rdat, String base_URL) + { + return rdat.getEncodedServletPath(base_URL + URLEncoder.encode(target)); + + } // end getTargetURL + +} // end class LogInOrCreate diff --git a/web/format/import_form.jsp b/web/format/import_form.jsp index edfada9..caa940d 100644 --- a/web/format/import_form.jsp +++ b/web/format/import_form.jsp @@ -39,4 +39,4 @@ The user accounts are imported as an XML file. <%-- TODO: put a description of the contents here, or a link to a DTD --%> - \ No newline at end of file + diff --git a/web/format/login_or_create.jsp b/web/format/login_or_create.jsp new file mode 100644 index 0000000..e52ac9e --- /dev/null +++ b/web/format/login_or_create.jsp @@ -0,0 +1,32 @@ +<%-- + 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 . + + 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 , + 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): +--%> +<%@ page import = "java.util.*" %> +<%@ page import = "com.silverwrist.util.StringUtil" %> +<%@ page import = "com.silverwrist.venice.core.*" %> +<%@ page import = "com.silverwrist.venice.servlets.Variables" %> +<%@ page import = "com.silverwrist.venice.servlets.format.*" %> +<% + LogInOrCreate data = LogInOrCreate.retrieve(request); + RenderData rdat = RenderConfig.createRenderData(application,request,response); +%> +<% rdat.writeContentHeader(out,"Log In or Create Account",null); %> +<%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %> + You must log in or create an account before you can view this page.

+ Returning users ">log in here.

+ New users ">create an account here.

+