");
+ out.println("Go back.");
+ out.println("");
+
+ } // end old_doPost
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException
+ {
+ final String save_dir = "/home/erbo";
+ String errmsg = null;
+ ServletMultipartHandler smh = null;
+ boolean file_check = false;
+ String text_value = null;
+ String file_name = null;
+ String file_type = null;
+
+ try
+ { // create the multipart handler
+ smh = new ServletMultipartHandler(request);
+ text_value = smh.getValue("text");
+ file_check = smh.isFileParam("file");
+ if (file_check)
+ { // copy out to file
+ file_name = smh.getValue("file");
+ file_type = smh.getContentType("file");
+ if ((file_name!=null) && (file_name.length()>0))
+ { // build the file name and save it
+ FileOutputStream stm = new FileOutputStream(save_dir + "/" + file_name);
+ InputStream in = smh.getFileContentStream("file");
+ byte[] copybuf = new byte[1024];
+ int ct = in.read(copybuf);
+ while (ct>=0)
+ { // copy loop...
+ if (ct>0)
+ stm.write(copybuf,0,ct);
+ ct = in.read(copybuf);
+
+ } // end while
+
+ stm.close();
+ in.close();
+
+ } // end if
+
+ } // end if
+
+ } // end try
+ catch (ServletMultipartException e)
+ { // load error message
+ errmsg = e.getMessage();
+
+ } // end catch
+
+ PrintWriter out = response.getWriter();
+ out.println("Form Test Results");
+ out.println("
Form Test Results
");
+ if (errmsg==null)
+ { // print data
+ out.println("Text value: " + text_value + "
");
+ if (file_check)
+ { // get file name and type
+ out.println("File name: " + file_name + "
");
+ out.println("File type: " + file_type + "
");
+ out.println("Saved to directory: " + save_dir + "
");
+
+ } // end if
+ else
+ out.println("Not a file.
");
+
+ } // end if
+ else
+ out.println("ERROR: " + errmsg + "
");
+ out.println("Go back.");
+ out.println("");
+
+ } // end doPost
+
+} // end class FormDataTest
diff --git a/src/com/silverwrist/util/test/TestMultiHandler.java b/src/com/silverwrist/util/test/TestMultiHandler.java
new file mode 100644
index 0000000..7e97da4
--- /dev/null
+++ b/src/com/silverwrist/util/test/TestMultiHandler.java
@@ -0,0 +1,121 @@
+package com.silverwrist.util.test;
+
+import java.io.*;
+import java.util.*;
+import javax.activation.DataSource;
+import javax.mail.*;
+import javax.mail.internet.*;
+import javax.servlet.*;
+
+public class TestMultiHandler
+{
+ private MimeMultipart multipart;
+ private int count;
+ private Vector params;
+
+ static class ServletDataSource implements DataSource
+ {
+ private ServletRequest request;
+ private InputStream istm = null;
+
+ public ServletDataSource(ServletRequest request)
+ {
+ this.request = request;
+
+ } // end constructor
+
+ public InputStream getInputStream() throws IOException
+ {
+ if (istm==null)
+ istm = request.getInputStream();
+ return istm;
+
+ } // end getInputStream
+
+ public OutputStream getOutputStream() throws IOException
+ {
+ throw new IOException("tried to get OutputStream on servlet input?!?!?");
+
+ } // end getOutputStream
+
+ public String getContentType()
+ {
+ return request.getContentType();
+
+ } // end getContentType
+
+ public String getName()
+ {
+ return "servlet";
+
+ } // end getName
+
+ } // end class ServletDataSource
+
+ public TestMultiHandler(ServletRequest request) throws IOException
+ {
+ if (!canHandle(request))
+ throw new UnsupportedOperationException("data type doesn't match");
+
+ try
+ { // OK, this is the tricky part...
+ ServletDataSource ds = new ServletDataSource(request);
+ multipart = new MimeMultipart(ds);
+ count = multipart.getCount();
+ params = new Vector(count);
+ // OK, that's enough for now
+
+ } // end try
+ catch (MessagingException e)
+ { // better run like hell, 'cos this may not work
+ throw new IOException("Got MessagingException: " + e.getMessage());
+
+ } // end catch
+
+ } // end constructor
+
+ public static boolean canHandle(ServletRequest request)
+ {
+ String ctype = request.getContentType();
+ return (ctype.startsWith("multipart/form-data"));
+
+ } // end canHandle
+
+ public int getCount()
+ {
+ return count;
+
+ } // end getCount
+
+ public void dump(PrintWriter out)
+ {
+ try
+ { // print out all parts
+ int ct = multipart.getCount();
+ out.println("Number of parts: " + String.valueOf(ct));
+
+ for (int i=0; i.
+ *
+ * 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 Community 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;
+
+public class ValidationException extends VeniceException
+{
+ public ValidationException()
+ {
+ super();
+
+ } // end constructor
+
+ public ValidationException(String msg)
+ {
+ super(msg);
+
+ } // end constructor
+
+ public ValidationException(Exception e)
+ {
+ super(e);
+
+ } // end constructor
+
+ public ValidationException(String msg, Exception e)
+ {
+ super(msg,e);
+
+ } // end constructor
+
+} // end class ValidationException
diff --git a/src/com/silverwrist/venice/VeniceException.java b/src/com/silverwrist/venice/VeniceException.java
new file mode 100644
index 0000000..f57a300
--- /dev/null
+++ b/src/com/silverwrist/venice/VeniceException.java
@@ -0,0 +1,64 @@
+/*
+ * 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 Community 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;
+
+public class VeniceException extends Exception
+{
+ // Attributes
+ private Exception e = null; // internal "root cause" exception
+
+ public VeniceException()
+ {
+ super();
+
+ } // end constructor
+
+ public VeniceException(String msg)
+ {
+ super(msg);
+
+ } // end constructor
+
+ public VeniceException(Exception e)
+ {
+ super(e.getMessage());
+ this.e = e;
+
+ } // end constructor
+
+ public VeniceException(String msg, Exception e)
+ {
+ super(msg);
+ this.e = e;
+
+ } // end constructor
+
+ protected void finalize() throws Throwable
+ {
+ e = null;
+ super.finalize();
+
+ } // end finalize
+
+ public Exception getException()
+ {
+ return e;
+
+ } // end getException
+
+} // end class VeniceException
diff --git a/src/com/silverwrist/venice/core/AccessError.java b/src/com/silverwrist/venice/core/AccessError.java
new file mode 100644
index 0000000..fad5230
--- /dev/null
+++ b/src/com/silverwrist/venice/core/AccessError.java
@@ -0,0 +1,46 @@
+/*
+ * 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 Community 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.core;
+
+public class AccessError extends com.silverwrist.venice.VeniceException
+{
+ public AccessError()
+ {
+ super();
+
+ } // end constructor
+
+ public AccessError(String msg)
+ {
+ super(msg);
+
+ } // end constructor
+
+ public AccessError(Exception e)
+ {
+ super(e);
+
+ } // end constructor
+
+ public AccessError(String msg, Exception e)
+ {
+ super(msg,e);
+
+ } // end constructor
+
+} // end class AccessError
diff --git a/src/com/silverwrist/venice/core/AdminOperations.java b/src/com/silverwrist/venice/core/AdminOperations.java
new file mode 100644
index 0000000..3b7c498
--- /dev/null
+++ b/src/com/silverwrist/venice/core/AdminOperations.java
@@ -0,0 +1,23 @@
+/*
+ * 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 Community 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.core;
+
+public interface AdminOperations
+{
+ // TODO: fill this in
+} // end interface AdminOperations
diff --git a/src/com/silverwrist/venice/core/CategoryDescriptor.java b/src/com/silverwrist/venice/core/CategoryDescriptor.java
new file mode 100644
index 0000000..259dd4a
--- /dev/null
+++ b/src/com/silverwrist/venice/core/CategoryDescriptor.java
@@ -0,0 +1,50 @@
+/*
+ * 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 Community 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.core;
+
+import java.util.List;
+
+public interface CategoryDescriptor
+{
+ public abstract int getCategoryID();
+
+ public abstract int getNumLevels();
+
+ public abstract int getIDAtLevel(int level);
+
+ public abstract String getTitleAtLevel(int level);
+
+ public abstract List getSubCategories() throws DataException;
+
+ public abstract CategoryDescriptor getSuperCategory(int levels);
+
+ public abstract CategoryDescriptor getParentCategory();
+
+ public abstract int getLinkedCategoryID();
+
+ public abstract boolean isSymbolicLink();
+
+ public abstract CategoryDescriptor getLinkedCategory() throws DataException;
+
+ public abstract boolean equals(Object obj);
+
+ public abstract int hashCode();
+
+ public abstract String toString();
+
+} // end interface CategoryDescriptor
diff --git a/src/com/silverwrist/venice/core/ConferenceContext.java b/src/com/silverwrist/venice/core/ConferenceContext.java
new file mode 100644
index 0000000..50b8eaf
--- /dev/null
+++ b/src/com/silverwrist/venice/core/ConferenceContext.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 Community 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.core;
+
+import java.util.Date;
+import java.util.List;
+
+public interface ConferenceContext
+{
+ public static final int GET_ALL = 0;
+ public static final int DISPLAY_NEW = 1;
+ public static final int DISPLAY_ACTIVE = 2;
+ public static final int DISPLAY_ALL = 3;
+ public static final int DISPLAY_HIDDEN = 4;
+ public static final int DISPLAY_ARCHIVED = 5;
+
+ public static final int SORT_TOPICID = 0;
+ public static final int SORT_NUMBER = 1;
+ public static final int SORT_NAME = 2;
+ public static final int SORT_UNREAD = 3;
+ public static final int SORT_TOTAL = 4;
+ public static final int SORT_DATE = 5;
+
+ public abstract int getConfID();
+
+ public abstract String getName();
+
+ public abstract String getDescription();
+
+ public abstract Date getCreationDate();
+
+ public abstract Date getLastUpdateDate();
+
+ public abstract List getAliases() throws DataException;
+
+ public abstract List getHosts() throws DataException;
+
+ public abstract boolean canReadConference();
+
+ public abstract boolean canPostToConference();
+
+ public abstract boolean canCreateTopic();
+
+ public abstract boolean canChangeConference();
+
+ public abstract int getReadLevel() throws DataException, AccessError;
+
+ public abstract int getPostLevel() throws DataException, AccessError;
+
+ public abstract int getCreateLevel() throws DataException, AccessError;
+
+ public abstract int getHideLevel() throws DataException, AccessError;
+
+ public abstract int getNukeLevel() throws DataException, AccessError;
+
+ public abstract int getChangeLevel() throws DataException, AccessError;
+
+ public abstract int getDeleteLevel() throws DataException, AccessError;
+
+ public abstract void setSecurityLevels(int read, int post, int create, int hide, int nuke,
+ int change, int delete) throws DataException, AccessError;
+
+ public abstract void setName(String val) throws DataException, AccessError;
+
+ public abstract void setDescription(String val) throws DataException, AccessError;
+
+ public abstract void addAlias(String alias) throws DataException, AccessError;
+
+ public abstract void removeAlias(String alias) throws DataException, AccessError;
+
+ public abstract void addMember(int uid, boolean as_host) throws DataException, AccessError;
+
+ public abstract void removeMember(int uid) throws DataException, AccessError;
+
+ public abstract int getSIGGrantedLevel() throws DataException, AccessError;
+
+ public abstract void setSIGGrantedLevel(int new_level) throws DataException, AccessError;
+
+ public abstract short getSequence() throws DataException, AccessError;
+
+ public abstract void setSequence(short seq) throws DataException, AccessError;
+
+ public abstract boolean getHideList() throws DataException, AccessError;
+
+ public abstract void setHideList(boolean flag) throws DataException, AccessError;
+
+ public abstract String getDefaultPseud();
+
+ public abstract void setDefaultPseud(String val) throws DataException;
+
+ public abstract boolean anyUnread();
+
+ public abstract List getTopicList(int get_option, int sort_option) throws DataException, AccessError;
+
+ public abstract TopicContext getTopic(short number) throws DataException, AccessError;
+
+} // end interface ConferenceContext
diff --git a/src/com/silverwrist/venice/core/ConfigException.java b/src/com/silverwrist/venice/core/ConfigException.java
new file mode 100644
index 0000000..0a4c3da
--- /dev/null
+++ b/src/com/silverwrist/venice/core/ConfigException.java
@@ -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 .
+ *
+ * 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 Community 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.core;
+
+import org.w3c.dom.*;
+import com.silverwrist.venice.VeniceException;
+
+public class ConfigException extends VeniceException
+{
+ // Attributes
+ private Node faulty_sect = null; // section of the configuration at fault
+
+ public ConfigException()
+ {
+ super();
+
+ } // end constructor
+
+ public ConfigException(String msg)
+ {
+ super(msg);
+
+ } // end constructor
+
+ public ConfigException(Exception e)
+ {
+ super(e);
+
+ } // end constructor
+
+ public ConfigException(String msg, Exception e)
+ {
+ super(msg,e);
+
+ } // end constructor
+
+ public ConfigException(Node faulty_sect)
+ {
+ super("Error in <" + faulty_sect.getNodeName() + "/> section of configuration!");
+ this.faulty_sect = faulty_sect;
+
+ } // end constructor
+
+ public ConfigException(String msg, Node faulty_sect)
+ {
+ super(msg);
+ this.faulty_sect = faulty_sect;
+
+ } // end constructor
+
+ public ConfigException(Exception e, Node faulty_sect)
+ {
+ super("Error in <" + faulty_sect.getNodeName() + "/> section of configuration - " + e.getMessage(),e);
+ this.faulty_sect = faulty_sect;
+
+ } // end constructor
+
+ public ConfigException(String msg, Exception e, Node faulty_sect)
+ {
+ super(msg,e);
+ this.faulty_sect = faulty_sect;
+
+ } // end constructor
+
+ protected void finalize() throws Throwable
+ {
+ faulty_sect = null;
+ super.finalize();
+
+ } // end finalize
+
+ public Node getFaultySect()
+ {
+ return faulty_sect;
+
+ } // end getFaultySect
+
+} // end class ConfigException
diff --git a/src/com/silverwrist/venice/core/ContactInfo.java b/src/com/silverwrist/venice/core/ContactInfo.java
new file mode 100644
index 0000000..a2a5003
--- /dev/null
+++ b/src/com/silverwrist/venice/core/ContactInfo.java
@@ -0,0 +1,123 @@
+/*
+ * 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 Community 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.core;
+
+import java.util.Date;
+import java.sql.Connection;
+
+public interface ContactInfo
+{
+ public abstract int getContactID();
+
+ public abstract String getGivenName();
+
+ public abstract void setGivenName(String name);
+
+ public abstract String getFamilyName();
+
+ public abstract void setFamilyName(String name);
+
+ public abstract char getMiddleInitial();
+
+ public abstract void setMiddleInitial(char in);
+
+ public abstract String getNamePrefix();
+
+ public abstract void setNamePrefix(String p);
+
+ public abstract String getNameSuffix();
+
+ public abstract void setNameSuffix(String s);
+
+ public abstract String getCompany();
+
+ public abstract void setCompany(String c);
+
+ public abstract String getAddressLine1();
+
+ public abstract void setAddressLine1(String addr);
+
+ public abstract String getAddressLine2();
+
+ public abstract void setAddressLine2(String addr);
+
+ public abstract String getLocality();
+
+ public abstract void setLocality(String city);
+
+ public abstract String getRegion();
+
+ public abstract void setRegion(String state);
+
+ public abstract String getPostalCode();
+
+ public abstract void setPostalCode(String zip);
+
+ public abstract String getCountry();
+
+ public abstract void setCountry(String c);
+
+ public abstract String getPhone();
+
+ public abstract void setPhone(String num);
+
+ public abstract String getFax();
+
+ public abstract void setFax(String num);
+
+ public abstract String getMobile();
+
+ public abstract void setMobile(String num);
+
+ public abstract String getEmail();
+
+ public abstract void setEmail(String addr);
+
+ public abstract String getPhotoURL();
+
+ public abstract void setPhotoURL(String addr);
+
+ public abstract String getURL();
+
+ public abstract void setURL(String addr);
+
+ public abstract boolean getPrivateAddress();
+
+ public abstract void setPrivateAddress(boolean flag);
+
+ public abstract boolean getPrivatePhone();
+
+ public abstract void setPrivatePhone(boolean flag);
+
+ public abstract boolean getPrivateFax();
+
+ public abstract void setPrivateFax(boolean flag);
+
+ public abstract boolean getPrivateEmail();
+
+ public abstract void setPrivateEmail(boolean flag);
+
+ public abstract int getOwnerUID();
+
+ public abstract int getOwnerSIGID();
+
+ public abstract Date getLastUpdate();
+
+ public abstract boolean getModified();
+
+} // end interface ContactInfo
diff --git a/src/com/silverwrist/venice/core/Country.java b/src/com/silverwrist/venice/core/Country.java
new file mode 100644
index 0000000..52ab5a1
--- /dev/null
+++ b/src/com/silverwrist/venice/core/Country.java
@@ -0,0 +1,26 @@
+/*
+ * 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 Community 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.core;
+
+public interface Country
+{
+ public abstract String getCode();
+
+ public abstract String getName();
+
+} // end interface Country
diff --git a/src/com/silverwrist/venice/core/DataException.java b/src/com/silverwrist/venice/core/DataException.java
new file mode 100644
index 0000000..129b7f0
--- /dev/null
+++ b/src/com/silverwrist/venice/core/DataException.java
@@ -0,0 +1,46 @@
+/*
+ * 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 Community 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.core;
+
+public class DataException extends com.silverwrist.venice.VeniceException
+{
+ public DataException()
+ {
+ super();
+
+ } // end constructor
+
+ public DataException(String msg)
+ {
+ super(msg);
+
+ } // end constructor
+
+ public DataException(Exception e)
+ {
+ super(e);
+
+ } // end constructor
+
+ public DataException(String msg, Exception e)
+ {
+ super(msg,e);
+
+ } // end constructor
+
+} // end class DataException
diff --git a/src/com/silverwrist/venice/core/EmailException.java b/src/com/silverwrist/venice/core/EmailException.java
new file mode 100644
index 0000000..85ab617
--- /dev/null
+++ b/src/com/silverwrist/venice/core/EmailException.java
@@ -0,0 +1,46 @@
+/*
+ * 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 Community 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.core;
+
+public class EmailException extends com.silverwrist.venice.VeniceException
+{
+ public EmailException()
+ {
+ super();
+
+ } // end constructor
+
+ public EmailException(String msg)
+ {
+ super(msg);
+
+ } // end constructor
+
+ public EmailException(Exception e)
+ {
+ super(e);
+
+ } // end constructor
+
+ public EmailException(String msg, Exception e)
+ {
+ super(msg,e);
+
+ } // end constructor
+
+} // end class EmailException
diff --git a/src/com/silverwrist/venice/core/FrontPageViewConfig.java b/src/com/silverwrist/venice/core/FrontPageViewConfig.java
new file mode 100644
index 0000000..c355744
--- /dev/null
+++ b/src/com/silverwrist/venice/core/FrontPageViewConfig.java
@@ -0,0 +1,36 @@
+/*
+ * 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 Community 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.core;
+
+public interface FrontPageViewConfig
+{
+ public abstract int getNumRows();
+
+ public abstract int getNumColumns();
+
+ public abstract String getPartID(int row, int column);
+
+ public abstract void setPartID(int row, int column, String partid);
+
+ public abstract String getParameter(int row, int column);
+
+ public abstract void setParameter(int row, int column, String param);
+
+ public abstract boolean getModified();
+
+} // end interface FrontPageViewConfig
diff --git a/src/com/silverwrist/venice/core/IDUtils.java b/src/com/silverwrist/venice/core/IDUtils.java
new file mode 100644
index 0000000..a891869
--- /dev/null
+++ b/src/com/silverwrist/venice/core/IDUtils.java
@@ -0,0 +1,75 @@
+/*
+ * 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 Community 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.core;
+
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.AddressException;
+
+public class IDUtils
+{
+ /**
+ * The list of valid characters in Venice identifiers other than alphanumerics.
+ */
+ private static final String EXTRA_VALID = "-_~*'$";
+
+ public static boolean isValidVeniceID(String id)
+ {
+ if ((id==null) || (id.length()==0))
+ return false; // null values and null strings are NEVER valid
+ for (int i=0; i='A') && (c<='Z'))
+ continue; // upper-case letters are OK
+ if ((c>='a') && (c<='z'))
+ continue; // lower-case letters are OK
+ if ((c>='0') && (c<='9'))
+ continue; // digits are OK
+ if (EXTRA_VALID.indexOf(c)<0)
+ return false;
+
+ } // end for
+
+ return true; // all tests passed - ship it!
+
+ } // end isValidVeniceID
+
+ public static boolean isValidEmailAddress(String addr)
+ {
+ try
+ { // take advantage of the JavaMail address parser
+ InternetAddress tmp = new InternetAddress(addr);
+
+ } // end try
+ catch (AddressException e)
+ { // if we get an AddressException, it's not valid, is it?
+ return false;
+
+ } // end catch
+
+ return true; // if get here, it's valid
+
+ } // end isValidEmailAddress
+
+ public static boolean isValidConfirmationNumber(int num)
+ {
+ return ((num>=1000000) && (num<=9999999));
+
+ } // end isValidConfirmationNumber
+
+} // end class IDUtils
diff --git a/src/com/silverwrist/venice/core/InternalStateError.java b/src/com/silverwrist/venice/core/InternalStateError.java
new file mode 100644
index 0000000..cf98ce1
--- /dev/null
+++ b/src/com/silverwrist/venice/core/InternalStateError.java
@@ -0,0 +1,64 @@
+/*
+ * 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 Community 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.core;
+
+public class InternalStateError extends RuntimeException
+{
+ // Attributes
+ private Exception e = null; // internal "root cause" exception
+
+ public InternalStateError()
+ {
+ super();
+
+ } // end constructor
+
+ public InternalStateError(String msg)
+ {
+ super(msg);
+
+ } // end constructor
+
+ public InternalStateError(Exception e)
+ {
+ super(e.getMessage());
+ this.e = e;
+
+ } // end constructor
+
+ public InternalStateError(String msg, Exception e)
+ {
+ super(msg);
+ this.e = e;
+
+ } // end constructor
+
+ protected void finalize() throws Throwable
+ {
+ e = null;
+ super.finalize();
+
+ } // end finalize
+
+ public Exception getException()
+ {
+ return e;
+
+ } // end getException
+
+} // end class InternalStateError
diff --git a/src/com/silverwrist/venice/core/Language.java b/src/com/silverwrist/venice/core/Language.java
new file mode 100644
index 0000000..892a724
--- /dev/null
+++ b/src/com/silverwrist/venice/core/Language.java
@@ -0,0 +1,26 @@
+/*
+ * 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 Community 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.core;
+
+public interface Language
+{
+ public abstract String getCode();
+
+ public abstract String getName();
+
+} // end interface Language
diff --git a/src/com/silverwrist/venice/core/SIGContext.java b/src/com/silverwrist/venice/core/SIGContext.java
new file mode 100644
index 0000000..f0fb7d9
--- /dev/null
+++ b/src/com/silverwrist/venice/core/SIGContext.java
@@ -0,0 +1,147 @@
+/*
+ * 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 Community 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.core;
+
+import java.util.BitSet;
+import java.util.Date;
+import java.util.List;
+
+public interface SIGContext
+{
+ public static final int HIDE_NONE = 0;
+ public static final int HIDE_DIRECTORY = 1;
+ public static final int HIDE_BOTH = 2;
+
+ public abstract int getSIGID();
+
+ public abstract String getName();
+
+ public abstract String getAlias();
+
+ public abstract boolean isMember();
+
+ public abstract boolean isAdmin();
+
+ public abstract boolean isPublicSIG();
+
+ public abstract int getCategoryID();
+
+ public abstract CategoryDescriptor getCategory() throws DataException;
+
+ public abstract String getSynopsis();
+
+ public abstract int getHostUID();
+
+ public abstract UserProfile getHostProfile() throws DataException;
+
+ public abstract String getLanguageCode();
+
+ public abstract String getLanguageFullName();
+
+ public abstract String getRules();
+
+ public abstract Date getCreationDate();
+
+ public abstract Date getLastAccessDate();
+
+ public abstract Date getLastUpdateDate();
+
+ public abstract ContactInfo getContactInfo() throws DataException;
+
+ public abstract void putContactInfo(ContactInfo ci) throws DataException, AccessError;
+
+ public abstract BitSet getFeatures();
+
+ public abstract void setFeatures(BitSet feature_set, BitSet mask) throws DataException, AccessError;
+
+ public abstract List getSIGFeaturesList();
+
+ public abstract String getDefaultApplet();
+
+ public abstract void setName(String name) throws DataException, AccessError;
+
+ public abstract void setAlias(String alias) throws DataException, AccessError;
+
+ public abstract void setCategoryID(int catid) throws DataException, AccessError;
+
+ public abstract void setCategory(CategoryDescriptor cat) throws DataException, AccessError;
+
+ public abstract void setSynopsis(String synopsis) throws DataException, AccessError;
+
+ public abstract void setLanguage(String language) throws DataException, AccessError;
+
+ public abstract void setRules(String rules) throws DataException, AccessError;
+
+ public abstract int getHideMode();
+
+ public abstract void setHideMode(int mode) throws DataException, AccessError;
+
+ public abstract boolean getMembersOnly();
+
+ public abstract void setMembersOnly(boolean flag) throws DataException, AccessError;
+
+ public abstract short getInitialFeatureIndex();
+
+ public abstract void setInitialFeatureIndex(short ndx) throws DataException, AccessError;
+
+ public abstract String getJoinKey() throws DataException, AccessError;
+
+ public abstract void setJoinKey(String key) throws DataException, AccessError;
+
+ public abstract int getReadLevel() throws DataException, AccessError;
+
+ public abstract int getWriteLevel() throws DataException, AccessError;
+
+ public abstract int getCreateLevel() throws DataException, AccessError;
+
+ public abstract int getDeleteLevel() throws DataException, AccessError;
+
+ public abstract int getJoinLevel() throws DataException, AccessError;
+
+ public abstract void setSecurityLevels(int read, int write, int create, int delete, int join)
+ throws DataException, AccessError;
+
+ public abstract boolean canAdministerSIG();
+
+ public abstract boolean canModifyProfile();
+
+ public abstract boolean isAdminSIG();
+
+ public abstract void join(String joinkey) throws DataException, AccessError;
+
+ public abstract void unjoin() throws DataException, AccessError;
+
+ public abstract int getMemberCount() throws DataException;
+
+ public abstract boolean canUnjoin();
+
+ public abstract boolean canJoin();
+
+ public abstract List getConferences() throws DataException, AccessError;
+
+ public abstract ConferenceContext getConferenceContext(int confid) throws DataException, AccessError;
+
+ public abstract ConferenceContext getConferenceContext(String alias) throws DataException, AccessError;
+
+ public abstract ConferenceContext createConference(String name, String alias, String description,
+ boolean pvt, boolean hide_list)
+ throws DataException, AccessError;
+
+ public abstract boolean canCreateConference();
+
+} // end interface SIGContext
diff --git a/src/com/silverwrist/venice/core/SIGFeature.java b/src/com/silverwrist/venice/core/SIGFeature.java
new file mode 100644
index 0000000..4368358
--- /dev/null
+++ b/src/com/silverwrist/venice/core/SIGFeature.java
@@ -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 Community 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.core;
+
+public interface SIGFeature
+{
+ public abstract int getFeatureCode();
+
+ public abstract String getSymbol();
+
+ public abstract String getName();
+
+ public abstract String getApplet();
+
+ public abstract int getSequence();
+
+} // end interface SIGFeature
diff --git a/src/com/silverwrist/venice/core/SearchMode.java b/src/com/silverwrist/venice/core/SearchMode.java
new file mode 100644
index 0000000..ce7e158
--- /dev/null
+++ b/src/com/silverwrist/venice/core/SearchMode.java
@@ -0,0 +1,40 @@
+/*
+ * 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 Community 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.core;
+
+public interface SearchMode
+{
+ public static final int FIELD_SIG_NAME = 0;
+
+ public static final int FIELD_SIG_SYNOPSIS = 1;
+
+ public static final int FIELD_USER_NAME = 2;
+
+ public static final int FIELD_USER_DESCRIPTION = 3;
+
+ public static final int FIELD_USER_GIVEN_NAME = 4;
+
+ public static final int FIELD_USER_FAMILY_NAME = 5;
+
+ public static final int SEARCH_PREFIX = 0;
+
+ public static final int SEARCH_SUBSTRING = 1;
+
+ public static final int SEARCH_REGEXP = 2;
+
+} // end interface SearchMode
diff --git a/src/com/silverwrist/venice/core/Startup.java b/src/com/silverwrist/venice/core/Startup.java
new file mode 100644
index 0000000..2faa89c
--- /dev/null
+++ b/src/com/silverwrist/venice/core/Startup.java
@@ -0,0 +1,216 @@
+/*
+ * 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 Community 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.core;
+
+import java.io.*;
+import javax.xml.parsers.*;
+import org.apache.log4j.*;
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import com.silverwrist.util.DOMElementHelper;
+
+public class Startup
+{
+ /*--------------------------------------------------------------------------------
+ * Static data values
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(Startup.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ private Startup()
+ { // this class cannot be created
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Document loadConfiguration(String configname) throws ConfigException
+ {
+ try
+ { // create a simple DOM parser by using the Java XML parsing API
+ DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
+ fac.setNamespaceAware(false);
+ fac.setValidating(false);
+ DocumentBuilder parser = fac.newDocumentBuilder();
+
+ // access the config file and parse it into our config data tree
+ File configfile = new File(configname);
+ Document rc = parser.parse(configfile);
+ if (logger.isDebugEnabled())
+ logger.debug("configuration loaded successfully");
+ return rc;
+
+ } // end try
+ catch (FactoryConfigurationError e1)
+ { // if the document builder factory could not be created
+ logger.fatal("Parser factory configuration error: " + e1.getMessage(),e1);
+ throw new ConfigException("XML parser factory could not be created - " + e1.getMessage());
+
+ } // end catch
+ catch (ParserConfigurationException e2)
+ { // if the XML parser itself could not be created
+ logger.fatal("Parser configuration error: " + e2.getMessage(),e2);
+ throw new ConfigException("XML parser could not be created - " + e2.getMessage(),e2);
+
+ } // end catch
+ catch (SAXException e3)
+ { // if the XML parser choked on our document
+ if (e3 instanceof SAXParseException)
+ { // we have a detailed message - make a proper exception
+ SAXParseException e3a = (SAXParseException)e3;
+ logger.fatal("Config file error [" + configname + ":" + e3a.getLineNumber() + ","
+ + e3a.getColumnNumber() + "]: " + e3a.getMessage(),e3a);
+ throw new ConfigException("Configuration file error: " + e3a.getMessage() + " at line "
+ + e3a.getLineNumber() + ", column " + e3a.getColumnNumber(),e3a);
+
+ } // end if
+ else
+ { // generic exception - just send up a simple error message
+ logger.fatal("Config file error [" + configname + "]: " + e3.getMessage(),e3);
+ throw new ConfigException("Configuration file error - " + e3.getMessage(),e3);
+
+ } // end else
+
+ } // end catch
+ catch (IOException e4)
+ { // error reading the config file itself off the disk
+ logger.fatal("IO error reading config: " + e4.getMessage(),e4);
+ throw new ConfigException("unable to read config file \"" + configname + "\" - " + e4.getMessage(),e4);
+
+ } // end catch
+
+ } // end loadConfiguration
+
+ private static String getEngineClassName(Document config) throws ConfigException
+ {
+ // Make sure the configuration is valid...
+ Element root = config.getDocumentElement();
+ if (!(root.getTagName().equals("venice-config")))
+ { // not the correct root tag name
+ logger.fatal("config document is not a document (root tag: <"
+ + root.getTagName() + "/>)");
+ throw new ConfigException("document is not a document",root);
+
+ } // end if
+
+ // Get the section.
+ DOMElementHelper root_h = new DOMElementHelper(root);
+ Element engine_sect = root_h.getSubElement("engine");
+ if (engine_sect==null)
+ { // no section - bail out now!
+ logger.fatal("config document has no section");
+ throw new ConfigException("no section found in config file",root);
+
+ } // end if
+
+ // Get the classname out of that section.
+ DOMElementHelper engine_sect_h = new DOMElementHelper(engine_sect);
+ String rc = engine_sect_h.getSubElementText("classname");
+ if (rc==null)
+ { // no specified - bail out now!
+ logger.fatal("config document section has no ");
+ throw new ConfigException("no found in section",engine_sect);
+
+ } // end if
+
+ return rc;
+
+ } // end getEngineClassName
+
+ /*--------------------------------------------------------------------------------
+ * External static methods (global functions)
+ *--------------------------------------------------------------------------------
+ */
+
+ public static VeniceEngine createEngine(String configname) throws ConfigException, DataException
+ {
+ // load the configuration data
+ Document config = loadConfiguration(configname);
+
+ // find the classname of the engine
+ String cname = getEngineClassName(config);
+
+ if (logger.isDebugEnabled())
+ logger.debug("Venice engine classname: " + cname);
+
+ try
+ { // attempt to load the engine class
+ Class engine_class = Class.forName(cname);
+
+ // now create a new Venice engine (cast to the external interface)
+ VeniceEngine engine = (VeniceEngine)(engine_class.newInstance());
+
+ if (logger.isDebugEnabled())
+ logger.debug("VeniceEngine created successfully");
+
+ // initialize the engine
+ engine.initialize(config);
+
+ // and return it
+ return engine;
+
+ } // end try
+ catch (ClassNotFoundException e1)
+ { // the class was not found
+ logger.fatal("Venice engine class \"" + cname + "\" not found",e1);
+ throw new ConfigException("Invalid engine classname: " + cname);
+
+ } // end catch
+ catch (IllegalAccessException e2)
+ { // could not access constructor or something
+ logger.fatal("Can't access \"" + cname + "\" constructor: " + e2.getMessage(),e2);
+ throw new ConfigException("Unable to create classname: " + cname);
+
+ } // end catch
+ catch (InstantiationException e3)
+ { // could not create the instance
+ logger.fatal("Can't create instance of \"" + cname + "\": " + e3.getMessage(),e3);
+ throw new ConfigException("Unable to create classname: " + cname);
+
+ } // end catch
+ catch (ExceptionInInitializerError e4)
+ { // some exception while initializing class
+ logger.fatal("Exception while initializing \"" + cname + "\": " + e4.getMessage(),e4);
+ throw new ConfigException("Unable to create classname: " + cname);
+
+ } // end catch
+ catch (SecurityException e5)
+ { // security violation somewhere
+ logger.fatal("Security violation on \"" + cname + "\": " + e5.getMessage(),e5);
+ throw new ConfigException("Unable to create classname: " + cname);
+
+ } // end catch
+ catch (ClassCastException e6)
+ { // engine could not be cast to VeniceEngine interface type
+ logger.fatal("\"" + cname + "\" is not of type VeniceEngine",e6);
+ throw new ConfigException("Invalid engine classname: " + cname);
+
+ } // end catch
+
+ } // end createEngine
+
+} // end class Startup
diff --git a/src/com/silverwrist/venice/core/TopicContext.java b/src/com/silverwrist/venice/core/TopicContext.java
new file mode 100644
index 0000000..c3e36dd
--- /dev/null
+++ b/src/com/silverwrist/venice/core/TopicContext.java
@@ -0,0 +1,67 @@
+/*
+ * 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 Community 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.core;
+
+import java.util.Date;
+import java.util.List;
+
+public interface TopicContext
+{
+ public abstract void refresh() throws DataException;
+
+ public abstract int getTopicID();
+
+ public abstract short getTopicNumber();
+
+ public abstract String getName();
+
+ public abstract int getUnreadMessages();
+
+ public abstract int getTotalMessages();
+
+ public abstract Date getLastUpdateDate();
+
+ public abstract int getCreatorUID();
+
+ public abstract boolean isFrozen();
+
+ public abstract boolean isArchived();
+
+ public abstract Date getCreatedDate();
+
+ public abstract boolean isHidden();
+
+ public abstract boolean isDeleted();
+
+ public abstract boolean canFreeze();
+
+ public abstract boolean canArchive();
+
+ public abstract void setFrozen(boolean flag) throws DataException, AccessError;
+
+ public abstract void setArchived(boolean flag) throws DataException, AccessError;
+
+ public abstract void setHidden(boolean flag) throws DataException;
+
+ public abstract int getFirstUnreadMessage();
+
+ public abstract void setUnreadMessages(int count) throws DataException;
+
+ public abstract void fixSeen() throws DataException;
+
+} // end interface TopicContext
diff --git a/src/com/silverwrist/venice/core/UserContext.java b/src/com/silverwrist/venice/core/UserContext.java
new file mode 100644
index 0000000..6ceb50b
--- /dev/null
+++ b/src/com/silverwrist/venice/core/UserContext.java
@@ -0,0 +1,92 @@
+/*
+ * 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 Community 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.core;
+
+import java.util.List;
+
+public interface UserContext extends SearchMode
+{
+ public abstract int getUID();
+
+ public abstract String getUserName();
+
+ public abstract int getContactID();
+
+ public abstract String getDescription();
+
+ public abstract boolean isLoggedIn();
+
+ public abstract boolean isEmailVerified();
+
+ public abstract void authenticate(String username, String password)
+ throws AccessError, DataException;
+
+ public abstract void confirmEmail(int conf_num) throws AccessError, DataException;
+
+ public abstract void resendEmailConfirmation() throws DataException, EmailException;
+
+ public abstract ContactInfo getContactInfo() throws DataException;
+
+ public abstract boolean putContactInfo(ContactInfo ci) throws DataException, EmailException;
+
+ public abstract UserProfile getProfile(String xusername) throws DataException;
+
+ public abstract UserProfile getProfile(int xuid) throws DataException;
+
+ public abstract void setPassword(String password, String reminder) throws DataException;
+
+ public abstract void setDescription(String new_descr) throws DataException;
+
+ public abstract FrontPageViewConfig getFrontPageViewConfig(int max_cols) throws DataException;
+
+ public abstract void putFrontPageViewConfig(FrontPageViewConfig cfg) throws DataException;
+
+ public abstract List getMemberSIGs() throws DataException;
+
+ public abstract SIGContext getSIGContext(int sigid) throws DataException;
+
+ public abstract SIGContext getSIGContext(String alias) throws DataException;
+
+ public abstract List getRootCategoryList() throws DataException;
+
+ public abstract CategoryDescriptor getCategoryDescriptor(int catid) throws DataException;
+
+ public abstract List searchForSIGs(int field, int mode, String term, int offset, int count)
+ throws DataException;
+
+ public abstract int getSearchSIGCount(int field, int mode, String term) throws DataException;
+
+ public abstract List getSIGsInCategory(int catid, int offset, int count) throws DataException;
+
+ public abstract List getSIGsInCategory(CategoryDescriptor cat, int offset, int count) throws DataException;
+
+ public abstract int getNumSIGsInCategory(int catid) throws DataException;
+
+ public abstract int getNumSIGsInCategory(CategoryDescriptor cat) throws DataException;
+
+ public abstract List searchForCategories(int mode, String term, int offset, int count) throws DataException;
+
+ public abstract int getSearchCategoryCount(int mode, String term) throws DataException;
+
+ public abstract SIGContext createSIG(String name, String alias, String language, String synopsis,
+ String rules, String joinkey, int hide_mode)
+ throws DataException, AccessError;
+
+ public abstract boolean canCreateSIG();
+
+} // end interface UserContext
diff --git a/src/com/silverwrist/venice/core/UserFound.java b/src/com/silverwrist/venice/core/UserFound.java
new file mode 100644
index 0000000..9cfdd5e
--- /dev/null
+++ b/src/com/silverwrist/venice/core/UserFound.java
@@ -0,0 +1,40 @@
+/*
+ * 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 Community 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.core;
+
+public interface UserFound
+{
+ public abstract int getUID();
+
+ public abstract String getName();
+
+ public abstract String getDescription();
+
+ public abstract String getGivenName();
+
+ public abstract String getFamilyName();
+
+ public abstract String getLocality();
+
+ public abstract String getRegion();
+
+ public abstract String getCountry();
+
+ public abstract int getLevel();
+
+} // end interface UserFound
diff --git a/src/com/silverwrist/venice/core/UserProfile.java b/src/com/silverwrist/venice/core/UserProfile.java
new file mode 100644
index 0000000..90911b0
--- /dev/null
+++ b/src/com/silverwrist/venice/core/UserProfile.java
@@ -0,0 +1,74 @@
+/*
+ * 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 Community 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.core;
+
+import java.util.Date;
+
+public interface UserProfile
+{
+ public abstract int getUID();
+
+ public abstract String getUserName();
+
+ public abstract String getGivenName();
+
+ public abstract String getFamilyName();
+
+ public abstract char getMiddleInitial();
+
+ public abstract String getNamePrefix();
+
+ public abstract String getNameSuffix();
+
+ public abstract String getCompany();
+
+ public abstract String getAddressLine1();
+
+ public abstract String getAddressLine2();
+
+ public abstract String getLocality();
+
+ public abstract String getRegion();
+
+ public abstract String getPostalCode();
+
+ public abstract String getCountry();
+
+ public abstract String getFullCountry();
+
+ public abstract String getPhone();
+
+ public abstract String getFax();
+
+ public abstract String getMobile();
+
+ public abstract String getEmail();
+
+ public abstract String getPhotoURL();
+
+ public abstract String getURL();
+
+ public abstract Date getCreateDate();
+
+ public abstract Date getLastLoginDate();
+
+ public abstract Date getLastUpdate();
+
+ public abstract String getDescription();
+
+} // end interface UserProfile
diff --git a/src/com/silverwrist/venice/core/VeniceEngine.java b/src/com/silverwrist/venice/core/VeniceEngine.java
new file mode 100644
index 0000000..abfbb0a
--- /dev/null
+++ b/src/com/silverwrist/venice/core/VeniceEngine.java
@@ -0,0 +1,68 @@
+/*
+ * 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 Community 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.core;
+
+import java.util.BitSet;
+import java.util.List;
+import org.w3c.dom.Document;
+import com.silverwrist.venice.htmlcheck.HTMLChecker;
+
+public interface VeniceEngine extends SearchMode
+{
+ public abstract void initialize(Document config) throws ConfigException, DataException;
+
+ public abstract int getNumFeatures();
+
+ public abstract BitSet getAllFeaturesMask();
+
+ public abstract List getCountryList() throws DataException;
+
+ public abstract List getLanguageList() throws DataException;
+
+ public abstract String getNameOfCountry(String code);
+
+ public abstract UserContext createUserContext(String remote_addr) throws DataException;
+
+ public abstract String getEmailAddressForUser(String username) throws DataException, AccessError;
+
+ public abstract void sendPasswordReminder(String username)
+ throws DataException, AccessError, EmailException;
+
+ public abstract UserContext createNewAccount(String remote_addr, String username, String password,
+ String reminder) throws DataException, AccessError;
+
+ public abstract boolean aliasExists(String alias, int exist_sigid);
+
+ public abstract boolean isValidCategoryID(int catid);
+
+ public abstract List searchForUsers(int field, int mode, String term, int offset, int count)
+ throws DataException;
+
+ public abstract int getSearchUserCount(int field, int mode, String term) throws DataException;
+
+ public abstract int getStdNumSearchResults();
+
+ public abstract boolean isEmailAddressBanned(String email);
+
+ public abstract boolean confAliasExists(String alias);
+
+ public abstract HTMLChecker getPreviewChecker();
+
+ public abstract HTMLChecker getEscapingChecker();
+
+} // end interface VeniceEngine
diff --git a/src/com/silverwrist/venice/core/impl/CategoryDescriptorImpl.java b/src/com/silverwrist/venice/core/impl/CategoryDescriptorImpl.java
new file mode 100644
index 0000000..03980ba
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/CategoryDescriptorImpl.java
@@ -0,0 +1,577 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.db.*;
+import com.silverwrist.venice.core.*;
+
+class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable
+{
+ /*--------------------------------------------------------------------------------
+ * Internal class for saving category segments
+ *--------------------------------------------------------------------------------
+ */
+
+ static class CatSegment
+ {
+ private int id;
+ private String name;
+
+ CatSegment(int id, String name)
+ {
+ this.id = id;
+ this.name = name;
+
+ } // end constructor
+
+ public int getID()
+ {
+ return id;
+
+ } // end getID
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ } // end class CatSegment
+
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(CategoryDescriptorImpl.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private DataPool datapool; // used for doing database lookups
+ private Vector cats; // the actual category segments
+ private int symlink = -1; // if our category is actually a symlink
+ private boolean do_hide = true; // do we hide subcategories marked hide_dir?
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ CategoryDescriptorImpl(DataPool datapool, int catid, boolean do_hide) throws DataException
+ {
+ this.datapool = datapool;
+ cats = new Vector();
+ this.do_hide = do_hide;
+
+ if (catid<0)
+ return; // this is a "top" category
+
+ Connection conn = null;
+
+ try
+ { // get a connection and a prepared statement
+ conn = datapool.getConnection();
+ doFillFromTop(conn,catid);
+
+ } // end try
+ catch (SQLException e)
+ { // remap to DataException
+ throw new DataException("Unable to load category descriptor: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure and release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end constructor
+
+ protected CategoryDescriptorImpl(DataPool datapool, Connection conn, int catid, boolean do_hide)
+ throws SQLException, DataException
+ {
+ this.datapool = datapool;
+ cats = new Vector();
+ this.do_hide = do_hide;
+
+ if (catid<0)
+ return; // this is a "top" category
+
+ doFillFromTop(conn,catid);
+
+ } // end constructor
+
+ protected CategoryDescriptorImpl(DataPool datapool, int id, int symlink, String name, boolean do_hide)
+ {
+ this.datapool = datapool;
+ this.cats = new Vector();
+ this.symlink = symlink;
+ this.do_hide = do_hide;
+
+ this.cats.add(new CatSegment(id,name));
+ this.cats.trimToSize();
+
+ } // end constructor
+
+ protected CategoryDescriptorImpl(CategoryDescriptorImpl other, int copy_levels)
+ {
+ this.datapool = other.datapool;
+ this.cats = new Vector();
+ this.symlink = ((copy_levels==other.cats.size()) ? other.symlink : -1);
+ this.do_hide = other.do_hide;
+
+ if (copy_levels>0)
+ { // copy the references to the objects directly
+ for (int i=0; i0)
+ throw new InternalStateError("invalid symlink in category table (" + String.valueOf(curr_catid)
+ + " => " + String.valueOf(symlink_field) + ")");
+ symlink = symlink_field;
+
+ } // end if
+
+ cats.add(0,new CatSegment(curr_catid,rs.getString("name")));
+ curr_catid = rs.getInt("parent");
+
+ } // end while
+
+ cats.trimToSize(); // shrink vector down to size
+
+ } // end doFillFromTop
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface CategoryDescriptor
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getCategoryID()
+ {
+ if (cats.size()>0)
+ return ((CatSegment)(cats.lastElement())).getID();
+ else
+ return -1;
+
+ } // end getCategoryID
+
+ public int getNumLevels()
+ {
+ return cats.size();
+
+ } // end getNumLevels
+
+ public int getIDAtLevel(int level)
+ {
+ return ((CatSegment)(cats.get(level))).getID();
+
+ } // end getIDAtLevel
+
+ public String getTitleAtLevel(int level)
+ {
+ return ((CatSegment)(cats.get(level))).getName();
+
+ } // end getTitleAtLevel
+
+ public List getSubCategories() throws DataException
+ {
+ if (symlink!=-1)
+ { // "snap" the symlink before getting subcategories
+ CategoryDescriptorImpl real_obj = new CategoryDescriptorImpl(datapool,symlink,do_hide);
+ return real_obj.getSubCategories();
+
+ } // end if
+
+ Connection conn = null;
+ Vector rc = new Vector();
+ try
+ { // get a connection and create a statement
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT catid, symlink, name FROM refcategory WHERE parent = ");
+ sql.append(getCategoryID());
+ if (do_hide)
+ sql.append(" AND hide_dir = 0");
+ sql.append(';');
+
+ // run the database query
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ while (rs.next())
+ { // turn data values into CategoryDescriptor objects
+ CategoryDescriptor ncd = new CategoryDescriptorImpl(this,rs.getInt("catid"),rs.getInt("symlink"),
+ rs.getString("name"));
+ rc.add(ncd);
+
+ } // end while
+
+ } // end try
+ catch (SQLException e)
+ { // remap to DataException
+ throw new DataException("Unable to load subcategories: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure and release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ // wrap the vector in a ReadOnlyVector object
+ return new ReadOnlyVector(rc);
+
+ } // end getSubCategories
+
+ public CategoryDescriptor getSuperCategory(int levels)
+ {
+ if ((levels<0) || (levels>(cats.size()-1)))
+ throw new IndexOutOfBoundsException("invalid supercategory level value");
+ return new CategoryDescriptorImpl(this,levels);
+
+ } // end getSuperCategory
+
+ public CategoryDescriptor getParentCategory()
+ {
+ return getSuperCategory(cats.size()-1);
+
+ } // end getParentCategory
+
+ public int getLinkedCategoryID()
+ {
+ if (symlink!=-1)
+ return symlink;
+ else
+ return getCategoryID();
+
+ } // end getLinkedCategoryID
+
+ public boolean isSymbolicLink()
+ {
+ return (symlink!=-1);
+
+ } // end isSymbolicLink
+
+ public CategoryDescriptor getLinkedCategory() throws DataException
+ {
+ if (symlink!=-1)
+ return new CategoryDescriptorImpl(datapool,symlink,do_hide);
+ else
+ return this;
+
+ } // end getLinkedCategory
+
+ public boolean equals(Object obj)
+ {
+ if (obj==null)
+ return false;
+ if (obj instanceof CategoryDescriptor)
+ { // this is something we can compare to directly
+ CategoryDescriptor other = (CategoryDescriptor)obj;
+ return (other.getLinkedCategoryID()==getLinkedCategoryID());
+
+ } // end if
+
+ // compare string values
+ return obj.toString().equals(toString());
+
+ } // end equals
+
+ public int hashCode()
+ {
+ if (symlink!=-1)
+ return symlink;
+ else
+ return getCategoryID();
+
+ } // end hashCode
+
+ public String toString()
+ {
+ StringBuffer buf = new StringBuffer();
+ Iterator it = cats.iterator();
+ while (it.hasNext())
+ { // concatenate all the parts together
+ CatSegment seg = (CatSegment)(it.next());
+ if (buf.length()>0)
+ buf.append(": ");
+ buf.append(seg.getName());
+
+ } // end while
+
+ return buf.toString();
+
+ } // end toString
+
+ public Object clone()
+ {
+ return new CategoryDescriptorImpl(this,cats.size());
+
+ } // end clone
+
+ /*--------------------------------------------------------------------------------
+ * Static operations for use within implementation package
+ *--------------------------------------------------------------------------------
+ */
+
+ static List getTopLevelCategoryList(DataPool datapool, boolean do_hide) throws DataException
+ {
+ Connection conn = null;
+ Vector rc = new Vector();
+ try
+ { // get a connection and create a statement
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT catid, symlink, name FROM refcategory WHERE parent = -1");
+ if (do_hide)
+ sql.append(" AND hide_dir = 0");
+ sql.append(';');
+
+ // run the database query
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ while (rs.next())
+ { // turn data values into CategoryDescriptor objects
+ CategoryDescriptor ncd = new CategoryDescriptorImpl(datapool,rs.getInt("catid"),rs.getInt("symlink"),
+ rs.getString("name"),do_hide);
+ rc.add(ncd);
+
+ } // end while
+
+ } // end try
+ catch (SQLException e)
+ { // remap to DataException
+ throw new DataException("Unable to load subcategories: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure and release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ // wrap the vector in a ReadOnlyVector object
+ return new ReadOnlyVector(rc);
+
+ } // end getTopLevelCategoryList
+
+ static List searchForCategories(DataPool datapool, boolean do_hide, boolean search_all, int mode,
+ String term, int offset, int count) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Category search: mode = " + String.valueOf(mode) + ", term '" + term + "', offset = "
+ + String.valueOf(offset) + ", count = " + String.valueOf(count));
+
+ Vector rc = new Vector();
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT catid FROM refcategory WHERE name ");
+
+ switch (mode)
+ { // compose SQL in different ways depending on the search term
+ case SearchMode.SEARCH_PREFIX:
+ sql.append("LIKE '").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_SUBSTRING:
+ sql.append("LIKE '%").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_REGEXP:
+ sql.append("REGEXP '").append(SQLUtil.encodeString(term)).append('\'');
+ break;
+
+ default:
+ throw new DataException("invalid search mode specified");
+
+ } // end switch
+
+ if (do_hide)
+ sql.append(" AND hide_dir = 0");
+ if (!search_all)
+ sql.append(" AND hide_search = 0");
+ sql.append(" ORDER BY parent, name LIMIT ").append(offset).append(", ").append(count+1).append(';');
+
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // launch the search!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ int[] rc_raw = new int[count+1];
+ int n = 0;
+
+ while (rs.next()) // just read off the matching CATIDs for now
+ rc_raw[n++] = rs.getInt("catid");
+
+ for (int i=0; i.
+ *
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+
+public interface ConferenceBackend extends SIGBackend
+{
+ public abstract int realConfID();
+
+ public abstract boolean userCanHide();
+
+ public abstract void touchRead(Connection conn) throws SQLException;
+
+ public abstract String realConfAlias();
+
+} // end interface ConferenceBackend
diff --git a/src/com/silverwrist/venice/core/impl/ConferenceCoreData.java b/src/com/silverwrist/venice/core/impl/ConferenceCoreData.java
new file mode 100644
index 0000000..eed6603
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/ConferenceCoreData.java
@@ -0,0 +1,958 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.db.*;
+import com.silverwrist.venice.security.AuditRecord;
+import com.silverwrist.venice.security.DefaultLevels;
+import com.silverwrist.venice.core.*;
+
+class ConferenceCoreData implements ConferenceData
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(ConferenceCoreData.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private int refcount = 1; // object reference count
+ private EngineBackend engine; // pointer to engine back end
+ private DataPool datapool; // pointer to data pool
+ private int confid; // ID of this conference
+ private java.util.Date create_date; // creation date of this conference
+ private java.util.Date last_update; // last update date of conference
+ private int read_level; // access level required to read conference contents
+ private int post_level; // access level required to post messages
+ private int create_level; // access level required to create new topics
+ private int hide_level; // access level required to hide posts/archive topics
+ private int nuke_level; // access level required to delete topics/scribble/nuke posts
+ private int change_level; // access level required to modify conference profile
+ private int delete_level; // access level required to delete conference
+ private int top_topic; // the highest topic number in the conference
+ private String name; // the name of the conference
+ private String description; // the conference's description
+ private String cached_alias = null; // the cached alias (for getAnAlias)
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ ConferenceCoreData(EngineBackend engine, DataPool datapool, int confid) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("new ConferenceCoreData for conference " + String.valueOf(confid));
+ this.engine = engine;
+ this.datapool = datapool;
+ this.confid = confid;
+
+ Connection conn = null;
+
+ try
+ { // get a database connection from this object
+ conn = datapool.getConnection();
+
+ // get the conference basic data from the database
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT * FROM confs WHERE confid = ");
+ sql.append(confid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new DataException("Conference #" + String.valueOf(confid) + " does not exist in the database.");
+
+ loadData(rs); // load the conference data
+
+ } // end try
+ catch (SQLException e)
+ { // translate into a nicer DataException
+ logger.error("DB error reading conference data: " + e.getMessage(),e);
+ throw new DataException("unable to load conference data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end constructor
+
+ protected ConferenceCoreData(EngineBackend engine, DataPool datapool, int confid, java.util.Date created,
+ boolean pvt, String name, String descr)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("new ConferenceCoreData for NEW conference " + String.valueOf(confid));
+ this.engine = engine;
+ this.datapool = datapool;
+ this.confid = confid;
+ this.create_date = created;
+ this.last_update = null;
+ this.read_level = DefaultLevels.newConferenceRead(pvt);
+ this.post_level = DefaultLevels.newConferencePost(pvt);
+ this.create_level = DefaultLevels.newConferenceCreate(pvt);
+ this.hide_level = DefaultLevels.newConferenceHide();
+ this.nuke_level = DefaultLevels.newConferenceNuke();
+ this.change_level = DefaultLevels.newConferenceChange();
+ this.delete_level = DefaultLevels.newConferenceDelete();
+ this.top_topic = 0;
+ this.name = name;
+ this.description = descr;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private synchronized void loadData(ResultSet rs) throws SQLException
+ {
+ // "confid" field is skipped
+ create_date = SQLUtil.getFullDateTime(rs,"createdate");
+ last_update = SQLUtil.getFullDateTime(rs,"lastupdate");
+ read_level = rs.getInt("read_lvl");
+ post_level = rs.getInt("post_lvl");
+ create_level = rs.getInt("create_lvl");
+ hide_level = rs.getInt("hide_lvl");
+ nuke_level = rs.getInt("nuke_lvl");
+ change_level = rs.getInt("change_lvl");
+ delete_level = rs.getInt("delete_lvl");
+ top_topic = rs.getInt("top_topic");
+ name = rs.getString("name");
+ description = rs.getString("descr");
+ // "icon_url" and "color" fields are skipped
+
+ } // end loadData
+
+ private synchronized void touchUpdate(Connection conn) throws SQLException
+ {
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE confs SET lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE confid = ").append(confid).append(';');
+ stmt.executeUpdate(sql.toString());
+ last_update = now;
+
+ } // end touchUpdate
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ReferencedData
+ *--------------------------------------------------------------------------------
+ */
+
+ public int rd_addRef()
+ {
+ return ++refcount;
+
+ } // end rd_addRef()
+
+ public int rd_release()
+ {
+ return --refcount;
+
+ } // end rd_release
+
+ public boolean rd_unreferenced()
+ {
+ return (refcount<=0);
+
+ } // end rd_unreferenced
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ConferenceData
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getID()
+ {
+ return confid;
+
+ } // end getID
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String getDescription()
+ {
+ return description;
+
+ } // end getDescription
+
+ public java.util.Date getCreationDate()
+ {
+ return create_date;
+
+ } // end getCreationDate
+
+ public java.util.Date getLastUpdateDate()
+ {
+ return last_update;
+
+ } // end getLastUpdate
+
+ public List getAliases() throws DataException
+ {
+ Connection conn = null;
+ Vector rc = new Vector();
+
+ try
+ { // get a database connection from this object
+ conn = datapool.getConnection();
+
+ // get a list of all aliases
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT alias FROM confalias WHERE confid = ");
+ sql.append(confid).append(" ORDER BY alias;");
+
+ // execute the query
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ while (rs.next())
+ rc.add(rs.getString(1));
+
+ } // end try
+ catch (SQLException e)
+ { // translate into a nicer DataException
+ logger.error("DB error reading conference data: " + e.getMessage(),e);
+ throw new DataException("unable to load conference data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return new ReadOnlyVector(rc);
+
+ } // end getAlias
+
+ public List getHosts() throws DataException
+ {
+ Connection conn = null;
+ Vector rc = new Vector();
+
+ try
+ { // get a database connection from this object
+ conn = datapool.getConnection();
+
+ // get a list of all hosts (with user info)
+ Statement stmt = conn.createStatement();
+ StringBuffer sql =
+ new StringBuffer("SELECT u.uid, u.username, u.description, c.given_name, c.family_name, "
+ + "c.locality, c.region, c.country FROM users u, contacts c, confmember m "
+ + "WHERE u.contactid = c.contactid AND u.uid = m.uid AND m.confid = ");
+ sql.append(confid).append(" AND m.granted_lvl >= ").append(DefaultLevels.hostPrivsConference());
+ sql.append(" ORDER BY u.username;");
+
+ // execute the query
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ while (rs.next())
+ { // create the UserFound
+ UserFound uf = new UserFoundImpl(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),
+ rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8));
+ rc.add(uf);
+
+ } // end while
+
+ } // end try
+ catch (SQLException e)
+ { // translate into a nicer DataException
+ logger.error("DB error reading conference hosts: " + e.getMessage(),e);
+ throw new DataException("unable to load conference hosts: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return new ReadOnlyVector(rc);
+
+ } // end getHosts
+
+ public boolean canReadConference(int level)
+ {
+ return (level>=read_level);
+
+ } // end canReadConference
+
+ public boolean canPostToConference(int level)
+ {
+ return (level>=post_level);
+
+ } // end canReadConference
+
+ public boolean canCreateTopic(int level)
+ {
+ return (level>=create_level);
+
+ } // end canCreateTopic
+
+ public boolean canChangeConference(int level)
+ {
+ return (level>=change_level);
+
+ } // end canChangeConference
+
+ public int getReadLevel()
+ {
+ return read_level;
+
+ } // end getReadLevel
+
+ public int getPostLevel()
+ {
+ return post_level;
+
+ } // end getPostLevel
+
+ public int getCreateLevel()
+ {
+ return create_level;
+
+ } // end getCreateLevel
+
+ public int getHideLevel()
+ {
+ return hide_level;
+
+ } // end getHideLevel
+
+ public int getNukeLevel()
+ {
+ return nuke_level;
+
+ } // end getNukeLevel
+
+ public int getChangeLevel()
+ {
+ return change_level;
+
+ } // end getChangeLevel
+
+ public int getDeleteLevel()
+ {
+ return delete_level;
+
+ } // end getDeleteLevel
+
+ public synchronized void setSecurityLevels(SIGBackend sig, int read, int post, int create, int hide,
+ int nuke, int change, int delete) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+
+ // create the SQL statement
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE confs SET read_lvl = ");
+ sql.append(read).append(", post_lvl = ").append(post).append(", create_lvl = ").append(create);
+ sql.append(", hide_lvl = ").append(hide).append(", nuke_lvl = ").append(nuke).append(", change_lvl = ");
+ sql.append(change).append(", delete_lvl = ").append(delete).append(", lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE confid = ").append(confid).append(';');
+
+ // execute the update
+ stmt.executeUpdate(sql.toString());
+
+ // save copies of the data in our local variables
+ read_level = read;
+ post_level = post;
+ create_level = create;
+ hide_level = hide;
+ nuke_level = nuke;
+ change_level = change;
+ delete_level = delete;
+ last_update = now;
+
+ // create an audit record reflecting the change
+ ar = new AuditRecord(AuditRecord.CONF_SECURITY,sig.realUID(),sig.userRemoteAddress(),sig.realSIGID(),
+ "conf=" + String.valueOf(confid));
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing conference data: " + e.getMessage(),e);
+ throw new DataException("unable to save conference data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setSecurityLevels
+
+ public synchronized void setName(SIGBackend sig, String val) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+
+ // create the SQL statement
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE confs SET name = '");
+ sql.append(SQLUtil.encodeString(val)).append("', lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE confid = ").append(confid).append(';');
+
+ // execute the update
+ stmt.executeUpdate(sql.toString());
+
+ // save copies of the data in our local variables
+ name = val;
+ last_update = now;
+
+ // create an audit record reflecting the change
+ ar = new AuditRecord(AuditRecord.CONF_SECURITY,sig.realUID(),sig.userRemoteAddress(),sig.realSIGID(),
+ "conf=" + String.valueOf(confid));
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing conference data: " + e.getMessage(),e);
+ throw new DataException("unable to save conference data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setName
+
+ public synchronized void setDescription(String val) throws DataException
+ {
+ Connection conn = null; // database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+
+ // create the SQL statement
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE confs SET descr = '");
+ sql.append(SQLUtil.encodeString(val)).append("', lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE confid = ").append(confid).append(';');
+
+ // execute the update
+ stmt.executeUpdate(sql.toString());
+
+ // save copies of the data in our local variables
+ description = val;
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing conference data: " + e.getMessage(),e);
+ throw new DataException("unable to save conference data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setDescription
+
+ public synchronized void addAlias(SIGBackend sig, String alias) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES confalias WRITE;");
+ try
+ { // first check to see if the alias already exists
+ StringBuffer sql = new StringBuffer("SELECT confid FROM confalias WHERE alias = '");
+ String alias_encode = SQLUtil.encodeString(alias);
+ sql.append(alias_encode).append("';");
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (rs.next())
+ { // already exists...but is it in this conference or a different one?
+ if (confid==rs.getInt(1))
+ return; // this conference - this is a no-op
+ throw new DataException("The alias \"" + alias + "\" is already in use by a different conference.");
+
+ } // end if
+
+ // now add it!
+ sql.setLength(0);
+ sql.append("INSERT INTO confalias (confid, alias) VALUES (").append(confid).append(", '");
+ sql.append(alias_encode).append("');");
+ stmt.executeUpdate(sql.toString());
+
+ } // end try
+ finally
+ { // make sure we unlock the tables before we go
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ // set the database's update date and generate a new audit record
+ touchUpdate(conn);
+ ar = new AuditRecord(AuditRecord.CONF_ALIAS,sig.realUID(),sig.userRemoteAddress(),sig.realSIGID(),
+ "conf=" + String.valueOf(confid),"add=" + alias);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing conference alias: " + e.getMessage(),e);
+ throw new DataException("unable to save conference alias: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end addAlias
+
+ public synchronized void removeAlias(SIGBackend sig, String alias) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ boolean did_it = false;
+
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES confalias WRITE;");
+ try
+ { // first check to see how many aliases there are
+ StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM confalias WHERE confid = ");
+ sql.append(confid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new InternalStateError("removeAlias query screwup - must be at least ONE row!");
+ int alias_count = rs.getInt(1);
+ if (alias_count<=0)
+ throw new InternalStateError("removeAlias database failure - detected less than one alias!");
+
+ if (alias_count==1)
+ { // OK, there's only one alias - make sure it ain't the one we're trying to remove!
+ sql.setLength(0);
+ sql.append("SELECT alias FROM confalias WHERE confid = ").append(confid).append(" AND alias = '");
+ sql.append(SQLUtil.encodeString(alias)).append("';");
+ rs = stmt.executeQuery(sql.toString());
+ if (rs.next()) // it is - that would be bad, throw an error!
+ throw new DataException("The conference must have at least one alias.");
+ return; // but if it isn't, we're not going to succeed in removing it anyway
+
+ } // end if
+
+ // OK, go delete the row (or not, if this alias is not in the table)
+ sql.setLength(0);
+ sql.append("DELETE FROM confalias WHERE confid = ").append(confid).append("AND alias = '");
+ sql.append(SQLUtil.encodeString(alias)).append("';");
+ did_it = (stmt.executeUpdate(sql.toString())>0);
+
+ } // end try
+ finally
+ { // make sure we unlock the tables before we go
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ if (did_it)
+ { // set the database's update date and generate a new audit record
+ touchUpdate(conn);
+ if (cached_alias.equals(alias))
+ cached_alias = null; // also release the cached alias and force a re-get
+ ar = new AuditRecord(AuditRecord.CONF_ALIAS,sig.realUID(),sig.userRemoteAddress(),sig.realSIGID(),
+ "conf=" + String.valueOf(confid),"remove=" + alias);
+
+ } // end if
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing conference alias: " + e.getMessage(),e);
+ throw new DataException("unable to save conference alias: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end removeAlias
+
+ public synchronized void setMembership(SIGBackend sig, int uid, int grant_level) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ boolean did_it = false;
+
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES confmember WRITE;");
+ try
+ { // how we go about this depends on whether we're adding or removing
+ StringBuffer sql = new StringBuffer();
+ if (grant_level>=0)
+ { // see whether the user is in the table yet...
+ sql.append("SELECT granted_lvl FROM confmember WHERE confid = ").append(confid);
+ sql.append(" AND uid = ").append(uid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ sql.setLength(0);
+
+ if (rs.next())
+ { // just poke the new level value in
+ sql.append("UPDATE confmember SET granted_lvl = ").append(grant_level).append(" WHERE confid = ");
+ sql.append(confid).append(" AND uid = ").append(uid).append(';');
+
+ } // end if
+ else
+ { // need to insert a new row...
+ sql.append("INSERT INTO confmember (confid, uid, granted_lvl) VALUES (").append(confid);
+ sql.append(", ").append(uid).append(", ").append(grant_level).append(");");
+
+ } // end else
+
+ stmt.executeUpdate(sql.toString());
+ did_it = true;
+
+ } // end if
+ else
+ { // just try to delete this row from the table (if possible)
+ sql.append("DELETE FROM confmember WHERE confid = ").append(confid).append(" AND uid = ");
+ sql.append(uid).append(';');
+ did_it = (stmt.executeUpdate(sql.toString())>0);
+
+ } // end else
+
+ } // end try
+ finally
+ { // make sure we unlock the tables before we go
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ if (did_it)
+ { // set the database's update date and generate a new audit record
+ touchUpdate(conn);
+ ar = new AuditRecord(AuditRecord.CONF_MEMBERSHIP,sig.realUID(),sig.userRemoteAddress(),sig.realSIGID(),
+ "conf=" + String.valueOf(confid),"uid=" + String.valueOf(uid),
+ "level=" + String.valueOf(grant_level));
+
+ } // end if
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing conference data: " + e.getMessage(),e);
+ throw new DataException("unable to save conference data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setMembership
+
+ public boolean canHideTopics(int level)
+ {
+ return (level>=hide_level);
+
+ } // end canHideTopics
+
+ public synchronized String getAnAlias() throws DataException
+ {
+ if (cached_alias!=null)
+ return cached_alias;
+
+ Connection conn = null;
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // create the SQL statement and execute it
+ StringBuffer sql = new StringBuffer("SELECT alias FROM confalias WHERE confid = ");
+ sql.append(confid).append(" LIMIT 1;");
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new DataException("unable to find alias for conference");
+ cached_alias = rs.getString(1);
+ return cached_alias;
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error retrieving conference data: " + e.getMessage(),e);
+ throw new DataException("unable to get conference data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getAnAlias
+
+ /*--------------------------------------------------------------------------------
+ * External static operations (usable only from within package)
+ *--------------------------------------------------------------------------------
+ */
+
+ static ReturnConfSeq createConference(EngineBackend engine, SIGBackend sig, DataPool datapool, String name,
+ String alias, String description, boolean pvt, boolean hide_list,
+ int host_uid) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+ int new_confid; // new conference ID
+ short new_sequence; // new sequence number
+ java.util.Date created; // date/time conference created
+
+ if (logger.isDebugEnabled())
+ logger.debug("createConference entry");
+
+ try
+ { // start by locking all the tables we need
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES confs WRITE, sigtoconf WRITE, confalias WRITE, confmember WRITE;");
+
+ try
+ { // first check on the alias availability
+ StringBuffer sql = new StringBuffer("SELECT confid FROM confalias WHERE alias = '");
+ String alias_encode = SQLUtil.encodeString(alias);
+ sql.append(alias_encode).append("';");
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (rs.next()) // already used - this is bogus!
+ throw new DataException("The alias \"" + alias + "\" is already in use by a different conference.");
+
+ // compute our new sequence number
+ sql.setLength(0);
+ sql.append("SELECT MAX(sequence) FROM sigtoconf WHERE sigid = ").append(sig.realSIGID()).append(';');
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+ rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new InternalStateError("bogus query in createConference - must return at least 1 row!");
+ new_sequence = (short)(rs.getShort(1) + 100);
+
+ // insert the record into the conferences table!
+ sql.setLength(0);
+ sql.append("INSERT INTO confs (createdate, read_lvl, post_lvl, create_lvl, hide_lvl, nuke_lvl, "
+ + "change_lvl, delete_lvl, top_topic, name, descr) VALUES ('");
+ created = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(created)).append("', ").append(DefaultLevels.newConferenceRead(pvt));
+ sql.append(", ").append(DefaultLevels.newConferencePost(pvt)).append(", ");
+ sql.append(DefaultLevels.newConferenceCreate(pvt)).append(", ");
+ sql.append(DefaultLevels.newConferenceHide()).append(", ").append(DefaultLevels.newConferenceNuke());
+ sql.append(", ").append(DefaultLevels.newConferenceChange()).append(", ");
+ sql.append(DefaultLevels.newConferenceDelete()).append(", 0, '").append(SQLUtil.encodeString(name));
+ sql.append("', '").append(SQLUtil.encodeString(description)).append("');");
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+ stmt.executeUpdate(sql.toString());
+
+ // Get the new conference ID.
+ rs = stmt.executeQuery("SELECT LAST_INSERT_ID();");
+ if (!(rs.next()))
+ throw new InternalStateError("bogus query in createConference - must get new confid!");
+ new_confid = rs.getInt(1);
+
+ // Make the insert into the confalias table to give the conference an alias.
+ sql.setLength(0);
+ sql.append("INSERT INTO confalias (confid, alias) VALUES (").append(new_confid).append(", '");
+ sql.append(alias_encode).append("');");
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+ stmt.executeUpdate(sql.toString());
+
+ // Link the SIG to the conference by adding a row to sigtoconf.
+ sql.setLength(0);
+ sql.append("INSERT INTO sigtoconf (sigid, confid, sequence, hide_list) VALUES (");
+ sql.append(sig.realSIGID()).append(", ").append(new_confid).append(", ").append(new_sequence);
+ sql.append(", ").append(hide_list ? '1' : '0').append(");");
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+ stmt.executeUpdate(sql.toString());
+
+ // Make the specified UID the host of this new conference.
+ sql.setLength(0);
+ sql.append("INSERT INTO confmember (confid, uid, granted_lvl) VALUES (").append(new_confid);
+ sql.append(", ").append(host_uid).append(", ").append(DefaultLevels.hostConference()).append(");");
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+ stmt.executeUpdate(sql.toString());
+
+ } // end try
+ finally
+ { // unlock the tables before we go
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ // create an audit record indicating we were successful
+ ar = new AuditRecord(AuditRecord.CREATE_CONF,sig.realUID(),sig.userRemoteAddress(),sig.realSIGID(),
+ "confid=" + String.valueOf(new_confid),"name=" + name,"alias=" + alias);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error creating SIG: " + e.getMessage(),e);
+ throw new DataException("unable to create SIG: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ // Create a new ConferenceCoreData object representing this conference and register it with the
+ // engine's conference data object cache.
+ ConferenceCoreData conf = new ConferenceCoreData(engine,datapool,new_confid,created,pvt,name,description);
+ engine.registerNewConference(conf);
+ return new ReturnConfSeq(conf,new_sequence);
+
+ } // end createConference
+
+} // end class ConferenceCoreData
diff --git a/src/com/silverwrist/venice/core/impl/ConferenceData.java b/src/com/silverwrist/venice/core/impl/ConferenceData.java
new file mode 100644
index 0000000..17f3173
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/ConferenceData.java
@@ -0,0 +1,79 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.util.Date;
+import java.util.List;
+import com.silverwrist.venice.core.DataException;
+
+public interface ConferenceData extends ReferencedData
+{
+ public abstract int getID();
+
+ public abstract String getName();
+
+ public abstract String getDescription();
+
+ public abstract Date getCreationDate();
+
+ public abstract Date getLastUpdateDate();
+
+ public abstract List getAliases() throws DataException;
+
+ public abstract List getHosts() throws DataException;
+
+ public abstract boolean canReadConference(int level);
+
+ public abstract boolean canPostToConference(int level);
+
+ public abstract boolean canCreateTopic(int level);
+
+ public abstract boolean canChangeConference(int level);
+
+ public abstract int getReadLevel();
+
+ public abstract int getPostLevel();
+
+ public abstract int getCreateLevel();
+
+ public abstract int getHideLevel();
+
+ public abstract int getNukeLevel();
+
+ public abstract int getChangeLevel();
+
+ public abstract int getDeleteLevel();
+
+ public abstract void setSecurityLevels(SIGBackend sig, int read, int post, int create, int hide,
+ int nuke, int change, int delete) throws DataException;
+
+ public abstract void setName(SIGBackend sig, String val) throws DataException;
+
+ public abstract void setDescription(String val) throws DataException;
+
+ public abstract void addAlias(SIGBackend sig, String alias) throws DataException;
+
+ public abstract void removeAlias(SIGBackend sig, String alias) throws DataException;
+
+ public abstract void setMembership(SIGBackend sig, int uid, int grant_level) throws DataException;
+
+ public abstract boolean canHideTopics(int level);
+
+ public abstract String getAnAlias() throws DataException;
+
+} // end interface ConferenceData
diff --git a/src/com/silverwrist/venice/core/impl/ConferenceSIGContext.java b/src/com/silverwrist/venice/core/impl/ConferenceSIGContext.java
new file mode 100644
index 0000000..e389d0b
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/ConferenceSIGContext.java
@@ -0,0 +1,91 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.util.Date;
+import java.util.List;
+import com.silverwrist.venice.core.DataException;
+
+public interface ConferenceSIGContext extends ReferencedData
+{
+ public abstract int getConfID();
+
+ public abstract String getName();
+
+ public abstract String getDescription();
+
+ public abstract Date getCreationDate();
+
+ public abstract Date getLastUpdateDate();
+
+ public abstract int getSIGGrantedLevel();
+
+ public abstract List getAliases() throws DataException;
+
+ public abstract List getHosts() throws DataException;
+
+ public abstract boolean canReadConference(int level);
+
+ public abstract boolean canPostToConference(int level);
+
+ public abstract boolean canCreateTopic(int level);
+
+ public abstract boolean canChangeConference(int level);
+
+ public abstract int getReadLevel() throws DataException;
+
+ public abstract int getPostLevel() throws DataException;
+
+ public abstract int getCreateLevel() throws DataException;
+
+ public abstract int getHideLevel() throws DataException;
+
+ public abstract int getNukeLevel() throws DataException;
+
+ public abstract int getChangeLevel() throws DataException;
+
+ public abstract int getDeleteLevel() throws DataException;
+
+ public abstract void setSecurityLevels(SIGBackend sig, int read, int post, int create, int hide,
+ int nuke, int change, int delete) throws DataException;
+
+ public abstract void setName(SIGBackend sig, String val) throws DataException;
+
+ public abstract void setDescription(String val) throws DataException;
+
+ public abstract void addAlias(SIGBackend sig, String alias) throws DataException;
+
+ public abstract void removeAlias(SIGBackend sig, String alias) throws DataException;
+
+ public abstract void setMembership(SIGBackend sig, int uid, int grant_level) throws DataException;
+
+ public abstract void setSIGGrantedLevel(SIGBackend sig, int new_level) throws DataException;
+
+ public abstract short getSequence();
+
+ public abstract void setSequence(short seq) throws DataException;
+
+ public abstract boolean getHideList();
+
+ public abstract void setHideList(SIGBackend sig, boolean flag) throws DataException;
+
+ public abstract boolean canHideTopics(int level);
+
+ public abstract String getAnAlias() throws DataException;
+
+} // end interface ConferenceSIGContext
diff --git a/src/com/silverwrist/venice/core/impl/ConferenceSIGContextImpl.java b/src/com/silverwrist/venice/core/impl/ConferenceSIGContextImpl.java
new file mode 100644
index 0000000..635f973
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/ConferenceSIGContextImpl.java
@@ -0,0 +1,614 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.db.*;
+import com.silverwrist.venice.security.AuditRecord;
+import com.silverwrist.venice.core.*;
+
+class ConferenceSIGContextImpl implements ConferenceSIGContext
+{
+ /*--------------------------------------------------------------------------------
+ * Inner class used to cache locally-important data
+ *--------------------------------------------------------------------------------
+ */
+
+ static class ConfCache
+ {
+ String name;
+ String description;
+ java.util.Date created;
+
+ public ConfCache(String name, String description, java.util.Date created)
+ {
+ this.name = name;
+ this.description = description;
+ this.created = created;
+
+ } // end constructor
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String getDescription()
+ {
+ return description;
+
+ } // end getDescription
+
+ public java.util.Date getCreated()
+ {
+ return created;
+
+ } // end getCreated
+
+ } // end class ConfCache
+
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(ConferenceSIGContextImpl.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private int refcount = 1; // reference count (within the SIGData)
+ private EngineBackend engine; // engine object reference
+ private SIGDataBackend sig; // SIG object reference
+ private DataPool datapool; // data pool object
+ private int confid; // ID of this conference
+ private int level; // level granted in conference to members of the SIG
+ private short sequence; // sequence number this conference appears in list
+ private boolean hide_list; // hide the conference in the list?
+ private ConfCache cache; // cache of locally-important information
+ private ConferenceData confdata = null; // the inner conference data object
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ ConferenceSIGContextImpl(EngineBackend engine, SIGDataBackend sig, DataPool datapool, int confid)
+ throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("new ConferenceSIGContextImpl(#" + String.valueOf(confid) + ") for SIG # "
+ + String.valueOf(sig.realSIGID()));
+
+ this.engine = engine;
+ this.sig = sig;
+ this.datapool = datapool;
+ this.confid = confid;
+
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // Build a monster query! This is like the query for retrieving the ConferenceUserContextImpl
+ // data, except without the left outer join to the user conference membership table.
+ StringBuffer sql =
+ new StringBuffer("SELECT c.createdate, c.name, c.descr, s.granted_lvl, s.sequence, s.hide_list "
+ + "FROM sigtoconf s, confs c WHERE s.confid = c.confid AND s.sigid = ");
+ sql.append(sig.realSIGID()).append(" AND c.confid = ").append(confid).append(';');
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // Run that monster query!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new DataException("conference ID#" + String.valueOf(confid) + " not found in SIG#"
+ + String.valueOf(sig.realSIGID()));
+
+ // fill in the "cache" and "level" indicators
+ this.cache = new ConfCache(rs.getString(2),rs.getString(3),SQLUtil.getFullDateTime(rs,1));
+ this.level = rs.getInt(4);
+ this.sequence = rs.getShort(5);
+ this.hide_list = rs.getBoolean(6);
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading conference entry: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve conference information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end constructor
+
+ ConferenceSIGContextImpl(EngineBackend engine, SIGDataBackend sig, DataPool datapool,
+ short sequence, boolean hide_list, ConferenceData cdata)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("new ConferenceSIGContextImpl(NEW#" + String.valueOf(confid) + ") for SIG # "
+ + String.valueOf(sig.realSIGID()));
+
+ this.engine = engine;
+ this.sig = sig;
+ this.datapool = datapool;
+ this.confid = cdata.getID();
+ this.level = 0;
+ this.sequence = sequence;
+ this.hide_list = hide_list;
+ this.cache = null;
+ cdata.rd_addRef();
+ this.confdata = cdata;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private synchronized ConferenceData getConferenceData() throws DataException
+ {
+ if (confdata==null)
+ { // attempt to load the ConferenceSIGContext
+ confdata = engine.getConferenceDataObject(confid);
+
+ // clear cache when we get the real confdata
+ cache = null;
+
+ } // end if
+
+ return confdata;
+
+ } // end getConferenceData
+
+ private synchronized ConferenceData getConferenceDataNE()
+ {
+ if (confdata==null)
+ { // we need to load the ConferenceSIGContext...
+ try
+ { // attempt to load the ConferenceSIGContext
+ confdata = engine.getConferenceDataObject(confid);
+
+ } // end try
+ catch (DataException e)
+ { // there was a data failure loading the conference
+ logger.error("** Got DataException in getConferenceDataNE: " + e.getMessage(),e);
+ return null;
+
+ } // end catch
+
+ // clear cache when we get the real confdata
+ cache = null;
+
+ } // end if
+
+ return confdata;
+
+ } // end getConferenceDataNE
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ReferencedData
+ *--------------------------------------------------------------------------------
+ */
+
+ public int rd_addRef()
+ {
+ return ++refcount;
+
+ } // end rd_addRef
+
+ public int rd_release()
+ {
+ return --refcount;
+
+ } // end rd_release
+
+ public boolean rd_unreferenced()
+ {
+ return (refcount<=0);
+
+ } // end rd_unreferences
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ConferenceSIGContext
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getConfID()
+ {
+ return confid;
+
+ } // end getConfID
+
+ public String getName()
+ {
+ if (cache!=null)
+ return cache.getName();
+ ConferenceData c = getConferenceDataNE();
+ if (c!=null)
+ return c.getName();
+ else
+ return null;
+
+ } // end getName
+
+ public String getDescription()
+ {
+ if (cache!=null)
+ return cache.getDescription();
+ ConferenceData c = getConferenceDataNE();
+ if (c!=null)
+ return c.getDescription();
+ else
+ return null;
+
+ } // end getDescription
+
+ public java.util.Date getCreationDate()
+ {
+ if (cache!=null)
+ return cache.getCreated();
+ ConferenceData c = getConferenceDataNE();
+ if (c!=null)
+ return c.getCreationDate();
+ else
+ return null;
+
+ } // end getCreationDate
+
+ public java.util.Date getLastUpdateDate()
+ {
+ ConferenceData c = getConferenceDataNE();
+ if (c!=null)
+ return c.getLastUpdateDate();
+ else
+ return null;
+
+ } // end getLastUpdateDate
+
+ public int getSIGGrantedLevel()
+ {
+ return level;
+
+ } // end getSIGGrantedLevel
+
+ public List getAliases() throws DataException
+ {
+ return getConferenceData().getAliases();
+
+ } // end getAliases
+
+ public List getHosts() throws DataException
+ {
+ return getConferenceData().getHosts();
+
+ } // end getHosts
+
+ public boolean canReadConference(int level)
+ {
+ ConferenceData c = getConferenceDataNE();
+ if (c==null)
+ return false;
+ if (level.
+ *
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.db.*;
+import com.silverwrist.venice.security.DefaultLevels;
+import com.silverwrist.venice.core.*;
+
+class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
+{
+ /*--------------------------------------------------------------------------------
+ * Inner class used to cache locally-important data
+ *--------------------------------------------------------------------------------
+ */
+
+ class ConfCache
+ {
+ String name;
+ String description;
+ java.util.Date created;
+ int grants_level;
+
+ public ConfCache(String name, String description, java.util.Date created, int grants_level)
+ {
+ this.name = name;
+ this.description = description;
+ this.created = created;
+ this.grants_level = grants_level;
+
+ } // end constructor
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String getDescription()
+ {
+ return description;
+
+ } // end getDescription
+
+ public java.util.Date getCreated()
+ {
+ return created;
+
+ } // end getCreated
+
+ public int getGrantsLevel()
+ {
+ return grants_level;
+
+ } // end getGrantsLevel
+
+ } // end class ConfCache
+
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(ConferenceUserContextImpl.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private EngineBackend engine; // pointer to the engine back end
+ private SIGBackend sig; // pointer to the SIG back end
+ private DataPool datapool; // pointer to the data pool
+ private int confid; // the conference ID
+ private int level; // access level I have within this conference
+ private ConfCache cache; // cached internal data for the conference
+ private ConferenceSIGContext confdata = null; // the internal subobject
+ private boolean settings_loaded = false; // did we load the settings from the database?
+ private String pseud; // default pseud to use in this conference
+ private java.util.Date last_read; // last date we read this conference
+ private java.util.Date last_post; // last date we posted to this conference
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ protected ConferenceUserContextImpl(EngineBackend engine, SIGBackend sig, DataPool datapool, int confid,
+ String name, String description, java.util.Date created, int sig_level,
+ int user_level, Connection conn) throws DataException
+ {
+ this.engine = engine;
+ this.sig = sig;
+ this.datapool = datapool;
+ this.confid = confid;
+ this.cache = new ConfCache(name,description,created,sig_level);
+ recalcLevel(user_level);
+ tryLoadSettings(conn);
+
+ } // end constructor
+
+ ConferenceUserContextImpl(EngineBackend engine, SIGBackend sig, DataPool datapool,
+ ConferenceSIGContext cdata) throws DataException
+ {
+ this.engine = engine;
+ this.sig = sig;
+ this.datapool = datapool;
+ this.confid = cdata.getConfID();
+ this.cache = null;
+ cdata.rd_addRef();
+ this.confdata = cdata;
+ recalcLevel(DefaultLevels.hostConference());
+ this.pseud = sig.userDefaultPseud();
+ this.last_read = null;
+ this.last_post = null;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * finalize() function
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void finalize()
+ {
+ if (confdata!=null)
+ confdata.rd_release();
+ engine = null;
+ sig = null;
+ datapool = null;
+ cache = null;
+ confdata = null;
+
+ } // end finalize
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private ConferenceSIGContext getConferenceData() throws DataException
+ {
+ if (confdata==null)
+ { // attempt to load the ConferenceSIGContext
+ confdata = sig.getConferenceDataObject(confid);
+
+ // clear cache when we get the real confdata
+ cache = null;
+
+ } // end if
+
+ return confdata;
+
+ } // end getConferenceData
+
+ private ConferenceSIGContext getConferenceDataNE()
+ {
+ if (confdata==null)
+ { // we need to load the ConferenceSIGContext...
+ try
+ { // attempt to load the ConferenceSIGContext
+ confdata = sig.getConferenceDataObject(confid);
+
+ } // end try
+ catch (DataException e)
+ { // there was a data failure loading the conference
+ logger.error("** Got DataException in getConferenceDataNE: " + e.getMessage(),e);
+ return null;
+
+ } // end catch
+
+ // clear cache when we get the real confdata
+ cache = null;
+
+ } // end if
+
+ return confdata;
+
+ } // end getConferenceDataNE
+
+ private void recalcLevel(int new_level)
+ {
+ level = sig.realSIGLevel();
+
+ int sig_level = -1;
+ if (cache!=null)
+ sig_level = cache.getGrantsLevel();
+ else
+ { // look at the ConferenceSIGContext to get the SIG level
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c!=null)
+ sig_level = c.getSIGGrantedLevel();
+
+ } // end else
+
+ if (sig_level>level)
+ level = sig_level;
+ if (new_level>level)
+ level = new_level;
+
+ } // end recalcLevel
+
+ private void tryLoadSettings(Connection conn) throws DataException
+ {
+ try
+ { // look up the conference settings for this user
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT * FROM confsettings WHERE confid = ");
+ sql.append(confid).append(" AND uid = ").append(sig.realUID()).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ if (rs.next())
+ { // load in the settings
+ settings_loaded = true;
+ pseud = rs.getString("default_pseud");
+ last_read = SQLUtil.getFullDateTime(rs,"last_read");
+ last_post = SQLUtil.getFullDateTime(rs,"last_post");
+
+ } // end if
+ else
+ { // just default everything
+ settings_loaded = false;
+ pseud = sig.userDefaultPseud();
+ last_read = null;
+ last_post = null;
+
+ } // end else
+
+ } // end try
+ catch (SQLException e)
+ { // handle a SQL error as usual
+ logger.error("Error loading conference settings: " + e.getMessage(),e);
+ throw new DataException("Unable to load conference settings: " + e.getMessage(),e);
+
+ } // end catch
+
+ } // end tryLoadSettings
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ConferenceContext
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getConfID()
+ {
+ return confid;
+
+ } // end getConfID
+
+ public String getName()
+ {
+ if (cache!=null)
+ return cache.getName();
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c!=null)
+ return c.getName();
+ else
+ return null;
+
+ } // end getName
+
+ public String getDescription()
+ {
+ if (cache!=null)
+ return cache.getDescription();
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c!=null)
+ return c.getDescription();
+ else
+ return null;
+
+ } // end getDescription
+
+ public java.util.Date getCreationDate()
+ {
+ if (cache!=null)
+ return cache.getCreated();
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c!=null)
+ return c.getCreationDate();
+ else
+ return null;
+
+ } // end getCreationDate
+
+ public java.util.Date getLastUpdateDate()
+ {
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c!=null)
+ return c.getLastUpdateDate();
+ else
+ return null;
+
+ } // end getLastUpdateDate
+
+ public List getAliases() throws DataException
+ {
+ return getConferenceData().getAliases();
+
+ } // end getAliases
+
+ public List getHosts() throws DataException
+ {
+ return getConferenceData().getHosts();
+
+ } // end getHosts
+
+ public boolean canReadConference()
+ {
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c==null)
+ return false;
+ return c.canReadConference(level);
+
+ } // end canReadConference
+
+ public boolean canPostToConference()
+ {
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c==null)
+ return false;
+ return c.canPostToConference(level);
+
+ } // end canPostToConference
+
+ public boolean canCreateTopic()
+ {
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c==null)
+ return false;
+ return c.canCreateTopic(level);
+
+ } // end canCreateTopic
+
+ public boolean canChangeConference()
+ {
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c==null)
+ return false;
+ return c.canChangeConference(level);
+
+ } // end canChangeConference
+
+ public int getReadLevel() throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getReadLevel();
+
+ } // end getReadLevel
+
+ public int getPostLevel() throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getPostLevel();
+
+ } // end getPostLevel
+
+ public int getCreateLevel() throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getCreateLevel();
+
+ } // end getCreateLevel
+
+ public int getHideLevel() throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getHideLevel();
+
+ } // end getHideLevel
+
+ public int getNukeLevel() throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getNukeLevel();
+
+ } // end getNukeLevel
+
+ public int getChangeLevel() throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getChangeLevel();
+
+ } // end getChangeLevel
+
+ public int getDeleteLevel() throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getDeleteLevel();
+
+ } // end getDeleteLevel
+
+ public void setSecurityLevels(int read, int post, int create, int hide, int nuke, int change, int delete)
+ throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to change security info");
+ throw new AccessError("You are not permitted to change security information for this conference.");
+
+ } // end if
+
+ // "Correct" the security levels specified.
+ if (post>create)
+ { // Post level should be no greater than Create
+ if (logger.isDebugEnabled())
+ logger.debug("Post level (" + String.valueOf(post) + ") was greater than create level ("
+ + String.valueOf(create) + "), correcting");
+ post = create;
+
+ } // end if
+
+ if (read>post)
+ { // Read level should be no greater than Post
+ if (logger.isDebugEnabled())
+ logger.debug("Read level (" + String.valueOf(read) + ") was greater than post level ("
+ + String.valueOf(post) + "), correcting");
+ read = post;
+
+ } // end if
+
+ if (change>delete)
+ { // Change level should be no greater than Delete
+ if (logger.isDebugEnabled())
+ logger.debug("Change level (" + String.valueOf(change) + ") was greater than delete level ("
+ + String.valueOf(delete) + "), correcting");
+ change = delete;
+
+ } // end if
+
+ if (nuke>delete)
+ { // Nuke level should be no greater than Delete
+ if (logger.isDebugEnabled())
+ logger.debug("Nuke level (" + String.valueOf(nuke) + ") was greater than delete level ("
+ + String.valueOf(delete) + "), correcting");
+ nuke = delete;
+
+ } // end if
+
+ if (hide>nuke)
+ { // Hide level should be no greater than Nuke
+ if (logger.isDebugEnabled())
+ logger.debug("Hide level (" + String.valueOf(hide) + ") was greater than nuke level ("
+ + String.valueOf(nuke) + "), correcting");
+ hide = nuke;
+
+ } // end if
+
+ // Now call through to set the security levels.
+ getConferenceData().setSecurityLevels(sig,read,post,create,hide,nuke,change,delete);
+
+ } // end setSecurityLevels
+
+ public void setName(String val) throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to change name");
+ throw new AccessError("You are not permitted to change the name of this conference.");
+
+ } // end if
+
+ // Call through to set the name.
+ getConferenceData().setName(sig,val);
+
+ } // end setName
+
+ public void setDescription(String val) throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to change description");
+ throw new AccessError("You are not permitted to change the description of this conference.");
+
+ } // end if
+
+ // Call through to set the name.
+ getConferenceData().setDescription(val);
+
+ } // end setDescription
+
+ public void addAlias(String alias) throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to change aliases");
+ throw new AccessError("You are not permitted to change the aliases of this conference.");
+
+ } // end if
+
+ // Call through to add the alias.
+ getConferenceData().addAlias(sig,alias);
+
+ } // end addAlias
+
+ public void removeAlias(String alias) throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to change aliases");
+ throw new AccessError("You are not permitted to change the aliases of this conference.");
+
+ } // end if
+
+ // Call through to remove the alias.
+ getConferenceData().removeAlias(sig,alias);
+
+ } // end removeAlias
+
+ public void addMember(int uid, boolean as_host) throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to change membership");
+ throw new AccessError("You are not permitted to change the membership of this conference.");
+
+ } // end if
+
+ // figure out which level to grant the user
+ int grant_level;
+ if (as_host)
+ grant_level = DefaultLevels.hostConference();
+ else
+ grant_level = DefaultLevels.memberConference();
+
+ // call down to set the level
+ getConferenceData().setMembership(sig,uid,grant_level);
+
+ // If we adjusted our OWN level, reflect that change.
+ if (uid==sig.realUID())
+ recalcLevel(grant_level);
+
+ } // end addMember
+
+ public void removeMember(int uid) throws DataException, AccessError
+ {
+ if (!(getConferenceData().canChangeConference(level)))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to change membership");
+ throw new AccessError("You are not permitted to change the membership of this conference.");
+
+ } // end if
+
+ // call down to set the level
+ getConferenceData().setMembership(sig,uid,-1);
+
+ // If we adjusted our OWN level, reflect that change.
+ if (uid==sig.realUID())
+ recalcLevel(-1);
+
+ } // end removeMember
+
+ public int getSIGGrantedLevel() throws DataException, AccessError
+ {
+ if (!(sig.userCanCreateSubobjects()))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getSIGGrantedLevel();
+
+ } // end getSIGGrantedLevel
+
+ public void setSIGGrantedLevel(int new_level) throws DataException, AccessError
+ {
+ if (!(sig.userCanCreateSubobjects()))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to change security info");
+ throw new AccessError("You are not permitted to change security information for this conference.");
+
+ } // end if
+
+ getConferenceData().setSIGGrantedLevel(sig,new_level);
+
+ } // end setSIGGrantedLevel
+
+ public short getSequence() throws DataException, AccessError
+ {
+ if (!(sig.userCanCreateSubobjects()))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve layout info");
+ throw new AccessError("You are not permitted to retrieve layout information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getSequence();
+
+ } // end getSequence
+
+ public void setSequence(short seq) throws DataException, AccessError
+ {
+ if (!(sig.userCanCreateSubobjects()))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to set layout info");
+ throw new AccessError("You are not permitted to set layout information for this conference.");
+
+ } // end if
+
+ getConferenceData().setSequence(seq);
+
+ } // end setSequence
+
+ public boolean getHideList() throws DataException, AccessError
+ {
+ if (!(sig.userCanCreateSubobjects()))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this conference.");
+
+ } // end if
+
+ return getConferenceData().getHideList();
+
+ } // end getHideList
+
+ public void setHideList(boolean flag) throws DataException, AccessError
+ {
+ if (!(sig.userCanCreateSubobjects()))
+ { // this user can't modify the conference security
+ logger.error("user not permitted to change security info");
+ throw new AccessError("You are not permitted to change security information for this conference.");
+
+ } // end if
+
+ getConferenceData().setHideList(sig,flag);
+
+ } // end setHideList
+
+ public String getDefaultPseud()
+ {
+ return pseud;
+
+ } // end getDefaultPseud
+
+ public void setDefaultPseud(String val) throws DataException
+ {
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer();
+
+ if (settings_loaded)
+ { // generate an update statement
+ sql.append("UPDATE confsettings SET default_pseud = '").append(SQLUtil.encodeString(val));
+ sql.append("' WHERE confid = ").append(confid).append(" AND uid = ").append(sig.realUID()).append(';');
+
+ } // end if
+ else
+ { // need to insert a confsettings row
+ sql.append("INSERT INTO confsettings (confid, uid, default_pseud) VALUES (").append(confid);
+ sql.append(", ").append(sig.realUID()).append(", '").append(SQLUtil.encodeString(val)).append("';");
+
+ } // end else
+
+ // execute the statement
+ stmt.executeUpdate(sql.toString());
+
+ // save off the values to our local fields
+ pseud = val;
+ settings_loaded = true;
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error setting default pseud: " + e.getMessage(),e);
+ throw new DataException("unable to set default pseud: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setDefaultPseud
+
+ public boolean anyUnread()
+ {
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+
+ // Build a query. The idea here is that we want to see the topic IDs of all topics within the
+ // conference which (a) are not hidden and (b) have one or more messages unread by this user.
+ // The need for the user's settings for both (a) and (b) necessitates the use of the LEFT JOIN
+ // to topicsettings, which in turn necessitates the IFNULL guards on references to topicsettings
+ // columns in the WHERE clause (as there's only a topicsettings row if the user has read anything
+ // in this topic or otherwise set it).
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT t.topicid FROM topics t LEFT JOIN topicsettings s "
+ + "ON t.topicid = s.topicid AND s.uid = ");
+ sql.append(sig.realUID()).append(" WHERE t.confid = ").append(confid);
+ sql.append(" AND IFNULL(s.hidden,0) = 0 AND (t.top_message - IFNULL(s.last_message,-1)) > 0 LIMIT 1;");
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // run the query
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ return rs.next(); // will return 0 or 1 rows
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error getting unread flag: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return false; // default return
+
+ } // end anyUnread
+
+ public List getTopicList(int get_option, int sort_option) throws DataException, AccessError
+ {
+ if (!(getConferenceData().canReadConference(level)))
+ { // the luser can't even read the conference...
+ logger.error("user not permitted to change membership");
+ throw new AccessError("You are not permitted to read this conference.");
+
+ } // end if
+
+ // palm it all off on the big static function
+ return TopicUserContextImpl.getTopicList(engine,this,datapool,get_option,sort_option);
+
+ } // end getTopicList
+
+ public TopicContext getTopic(short number) throws DataException, AccessError
+ {
+ if (!(getConferenceData().canReadConference(level)))
+ { // the luser can't even read the conference...
+ logger.error("user not permitted to change membership");
+ throw new AccessError("You are not permitted to read this conference.");
+
+ } // end if
+
+ // call down to the TopicUserContextImpl implementation
+ return TopicUserContextImpl.getTopicByNumber(engine,this,datapool,number);
+
+ } // end getTopic
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface UserBackend
+ *--------------------------------------------------------------------------------
+ */
+
+ public int realUID()
+ {
+ return sig.realUID();
+
+ } // end realUID
+
+ public int realBaseLevel()
+ {
+ return sig.realBaseLevel();
+
+ } // end realBaseLevel
+
+ public String userRemoteAddress()
+ {
+ return sig.userRemoteAddress();
+
+ } // end userRemoteAddress
+
+ public String userDefaultPseud() throws DataException
+ {
+ return sig.userDefaultPseud();
+
+ } // end userDefaultPseud
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface SIGBackend
+ *--------------------------------------------------------------------------------
+ */
+
+ public int realSIGID()
+ {
+ return sig.realSIGID();
+
+ } // end realSIGID
+
+ public boolean userHideHiddenConferences()
+ {
+ return sig.userHideHiddenConferences();
+
+ } // end userHideHiddenConferences
+
+ public int realSIGLevel()
+ {
+ return sig.realSIGLevel();
+
+ } // end realSIGLevel
+
+ public ConferenceSIGContext getConferenceDataObject(int confid) throws DataException
+ {
+ return sig.getConferenceDataObject(confid);
+
+ } // end getConferenceDataObject
+
+ public boolean userCanCreateSubobjects()
+ {
+ return sig.userCanCreateSubobjects();
+
+ } // end userCanCreateSubobjects
+
+ public String realSIGAlias()
+ {
+ return sig.realSIGAlias();
+
+ } // end realSIGAlias
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ConferenceBackend
+ *--------------------------------------------------------------------------------
+ */
+
+ public int realConfID()
+ {
+ return confid;
+
+ } // end realConfID
+
+ public boolean userCanHide()
+ {
+ ConferenceSIGContext c = getConferenceDataNE();
+ if (c==null)
+ return false;
+ return c.canHideTopics(level);
+
+ } // end userCanHide
+
+ public void touchRead(Connection conn) throws SQLException
+ {
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer();
+
+ java.util.Date now = new java.util.Date();
+ if (settings_loaded)
+ { // generate an update statement
+ sql.append("UPDATE confsettings SET last_read = '").append(SQLUtil.encodeDate(now));
+ sql.append("' WHERE confid = ").append(confid).append(" AND uid = ").append(sig.realUID()).append(';');
+
+ } // end if
+ else
+ { // need to insert a confsettings row
+ sql.append("INSERT INTO confsettings (confid, uid, default_pseud, last_read) VALUES (").append(confid);
+ sql.append(", ").append(sig.realUID()).append(", '").append(SQLUtil.encodeString(pseud)).append("', '");
+ sql.append(SQLUtil.encodeDate(now)).append("');");
+
+ } // end else
+
+ // execute the statement
+ stmt.executeUpdate(sql.toString());
+
+ // save off the values to our local fields
+ last_read = now;
+ settings_loaded = true;
+
+ } // end touchRead
+
+ public String realConfAlias()
+ {
+ try
+ { // just pull it from the lower-level object
+ return getConferenceData().getAnAlias();
+
+ } // end try
+ catch (DataException de)
+ { // whoops - this wasn't supposed to happen!
+ logger.error("DataException in realConfAlias(): " + de.getMessage(),de);
+ return null;
+
+ } // end catch
+
+ } // end realConfAlias
+
+ /*--------------------------------------------------------------------------------
+ * Static functions usable only from within the package
+ *--------------------------------------------------------------------------------
+ */
+
+ static List getSIGConferences(EngineBackend engine, SIGBackend sig, DataPool datapool) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getSIGConferences for SIG # " + String.valueOf(sig.realSIGID()) + ", user #"
+ + String.valueOf(sig.realUID()));
+ Vector rc = new Vector(); // return from this function
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // Build a monster query! The idea is that we get the basic info of all conferences linked to the
+ // SIG, as well as the user level (within the conference) that gets granted to all members of the
+ // linked SIG. (Commonly this is 0; the standard user level within the SIG will then take precedence.)
+ // If the user has an entry within the confmember table for that conference, the level granted by
+ // that entry is also reported. The highest of these two levels and the level of the user within the
+ // SIG is then taken to be the user's access level within the conference.
+ StringBuffer sql =
+ new StringBuffer("SELECT c.confid, c.createdate, c.name, c.descr, s.granted_lvl, m.granted_lvl "
+ + "FROM sigtoconf s, confs c LEFT JOIN confmember m ON c.confid = m.confid "
+ + "AND m.uid = ");
+ sql.append(sig.realUID()).append(" WHERE s.confid = c.confid AND s.sigid = ").append(sig.realSIGID());
+ if (sig.userHideHiddenConferences())
+ sql.append(" AND s.hide_list = 0");
+ sql.append(" ORDER BY s.sequence, c.name;");
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // Run that monster query!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ while (rs.next())
+ { // create the appropriate objects to return
+ ConferenceContext cc = new ConferenceUserContextImpl(engine,sig,datapool,rs.getInt(1),rs.getString(3),
+ rs.getString(4),SQLUtil.getFullDateTime(rs,2),
+ rs.getInt(5),rs.getInt(6),conn);
+ rc.add(cc);
+
+ } // end while
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading conference entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve conference information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return new ReadOnlyVector(rc);
+
+ } // end getSIGConferences
+
+ static ConferenceContext getConference(EngineBackend engine, SIGBackend sig, DataPool datapool,
+ int confid) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getConference(#" + String.valueOf(confid) + ") for SIG # "
+ + String.valueOf(sig.realSIGID()) + ", user #" + String.valueOf(sig.realUID()));
+
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // Build a monster query! This is like the query in getSIGConferences, except that we add the
+ // conference ID as a search term (thus we can return at most one row).
+ StringBuffer sql =
+ new StringBuffer("SELECT c.createdate, c.name, c.descr, s.granted_lvl, m.granted_lvl "
+ + "FROM sigtoconf s, confs c LEFT JOIN confmember m ON c.confid = m.confid "
+ + "AND m.uid = ");
+ sql.append(sig.realUID()).append(" WHERE s.confid = c.confid AND s.sigid = ");
+ sql.append(sig.realSIGID()).append(" AND c.confid = ").append(confid).append(';');
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // Run that monster query!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new DataException("conference ID#" + String.valueOf(confid) + " not found in SIG#"
+ + String.valueOf(sig.realSIGID()));
+
+ // pass back the new object
+ return new ConferenceUserContextImpl(engine,sig,datapool,confid,rs.getString(2),
+ rs.getString(3),SQLUtil.getFullDateTime(rs,1),
+ rs.getInt(4),rs.getInt(5),conn);
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading conference entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve conference information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getConference
+
+ static ConferenceContext getConference(EngineBackend engine, SIGBackend sig, DataPool datapool,
+ String alias) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getConference(\"" + alias + "\") for SIG # " + String.valueOf(sig.realSIGID())
+ + ", user #" + String.valueOf(sig.realUID()));
+
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // Build a monster query! This is similar to the other getConference query, except that now we
+ // have an extra table in the query (confalias) and we match on that. Notice that pretty much
+ // everything is joined on the conference ID...
+ StringBuffer sql =
+ new StringBuffer("SELECT c.confid, c.createdate, c.name, c.descr, s.granted_lvl, m.granted_lvl "
+ + "FROM sigtoconf s, confalias a, confs c LEFT JOIN confmember m ON "
+ + "c.confid = m.confid AND m.uid = ");
+ sql.append(sig.realUID()).append(" WHERE s.confid = c.confid AND a.confid = c.confid AND s.sigid = ");
+ sql.append(sig.realSIGID()).append(" AND a.alias = '").append(SQLUtil.encodeString(alias));
+ sql.append("';");
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // Run that monster query!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new DataException("conference \"" + alias + "\" not found in SIG#"
+ + String.valueOf(sig.realSIGID()));
+
+ // pass back the new object
+ return new ConferenceUserContextImpl(engine,sig,datapool,rs.getInt(1),rs.getString(3),rs.getString(4),
+ SQLUtil.getFullDateTime(rs,2),rs.getInt(5),rs.getInt(6),conn);
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading conference entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve conference information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getConference
+
+} // end class ConferenceUserContextImpl
diff --git a/src/com/silverwrist/venice/core/impl/ContactInfoImpl.java b/src/com/silverwrist/venice/core/impl/ContactInfoImpl.java
new file mode 100644
index 0000000..a1c4a03
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/ContactInfoImpl.java
@@ -0,0 +1,694 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.db.*;
+
+class ContactInfoImpl implements ContactInfo, Stashable
+{
+ // Attributes
+ private int contactid; // ID of this contact record (-1 = new)
+ private String given_name; // given name ("first name")
+ private String family_name; // family name ("last name")
+ private char middle_initial; // middle initial (natch)
+ private String prefix; // prefix (Mr., Ms., Prof., Dr., etc.)
+ private String suffix; // suffix (Jr., III, etc.)
+ private String company; // company name
+ private String addr1; // address line 1
+ private String addr2; // address line 2
+ private String locality; // locality ("city")
+ private String region; // region ("state")
+ private String postal_code; // postal code ("ZIP code")
+ private String country; // 2-character ISO 3166 country code
+ private String phone; // voice phone number
+ private String fax; // facsimile (fax) number
+ private String mobile; // mobile phone (cellphone) number
+ private String email; // email address
+ private String photo_url; // URL of user photo
+ private String url; // URL of user's homepage
+ private boolean private_addr; // are addr1 and addr2 hidden?
+ private boolean private_phone; // are phone and mobile hidden?
+ private boolean private_fax; // is fax hidden?
+ private boolean private_email; // is email hidden?
+ private int owner_uid; // UID that owns this contact record
+ private int owner_sigid; // SIGID this contact record is in (-1 for none)
+ private java.util.Date last_update; // date of last update
+ private boolean is_modified = false; // have we modified this ContactInfo?
+
+ /**
+ * Constructs a new blank ContactInfoImpl object.
+ *
+ * @param owner_uid UID that owns this object.
+ */
+ ContactInfoImpl(int owner_uid)
+ {
+ makeEmpty(owner_uid,-1);
+
+ } // end constructor
+
+ /**
+ * Constructs a new blank ContactInfoImpl object.
+ *
+ * @param owner_uid UID that owns this object.
+ * @param owner_sigid SIGID that owns this object.
+ */
+ ContactInfoImpl(int owner_uid, int owner_sigid)
+ {
+ makeEmpty(owner_uid,owner_sigid);
+
+ } // end constructor
+
+ /**
+ * Loads a ContactInfoImpl object out of the database.
+ *
+ * @param dp Database connection pool to get a Venice database connection from.
+ * @param contactid ID of the contact to load.
+ * @exception DataException The contact could not be loaded for some reason.
+ */
+ ContactInfoImpl(DataPool dp, int contactid) throws DataException
+ {
+ Connection conn = null;
+
+ try
+ { // get a connection and call loadData
+ conn = dp.getConnection();
+ loadData(conn,contactid);
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLExceptions at this level into DataExceptions
+ throw new DataException("Unable to look up contact info: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ dp.releaseConnection(conn);
+
+ } // end finally
+
+ } // end constructor
+
+ private void makeEmpty(int owner_uid, int owner_sigid)
+ {
+ this.contactid = -1;
+ this.given_name = null;
+ this.family_name = null;
+ this.middle_initial = ' ';
+ this.prefix = null;
+ this.suffix = null;
+ this.company = null;
+ this.addr1 = null;
+ this.addr2 = null;
+ this.locality = null;
+ this.region = null;
+ this.postal_code = null;
+ this.country = null;
+ this.phone = null;
+ this.fax = null;
+ this.mobile = null;
+ this.email = null;
+ this.photo_url = null;
+ this.url = null;
+ this.private_addr = false;
+ this.private_phone = false;
+ this.private_fax = false;
+ this.private_email = false;
+ this.owner_uid = owner_uid;
+ this.owner_sigid = owner_sigid;
+ this.last_update = null;
+
+ } // end makeEmpty
+
+ private void loadData(Connection conn, int contactid) throws DataException
+ {
+ try
+ { // do a simple SELECT in contacts to look this up
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT * FROM contacts WHERE contactid = ");
+ sql.append(contactid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (rs.next())
+ { // do a mad orgy of saving off field values
+ this.contactid = rs.getInt("contactid");
+ given_name = rs.getString("given_name");
+ family_name = rs.getString("family_name");
+ String blort = rs.getString("middle_init");
+ if ((blort!=null) && (blort.length()>0))
+ middle_initial = blort.charAt(0);
+ else
+ middle_initial = ' ';
+ prefix = rs.getString("prefix");
+ suffix = rs.getString("suffix");
+ company = rs.getString("company");
+ addr1 = rs.getString("addr1");
+ addr2 = rs.getString("addr2");
+ locality = rs.getString("locality");
+ region = rs.getString("region");
+ postal_code = rs.getString("pcode");
+ country = rs.getString("country");
+ phone = rs.getString("phone");
+ fax = rs.getString("fax");
+ mobile = rs.getString("mobile");
+ email = rs.getString("email");
+ private_addr = rs.getBoolean("pvt_addr");
+ private_phone = rs.getBoolean("pvt_phone");
+ private_fax = rs.getBoolean("pvt_fax");
+ private_email = rs.getBoolean("pvt_email");
+ owner_uid = rs.getInt("owner_uid");
+ owner_sigid = rs.getInt("owner_sigid");
+ photo_url = rs.getString("photo_url");
+ url = rs.getString("url");
+ last_update = SQLUtil.getFullDateTime(rs,"lastupdate");
+
+ } // end if
+ else // contact was not found
+ throw new DataException("Contact was not found.");
+
+ } // end try
+ catch (SQLException e)
+ { // map all SQLExceptions into DataExceptions
+ throw new DataException("Unable to look up contact info: " + e.getMessage(),e);
+
+ } // end catch
+
+ } // end loadData
+
+ public int getContactID()
+ {
+ return contactid;
+
+ } // end getContactID
+
+ public String getGivenName()
+ {
+ return given_name;
+
+ } // end getGivenName
+
+ public void setGivenName(String name)
+ {
+ if ((name!=null) && (name.length()>64))
+ given_name = name.substring(0,64);
+ else
+ given_name = name;
+ is_modified = true;
+
+ } // end setGivenName
+
+ public String getFamilyName()
+ {
+ return family_name;
+
+ } // end getFamilyName
+
+ public void setFamilyName(String name)
+ {
+ if ((name!=null) && (name.length()>64))
+ family_name = name.substring(0,64);
+ else
+ family_name = name;
+ is_modified = true;
+
+ } // end setFamilyName
+
+ public char getMiddleInitial()
+ {
+ return middle_initial;
+
+ } // end getMiddleInitial
+
+ public void setMiddleInitial(char in)
+ {
+ middle_initial = in;
+ is_modified = true;
+
+ } // end setMiddleInitial
+
+ public String getNamePrefix()
+ {
+ return prefix;
+
+ } // end getNamePrefix
+
+ public void setNamePrefix(String p)
+ {
+ if ((p!=null) && (p.length()>8))
+ prefix = p.substring(0,8);
+ else
+ prefix = p;
+ is_modified = true;
+
+ } // end setNamePrefix
+
+ public String getNameSuffix()
+ {
+ return suffix;
+
+ } // end getNameSuffix
+
+ public void setNameSuffix(String s)
+ {
+ if ((s!=null) && (s.length()>16))
+ suffix = s.substring(0,16);
+ else
+ suffix = s;
+ is_modified = true;
+
+ } // end setNameSuffix
+
+ public String getCompany()
+ {
+ return company;
+
+ } // end getCompany
+
+ public void setCompany(String c)
+ {
+ if ((c!=null) && (c.length()>255))
+ company = c.substring(0,255);
+ else
+ company = c;
+ is_modified = true;
+
+ } // end setCompany
+
+ public String getAddressLine1()
+ {
+ return addr1;
+
+ } // end getAddressLine1
+
+ public void setAddressLine1(String addr)
+ {
+ if ((addr!=null) && (addr.length()>255))
+ addr1 = addr.substring(0,255);
+ else
+ addr1 = addr;
+ is_modified = true;
+
+ } // end setAddressLine1
+
+ public String getAddressLine2()
+ {
+ return addr2;
+
+ } // end getAddressLine2
+
+ public void setAddressLine2(String addr)
+ {
+ if ((addr!=null) && (addr.length()>255))
+ addr2 = addr.substring(0,255);
+ else
+ addr2 = addr;
+ is_modified = true;
+
+ } // end setAddressLine2
+
+ public String getLocality()
+ {
+ return locality;
+
+ } // end getLocality
+
+ public void setLocality(String city)
+ {
+ if ((city!=null) && (city.length()>64))
+ locality = city.substring(0,64);
+ else
+ locality = city;
+ is_modified = true;
+
+ } // end setLocality
+
+ public String getRegion()
+ {
+ return region;
+
+ } // end getRegion
+
+ public void setRegion(String state)
+ {
+ if ((state!=null) && (state.length()>64))
+ region = state.substring(0,64);
+ else
+ region = state;
+ is_modified = true;
+
+ } // end setRegion
+
+ public String getPostalCode()
+ {
+ return postal_code;
+
+ } // end getPostalCode
+
+ public void setPostalCode(String zip)
+ {
+ if ((zip!=null) && (zip.length()>16))
+ postal_code = zip.substring(0,16);
+ else
+ postal_code = zip;
+ is_modified = true;
+
+ } // end setPostalCode
+
+ public String getCountry()
+ {
+ return country;
+
+ } // end getCountry
+
+ public void setCountry(String c)
+ {
+ if ((c!=null) && (c.length()>2))
+ country = c.substring(0,2);
+ else
+ country = c;
+ is_modified = true;
+
+ } // end setCountry
+
+ public String getPhone()
+ {
+ return phone;
+
+ } // end getPhone
+
+ public void setPhone(String num)
+ {
+ if ((num!=null) && (num.length()>32))
+ phone = num.substring(0,32);
+ else
+ phone = num;
+ is_modified = true;
+
+ } // end setPhone
+
+ public String getFax()
+ {
+ return fax;
+
+ } // end getFax
+
+ public void setFax(String num)
+ {
+ if ((num!=null) && (num.length()>32))
+ fax = num.substring(0,32);
+ else
+ fax = num;
+ is_modified = true;
+
+ } // end setFax
+
+ public String getMobile()
+ {
+ return mobile;
+
+ } // end getMobile
+
+ public void setMobile(String num)
+ {
+ if ((num!=null) && (num.length()>32))
+ mobile = num.substring(0,32);
+ else
+ mobile = num;
+ is_modified = true;
+
+ } // end setMobile
+
+ public String getEmail()
+ {
+ return email;
+
+ } // end getEmail
+
+ public void setEmail(String addr)
+ {
+ if ((addr!=null) && (addr.length()>255))
+ email = addr.substring(0,255);
+ else
+ email = addr;
+ is_modified = true;
+
+ } // end setEmail
+
+ public String getPhotoURL()
+ {
+ return photo_url;
+
+ } // end getPhotoURL
+
+ public void setPhotoURL(String addr)
+ {
+ if ((addr!=null) && (addr.length()>255))
+ photo_url = addr.substring(0,255);
+ else
+ photo_url = addr;
+ is_modified = true;
+
+ } // end setPhotoURL
+
+ public String getURL()
+ {
+ return url;
+
+ } // end getURL
+
+ public void setURL(String addr)
+ {
+ if ((addr!=null) && (addr.length()>255))
+ url = addr.substring(0,255);
+ else
+ url = addr;
+ is_modified = true;
+
+ } // end setURL
+
+ public boolean getPrivateAddress()
+ {
+ return private_addr;
+
+ } // end getPrivateAddress
+
+ public void setPrivateAddress(boolean flag)
+ {
+ private_addr = flag;
+ is_modified = true;
+
+ } // end setPrivateAddress
+
+ public boolean getPrivatePhone()
+ {
+ return private_phone;
+
+ } // end getPrivatePhone
+
+ public void setPrivatePhone(boolean flag)
+ {
+ private_phone = flag;
+ is_modified = true;
+
+ } // end setPrivatePhone
+
+ public boolean getPrivateFax()
+ {
+ return private_fax;
+
+ } // end getPrivateFax
+
+ public void setPrivateFax(boolean flag)
+ {
+ private_fax = flag;
+ is_modified = true;
+
+ } // end setPrivateFax
+
+ public boolean getPrivateEmail()
+ {
+ return private_email;
+
+ } // end getPrivateEmail
+
+ public void setPrivateEmail(boolean flag)
+ {
+ private_email = flag;
+ is_modified = true;
+
+ } // end setPrivateEmail
+
+ public int getOwnerUID()
+ {
+ return owner_uid;
+
+ } // end getOwnerUID
+
+ public int getOwnerSIGID()
+ {
+ return owner_sigid;
+
+ } // end getOwnerSIGID
+
+ public java.util.Date getLastUpdate()
+ {
+ return last_update;
+
+ } // end getLastUpdate
+
+ public boolean getModified()
+ {
+ return is_modified;
+
+ } // end getModified
+
+ public int getStashableUID()
+ {
+ return getOwnerUID();
+
+ } // end getStashableUID
+
+ public void stash(Connection conn) throws DataException, SQLException
+ {
+ java.util.Date update = null;
+ Statement stmt = conn.createStatement();
+ StringBuffer buf;
+
+ if (contactid>=0)
+ { // this involves updating an existing record
+ buf = new StringBuffer("UPDATE contacts SET given_name = ");
+ buf.append(SQLUtil.encodeStringArg(given_name)).append(", family_name = ");
+ buf.append(SQLUtil.encodeStringArg(family_name)).append(", middle_init = ");
+ if (middle_initial==' ')
+ buf.append("NULL");
+ else
+ buf.append('\'').append(middle_initial).append('\'');
+ buf.append(", prefix = ").append(SQLUtil.encodeStringArg(prefix));
+ buf.append(", suffix = ").append(SQLUtil.encodeStringArg(suffix));
+ buf.append(", company = ").append(SQLUtil.encodeStringArg(company));
+ buf.append(", addr1 = ").append(SQLUtil.encodeStringArg(addr1));
+ buf.append(", addr2 = ").append(SQLUtil.encodeStringArg(addr2));
+ buf.append(", locality = ").append(SQLUtil.encodeStringArg(locality));
+ buf.append(", region = ").append(SQLUtil.encodeStringArg(region));
+ buf.append(", pcode = ").append(SQLUtil.encodeStringArg(postal_code));
+ buf.append(", country = ").append(SQLUtil.encodeStringArg(country));
+ buf.append(", phone = ").append(SQLUtil.encodeStringArg(phone));
+ buf.append(", fax = ").append(SQLUtil.encodeStringArg(fax));
+ buf.append(", mobile = ").append(SQLUtil.encodeStringArg(mobile));
+ buf.append(", email = ").append(SQLUtil.encodeStringArg(email));
+ buf.append(", pvt_addr = ").append(private_addr ? '1' : '0');
+ buf.append(", pvt_phone = ").append(private_phone ? '1' : '0');
+ buf.append(", pvt_fax = ").append(private_fax ? '1' : '0');
+ buf.append(", pvt_email = ").append(private_email ? '1' : '0');
+ buf.append(", photo_url = ").append(SQLUtil.encodeStringArg(photo_url));
+ buf.append(", url = ").append(SQLUtil.encodeStringArg(url)).append(", lastupdate = '");
+ update = new java.util.Date();
+ buf.append(SQLUtil.encodeDate(update)).append("' WHERE contactid = ").append(contactid).append(';');
+
+ stmt.executeUpdate(buf.toString());
+
+ } // end if
+ else
+ { // this involves creating a new record
+ if (owner_sigid>=0)
+ stmt.executeUpdate("LOCK TABLES contacts WRITE, sigs WRITE;");
+ else
+ stmt.executeUpdate("LOCK TABLES contacts WRITE, users WRITE;");
+
+ try
+ { // insert contact record data
+ buf = new StringBuffer("INSERT INTO contacts (given_name, family_name, middle_init, prefix, "
+ + "suffix, company, addr1, addr2, locality, region, pcode, country, "
+ + "phone, fax, mobile, email, pvt_addr, pvt_phone, pvt_fax, pvt_email, "
+ + "owner_uid, owner_sigid, photo_url, url, lastupdate) VALUES (");
+ buf.append(SQLUtil.encodeStringArg(given_name)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(family_name)).append(", ");
+ if (middle_initial==' ')
+ buf.append("NULL, ");
+ else
+ buf.append('\'').append(middle_initial).append("', ");
+ buf.append(SQLUtil.encodeStringArg(prefix)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(suffix)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(company)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(addr1)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(addr2)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(locality)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(region)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(postal_code)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(country)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(phone)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(fax)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(mobile)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(email)).append(", ");
+ buf.append(private_addr ? '1' : '0').append(", ");
+ buf.append(private_phone ? '1' : '0').append(", ");
+ buf.append(private_fax ? '1' : '0').append(", ");
+ buf.append(private_email ? '1' : '0').append(", ");
+ buf.append(owner_uid).append(", ").append(owner_sigid).append(", ");
+ buf.append(SQLUtil.encodeStringArg(photo_url)).append(", ");
+ buf.append(SQLUtil.encodeStringArg(url)).append(", '");
+ update = new java.util.Date();
+ buf.append(SQLUtil.encodeDate(update)).append("');");
+
+ stmt.executeUpdate(buf.toString());
+
+ // now read back the contact ID we just added
+ int new_contactid;
+ ResultSet rs = stmt.executeQuery("SELECT LAST_INSERT_ID() AS blort;");
+ if (rs.next())
+ new_contactid = rs.getInt("blort");
+ else
+ throw new DataException("unable to read back new contact ID");
+
+ // and patch the database table so we know what our contact ID is
+ buf.setLength(0);
+ if (owner_sigid>=0)
+ { // update the SIGS table
+ buf.append("UPDATE sigs SET contactid = ").append(new_contactid).append(" WHERE sigid = ");
+ buf.append(owner_sigid).append(';');
+
+ } // end if
+ else
+ { // update the USERS table
+ buf.append("UPDATE users SET contactid = ").append(new_contactid).append(" WHERE uid = ");
+ buf.append(owner_uid).append(';');
+
+ } // end else
+
+ stmt.executeUpdate(buf.toString());
+
+ contactid = new_contactid; // save link
+
+ } // end try
+ finally
+ { // make sure the tables get unlocked
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ } // end else
+
+ last_update = update; // save last update date
+ is_modified = false;
+
+ } // end stash
+
+} // end class ContactInfoImpl
diff --git a/src/com/silverwrist/venice/core/impl/EngineBackend.java b/src/com/silverwrist/venice/core/impl/EngineBackend.java
new file mode 100644
index 0000000..2c70aeb
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/EngineBackend.java
@@ -0,0 +1,69 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.util.BitSet;
+import java.util.List;
+import com.silverwrist.venice.security.AuditRecord;
+import com.silverwrist.venice.htmlcheck.HTMLChecker;
+import com.silverwrist.venice.core.DataException;
+
+public interface EngineBackend
+{
+ public static final int HTMLC_POST_BODY = 0;
+ public static final int HTMLC_POST_PSEUD = 1;
+ public static final int HTMLC_PREVIEW_BODY = 2;
+ public static final int HTMLC_ESCAPE_BODY_PSEUD = 3;
+
+ public abstract SimpleEmailer createEmailer();
+
+ public abstract String getStockMessage(String key);
+
+ public abstract int getNewConfirmationNumber();
+
+ public abstract String getCountryNameForCode(String code);
+
+ public abstract String getLanguageNameForCode(String code);
+
+ public abstract SIGData getSIGDataObject(int sigid) throws DataException;
+
+ public abstract BitSet getLockedFeaturesMask();
+
+ public abstract List getSIGFeatureSet(BitSet enabled_features, int level, boolean read_privs);
+
+ public abstract String getAppletForFeature(int code);
+
+ public abstract boolean isValidInitialFeatureIndex(short ndx);
+
+ public abstract BitSet getDefaultFeaturesMask();
+
+ public abstract void registerNewSIG(SIGData sig);
+
+ public abstract int getFeatureIndexBySymbol(String symbol);
+
+ public abstract boolean canAccessFeature(String symbol, int level, boolean has_read);
+
+ public abstract ConferenceData getConferenceDataObject(int confid) throws DataException;
+
+ public abstract void saveAuditRecord(AuditRecord ar);
+
+ public abstract void registerNewConference(ConferenceData conf);
+
+ public abstract HTMLChecker createCheckerObject(int type);
+
+} // end interface EngineBackend
diff --git a/src/com/silverwrist/venice/core/impl/FrontPageViewConfigImpl.java b/src/com/silverwrist/venice/core/impl/FrontPageViewConfigImpl.java
new file mode 100644
index 0000000..aaff16c
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/FrontPageViewConfigImpl.java
@@ -0,0 +1,273 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.db.*;
+
+class FrontPageViewConfigImpl implements FrontPageViewConfig, Stashable
+{
+ private int my_uid;
+ private int num_cols;
+ private Vector v_parts = new Vector();
+ private Vector v_params = new Vector();
+ private boolean is_modified = false;
+
+ FrontPageViewConfigImpl(Connection conn, int uid, int max_cols) throws DataException, SQLException
+ {
+ my_uid = uid;
+ num_cols = max_cols;
+ StringBuffer sql = new StringBuffer("SELECT row, col, partid, param FROM topconfig WHERE uid = ");
+ sql.append(uid).append(';');
+
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ while (rs.next())
+ { // make sure the column is in range first
+ int col = rs.getInt("col");
+ if ((col>=0) && (col=0)
+ { // now look for the right arrays to store into
+ String[] a_part = null;
+ String[] a_param = null;
+
+ if (row>=v_parts.size())
+ { // need to extend the vector contents
+ while (row>=v_parts.size())
+ { // append new arrays onto the config
+ a_part = new String[num_cols];
+ a_param = new String[num_cols];
+ for (int i=0; i=v_parts.size()))
+ throw new IndexOutOfBoundsException("invalid row specified to FrontPageViewConfig.getPartID");
+ if ((column<0) || (column>=num_cols))
+ throw new IndexOutOfBoundsException("invalid column specified to FrontPageViewConfig.getPartID");
+
+ String[] array = (String[])(v_parts.elementAt(row));
+ return array[column];
+
+ } // end getPartID
+
+ public void setPartID(int row, int column, String partid)
+ {
+ if (row<0)
+ throw new IndexOutOfBoundsException("invalid row specified to FrontPageViewConfig.setPartID");
+ if ((column<0) || (column>=num_cols))
+ throw new IndexOutOfBoundsException("invalid column specified to FrontPageViewConfig.setPartID");
+
+ String[] a_part = null;
+ String[] a_param = null;
+
+ if (row>=v_parts.size())
+ { // need to extend the vector contents
+ while (row>=v_parts.size())
+ { // append new arrays onto the config
+ a_part = new String[num_cols];
+ a_param = new String[num_cols];
+ for (int i=0; i=v_params.size()))
+ throw new IndexOutOfBoundsException("invalid row specified to FrontPageViewConfig.getParameter");
+ if ((column<0) || (column>=num_cols))
+ throw new IndexOutOfBoundsException("invalid column specified to FrontPageViewConfig.getParameter");
+
+ String[] array = (String[])(v_params.elementAt(row));
+ return array[column];
+
+ } // end getParameter
+
+ public void setParameter(int row, int column, String param)
+ {
+ if (row<0)
+ throw new IndexOutOfBoundsException("invalid row specified to FrontPageViewConfig.setParameter");
+ if ((column<0) || (column>=num_cols))
+ throw new IndexOutOfBoundsException("invalid column specified to FrontPageViewConfig.setParameter");
+
+ String[] a_part = null;
+ String[] a_param = null;
+
+ if (row>=v_parts.size())
+ { // need to extend the vector contents
+ while (row>=v_parts.size())
+ { // append new arrays onto the config
+ a_part = new String[num_cols];
+ a_param = new String[num_cols];
+ for (int i=0; i0)
+ { // we've got the insert command
+ buf.append(';');
+ insert_cmd = buf.toString();
+ buf.setLength(0);
+
+ } // end if
+
+ // now create the DELETE command
+ buf.append("DELETE FROM topconfig WHERE uid = ").append(my_uid).append(';');
+
+ // we need to lock the topconfig table while we do this
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES topconfig WRITE;");
+
+ try
+ { // delete all existing records
+ stmt.executeUpdate(buf.toString());
+
+ // now insert the new records
+ if (insert_cmd!=null)
+ stmt.executeUpdate(insert_cmd);
+
+ } // end try
+ finally
+ { // make sure to unlock the tables when we're done
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ } // end stash
+
+} // end class FrontPageViewConfigImpl
diff --git a/src/com/silverwrist/venice/core/impl/ReadOnlyVector.java b/src/com/silverwrist/venice/core/impl/ReadOnlyVector.java
new file mode 100644
index 0000000..a43efa4
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/ReadOnlyVector.java
@@ -0,0 +1,73 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.util.*;
+
+class ReadOnlyVector extends AbstractList
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private Vector my_vec; // local vector
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ ReadOnlyVector(Vector vec)
+ {
+ my_vec = vec;
+ my_vec.trimToSize();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * finalize() method
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void finalize() throws Throwable
+ {
+ my_vec = null;
+ super.finalize();
+
+ } // end finalize
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from superclass AbstractList
+ *--------------------------------------------------------------------------------
+ */
+
+ public Object get(int index)
+ {
+ return my_vec.elementAt(index);
+
+ } // end get
+
+ public int size()
+ {
+ return my_vec.size();
+
+ } // end size
+
+} // end class ReadOnlyVector
+
diff --git a/src/com/silverwrist/venice/core/impl/ReferencedData.java b/src/com/silverwrist/venice/core/impl/ReferencedData.java
new file mode 100644
index 0000000..8f021c3
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/ReferencedData.java
@@ -0,0 +1,28 @@
+/*
+ * 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 Community 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.core.impl;
+
+public interface ReferencedData
+{
+ public abstract int rd_addRef();
+
+ public abstract int rd_release();
+
+ public abstract boolean rd_unreferenced();
+
+} // end interface ReferencedData
diff --git a/src/com/silverwrist/venice/core/impl/ReturnConfSeq.java b/src/com/silverwrist/venice/core/impl/ReturnConfSeq.java
new file mode 100644
index 0000000..ec755df
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/ReturnConfSeq.java
@@ -0,0 +1,59 @@
+/*
+ * 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 Community 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.core.impl;
+
+class ReturnConfSeq
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private ConferenceData conf;
+ private short sequence;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ ReturnConfSeq(ConferenceData conf, short sequence)
+ {
+ this.conf = conf;
+ this.sequence = sequence;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations (usable only inside package)
+ *--------------------------------------------------------------------------------
+ */
+
+ ConferenceData getConference()
+ {
+ return conf;
+
+ } // end getConference
+
+ short getSequence()
+ {
+ return sequence;
+
+ } // end getSequence
+
+} // end class ReturnConfSeq
diff --git a/src/com/silverwrist/venice/core/impl/SIGBackend.java b/src/com/silverwrist/venice/core/impl/SIGBackend.java
new file mode 100644
index 0000000..bf0f5a3
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/SIGBackend.java
@@ -0,0 +1,36 @@
+/*
+ * 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 Community 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.core.impl;
+
+import com.silverwrist.venice.core.DataException;
+
+public interface SIGBackend extends UserBackend
+{
+ public abstract int realSIGID();
+
+ public abstract boolean userHideHiddenConferences();
+
+ public abstract int realSIGLevel();
+
+ public abstract ConferenceSIGContext getConferenceDataObject(int confid) throws DataException;
+
+ public abstract boolean userCanCreateSubobjects();
+
+ public abstract String realSIGAlias();
+
+} // end interface SIGBackend
diff --git a/src/com/silverwrist/venice/core/impl/SIGCoreData.java b/src/com/silverwrist/venice/core/impl/SIGCoreData.java
new file mode 100644
index 0000000..17bd064
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/SIGCoreData.java
@@ -0,0 +1,1534 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import org.apache.log4j.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.db.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.security.AuditRecord;
+import com.silverwrist.venice.security.Capability;
+import com.silverwrist.venice.security.DefaultLevels;
+
+class SIGCoreData implements SIGData, SIGDataBackend
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(SIGCoreData.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private int refcount = 1; // object reference count
+ private EngineBackend engine; // pointer to engine back end
+ private DataPool datapool; // pointer to data pool
+ private int sigid; // ID of this SIG
+ private java.util.Date created; // date/time of database creation
+ private java.util.Date last_access; // date/time of last access
+ private java.util.Date last_update; // date/time of last update
+ private int read_level; // access level required to read contained data
+ private int write_level; // access level required to write summary data
+ private int create_level; // access level required to create subobjects
+ private int delete_level; // access level required to delete SIG
+ private int join_level; // access level required to become a SIG member
+ private int contactid; // this community's contact ID (geographic info)
+ private int host_uid; // UID of the community host
+ private int category_id; // category ID for this community
+ private boolean hidden_directory; // hidden from directory listings?
+ private boolean hidden_search; // hidden from keyword searches?
+ private boolean members_only; // only members allowed in this SIG?
+ private boolean is_admin; // is this the administrative SIG?
+ private short initial_feature; // the "initial" feature to display for this SIG
+ private String name; // the name of this SIG
+ private String language; // the default language code
+ private String synopsis; // the synopsis of the community
+ private String rules; // the community "rules"
+ private String alias; // the community alias value
+ private boolean public_sig; // is this a public SIG?
+ private BitSet features; // set of available features
+ private Hashtable conf_objects = new Hashtable(); // holder for ConferenceSIGContextImpl objects
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ SIGCoreData(EngineBackend engine, DataPool datapool, int sigid) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("new SIGCoreData for SIG " + String.valueOf(sigid));
+ this.engine = engine;
+ this.datapool = datapool;
+ this.sigid = sigid;
+
+ Connection conn = null;
+
+ try
+ { // get a database connection from this object
+ conn = datapool.getConnection();
+
+ // get the SIG basic data from the database
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT * FROM sigs WHERE sigid = ");
+ sql.append(sigid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new DataException("SIG #" + String.valueOf(sigid) + " does not exist in the database.");
+
+ loadData(rs); // load the SIG data
+
+ // get the SIG feature set
+ sql.setLength(0);
+ sql.append("SELECT ftr_code FROM sigftrs WHERE sigid = ").append(sigid).append(';');
+ rs = stmt.executeQuery(sql.toString());
+ features = new BitSet();
+ while (rs.next())
+ features.set(rs.getInt("ftr_code"));
+
+ } // end try
+ catch (SQLException e)
+ { // translate into a nicer DataException
+ logger.error("DB error reading SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to load SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end constructor
+
+ protected SIGCoreData(EngineBackend engine, DataPool datapool, int sigid, java.util.Date creation,
+ String name, String alias, int host_uid, String language, String synopsis,
+ String rules, String joinkey, boolean hide_dir, boolean hide_search,
+ BitSet features)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("new SIGCoreData for BRAND NEW SIG " + String.valueOf(sigid));
+ this.engine = engine;
+ this.datapool = datapool;
+ this.sigid = sigid;
+ this.created = (java.util.Date)(creation.clone());
+ this.last_access = this.created;
+ this.last_update = this.created;
+ this.read_level = DefaultLevels.newSIGRead();
+ this.write_level = DefaultLevels.newSIGWrite();
+ this.create_level = DefaultLevels.newSIGCreate();
+ this.delete_level = DefaultLevels.newSIGDelete();
+ this.join_level = DefaultLevels.newSIGJoin();
+ this.contactid = -1;
+ this.host_uid = host_uid;
+ this.category_id = 0;
+ this.hidden_directory = hide_dir;
+ this.hidden_search = hide_search;
+ this.members_only = true;
+ this.is_admin = false;
+ this.initial_feature = 0;
+ this.name = name;
+ this.language = language;
+ this.synopsis = synopsis;
+ this.rules = rules;
+ this.alias = alias;
+ this.public_sig = StringUtil.isStringEmpty(joinkey);
+ this.features = (BitSet)(features.clone());
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * finalize() function
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void finalize()
+ {
+ engine = null;
+ datapool = null;
+ created = null;
+ last_access = null;
+ last_update = null;
+ name = null;
+ language = null;
+ synopsis = null;
+ rules = null;
+ alias = null;
+
+ } // end finalize
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private synchronized void loadData(ResultSet rs) throws SQLException
+ {
+ // "sigid" field is skipped
+ created = SQLUtil.getFullDateTime(rs,"createdate");
+ last_access = SQLUtil.getFullDateTime(rs,"lastaccess");
+ last_update = SQLUtil.getFullDateTime(rs,"lastupdate");
+ read_level = rs.getInt("read_lvl");
+ write_level = rs.getInt("write_lvl");
+ create_level = rs.getInt("create_lvl");
+ delete_level = rs.getInt("delete_lvl");
+ join_level = rs.getInt("join_lvl");
+ contactid = rs.getInt("contactid");
+ host_uid = rs.getInt("host_uid");
+ category_id = rs.getInt("catid");
+ hidden_directory = rs.getBoolean("hide_dir");
+ hidden_search = rs.getBoolean("hide_search");
+ members_only = rs.getBoolean("membersonly");
+ is_admin = rs.getBoolean("is_admin");
+ initial_feature = rs.getShort("init_ftr");
+ name = rs.getString("signame");
+ language = rs.getString("language");
+ synopsis = rs.getString("synopsis");
+ rules = rs.getString("rules");
+ if (!is_admin)
+ { // figure out whether we need a "join key" (password)
+ String foo = rs.getString("joinkey");
+ public_sig = StringUtil.isStringEmpty(foo);
+
+ } // end if
+ else // Admin is NEVER a public SIG!
+ public_sig = false;
+ alias = rs.getString("alias");
+
+ if (logger.isDebugEnabled())
+ logger.debug("Loaded data for SIG \"" + name + "\" (ID " + String.valueOf(sigid) + ", alias '"
+ + alias + "') successfully");
+
+ } // end loadData
+
+ private synchronized void touchUpdate(Connection conn) throws SQLException
+ {
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ last_update = now;
+
+ } // end touchUpdate
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ReferencedData
+ *--------------------------------------------------------------------------------
+ */
+
+ public int rd_addRef()
+ {
+ return ++refcount;
+
+ } // end rd_addRef()
+
+ public int rd_release()
+ {
+ return --refcount;
+
+ } // end rd_release
+
+ public boolean rd_unreferenced()
+ {
+ return (refcount<=0);
+
+ } // end rd_unreferenced
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface SIGData
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getID()
+ {
+ return sigid;
+
+ } // end getID
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String getAlias()
+ {
+ return alias;
+
+ } // end getAlias
+
+ public boolean isPublicSIG()
+ {
+ return public_sig;
+
+ } // end isPublicSIG
+
+ public int getCategoryID()
+ {
+ return category_id;
+
+ } // end getCategoryID
+
+ public String getSynopsis()
+ {
+ return synopsis;
+
+ } // end getSynopsis
+
+ public int getHostUID()
+ {
+ return host_uid;
+
+ } // end getHostUID
+
+ public String getLanguage()
+ {
+ return language;
+
+ } // end getLanguage
+
+ public String getRules()
+ {
+ return rules;
+
+ } // end getRules
+
+ public int getContactID()
+ {
+ return contactid;
+
+ } // end getContactID
+
+ public java.util.Date getCreationDate()
+ {
+ return created;
+
+ } // end getCreationDate
+
+ public java.util.Date getLastAccessDate()
+ {
+ return last_access;
+
+ } // end getLastAccessDate
+
+ public java.util.Date getLastUpdateDate()
+ {
+ return last_update;
+
+ } // end getLastUpdateDate
+
+ public void testMembership(int level, boolean is_member) throws AccessError
+ {
+ if (Capability.exemptFromMembershipRequirement(level))
+ return;
+ if (members_only && !is_member)
+ { // the membership test failed
+ logger.error("not a SIG member");
+ throw new AccessError("You are not a member of this SIG.");
+
+ } // end if
+
+ } // end testMembership
+
+ public boolean checkMembership(int level, boolean is_member)
+ {
+ if (Capability.exemptFromMembershipRequirement(level))
+ return true;
+ return !members_only || is_member;
+
+ } // end checkMembership
+
+ public boolean canReadSIGSubObjects(int level)
+ {
+ return (level>=read_level);
+
+ } // end canReadSIGSubObjects
+
+ public boolean canModifySIGProfile(int level)
+ {
+ return (level>=write_level);
+
+ } // end canModifySIGProfile
+
+ public boolean canCreateSIGSubObjects(int level)
+ {
+ return (level>=create_level);
+
+ } // end canCreateSIGSubObjects
+
+ public boolean canDeleteSIG(int level)
+ {
+ return (level>=delete_level);
+
+ } // end canDeleteSIG
+
+ public boolean canJoinSIG(int uid, int level)
+ {
+ if (level0)
+ { // add the features to the database
+ sql.append(';');
+ stmt.executeUpdate(sql.toString());
+
+ } // end if
+
+ features = set;
+
+ } // end try
+ finally
+ { // make sure we unlock the tables before we go
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ touchUpdate(conn);
+ ar = new AuditRecord(AuditRecord.SIG_FEATURE_SET,user.realUID(),user.userRemoteAddress(),sigid);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG feature set: " + e.getMessage(),e);
+ throw new DataException("unable to update feature set: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end putFeatureSet
+
+ public List getSIGFeaturesList(int level)
+ {
+ return engine.getSIGFeatureSet(features,level,canReadSIGSubObjects(level));
+
+ } // end getSIGFeaturesList
+
+ public String getDefaultApplet()
+ {
+ StringBuffer buf = new StringBuffer(engine.getAppletForFeature(initial_feature));
+ buf.append("?sig=").append(sigid);
+ return buf.toString();
+
+ } // end getDefaultApplet
+
+ public synchronized void setName(UserBackend user, String name) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET signame = '");
+ sql.append(SQLUtil.encodeString(name)).append("', lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ this.name = name;
+ last_update = now;
+ ar = new AuditRecord(AuditRecord.SIG_NAME,user.realUID(),user.userRemoteAddress(),sigid,"name=" + name);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setName
+
+ public synchronized void setAlias(UserBackend user, String alias) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET alias = '");
+ sql.append(alias).append("', lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ this.alias = alias;
+ last_update = now;
+ ar = new AuditRecord(AuditRecord.SIG_ALIAS,user.realUID(),user.userRemoteAddress(),sigid,
+ "alias=" + alias);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setAlias
+
+ public synchronized void setCategoryID(UserBackend user, int catid) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET catid = ");
+ sql.append(catid).append(", lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ this.category_id = catid;
+ last_update = now;
+ ar = new AuditRecord(AuditRecord.SIG_CATEGORY,user.realUID(),user.userRemoteAddress(),sigid,
+ "catid=" + String.valueOf(catid));
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setCategoryID
+
+ public synchronized void setSynopsis(String synopsis) throws DataException
+ {
+ Connection conn = null; // database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET synopsis = ");
+ sql.append(SQLUtil.encodeStringArg(synopsis)).append(", lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ this.synopsis = synopsis;
+ last_update = now;
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setSynopsis
+
+ public synchronized void setLanguage(String language) throws DataException
+ {
+ Connection conn = null; // database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET language = '");
+ sql.append(SQLUtil.encodeString(language)).append("', lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ this.language = language;
+ last_update = now;
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setLanguage
+
+ public synchronized void setRules(String rules) throws DataException
+ {
+ Connection conn = null; // database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET rules = ");
+ sql.append(SQLUtil.encodeStringArg(rules)).append(", lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ this.rules = rules;
+ last_update = now;
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setRules
+
+ public synchronized void touch() throws DataException
+ {
+ Connection conn = null; // database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET lastaccess = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ last_access = now;
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end touch
+
+ public boolean getHideDirectory()
+ {
+ return hidden_directory;
+
+ } // end getHideDirectory
+
+ public boolean getHideSearch()
+ {
+ return hidden_search;
+
+ } // end getHideSearch
+
+ public synchronized void setHideFlags(UserBackend user, boolean directory, boolean search)
+ throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET hide_dir = ");
+ sql.append(directory ? '1' : '0').append(", hide_search = ").append(search ? '1' : '0');
+ sql.append(", lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ hidden_directory = directory;
+ hidden_search = search;
+ last_update = now;
+ ar = new AuditRecord(AuditRecord.SIG_HIDE_INFO,user.realUID(),user.userRemoteAddress(),sigid,
+ "dir=" + String.valueOf(directory) + ",search=" + String.valueOf(search));
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setHideFlags
+
+ public boolean getMembersOnly()
+ {
+ return members_only;
+
+ } // end getMembersOnly
+
+ public synchronized void setMembersOnly(UserBackend user, boolean flag) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET membersonly = ");
+ sql.append(flag ? '1' : '0').append(", lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ members_only = flag;
+ last_update = now;
+ ar = new AuditRecord(AuditRecord.SIG_MEMBERS_ONLY,user.realUID(),user.userRemoteAddress(),sigid,
+ "flag=" + String.valueOf(flag));
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setMembersOnly
+
+ public short getInitialFeatureIndex()
+ {
+ return initial_feature;
+
+ } // end getInitialFeatureIndex
+
+ public synchronized void setInitialFeatureIndex(short ndx) throws DataException
+ {
+ Connection conn = null; // database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET init_ftr = ");
+ sql.append(ndx).append(", lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ initial_feature = ndx;
+ last_update = now;
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setInitialFeatureIndex
+
+ public String getJoinKey() throws DataException
+ {
+ Connection conn = null; // database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT joinkey FROM sigs WHERE sigid = ");
+ sql.append(sigid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ { // can't find the join key?
+ logger.error("SIG " + String.valueOf(sigid) + "appears to not be there");
+ throw new DataException("Unable to find join key for SIG");
+
+ } // end if
+
+ return rs.getString("joinkey");
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error retrieving join key: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve join key: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getJoinKey
+
+ public synchronized void setJoinKey(UserBackend user, String key) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET joinkey = ");
+ sql.append(SQLUtil.encodeStringArg(key)).append(", lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+ stmt.executeUpdate(sql.toString());
+ public_sig = StringUtil.isStringEmpty(key);
+ last_update = now;
+ ar = new AuditRecord(AuditRecord.SIG_JOIN_KEY,user.realUID(),user.userRemoteAddress(),sigid);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setJoinKey
+
+ public int getReadLevel()
+ {
+ return read_level;
+
+ } // end getReadLevel
+
+ public int getWriteLevel()
+ {
+ return write_level;
+
+ } // end getWriteLevel
+
+ public int getCreateLevel()
+ {
+ return create_level;
+
+ } // end getCreateLevel
+
+ public int getDeleteLevel()
+ {
+ return delete_level;
+
+ } // end getDeleteLevel
+
+ public int getJoinLevel()
+ {
+ return join_level;
+
+ } // end getJoinLevel
+
+ public synchronized void setSecurityLevels(UserBackend user, int read, int write, int create, int delete,
+ int join) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+
+ // create the SQL statement
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE sigs SET read_lvl = ");
+ sql.append(read).append(", write_lvl = ").append(write).append(", create_lvl = ").append(create);
+ sql.append(", delete_lvl = ").append(delete).append(", join_lvl = ").append(join);
+ sql.append(", lastupdate = '");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("' WHERE sigid = ").append(sigid).append(';');
+
+ // execute the database update
+ stmt.executeUpdate(sql.toString());
+
+ // save copies of the data to our local variables
+ read_level = read;
+ write_level = write;
+ create_level = create;
+ delete_level = delete;
+ join_level = join;
+ last_update = now;
+
+ // create an audit record reflecting what was done
+ ar = new AuditRecord(AuditRecord.SIG_SECURITY,user.realUID(),user.userRemoteAddress(),sigid);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setSecurityLevels
+
+ public boolean isAdminSIG()
+ {
+ return is_admin;
+
+ } // end isAdminSig
+
+ public synchronized void setMembership(UserBackend user, int uid, int grant_level, boolean locked,
+ boolean hidden) throws DataException
+ {
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // successful audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ boolean did_it = false;
+ stmt.executeUpdate("LOCK TABLES sigmember WRITE;");
+
+ try
+ { // perform the actual manipulation of the SIGMEMBER table...
+ StringBuffer sql = new StringBuffer();
+ if (grant_level>=0)
+ { // start by seeing if the user already has a record...
+ sql.append("SELECT sigid FROM sigmember WHERE sigid = ").append(sigid).append(" AND uid = ");
+ sql.append(uid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ sql.setLength(0);
+ if (rs.next())
+ { // build an UPDATE statement
+ sql.append("UPDATE sigmember SET granted_lvl = ").append(grant_level).append(", locked = ");
+ sql.append(locked ? '1' : '0').append(", hidden = ").append(hidden ? '1' : '0');
+ sql.append(" WHERE sigid = ").append(sigid).append(" AND uid = ").append(uid).append(';');
+
+ } // end if
+ else
+ { // build an INSERT statement
+ sql.append("INSERT INTO sigmember (sigid, uid, granted_lvl, locked, hidden) VALUES (");
+ sql.append(sigid).append(", ").append(uid).append(", ").append(grant_level).append(", ");
+ sql.append(locked ? '1' : '0').append(", ").append(hidden ? '1' : '0').append(");");
+
+ } // end else
+
+ stmt.executeUpdate(sql.toString()); // update me!
+ did_it = true;
+
+ } // end if
+ else
+ { // delete the membership reference (which may not exist, but oh well)
+ sql.append("DELETE FROM sigmember WHERE sigid = ").append(sigid).append(" AND uid = ");
+ sql.append(uid).append(';');
+ did_it = (stmt.executeUpdate(sql.toString())>0);
+
+ } // end else
+
+ } // end try
+ finally
+ { // make sure the tables are unlocked before we go
+ Statement ulk_stmt = conn.createStatement();
+ stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ if (did_it)
+ { // update the SIG data and generate an audit record
+ touchUpdate(conn);
+ ar = new AuditRecord(AuditRecord.SET_MEMBERSHIP,user.realUID(),user.userRemoteAddress(),sigid,
+ "uid=" + String.valueOf(uid),"level=" + String.valueOf(grant_level));
+ } // end if
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error storing SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to save SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setMembership
+
+ public int getMemberCount(boolean include_hidden) throws DataException
+ {
+ Connection conn = null; // database connection
+
+ try
+ { // get a database connection and create the appropriate SELECT statement
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT COUNT(*) AS total FROM sigmember WHERE sigid = ");
+ sql.append(sigid);
+ if (!include_hidden)
+ sql.append(" AND hidden = 0");
+ sql.append(';');
+
+ // execute the query
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new InternalStateError("getMemberCount query failure - must have ONE row!");
+
+ return rs.getInt("total");
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error getting SIG data: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve SIG data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getMemberCount
+
+ public boolean isFeaturePresent(String symbol)
+ {
+ int ndx = engine.getFeatureIndexBySymbol(symbol);
+ if (ndx>=0)
+ return features.get(ndx);
+ else
+ return false;
+
+ } // end isFeaturePresent
+
+ public ConferenceSIGContext getConferenceDataObject(int confid) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getConferenceDataObject(" + String.valueOf(confid) + ")...");
+
+ Integer the_confid = new Integer(confid);
+ ConferenceSIGContext csc = (ConferenceSIGContext)(conf_objects.get(the_confid));
+ if (csc==null)
+ { // create a new ConferenceSIGContextImpl object and save it off
+ csc = new ConferenceSIGContextImpl(engine,this,datapool,confid);
+ conf_objects.put(the_confid,csc);
+ if (logger.isDebugEnabled())
+ logger.debug("...created new object");
+
+ } // end if
+ else
+ { // this is an extra reference to the ConferenceSIGContext
+ csc.rd_addRef();
+ if (logger.isDebugEnabled())
+ logger.debug("...using cached object");
+
+ } // end else
+
+ return csc;
+
+ } // end getConferenceDataObject
+
+ public ConferenceSIGContext createConference(SIGBackend sig, String name, String alias, String description,
+ boolean pvt, boolean hide_list) throws DataException
+ {
+ ReturnConfSeq rcs = ConferenceCoreData.createConference(engine,sig,datapool,name,alias,description,
+ pvt,hide_list,host_uid);
+ ConferenceData cdata = rcs.getConference();
+ if (sig.realUID()!=host_uid) // make the creating user a conference host too
+ cdata.setMembership(sig,sig.realUID(),DefaultLevels.hostConference());
+
+ // Wrap the returned ConferenceData object in a ConferenceSIGContextImpl object and release the
+ // extra reference on it.
+ ConferenceSIGContextImpl conf = new ConferenceSIGContextImpl(engine,this,datapool,rcs.getSequence(),
+ hide_list,cdata);
+ cdata.rd_release();
+ rcs = null;
+
+ // Register this object with our local cache of ConferenceSIGData objects.
+ Integer the_confid = new Integer(conf.getConfID());
+ if (conf_objects.get(the_confid)!=null)
+ throw new InternalStateError("ConfID " + the_confid.toString() + " already exists...but it CAN'T HAVE!");
+
+ // throw an extra reference on it and dump it in the object cache
+ conf.rd_addRef();
+ conf_objects.put(the_confid,conf);
+
+ return conf; // pass it up to the next level
+
+ } // end createConference
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface SIGDataBackend
+ *--------------------------------------------------------------------------------
+ */
+
+ public int realSIGID()
+ {
+ return sigid;
+
+ } // end realSIGID
+
+ /*--------------------------------------------------------------------------------
+ * External static operations (usable only from within package)
+ *--------------------------------------------------------------------------------
+ */
+
+ static SIGData createSIG(EngineBackend engine, UserBackend user, DataPool datapool, String name,
+ String alias, int host_uid, String language, String synopsis, String rules,
+ String joinkey, boolean hide_dir, boolean hide_search)
+ throws DataException, AccessError
+ {
+ Connection conn = null; // database connection
+ BitSet def_features = engine.getDefaultFeaturesMask();
+ int new_sigid; // ID of the new SIG
+ java.util.Date creation; // creation date!
+ AuditRecord ar = null; // the audit record
+
+ try
+ { // get a database connection and create the appropriate SELECT statement
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES sigs WRITE, sigftrs WRITE, sigmember WRITE;");
+
+ try
+ { // first, we need to check if the SIG alias already exists
+ StringBuffer sql = new StringBuffer("SELECT sigid FROM sigs WHERE alias = ");
+ sql.append(SQLUtil.encodeStringArg(alias)).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (rs.next()) // we should get 0 rows back on this one
+ throw new AccessError("A SIG with that alias already exists.");
+
+ // Now, here comes the BIG INSERT to create the SIG!
+ sql.setLength(0);
+ sql.append("INSERT INTO sigs (createdate, lastaccess, lastupdate, read_lvl, write_lvl, create_lvl, "
+ + "delete_lvl, join_lvl, host_uid, hide_dir, hide_search, signame, language, synopsis, "
+ + "rules, joinkey, alias) VALUES ('");
+ creation = new java.util.Date();
+ String creation_str = SQLUtil.encodeDate(creation);
+ sql.append(creation).append("', '").append(creation).append("', '").append(creation).append("', ");
+ sql.append(DefaultLevels.newSIGRead()).append(", ").append(DefaultLevels.newSIGWrite()).append(", ");
+ sql.append(DefaultLevels.newSIGCreate()).append(", ").append(DefaultLevels.newSIGDelete());
+ sql.append(", ").append(DefaultLevels.newSIGJoin()).append(", ").append(host_uid).append(", ");
+ sql.append(hide_dir ? '1' : '0').append(", ").append(hide_search ? '1' : '0').append(", ");
+ sql.append(SQLUtil.encodeStringArg(name)).append(", ").append(SQLUtil.encodeStringArg(language));
+ sql.append(", ").append(SQLUtil.encodeStringArg(synopsis)).append(", ");
+ sql.append(SQLUtil.encodeStringArg(rules)).append(", ").append(SQLUtil.encodeStringArg(joinkey));
+ sql.append(", ").append(SQLUtil.encodeStringArg(alias)).append(");");
+
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ stmt.executeUpdate(sql.toString()); // here we go!
+
+ // Get the SIGID of the new SIG!
+ rs = stmt.executeQuery("SELECT LAST_INSERT_ID() AS blort;");
+ if (rs.next())
+ new_sigid = rs.getInt("blort");
+ else
+ { // we should have gotten a SIGID back!
+ logger.error("readback of new SIGID failed!");
+ throw new InternalStateError("failure on createSIG return query - must have 1 row!");
+
+ } // end else
+
+ if (def_features.length()>0)
+ { // need to build the SIG's defined feature set
+ sql.setLength(0);
+ for (int i=0; i.
+ *
+ * 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 Community 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.core.impl;
+
+import java.util.BitSet;
+import java.util.Date;
+import java.util.List;
+import com.silverwrist.venice.core.AccessError;
+import com.silverwrist.venice.core.ContactInfo;
+import com.silverwrist.venice.core.DataException;
+
+public interface SIGData extends ReferencedData
+{
+ public abstract int getID();
+
+ public abstract String getName();
+
+ public abstract String getAlias();
+
+ public abstract boolean isPublicSIG();
+
+ public abstract int getCategoryID();
+
+ public abstract String getSynopsis();
+
+ public abstract int getHostUID();
+
+ public abstract String getLanguage();
+
+ public abstract String getRules();
+
+ public abstract int getContactID();
+
+ public abstract Date getCreationDate();
+
+ public abstract Date getLastAccessDate();
+
+ public abstract Date getLastUpdateDate();
+
+ public abstract void testMembership(int level, boolean is_member) throws AccessError;
+
+ public abstract boolean checkMembership(int level, boolean is_member);
+
+ public abstract boolean canReadSIGSubObjects(int level);
+
+ public abstract boolean canModifySIGProfile(int level);
+
+ public abstract boolean canCreateSIGSubObjects(int level);
+
+ public abstract boolean canDeleteSIG(int level);
+
+ public abstract boolean canJoinSIG(int uid, int level);
+
+ public abstract void putContactInfo(UserBackend user, ContactInfo ci) throws DataException;
+
+ public abstract BitSet getFeatureSet();
+
+ public abstract void putFeatureSet(UserBackend user, BitSet set) throws DataException;
+
+ public abstract List getSIGFeaturesList(int level);
+
+ public abstract String getDefaultApplet();
+
+ public abstract void setName(UserBackend user, String name) throws DataException;
+
+ public abstract void setAlias(UserBackend user, String alias) throws DataException;
+
+ public abstract void setCategoryID(UserBackend user, int catid) throws DataException;
+
+ public abstract void setSynopsis(String synopsis) throws DataException;
+
+ public abstract void setLanguage(String language) throws DataException;
+
+ public abstract void setRules(String rules) throws DataException;
+
+ public abstract void touch() throws DataException;
+
+ public abstract boolean getHideDirectory();
+
+ public abstract boolean getHideSearch();
+
+ public abstract void setHideFlags(UserBackend user, boolean directory, boolean search) throws DataException;
+
+ public abstract boolean getMembersOnly();
+
+ public abstract void setMembersOnly(UserBackend user, boolean flag) throws DataException;
+
+ public abstract short getInitialFeatureIndex();
+
+ public abstract void setInitialFeatureIndex(short ndx) throws DataException;
+
+ public abstract String getJoinKey() throws DataException;
+
+ public abstract void setJoinKey(UserBackend user, String key) throws DataException;
+
+ public abstract int getReadLevel();
+
+ public abstract int getWriteLevel();
+
+ public abstract int getCreateLevel();
+
+ public abstract int getDeleteLevel();
+
+ public abstract int getJoinLevel();
+
+ public abstract void setSecurityLevels(UserBackend user, int read, int write, int create, int delete,
+ int join) throws DataException;
+
+ public abstract boolean isAdminSIG();
+
+ public abstract void setMembership(UserBackend user, int uid, int grant_level, boolean locked,
+ boolean hidden) throws DataException;
+
+ public abstract int getMemberCount(boolean include_hidden) throws DataException;
+
+ public abstract boolean isFeaturePresent(String symbol);
+
+ public abstract ConferenceSIGContext getConferenceDataObject(int confid) throws DataException;
+
+ public abstract ConferenceSIGContext createConference(SIGBackend sig, String name, String alias,
+ String description, boolean pvt, boolean hide_list)
+ throws DataException;
+
+} // end interface SIGData
diff --git a/src/com/silverwrist/venice/core/impl/SIGDataBackend.java b/src/com/silverwrist/venice/core/impl/SIGDataBackend.java
new file mode 100644
index 0000000..0725c9e
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/SIGDataBackend.java
@@ -0,0 +1,24 @@
+/*
+ * 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 Community 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.core.impl;
+
+public interface SIGDataBackend
+{
+ public abstract int realSIGID();
+
+} // end interface SIGDataBackend
diff --git a/src/com/silverwrist/venice/core/impl/SIGUserContextImpl.java b/src/com/silverwrist/venice/core/impl/SIGUserContextImpl.java
new file mode 100644
index 0000000..0a4f9ca
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/SIGUserContextImpl.java
@@ -0,0 +1,1587 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.db.*;
+import com.silverwrist.venice.security.Capability;
+import com.silverwrist.venice.security.DefaultLevels;
+import com.silverwrist.venice.core.*;
+
+class SIGUserContextImpl implements SIGContext, SIGBackend
+{
+ /*--------------------------------------------------------------------------------
+ * Internal class for caching the SIG name and alias
+ *--------------------------------------------------------------------------------
+ */
+
+ class SIGSimpleDataCache
+ {
+ private String name;
+ private String alias;
+
+ public SIGSimpleDataCache(String name, String alias)
+ {
+ this.name = name;
+ this.alias = alias;
+
+ } // end constructor
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String getAlias()
+ {
+ return alias;
+
+ } // end getAlias
+
+ } // end class SIGSimpleDataCache
+
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(SIGUserContextImpl.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private EngineBackend engine; // pointer to the engine back end
+ private UserBackend user; // pointer to the user back end
+ private DataPool datapool; // pointer to the main data pool
+ private int sigid; // ID of the underlying SIG
+ private int level; // access level we have to the SIG
+ private boolean is_member; // are we a member of the SIG?
+ private boolean show_admin; // do we show up as an admin?
+ private boolean locked; // is our membership locked?
+ private SIGSimpleDataCache cache; // cache object for name and alias
+ private SIGData sigdata = null; // the actual SIG data
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ protected SIGUserContextImpl(EngineBackend engine, UserBackend user, DataPool datapool, int sigid,
+ int granted_level, boolean locked, String name, String alias)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("SIGUserContextImpl constructor:member");
+ this.engine = engine;
+ this.user = user;
+ this.datapool = datapool;
+ this.sigid = sigid;
+ setMemberValues(granted_level,true,locked);
+ this.cache = new SIGSimpleDataCache(name,alias);
+
+ } // end constructor
+
+ protected SIGUserContextImpl(EngineBackend engine, UserBackend user, DataPool datapool, int sigid,
+ String name, String alias)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("SIGUserContextImpl constructor:ordinary");
+ this.engine = engine;
+ this.user = user;
+ this.datapool = datapool;
+ this.sigid = sigid;
+ this.level = user.realBaseLevel();
+ this.is_member = false;
+ this.show_admin = false;
+ this.locked = false;
+ this.cache = new SIGSimpleDataCache(name,alias);
+
+ } // end constructor
+
+ SIGUserContextImpl(EngineBackend engine, UserBackend user, DataPool datapool, SIGData sigdata)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("SIGUserContextImpl constructor:newSIG");
+ this.engine = engine;
+ this.user = user;
+ this.datapool = datapool;
+ this.sigid = sigdata.getID();
+ this.cache = null; // no cache required - we have the SIGData
+ sigdata.rd_addRef();
+ this.sigdata = sigdata;
+ setMemberValues(DefaultLevels.creatorSIG(),true,true);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * finalize() function
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void finalize()
+ {
+ if (sigdata!=null)
+ sigdata.rd_release();
+ engine = null;
+ user = null;
+ datapool = null;
+ cache = null;
+ sigdata = null;
+
+ } // end finalize
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private void setMemberValues(int granted_level, boolean member, boolean locked)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("setMemberValues(" + String.valueOf(granted_level) + ", " + String.valueOf(member)
+ + ", " + String.valueOf(locked));
+
+ if (user.realBaseLevel()>granted_level)
+ this.level = user.realBaseLevel();
+ else
+ this.level = granted_level;
+ this.is_member = member;
+ this.show_admin = Capability.isCommunityAdmin(granted_level);
+ this.locked = locked;
+
+ } // end setMemberValues
+
+ private SIGData getSIGData() throws DataException
+ {
+ if (sigdata==null)
+ { // attempt to load the SIGDataObject
+ sigdata = engine.getSIGDataObject(sigid);
+
+ // clear cache when we get the real sigdata
+ cache = null;
+
+ } // end if
+
+ return sigdata;
+
+ } // end getSIGData
+
+ private SIGData getSIGDataNE()
+ {
+ if (sigdata==null)
+ { // we need to load the SIGData...
+ try
+ { // attempt to load the SIGDataObject
+ sigdata = engine.getSIGDataObject(sigid);
+
+ } // end try
+ catch (DataException e)
+ { // there was a data failure loading the SIG
+ logger.error("** Got DataException in getSIGDataNE: " + e.getMessage(),e);
+ return null;
+
+ } // end catch
+
+ // clear cache when we get the real sigdata
+ cache = null;
+
+ } // end if
+
+ return sigdata;
+
+ } // end getSIGData
+
+ private void testConferenceAccess() throws DataException, AccessError
+ {
+ if (!(getSIGData().isFeaturePresent("CONF")))
+ { // the SIG doesn't use conferencing
+ logger.error("the SIG doesn't use conferencing");
+ throw new AccessError("This SIG does not use the conferencing feature.");
+
+ } // end if
+
+ getSIGData().testMembership(level,is_member);
+ if (!(engine.canAccessFeature("CONF",level,getSIGData().canReadSIGSubObjects(level))))
+ { // you can't access the conferences!
+ logger.error("user not permitted to read confs from this SIG");
+ throw new AccessError("You are not permitted to access this SIG's conferences.");
+
+ } // end if
+
+ } // end testConferenceAccess
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from class SIGContext
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getSIGID()
+ {
+ return sigid;
+
+ } // end getSIGID
+
+ public String getName()
+ {
+ if (cache!=null)
+ { // return cached name if possible
+ if (cache.getName()!=null)
+ return cache.getName();
+
+ } // end if
+
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getName();
+ else
+ return null;
+
+ } // end getName
+
+ public String getAlias()
+ {
+ if (cache!=null)
+ { // return cached alias if possible
+ if (cache.getAlias()!=null)
+ return cache.getAlias();
+
+ } // end if
+
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getAlias();
+ else
+ return null;
+
+ } // end getAlias
+
+ public boolean isMember()
+ {
+ return is_member;
+
+ } // end isMember
+
+ public boolean isAdmin()
+ {
+ return show_admin;
+
+ } // end isAdmin
+
+ public boolean isPublicSIG()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.isPublicSIG();
+ else
+ return false;
+
+ } // end isPublicSIG
+
+ public int getCategoryID()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getCategoryID();
+ else
+ return -1;
+
+ } // end getCategoryID
+
+ public CategoryDescriptor getCategory() throws DataException
+ {
+ return new CategoryDescriptorImpl(datapool,getSIGData().getCategoryID(),
+ Capability.hideHiddenCategories(user.realBaseLevel()));
+
+ } // end getCategory
+
+ public String getSynopsis()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getSynopsis();
+ else
+ return null;
+
+ } // end getSynopsis
+
+ public int getHostUID()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getHostUID();
+ else
+ return -1;
+
+ } // end getHostUID
+
+ public UserProfile getHostProfile() throws DataException
+ {
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+
+ // load the profile for the user
+ return new UserProfileImpl(engine,conn,getSIGData().getHostUID(),
+ Capability.canSeeHiddenContactFields(user.realBaseLevel()));
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ throw new DataException("unable to retrieve host contact information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getHostProfile
+
+ public String getLanguageCode()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getLanguage();
+ else
+ return null;
+
+ } // end getLanguageCode
+
+ public String getLanguageFullName()
+ {
+ String code = getLanguageCode();
+ if (code!=null)
+ return engine.getLanguageNameForCode(code);
+ else
+ return null;
+
+ } // end getLanguageFullName
+
+ public String getRules()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getRules();
+ else
+ return null;
+
+ } // end getRules
+
+ public java.util.Date getCreationDate()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getCreationDate();
+ else
+ return null;
+
+ } // end getCreationDate
+
+ public java.util.Date getLastAccessDate()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getLastAccessDate();
+ else
+ return null;
+
+ } // end getLastAccessDate
+
+ public java.util.Date getLastUpdateDate()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getLastUpdateDate();
+ else
+ return null;
+
+ } // end getLastUpdateDate
+
+ public ContactInfo getContactInfo() throws DataException
+ {
+ int cid = getSIGData().getContactID();
+ ContactInfo rc;
+ if (cid>=0)
+ rc = new ContactInfoImpl(datapool,cid);
+ else
+ rc = new ContactInfoImpl(getSIGData().getHostUID(),sigid);
+ getSIGData().touch();
+ return rc;
+
+ } // end getContactInfo
+
+ public void putContactInfo(ContactInfo ci) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (ci.getOwnerSIGID()!=sigid)
+ { // this isn't a valid contact info for the SIG
+ logger.error("ContactInfo wrong ownership (was " + String.valueOf(ci.getOwnerSIGID())
+ + ", should be " + String.valueOf(sigid) + ")");
+ throw new DataException("invalid contact information record");
+
+ } // end if
+
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG contact info
+ logger.error("user not permitted to modify the SIG's contact info");
+ throw new AccessError("You are not permitted to modify the SIG's contact information.");
+
+ } // end if
+
+ getSIGData().putContactInfo(user,ci);
+
+ } // end putContactInfo
+
+ public BitSet getFeatures()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getFeatureSet();
+ else
+ return null;
+
+ } // end getFeatures
+
+ public void setFeatures(BitSet feature_set, BitSet mask) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's feature set");
+ throw new AccessError("You are not permitted to modify the SIG's feature set.");
+
+ } // end if
+
+ // Adjust the "mask"...this function cannot affect the set of "locked" features.
+ BitSet real_mask = (BitSet)(mask.clone());
+ real_mask.andNot(engine.getLockedFeaturesMask());
+
+ // Figure out which bits are being carried over from the old feature set.
+ BitSet new_features = getSIGData().getFeatureSet();
+ new_features.andNot(real_mask);
+
+ // Figure out which bits are being set by the new feature set.
+ BitSet update_bits = (BitSet)(feature_set.clone());
+ update_bits.and(real_mask);
+
+ // Put the features together to result in the final feature set, which we set down in
+ // the "back end" class.
+ new_features.or(update_bits);
+ getSIGData().putFeatureSet(user,new_features);
+
+ } // end setFeatures
+
+ public List getSIGFeaturesList()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getSIGFeaturesList(level);
+ else
+ return null;
+
+ } // end getSIGFeaturesList
+
+ public String getDefaultApplet()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getDefaultApplet();
+ else
+ return null;
+
+ } // end getDefaultApplet
+
+ public void setName(String name) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ getSIGData().setName(user,name);
+
+ } // end setName
+
+ public void setAlias(String alias) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ getSIGData().setAlias(user,alias);
+
+ } // end setAlias
+
+ public void setCategoryID(int catid) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ if (getSIGData().isAdminSIG())
+ { // the Admin SIG cannot change its security
+ logger.error("trying to change category for the ADMIN SIG");
+ throw new AccessError("The administrative SIG's category cannot be modified.");
+
+ } // end if
+
+ getSIGData().setCategoryID(user,catid);
+
+ } // end setCategoryID
+
+ public void setCategory(CategoryDescriptor cat) throws DataException, AccessError
+ {
+ setCategoryID(cat.getCategoryID());
+
+ } // end setCategory
+
+ public void setSynopsis(String synopsis) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ getSIGData().setSynopsis(synopsis);
+
+ } // end setSynopsis
+
+ public void setLanguage(String language) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ getSIGData().setLanguage(language);
+
+ } // end setLanguage
+
+ public void setRules(String rules) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ getSIGData().setRules(rules);
+
+ } // end setRules
+
+ public int getHideMode()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd==null)
+ return HIDE_NONE;
+ if (sd.getHideSearch())
+ return HIDE_BOTH;
+ else if (sd.getHideDirectory())
+ return HIDE_DIRECTORY;
+ else
+ return HIDE_NONE;
+
+ } // end getHideMode
+
+ public void setHideMode(int mode) throws DataException, AccessError
+ {
+ if ((mode!=HIDE_NONE) && (mode!=HIDE_DIRECTORY) && (mode!=HIDE_BOTH))
+ { // the mode is not valid
+ logger.error("mode value " + String.valueOf(mode) + " is not valid");
+ throw new IllegalArgumentException("invalid hide mode value");
+
+ } // end if
+
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ if (getSIGData().isAdminSIG())
+ { // the Admin SIG cannot change its security
+ logger.error("trying to change security info for the ADMIN SIG");
+ throw new AccessError("The administrative SIG's security information cannot be modified.");
+
+ } // end if
+
+ boolean hide_dir = (mode!=HIDE_NONE);
+ boolean hide_search = (mode==HIDE_BOTH);
+ getSIGData().setHideFlags(user,hide_dir,hide_search);
+
+ } // end setHideMode
+
+ public boolean getMembersOnly()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getMembersOnly();
+ else
+ return true;
+
+ } // end getMembersOnly
+
+ public void setMembersOnly(boolean flag) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ if (getSIGData().isAdminSIG())
+ { // the Admin SIG cannot change its security
+ logger.error("trying to change security info for the ADMIN SIG");
+ throw new AccessError("The administrative SIG's security information cannot be modified.");
+
+ } // end if
+
+ getSIGData().setMembersOnly(user,flag);
+
+ } // end setMembersOnly
+
+ public short getInitialFeatureIndex()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.getInitialFeatureIndex();
+ else
+ return 0;
+
+ } // end getInitialFeatureIndex
+
+ public void setInitialFeatureIndex(short ndx) throws DataException, AccessError
+ {
+ if (!(engine.isValidInitialFeatureIndex(ndx)))
+ { // the mode is not valid
+ logger.error("feature index value " + String.valueOf(ndx) + " is not valid");
+ throw new IllegalArgumentException("invalid initial feature index");
+
+ } // end if
+
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ getSIGData().setInitialFeatureIndex(ndx);
+
+ } // end setInitialFeatureIndex
+
+ public String getJoinKey() throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to retrieve join key");
+ throw new AccessError("You are not permitted to retrieve the join key for this SIG.");
+
+ } // end if
+
+ return getSIGData().getJoinKey();
+
+ } // end getJoinKey
+
+ public void setJoinKey(String key) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ if (getSIGData().isAdminSIG())
+ { // the Admin SIG cannot change its security
+ logger.error("trying to change security info for the ADMIN SIG");
+ throw new AccessError("The administrative SIG's security information cannot be modified.");
+
+ } // end if
+
+ getSIGData().setJoinKey(user,key);
+
+ } // end setJoinKey
+
+ public int getReadLevel() throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this SIG.");
+
+ } // end if
+
+ return getSIGData().getReadLevel();
+
+ } // end getReadLevel
+
+ public int getWriteLevel() throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this SIG.");
+
+ } // end if
+
+ return getSIGData().getWriteLevel();
+
+ } // end getWriteLevel
+
+ public int getCreateLevel() throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this SIG.");
+
+ } // end if
+
+ return getSIGData().getCreateLevel();
+
+ } // end getCreateLevel
+
+ public int getDeleteLevel() throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this SIG.");
+
+ } // end if
+
+ return getSIGData().getDeleteLevel();
+
+ } // end getDeleteLevel
+
+ public int getJoinLevel() throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to retrieve security info");
+ throw new AccessError("You are not permitted to retrieve security information for this SIG.");
+
+ } // end if
+
+ return getSIGData().getJoinLevel();
+
+ } // end getJoinLevel
+
+ public void setSecurityLevels(int read, int write, int create, int delete, int join)
+ throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().canModifySIGProfile(level)))
+ { // this user can't modify the SIG feature set
+ logger.error("user not permitted to modify the SIG's information");
+ throw new AccessError("You are not permitted to modify the SIG's information.");
+
+ } // end if
+
+ if (getSIGData().isAdminSIG())
+ { // the Admin SIG cannot change its security
+ logger.error("trying to change security info for the ADMIN SIG");
+ throw new AccessError("The administrative SIG's security information cannot be modified.");
+
+ } // end if
+
+ if (read>write)
+ { // correct the write level...
+ if (logger.isDebugEnabled())
+ logger.debug("read level (" + String.valueOf(read) + ") greater than write level ("
+ + String.valueOf(write) + "); correcting write level");
+ write = read;
+
+ } // end if
+
+ if (write>delete)
+ { // correct the delete level...
+ if (logger.isDebugEnabled())
+ logger.debug("write level (" + String.valueOf(write) + ") greater than delete level ("
+ + String.valueOf(delete) + "); correcting delete level");
+ delete = write;
+
+ } // end if
+
+ if (create>delete)
+ { // correct the create level...
+ if (logger.isDebugEnabled())
+ logger.debug("create level (" + String.valueOf(create) + ") greater than delete level ("
+ + String.valueOf(delete) + "); correcting create level");
+ create = delete;
+
+ } // end if
+
+ getSIGData().setSecurityLevels(user,read,write,create,delete,join);
+
+ } // end setSecurityLevels
+
+ public boolean canAdministerSIG()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd==null)
+ return false;
+
+ if (sd.canDeleteSIG(level))
+ return true;
+ if (sd.canModifySIGProfile(level))
+ return true;
+ if (sd.canCreateSIGSubObjects(level))
+ return true;
+
+ return false;
+
+ } // end canAdministerSIG
+
+ public boolean canModifyProfile()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd==null)
+ return false;
+
+ return sd.canModifySIGProfile(level);
+
+ } // end canModifyProfile
+
+ public boolean isAdminSIG()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.isAdminSIG();
+ else
+ return false;
+
+ } // end isAdminSIG
+
+ public void join(String joinkey) throws DataException, AccessError
+ {
+ if (is_member)
+ { // we're already a member!
+ logger.info("attempting to join SIG, but already a member");
+ return; // this becomes a no-op
+
+ } // end if
+
+ if (!(getSIGData().canJoinSIG(user.realUID(),level)))
+ { // this user can't join up!
+ logger.error("user not permitted to join SIG");
+ throw new AccessError("You are not permitted to join this SIG.");
+
+ } // end if
+
+ if (!(getSIGData().isPublicSIG()))
+ { // this is a private SIG - but admins can join anyway
+ if (!(Capability.canJoinPrivateSIGWithoutKey(level)))
+ { // we need to test the join key against the one they supply
+ String real_key = getSIGData().getJoinKey();
+ if (!(real_key.equals(joinkey)))
+ { // the join key was not the one stored in the SIG
+ logger.error("invalid join key specified");
+ throw new AccessError("The join key you specified was incorrect.");
+
+ } // end if
+
+ } // end if
+ // else the admin person can join, that's cool
+
+ } // end if
+ // else we can join without specifying a key
+
+ // actually set the data in the database
+ getSIGData().setMembership(user,user.realUID(),DefaultLevels.memberSIG(),false,false);
+
+ // and update our internal data store
+ setMemberValues(DefaultLevels.memberSIG(),true,false);
+
+ // and that's it! You expected lightning bolts maybe?
+
+ } // end join
+
+ public void unjoin() throws DataException, AccessError
+ {
+ if (!is_member)
+ { // we're already a member!
+ logger.info("attempting to unjoin SIG, but not currently a member");
+ return; // this becomes a no-op
+
+ } // end if
+
+ if (locked)
+ { // we're locked - we can't possibly unjoin!
+ logger.info("membership in SIG is locked, cannot remove");
+ throw new AccessError("You are not permitted to unjoin this SIG.");
+
+ } // end if
+
+ // actually set the data in the database
+ getSIGData().setMembership(user,user.realUID(),-1,false,false);
+
+ // and update our internal data store
+ setMemberValues(-1,false,false);
+
+ } // end unjoin
+
+ public int getMemberCount() throws DataException
+ {
+ return getSIGData().getMemberCount(Capability.showHiddenSIGMembers(level));
+
+ } // end getMemberCount
+
+ public boolean canUnjoin()
+ {
+ return is_member && !locked;
+
+ } // end canUnjoin
+
+ public boolean canJoin()
+ {
+ if (is_member)
+ return false;
+ SIGData sd = getSIGDataNE();
+ if (sd!=null)
+ return sd.canJoinSIG(user.realUID(),level);
+ else
+ return false;
+
+ } // end canJoin
+
+ public List getConferences() throws DataException, AccessError
+ {
+ testConferenceAccess();
+ return ConferenceUserContextImpl.getSIGConferences(engine,this,datapool);
+
+ } // end getConferences
+
+ public ConferenceContext getConferenceContext(int confid) throws DataException, AccessError
+ {
+ testConferenceAccess();
+ return ConferenceUserContextImpl.getConference(engine,this,datapool,confid);
+
+ } // end getConferenceContext
+
+ public ConferenceContext getConferenceContext(String alias) throws DataException, AccessError
+ {
+ testConferenceAccess();
+ return ConferenceUserContextImpl.getConference(engine,this,datapool,alias);
+
+ } // end getConferenceContext
+
+ public ConferenceContext createConference(String name, String alias, String description, boolean pvt,
+ boolean hide_list) throws DataException, AccessError
+ {
+ getSIGData().testMembership(level,is_member);
+ if (!(getSIGData().isFeaturePresent("CONF")))
+ { // we can't create a conference in this SIG
+ logger.error("this SIG does not use conferencing");
+ throw new AccessError("You are not permitted to create conferences in this SIG.");
+
+ } // end if
+
+ if (!(getSIGData().canCreateSIGSubObjects(level)))
+ { // this user can't create a conference
+ logger.error("user not permitted to create a conference");
+ throw new AccessError("You are not permitted to create conferences in this SIG.");
+
+ } // end if
+
+ // call down to the SIG core data to create the conference
+ ConferenceSIGContext cdata = getSIGData().createConference(this,name,alias,description,pvt,hide_list);
+
+ // wrap the returned object in a conference user context object and release the extra reference
+ ConferenceUserContextImpl rc;
+ try
+ { // need to wrap this 'cos it can throw DataException
+ rc = new ConferenceUserContextImpl(engine,this,datapool,cdata);
+
+ } // end try
+ finally
+ { // make sure to release that extra reference before we go
+ cdata.rd_release();
+
+ } // end finally
+
+ return rc;
+
+ } // end createConference
+
+ public boolean canCreateConference()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd==null)
+ return false;
+ if (!(sd.checkMembership(level,is_member)))
+ return false;
+ if (sd.isFeaturePresent("CONF"))
+ return sd.canCreateSIGSubObjects(level);
+ else
+ return false;
+
+ } // end canCreateConference
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface UserBackend
+ *--------------------------------------------------------------------------------
+ */
+
+ public int realUID()
+ {
+ return user.realUID();
+
+ } // end realUID
+
+ public int realBaseLevel()
+ {
+ return user.realBaseLevel();
+
+ } // end realBaseLevel
+
+ public String userRemoteAddress()
+ {
+ return user.userRemoteAddress();
+
+ } // end userRemoteAddress
+
+ public String userDefaultPseud() throws DataException
+ {
+ return user.userDefaultPseud();
+
+ } // end userDefaultPseud
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface SIGBackend
+ *--------------------------------------------------------------------------------
+ */
+
+ public int realSIGID()
+ {
+ return sigid;
+
+ } // end realSIGID
+
+ public boolean userHideHiddenConferences()
+ {
+ return Capability.hideHiddenConferences(level);
+
+ } // end userHideHiddenConferences
+
+ public int realSIGLevel()
+ {
+ return level;
+
+ } // end realSIGLevel
+
+ public ConferenceSIGContext getConferenceDataObject(int confid) throws DataException
+ {
+ return getSIGData().getConferenceDataObject(confid);
+
+ } // end getConferenceDataObject
+
+ public boolean userCanCreateSubobjects()
+ {
+ SIGData sd = getSIGDataNE();
+ if (sd==null)
+ return false;
+ if (sd.checkMembership(level,is_member))
+ return sd.canCreateSIGSubObjects(level);
+ else
+ return false;
+
+ } // end userCanCreateSubObjects
+
+ public String realSIGAlias()
+ {
+ return getAlias();
+
+ } // end realSIGAlias
+
+ /*--------------------------------------------------------------------------------
+ * Static operations for use within the implementation package
+ *--------------------------------------------------------------------------------
+ */
+
+ static List getMemberSIGEntries(EngineBackend engine, UserBackend user, DataPool datapool)
+ throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getMemberSIGEntries for user #" + String.valueOf(user.realUID()));
+ Vector rc = new Vector(); // return from this function
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT sm.sigid AS sigid, sm.granted_lvl AS level, "
+ + "sm.locked AS locked, s.signame AS name, s.alias AS alias "
+ + "FROM sigmember sm, sigs s WHERE sm.sigid = s.sigid "
+ + "AND sm.uid = ");
+ sql.append(user.realUID()).append(" ORDER BY s.signame;");
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ while (rs.next())
+ { // create the user contexts and add them to the return vector
+ int the_sigid = rs.getInt("sigid");
+ if (logger.isDebugEnabled())
+ logger.debug("...found SIG #" + String.valueOf(the_sigid));
+ SIGContext tmp = new SIGUserContextImpl(engine,user,datapool,the_sigid,rs.getInt("level"),
+ rs.getBoolean("locked"),rs.getString("name"),
+ rs.getString("alias"));
+ rc.add(tmp);
+
+ } // end while
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading SIG entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve user SIG information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return new ReadOnlyVector(rc);
+
+ } // end getMemberSIGEntries
+
+ static SIGContext getSIGContext(EngineBackend engine, UserBackend user, DataPool datapool, int sigid)
+ throws DataException
+ {
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+
+ // create the query to find the SIG in the table
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT signame, alias FROM sigs WHERE sigid = ");
+ sql.append(sigid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ { // the SIG entry was not found
+ logger.error("SIG " + String.valueOf(sigid) + " not found in database");
+ throw new DataException("SIG #" + String.valueOf(sigid) + " was not found in the database.");
+
+ } // end if
+
+ // initialize the object and check membership info
+ SIGUserContextImpl sc = new SIGUserContextImpl(engine,user,datapool,sigid,rs.getString("signame"),
+ rs.getString("alias"));
+ sc.checkMembership(conn);
+ return sc;
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading SIG entry: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve SIG information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getSIGContext
+
+ static SIGContext getSIGContext(EngineBackend engine, UserBackend user, DataPool datapool, String alias)
+ throws DataException
+ {
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+
+ // create the query to find the SIG in the table
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT sigid, signame FROM sigs WHERE alias = '");
+ sql.append(SQLUtil.encodeString(alias)).append("';");
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ { // no SIG entry found...
+ logger.error("SIG '" + alias + "' not found in the database");
+ throw new DataException("The SIG '" + alias + "' was not found in the database.");
+
+ } // end if
+
+ // initialize the object and check membership info
+ SIGUserContextImpl sc = new SIGUserContextImpl(engine,user,datapool,rs.getInt("sigid"),
+ rs.getString("signame"),alias);
+ sc.checkMembership(conn);
+ return sc;
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading SIG entry: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve SIG information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getSIGContext
+
+ static List searchForSIGs(EngineBackend engine, UserBackend user, DataPool datapool, int field,
+ int mode, String term, int offset, int count) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("SIG search: field = " + String.valueOf(field) + ", mode = " + String.valueOf(mode)
+ + ", term '" + term + "', offset = " + String.valueOf(offset) + ", count = "
+ + String.valueOf(count));
+
+ Vector rc = new Vector(); // return from this function
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT sigid, signame, alias FROM sigs WHERE ");
+
+ switch (field)
+ {
+ case SearchMode.FIELD_SIG_NAME:
+ sql.append("signame ");
+ break;
+
+ case SearchMode.FIELD_SIG_SYNOPSIS:
+ sql.append("synopsis ");
+ break;
+
+ default:
+ throw new DataException("invalid search field specified");
+
+ } // end switch
+
+ switch (mode)
+ { // compose SQL in different ways depending on the search term
+ case SearchMode.SEARCH_PREFIX:
+ sql.append("LIKE '").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_SUBSTRING:
+ sql.append("LIKE '%").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_REGEXP:
+ sql.append("REGEXP '").append(SQLUtil.encodeString(term)).append('\'');
+ break;
+
+ default:
+ throw new DataException("invalid search mode specified");
+
+ } // end switch
+
+ if (Capability.hideHiddenSearchSIGs(user.realBaseLevel()))
+ sql.append(" AND hide_search = 0");
+ sql.append(" ORDER BY signame LIMIT ").append(offset).append(", ").append(count+1).append(';');
+
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // launch the search!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ while (rs.next())
+ { // load all matching SIGs into the recordset
+ SIGUserContextImpl sc = new SIGUserContextImpl(engine,user,datapool,rs.getInt("sigid"),
+ rs.getString("signame"),rs.getString("alias"));
+ sc.checkMembership(conn);
+ SIGContext tmp = sc;
+ rc.add(tmp);
+
+ } // end while
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading SIG entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve user SIG information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return new ReadOnlyVector(rc);
+
+ } // end searchForSIGs
+
+ static int getSearchSIGCount(UserBackend user, DataPool datapool, int field, int mode, String term)
+ throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("SIG search: field = " + String.valueOf(field) + ", mode = " + String.valueOf(mode)
+ + ", term '" + term + "'");
+
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT COUNT(*) AS total FROM sigs WHERE ");
+
+ switch (field)
+ {
+ case SearchMode.FIELD_SIG_NAME:
+ sql.append("signame ");
+ break;
+
+ case SearchMode.FIELD_SIG_SYNOPSIS:
+ sql.append("synopsis ");
+ break;
+
+ default:
+ throw new DataException("invalid search field specified");
+
+ } // end switch
+
+ switch (mode)
+ { // compose SQL in different ways depending on the search term
+ case SearchMode.SEARCH_PREFIX:
+ sql.append("LIKE '").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_SUBSTRING:
+ sql.append("LIKE '%").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_REGEXP:
+ sql.append("REGEXP '").append(SQLUtil.encodeString(term)).append('\'');
+ break;
+
+ default:
+ throw new DataException("invalid search mode specified");
+
+ } // end switch
+
+ if (Capability.hideHiddenSearchSIGs(user.realBaseLevel()))
+ sql.append(" AND hide_search = 0");
+ sql.append(';');
+
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // launch the search!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ if (!(rs.next()))
+ throw new InternalStateError("getSearchSIGCount search failure (MUST have 1 row!)");
+
+ return rs.getInt("total");
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading SIG entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve user SIG information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getSearchSIGCount
+
+ static List getSIGsInCategory(EngineBackend engine, UserBackend user, DataPool datapool, int catid,
+ int offset, int count)
+ throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("reading SIGs in category " + String.valueOf(catid) + ", offset = "
+ + String.valueOf(offset) + ", count = " + String.valueOf(count));
+
+ Vector rc = new Vector(); // return from this function
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT sigid, signame, alias FROM sigs WHERE catid = ");
+ sql.append(catid);
+ if (Capability.hideHiddenDirectorySIGs(user.realBaseLevel()))
+ sql.append(" AND hide_dir = 0");
+ sql.append(" ORDER BY signame LIMIT ").append(offset).append(", ").append(count+1).append(';');
+
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // launch the search!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ while (rs.next())
+ { // load all matching SIGs into the recordset
+ SIGUserContextImpl sc = new SIGUserContextImpl(engine,user,datapool,rs.getInt("sigid"),
+ rs.getString("signame"),rs.getString("alias"));
+ sc.checkMembership(conn);
+ SIGContext tmp = sc;
+ rc.add(tmp);
+
+ } // end while
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading SIG entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve user SIG information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return new ReadOnlyVector(rc);
+
+ } // end getSIGsInCategory
+
+ static int getNumSIGsInCategory(UserBackend user, DataPool datapool, int catid) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("reading SIGs in category " + String.valueOf(catid));
+
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT COUNT(*) AS total FROM sigs WHERE catid = ");
+ sql.append(catid);
+ if (Capability.hideHiddenDirectorySIGs(user.realBaseLevel()))
+ sql.append(" AND hide_dir = 0");
+ sql.append(';');
+
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // launch the search!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ if (!(rs.next()))
+ throw new InternalStateError("getNumSIGsInCategory search failure (MUST have 1 row!)");
+
+ return rs.getInt("total");
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading SIG entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve user SIG information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getNumSIGsInCategory
+
+ /*--------------------------------------------------------------------------------
+ * Operations for use within the class only
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void checkMembership(Connection conn) throws SQLException
+ {
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT granted_lvl, locked FROM sigmember WHERE sigid = ");
+ sql.append(sigid).append(" AND uid = ").append(user.realUID()).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (rs.next())
+ { // we are a member...
+ if (logger.isDebugEnabled())
+ logger.debug("we are a member of this SIG");
+ setMemberValues(rs.getInt("granted_lvl"),true,rs.getBoolean("locked"));
+
+ } // end if
+ else
+ { // we're NOT a member...
+ if (logger.isDebugEnabled())
+ logger.debug("we are NOT a member of this SIG");
+ setMemberValues(0,false,false);
+
+ } // end else
+
+ } // end checkMembership
+
+} // end class SIGUserContextImpl
diff --git a/src/com/silverwrist/venice/core/impl/SimpleEmailer.java b/src/com/silverwrist/venice/core/impl/SimpleEmailer.java
new file mode 100644
index 0000000..e9213ac
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/SimpleEmailer.java
@@ -0,0 +1,129 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.util.*;
+import javax.mail.*;
+import javax.mail.internet.*;
+import com.silverwrist.venice.core.EmailException;
+import com.silverwrist.venice.core.InternalStateError;
+
+class SimpleEmailer
+{
+ private Session session; // the email session
+ private MimeMessage msg; // the message being composed
+
+ public SimpleEmailer(Properties props, javax.mail.Session session)
+ {
+ this.session = session;
+ msg = new MimeMessage(session);
+ try
+ { // set the X-Mailer header
+ msg.setHeader("X-Mailer",(String)(props.get("com.silverwrist.venice.email.mailer")));
+
+ } // end try
+ catch (Exception e)
+ { // do nothing - we don't really care about this too much
+ } // end catch
+
+ try
+ { // set the From address on the message
+ msg.setFrom(InternetAddress.getLocalAddress(session));
+
+ } // end try
+ catch (MessagingException me)
+ { // this should be impossible
+ throw new InternalStateError("condition should not apply to message here",me);
+
+ } // end catch
+
+ } // end constructor
+
+ public void setTo(String to) throws EmailException
+ {
+ try
+ { // create an Internet address and set the recipient to it
+ InternetAddress[] address = { new InternetAddress(to) };
+ msg.setRecipients(Message.RecipientType.TO,address);
+
+ } // end try
+ catch (AddressException e1)
+ { // the address was somehow invalid
+ throw new EmailException("invalid email recipient address",e1);
+
+ } // end catch
+ catch (MessagingException e2)
+ { // msg.setRecipients should NOT be throwing a MessageException here!
+ throw new InternalStateError("condition should not apply to message here",e2);
+
+ } // end catch
+
+ } // end setTo
+
+ public void setSubject(String subject)
+ {
+ try
+ { // set the mail message subject
+ msg.setSubject(subject);
+
+ } // end try
+ catch (MessagingException e2)
+ { // msg.setSubject should NOT be throwing a MessageException here!
+ throw new InternalStateError("condition should not apply to message here",e2);
+
+ } // end catch
+
+ } // end setSubject
+
+ public void setText(String text)
+ {
+ try
+ { // set the mail message subject
+ msg.setText(text);
+
+ } // end try
+ catch (MessagingException e2)
+ { // msg.setText should NOT be throwing a MessageException here!
+ throw new InternalStateError("condition should not apply to message here",e2);
+
+ } // end catch
+
+ } // end setText
+
+ public void send() throws EmailException
+ {
+ try
+ { // attempt to send the transport message
+ Transport.send(msg);
+
+ } // end try
+ catch (SendFailedException e1)
+ { // convert this exception into an EmailException
+ throw new EmailException("send of the email message failed: " + e1.getMessage(),e1);
+
+ } // end catch
+ catch (MessagingException e2)
+ { // msg.setText should NOT be throwing a MessageException here!
+ throw new InternalStateError("condition should not apply to message here",e2);
+
+ } // end catch
+
+ } // end send
+
+} // end class SimpleEmailer
+
diff --git a/src/com/silverwrist/venice/core/impl/Stashable.java b/src/com/silverwrist/venice/core/impl/Stashable.java
new file mode 100644
index 0000000..8464d1d
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/Stashable.java
@@ -0,0 +1,30 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import com.silverwrist.venice.core.DataException;
+
+public interface Stashable
+{
+ public abstract int getStashableUID();
+
+ public abstract void stash(Connection conn) throws DataException, SQLException;
+
+} // end interface Stashable
diff --git a/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java
new file mode 100644
index 0000000..9b0cc5e
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java
@@ -0,0 +1,785 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.db.*;
+import com.silverwrist.venice.security.AuditRecord;
+import com.silverwrist.venice.core.*;
+
+class TopicUserContextImpl implements TopicContext
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(TopicUserContextImpl.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private EngineBackend engine;
+ private ConferenceBackend conf;
+ private DataPool datapool;
+ private int topicid;
+ private short topicnum;
+ private int creator_uid;
+ private int top_message;
+ private boolean frozen;
+ private boolean archived;
+ private java.util.Date created;
+ private java.util.Date lastupdate;
+ private String name;
+ private boolean hidden;
+ private int unread;
+ private boolean deleted = false;
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ protected TopicUserContextImpl(EngineBackend engine, ConferenceBackend conf, DataPool datapool, int topicid,
+ short topicnum, int creator_uid, int top_message, boolean frozen,
+ boolean archived, java.util.Date created, java.util.Date lastupdate,
+ String name, boolean hidden, int unread)
+ {
+ this.engine = engine;
+ this.conf = conf;
+ this.datapool = datapool;
+ this.topicid = topicid;
+ this.topicnum = topicnum;
+ this.creator_uid = creator_uid;
+ this.top_message = top_message;
+ this.frozen = frozen;
+ this.archived = archived;
+ this.created = created;
+ this.lastupdate = lastupdate;
+ this.name = name;
+ this.hidden = hidden;
+ this.unread = unread;
+
+ } // end TopicUserContextImpl
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static ResultSet queryByTopic(Statement stmt, int topicid, int uid) throws SQLException
+ {
+ StringBuffer sql =
+ new StringBuffer("SELECT t.topicid, t.num, t.creator_uid, t.top_message, t.frozen, t.archived, "
+ + "t.createdate, t.lastupdate, t.name, IFNULL(s.hidden,0) AS hidden, "
+ + "(t.top_message - IFNULL(s.last_message,-1)) AS unread FROM topics t "
+ + "LEFT JOIN topicsettings s ON t.topicid = s.topicid AND s.uid = ");
+ sql.append(uid).append(" WHERE t.topicid = ").append(topicid).append(';');
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+ return stmt.executeQuery(sql.toString());
+
+ } // end queryByTopic
+
+ private void makeDeleted()
+ {
+ top_message = -1;
+ frozen = false;
+ archived = false;
+ created = null;
+ lastupdate = null;
+ name = null;
+ hidden = false;
+ unread = -1;
+ deleted = true;
+
+ } // end if
+
+ /*--------------------------------------------------------------------------------
+ * Implementatuions from interface TopicContext
+ *--------------------------------------------------------------------------------
+ */
+
+ public void refresh() throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("refreshing topic ID " + String.valueOf(topicid));
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // perform a requery of the database
+ ResultSet rs = queryByTopic(stmt,topicid,conf.realUID());
+ if (rs.next())
+ { // update the fields that are capable of changing
+ top_message = rs.getInt(4);
+ frozen = rs.getBoolean(5);
+ archived = rs.getBoolean(6);
+ lastupdate = SQLUtil.getFullDateTime(rs,8);
+ hidden = rs.getBoolean(10);
+ unread = rs.getInt(11);
+
+ } // end if
+ else // this topic must have been deleted - fsck it
+ makeDeleted();
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading topic data: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve topic information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end refresh
+
+ public int getTopicID()
+ {
+ return topicid;
+
+ } // end getTopicID
+
+ public short getTopicNumber()
+ {
+ return topicnum;
+
+ } // end getTopicNumber
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public int getUnreadMessages()
+ {
+ return unread;
+
+ } // end getUnreadMessages
+
+ public int getTotalMessages()
+ {
+ return top_message + 1;
+
+ } // end getTotalMessages
+
+ public java.util.Date getLastUpdateDate()
+ {
+ return lastupdate;
+
+ } // end getLastUpdateDate
+
+ public int getCreatorUID()
+ {
+ return creator_uid;
+
+ } // end getCreatorUID
+
+ public boolean isFrozen()
+ {
+ return frozen;
+
+ } // end isFrozen
+
+ public boolean isArchived()
+ {
+ return archived;
+
+ } // end isArchived
+
+ public java.util.Date getCreatedDate()
+ {
+ return created;
+
+ } // end getCreatedDate
+
+ public boolean isHidden()
+ {
+ return hidden;
+
+ } // end isHidden
+
+ public boolean isDeleted()
+ {
+ return deleted;
+
+ } // end isDeleted
+
+ public boolean canFreeze()
+ {
+ return conf.userCanHide();
+
+ } // end canFreeze
+
+ public boolean canArchive()
+ {
+ return conf.userCanHide();
+
+ } // end canArchive
+
+ public void setFrozen(boolean flag) throws DataException, AccessError
+ {
+ if ((frozen==flag) || deleted)
+ return; // no-op
+ if (!(conf.userCanHide()))
+ { // you can't freeze the topic!
+ logger.error("user cannot change frozen status of topic");
+ throw new AccessError("You are not permitted to freeze or unfreeze this topic.");
+
+ } // end if
+
+ Connection conn = null; // pooled database connection
+ AuditRecord ar = null; // audit record indicating success
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // create the SQL statement to freeze or unfreeze the topic
+ StringBuffer sql = new StringBuffer("UPDATE topics SET frozen = ");
+ sql.append(flag ? '1' : '0').append(" WHERE topicid = ").append(topicid).append(';');
+ if (stmt.executeUpdate(sql.toString())>0)
+ { // success! save the flag and generate an audit record
+ frozen = flag;
+ ar = new AuditRecord(AuditRecord.TOPIC_FREEZE,conf.realUID(),conf.userRemoteAddress(),
+ conf.realSIGID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic="
+ + String.valueOf(topicid),flag ? "freeze" : "unfreeze");
+
+ } // end if
+ else // somebody else must have deleted this topic
+ makeDeleted();
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error setting topic data: " + e.getMessage(),e);
+ throw new DataException("unable to set topic frozen status: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setFrozen
+
+ public void setArchived(boolean flag) throws DataException, AccessError
+ {
+ if ((archived==flag) || deleted)
+ return; // no-op
+ if (!(conf.userCanHide()))
+ { // you can't archive the topic!
+ logger.error("user cannot change archived status of topic");
+ throw new AccessError("You are not permitted to archive or unarchive this topic.");
+
+ } // end if
+
+ Connection conn = null; // pooled database connection
+ AuditRecord ar = null; // audit record indicating success
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // create the SQL statement to freeze or unfreeze the topic
+ StringBuffer sql = new StringBuffer("UPDATE topics SET archived = ");
+ sql.append(flag ? '1' : '0').append(" WHERE topicid = ").append(topicid).append(';');
+ if (stmt.executeUpdate(sql.toString())>0)
+ { // success! save the flag and generate an audit record
+ archived = flag;
+ ar = new AuditRecord(AuditRecord.TOPIC_ARCHIVE,conf.realUID(),conf.userRemoteAddress(),
+ conf.realSIGID(),"conf=" + String.valueOf(conf.realConfID()) + ",topic="
+ + String.valueOf(topicid),flag ? "archive" : "unarchive");
+
+ } // end if
+ else // somebody else must have deleted this topic
+ makeDeleted();
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error setting topic data: " + e.getMessage(),e);
+ throw new DataException("unable to set topic archived status: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setArchived
+
+ public void setHidden(boolean flag) throws DataException
+ {
+ if ((hidden==flag) || deleted)
+ return; // no-op
+
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES topicsettings WRITE, topics READ;");
+
+ try
+ { // start by trying to see if we can update topicsettings directly
+ StringBuffer sql = new StringBuffer("UPDATE topicsettings SET hidden = ");
+ sql.append(flag ? '1' : '0').append(" WHERE topicid = ").append(topicid).append(" AND uid = ");
+ sql.append(conf.realUID()).append(';');
+ if (stmt.executeUpdate(sql.toString())>0)
+ { // that was all we needed - just save the flag and exit
+ hidden = flag;
+ return;
+
+ } // end if
+
+ // OK, check: Is the topic still there?!?
+ sql.setLength(0);
+ sql.append("SELECT topicid from topics WHERE topicid = ").append(topicid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ { // the topic's been deleted - bail out
+ makeDeleted();
+ return;
+
+ } // end if
+
+ // OK, just insert a new row into topicsettings, why dontcha...
+ sql.setLength(0);
+ sql.append("INSERT INTO topicsettings (topicid, uid, hidden) VALUES (").append(topicid).append(", ");
+ sql.append(conf.realUID()).append(", ").append(flag ? '1' : '0').append(");");
+ stmt.executeUpdate(sql.toString());
+ hidden = flag; // successful completion
+
+ } // end try
+ finally
+ { // unlock the tables before we go
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error setting topic data: " + e.getMessage(),e);
+ throw new DataException("unable to set topic hidden status: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setHidden
+
+ public int getFirstUnreadMessage()
+ {
+ if (unread==0)
+ return -1;
+ else
+ return top_message - (unread - 1);
+
+ } // end getFirstUnreadMessage
+
+ public void setUnreadMessages(int count) throws DataException
+ {
+ if (count>(top_message+1)) // constrain count to [0, top_message+1]
+ count = top_message + 1;
+ else if (count<0)
+ count = 0;
+ if ((count==unread) || deleted)
+ return; // no-op
+
+ int last_msg = top_message - count;
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES confsettings WRITE, topicsettings WRITE, topics READ;");
+
+ try
+ { // start by trying to see if we can update topicsettings directly
+ StringBuffer sql = new StringBuffer("UPDATE topicsettings SET last_message = ");
+ sql.append(last_msg).append(" WHERE topicid = ").append(topicid).append(" AND uid = ");
+ sql.append(conf.realUID()).append(';');
+ if (stmt.executeUpdate(sql.toString())>0)
+ { // that was all we needed - just save the flag and exit
+ conf.touchRead(conn);
+ unread = count;
+ return;
+
+ } // end if
+
+ // OK, check: Is the topic still there?!?
+ sql.setLength(0);
+ sql.append("SELECT topicid from topics WHERE topicid = ").append(topicid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ { // the topic's been deleted - bail out
+ makeDeleted();
+ return;
+
+ } // end if
+
+ // OK, just insert a new row into topicsettings, why dontcha...
+ sql.setLength(0);
+ sql.append("INSERT INTO topicsettings (topicid, uid, last_message) VALUES (").append(topicid);
+ sql.append(", ").append(conf.realUID()).append(", ").append(last_msg).append(");");
+ stmt.executeUpdate(sql.toString());
+ conf.touchRead(conn);
+ unread = count; // successful completion
+
+ } // end try
+ finally
+ { // unlock the tables before we go
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error setting topic data: " + e.getMessage(),e);
+ throw new DataException("unable to set topic hidden status: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setUnreadMessages
+
+ public void fixSeen() throws DataException
+ {
+ setUnreadMessages(0);
+
+ } // end fixSeen
+
+ /*--------------------------------------------------------------------------------
+ * External operations usable only from within the package
+ *--------------------------------------------------------------------------------
+ */
+
+ static List getTopicList(EngineBackend engine, ConferenceBackend conf, DataPool datapool, int get_option,
+ int sort_option) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getTopicList for conf # " + String.valueOf(conf.realConfID()) + ", user #"
+ + String.valueOf(conf.realUID()));
+ Vector rc = new Vector(); // return from this function
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // Figure out what the "where" clause of the SQL statement will be. This is in addition to a
+ // WHERE t.confid = (confid) that is always present. (Some of these WHERE specifiers refer to
+ // computed fields of the SELECT.)
+ String where_clause;
+ switch (get_option)
+ {
+ case ConferenceContext.GET_ALL:
+ where_clause = null; // no filtering options
+ break;
+
+ case ConferenceContext.DISPLAY_NEW:
+ where_clause = "hidden = 0 AND unread > 0"; // only non-hidden topics w/unread messages
+ break;
+
+ case ConferenceContext.DISPLAY_ACTIVE:
+ where_clause = "t.archived = 0 AND hidden = 0"; // only non-hidden, non-archived topics
+ break;
+
+ case ConferenceContext.DISPLAY_ALL:
+ where_clause = "t.archived = 0 AND hidden = 0"; // only non-hidden, non-archived topics
+ break;
+
+ case ConferenceContext.DISPLAY_HIDDEN:
+ where_clause = "hidden = 1"; // only hidden topics
+ break;
+
+ case ConferenceContext.DISPLAY_ARCHIVED:
+ where_clause = "t.archived = 1 AND hidden = 0"; // only non-hidden, archived topics
+ break;
+
+ default:
+ logger.error("ACK! get_option (" + String.valueOf(get_option) + ") is bogus!");
+ throw new DataException("Invalid retrieval option specified.");
+
+ } // end switch
+
+ // Figure out what the "order by" clause of the SQL statement will be. In the case of
+ // DISPLAY_NEW mode, this will be in addition to an ordering clause that puts all topics
+ // with unread messages first.
+ boolean reverse = false;
+ int real_sort_option = sort_option;
+ if (sort_option<0)
+ { // did we specify a "reverse" option?
+ reverse = true;
+ real_sort_option = -sort_option;
+
+ } // end if
+
+ String order_by_clause;
+ switch (real_sort_option)
+ {
+ case ConferenceContext.SORT_TOPICID:
+ // no reverse possible here
+ order_by_clause = "t.topicid ASC";
+ break;
+
+ case ConferenceContext.SORT_NUMBER:
+ if (reverse)
+ order_by_clause = "t.num DESC";
+ else
+ order_by_clause = "t.num ASC";
+ break;
+
+ case ConferenceContext.SORT_NAME:
+ if (reverse)
+ order_by_clause = "t.name DESC, t.num DESC";
+ else
+ order_by_clause = "t.name ASC, t.num ASC";
+ break;
+
+ case ConferenceContext.SORT_UNREAD:
+ if (reverse)
+ order_by_clause = "unread ASC, t.num DESC";
+ else
+ order_by_clause = "unread DESC, t.num ASC";
+ break;
+
+ case ConferenceContext.SORT_TOTAL:
+ if (reverse)
+ order_by_clause = "t.top_message ASC, t.num DESC";
+ else
+ order_by_clause = "t.top_message DESC, t.num ASC";
+ break;
+
+ case ConferenceContext.SORT_DATE:
+ if (reverse)
+ order_by_clause = "t.lastupdate ASC, t.num DESC";
+ else
+ order_by_clause = "t.lastupdate DESC, t.num ASC";
+ break;
+
+ default:
+ logger.error("ACK! sort_option (" + String.valueOf(sort_option) + ") is bogus!");
+ throw new DataException("Invalid sort option specified.");
+
+ } // end switch
+
+ // Build the huge SQL statement to feed to the database.
+ StringBuffer sql =
+ new StringBuffer("SELECT t.topicid, t.num, t.creator_uid, t.top_message, t.frozen, t.archived, "
+ + "t.createdate, t.lastupdate, t.name, IFNULL(s.hidden,0) AS hidden, "
+ + "(t.top_message - IFNULL(s.last_message,-1)) AS unread");
+ if (get_option==ConferenceContext.DISPLAY_ACTIVE)
+ sql.append(", SIGN(t.top_message - IFNULL(s.last_message,-1)) AS newflag");
+ sql.append(" FROM topics t LEFT JOIN topicsettings s ON t.topicid = s.topicid AND s.uid = ");
+ sql.append(conf.realUID()).append(" WHERE t.confid = ").append(conf.realConfID());
+ if (where_clause!=null)
+ sql.append(" AND ").append(where_clause);
+ sql.append(" ORDER BY ");
+ if (get_option==ConferenceContext.DISPLAY_ACTIVE)
+ sql.append("newflag DESC, ");
+ sql.append(order_by_clause).append(';');
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // Now pass this query off to the database!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ while (rs.next())
+ { // create the returned objects and add them to the vector
+ TopicContext top =
+ new TopicUserContextImpl(engine,conf,datapool,rs.getInt(1),rs.getShort(2),rs.getInt(3),
+ rs.getInt(4),rs.getBoolean(5),rs.getBoolean(6),
+ SQLUtil.getFullDateTime(rs,7),SQLUtil.getFullDateTime(rs,8),
+ rs.getString(9),rs.getBoolean(10),rs.getInt(11));
+ rc.add(top);
+
+ } // end while
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading topic entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve topic information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return new ReadOnlyVector(rc);
+
+ } // end getTopicList
+
+ static TopicContext getTopicByID(EngineBackend engine, ConferenceBackend conf, DataPool datapool,
+ int topicid) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getTopicByID for topic # " + String.valueOf(topicid) + ", user #"
+ + String.valueOf(conf.realUID()));
+
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // Query the dtabase by topic ID.
+ ResultSet rs = queryByTopic(stmt,topicid,conf.realUID());
+ if (rs.next()) // found it!
+ return new TopicUserContextImpl(engine,conf,datapool,topicid,rs.getShort(2),rs.getInt(3),
+ rs.getInt(4),rs.getBoolean(5),rs.getBoolean(6),
+ SQLUtil.getFullDateTime(rs,7),SQLUtil.getFullDateTime(rs,8),
+ rs.getString(9),rs.getBoolean(10),rs.getInt(11));
+ // else fall out and return null
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading topic entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve topic information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return null; // default return
+
+ } // end getTopicByID
+
+ static TopicContext getTopicByNumber(EngineBackend engine, ConferenceBackend conf, DataPool datapool,
+ short topicnum) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getTopicByNumber for topic # " + String.valueOf(topicnum) + ", conf # "
+ + String.valueOf(conf.realConfID()) + ", user #" + String.valueOf(conf.realUID()));
+
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // Build the database query.
+ StringBuffer sql =
+ new StringBuffer("SELECT t.topicid, t.num, t.creator_uid, t.top_message, t.frozen, t.archived, "
+ + "t.createdate, t.lastupdate, t.name, IFNULL(s.hidden,0) AS hidden, "
+ + "(t.top_message - IFNULL(s.last_message,-1)) AS unread FROM topics t "
+ + "LEFT JOIN topicsettings s ON t.topicid = s.topicid AND s.uid = ");
+ sql.append(conf.realUID()).append(" WHERE t.confid = ").append(conf.realConfID());
+ sql.append(" AND t.num = ").append(topicnum).append(';');
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // Now pass this query off to the database!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (rs.next()) // found it!
+ return new TopicUserContextImpl(engine,conf,datapool,rs.getInt(1),topicnum,rs.getInt(3),
+ rs.getInt(4),rs.getBoolean(5),rs.getBoolean(6),
+ SQLUtil.getFullDateTime(rs,7),SQLUtil.getFullDateTime(rs,8),
+ rs.getString(9),rs.getBoolean(10),rs.getInt(11));
+ // else fall out and return null
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading topic entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve topic information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return null; // default return
+
+ } // end getTopicByNumber
+
+} // end class TopicUserContextImpl
diff --git a/src/com/silverwrist/venice/core/impl/UserBackend.java b/src/com/silverwrist/venice/core/impl/UserBackend.java
new file mode 100644
index 0000000..c51ee47
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/UserBackend.java
@@ -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 Community 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.core.impl;
+
+import com.silverwrist.venice.core.DataException;
+
+public interface UserBackend
+{
+ public abstract int realUID();
+
+ public abstract int realBaseLevel();
+
+ public abstract String userRemoteAddress();
+
+ public abstract String userDefaultPseud() throws DataException;
+
+} // end interface UserBackend
diff --git a/src/com/silverwrist/venice/core/impl/UserContextImpl.java b/src/com/silverwrist/venice/core/impl/UserContextImpl.java
new file mode 100644
index 0000000..2446cc6
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/UserContextImpl.java
@@ -0,0 +1,988 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.log4j.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.db.*;
+import com.silverwrist.venice.security.PasswordHash;
+import com.silverwrist.venice.security.Capability;
+import com.silverwrist.venice.security.DefaultLevels;
+import com.silverwrist.venice.security.AuditRecord;
+
+class UserContextImpl implements UserContext, UserBackend
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(UserContextImpl.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private EngineBackend engine; // the back end of the engine
+ private DataPool datapool; // the data pool used by this object
+ private String remote_addr; // remote address identifier
+ private int uid = -1; // the user ID we're using
+ private int contactid; // ID of our contact information
+ private int level; // base security level for this user
+ private int confirm_num; // email confirmation number for this user
+ private boolean is_anon = false; // is this the anonymous user?
+ private boolean email_verified = false; // has email address been verified?
+ private String username; // the user name we're using
+ private java.util.Date created; // when was this user created? (GMT)
+ private java.util.Date last_access; // when did we last log in? (GMT)
+ private String description; // personal description
+ private String my_email = null; // my email address (cached)
+ private String my_pseud = null; // my pseud (cached)
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ UserContextImpl(EngineBackend engine, DataPool datapool)
+ {
+ this.engine = engine;
+ this.datapool = datapool;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * finalize() method
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void finalize()
+ {
+ engine = null;
+ datapool = null;
+ username = null;
+ created = null;
+ last_access = null;
+
+ } // end finalize
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private void loadUserData(ResultSet rs) throws SQLException
+ {
+ uid = rs.getInt("uid");
+ username = rs.getString("username");
+ // skip field "passhash"
+ contactid = rs.getInt("contactid");
+ is_anon = rs.getBoolean("is_anon");
+ email_verified = rs.getBoolean("verify_email");
+ // skip fields "lockout", "access_tries"
+ confirm_num = rs.getInt("email_confnum");
+ level = rs.getInt("base_lvl");
+ created = SQLUtil.getFullDateTime(rs,"created");
+ last_access = SQLUtil.getFullDateTime(rs,"lastaccess");
+ // skip field "passreminder"
+ description = rs.getString("description");
+
+ if (logger.isDebugEnabled())
+ { // spit it all out to debug info
+ logger.debug("Loaded: UID " + String.valueOf(uid) + ", username \"" + username + "\", contactid "
+ + String.valueOf(contactid));
+ logger.debug("...is_anon " + String.valueOf(is_anon) + ", email_verified "
+ + String.valueOf(email_verified));
+ logger.debug("... level " + String.valueOf(level));
+
+ } // end if
+
+ } // end loadUserData
+
+ private void sendEmailConfirmation() throws DataException, EmailException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("sendEmailConfirmation(): sending to \"" + my_email + "\"");
+
+ // Create the message to be sent.
+ String message = engine.getStockMessage("email-confirm");
+ if (message==null)
+ { // no message defined? oy!
+ logger.error("internal error condition: email-confirm stock message not defined");
+ throw new DataException("INTERNAL: email-confirm message not defined");
+
+ } // end if
+
+ message = StringUtil.replaceAllInstances(message,"$USERNAME",username);
+ message = StringUtil.replaceAllInstances(message,"$CONFNUM",String.valueOf(confirm_num));
+
+ // Create the emailer and send the message.
+ SimpleEmailer emailer = engine.createEmailer();
+ emailer.setTo(my_email);
+ emailer.setSubject("Venice Email Confirmation");
+ emailer.setText(message);
+ emailer.send();
+ if (logger.isDebugEnabled())
+ logger.debug("...email sent!");
+
+ } // end sendEmailConfirmation
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface UserContext
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getUID()
+ {
+ return uid;
+
+ } // end getUID
+
+ public String getUserName()
+ {
+ return username;
+
+ } // end getUserName
+
+ public int getContactID()
+ {
+ return contactid;
+
+ } // end getContactID
+
+ public String getDescription()
+ {
+ return description;
+
+ } // end getDescription
+
+ public boolean isLoggedIn()
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("isLoggedIn(): uid = " + String.valueOf(uid) + ", is_anon = " + String.valueOf(is_anon));
+ return ((uid!=-1) && !is_anon);
+
+ } // end is_logged_in
+
+ public boolean isEmailVerified()
+ {
+ return email_verified;
+
+ } // end isEmailVerified
+
+ public void authenticate(String username, String password) throws AccessError, DataException
+ {
+ if (isLoggedIn())
+ { // already authenticated, can't authenticate again
+ logger.error("UserContext already authenticated (with uid " + String.valueOf(uid) + ")");
+ throw new InternalStateError("context already authenticated");
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("authenticate(): authenticating user \"" + username + "\"...");
+
+ Connection conn = null;
+ AuditRecord ar = null;
+
+ try
+ { // look for a user name matching this user record
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE username = '"
+ + SQLUtil.encodeString(username) + "';");
+
+ if (!(rs.next()))
+ { // user not found
+ logger.error("...user not found");
+ ar = new AuditRecord(AuditRecord.LOGIN_FAIL,0,remote_addr,"Bad username: " + username);
+ throw new AccessError("The user account you have specified does not exist. Please try again.");
+
+ } // end if
+
+ int the_uid = rs.getInt("uid");
+
+ if (rs.getBoolean("is_anon"))
+ { // can't log in as Anonymous Honyak
+ logger.error("...user is the Anonymous Honyak, can't explicitly login");
+ ar = new AuditRecord(AuditRecord.LOGIN_FAIL,the_uid,remote_addr,"Anonymous user");
+ throw new AccessError("This account cannot be explicitly logged into. Please try again.");
+
+ } // end if
+
+ if (rs.getBoolean("lockout"))
+ { // account locked out
+ logger.error("...user is locked out by the Admin");
+ ar = new AuditRecord(AuditRecord.LOGIN_FAIL,the_uid,remote_addr,"Account locked out");
+ throw new AccessError("This account has been administratively locked out. Please contact "
+ + "the system administrator for assistance.");
+
+ } // end if
+
+ // hash the password and compare it to the stored password hash
+ PasswordHash phash = new PasswordHash(password);
+ if (!(phash.equals(rs.getString("passhash"))))
+ { // they specified an incorrect password
+ // TODO: advance an "invalid" counter and lock the account out if more than X tries
+ logger.warn("...invalid password");
+ ar = new AuditRecord(AuditRecord.LOGIN_FAIL,the_uid,remote_addr,"Bad password");
+ throw new AccessError("The password you have specified is incorrect. Please try again.");
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("...authenticated");
+
+ // we're authenticated - load the user data into the context
+ loadUserData(rs);
+
+ // update the "last access" time in the database
+ java.util.Date mydate = new java.util.Date();
+ stmt.executeUpdate("UPDATE users SET lastaccess = '" + SQLUtil.encodeDate(mydate)
+ + "' WHERE uid = " + uid + ";");
+
+ // update the "last access" time in this object
+ last_access = mydate;
+
+ // an audit record indicating we logged in OK
+ ar = new AuditRecord(AuditRecord.LOGIN_OK,the_uid,remote_addr);
+
+ if (logger.isDebugEnabled())
+ logger.debug("...context loaded, we're ready :-)");
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error reading user data: " + e.getMessage(),e);
+ throw new DataException("unable to access user data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end if
+
+ } // end authenticate
+
+ public void confirmEmail(int conf_num) throws AccessError, DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("confirmEmail(): confirming for UID " + String.valueOf(uid));
+ if ((email_verified) || Capability.exemptFromEmailVerification(level))
+ { // already confirmed
+ if (logger.isDebugEnabled())
+ logger.debug("...user has either already confirmed or is exempt");
+ return;
+
+ } // end if
+
+ AuditRecord ar = null;
+
+ if (conf_num!=confirm_num)
+ { // the confirmation number is wrong
+ logger.warn("...confirmation number incorrect");
+ ar = new AuditRecord(AuditRecord.VERIFY_FAIL,uid,remote_addr,"Invalid confirmation number");
+ engine.saveAuditRecord(ar);
+ throw new AccessError("Confirmation number is incorrect. Please try again.");
+
+ } // end if
+
+ Connection conn = null;
+
+ try
+ { // get a connection and set the user's status to reflect the verification
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 1, base_lvl = ");
+ sql.append(DefaultLevels.afterEmailVerification()).append(" WHERE uid = ").append(uid).append(';');
+ stmt.executeUpdate(sql.toString());
+ email_verified = true;
+ level = DefaultLevels.afterEmailVerification();
+
+ // record an audit message indicating that we verified OK
+ ar = new AuditRecord(AuditRecord.VERIFY_OK,uid,remote_addr);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error updating user data: " + e.getMessage(),e);
+ throw new DataException("unable to update user data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end if
+
+ } // end confirmEmail
+
+ public void resendEmailConfirmation() throws DataException, EmailException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("resendEmailConfirmation(): resending for UID " + String.valueOf(uid));
+ if ((email_verified) || Capability.exemptFromEmailVerification(level))
+ { // already confirmed, no need to resend
+ if (logger.isDebugEnabled())
+ logger.debug("...user has either already confirmed or is exempt");
+ return;
+
+ } // end if
+
+ if (my_email==null)
+ getContactInfo(); // forces my_email to be updated
+
+ Connection conn = null;
+ AuditRecord ar = null;
+ try
+ { // need to change the user's email confirmation number first
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // generate new confirmation number
+ int new_confirm_num = engine.getNewConfirmationNumber();
+
+ // create an SQL statement to reset the user account information, and execute it
+ StringBuffer sql = new StringBuffer("UPDATE users SET email_confnum = ");
+ sql.append(new_confirm_num).append(" WHERE uid = ").append(uid).append(';');
+ stmt.executeUpdate(sql.toString());
+
+ confirm_num = new_confirm_num; // save changed value
+
+ // now send the email confirmation!
+ sendEmailConfirmation();
+
+ // log that a resend was performed...
+ ar = new AuditRecord(AuditRecord.RESEND_CONFIRM,uid,remote_addr);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error updating user data: " + e.getMessage(),e);
+ throw new DataException("unable to update user data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end if
+
+ } // end resendEmailConfirmation
+
+ public ContactInfo getContactInfo() throws DataException
+ {
+ ContactInfoImpl rc;
+ if (contactid>=0)
+ rc = new ContactInfoImpl(datapool,contactid);
+ else
+ rc = new ContactInfoImpl(uid);
+ if (my_email==null)
+ my_email = rc.getEmail();
+ if (my_pseud==null)
+ my_pseud = rc.getGivenName() + " " + rc.getFamilyName();
+ return rc;
+
+ } // end getContactInfo
+
+ public boolean putContactInfo(ContactInfo ci) throws DataException, EmailException
+ {
+ boolean email_changed = false;
+ if ((ci.getOwnerUID()!=uid) || (ci.getOwnerSIGID()>=0))
+ { // the contact information is not owned correctly
+ logger.error("ContactInfo ownership wrong (it's " + String.valueOf(ci.getOwnerUID()) + ", "
+ + String.valueOf(ci.getOwnerSIGID()) + "), should be (" + String.valueOf(uid) + ", -1)");
+ throw new DataException("invalid contact information record");
+
+ } // end if
+
+ if (is_anon)
+ { // we can't change Anonymous Honyak this way!
+ logger.error("cannot modify anonymous user contact info");
+ throw new DataException("unmodifiable contact information");
+
+ } // end if
+
+ Connection conn = null; // database connection
+ AuditRecord ar = null; // audit record
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Stashable obj = (Stashable)ci;
+
+ // save the contact information
+ obj.stash(conn);
+
+ if (contactid<0)
+ { // contact being established for the first time
+ contactid = ci.getContactID();
+ if (logger.isDebugEnabled())
+ logger.debug("...established initial contact (" + String.valueOf(contactid) + ") for user");
+ my_email = ci.getEmail();
+ sendEmailConfirmation();
+ email_changed = true;
+
+ } // end if
+
+ my_pseud = ci.getGivenName() + " " + ci.getFamilyName(); // update this field
+
+ if (my_email==null) // filling in, this is not necessarily the first time
+ my_email = ci.getEmail();
+ else if (!(my_email.equals(ci.getEmail())) && !Capability.exemptFromEmailVerification(level))
+ { // email address change - need to reconfirm - but choose a new confirmation
+ // number and save it in the database first; also turn off the verify flag
+ // and set the base level to GLOBAL_UNVERIFIED
+ // NOTE: Administrators are exempt from this requirement!
+
+ if (logger.isDebugEnabled())
+ logger.debug("email address changed, need to reconfirm");
+
+ // generate new confirmation number
+ int new_confirm_num = engine.getNewConfirmationNumber();
+
+ // create an SQL statement to reset the user account information, and execute it
+ StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 0, email_confnum = ");
+ sql.append(new_confirm_num).append(", base_lvl = ").append(DefaultLevels.afterEmailAddressChange());
+ sql.append(" WHERE uid = ").append(uid).append(';');
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate(sql.toString());
+
+ // save off changed data
+ email_verified = false;
+ confirm_num = new_confirm_num;
+ level = DefaultLevels.afterEmailAddressChange();
+
+ // now send the email confirmation!
+ sendEmailConfirmation();
+
+ email_changed = true;
+
+ } // end else if
+
+ ar = new AuditRecord(AuditRecord.USER_CONTACT_INFO,uid,remote_addr,
+ "contactid=" + String.valueOf(contactid));
+
+ } // end try
+ catch (ClassCastException cce)
+ { // we need to be able to coerce the ContactInfo to a Stashable
+ logger.error("ContactInfo needs to be a Stashable for this to work");
+ throw new DataException("improper contact information record");
+
+ } // end catch
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error updating contact info: " + e.getMessage(),e);
+ throw new DataException("unable to access user contact data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end if
+
+ return email_changed;
+
+ } // end putContactInfo
+
+ public UserProfile getProfile(String xusername) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getProfile(\"" + xusername + "\")...");
+ Connection conn = null;
+
+ try
+ { // retrieve a connection from the data pool
+ conn = datapool.getConnection();
+ UserProfileImpl prof = new UserProfileImpl(engine,conn,xusername,
+ Capability.canSeeHiddenContactFields(level));
+ if (logger.isDebugEnabled())
+ logger.debug("...found it!");
+ return prof;
+
+ } // end catch
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error looking up profile information: " + e.getMessage(),e);
+ throw new DataException("Unable to look up user info: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getProfile
+
+ public UserProfile getProfile(int xuid) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("getProfile(#" + String.valueOf(xuid) + ")...");
+ Connection conn = null;
+
+ try
+ { // retrieve a connection from the data pool
+ conn = datapool.getConnection();
+ UserProfileImpl prof = new UserProfileImpl(engine,conn,xuid,Capability.canSeeHiddenContactFields(level));
+ if (logger.isDebugEnabled())
+ logger.debug("...found it!");
+ return prof;
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error looking up profile information: " + e.getMessage(),e);
+ throw new DataException("Unable to look up user info: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getProfile
+
+ public void setPassword(String password, String reminder) throws DataException
+ {
+ if (is_anon)
+ { // trying to change Anonymous Honyak's (nonexistent) password?
+ logger.error("cannot change password of anonymous account");
+ throw new DataException("The anonymous account cannot change its password.");
+
+ } // end if
+
+ Connection conn = null;
+ AuditRecord ar = null;
+
+ try
+ { // retrieve a connection from the data pool
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ PasswordHash phash = new PasswordHash(password);
+ StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
+ sql.append(phash.toString()).append("', passreminder = '").append(SQLUtil.encodeString(reminder));
+ sql.append("' WHERE uid = ").append(uid).append(';');
+ stmt.executeUpdate(sql.toString());
+
+ // record an audit record for this user
+ ar = new AuditRecord(AuditRecord.PASSWORD_CHANGE,uid,remote_addr);
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error changing password: " + e.getMessage(),e);
+ throw new DataException("Unable to set user password: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setPassword
+
+ public void setDescription(String new_descr) throws DataException
+ {
+ if (is_anon)
+ { // trying to change Anonymous Honyak's (nonexistent) description?
+ logger.error("cannot change description of anonymous account");
+ throw new DataException("The anonymous account cannot change its description.");
+
+ } // end if
+
+ Connection conn = null;
+
+ try
+ { // retrieve a connection from the data pool
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("UPDATE users SET description = '");
+ sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';');
+ stmt.executeUpdate(sql.toString());
+
+ description = new_descr; // change stored information
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error changing description: " + e.getMessage(),e);
+ throw new DataException("Unable to set user description: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end setDescription
+
+ public FrontPageViewConfig getFrontPageViewConfig(int max_cols) throws DataException
+ {
+ Connection conn = null;
+
+ try
+ { // retrieve a connection from the data pool
+ conn = datapool.getConnection();
+
+ // create new object
+ return new FrontPageViewConfigImpl(conn,uid,max_cols);
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error getting front page view config: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve front page view config: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getFrontPageViewConfig
+
+ public void putFrontPageViewConfig(FrontPageViewConfig cfg) throws DataException
+ {
+ Connection conn = null;
+
+ try
+ { // coerce the value to a Stashable first
+ Stashable obj = (Stashable)cfg;
+ if (obj.getStashableUID()!=uid)
+ { // wrong UID for configuration - this is bogus
+ logger.error("invalid ownership of FrontPageViewConfig (was "
+ + String.valueOf(obj.getStashableUID()) + ", should be " + String.valueOf(uid) + ")");
+ throw new DataException("invalid front page view config record");
+
+ } // end if
+
+ // retrieve a connection from the data pool
+ conn = datapool.getConnection();
+
+ // stash the object
+ obj.stash(conn);
+
+ } // end try
+ catch (ClassCastException cce)
+ { // we need to be able to coerce the FrontPageViewConfig to a Stashable
+ logger.error("FrontPageViewConfig was not a Stashable");
+ throw new DataException("improper front page view config record");
+
+ } // end catch
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error saving front page view config: " + e.getMessage(),e);
+ throw new DataException("unable to save front page view config: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end putFrontPageViewConfig
+
+ public List getMemberSIGs() throws DataException
+ {
+ return SIGUserContextImpl.getMemberSIGEntries(engine,this,datapool);
+
+ } // end getMemberSIGs
+
+ public SIGContext getSIGContext(int sigid) throws DataException
+ {
+ return SIGUserContextImpl.getSIGContext(engine,this,datapool,sigid);
+
+ } // end getSIGContext
+
+ public SIGContext getSIGContext(String alias) throws DataException
+ {
+ return SIGUserContextImpl.getSIGContext(engine,this,datapool,alias);
+
+ } // end getSIGContext
+
+ public List getRootCategoryList() throws DataException
+ {
+ return CategoryDescriptorImpl.getTopLevelCategoryList(datapool,Capability.hideHiddenCategories(level));
+
+ } // end getRootCategoryList
+
+ public CategoryDescriptor getCategoryDescriptor(int catid) throws DataException
+ {
+ return new CategoryDescriptorImpl(datapool,catid,Capability.hideHiddenCategories(level));
+
+ } // end getCategoryDescriptor
+
+ public List searchForSIGs(int field, int mode, String term, int offset, int count) throws DataException
+ {
+ return SIGUserContextImpl.searchForSIGs(engine,this,datapool,field,mode,term,offset,count);
+
+ } // end searchForSIGs
+
+ public int getSearchSIGCount(int field, int mode, String term) throws DataException
+ {
+ return SIGUserContextImpl.getSearchSIGCount(this,datapool,field,mode,term);
+
+ } // end getSearchSIGCount
+
+ public List getSIGsInCategory(int catid, int offset, int count) throws DataException
+ {
+ return SIGUserContextImpl.getSIGsInCategory(engine,this,datapool,catid,offset,count);
+
+ } // end getSIGsInCategory
+
+ public List getSIGsInCategory(CategoryDescriptor cat, int offset, int count) throws DataException
+ {
+ return SIGUserContextImpl.getSIGsInCategory(engine,this,datapool,cat.getLinkedCategoryID(),offset,count);
+
+ } // end getSIGsInCategory
+
+ public int getNumSIGsInCategory(int catid) throws DataException
+ {
+ return SIGUserContextImpl.getNumSIGsInCategory(this,datapool,catid);
+
+ } // end getNumSIGsInCategory
+
+ public int getNumSIGsInCategory(CategoryDescriptor cat) throws DataException
+ {
+ return SIGUserContextImpl.getNumSIGsInCategory(this,datapool,cat.getLinkedCategoryID());
+
+ } // end getNumSIGsInCategory
+
+ public List searchForCategories(int mode, String term, int offset, int count) throws DataException
+ {
+ return CategoryDescriptorImpl.searchForCategories(datapool,Capability.hideHiddenCategories(level),
+ Capability.showHiddenSearchCategories(level),mode,
+ term,offset,count);
+
+ } // end searchForCategories
+
+ public int getSearchCategoryCount(int mode, String term) throws DataException
+ {
+ return CategoryDescriptorImpl.getSearchCategoryCount(datapool,Capability.hideHiddenCategories(level),
+ Capability.showHiddenSearchCategories(level),
+ mode,term);
+
+ } // end getSearchCategoryCount
+
+ public SIGContext createSIG(String name, String alias, String language, String synopsis, String rules,
+ String joinkey, int hide_mode) throws DataException, AccessError
+ {
+ if (!(Capability.canCreateSIG(level)))
+ throw new AccessError("You are not authorized to create new SIGs.");
+
+ // Convert the "hide mode" value int othe two hide flags.
+ boolean hide_dir = (hide_mode!=SIGContext.HIDE_NONE);
+ boolean hide_search = (hide_mode==SIGContext.HIDE_BOTH);
+
+ // Create the new SIG's database entries and internal data.
+ SIGData new_sig = SIGCoreData.createSIG(engine,this,datapool,name,alias,uid,language,synopsis,rules,
+ joinkey,hide_dir,hide_search);
+
+ // Create the SIG context we return to the user.
+ SIGContext rc = new SIGUserContextImpl(engine,this,datapool,new_sig);
+
+ new_sig.rd_release(); // release the extra reference we have on SIGData
+
+ // And that's it! You expected lightning bolts maybe? :-)
+
+ return rc;
+
+ } // end createSIG
+
+ public boolean canCreateSIG()
+ {
+ return Capability.canCreateSIG(level);
+
+ } // end canCreateSIG
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface UserBackend
+ *--------------------------------------------------------------------------------
+ */
+
+ public int realUID()
+ {
+ return uid;
+
+ } // end realUID
+
+ public int realBaseLevel()
+ {
+ return level;
+
+ } // end realBaseLevel
+
+ public String userRemoteAddress()
+ {
+ return remote_addr;
+
+ } // end userRemoteAddress
+
+ public String userDefaultPseud() throws DataException
+ {
+ if (my_pseud==null)
+ getContactInfo();
+ return my_pseud;
+
+ } // end userDefaultPseud
+
+ /*--------------------------------------------------------------------------------
+ * Operations private to implementation package
+ *--------------------------------------------------------------------------------
+ */
+
+ void loadAnonymous(String remote_addr) throws DataException
+ {
+ Connection conn = null;
+ if (logger.isDebugEnabled())
+ logger.debug("loadAnonymous() on UserContext: addr " + remote_addr);
+
+ try
+ { // retrieve a connection from the data pool
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE is_anon = 1;");
+ if (!(rs.next()))
+ { // could not find the anonymous user - this is an internal error
+ logger.error("WTF? anonymous user not found?!?");
+ throw new DataException("INTERNAL ERROR - cannot find anonymous user");
+
+ } // end if
+
+ loadUserData(rs); // load the data for Anonymous Honyak
+
+ this.remote_addr = remote_addr;
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("error loading anonymous user data: " + e.getMessage(),e);
+ throw new DataException("unable to access user data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end loadAnonymous
+
+ void loadNewUser(String remote_addr, int uid, int level, String username, int confirm_num,
+ java.util.Date created, java.util.Date last_access)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("loadNewUser() on UserContext: addr " + remote_addr + ", uid " + String.valueOf(uid)
+ + ", level " + String.valueOf(level) + ", username \"" + username + "\"");
+
+ this.remote_addr = remote_addr;
+ this.uid = uid;
+ this.contactid = -1;
+ this.level = level;
+ this.username = username;
+ this.confirm_num = confirm_num;
+ this.created = created;
+ this.last_access = last_access;
+
+ } // end loadNewUser
+
+} // end class UserContextImpl
diff --git a/src/com/silverwrist/venice/core/impl/UserFoundImpl.java b/src/com/silverwrist/venice/core/impl/UserFoundImpl.java
new file mode 100644
index 0000000..a1578f1
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/UserFoundImpl.java
@@ -0,0 +1,132 @@
+/*
+ * 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 Community 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.core.impl;
+
+import com.silverwrist.venice.core.*;
+
+class UserFoundImpl implements UserFound
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private int uid;
+ private String name;
+ private String description;
+ private String given_name;
+ private String family_name;
+ private String locality;
+ private String region;
+ private String country;
+ private int level = -1;
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ UserFoundImpl(int uid, String name, String description, String given_name, String family_name,
+ String locality, String region, String country)
+ {
+ this.uid = uid;
+ this.name = name;
+ this.description = description;
+ this.given_name = given_name;
+ this.family_name = family_name;
+ this.locality = locality;
+ this.region = region;
+ this.country = country;
+
+ } // end constructor
+
+ UserFoundImpl(int uid, String name, String description, String given_name, String family_name,
+ String locality, String region, String country, int level)
+ {
+ this.uid = uid;
+ this.name = name;
+ this.description = description;
+ this.given_name = given_name;
+ this.family_name = family_name;
+ this.locality = locality;
+ this.region = region;
+ this.country = country;
+ this.level = level;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface UserFound
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getUID()
+ {
+ return uid;
+
+ } // end getUID
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String getDescription()
+ {
+ return description;
+
+ } // end getDescription
+
+ public String getGivenName()
+ {
+ return given_name;
+
+ } // end getGivenName
+
+ public String getFamilyName()
+ {
+ return family_name;
+
+ } // end getFamilyName
+
+ public String getLocality()
+ {
+ return locality;
+
+ } // end getLocality
+
+ public String getRegion()
+ {
+ return region;
+
+ } // end getRegion
+
+ public String getCountry()
+ {
+ return country;
+
+ } // end getCountry
+
+ public int getLevel()
+ {
+ return level;
+
+ } // end getLevel
+
+} // end class UserFoundImpl
diff --git a/src/com/silverwrist/venice/core/impl/UserProfileImpl.java b/src/com/silverwrist/venice/core/impl/UserProfileImpl.java
new file mode 100644
index 0000000..e8483dd
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/UserProfileImpl.java
@@ -0,0 +1,347 @@
+/*
+ * 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 Community 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.db.*;
+
+class UserProfileImpl implements UserProfile
+{
+ private EngineBackend engine; // the engine back end
+ private int uid; // user ID
+ private String username; // user name
+ private String given_name; // given name ("first name")
+ private String family_name; // family name ("last name")
+ private char middle_initial; // middle initial (natch)
+ private String prefix; // prefix (Mr., Ms., Prof., Dr., etc.)
+ private String suffix; // suffix (Jr., III, etc.)
+ private String company; // company name
+ private String addr1; // address line 1
+ private String addr2; // address line 2
+ private String locality; // locality ("city")
+ private String region; // region ("state")
+ private String postal_code; // postal code ("ZIP code")
+ private String country; // 2-character ISO 3166 country code
+ private String phone; // voice phone number
+ private String fax; // facsimile (fax) number
+ private String mobile; // mobile phone (cellphone) number
+ private String email; // email address
+ private String photo_url; // URL of user photo
+ private String url; // URL of user's homepage
+ private String descr; // user's self-description
+ private java.util.Date created; // date created
+ private java.util.Date last_login; // date of last login
+ private java.util.Date last_update; // date of last update
+ private String real_email; // real email address
+
+ UserProfileImpl(EngineBackend engine, Connection conn, String username, boolean override)
+ throws DataException, SQLException
+ {
+ this.engine = engine;
+
+ // first retrieve from the users table
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description "
+ + "FROM users WHERE username = '");
+ sql.append(SQLUtil.encodeString(username)).append("';");
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new DataException("User '" + username + "' not found.");
+
+ // load the "elementary" fields
+ this.uid = rs.getInt("uid");
+ this.username = rs.getString("username");
+ int contact_id = rs.getInt("contactid");
+ created = SQLUtil.getFullDateTime(rs,"created");
+ last_login = SQLUtil.getFullDateTime(rs,"lastaccess");
+ descr = rs.getString("description");
+
+ loadContact(conn,contact_id,override);
+
+ } // end constructor
+
+ UserProfileImpl(EngineBackend engine, Connection conn, int uid, boolean override)
+ throws DataException, SQLException
+ {
+ this.engine = engine;
+
+ // first retrieve from the users table
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT uid, username, contactid, created, lastaccess, description "
+ + "FROM users WHERE uid = ");
+ sql.append(uid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ throw new DataException("User #" + String.valueOf(uid) + " not found.");
+
+ // load the "elementary" fields
+ this.uid = rs.getInt("uid");
+ this.username = rs.getString("username");
+ int contact_id = rs.getInt("contactid");
+ created = SQLUtil.getFullDateTime(rs,"created");
+ last_login = SQLUtil.getFullDateTime(rs,"lastaccess");
+ descr = rs.getString("description");
+
+ loadContact(conn,contact_id,override);
+
+ } // end constructor
+
+ private void loadContact(Connection conn, int contact_id, boolean override) throws SQLException
+ {
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT * FROM contacts WHERE contactid = ");
+ sql.append(contact_id).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (rs.next())
+ { // load all the record data
+ given_name = rs.getString("given_name");
+ family_name = rs.getString("family_name");
+ String blort = rs.getString("middle_init");
+ if ((blort==null) || (blort.length()<1))
+ middle_initial = ' ';
+ else
+ middle_initial = blort.charAt(0);
+ prefix = rs.getString("prefix");
+ suffix = rs.getString("suffix");
+ company = rs.getString("company");
+ if (!override && rs.getBoolean("pvt_addr"))
+ { // enforce address privacy
+ addr1 = null;
+ addr2 = null;
+
+ } // end if
+ else
+ { // load the address strings
+ addr1 = rs.getString("addr1");
+ addr2 = rs.getString("addr2");
+
+ } // end else
+
+ locality = rs.getString("locality");
+ region = rs.getString("region");
+ postal_code = rs.getString("pcode");
+ country = rs.getString("country");
+ if (!override && rs.getBoolean("pvt_phone"))
+ { // enforce phone privacy
+ phone = null;
+ mobile = null;
+
+ } // end if
+ else
+ { // load the phone strings
+ phone = rs.getString("phone");
+ mobile = rs.getString("mobile");
+
+ } // end else
+
+ if (!override && rs.getBoolean("pvt_fax"))
+ fax = null;
+ else
+ fax = rs.getString("fax");
+
+ real_email = rs.getString("email");
+ if (!override && rs.getBoolean("pvt_email"))
+ email = null;
+ else
+ email = real_email;
+
+ photo_url = rs.getString("photo_url");
+ url = rs.getString("url");
+ last_update = SQLUtil.getFullDateTime(rs,"lastupdate");
+
+ } // end if
+ else
+ { // no contact ID - just default all the data
+ given_name = null;
+ family_name = null;
+ middle_initial = ' ';
+ prefix = null;
+ suffix = null;
+ company = null;
+ addr1 = null;
+ addr2 = null;
+ locality = null;
+ region = null;
+ postal_code = null;
+ country = null;
+ phone = null;
+ fax = null;
+ mobile = null;
+ email = null;
+ photo_url = null;
+ url = null;
+ last_update = null;
+ real_email = null;
+
+ } // end else
+
+ } // end loadContact
+
+ public int getUID()
+ {
+ return uid;
+
+ } // end getUID
+
+ public String getUserName()
+ {
+ return username;
+
+ } // end getUserName
+
+ public String getGivenName()
+ {
+ return given_name;
+
+ } // end getGivenName
+
+ public String getFamilyName()
+ {
+ return family_name;
+
+ } // end getFamilyName
+
+ public char getMiddleInitial()
+ {
+ return middle_initial;
+
+ } // end getMiddleInitial
+
+ public String getNamePrefix()
+ {
+ return prefix;
+
+ } // end getNamePrefix
+
+ public String getNameSuffix()
+ {
+ return suffix;
+
+ } // end getNameSuffix
+
+ public String getCompany()
+ {
+ return company;
+
+ } // end getCompany
+
+ public String getAddressLine1()
+ {
+ return addr1;
+
+ } // end getAddressLine1
+
+ public String getAddressLine2()
+ {
+ return addr2;
+
+ } // end getAddressLine2
+
+ public String getLocality()
+ {
+ return locality;
+
+ } // end getLocality
+
+ public String getRegion()
+ {
+ return region;
+
+ } // end getRegion
+
+ public String getPostalCode()
+ {
+ return postal_code;
+
+ } // end getPostalCode
+
+ public String getCountry()
+ {
+ return country;
+
+ } // end getCountry
+
+ public String getFullCountry()
+ {
+ return engine.getCountryNameForCode(country);
+
+ } // end getFullCountry
+
+ public String getPhone()
+ {
+ return phone;
+
+ } // end getPhone
+
+ public String getFax()
+ {
+ return fax;
+
+ } // end getFax
+
+ public String getMobile()
+ {
+ return mobile;
+
+ } // end getMobile
+
+ public String getEmail()
+ {
+ return email;
+
+ } // end getEmail
+
+ public String getPhotoURL()
+ {
+ return photo_url;
+
+ } // end getPhotoURL
+
+ public String getURL()
+ {
+ return url;
+
+ } // end getURL
+
+ public java.util.Date getCreateDate()
+ {
+ return created;
+
+ } // end getCreateDate
+
+ public java.util.Date getLastLoginDate()
+ {
+ return last_login;
+
+ } // end getLastLoginDate
+
+ public java.util.Date getLastUpdate()
+ {
+ return last_update;
+
+ } // end getLastUpdate
+
+ public String getDescription()
+ {
+ return descr;
+
+ } // end getDescription
+
+} // end class UserProfileImpl
diff --git a/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java b/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java
new file mode 100644
index 0000000..2e3d3ed
--- /dev/null
+++ b/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java
@@ -0,0 +1,1560 @@
+/*
+ * 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.core.impl;
+
+import java.sql.*;
+import java.util.*;
+import org.apache.log4j.*;
+import org.w3c.dom.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.util.DOMElementHelper;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.db.*;
+import com.silverwrist.venice.htmlcheck.*;
+import com.silverwrist.venice.htmlcheck.dict.*;
+import com.silverwrist.venice.htmlcheck.filters.*;
+import com.silverwrist.venice.security.AuditRecord;
+import com.silverwrist.venice.security.PasswordHash;
+import com.silverwrist.venice.security.DefaultLevels;
+
+public class VeniceEngineImpl implements VeniceEngine, EngineBackend
+{
+ /*--------------------------------------------------------------------------------
+ * Internal class implementing the Country interface
+ *--------------------------------------------------------------------------------
+ */
+
+ static class CountryImpl implements Country
+ {
+ private String code;
+ private String name;
+
+ public CountryImpl(String code, String name)
+ {
+ this.code = code;
+ this.name = name;
+
+ } // end constructor
+
+ public String getCode()
+ {
+ return code;
+
+ } // end getCode
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ } // end class CountryImpl
+
+ /*--------------------------------------------------------------------------------
+ * Internal class implementing the Language interface
+ *--------------------------------------------------------------------------------
+ */
+
+ static class LanguageImpl implements Language
+ {
+ private String code;
+ private String name;
+
+ public LanguageImpl(String code, String name)
+ {
+ this.code = code;
+ this.name = name;
+
+ } // end constructor
+
+ public String getCode()
+ {
+ return code;
+
+ } // end getCode
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ } // end class LanguageImpl
+
+ /*--------------------------------------------------------------------------------
+ * Internal class storing feature information.
+ *--------------------------------------------------------------------------------
+ */
+
+ class VeniceFeatureDef implements SIGFeature
+ {
+ int code;
+ String symbol;
+ String name;
+ String applet;
+ boolean is_default;
+ boolean is_locked;
+ boolean is_hidden;
+ boolean requires_read;
+ int sequence;
+ int min_level;
+
+ VeniceFeatureDef(int code, ResultSet rs) throws SQLException
+ {
+ this.code = code;
+ this.is_default = rs.getBoolean("is_default");
+ this.is_locked = rs.getBoolean("is_locked");
+ this.is_hidden = rs.getBoolean("is_hidden");
+ this.requires_read = rs.getBoolean("require_read");
+ this.sequence = rs.getInt("sequence");
+ this.min_level = rs.getInt("min_level");
+ this.symbol = rs.getString("symbol");
+ this.name = rs.getString("name");
+ this.applet = rs.getString("applet");
+
+ } // end constructor
+
+ public int getFeatureCode()
+ {
+ return code;
+
+ } // end getFeatureCode
+
+ public String getSymbol()
+ {
+ return symbol;
+
+ } // end getSymbol
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String getApplet()
+ {
+ return applet;
+
+ } // end getApplet
+
+ public int getSequence()
+ {
+ return sequence;
+
+ } // end getSequence
+
+ boolean featureAllowed(int level, boolean has_read)
+ {
+ if (level document (root tag: <"
+ + root.getTagName() + "/>)");
+ throw new ConfigException("document is not a document",root);
+
+ } // end if
+
+ // Get the section.
+ DOMElementHelper root_h = new DOMElementHelper(root);
+ Element db_sect = root_h.getSubElement("database");
+ if (db_sect==null)
+ { // unable to find the database section
+ logger.fatal("config document has no section");
+ throw new ConfigException("no section found in config file",root);
+
+ } // end if
+
+ try
+ { // allocate the data pool object
+ datapool = new DataPool(db_sect);
+
+ } // end try
+ catch (SQLException e)
+ { // could not initialize the SQL database! this is a big fat error!
+ logger.fatal("data pool init failed - " + e.getMessage(),e);
+ throw new ConfigException("database access initialization failed - " + e.getMessage(),e);
+
+ } // end catch
+
+ Element email_sect = root_h.getSubElement("email");
+ if (email_sect==null)
+ { // unable to find the database section
+ logger.fatal("config document has no section");
+ throw new ConfigException("no section found in config file",root);
+
+ } // end if
+
+ // initialize the email properties and get a mail session object
+ email_props = new Properties();
+ email_props.put("mail.transport.protocol","smtp");
+ DOMElementHelper email_sect_h = new DOMElementHelper(email_sect);
+ email_props.put("mail.smtp.host",email_sect_h.getSubElementText("smtp-host"));
+ email_props.put("mail.from",email_sect_h.getSubElementText("mail-from-addr"));
+ email_props.put("com.silverwrist.venice.email.mailer",email_sect_h.getSubElementText("mailer"));
+ mailsession = javax.mail.Session.getInstance(email_props,null);
+
+ Element dict_sect = root_h.getSubElement("dictionary");
+ if (dict_sect==null)
+ { // unable to find the database section
+ logger.fatal("config document has no section");
+ throw new ConfigException("no section found in config file",root);
+
+ } // end if
+
+ // Retrieve the list of dictionary files to load into the spellchecker.
+ dictionary_tmp = new Vector();
+ NodeList dict_nodes = dict_sect.getChildNodes();
+ int j;
+ for (j=0; j element looking for elements
+ Node dn = dict_nodes.item(j);
+ if ((dn.getNodeType()==Node.ELEMENT_NODE) && (dn.getNodeName().equals("file")))
+ { // store the file name as a vector element
+ Element del = (Element)dn;
+ DOMElementHelper h = new DOMElementHelper(del);
+ dictionary_tmp.add(h.getElementText());
+
+ } // end if
+
+ } // end for
+
+ Element msg_sect = root_h.getSubElement("messages");
+ if (msg_sect==null)
+ { // unable to find the database section
+ logger.fatal("config document has no section");
+ throw new ConfigException("no section found in config file",root);
+
+ } // end if
+
+ // Initialize the stock messages list.
+ stock_messages = new Hashtable();
+ NodeList msg_nodes = msg_sect.getChildNodes();
+ for (j=0; jmax_value)
+ max_value = ndx;
+
+ } // end while
+
+ // store the real feature table as an array
+ features = new VeniceFeatureDef[++max_value];
+ System.arraycopy(tmp_array,0,features,0,max_value);
+ if (logger.isDebugEnabled())
+ logger.debug(String.valueOf(max_value) + " features loaded from database");
+
+ } // end try
+ catch (SQLException e)
+ { // convert exceptions to DataException
+ logger.fatal("Database error loading engine data: " + e.getMessage(),e);
+ throw new DataException("error initializing Venice engine: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ for (int i=0; i not found!");
+ throw new AccessError("Unable to find email address for user \"" + username +
+ "\". Please contact the system administrator for assistance.");
+
+ } // end if
+
+ String rc = rs.getString("email");
+ if (logger.isDebugEnabled())
+ logger.debug("getEmailAddressForUser(\"" + username + "\") => \"" + rc + "\"");
+ return rc;
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error getting email address for user: " + e.getMessage(),e);
+ throw new DataException("unable to access user data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getEmailAddressForUser
+
+ public void sendPasswordReminder(String username) throws DataException, AccessError, EmailException
+ {
+ checkInitialized();
+ Connection conn = null;
+
+ try
+ { // look for a user name matching this user record
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT c.email AS email, u.passreminder AS passreminder "
+ + "FROM users u, contacts c WHERE u.contactid = c.contactid "
+ + "AND u.username = '");
+ sql.append(SQLUtil.encodeString(username)).append("';");
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ { // the email address could not be found
+ logger.error("can't find email to send password reminder to \"" + username + "\"");
+ throw new AccessError("Unable to find email address for user \"" + username +
+ "\". Please contact the system administrator for assistance.");
+
+ } // end if
+
+ String email_addr = rs.getString("email");
+ if (logger.isDebugEnabled())
+ logger.debug("sendPasswordReminder(\"" + username + "\") going out to \"" + email_addr + "\"");
+
+ // Create the message to be sent.
+ String message = getStockMessage("reminder");
+ if (message==null)
+ { // what? the message does not exist?
+ logger.error("\"reminder\" message does not exist in config file!");
+ throw new DataException("INTERNAL: reminder message not specified");
+
+ } // end if
+
+ message = StringUtil.replaceAllInstances(message,"$USERNAME",username);
+ message = StringUtil.replaceAllInstances(message,"$REMINDER",rs.getString("passreminder"));
+
+ // Create the emailer and send the message.
+ SimpleEmailer emailer = createEmailer();
+ emailer.setTo(email_addr);
+ emailer.setSubject("Venice Password Reminder Message");
+ emailer.setText(message);
+ emailer.send();
+ if (logger.isDebugEnabled())
+ logger.debug("...email sent");
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error getting email address/reminder for user: " + e.getMessage(),e);
+ throw new DataException("unable to access user data: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end sendPasswordReminder
+
+ public UserContext createNewAccount(String remote_addr, String username, String password, String reminder)
+ throws DataException, AccessError
+ {
+ checkInitialized();
+ Connection conn = null;
+ AuditRecord ar = null;
+ String encode_username = SQLUtil.encodeString(username);
+ // email confirmation # is between 1000000 and 9999999
+ int confirm_num = getNewConfirmationNumber();
+ int new_uid;
+ java.util.Date created = null;
+
+ if (logger.isDebugEnabled())
+ logger.debug("createNewAccount(\"" + username + "\",,)...");
+
+ try
+ { // look to see if the user name is already present
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES users WRITE, userprefs WRITE, sigmember WRITE, topconfig WRITE;");
+ try
+ { // make sure the user name isn't there already
+ ResultSet rs = stmt.executeQuery("SELECT uid FROM users WHERE username = '" + encode_username + "';");
+ if (rs.next())
+ { // the user account already exists
+ logger.warn("username \"" + username + "\" already exists");
+ throw new AccessError("That user name already exists. Please try again.");
+
+ } // end if
+
+ // perform the insert of the user's new data
+ PasswordHash phash = new PasswordHash(password);
+ StringBuffer sql = new StringBuffer("INSERT INTO users (username, passhash, email_confnum, "
+ + "base_lvl, created, lastaccess, passreminder) VALUES ('");
+ sql.append(encode_username).append("', '").append(phash.toString()).append("', ");
+ sql.append(confirm_num).append(", ").append(DefaultLevels.newUser()).append(", '");
+ created = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(created)).append("', '").append(SQLUtil.encodeDate(created));
+ sql.append("', ").append(SQLUtil.encodeStringArg(reminder)).append(");");
+ stmt.executeUpdate(sql.toString());
+
+ // what is the new user ID?
+ rs = stmt.executeQuery("SELECT LAST_INSERT_ID();");
+ if (!(rs.next()))
+ { // the readback failed...
+ logger.error("readback of new user's UID failed");
+ throw new DataException("unable to read back new user ID");
+
+ } // end if
+
+ new_uid = rs.getInt(1);
+ if (logger.isDebugEnabled())
+ logger.debug("...created user \"" + username + "\" with UID " + String.valueOf(new_uid));
+
+ // add a UserPrefs record for this user, too
+ sql.setLength(0);
+ sql.append("INSERT INTO userprefs (uid) VALUES (").append(new_uid).append(");");
+ stmt.executeUpdate(sql.toString());
+
+ if (logger.isDebugEnabled())
+ logger.debug("...created userprefs");
+
+ // get the list of SIG IDs the anonymous user is a member of
+ rs = stmt.executeQuery("SELECT sigmember.sigid, sigmember.locked FROM users, sigmember "
+ + "WHERE sigmember.uid = users.uid AND users.is_anon = 1;");
+ sql.setLength(0);
+ while (rs.next())
+ { // set up to insert into the sigmember table
+ if (sql.length()==0)
+ sql.append("INSERT INTO sigmember (sigid, uid, granted_lvl, locked) VALUES ");
+ else
+ sql.append(", ");
+ sql.append("(").append(rs.getInt(1)).append(", ").append(new_uid).append(", ");
+ sql.append(DefaultLevels.memberSIG()).append(", ").append(rs.getInt(2)).append(")");
+
+ } // end while
+
+ if (sql.length()>0)
+ { // execute the big update
+ sql.append(';');
+ stmt.executeUpdate(sql.toString());
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("...loaded default SIG memberships");
+
+ // get the "top" configuration for this user
+ rs = stmt.executeQuery("SELECT topconfig.row, topconfig.col, topconfig.partid, topconfig.param "
+ + "FROM topconfig, users WHERE topconfig.uid = users.uid AND "
+ + "users.is_anon = 1;");
+ sql.setLength(0);
+ while (rs.next())
+ { // set up to insert into the topconfig table
+ if (sql.length()==0)
+ sql.append("INSERT INTO topconfig (uid, row, col, partid, param) VALUES ");
+ else
+ sql.append(", ");
+ sql.append("(").append(new_uid).append(", ").append(rs.getInt(1)).append(", ");
+ sql.append(rs.getInt(2)).append(", ").append(SQLUtil.encodeStringArg(rs.getString(3)));
+ sql.append(", ").append(SQLUtil.encodeStringArg(rs.getString(4))).append(')');
+
+ } // end while
+
+ if (sql.length()>0)
+ { // execute the big update
+ sql.append(';');
+ stmt.executeUpdate(sql.toString());
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("...loaded default top view config");
+
+ } // end try
+ finally
+ { // make sure the tables get unlocked before we go
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ // the operation was a success - give back an audit record
+ ar = new AuditRecord(AuditRecord.ACCOUNT_CREATE,new_uid,remote_addr);
+
+ } // end try
+ catch (SQLException e)
+ { // database error - this is a DataException
+ logger.error("DB error creating user: " + e.getMessage(),e);
+ throw new DataException("unable to create user record: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ try
+ { // save off the audit record before we go, though
+ if ((ar!=null) && (conn!=null))
+ ar.store(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // we couldn't store the audit record!
+ logger.error("DB error saving audit record: " + e.getMessage(),e);
+
+ } // end catch
+
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ // create a new context for the user (they're now effectively logged in)
+ UserContextImpl rc = new UserContextImpl(this,datapool);
+ rc.loadNewUser(remote_addr,new_uid,DefaultLevels.newUser(),username,confirm_num,created,created);
+ if (logger.isDebugEnabled())
+ logger.debug("...created new user context");
+ return rc;
+
+ } // end createNewAccount
+
+ public boolean aliasExists(String alias, int exist_sigid)
+ {
+ checkInitialized();
+ Connection conn = null;
+
+ try
+ { // do a SELECT on the sigs table
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT sigid FROM sigs WHERE alias = '");
+ sql.append(alias).append("'");
+ if (exist_sigid>0)
+ sql.append(" AND sigid <> ").append(exist_sigid);
+ sql.append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ return rs.next();
+
+ } // end try
+ catch (SQLException e)
+ { // force to return null
+ logger.warn("DB error looking up SIG: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return false; // this is a "default" return
+
+ } // end aliasExists
+
+ public boolean isValidCategoryID(int catid)
+ {
+ checkInitialized();
+ if (catid==-1)
+ return true; // valid by definition, it means "Top"
+ Connection conn = null;
+
+ try
+ { // do a SELECT on the sigs table
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT catid FROM refcategory WHERE catid = ");
+ sql.append(catid).append(';');
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ return rs.next();
+
+ } // end try
+ catch (SQLException e)
+ { // force to return null
+ logger.warn("DB error looking up category: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return false; // this is a "default" return
+
+ } // end isValidCategoryID
+
+ public List searchForUsers(int field, int mode, String term, int offset, int count) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("User search: field = " + String.valueOf(field) + ", mode = " + String.valueOf(mode)
+ + ", term '" + term + "', offset = " + String.valueOf(offset) + ", count = "
+ + String.valueOf(count));
+
+ Vector rc = new Vector(); // return from this function
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT u.uid AS uid, u.username AS username, u.description "
+ + "AS description, c.given_name AS given_name, c.family_name AS "
+ + "family_name, c.locality AS locality, c.region AS region, "
+ + "c.country AS country FROM users u, contacts c WHERE "
+ + "u.contactid = c.contactid AND ");
+
+ switch (field)
+ { // determine which field to search on
+ case SearchMode.FIELD_USER_NAME:
+ sql.append("u.username ");
+ break;
+
+ case SearchMode.FIELD_USER_DESCRIPTION:
+ sql.append("u.description ");
+ break;
+
+ case SearchMode.FIELD_USER_GIVEN_NAME:
+ sql.append("c.given_name ");
+ break;
+
+ case SearchMode.FIELD_USER_FAMILY_NAME:
+ sql.append("c.family_name ");
+ break;
+
+ default:
+ throw new DataException("invalid search field specified");
+
+ } // end switch
+
+ switch (mode)
+ { // compose SQL in different ways depending on the search term
+ case SearchMode.SEARCH_PREFIX:
+ sql.append("LIKE '").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_SUBSTRING:
+ sql.append("LIKE '%").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_REGEXP:
+ sql.append("REGEXP '").append(SQLUtil.encodeString(term)).append('\'');
+ break;
+
+ default:
+ throw new DataException("invalid search mode specified");
+
+ } // end switch
+
+ sql.append(" AND u.is_anon = 0 ORDER BY u.username LIMIT ").append(offset).append(", ");
+ sql.append(count+1).append(';');
+
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // launch the search!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ while (rs.next())
+ { // add all the found users to the list
+ UserFoundImpl ufi = new UserFoundImpl(rs.getInt("uid"),rs.getString("username"),
+ rs.getString("description"),rs.getString("given_name"),
+ rs.getString("family_name"),rs.getString("locality"),
+ rs.getString("region"),rs.getString("country"));
+ UserFound tmp = (UserFound)ufi;
+ rc.add(tmp);
+
+ } // end while
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading user entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve user information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return new ReadOnlyVector(rc);
+
+ } // end searchForUsers
+
+ public int getSearchUserCount(int field, int mode, String term) throws DataException
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("User search: field = " + String.valueOf(field) + ", mode = " + String.valueOf(mode)
+ + ", term '" + term + "'");
+
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT COUNT(*) AS total FROM users u, contacts c WHERE "
+ + "u.contactid = c.contactid AND ");
+
+ switch (field)
+ { // determine which field to search on
+ case SearchMode.FIELD_USER_NAME:
+ sql.append("u.username ");
+ break;
+
+ case SearchMode.FIELD_USER_DESCRIPTION:
+ sql.append("u.description ");
+ break;
+
+ case SearchMode.FIELD_USER_GIVEN_NAME:
+ sql.append("c.given_name ");
+ break;
+
+ case SearchMode.FIELD_USER_FAMILY_NAME:
+ sql.append("c.family_name ");
+ break;
+
+ default:
+ throw new DataException("invalid search field specified");
+
+ } // end switch
+
+ switch (mode)
+ { // compose SQL in different ways depending on the search term
+ case SearchMode.SEARCH_PREFIX:
+ sql.append("LIKE '").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_SUBSTRING:
+ sql.append("LIKE '%").append(SQLUtil.encodeStringWildcards(term)).append("%'");
+ break;
+
+ case SearchMode.SEARCH_REGEXP:
+ sql.append("REGEXP '").append(SQLUtil.encodeString(term)).append('\'');
+ break;
+
+ default:
+ throw new DataException("invalid search mode specified");
+
+ } // end switch
+
+ sql.append(" AND u.is_anon = 0;");
+
+
+ if (logger.isDebugEnabled())
+ logger.debug("SQL: " + sql.toString());
+
+ // launch the search!
+ ResultSet rs = stmt.executeQuery(sql.toString());
+
+ if (!(rs.next()))
+ throw new InternalStateError("getSearchUserCount search failure (MUST have 1 row!)");
+
+ return rs.getInt("total");
+
+ } // end try
+ catch (SQLException e)
+ { // turn SQLException into data exception
+ logger.error("DB error reading user entries: " + e.getMessage(),e);
+ throw new DataException("unable to retrieve user information: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end getSearchUserCount
+
+ public int getStdNumSearchResults()
+ {
+ return 20; // TODO: make this a config file option
+
+ } // end getStdNumSearchResults
+
+ public boolean isEmailAddressBanned(String email)
+ {
+ Connection conn = null; // pooled database connection
+
+ try
+ { // get a database connection
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+
+ // create and execute the right SQL statement
+ StringBuffer sql = new StringBuffer("SELECT by_uid FROM emailban WHERE address = '");
+ sql.append(SQLUtil.encodeString(email)).append("';");
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ return rs.next();
+
+ } // end try
+ catch (SQLException e)
+ { // if the database is horked, return false
+ logger.warn("DB error looking email address: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure we release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return false;
+
+ } // end isEmailAddressBanned
+
+ public boolean confAliasExists(String alias)
+ {
+ checkInitialized();
+ Connection conn = null;
+
+ try
+ { // do a SELECT on the confalias table
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT confid FROM confalias WHERE alias = '");
+ sql.append(alias).append("';");
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ return rs.next();
+
+ } // end try
+ catch (SQLException e)
+ { // force to return false
+ logger.warn("DB error looking up conference: " + e.getMessage(),e);
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ return false; // this is a "default" return
+
+ } // end confAliasExists
+
+ public HTMLChecker getPreviewChecker()
+ {
+ return html_configs[HTMLC_PREVIEW_BODY].createHTMLChecker();
+
+ } // end getPreviewChecker
+
+ public HTMLChecker getEscapingChecker()
+ {
+ return html_configs[HTMLC_ESCAPE_BODY_PSEUD].createHTMLChecker();
+
+ } // end getEscapingChecker
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface EngineBackend
+ *--------------------------------------------------------------------------------
+ */
+
+ public SimpleEmailer createEmailer()
+ {
+ checkInitialized();
+ return new SimpleEmailer(email_props,mailsession);
+
+ } // end createEmailer
+
+ public String getStockMessage(String key)
+ {
+ checkInitialized();
+ return (String)(stock_messages.get(key));
+
+ } // end getStockMessage
+
+ public int getNewConfirmationNumber()
+ {
+ checkInitialized();
+ return rng.nextInt(9000000) + 1000000;
+
+ } // end getNewConfirmationNumber
+
+ public String getCountryNameForCode(String code)
+ {
+ checkInitialized();
+ if (code==null)
+ return null;
+ Connection conn = null;
+
+ try
+ { // do a SELECT on the refcountry table
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT name FROM refcountry WHERE code = '" + code + "';");
+ if (rs.next())
+ { // found it!
+ String rc = rs.getString("name");
+ if (logger.isDebugEnabled())
+ logger.debug("getCountryNameForCode(\"" + code + "\") => \"" + rc + "\"");
+ return rc;
+
+ } // end if
+
+ } // end try
+ catch (SQLException e)
+ { // force to return null
+ logger.warn("DB error looking up country code: " + e.getMessage(),e);
+ if (logger.isDebugEnabled())
+ logger.debug("getCountryNameForCode(\"" + code + "\") => not found (data error)");
+ return null;
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ if (logger.isDebugEnabled())
+ logger.debug("getCountryNameForCode(\"" + code + "\") => not found");
+ return null; // if get here, it wasn't found
+
+ } // end getCountryNameForCode
+
+ public String getLanguageNameForCode(String code)
+ {
+ checkInitialized();
+ if (code==null)
+ return null;
+ Connection conn = null;
+
+ try
+ { // do a SELECT on the refcountry table
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT name FROM reflanguage WHERE CODE = '" + code + "';");
+ if (rs.next())
+ { // found it!
+ String rc = rs.getString("name");
+ if (logger.isDebugEnabled())
+ logger.debug("getLanguageNameForCode(\"" + code + "\") => \"" + rc + "\"");
+ return rc;
+
+ } // end if
+
+ } // end try
+ catch (SQLException e)
+ { // force to return null
+ logger.warn("DB error looking up language code: " + e.getMessage(),e);
+ if (logger.isDebugEnabled())
+ logger.debug("getLanguageNameForCode(\"" + code + "\") => not found (data error)");
+ return null;
+
+ } // end catch
+ finally
+ { // make sure the connection is released before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ if (logger.isDebugEnabled())
+ logger.debug("getLanguageNameForCode(\"" + code + "\") => not found");
+ return null; // if get here, it wasn't found
+
+ } // end getLanguageNameForCode
+
+ public SIGData getSIGDataObject(int sigid) throws DataException
+ {
+ checkInitialized();
+ if (logger.isDebugEnabled())
+ logger.debug("getSIGDataObject(" + String.valueOf(sigid) + ")...");
+
+ Integer the_sigid = new Integer(sigid);
+ SIGData sd = (SIGData)(sig_objects.get(the_sigid));
+ if (sd==null)
+ { // create a new SIGCoreData object and save it off
+ sd = new SIGCoreData(this,datapool,sigid);
+ sig_objects.put(the_sigid,sd);
+ if (logger.isDebugEnabled())
+ logger.debug("...created new object");
+
+ } // end if
+ else
+ { // this is an extra reference to the SIGDataObject
+ sd.rd_addRef();
+ if (logger.isDebugEnabled())
+ logger.debug("...using cached object");
+
+ } // end else
+
+ return sd;
+
+ } // end getSIGDataObject
+
+ public BitSet getLockedFeaturesMask()
+ {
+ checkInitialized();
+ BitSet rc = new BitSet();
+ for (int i=0; i=features.length))
+ { // the index is out of bounds!
+ logger.error("getAppletForFeature(" + String.valueOf(code) + ") => out of range");
+ throw new IndexOutOfBoundsException("invalid feature code");
+
+ } // end if
+
+ String rc = features[code].getApplet();
+ if (logger.isDebugEnabled())
+ logger.debug("getAppletForFeature(" + String.valueOf(code) + ") => \"" + rc + "\"");
+ return rc;
+
+ } // end getAppletForFeature
+
+ public boolean isValidInitialFeatureIndex(short ndx)
+ {
+ if ((ndx<0) || (ndx>=features.length))
+ return false;
+ return features[ndx].isVisible();
+
+ } // end isValidInitialFeatureIndex
+
+ public BitSet getDefaultFeaturesMask()
+ {
+ checkInitialized();
+ BitSet rc = new BitSet();
+ for (int i=0; i=html_configs.length))
+ throw new IllegalArgumentException("invalid HTML checker type index");
+ return html_configs[type].createHTMLChecker();
+
+ } // end createCheckerObject
+
+} // end class VeniceEngineImpl
diff --git a/src/com/silverwrist/venice/db/DataPool.java b/src/com/silverwrist/venice/db/DataPool.java
new file mode 100644
index 0000000..c3de7be
--- /dev/null
+++ b/src/com/silverwrist/venice/db/DataPool.java
@@ -0,0 +1,421 @@
+/*
+ * 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 Community 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.db;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.log4j.*;
+import org.w3c.dom.*;
+import com.silverwrist.util.DOMElementHelper;
+import com.silverwrist.venice.core.ConfigException;
+
+public class DataPool implements Runnable
+{
+ /*--------------------------------------------------------------------------------
+ * Static data values
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(DataPool.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String driver; // name of JDBC driver class
+ private String url; // URL for JDBC connection
+ private String username; // username for JDBC connection
+ private String password; // password for JDBC connection
+ private int max_conns; // maximum number of possible connections
+ private boolean wait_if_busy; // do we wait for a connection if none is available?
+ private boolean pending = false; // pending connection being created?
+ private Vector avail_connections; // connections which are available for use
+ private Vector busy_connections; // connections which are currently in use
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public DataPool(Element cfg) throws ConfigException, SQLException
+ {
+ // Make sure they passed the section to us.
+ if (!(cfg.getTagName().equals("database")))
+ { // not the right section name
+ logger.fatal("configuration section is not ");
+ throw new ConfigException("improper configuration section",cfg);
+
+ } // end if
+
+ // Use a DOMElementHelper to read off the configuration for the DataPool.
+ DOMElementHelper cfgx = new DOMElementHelper(cfg);
+ driver = cfgx.getSubElementText("driver");
+ if (driver==null)
+ { // no driver found!
+ logger.fatal("no name inside section");
+ throw new ConfigException("no name specified",cfg);
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("DataPool driver: " + driver);
+
+ url = cfgx.getSubElementText("uri");
+ if (url==null)
+ { // no database URI found!
+ logger.fatal("no name inside section");
+ throw new ConfigException("no database specified",cfg);
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("DataPool URI: " + url);
+
+ username = cfgx.getSubElementText("username");
+ if (username==null)
+ { // no database username found
+ logger.fatal("no inside section");
+ throw new ConfigException("no database specified",cfg);
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("DataPool username: " + url);
+
+ password = cfgx.getSubElementText("password");
+ if (password==null)
+ { // no database password found
+ logger.fatal("no user inside section");
+ throw new ConfigException("no database specified",cfg);
+
+ } // end if
+
+ int initial_conns = 0;
+ try
+ { // retrieve the initial-conns figure and make it an integer
+ String tmp = cfgx.getSubElementText("initial-conns");
+ if (tmp==null)
+ { // the connections value was not specified
+ logger.fatal("database value not specified");
+ throw new ConfigException("no value specified",cfg);
+
+ } // end if
+
+ initial_conns = Integer.parseInt(tmp);
+ if (initial_conns<0)
+ { // the connections value was out of range
+ logger.fatal("database value was out of range");
+ throw new ConfigException(" value out of range",cfg);
+
+ } // end if
+
+ } // end try
+ catch (NumberFormatException e)
+ { // the value wasn't a valid integer
+ logger.fatal("database value was not a number");
+ throw new ConfigException(" value is not a number",e,cfg);
+
+ } // end catch
+
+ if (logger.isDebugEnabled())
+ logger.debug("DataPool initial connections: " + String.valueOf(initial_conns));
+
+ try
+ { // retrieve the max-conns figure and make it an integer
+ String tmp = cfgx.getSubElementText("max-conns");
+ if (tmp==null)
+ { // maximum connections value not specified
+ logger.fatal("database value not specified");
+ throw new ConfigException("no value specified",cfg);
+
+ } // end if
+
+ max_conns = Integer.parseInt(tmp);
+ if (max_conns<=0)
+ { // value must be greater than 0!
+ logger.fatal("database value was out of range");
+ throw new ConfigException(" value out of range",cfg);
+
+ } // end if
+
+ } // end try
+ catch (NumberFormatException e)
+ { // the value wasn't a valid integer
+ logger.fatal("database value was not a number");
+ throw new ConfigException(" value is not a number",e,cfg);
+
+ } // end catch
+
+ if (logger.isDebugEnabled())
+ logger.debug("DataPool maximum connections: " + String.valueOf(max_conns));
+
+ wait_if_busy = cfgx.hasChildElement("wait-if-busy");
+ if (logger.isDebugEnabled())
+ logger.debug("DataPool wait if busy: " + String.valueOf(wait_if_busy));
+
+ if (initial_conns>max_conns)
+ { // fix initial value if above maximum
+ if (logger.isDebugEnabled())
+ logger.debug("N.B.: reducing configured initial connections");
+ initial_conns = max_conns;
+
+ } // end if
+
+ // Create the vectors that hold connections.
+ avail_connections = new Vector(initial_conns);
+ busy_connections = new Vector();
+
+ // Populate the "available connection" vector.
+ for (int i=0; i " + String.valueOf(rc));
+ return rc;
+
+ } // end numConnections
+
+ public synchronized Connection getConnection() throws SQLException
+ {
+ for (;;)
+ { // loop until we get a connection or throw an exception
+ if (avail_connections.isEmpty())
+ { // no connections available - we may need to make a new one
+ if (logger.isDebugEnabled())
+ logger.debug("no connections available - looking to get one");
+ if ((numConnections() < max_conns) && !pending)
+ makeBackgroundConnection(); // try to create a new connection
+ else if (!wait_if_busy)
+ { // don't want to wait? tough, we're h0sed!
+ logger.error("exhausted maximum connection limit (" + String.valueOf(max_conns) + ")");
+ throw new SQLException("connection limit reached");
+
+ } // end else if
+
+ // Wait for the background connect attempt to finish, or for
+ // someone to return a connection.
+ try
+ { // park the thread here until we know what's up
+ wait();
+
+ } // end try
+ catch (InterruptedException e)
+ { // do nothing
+ } // end catch
+
+ // now fall through the loop and try again
+
+ } // end if
+ else
+ { // pull the last connection off the available list...
+ int ndx = avail_connections.size() - 1;
+ Connection rc = (Connection)(avail_connections.elementAt(ndx));
+ avail_connections.removeElementAt(ndx);
+ if (rc.isClosed())
+ { // this connection is closed - discard it, and notify any waiters that a slot
+ // has opened up
+ if (logger.isDebugEnabled())
+ logger.debug("discarding closed connection");
+ notifyAll();
+ rc = null;
+ // fall out to the end of the loop and try again
+
+ } // end if
+ else
+ { // this connection is OK - return it
+ busy_connections.addElement(rc);
+ return rc;
+
+ } // end else
+
+ } // end else (at least one connection available)
+
+ } // end for (ever)
+
+ } // end getConnection
+
+ public synchronized void releaseConnection(Connection c)
+ {
+ busy_connections.removeElement(c); // move from one vector to another
+ avail_connections.addElement(c);
+ notifyAll(); // wake up! Got a new connection for you!
+
+ } // end releaseConnection
+
+ public synchronized void closeAllConnections()
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("closing ALL connections!");
+ closeConnections(avail_connections);
+ avail_connections = new Vector();
+ closeConnections(busy_connections);
+ busy_connections = new Vector();
+
+ } // end closeAllConnections
+
+ public synchronized String toString()
+ {
+ StringBuffer info = new StringBuffer();
+ info.append("DataPool(\"").append(url).append("\",\"").append(username).append("\"), ");
+ info.append(avail_connections.size()).append(" avail, ").append(busy_connections.size());
+ info.append(" busy, ").append(max_conns).append(" max");
+ return info.toString();
+
+ } // end toString
+
+} // end class DataPool
+
+
diff --git a/src/com/silverwrist/venice/db/PostLinkDecoder.java b/src/com/silverwrist/venice/db/PostLinkDecoder.java
new file mode 100644
index 0000000..a01205b
--- /dev/null
+++ b/src/com/silverwrist/venice/db/PostLinkDecoder.java
@@ -0,0 +1,371 @@
+/*
+ * 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 Community 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.db;
+
+import java.sql.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.IDUtils;
+
+public class PostLinkDecoder
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final int MAX_LINK_LEN = 130;
+ private static final int MAX_SIG_LEN = 32;
+ private static final int MAX_CONF_LEN = 64;
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String signame = null;
+ private String confname = null;
+ private short topicnum = -1;
+ private int first_post = -1;
+ private int last_post = -1;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public PostLinkDecoder(String data) throws ValidationException
+ {
+ if (StringUtil.isStringEmpty(data))
+ throw new ValidationException("empty string");
+ if (data.length()>MAX_LINK_LEN)
+ throw new ValidationException("post link string too long");
+
+ // turn the data into a StringBuffer so we can parse it
+ StringBuffer work = new StringBuffer(data);
+
+ // First Test: Bang
+ int pos = work.toString().indexOf('!');
+ if (pos>0)
+ { // We have "sig!something" ... store off the SIG name
+ setSIGName(work.substring(0,pos));
+ work.delete(0,pos+1);
+ if (work.length()==0)
+ return; // we had just "sig!" - that's the syntax for a SIG link
+
+ } // end if
+ else if (pos==0)
+ throw new ValidationException("! at beginning of string");
+
+ // Second Test: Dot Number One
+ pos = work.toString().indexOf('.');
+ if (pos<0)
+ { // there's no dots in here...this must have been either "postlink" or "sig!conference"
+ if (signame!=null) // it's "sig!conference"
+ setConferenceName(work.toString());
+ else // it's "postlink"
+ setPostRange(work);
+ return;
+
+ } // end if
+ else if (pos==0)
+ throw new ValidationException(". at beginning of string");
+
+ // Peel off the initial substring.
+ String conf_or_topic = work.substring(0,pos);
+ work.delete(0,pos+1);
+
+ if (work.length()==0)
+ { // we had "conference." or "topic." (or perhaps "sig!conference.")
+ if (signame==null)
+ { // it's either "conference." or "topic." - try topic first
+ try
+ { // try it as a topic number first...
+ setTopicNumber(conf_or_topic);
+
+ } // end try
+ catch (ValidationException ve)
+ { // it's not a topic number - try it as a conference name!
+ setConferenceName(conf_or_topic);
+
+ } // end catch
+
+ } // end if
+ else // it was "sig!conference."...save it off
+ setConferenceName(conf_or_topic);
+
+ return; // all done here...
+
+ } // end if
+
+ // Third Test: Dot Number Two
+ pos = work.toString().indexOf('.');
+ if (pos<0)
+ { // we had "conference.topic" or "topic.posts" (or perhaps "sig!conference.topic")
+ if (signame==null)
+ { // we have "conference.topic" or "topic.posts" - have to determine this
+ boolean is_topic = false; // what does "work" currently hold?
+ try
+ { // try the "topic.posts" possibility first...
+ setTopicNumber(conf_or_topic);
+
+ } // end try
+ catch (ValidationException ve)
+ { // nope, it's gotta be "conference.topic"
+ setConferenceName(conf_or_topic);
+ is_topic = true;
+
+ } // end if
+
+ // complete the parsing here
+ if (is_topic)
+ setTopicNumber(work.toString());
+ else
+ setPostRange(work);
+
+ } // end if
+ else
+ { // it's "sig!conference.topic"...set 'em up accordingly
+ setConferenceName(conf_or_topic);
+ setTopicNumber(work.toString());
+
+ } // end else
+
+ return; // all done
+
+ } // end if
+ else if (pos==0)
+ throw new ValidationException(". at beginning of string");
+
+ // We definitely have "conference.topic.something" (or "sig!conference.topic.sonething") now,
+ // so save off the conference name and topic number.
+ setConferenceName(conf_or_topic);
+ setTopicNumber(work.substring(0,pos));
+ work.delete(0,pos+1);
+
+ if (work.length()==0)
+ return; // we just had "conference.topic." or "sig!conference.topic.", which is valid
+
+ setPostRange(work); // the rest must be the post range!
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static boolean isAllDigits(String str)
+ {
+ for (int i=0; iMAX_SIG_LEN)
+ throw new ValidationException("SIG alias is too long");
+ if (!(IDUtils.isValidVeniceID(name)))
+ throw new ValidationException("SIG alias is not a valid Venice identifier");
+ signame = name;
+
+ } // end setSIGName
+
+ private void setConferenceName(String name) throws ValidationException
+ {
+ if (name.length()>MAX_CONF_LEN)
+ throw new ValidationException("conference alias is too long");
+ if (!(IDUtils.isValidVeniceID(name)))
+ throw new ValidationException("conference alias is not a valid Venice identifier");
+ confname = name;
+
+ } // end setConferenceName
+
+ private void setTopicNumber(String val) throws ValidationException
+ {
+ if (!isAllDigits(val))
+ throw new ValidationException("invalid topic number reference");
+ short temp_val;
+ try
+ { // parse the temp value
+ temp_val = Short.parseShort(val);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // if there's a validation exception, it goes here
+ throw new ValidationException("invalid topic number reference");
+
+ } // end catch
+
+ topicnum = temp_val;
+
+ } // end setTopicNumber
+
+ private void setPostRange(StringBuffer buf) throws ValidationException
+ {
+ int pos = buf.toString().indexOf('-');
+ String temp = null;
+ int temp_val = -1;
+ if (pos>0)
+ { // we've got "temp-something" here...make sure "temp" is a valid post number
+ temp = buf.substring(0,pos);
+ buf.delete(0,pos+1);
+ if (!isAllDigits(temp))
+ throw new ValidationException("invalid post number reference");
+ try
+ { // parse the temp value
+ temp_val = Integer.parseInt(temp);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // if there's a validation exception, it goes here
+ throw new ValidationException("invalid post number reference");
+
+ } // end catch
+
+ if (buf.length()==0)
+ { // we just had "first-"...set it up
+ first_post = temp_val;
+ last_post = -1;
+ return;
+
+ } // end if
+
+ } // end if
+ else if (pos==0)
+ throw new ValidationException("- at beginning of post range");
+
+ // the remaining string must be all digits at this point
+ if (!isAllDigits(buf.toString()))
+ throw new ValidationException("invalid post number reference");
+ try
+ { // parse the first value
+ first_post = Integer.parseInt(buf.toString());
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // if there's a validation exception, it goes here
+ throw new ValidationException("invalid post number reference");
+
+ } // end catch
+
+ if (temp!=null)
+ { // we converted a "temp_val" above - include it
+ if (temp_val.
+ *
+ * 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 Community 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.db;
+
+public class PostLinkDecoderContext
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String signame; // SIG name that's cached
+ private String confname; // conference name that's cached
+ private short topic; // topic that's cached
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public PostLinkDecoderContext(String signame, String confname, short topic)
+ {
+ this.signame = signame;
+ this.confname = confname;
+ this.topic = topic;
+
+ } // end PostLinkDecoderContext
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getSIGName()
+ {
+ return signame;
+
+ } // end getSIGName
+
+ public String getConferenceName()
+ {
+ return confname;
+
+ } // end getConferenceName
+
+ public short getTopicNumber()
+ {
+ return topic;
+
+ } // end getTopicNumber
+
+} // end class PostLinkDecoderContext
diff --git a/src/com/silverwrist/venice/db/PostLinkRewriter.java b/src/com/silverwrist/venice/db/PostLinkRewriter.java
new file mode 100644
index 0000000..bc44ccf
--- /dev/null
+++ b/src/com/silverwrist/venice/db/PostLinkRewriter.java
@@ -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 .
+ *
+ * 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 Community 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.db;
+
+import java.sql.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.htmlcheck.Rewriter;
+import com.silverwrist.venice.htmlcheck.RewriterServices;
+import com.silverwrist.venice.htmlcheck.MarkupData;
+import com.silverwrist.venice.core.IDUtils;
+
+public class PostLinkRewriter implements Rewriter
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private DataPool datapool;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public PostLinkRewriter(DataPool datapool)
+ {
+ this.datapool = datapool;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static String buildPostLink(PostLinkDecoder pl, PostLinkDecoderContext ctxt)
+ {
+ StringBuffer b = new StringBuffer("x-postlink:");
+ boolean started = false;
+ if (pl.getSIG()==null)
+ b.append(ctxt.getSIGName());
+ else
+ { // append the real SIG name
+ started = true;
+ b.append(pl.getSIG());
+
+ } // end else
+
+ b.append('!');
+ if (pl.getConference()==null)
+ { // need to default the context
+ if (started)
+ return b.toString();
+ b.append(ctxt.getConferenceName());
+
+ } // end if
+ else
+ { // append the proper conference name
+ started = true;
+ b.append(pl.getConference());
+
+ } // end else
+
+ b.append('.');
+ if (pl.getTopic()==-1)
+ { // need to default the topic number
+ if (started)
+ return b.toString();
+ b.append(ctxt.getTopicNumber());
+
+ } // end if
+ else
+ { // append the proper topic number
+ started = true;
+ b.append(pl.getTopic());
+
+ } // end else
+
+ // append the post link information, if applicable
+ b.append('.');
+ if (pl.getFirstPost()==-1)
+ return b.toString();
+ b.append(pl.getFirstPost());
+ if (pl.getFirstPost()==pl.getLastPost())
+ return b.toString();
+ b.append('-');
+ if (pl.getLastPost()==-1)
+ return b.toString();
+ b.append(pl.getLastPost());
+ return b.toString();
+
+ } // end buildPostLink
+
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface Rewriter
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getName()
+ {
+ return null;
+
+ } // end getName
+
+ public MarkupData rewrite(String data, RewriterServices svc)
+ {
+ PostLinkDecoderContext ctxt;
+
+ try
+ { // attempt to get the decoder context
+ ctxt = (PostLinkDecoderContext)(svc.getRewriterContextValue("PostLinkDecoderContext"));
+ if (ctxt==null)
+ return null; // decoder can't function
+
+ } // end try
+ catch (ClassCastException x)
+ { // decoder can't function without the context
+ return null;
+
+ } // end catch
+
+ PostLinkDecoder pl;
+
+ try
+ { // create the post link decoder
+ pl = new PostLinkDecoder(data);
+
+ if (pl.needDatabaseVerification())
+ { // open up a database connection and verify the SIG/conference names
+ Connection conn = null;
+
+ try
+ { // verify against the database
+ conn = datapool.getConnection();
+ pl.verifyNames(conn);
+
+ } // end try
+ catch (SQLException e)
+ { // just return null on failures
+ return null;
+
+ } // end catch
+ finally
+ { // release the connection when we're done
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ } // end if
+
+ } // end try
+ catch (ValidationException ve)
+ { // we can't validate the post link - just bail out
+ return null;
+
+ } // end catch
+
+ // build the necessary markup and return it
+ StringBuffer open_a = new StringBuffer("');
+ return new MarkupData(open_a.toString(),data,"");
+
+ } // end rewrite
+
+} // end class PostLinkRewriter
diff --git a/src/com/silverwrist/venice/db/SQLUtil.java b/src/com/silverwrist/venice/db/SQLUtil.java
new file mode 100644
index 0000000..5e1d810
--- /dev/null
+++ b/src/com/silverwrist/venice/db/SQLUtil.java
@@ -0,0 +1,176 @@
+/*
+ * 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 Community 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.db;
+
+import java.sql.*;
+import java.util.*;
+import com.silverwrist.util.StringUtil;
+
+public class SQLUtil
+{
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static java.util.Date convertDateTimeString(String dstr) throws SQLException
+ {
+ if (dstr==null)
+ return null; // null values are the same
+
+ try
+ { // do almost the reverse process of formatting it into a string
+ GregorianCalendar cal = new GregorianCalendar(new SimpleTimeZone(0,"UTC"));
+ cal.set(Calendar.YEAR,Integer.parseInt(dstr.substring(0,4)));
+ cal.set(Calendar.MONTH,Integer.parseInt(dstr.substring(5,7)) - 1 + Calendar.JANUARY);
+ cal.set(Calendar.DAY_OF_MONTH,Integer.parseInt(dstr.substring(8,10)));
+ cal.set(Calendar.HOUR_OF_DAY,Integer.parseInt(dstr.substring(11,13)));
+ cal.set(Calendar.MINUTE,Integer.parseInt(dstr.substring(14,16)));
+ cal.set(Calendar.SECOND,Integer.parseInt(dstr.substring(17,19)));
+ return cal.getTime();
+
+ } // end try
+ catch (NumberFormatException e)
+ { // the NumberFormatException becomes an SQLException
+ throw new SQLException("invalid DATETIME field format");
+
+ } // end catch
+
+ } // end convertDateString
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static String encodeString(String str)
+ {
+ return StringUtil.encodeStringSQL(str);
+
+ } // end encodeString
+
+ public static String encodeStringArg(String str)
+ {
+ if (str==null)
+ return "NULL";
+ StringBuffer b = new StringBuffer("'");
+ b.append(StringUtil.encodeStringSQL(str)).append('\'');
+ return b.toString();
+
+ } // end encodeStringArg
+
+ public static String encodeStringWildcards(String str)
+ {
+ if ((str.indexOf('_')<0) && (str.indexOf('%')<0))
+ return StringUtil.encodeStringSQL(str);
+
+ StringBuffer buf = new StringBuffer();
+ for (int i=0; i.
+ *
+ * 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 Community 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.db;
+
+import java.sql.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.htmlcheck.Rewriter;
+import com.silverwrist.venice.htmlcheck.RewriterServices;
+import com.silverwrist.venice.htmlcheck.MarkupData;
+import com.silverwrist.venice.core.IDUtils;
+
+public class UserNameRewriter implements Rewriter
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private DataPool datapool;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public UserNameRewriter(DataPool datapool)
+ {
+ this.datapool = datapool;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface Rewriter
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getName()
+ {
+ return null;
+
+ } // end getName
+
+ public MarkupData rewrite(String data, RewriterServices svc)
+ {
+ if (StringUtil.isStringEmpty(data) || (data.length()>64) || !(IDUtils.isValidVeniceID(data)))
+ return null;
+
+ Connection conn = null;
+
+ try
+ { // get a database connection and create a statement
+ conn = datapool.getConnection();
+ Statement stmt = conn.createStatement();
+ StringBuffer sql = new StringBuffer("SELECT uid FROM users WHERE username = '");
+ sql.append(SQLUtil.encodeString(data)).append("';");
+ ResultSet rs = stmt.executeQuery(sql.toString());
+ if (!(rs.next()))
+ return null; // not found
+
+ } // end try
+ catch (SQLException e)
+ { // if we hit a database error, just return null...
+ return null;
+
+ } // end catch
+ finally
+ { // make sure and release the connection before we go
+ if (conn!=null)
+ datapool.releaseConnection(conn);
+
+ } // end finally
+
+ StringBuffer open_a = new StringBuffer("');
+ return new MarkupData(open_a.toString(),data,"");
+
+ } // end rewrite
+
+} // end class UserNameRewriter
diff --git a/src/com/silverwrist/venice/htmlcheck/AlreadyFinishedException.java b/src/com/silverwrist/venice/htmlcheck/AlreadyFinishedException.java
new file mode 100644
index 0000000..86dc578
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/AlreadyFinishedException.java
@@ -0,0 +1,28 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public class AlreadyFinishedException extends HTMLCheckerException
+{
+ public AlreadyFinishedException()
+ {
+ super("The HTML Checker is already in a finished state.");
+
+ } // end constructor
+
+} // end AlreadyFinishedException
diff --git a/src/com/silverwrist/venice/htmlcheck/HTMLChecker.java b/src/com/silverwrist/venice/htmlcheck/HTMLChecker.java
new file mode 100644
index 0000000..4a7558f
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/HTMLChecker.java
@@ -0,0 +1,40 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public interface HTMLChecker
+{
+ public abstract void append(String str) throws AlreadyFinishedException;
+
+ public abstract void finish() throws AlreadyFinishedException;
+
+ public abstract void reset();
+
+ public abstract String getValue() throws NotYetFinishedException;
+
+ public abstract int getLength() throws NotYetFinishedException;
+
+ public abstract int getLines() throws NotYetFinishedException;
+
+ public abstract int getCounter(String name) throws NotYetFinishedException;
+
+ public abstract Object getContextValue(String name);
+
+ public abstract void setContextValue(String name, Object val);
+
+} // end interface HTMLChecker
diff --git a/src/com/silverwrist/venice/htmlcheck/HTMLCheckerConfig.java b/src/com/silverwrist/venice/htmlcheck/HTMLCheckerConfig.java
new file mode 100644
index 0000000..5869d1b
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/HTMLCheckerConfig.java
@@ -0,0 +1,66 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public interface HTMLCheckerConfig extends HTMLTagSets
+{
+ public abstract short getWordWrapLength();
+
+ public abstract void setWordWrapLength(short val);
+
+ public abstract boolean getProcessAngles();
+
+ public abstract void setProcessAngles(boolean val);
+
+ public abstract boolean getProcessParens();
+
+ public abstract void setProcessParens(boolean val);
+
+ public abstract boolean getDiscardHTMLTags();
+
+ public abstract void setDiscardHTMLTags(boolean val);
+
+ public abstract String getAnchorTail();
+
+ public abstract void setAnchorTail(String s);
+
+ public abstract void addOutputFilter(OutputFilter filter);
+
+ public abstract void addRawOutputFilter(OutputFilter filter);
+
+ public abstract void addStringRewriter(Rewriter rewriter);
+
+ public abstract void addWordRewriter(Rewriter rewriter);
+
+ public abstract void addTagRewriter(Rewriter rewriter);
+
+ public abstract void addParenRewriter(Rewriter rewriter);
+
+ public abstract boolean isTagSetAllowed(int setid);
+
+ public abstract void allowTagSet(int setid);
+
+ public abstract void disallowTagSet(int setid);
+
+ public abstract void configureNormalTagSet();
+
+ public abstract void configureRestrictedTagSet();
+
+ public abstract HTMLChecker createHTMLChecker();
+
+} // end interface HTMLCheckerConfig
diff --git a/src/com/silverwrist/venice/htmlcheck/HTMLCheckerCreator.java b/src/com/silverwrist/venice/htmlcheck/HTMLCheckerCreator.java
new file mode 100644
index 0000000..8e7524f
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/HTMLCheckerCreator.java
@@ -0,0 +1,30 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+import com.silverwrist.venice.htmlcheck.impl.HTMLCheckerConfigImpl;
+
+public class HTMLCheckerCreator
+{
+ public static HTMLCheckerConfig create()
+ {
+ return HTMLCheckerConfigImpl.createHTMLCheckerConfig();
+
+ } // end create
+
+} // end HTMLCheckerCreator
diff --git a/src/com/silverwrist/venice/htmlcheck/HTMLCheckerException.java b/src/com/silverwrist/venice/htmlcheck/HTMLCheckerException.java
new file mode 100644
index 0000000..4aeaa68
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/HTMLCheckerException.java
@@ -0,0 +1,46 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public class HTMLCheckerException extends com.silverwrist.venice.VeniceException
+{
+ public HTMLCheckerException()
+ {
+ super();
+
+ } // end constructor
+
+ public HTMLCheckerException(String msg)
+ {
+ super(msg);
+
+ } // end constructor
+
+ public HTMLCheckerException(Exception e)
+ {
+ super(e);
+
+ } // end constructor
+
+ public HTMLCheckerException(String msg, Exception e)
+ {
+ super(msg,e);
+
+ } // end constructor
+
+} // end class HTMLCheckerException
diff --git a/src/com/silverwrist/venice/htmlcheck/HTMLTagSets.java b/src/com/silverwrist/venice/htmlcheck/HTMLTagSets.java
new file mode 100644
index 0000000..30420e3
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/HTMLTagSets.java
@@ -0,0 +1,138 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public interface HTMLTagSets
+{
+ /**
+ * Denotes all tags that affect "inline" formatting only, such as
+ * <EM> and <B>. These are usually allowed.
+ */
+ public static final int INLINE_FORMAT = 1;
+ /**
+ * Denotes the "A" tag.
+ */
+ public static final int ANCHOR = 2;
+ /**
+ * Denotes all tags that affect "block-level" formatting, such as
+ * <P> and <Hn>.
+ */
+ public static final int BLOCK_FORMAT = 3;
+ /**
+ * Denotes all tags that cause "active" content to be included in the
+ * HTML document, such as <OBJECT>, <APPLET>, and <SCRIPT>.
+ * These are generally not allowed.
+ */
+ public static final int ACTIVE_CONTENT = 4;
+ /**
+ * Denotes the tags that create clickable image maps, such as <AREA> and
+ * <MAP>.
+ */
+ public static final int IMAGE_MAPS = 5;
+ /**
+ * Denotes the tags that are used for document-level formatting and structure, such as
+ * <HTML>, <BODY>, and <TITLE>. These are generally not allowed.
+ */
+ public static final int DOC_FORMAT = 6;
+ /**
+ * Denotes the <FONT> tag.
+ */
+ public static final int FONT_FORMAT = 7;
+ /**
+ * Denotes all tags that are used in conjunction with forms, such as
+ * <FORM>, <INPUT>, and <SELECT>.
+ */
+ public static final int FORMS = 8;
+ /**
+ * Denotes all tags that are used in conjunction with tables, such as
+ * <TABLE>, <TR>, and <TD>.
+ */
+ public static final int TABLES = 9;
+ /**
+ * Denotes the <DEL> and <INS> tags, which are used for change markup.
+ */
+ public static final int CHANGE_MARKUP = 10;
+ /**
+ * Denotes all tags related to frames, such as <FRAMESET> and <FRAME>.
+ * These are generally not allowed.
+ */
+ public static final int FRAMES = 11;
+ /**
+ * Denotes the <IMG> tag.
+ */
+ public static final int IMAGES = 12;
+ /**
+ * Denotes tags like <PRE>, which are used to preformat input text.
+ */
+ public static final int PREFORMAT = 13;
+ /**
+ * Denotes Netscape-specific inline formatting, such as the hated <BLINK>.
+ */
+ public static final int NSCP_INLINE_FORMAT = 14;
+ /**
+ * Denotes Netscape's layer tags, such as <LAYER> and <ILAYER>. These are
+ * generally not allowed.
+ */
+ public static final int NSCP_LAYERS = 15;
+ /**
+ * Denotes Netscape-specific form tags, like <KEYGEN>. These are generally
+ * not allowed.
+ */
+ public static final int NSCP_FORMS = 16;
+ /**
+ * Denotes Netscape-specific block formatting tags, like <MULTICOL>. These are
+ * generally not allowed.
+ */
+ public static final int NSCP_BLOCK_FORMAT = 17;
+ /**
+ * Denotes the Netscape <SERVER> tag, used for server-side execution. This is
+ * generally not allowed.
+ */
+ public static final int NSCP_SERVER = 18;
+ /**
+ * Denotes Microsoft-specific document formatting tags, such as <BGSOUND>. These
+ * are generally not allowed.
+ */
+ public static final int MSFT_DOC_FORMAT = 19;
+ /**
+ * Denotes Microsoft-specific inline formatting tags, such as <COMMENT>. These
+ * are generally not allowed.
+ */
+ public static final int MSFT_INLINE_FORMAT = 20;
+ /**
+ * Denotes Microsoft-specific block formatting tags, such as <MARQUEE>. These
+ * are generally not allowed.
+ */
+ public static final int MSFT_BLOCK_FORMAT = 21;
+ /**
+ * Denotes Microsoft-specific active-content tags, such as <XML>. These
+ * are generally not allowed.
+ */
+ public static final int MSFT_ACTIVE_CONTENT = 22;
+ /**
+ * Denotes constructs for server-side page use only, such as with Microsoft Active
+ * Server Pages and Sun Java Server Pages. These are generally not allowed.
+ */
+ public static final int SERVER_PAGE = 23;
+ /**
+ * Denotes tags used by the Sun Java Server and other Java-compatible servers for
+ * including server-side components. These are generally not allowed.
+ */
+ public static final int JAVA_SERVER = 24;
+
+} // end interface HTMLTagSets
diff --git a/src/com/silverwrist/venice/htmlcheck/MarkupData.java b/src/com/silverwrist/venice/htmlcheck/MarkupData.java
new file mode 100644
index 0000000..c6a6376
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/MarkupData.java
@@ -0,0 +1,67 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public class MarkupData
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String begin_markup;
+ private String text;
+ private String end_markup;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public MarkupData(String begin_markup, String text, String end_markup)
+ {
+ this.begin_markup = begin_markup;
+ this.text = text;
+ this.end_markup = end_markup;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getBeginMarkup()
+ {
+ return begin_markup;
+
+ } // end getBeginMarkup
+
+ public String getText()
+ {
+ return text;
+
+ } // end getText
+
+ public String getEndMarkup()
+ {
+ return end_markup;
+
+ } // end getEndMarkup
+
+} // end class MarkupData
diff --git a/src/com/silverwrist/venice/htmlcheck/ModSpellingDictionary.java b/src/com/silverwrist/venice/htmlcheck/ModSpellingDictionary.java
new file mode 100644
index 0000000..1f0e860
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/ModSpellingDictionary.java
@@ -0,0 +1,29 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public interface ModSpellingDictionary extends SpellingDictionary
+{
+ public abstract void addWord(String word);
+
+ public abstract void delWord(String word);
+
+ public abstract void clear();
+
+} // end interface ModSpellingDictionary
+
diff --git a/src/com/silverwrist/venice/htmlcheck/NotYetFinishedException.java b/src/com/silverwrist/venice/htmlcheck/NotYetFinishedException.java
new file mode 100644
index 0000000..f3e5374
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/NotYetFinishedException.java
@@ -0,0 +1,28 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public class NotYetFinishedException extends HTMLCheckerException
+{
+ public NotYetFinishedException()
+ {
+ super("The HTML Checker is not yet in a finished state.");
+
+ } // end constructor
+
+} // end NotYetFinishedException
diff --git a/src/com/silverwrist/venice/htmlcheck/OutputFilter.java b/src/com/silverwrist/venice/htmlcheck/OutputFilter.java
new file mode 100644
index 0000000..12c270c
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/OutputFilter.java
@@ -0,0 +1,28 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public interface OutputFilter
+{
+ public abstract boolean tryOutputCharacter(StringBuffer buf, char ch);
+
+ public abstract boolean matchCharacter(char ch);
+
+ public abstract int lengthNoMatch(String s);
+
+} // end interface OutputFilter
diff --git a/src/com/silverwrist/venice/htmlcheck/Rewriter.java b/src/com/silverwrist/venice/htmlcheck/Rewriter.java
new file mode 100644
index 0000000..79ba103
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/Rewriter.java
@@ -0,0 +1,26 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public interface Rewriter
+{
+ public abstract String getName();
+
+ public abstract MarkupData rewrite(String data, RewriterServices svc);
+
+} // end interface Rewriter
diff --git a/src/com/silverwrist/venice/htmlcheck/RewriterServices.java b/src/com/silverwrist/venice/htmlcheck/RewriterServices.java
new file mode 100644
index 0000000..b9e1152
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/RewriterServices.java
@@ -0,0 +1,26 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public interface RewriterServices
+{
+ public abstract String getRewriterAttrValue(String name);
+
+ public abstract Object getRewriterContextValue(String name);
+
+} // end interface RewriterServices
diff --git a/src/com/silverwrist/venice/htmlcheck/SpellingDictionary.java b/src/com/silverwrist/venice/htmlcheck/SpellingDictionary.java
new file mode 100644
index 0000000..861bb0e
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/SpellingDictionary.java
@@ -0,0 +1,26 @@
+/*
+ * 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 Community 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.htmlcheck;
+
+public interface SpellingDictionary
+{
+ public abstract int size();
+
+ public abstract boolean checkWord(String word);
+
+} // end interface SpellingDictionary
diff --git a/src/com/silverwrist/venice/htmlcheck/dict/LazyLexicon.java b/src/com/silverwrist/venice/htmlcheck/dict/LazyLexicon.java
new file mode 100644
index 0000000..ea71e0a
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/dict/LazyLexicon.java
@@ -0,0 +1,144 @@
+/*
+ * 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 Community 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.htmlcheck.dict;
+
+import java.io.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.htmlcheck.SpellingDictionary;
+
+public class LazyLexicon implements Runnable, SpellingDictionary
+{
+ /*--------------------------------------------------------------------------------
+ * Static data values
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(LazyLexicon.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private Lexicon inner_lex = null;
+ private String[] filenames;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public LazyLexicon(String[] filenames)
+ {
+ this.filenames = filenames; // save off the file names to be loaded
+
+ // spin off the load process into the background
+ Thread thrd = new Thread(this);
+ thrd.start();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private synchronized Lexicon getLex()
+ {
+ while (inner_lex==null)
+ { // wait for the inner thread to finish creating the lexicon
+ if (logger.isDebugEnabled())
+ logger.debug("LazyLexicon: waiting for lex to load...");
+
+ try
+ { // park the thread here until we know what's up
+ wait();
+
+ } // end try
+ catch (InterruptedException e)
+ { // do nothing
+ } // end catch
+
+ } // end while
+
+ return inner_lex;
+
+ } // end getLex
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface Runnable
+ *--------------------------------------------------------------------------------
+ */
+
+ public void run()
+ {
+ Lexicon lex = new Lexicon();
+
+ if (logger.isDebugEnabled())
+ logger.debug("LazyLexicon loading " + String.valueOf(filenames.length) + " lexicon(s)");
+
+ for (int i=0; i.
+ *
+ * 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 Community 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.htmlcheck.dict;
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+import com.silverwrist.venice.htmlcheck.ModSpellingDictionary;
+
+public class Lexicon implements ModSpellingDictionary, Serializable
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private HashSet[] sets; // 26 word sets, one for each letter of the alphabet
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public Lexicon()
+ {
+ sets = new HashSet[26];
+ for (int i=0; i<26; i++)
+ sets[i] = new HashSet(500,0.9F);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface SpellingDictionary
+ *--------------------------------------------------------------------------------
+ */
+
+ public synchronized int size()
+ {
+ int rc = 0;
+ for (int i=0; i<26; i++)
+ rc += sets[i].size();
+ return rc;
+
+ } // end size
+
+ public synchronized boolean checkWord(String word)
+ {
+ String real_word = word.toLowerCase();
+ int ndx = (int)(real_word.charAt(0) - 'a');
+ return sets[ndx].contains(real_word);
+
+ } // end checkWord
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ModSpellingDictionary
+ *--------------------------------------------------------------------------------
+ */
+
+ public synchronized void addWord(String word)
+ {
+ String real_word = word.toLowerCase();
+ int ndx = (int)(real_word.charAt(0) - 'a');
+ sets[ndx].add(real_word);
+
+ } // end addWord
+
+ public synchronized void delWord(String word)
+ {
+ String real_word = word.toLowerCase();
+ int ndx = (int)(real_word.charAt(0) - 'a');
+ sets[ndx].remove(real_word);
+
+ } // end delWord
+
+ public synchronized void clear()
+ {
+ for (int i=0; i<26; i++)
+ sets[i].clear();
+
+ } // end clear
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public synchronized void saveToStream(OutputStream stm, boolean compress) throws IOException
+ {
+ ObjectOutputStream real_stm;
+ if (compress)
+ { // run through a GZIP object before writing
+ GZIPOutputStream gz_stm = new GZIPOutputStream(stm);
+ real_stm = new ObjectOutputStream(gz_stm);
+
+ } // end if
+ else // just create the ObjectOutputStream directly
+ real_stm = new ObjectOutputStream(stm);
+
+ real_stm.writeObject(this);
+ real_stm.flush();
+
+ } // end saveToStream
+
+ public synchronized void saveToFile(File file, boolean compress) throws IOException
+ {
+ FileOutputStream fstm = new FileOutputStream(file);
+ try
+ { // save the object data
+ saveToStream(fstm,compress);
+ fstm.flush();
+
+ } // end try
+ finally
+ { // make sure we close the file before leaving
+ fstm.close();
+
+ } // end finally
+
+ } // end saveToFile
+
+ public synchronized void saveToFile(String filename, boolean compress) throws IOException
+ {
+ FileOutputStream fstm = new FileOutputStream(filename);
+ try
+ { // save the object data
+ saveToStream(fstm,compress);
+ fstm.flush();
+
+ } // end try
+ finally
+ { // make sure we close the file before leaving
+ fstm.close();
+
+ } // end finally
+
+ } // end saveToFile
+
+ public synchronized void readFile(String filename) throws IOException
+ {
+ BufferedReader rdr = new BufferedReader(new FileReader(filename));
+
+ String word = rdr.readLine();
+ while (word!=null)
+ { // add each word to the lexicon as we go
+ addWord(word);
+ word = rdr.readLine();
+
+ } // end while
+
+ rdr.close();
+
+ } // end readFile
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static Lexicon loadFromStream(InputStream stm, boolean compress) throws IOException
+ {
+ ObjectInputStream real_stm;
+ if (compress)
+ { // chain in a decompressor before we read the object
+ GZIPInputStream gz_stm = new GZIPInputStream(stm);
+ real_stm = new ObjectInputStream(gz_stm);
+
+ } // end if
+ else // just load uncompressed
+ real_stm = new ObjectInputStream(stm);
+
+ try
+ { // attempt to read the LExicon object
+ Object tmp = real_stm.readObject();
+ if (tmp instanceof Lexicon)
+ return (Lexicon)tmp;
+ throw new IOException("invalid stream data format");
+
+ } // end try
+ catch (OptionalDataException od)
+ { // translate exception here so we only throw one type
+ throw new IOException("invalid stream data format");
+
+ } // end catch
+ catch (ClassNotFoundException cnf)
+ { // translate exception here so we only throw one type
+ throw new IOException("invalid stream data format");
+
+ } // end catch
+
+ } // end loadFromStream
+
+ public static Lexicon loadFromFile(File file, boolean compress) throws IOException
+ {
+ FileInputStream fstm = new FileInputStream(file);
+ try
+ { // load the object data and return it
+ return loadFromStream(fstm,compress);
+
+ } // end try
+ finally
+ { // close the file before leaving
+ fstm.close();
+
+ } // end finally
+
+ } // end loadFromFile
+
+ public static Lexicon loadFromFile(String filename, boolean compress) throws IOException
+ {
+ FileInputStream fstm = new FileInputStream(filename);
+ try
+ { // load the object data and return it
+ return loadFromStream(fstm,compress);
+
+ } // end try
+ finally
+ { // close the file before leaving
+ fstm.close();
+
+ } // end finally
+
+ } // end loadFromFile
+
+} // end class Lexicon
diff --git a/src/com/silverwrist/venice/htmlcheck/dict/LexiconBuilder.java b/src/com/silverwrist/venice/htmlcheck/dict/LexiconBuilder.java
new file mode 100644
index 0000000..1068821
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/dict/LexiconBuilder.java
@@ -0,0 +1,117 @@
+/*
+ * 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 Community 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.htmlcheck.dict;
+
+import java.io.*;
+
+public class LexiconBuilder
+{
+ private LexiconBuilder()
+ { // cannot construct this object
+ } // end constructor
+
+ private static final String USAGE = "Usage: LexiconBuilder [-c] outputfile inputfile [...]";
+
+ public static void main(String args[])
+ {
+ if (args.length==0)
+ { // print the usage string and exit
+ System.err.println(USAGE);
+ System.exit(1);
+
+ } // end if
+
+ boolean compress = false;
+ int ofx = 0;
+ if (args[0].equals("-c"))
+ { // we're compressing the output
+ compress = true;
+ if (++ofx>=args.length)
+ { // no output filename specified!
+ System.err.println("No output file specified!");
+ System.err.println(USAGE);
+ System.exit(1);
+
+ } // end if
+
+ } // end if
+
+ int ifx = ofx + 1;
+ if (ifx>=args.length)
+ { // no input filename specified!
+ System.err.println("No input file specified!");
+ System.err.println(USAGE);
+ System.exit(1);
+
+ } // end if
+
+ Lexicon lex = new Lexicon(); // initialize lexicon object
+
+ while (ifx.
+ *
+ * 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 Community 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.htmlcheck.dict;
+
+import java.io.*;
+import java.util.*;
+
+public class LexiconTest
+{
+ private LexiconTest()
+ { // this class cannot be instantiated
+ } // end constructor
+
+ private static final String USAGE = "Usage: LexiconTest [-c] lexfile word [...]";
+
+ public static void main(String args[])
+ {
+ if (args.length==0)
+ { // print the usage string and exit
+ System.err.println(USAGE);
+ System.exit(1);
+
+ } // end if
+
+ boolean compress = false;
+ int ifx = 0;
+ if (args[0].equals("-c"))
+ { // we're compressing the output
+ compress = true;
+ if (++ifx>=args.length)
+ { // no lexicon specified!
+ System.err.println("No lexicon file specified!");
+ System.err.println(USAGE);
+ System.exit(1);
+
+ } // end if
+
+ } // end if
+
+ int wfx = ifx + 1;
+ Lexicon lex = null;
+
+ try
+ { // save the lexicon to its very own file
+ System.out.println("Loading " + args[ifx] + "...");
+ Date start = new Date();
+ lex = Lexicon.loadFromFile(args[ifx],compress);
+ Date stop = new Date();
+ long interval = stop.getTime() - start.getTime();
+ System.out.println("Loaded " + args[ifx] + ", elapsed time " + String.valueOf(interval/1000) + "."
+ + String.valueOf(interval%1000) + " seconds");
+
+ } // end try
+ catch (IOException e)
+ { // just die on IOException
+ System.err.println("Error loading from " + args[ifx] + ": " + e.getMessage());
+ System.exit(1);
+
+ } // end catch
+
+ while (wfx.
+ *
+ * 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 Community 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.htmlcheck.filters;
+
+import java.util.*;
+import com.silverwrist.venice.htmlcheck.Rewriter;
+import com.silverwrist.venice.htmlcheck.RewriterServices;
+import com.silverwrist.venice.htmlcheck.MarkupData;
+
+public class EmailRewriter implements Rewriter
+{
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public EmailRewriter()
+ { // do nothing
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface Rewriter
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getName()
+ {
+ return null;
+
+ } // end getName
+
+ public MarkupData rewrite(String data, RewriterServices svc)
+ {
+ int at_pos = data.indexOf('@');
+ if ((at_pos<=0) || (at_pos==(data.length()-1)))
+ return null;
+
+ // TODO: put in more validation checking
+
+ // build the tag (the gnarliest part)
+ StringBuffer open_a = new StringBuffer("0))
+ open_a.append(' ').append(catenate);
+ open_a.append('>');
+
+ // return the markup data back to the checker
+ return new MarkupData(open_a.toString(),data,"");
+
+ } // end rewrite
+
+} // end class EmailRewriter
diff --git a/src/com/silverwrist/venice/htmlcheck/filters/HTMLEncodingFilter.java b/src/com/silverwrist/venice/htmlcheck/filters/HTMLEncodingFilter.java
new file mode 100644
index 0000000..f70348d
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/filters/HTMLEncodingFilter.java
@@ -0,0 +1,148 @@
+/*
+ * 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 Community 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.htmlcheck.filters;
+
+import com.silverwrist.venice.htmlcheck.OutputFilter;
+
+/**
+ * An output filter for HTMLChecker that escapes the three basic characters
+ * used by HTML formatting. It translates the following characters:
+ *
+ *
< - <
+ *
> - >
+ *
& - &
+ *
+ *
+ * @author Eric J. Bowersox <erbo@silcom.com>
+ * @see HTMLOutputFilter
+ * @see HTMLChecker#addOutputFilter
+ */
+public class HTMLEncodingFilter implements OutputFilter
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final String ESCAPED_CHARACTERS = "<>&";
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ /**
+ * Creates a new instance of HTMLEncodingFilter.
+ */
+ public HTMLEncodingFilter()
+ { // do nothing
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface OutputFilter
+ *--------------------------------------------------------------------------------
+ */
+
+ /**
+ * Checks and possibly outputs a character. If the character ch is '<',
+ * '>', or '&', it appends the appropriate string to the string buffer
+ * buf and returns true. If not, it returns false
+ * and leaves the buffer alone.
+ *
+ * @param buf The string buffer to append the character equivalent to.
+ * @param ch The character to be checked and possibly output.
+ * @return true if the character matches and was output,
+ * false if not.
+ * @see #matchCharacter
+ * @see HTMLOutputFilter#tryOutputCharacter
+ */
+ public boolean tryOutputCharacter(StringBuffer buf, char ch)
+ {
+ switch (ch)
+ { // turn the HTML flag characters into appropriate entity escapes
+ case '<':
+ buf.append("<");
+ return true;
+
+ case '>':
+ buf.append(">");
+ return true;
+
+ case '&':
+ buf.append("&");
+ return true;
+
+ default:
+ break;
+
+ } // end switch
+
+ return false; // bail out! not one we handle!
+
+ } // end tryOutputCharacter
+
+ /**
+ * Returns true if the character ch is '<', '>', or '&',
+ * false if not.
+ *
+ * @param ch The character to be tested.
+ * @return true if the character ch is '<', '>', or '&',
+ * false if not.
+ * @see #tryOutputCharacter
+ * @see #lengthNoMatch
+ * @see HTMLOutputFilter#matchCharacter
+ */
+ public boolean matchCharacter(char ch)
+ {
+ return (ESCAPED_CHARACTERS.indexOf(ch)>=0);
+
+ } // end matchCharacter
+
+ /**
+ * Given a character string, returns the total number of characters in that string,
+ * starting from the beginning, that are not handled by this filter before
+ * one that is appears. If none of the characters in this string are handled
+ * by the filter, the length of the string is returned.
+ *
+ * @param s The string to scan through.
+ * @return The length of the initial sequence of non-matching characters in this string.
+ * @see #matchCharacter
+ * @see HTMLOutputFilter#lengthNoMatch
+ */
+ public int lengthNoMatch(String s)
+ {
+ int rc = s.length();
+ int i;
+ for (i=0; i=0) && (tmp.
+ *
+ * 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 Community 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.htmlcheck.filters;
+
+import com.silverwrist.venice.htmlcheck.OutputFilter;
+
+/**
+ * An output filter for HTMLChecker that escapes the apostrophe character
+ * (the SQL quote character) by doubling it.
+ *
+ * @author Eric J. Bowersox <erbo@silcom.com>
+ * @see OutputFilter
+ * @see HTMLChecker#addOutputFilter
+ */
+public class SQLEncodingFilter implements OutputFilter
+{
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ /**
+ * Creates a new instance of SQLEncodingFilter.
+ */
+ public SQLEncodingFilter()
+ { // do nothing
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface OutputFilter
+ *--------------------------------------------------------------------------------
+ */
+
+ /**
+ * Checks and possibly outputs a character. If the character ch is
+ * an apostrophe, it appends two apostrophes to the string buffer
+ * buf and returns true. If not, it returns false
+ * and leaves the buffer alone.
+ *
+ * @param buf The string buffer to append the character equivalent to.
+ * @param ch The character to be checked and possibly output.
+ * @return true if the character matches and was output,
+ * false if not.
+ * @see #matchCharacter
+ * @see HTMLOutputFilter#tryOutputCharacter
+ */
+ public boolean tryOutputCharacter(StringBuffer buf, char ch)
+ {
+ if (ch=='\'')
+ { // convert one apostrophe into two
+ buf.append("\'\'");
+ return true;
+
+ } // end if
+
+ return false;
+
+ } // end tryOutputCharacter
+
+ /**
+ * Returns true if the character ch is an apostrophe,
+ * false if not.
+ *
+ * @param ch The character to be tested.
+ * @return true if the character ch is an apostrophe,
+ * false if not.
+ * @see #tryOutputCharacter
+ * @see #lengthNoMatch
+ * @see HTMLOutputFilter#matchCharacter
+ */
+ public boolean matchCharacter(char ch)
+ {
+ return (ch=='\'');
+
+ } // end matchCharacter
+
+ /**
+ * Given a character string, returns the total number of characters in that string,
+ * starting from the beginning, that are not handled by this filter before
+ * one that is appears. If none of the characters in this string are handled
+ * by the filter, the length of the string is returned.
+ *
+ * @param s The string to scan through.
+ * @return The length of the initial sequence of non-matching characters in this string.
+ * @see #matchCharacter
+ * @see HTMLOutputFilter#lengthNoMatch
+ */
+ public int lengthNoMatch(String s)
+ {
+ int rc = s.indexOf('\'');
+ if (rc<0)
+ rc = s.length();
+ return rc;
+
+ } // end lengthNoMatch
+
+} // end class SQLEncodingFilter
diff --git a/src/com/silverwrist/venice/htmlcheck/filters/SpellingRewriter.java b/src/com/silverwrist/venice/htmlcheck/filters/SpellingRewriter.java
new file mode 100644
index 0000000..c7061bb
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/filters/SpellingRewriter.java
@@ -0,0 +1,118 @@
+/*
+ * 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 Community 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.htmlcheck.filters;
+
+import java.util.*;
+import com.silverwrist.venice.htmlcheck.Rewriter;
+import com.silverwrist.venice.htmlcheck.RewriterServices;
+import com.silverwrist.venice.htmlcheck.MarkupData;
+import com.silverwrist.venice.htmlcheck.SpellingDictionary;
+
+public class SpellingRewriter implements Rewriter
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final String DEFAULT_BEGIN_ERROR = "";
+ private static final String DEFAULT_END_ERROR = "";
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private Vector dictionaries = new Vector();
+ private String begin_error = DEFAULT_BEGIN_ERROR;
+ private String end_error = DEFAULT_END_ERROR;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public SpellingRewriter()
+ { // do nothing here
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface Rewriter
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getName()
+ {
+ return "spelling";
+
+ } // end getName
+
+ public MarkupData rewrite(String data, RewriterServices svc)
+ {
+ Iterator it = dictionaries.iterator();
+ while (it.hasNext())
+ { // check each stored dictionary in turn
+ SpellingDictionary dict = (SpellingDictionary)(it.next());
+ if (dict.checkWord(data))
+ return null; // it's in a dictionary, that means it's spelled right
+
+ } // end while
+
+ // not found - it's spelled wrong
+ return new MarkupData(begin_error,data,end_error);
+
+ } // end rewrite
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void addDictionary(SpellingDictionary dict)
+ {
+ dictionaries.add(dict);
+
+ } // end addDictionary
+
+ public String getBeginError()
+ {
+ return begin_error;
+
+ } // end getBeginError
+
+ public void setBeginError(String val)
+ {
+ begin_error = val;
+
+ } // end setBeginError
+
+ public String getEndError()
+ {
+ return end_error;
+
+ } // end getEndError
+
+ public void setEndError(String val)
+ {
+ end_error = val;
+
+ } // end setEndError
+
+} // end class SpellingRewriter
+
+
diff --git a/src/com/silverwrist/venice/htmlcheck/filters/URLRewriter.java b/src/com/silverwrist/venice/htmlcheck/filters/URLRewriter.java
new file mode 100644
index 0000000..ea18a00
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/filters/URLRewriter.java
@@ -0,0 +1,114 @@
+/*
+ * 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 Community 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.htmlcheck.filters;
+
+import java.util.*;
+import com.silverwrist.venice.htmlcheck.Rewriter;
+import com.silverwrist.venice.htmlcheck.RewriterServices;
+import com.silverwrist.venice.htmlcheck.MarkupData;
+
+public class URLRewriter implements Rewriter
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final String NULLSTRING = "";
+ private static Hashtable prefix_list = null;
+ private static boolean set_up = true;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public URLRewriter()
+ {
+ setUpPrefixes(); // make sure the prefix data is set up
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static void setUpPrefixes()
+ {
+ if (set_up)
+ { // allocate the hash table
+ set_up = false;
+ prefix_list = new Hashtable(10,0.9F);
+
+ // fill it with the proper URL prefixes
+ prefix_list.put("http:",NULLSTRING);
+ prefix_list.put("ftp:",NULLSTRING);
+ prefix_list.put("gopher:",NULLSTRING);
+ prefix_list.put("mailto:",NULLSTRING);
+ prefix_list.put("news:",NULLSTRING);
+ prefix_list.put("nntp:",NULLSTRING);
+ prefix_list.put("telnet:",NULLSTRING);
+ prefix_list.put("tn3270:",NULLSTRING);
+ prefix_list.put("www.",new String("http://"));
+ prefix_list.put("ftp.",new String("ftp://"));
+ prefix_list.put("gopher.",new String("gopher://"));
+
+ } // end if
+
+ } // end setUpPrefixes
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface Rewriter
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getName()
+ {
+ return null;
+
+ } // end getName
+
+ public MarkupData rewrite(String data, RewriterServices svc)
+ {
+ Enumeration prefixes = prefix_list.keys();
+ while (prefixes.hasMoreElements())
+ { // get the next prefix and compare against the beginning of the string
+ String pfx = (String)(prefixes.nextElement());
+ if (data.regionMatches(true,0,pfx,0,pfx.length()))
+ { // good enough! build the open tag (the gnarliest part of the markup)
+ StringBuffer open_a = new StringBuffer("0))
+ open_a.append(' ').append(catenate);
+ open_a.append('>');
+
+ // here's how you mark it up!
+ return new MarkupData(open_a.toString(),data,"");
+
+ } // end if
+
+ } // end while
+
+ return null; // sorry, no can do
+
+ } // end rewrite
+
+} // end class URLRewriter
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/BalancedTag.java b/src/com/silverwrist/venice/htmlcheck/impl/BalancedTag.java
new file mode 100644
index 0000000..d64c831
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/BalancedTag.java
@@ -0,0 +1,49 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+class BalancedTag extends OpenCloseTag
+{
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ BalancedTag(String name, boolean brk)
+ {
+ super(name,brk);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public final boolean balanceTags()
+ {
+ return true;
+
+ } // end balanceTags
+
+} // end class BalancedTag
+
+
+
+
+
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/HTMLCheckerBackend.java b/src/com/silverwrist/venice/htmlcheck/impl/HTMLCheckerBackend.java
new file mode 100644
index 0000000..39cff1c
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/HTMLCheckerBackend.java
@@ -0,0 +1,28 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+public interface HTMLCheckerBackend
+{
+ public abstract String getCheckerAttrValue(String name);
+
+ public abstract void sendTagMessage(String msg);
+
+ public abstract Object getCheckerContextValue(String name);
+
+} // end interface HTMLCheckerBackend
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/HTMLCheckerConfigImpl.java b/src/com/silverwrist/venice/htmlcheck/impl/HTMLCheckerConfigImpl.java
new file mode 100644
index 0000000..8bf083e
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/HTMLCheckerConfigImpl.java
@@ -0,0 +1,252 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+import java.util.*;
+import com.silverwrist.venice.htmlcheck.*;
+
+public class HTMLCheckerConfigImpl implements HTMLCheckerConfig
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final String DEFAULT_ANCHOR_TAIL = "TARGET=\"Wander\"";
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private boolean process_angles = true; // process angle-bracketed strings?
+ private boolean process_parens = true; // process parenthesized strings?
+ private boolean discard_html_tags = false; // discard all HTML tags?
+ private short word_wrap_length = 0; // word wrap length
+ private String anchor_tail = DEFAULT_ANCHOR_TAIL; // the tail end of the anchor
+ private BitSet allowed_tagsets = new BitSet(); // which tagsets are allowed?
+ private Vector output_filters = new Vector(); // output filters
+ private Vector raw_output_filters = new Vector(); // output filters only applied in "raw mode"
+ private Vector string_rewriters = new Vector(); // rewriters that operate on full "strings"
+ private Vector word_rewriters = new Vector(); // rewriters that operate on "words" only
+ private Vector tag_rewriters = new Vector(); // rewriters that operate on only
+ private Vector paren_rewriters = new Vector(); // rewriters that operate on (parens) only
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ HTMLCheckerConfigImpl()
+ {
+ TagRepository.init();
+ TagRepository.configureNormalSet(allowed_tagsets);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface HTMLCheckerConfig
+ *--------------------------------------------------------------------------------
+ */
+
+ public short getWordWrapLength()
+ {
+ return word_wrap_length;
+
+ } // end getWordWrapLength
+
+ public void setWordWrapLength(short val)
+ {
+ if (val<0)
+ word_wrap_length = 0;
+ else
+ word_wrap_length = val;
+
+ } // end setWordWrapLength
+
+ public boolean getProcessAngles()
+ {
+ return process_angles;
+
+ } // end getProcessAngles
+
+ public void setProcessAngles(boolean val)
+ {
+ process_angles = val;
+
+ } // end setProcessAngles
+
+ public boolean getProcessParens()
+ {
+ return process_parens;
+
+ } // end getProcessParens
+
+ public void setProcessParens(boolean val)
+ {
+ process_parens = val;
+
+ } // end setProcessParens
+
+ public boolean getDiscardHTMLTags()
+ {
+ return discard_html_tags;
+
+ } // end getDiscardHTMLTags
+
+ public void setDiscardHTMLTags(boolean val)
+ {
+ discard_html_tags = val;
+
+ } // end setDiscardHTMLTags
+
+ public String getAnchorTail()
+ {
+ return anchor_tail;
+
+ } // end getAnchorTail
+
+ public void setAnchorTail(String s)
+ {
+ anchor_tail = s;
+
+ } // end setAnchorTail
+
+ public void addOutputFilter(OutputFilter filter)
+ {
+ output_filters.add(filter);
+
+ } // end addOutputFilter
+
+ public void addRawOutputFilter(OutputFilter filter)
+ {
+ raw_output_filters.add(filter);
+
+ } // end addRawOutputFilter
+
+ public void addStringRewriter(Rewriter rewriter)
+ {
+ string_rewriters.add(rewriter);
+
+ } // end addStringRewriter
+
+ public void addWordRewriter(Rewriter rewriter)
+ {
+ word_rewriters.add(rewriter);
+
+ } // end addWordRewriter
+
+ public void addTagRewriter(Rewriter rewriter)
+ {
+ tag_rewriters.add(rewriter);
+
+ } // end addTagRewriter
+
+ public void addParenRewriter(Rewriter rewriter)
+ {
+ } // end addParenRewriter
+
+ public boolean isTagSetAllowed(int setid)
+ {
+ return allowed_tagsets.get(setid);
+
+ } // end isTagSetAllowed
+
+ public void allowTagSet(int setid)
+ {
+ allowed_tagsets.set(setid);
+
+ } // end allowTagSet
+
+ public void disallowTagSet(int setid)
+ {
+ allowed_tagsets.clear(setid);
+
+ } // end disallowTagSet
+
+ public void configureNormalTagSet()
+ {
+ TagRepository.configureNormalSet(allowed_tagsets);
+
+ } // end configureNormalTagSet
+
+ public void configureRestrictedTagSet()
+ {
+ TagRepository.configureRestrictedSet(allowed_tagsets);
+
+ } // end configureRestrictedTagSet
+
+ /*--------------------------------------------------------------------------------
+ * Operations usable only from within the package
+ *--------------------------------------------------------------------------------
+ */
+
+ List getOutputFilters()
+ {
+ return output_filters;
+
+ } // end getOutputFilters
+
+ List getRawOutputFilters()
+ {
+ return raw_output_filters;
+
+ } // end getRawOutputFilters
+
+ List getStringRewriters()
+ {
+ return string_rewriters;
+
+ } // end getStringRewriters
+
+ List getWordRewriters()
+ {
+ return word_rewriters;
+
+ } // end getWordRewriters
+
+ List getTagRewriters()
+ {
+ return tag_rewriters;
+
+ } // end getTagRewriters
+
+ List getParenRewriters()
+ {
+ return paren_rewriters;
+
+ } // end getParenRewriters
+
+ public HTMLChecker createHTMLChecker()
+ {
+ return new HTMLCheckerImpl(this);
+
+ } // end createHTMLChecker
+
+ /*--------------------------------------------------------------------------------
+ * Static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static HTMLCheckerConfig createHTMLCheckerConfig()
+ {
+ return new HTMLCheckerConfigImpl();
+
+ } // end createHTMLCheckerConfig
+
+} // end class HTMLCheckerConfigImpl
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/HTMLCheckerImpl.java b/src/com/silverwrist/venice/htmlcheck/impl/HTMLCheckerImpl.java
new file mode 100644
index 0000000..f8f6f19
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/HTMLCheckerImpl.java
@@ -0,0 +1,1111 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+import java.util.*;
+import com.silverwrist.venice.htmlcheck.*;
+
+class HTMLCheckerImpl implements HTMLChecker, HTMLCheckerBackend, RewriterServices
+{
+ /*--------------------------------------------------------------------------------
+ * Wrapper for Rewriters to implement counting where necessary
+ *--------------------------------------------------------------------------------
+ */
+
+ static class CountingRewriter implements Rewriter
+ {
+ private Rewriter inner;
+ private int count = 0;
+
+ public CountingRewriter(Rewriter inner)
+ {
+ this.inner = inner;
+
+ } // end constructor
+
+ public String getName()
+ {
+ return inner.getName();
+
+ } // end getName
+
+ public MarkupData rewrite(String data, RewriterServices svc)
+ {
+ MarkupData rc = inner.rewrite(data,svc);
+ if (rc!=null)
+ count++;
+ return rc;
+
+ } // end rewrite
+
+ public int getCount()
+ {
+ return count;
+
+ } // end getCount
+
+ public void reset()
+ {
+ count = 0;
+
+ } // end reset
+
+ } // end class CountingRewriter
+
+ /*--------------------------------------------------------------------------------
+ * State machine constants
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final short ST_WHITESPACE = 0;
+ private static final short ST_CHARS = 1;
+ private static final short ST_LEFTANGLE = 2;
+ private static final short ST_TAG = 3;
+ private static final short ST_PAREN = 4;
+ private static final short ST_TAGQUOTE = 5;
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private HTMLCheckerConfigImpl config; // the configuration we're working from
+ private boolean started = false; // have we started parsing?
+ private boolean finished = false; // have we finished parsing?
+ private short state = ST_WHITESPACE; // current parser state
+ private char quote_char; // quote character to match
+ private int paren_level = 0; // parenthesization level
+ private short columns = 0; // current number of columns
+ private int lines = 0; // current number of lines
+ private int nobreak_count = 0; // "no-break" count
+ private boolean trigger_WBR = false; // word break trigger
+ private StringBuffer output_buffer = null; // output buffer for characters
+ private StringBuffer temp_buffer = null; // temporary buffer used within one state
+ private Vector tag_stack = null; // stack of tags that have been opened
+ private Hashtable counters = new Hashtable(); // the CountingRewriter instances
+ private Vector string_rewriters = new Vector(); // string rewriter instances
+ private Vector word_rewriters = new Vector(); // word rewriter instances
+ private Vector tag_rewriters = new Vector(); // tag rewriter instances
+ private Vector paren_rewriters = new Vector(); // paren rewriter instances
+ private Hashtable context_data = new Hashtable(); // context variables
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ HTMLCheckerImpl(HTMLCheckerConfigImpl config)
+ {
+ TagRepository.init();
+ this.config = config;
+ copyRewriters(string_rewriters,config.getStringRewriters());
+ copyRewriters(word_rewriters,config.getWordRewriters());
+ copyRewriters(tag_rewriters,config.getTagRewriters());
+ copyRewriters(paren_rewriters,config.getParenRewriters());
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final boolean isWordChar(char ch)
+ {
+ return (Character.isUpperCase(ch) || Character.isLowerCase(ch) || (ch=='-'));
+
+ } // end isWordChar
+
+ private static final int getRunLength(StringBuffer buf)
+ {
+ boolean word_char = isWordChar(buf.charAt(0));
+ int l = 1;
+ while (l0)
+ { // look through all the output filters to see what we can do
+ Iterator it = filters.iterator();
+ while (!handled && it.hasNext())
+ { // look for an output filter that matches this character
+ OutputFilter of = (OutputFilter)(it.next());
+ handled = of.tryOutputCharacter(output_buffer,ch);
+
+ } // end while
+
+ } // end if
+
+ if (!handled) // output the character
+ output_buffer.append(ch);
+ if (count_cols && (config.getWordWrapLength()>0))
+ columns++; // adjust column indicator
+
+ } // end emitChar
+
+ private void emitString(String str, List filters, boolean count_cols)
+ {
+ boolean real_count_cols = count_cols && (config.getWordWrapLength()>0);
+
+ if (filters.size()==0)
+ { // if there are no filters, just append the entire string directly
+ output_buffer.append(str);
+ if (real_count_cols)
+ columns += (short)(str.length());
+ return;
+
+ } // end if
+
+ String temp = str;
+ while ((temp!=null) && (temp.length()>0))
+ { // We output as much of the string as we possibly can at once. For starters,
+ // assume we're going to output the whole thing.
+ int output_len = temp.length();
+
+ // Now look at each of the output filters to see if we should try outputting
+ // a lesser amount (i.e., does the string contain a "stopper" that one of the
+ // output filters would like to mogrify?)
+ Iterator it = filters.iterator();
+ OutputFilter stopper = null;
+ while (it.hasNext() && (output_len>0))
+ { // look to find the length of characters that doesn't match this filter
+ OutputFilter of = (OutputFilter)(it.next());
+ int lnm = of.lengthNoMatch(temp);
+ if ((lnm>=0) && (lnm0)
+ { // At least this many unaltered characters can be output, so copy them.
+ output_buffer.append(temp.substring(0,output_len));
+ if (real_count_cols)
+ columns += (short)output_len;
+
+ } // end if
+
+ if (stopper!=null)
+ { // one of the output filters stopped us, so invoke it
+ char tmpch = temp.charAt(output_len++);
+ if (!(stopper.tryOutputCharacter(output_buffer,tmpch)))
+ output_buffer.append(tmpch);
+ if (real_count_cols)
+ columns++;
+
+ } // end if
+
+ // Chop the string down the middle and go around again.
+ if (output_len==temp.length())
+ temp = null;
+ else if (output_len>0)
+ temp = temp.substring(output_len);
+
+ } // end while (still data left to append)
+
+ } // end emitString
+
+ private void emitLineBreak()
+ {
+ emitString("\r\n",config.getRawOutputFilters(),false);
+ if (config.getWordWrapLength()>0)
+ columns = 0;
+ lines++;
+
+ } // end emitLineBreak
+
+ private void emitPossibleLineBreak()
+ {
+ if ((config.getWordWrapLength()>0) && (nobreak_count<=0) && (columns>=config.getWordWrapLength()))
+ emitLineBreak();
+
+ } // end emitPossibleLineBreak
+
+ private void ensureSpaceOnLine(int nchars)
+ {
+ if ((config.getWordWrapLength()>0) && (nobreak_count<=0))
+ { // line break might be required here
+ int remain_space = (int)(config.getWordWrapLength() - columns);
+ if (remain_space0)
+ { // calculate where the next line break is
+ int line_break = temp_buffer.toString().indexOf('\n');
+ int output_len = line_break;
+ if (output_len<0)
+ output_len = temp_buffer.length();
+
+ if ((config.getWordWrapLength()>0) && (nobreak_count<=0))
+ { // adjust output if necessary for word wrapping
+ int remain_space = (int)(config.getWordWrapLength() - columns);
+ if (remain_space0)
+ emitString(temp_buffer.substring(0,output_len),config.getOutputFilters(),true);
+
+ if (line_break>=0)
+ { // there's a line break present - emit the line break
+ emitLineBreak(); // output the line break character
+ if (++line_break0) && (nobreak_count<=0))
+ { // we can output the line break anywhere in the subsequence...
+ while (nchars>0)
+ { // figure out how many characters we can output WITHOUT causing a line break
+ int curlen = nchars;
+ int remaining_space = (int)(config.getWordWrapLength() - columns);
+ if (curlen>remaining_space)
+ curlen = remaining_space;
+
+ // output those characters
+ emitString(temp_buffer.substring(0,curlen),config.getOutputFilters(),true);
+ temp_buffer.delete(0,curlen);
+ nchars -= curlen;
+
+ if (columns==config.getWordWrapLength())
+ emitLineBreak(); // and line break us to get to the next line
+
+ } // end while
+
+ } // end if
+ else
+ { // just output the run of characters straight
+ emitString(temp_buffer.substring(0,nchars),config.getOutputFilters(),true);
+ temp_buffer.delete(0,nchars);
+
+ } // end else
+
+ } // end emitFromStartOfTempBuffer
+
+ private void doFlushString()
+ {
+ MarkupData md = attemptRewrite(string_rewriters,temp_buffer.toString());
+ if (md!=null)
+ { // we've got something marked up! output it...
+ emitMarkupData(md);
+ temp_buffer.setLength(0);
+ return;
+
+ } // end if
+
+ while (temp_buffer.length()>0)
+ { // find the length of the initial string of word or non-word characters
+ int sublen = getRunLength(temp_buffer);
+
+ if (isWordChar(temp_buffer.charAt(0)))
+ { // we need to check the word...but first, we must eliminate leading hyphens
+ int hyph_count = 0;
+ while ((hyph_count0) && (temp_buffer.charAt(word_len-1)=='-'))
+ { // decrement word length, increment hyphen count
+ hyph_count++;
+ word_len--;
+
+ } // end while
+
+ if (word_len>0)
+ { // extract the word from the start of the buffer
+ String word = temp_buffer.substring(0,word_len);
+ temp_buffer.delete(0,word_len);
+
+ // try to rewrite this word...
+ md = attemptRewrite(word_rewriters,word);
+ if (md!=null)
+ emitMarkupData(md);
+ else
+ { // just output the word normally
+ ensureSpaceOnLine(word.length());
+ emitString(word,config.getOutputFilters(),true);
+
+ } // end else
+
+ } // end if
+
+ // now emit the rest of the hyphens
+ emitFromStartOfTempBuffer(hyph_count);
+
+ } // end if
+ else // just emit this many characters, line-breaking where required
+ emitFromStartOfTempBuffer(sublen);
+
+ } // end while
+
+ } // end doFlushString
+
+ private boolean handleAsHTML()
+ {
+ trigger_WBR = false; // initialize
+
+ // Figure out the place in the buffer where the command word starts.
+ int start_cmd = 0;
+ boolean closing_tag = false;
+ if ((start_cmdTagRepository.getMaxTagLength()))
+ return false; // the command word is empty or is just too long to be an HTML tag
+
+ // Look up the tag name to get a tag index from the repository.
+ int tag_index = TagRepository.tagNameToIndex(temp_buffer.substring(start_cmd,end_cmd));
+ if (tag_index<0)
+ return false; // not a known HTML tag
+
+ // Look up the tag object that corresponds to the tag index.
+ SimpleTag tagobj = TagRepository.tagIndexToObject(tag_index);
+ if (closing_tag && !(tagobj.allowClose()))
+ return false; // this is a closing tag, and this tag doesn't permit the "close" form
+
+ // Get the HTML tag set index for this tag, and see if we allow that set.
+ int tag_set_id = TagRepository.tagIndexToSet(tag_index);
+ if (!(config.isTagSetAllowed(tag_set_id)) && !(config.getDiscardHTMLTags()))
+ return false; // we're not allowing it, we're not discarding it, so punt!
+
+ boolean valid = false;
+ if (!(config.getDiscardHTMLTags()) && tagobj.balanceTags())
+ { // this tag needs to be balanced - here is where we manipulate the stack
+ if (closing_tag)
+ { // hunt through the list to find the most recently-opened tag of this type
+ int i = tag_stack.size() - 1;
+ while (i>=0)
+ { // look through the stack...
+ Integer foo = (Integer)(tag_stack.get(i));
+ if (foo.intValue()==tag_index)
+ { // found it - remove it from the tag stack
+ tag_stack.remove(i);
+ valid = true;
+ break;
+
+ } // end if
+
+ } // end while
+
+ } // end if
+ else
+ { // push a new opening tag!
+ tag_stack.add(new Integer(tag_index));
+ valid = true;
+
+ } // end else
+
+ } // end if
+ // else tag doesn't need to be auto-balanced, or is being discarded
+
+ if (!valid && !(config.getDiscardHTMLTags()))
+ return false; // not validated by the stack code, and not being discarded
+
+ // Give the tag object one last chance to dictate what we do with the tag.
+ String real_tag_data = tagobj.rewriteTagContents(temp_buffer.toString(),closing_tag,this);
+ if ((real_tag_data==null) || config.getDiscardHTMLTags())
+ return true; // tag is being erased by rewriter, or is being discarded anyway
+
+ // Emit the tag to the output.
+ emitChar('<',config.getRawOutputFilters(),false);
+ emitString(real_tag_data,config.getRawOutputFilters(),false);
+ emitChar('>',config.getRawOutputFilters(),false);
+
+ // Determine whether this tag causes a "logical line break."
+ boolean logical_line_break = false;
+ if (trigger_WBR && !closing_tag && (nobreak_count>0))
+ logical_line_break = true;
+ else
+ logical_line_break = tagobj.causeLineBreak(closing_tag);
+ if (logical_line_break)
+ columns = 0;
+
+ return true; // handled!
+
+ } // end handleAsHTML()
+
+ private void finishTag()
+ {
+ if (handleAsHTML())
+ { // the tag has been handled as an HTML tag - bail out immediately
+ temp_buffer.setLength(0);
+ state = ST_WHITESPACE;
+ return;
+
+ } // end if
+
+ // now try to handle it using a tag rewriter
+ MarkupData md = attemptRewrite(tag_rewriters,temp_buffer.toString());
+ if (md!=null)
+ { // we've got something marked up! output it...
+ emitMarkupData(md,'<','>');
+ temp_buffer.setLength(0);
+ state = ST_WHITESPACE;
+ return;
+
+ } // end if
+
+ // This tag has been rejected! We need to process it normally, as character data.
+ String rejection = temp_buffer.toString();
+ temp_buffer.setLength(0);
+ temp_buffer.append('<');
+ state = ST_CHARS;
+ if (rejection.length()>0)
+ parse(rejection); // just run it through the parser, now that we've fixed up the state
+ parse(">");
+
+ } // end finishTag
+
+ private void finishParen()
+ {
+ // Try to handle the paren element using a paren rewriter.
+ MarkupData md = attemptRewrite(paren_rewriters,temp_buffer.toString());
+ if (md!=null)
+ { // we've got something marked up! output it...
+ emitMarkupData(md,'(',')');
+ temp_buffer.setLength(0);
+ state = ST_WHITESPACE;
+ paren_level = 0;
+ return;
+
+ } // end if
+
+ // This tag has been rejected! We need to process it normally, as character data.
+ String rejection = temp_buffer.toString();
+ temp_buffer.setLength(0);
+ temp_buffer.append('(');
+ state = ST_CHARS;
+ paren_level = 0;
+ if (rejection.length()>0)
+ parse(rejection); // just run it through the parser, now that we've fixed up the state
+ parse(")");
+
+ } // end finishParen
+
+ private void parse(String str)
+ {
+ int i = 0;
+ while (i': // end tag
+ finishTag(); // this changes the state, and maybe calls parse() recursively
+ i++;
+ break;
+
+ case '\'': // go into "quote string" mode inside tag
+ case '\"':
+ temp_buffer.append(ch);
+ state = ST_TAGQUOTE;
+ quote_char = ch;
+ i++;
+ break;
+
+ default: // just append more data to the temp buffer
+ temp_buffer.append(ch);
+ i++;
+ break;
+
+ } // end switch
+
+ } // end case
+ break;
+
+ case ST_PAREN:
+ { // inside parentheses - try to build something up
+ switch (ch)
+ {
+ case '(': // append the open parenthesis and kick it up a notch!
+ temp_buffer.append(ch);
+ paren_level++;
+ i++;
+ break;
+
+ case ')':
+ if (paren_level==0)
+ finishParen(); // will change the parser state
+ else
+ { // append the close parenthesis and kick it DOWN a notch
+ temp_buffer.append(ch);
+ paren_level--;
+
+ } // end else
+ i++;
+ break;
+
+ default:
+ temp_buffer.append(ch);
+ i++;
+ break;
+
+ } // end switch
+
+ } // end case
+ break;
+
+ case ST_TAGQUOTE:
+ temp_buffer.append(ch);
+ if (ch==quote_char) // close quote seen - go back to ST_TAG state
+ state = ST_TAG;
+ i++;
+ break;
+
+ default:
+ throw new IllegalStateException("invalid parser state value");
+
+ } // end switch
+
+ } // end while (looking through string)
+
+ } // end parse
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface HTMLChecker
+ *--------------------------------------------------------------------------------
+ */
+
+ public void append(String str) throws AlreadyFinishedException
+ {
+ if (finished)
+ throw new AlreadyFinishedException();
+ if (!started)
+ { // initialize the parser state
+ initState();
+ started = true;
+
+ } // end if
+
+ parse(str); // parse things
+
+ } // end append
+
+ public void finish() throws AlreadyFinishedException
+ {
+ if (finished)
+ throw new AlreadyFinishedException();
+ if (!started)
+ { // set up the initial parser state (so we don't kill ourselves later)
+ initState();
+ started = true;
+
+ } // end if
+
+ // This is the "end parse" loop, in which we resolve any funny state the parser has
+ // found itself in and clear out the internal buffers.
+ boolean running = false;
+ do
+ { // what we do depends on the parser state...
+ switch (state)
+ {
+ case ST_WHITESPACE:
+ break; // discard any whitespace at the end of output
+
+ case ST_CHARS:
+ doFlushString(); // flush out the temporary buffer
+ break;
+
+ case ST_LEFTANGLE: // just emit a '<' character
+ emitPossibleLineBreak();
+ emitChar('<',config.getOutputFilters(),true);
+ break;
+
+ case ST_TAG:
+ case ST_TAGQUOTE:
+ { // we won't finish this tag, so it's automagically rejected
+ String rejection = temp_buffer.toString();
+ temp_buffer.setLength(0);
+ temp_buffer.append('<');
+ state = ST_CHARS;
+
+ // now parse the tag contents again
+ if (rejection.length()>0)
+ parse(rejection);
+
+ running = true; // go back around for another try
+
+ } // end case
+ break;
+
+ case ST_PAREN:
+ { // we won't finish this paren tag, so it's automagically rejected
+ String rejection = temp_buffer.toString();
+ temp_buffer.setLength(0);
+ temp_buffer.append('(');
+ state = ST_CHARS;
+ paren_level = 0;
+
+ // now parse the parenthesis contents again
+ if (rejection.length()>0)
+ parse(rejection);
+
+ running = true; // go back around for another try
+
+ } // end case
+ break;
+
+ } // end switch
+
+ } while (running); // end do
+
+ // Now close all the HTML tags that were left open.
+ for (int i=(tag_stack.size()-1); i>=0; i--)
+ { // get each element in the tag stack and append the appropriate closing tag
+ Integer foo = (Integer)(tag_stack.get(i));
+ SimpleTag tagobj = TagRepository.tagIndexToObject(foo.intValue());
+ output_buffer.append(tagobj.makeClosingTag());
+
+ } // end for
+
+ // deallocate some excess crap and mark the object as finished
+ killState();
+ lines++; // there's one extra line at the end
+ finished = true;
+
+ } // end finish
+
+ public void reset()
+ {
+ started = false;
+ finished = false;
+ trigger_WBR = false;
+ state = ST_WHITESPACE;
+ quote_char = '\0';
+ columns = 0;
+ lines = 0;
+ paren_level = 0;
+ output_buffer = null;
+ killState();
+
+ // Also reset all the counters.
+ Iterator it = counters.values().iterator();
+ while (it.hasNext())
+ { // reset each counter in turn
+ CountingRewriter cr = (CountingRewriter)(it.next());
+ cr.reset();
+
+ } // end while
+
+ } // end reset
+
+ public String getValue() throws NotYetFinishedException
+ {
+ if (!finished)
+ throw new NotYetFinishedException();
+ return output_buffer.toString();
+
+ } // end getValue
+
+ public int getLength() throws NotYetFinishedException
+ {
+ if (!finished)
+ throw new NotYetFinishedException();
+ return output_buffer.length();
+
+ } // end getLength
+
+ public int getLines() throws NotYetFinishedException
+ {
+ if (!finished)
+ throw new NotYetFinishedException();
+ return lines;
+
+ } // end getLines
+
+ public int getCounter(String name) throws NotYetFinishedException
+ {
+ if (!finished)
+ throw new NotYetFinishedException();
+ CountingRewriter cr = (CountingRewriter)(counters.get(name));
+ if (cr==null)
+ return 0;
+ else
+ return cr.getCount();
+
+ } // end getCounter
+
+ public Object getContextValue(String name)
+ {
+ return context_data.get(name);
+
+ } // end getContextValue
+
+ public void setContextValue(String name, Object val)
+ {
+ context_data.put(name,val);
+
+ } // end setContextValue
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface HTMLCheckerBackend
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getCheckerAttrValue(String name)
+ {
+ if (name=="ANCHORTAIL")
+ return config.getAnchorTail();
+
+ throw new IllegalArgumentException("attribute \"" + name + "\" is not defined");
+
+ } // end getCheckerAttrValue
+
+ public void sendTagMessage(String msg)
+ {
+ if (msg=="NOBR")
+ { // increment the no-break count
+ nobreak_count++;
+ return;
+
+ } // end if
+
+ if (msg=="/NOBR")
+ { // decrement the no-break count
+ nobreak_count--;
+ return;
+
+ } // end if
+
+ if (msg=="WBR")
+ { // trigger a word break
+ trigger_WBR = true;
+ return;
+
+ } // end if
+
+ throw new IllegalArgumentException("message \"" + msg + "\" is not defined");
+
+ } // end sendTagMessage
+
+ public Object getCheckerContextValue(String name)
+ {
+ return context_data.get(name);
+
+ } // end getCheckerContextValue
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface RewriterServices
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getRewriterAttrValue(String name)
+ {
+ return getCheckerAttrValue(name);
+
+ } // end getRewriterAttrValue
+
+ public Object getRewriterContextValue(String name)
+ {
+ return context_data.get(name);
+
+ } // end getRewriterContextValue
+
+} // end class HTMLCheckerImpl
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/ListElementTag.java b/src/com/silverwrist/venice/htmlcheck/impl/ListElementTag.java
new file mode 100644
index 0000000..90919e3
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/ListElementTag.java
@@ -0,0 +1,44 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+class ListElementTag extends OpenCloseTag
+{
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ ListElementTag(String name)
+ {
+ super(name,true);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public boolean causeLineBreak(boolean is_closing)
+ {
+ return !is_closing;
+
+ } // end causeLineBreak
+
+} // end class ListElementTag
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/OpenCloseTag.java b/src/com/silverwrist/venice/htmlcheck/impl/OpenCloseTag.java
new file mode 100644
index 0000000..c69451c
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/OpenCloseTag.java
@@ -0,0 +1,50 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+class OpenCloseTag extends SimpleTag
+{
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ OpenCloseTag(String name, boolean brk)
+ {
+ super(name,brk);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public final boolean allowClose()
+ {
+ return true;
+
+ } // end allowClose
+
+ public final String makeClosingTag()
+ {
+ return "" + getTagName() + ">";
+
+ } // end makeClosingTag
+
+} // end class OpenCloseTag
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/SimpleTag.java b/src/com/silverwrist/venice/htmlcheck/impl/SimpleTag.java
new file mode 100644
index 0000000..b65cc28
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/SimpleTag.java
@@ -0,0 +1,103 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+class SimpleTag
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String tagname; // the name of the tag
+ private boolean linebreak; // does tag cause line breaks?
+ private int index; // index of the tag
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ SimpleTag(String name, boolean brk)
+ {
+ tagname = name.toUpperCase();
+ linebreak = brk;
+ index = -1;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Operations usable only within the package
+ *--------------------------------------------------------------------------------
+ */
+
+ final void setIndex(int ndx)
+ {
+ if (index==-1)
+ index = ndx;
+
+ } // end setIndex
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getTagName()
+ {
+ return tagname;
+
+ } // end getTagName
+
+ public boolean allowClose()
+ {
+ return false;
+
+ } // end allowClose
+
+ public boolean balanceTags()
+ {
+ return false;
+
+ } // end balanceTags
+
+ public boolean causeLineBreak(boolean is_closing)
+ {
+ return linebreak;
+
+ } // end causeLineBreak
+
+ public final int getIndex()
+ {
+ return index;
+
+ } // end getIndex
+
+ public String makeClosingTag()
+ {
+ throw new RuntimeException("cannot make closing tags of SimpleTag");
+
+ } // end makeClosingTag
+
+ public String rewriteTagContents(String contents, boolean is_closing, HTMLCheckerBackend context)
+ {
+ return contents; // just let everything pass for now
+
+ } // end rewriteTagContents
+
+} // end class SimpleTag
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/TagA.java b/src/com/silverwrist/venice/htmlcheck/impl/TagA.java
new file mode 100644
index 0000000..f6391fb
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/TagA.java
@@ -0,0 +1,124 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+class TagA extends BalancedTag
+{
+ /*--------------------------------------------------------------------------------
+ * Internal static data
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final String TARGET_ATTR = "TARGET";
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ TagA()
+ {
+ super("A",false);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String rewriteTagContents(String contents, boolean is_closing, HTMLCheckerBackend context)
+ {
+ if (is_closing)
+ return contents; // don't bother checking close tags
+
+ // Skip over the initial word of the tag data, as that's the tag name.
+ int i = 0;
+ while ((i!=contents.length()) && !(Character.isWhitespace(contents.charAt(i))))
+ i++;
+
+ // Search for the TARGET= attribute in the tag data.
+ boolean target_seen = false;
+ while (i!=contents.length())
+ { // skip over any whitespace between one attribute (or the name) and the next one
+ while ((i!=contents.length()) && Character.isWhitespace(contents.charAt(i)))
+ i++;
+ if (i==contents.length())
+ break; // reached end of string, all done searching
+
+ // Mark the start of this attribute name and start skipping over it.
+ int start_name = i;
+ while ((i!=contents.length()) && !(Character.isWhitespace(contents.charAt(i)))
+ && (contents.charAt(i)!='='))
+ i++;
+
+ // We now know where the attribute name is, see if it's "TARGET".
+ if ((i-start_name)==TARGET_ATTR.length())
+ { // compare the substring to see if it's right
+ String name = contents.substring(start_name,i);
+ if (name.equalsIgnoreCase(TARGET_ATTR))
+ { // OK, we saw the TARGET tag in the list! Bail out!
+ target_seen = true;
+ break;
+
+ } // end if
+
+ } // end if
+
+ while ((i!=contents.length()) && Character.isWhitespace(contents.charAt(i)))
+ i++; // skip over whitespace at end of name but before the = sign
+
+ if ((i.
+ *
+ * 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 Community 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.htmlcheck.impl;
+
+class TagNOBR extends BalancedTag
+{
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ TagNOBR()
+ {
+ super("NOBR",false);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String rewriteTagContents(String contents, boolean is_closing, HTMLCheckerBackend context)
+ {
+ if (is_closing)
+ context.sendTagMessage("/NOBR");
+ else
+ context.sendTagMessage("NOBR");
+ return contents;
+
+ } // end rewriteTagContents
+
+} // end class TagNOBR
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/TagRepository.java b/src/com/silverwrist/venice/htmlcheck/impl/TagRepository.java
new file mode 100644
index 0000000..dd40ad2
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/TagRepository.java
@@ -0,0 +1,243 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+import java.util.*;
+import com.silverwrist.venice.htmlcheck.HTMLTagSets;
+
+class TagRepository implements HTMLTagSets
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Hashtable tagname_to_index = new Hashtable(50,0.9F);
+ private static Vector index_to_object = new Vector();
+ private static Vector index_to_setid = new Vector();
+ private static int maxlength = 0;
+ private static boolean initialized = false;
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static void enshrineTag(SimpleTag tag, int set)
+ {
+ int ndx = index_to_object.size();
+ index_to_object.add(tag);
+ index_to_setid.add(new Integer(set));
+ tag.setIndex(ndx);
+ tagname_to_index.put(new String(tag.getTagName()),new Integer(ndx));
+ int newlen = tag.getTagName().length();
+ if (newlen>maxlength)
+ maxlength = newlen;
+
+ } // end enshrineTag
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static void init()
+ {
+ if (!initialized)
+ { // set the flag so we don't do this again
+ initialized = true;
+
+ // begin enshrining the tags!
+ enshrineTag(new SimpleTag("!DOCTYPE",false),DOC_FORMAT);
+ enshrineTag(new SimpleTag("%",false),SERVER_PAGE);
+ enshrineTag(new SimpleTag("%=",false),SERVER_PAGE);
+ enshrineTag(new SimpleTag("%@",false),SERVER_PAGE);
+ enshrineTag(new TagA(),ANCHOR);
+ enshrineTag(new BalancedTag("ABBR",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("ACRONYM",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("ADDRESS",true),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("APPLET",false),ACTIVE_CONTENT);
+ enshrineTag(new SimpleTag("AREA",false),IMAGE_MAPS);
+ enshrineTag(new BalancedTag("B",false),INLINE_FORMAT);
+ enshrineTag(new SimpleTag("BASE",false),DOC_FORMAT);
+ enshrineTag(new SimpleTag("BASEFONT",false),DOC_FORMAT);
+ enshrineTag(new BalancedTag("BDO",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("BEAN",false),JAVA_SERVER);
+ enshrineTag(new SimpleTag("BGSOUND",false),MSFT_DOC_FORMAT);
+ enshrineTag(new BalancedTag("BIG",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("BLINK",false),NSCP_INLINE_FORMAT);
+ enshrineTag(new BalancedTag("BLOCKQUOTE",true),BLOCK_FORMAT);
+ enshrineTag(new OpenCloseTag("BODY",false),DOC_FORMAT);
+ enshrineTag(new SimpleTag("BR",true),BLOCK_FORMAT);
+ enshrineTag(new OpenCloseTag("BUTTON",false),FORMS);
+ enshrineTag(new BalancedTag("CAPTION",true),TABLES);
+ enshrineTag(new BalancedTag("CENTER",true),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("CITE",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("CODE",false),INLINE_FORMAT);
+ enshrineTag(new SimpleTag("COL",true),TABLES);
+ enshrineTag(new OpenCloseTag("COLGROUP",true),TABLES);
+ enshrineTag(new BalancedTag("COMMENT",false),MSFT_INLINE_FORMAT);
+ enshrineTag(new ListElementTag("DD"),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("DEL",false),CHANGE_MARKUP);
+ enshrineTag(new BalancedTag("DFN",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("DIR",true),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("DIV",true),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("DL",true),BLOCK_FORMAT);
+ enshrineTag(new ListElementTag("DT"),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("EM",false),INLINE_FORMAT);
+ enshrineTag(new SimpleTag("EMBED",false),ACTIVE_CONTENT);
+ enshrineTag(new BalancedTag("FIELDSET",false),FORMS);
+ enshrineTag(new BalancedTag("FONT",false),FONT_FORMAT);
+ enshrineTag(new BalancedTag("FORM",false),FORMS);
+ enshrineTag(new SimpleTag("FRAME",true),FRAMES);
+ enshrineTag(new BalancedTag("FRAMESET",false),FRAMES);
+ enshrineTag(new BalancedTag("H1",true),FONT_FORMAT);
+ enshrineTag(new BalancedTag("H2",true),FONT_FORMAT);
+ enshrineTag(new BalancedTag("H3",true),FONT_FORMAT);
+ enshrineTag(new BalancedTag("H4",true),FONT_FORMAT);
+ enshrineTag(new BalancedTag("H5",true),FONT_FORMAT);
+ enshrineTag(new BalancedTag("H6",true),FONT_FORMAT);
+ enshrineTag(new OpenCloseTag("HEAD",false),DOC_FORMAT);
+ enshrineTag(new SimpleTag("HR",true),BLOCK_FORMAT);
+ enshrineTag(new OpenCloseTag("HTML",false),DOC_FORMAT);
+ enshrineTag(new BalancedTag("I",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("IFRAME",true),FRAMES);
+ enshrineTag(new BalancedTag("ILAYER",true),NSCP_LAYERS);
+ enshrineTag(new SimpleTag("IMG",false),IMAGES);
+ enshrineTag(new SimpleTag("INPUT",false),FORMS);
+ enshrineTag(new BalancedTag("INS",false),CHANGE_MARKUP);
+ enshrineTag(new SimpleTag("ISINDEX",false),FORMS);
+ enshrineTag(new BalancedTag("KBD",false),INLINE_FORMAT);
+ enshrineTag(new SimpleTag("KEYGEN",false),NSCP_FORMS);
+ enshrineTag(new BalancedTag("LABEL",false),FORMS);
+ enshrineTag(new BalancedTag("LAYER",true),NSCP_LAYERS);
+ enshrineTag(new BalancedTag("LEGEND",false),FORMS);
+ enshrineTag(new ListElementTag("LI"),BLOCK_FORMAT);
+ enshrineTag(new SimpleTag("LINK",false),DOC_FORMAT);
+ enshrineTag(new BalancedTag("LISTING",false),MSFT_INLINE_FORMAT);
+ enshrineTag(new BalancedTag("MAP",false),IMAGE_MAPS);
+ enshrineTag(new BalancedTag("MARQUEE",true),MSFT_BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("MENU",true),BLOCK_FORMAT);
+ enshrineTag(new SimpleTag("META",false),DOC_FORMAT);
+ enshrineTag(new BalancedTag("MULTICOL",true),NSCP_BLOCK_FORMAT);
+ enshrineTag(new TagNOBR(),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("NOEMBED",false),ACTIVE_CONTENT);
+ enshrineTag(new BalancedTag("NOFRAMES",false),FRAMES);
+ enshrineTag(new BalancedTag("NOLAYER",false),NSCP_LAYERS);
+ enshrineTag(new BalancedTag("NOSCRIPT",false),ACTIVE_CONTENT);
+ enshrineTag(new BalancedTag("OBJECT",false),ACTIVE_CONTENT);
+ enshrineTag(new BalancedTag("OL",true),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("OPTGROUP",false),FORMS);
+ enshrineTag(new ListElementTag("OPTION"),FORMS);
+ enshrineTag(new OpenCloseTag("P",true),BLOCK_FORMAT);
+ enshrineTag(new SimpleTag("PARAM",false),ACTIVE_CONTENT);
+ enshrineTag(new SimpleTag("PLAINTEXT",false),PREFORMAT);
+ enshrineTag(new BalancedTag("PRE",false),PREFORMAT);
+ enshrineTag(new BalancedTag("Q",false),INLINE_FORMAT);
+ enshrineTag(new SimpleTag("RT",false),MSFT_ACTIVE_CONTENT);
+ enshrineTag(new BalancedTag("RUBY",false),MSFT_ACTIVE_CONTENT);
+ enshrineTag(new BalancedTag("S",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("SAMP",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("SCRIPT",false),ACTIVE_CONTENT);
+ enshrineTag(new BalancedTag("SELECT",false),FORMS);
+ enshrineTag(new BalancedTag("SERVER",false),NSCP_SERVER);
+ enshrineTag(new BalancedTag("SERVLET",false),JAVA_SERVER);
+ enshrineTag(new BalancedTag("SMALL",false),INLINE_FORMAT);
+ enshrineTag(new SimpleTag("SPACER",false),NSCP_INLINE_FORMAT);
+ enshrineTag(new BalancedTag("SPAN",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("STRIKE",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("STRONG",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("STYLE",false),DOC_FORMAT);
+ enshrineTag(new BalancedTag("SUB",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("SUP",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("TABLE",true),TABLES);
+ enshrineTag(new OpenCloseTag("TBODY",false),TABLES);
+ enshrineTag(new BalancedTag("TD",true),TABLES);
+ enshrineTag(new BalancedTag("TEXTAREA",true),FORMS);
+ enshrineTag(new OpenCloseTag("TFOOT",false),TABLES);
+ enshrineTag(new BalancedTag("TH",true),TABLES);
+ enshrineTag(new OpenCloseTag("THEAD",false),TABLES);
+ enshrineTag(new BalancedTag("TITLE",false),DOC_FORMAT);
+ enshrineTag(new BalancedTag("TR",true),TABLES);
+ enshrineTag(new BalancedTag("TT",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("U",false),INLINE_FORMAT);
+ enshrineTag(new BalancedTag("UL",true),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("VAR",false),INLINE_FORMAT);
+ enshrineTag(new TagWBR(),BLOCK_FORMAT);
+ enshrineTag(new BalancedTag("XML",false),MSFT_ACTIVE_CONTENT);
+ enshrineTag(new BalancedTag("XMP",false),NSCP_INLINE_FORMAT);
+
+ } // end if
+
+ } // end init
+
+ public static int getMaxTagLength()
+ {
+ return maxlength;
+
+ } // end getMaxTagLength
+
+ public static int tagNameToIndex(String tag)
+ { // look up tag name and get index
+ Object obj = tagname_to_index.get(tag.toUpperCase());
+ if (obj==null)
+ return -1;
+ else
+ return ((Integer)obj).intValue();
+
+ } // end tagNameToIndex
+
+ public static SimpleTag tagIndexToObject(int ndx)
+ {
+ Object obj = index_to_object.get(ndx);
+ if (obj==null)
+ return null;
+ else
+ return (SimpleTag)obj;
+
+ } // end tagIndexToObject
+
+ public static int tagIndexToSet(int ndx)
+ {
+ Object obj = index_to_setid.get(ndx);
+ if (obj==null)
+ return -1;
+ else
+ return ((Integer)obj).intValue();
+
+ } // end tagIndexToSet
+
+ public static void configureNormalSet(BitSet bs)
+ {
+ bs.xor(bs); // clears all bits presently set in the bitset
+ bs.set(INLINE_FORMAT);
+ bs.set(ANCHOR);
+ bs.set(BLOCK_FORMAT);
+ bs.set(FONT_FORMAT);
+ bs.set(IMAGES);
+
+ } // end configureNormalSet
+
+ public static void configureRestrictedSet(BitSet bs)
+ {
+ bs.xor(bs); // clears all bits presently set in the bitset
+ bs.set(INLINE_FORMAT);
+
+ } // end configureRestrictedSet
+
+} // end class TagRepository
diff --git a/src/com/silverwrist/venice/htmlcheck/impl/TagWBR.java b/src/com/silverwrist/venice/htmlcheck/impl/TagWBR.java
new file mode 100644
index 0000000..1ddfb95
--- /dev/null
+++ b/src/com/silverwrist/venice/htmlcheck/impl/TagWBR.java
@@ -0,0 +1,45 @@
+/*
+ * 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 Community 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.htmlcheck.impl;
+
+class TagWBR extends SimpleTag
+{
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ TagWBR()
+ {
+ super("WBR",false);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String rewriteTagContents(String contents, boolean is_closing, HTMLCheckerBackend context)
+ {
+ context.sendTagMessage("WBR");
+ return contents; // just let everything pass for now
+
+ } // end rewriteTagContents
+
+} // end class TagWBR
diff --git a/src/com/silverwrist/venice/security/Audit.java b/src/com/silverwrist/venice/security/Audit.java
new file mode 100644
index 0000000..a58a5f2
--- /dev/null
+++ b/src/com/silverwrist/venice/security/Audit.java
@@ -0,0 +1,58 @@
+/*
+ * 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 Community 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.security;
+
+public interface Audit
+{
+ // Codes 0-100 - System events
+
+ // Codes 101-200 - Login/user events
+ public static final int LOGIN_OK = 101;
+ public static final int LOGIN_FAIL = 102;
+ public static final int ACCOUNT_CREATE = 103;
+ public static final int VERIFY_OK = 104;
+ public static final int VERIFY_FAIL = 105;
+ public static final int USER_CONTACT_INFO = 106;
+ public static final int RESEND_CONFIRM = 107;
+ public static final int PASSWORD_CHANGE = 108;
+
+ // Codes 201-300 - SIG events
+ public static final int CREATE_SIG = 201;
+ public static final int SET_MEMBERSHIP = 202;
+ public static final int SIG_CONTACT_INFO = 203;
+ public static final int SIG_FEATURE_SET = 204;
+ public static final int SIG_NAME = 205;
+ public static final int SIG_ALIAS = 206;
+ public static final int SIG_CATEGORY = 207;
+ public static final int SIG_HIDE_INFO = 208;
+ public static final int SIG_MEMBERS_ONLY = 209;
+ public static final int SIG_JOIN_KEY = 210;
+ public static final int SIG_SECURITY = 211;
+
+ // Codes 301-400 - Conference events
+ public static final int CREATE_CONF = 301;
+ public static final int CONF_SECURITY = 302;
+ public static final int CONF_NAME = 303;
+ public static final int CONF_ALIAS = 304;
+ public static final int CONF_MEMBERSHIP = 305;
+ public static final int CREATE_TOPIC = 306;
+ public static final int DELETE_TOPIC = 307;
+ public static final int TOPIC_FREEZE = 308;
+ public static final int TOPIC_ARCHIVE = 309;
+
+} // end interface Audit
diff --git a/src/com/silverwrist/venice/security/AuditRecord.java b/src/com/silverwrist/venice/security/AuditRecord.java
new file mode 100644
index 0000000..aedd33b
--- /dev/null
+++ b/src/com/silverwrist/venice/security/AuditRecord.java
@@ -0,0 +1,241 @@
+/*
+ * 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 Community 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.security;
+
+import java.sql.*;
+import java.util.*;
+import com.silverwrist.venice.db.SQLUtil;
+import com.silverwrist.venice.core.InternalStateError;
+
+public class AuditRecord implements Audit
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private long record; // audit record identifier
+ private java.util.Date when; // the date/time of this audit event
+ private int type; // the audit event type
+ private int uid; // the user ID
+ private int sigid; // the SIG ID
+ private String ip; // the IP address of the user
+ private String[] data; // the data values associated with the record
+ private String descr = null; // audit record description
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public AuditRecord(int type, int uid, String ip, int sigid, String data1, String data2, String data3,
+ String data4)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = sigid;
+ setData(data1,data2,data3,data4);
+
+ } // end constructor
+
+ public AuditRecord(int type, int uid, String ip, int sigid, String data1, String data2, String data3)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = sigid;
+ setData(data1,data2,data3,null);
+
+ } // end constructor
+
+ public AuditRecord(int type, int uid, String ip, int sigid, String data1, String data2)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = sigid;
+ setData(data1,data2,null,null);
+
+ } // end constructor
+
+ public AuditRecord(int type, int uid, String ip, int sigid, String data1)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = sigid;
+ setData(data1,null,null,null);
+
+ } // end constructor
+
+ public AuditRecord(int type, int uid, String ip, int sigid)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = sigid;
+ setData(null,null,null,null);
+
+ } // end constructor
+
+ public AuditRecord(int type, int uid, String ip, String data1, String data2, String data3, String data4)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = 0;
+ setData(data1,data2,data3,data4);
+
+ } // end constructor
+
+ public AuditRecord(int type, int uid, String ip, String data1, String data2, String data3)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = 0;
+ setData(data1,data2,data3,null);
+
+ } // end constructor
+
+ public AuditRecord(int type, int uid, String ip, String data1, String data2)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = 0;
+ setData(data1,data2,null,null);
+
+ } // end constructor
+
+ public AuditRecord(int type, int uid, String ip, String data1)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = 0;
+ setData(data1,null,null,null);
+
+ } // end constructor
+
+ public AuditRecord(int type, int uid, String ip)
+ {
+ setBaseData(type,uid,ip);
+ this.sigid = 0;
+ setData(null,null,null,null);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private void setBaseData(int type, int uid, String ip)
+ {
+ this.record = 0;
+ this.when = null;
+ this.type = type;
+ this.uid = uid;
+ this.ip = ip;
+
+ } // end setBaseData
+
+ private void setData(String data1, String data2, String data3, String data4)
+ {
+ data = new String[4];
+ data[0] = data1;
+ data[1] = data2;
+ data[2] = data3;
+ data[3] = data4;
+
+ } // end setData
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public long getRecord()
+ {
+ return record;
+
+ } // end getRecord
+
+ public java.util.Date getDateTime()
+ {
+ return when;
+
+ } // end getDateTime
+
+ public int getType()
+ {
+ return type;
+
+ } // end getType
+
+ public int getUID()
+ {
+ return uid;
+
+ } // end getType
+
+ public int getSIGID()
+ {
+ return sigid;
+
+ } // end getType
+
+ public String getIPAddress()
+ {
+ return ip;
+
+ } // end getIPAddress
+
+ public String getData(int ndx)
+ {
+ return data[ndx];
+
+ } // end getData
+
+ public String getDescription()
+ {
+ return descr;
+
+ } // end getDescription
+
+ public void store(Connection conn) throws SQLException
+ {
+ if (record!=0)
+ throw new InternalStateError("audit record " + String.valueOf(record) + " already stored!");
+
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LOCK TABLES audit WRITE;");
+ try
+ { // attempt to insert a record into the audit table
+ StringBuffer sql = new StringBuffer("INSERT INTO audit (on_date, event, uid, sigid, ip, data1, data2, "
+ + "data3, data4) VALUES ('");
+ java.util.Date now = new java.util.Date();
+ sql.append(SQLUtil.encodeDate(now)).append("', ").append(type).append(", ").append(uid).append(", ");
+ sql.append(sigid).append(", '").append(SQLUtil.encodeString(ip)).append("', ");
+ sql.append(SQLUtil.encodeStringArg(data[0])).append(", ").append(SQLUtil.encodeStringArg(data[1]));
+ sql.append(", ").append(SQLUtil.encodeStringArg(data[2])).append(", ");
+ sql.append(SQLUtil.encodeStringArg(data[3])).append(");");
+
+ stmt.executeUpdate(sql.toString());
+
+ ResultSet rs = stmt.executeQuery("SELECT LAST_INSERT_ID();");
+ if (!(rs.next()))
+ throw new InternalStateError("AuditRecord.store bogus query - must return at least 1 row!");
+ record = rs.getLong(1);
+ when = now;
+
+ } // end try
+ finally
+ { // make sure we unlock the tables before we go
+ Statement ulk_stmt = conn.createStatement();
+ ulk_stmt.executeUpdate("UNLOCK TABLES;");
+
+ } // end finally
+
+ } // end store
+
+} // end class AuditRecord
diff --git a/src/com/silverwrist/venice/security/Capability.java b/src/com/silverwrist/venice/security/Capability.java
new file mode 100644
index 0000000..9793304
--- /dev/null
+++ b/src/com/silverwrist/venice/security/Capability.java
@@ -0,0 +1,100 @@
+/*
+ * 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 Community 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.security;
+
+public class Capability implements SecLevels
+{
+ public static boolean canDesignatePFYs(int level)
+ {
+ return (level>=GLOBAL_BOFH);
+
+ } // end canDesignatePFYs
+
+ public static boolean isCommunityAdmin(int level)
+ {
+ return (level>=SIG_ANYADMIN);
+
+ } // end isCommunityAdmin
+
+ public static boolean hideHiddenCategories(int level)
+ {
+ return (level=GLOBAL_ANYADMIN);
+
+ } // end exemptFromEmailVerification
+
+ public static boolean canSeeHiddenContactFields(int level)
+ {
+ return (level>=GLOBAL_ANYADMIN);
+
+ } // end canSeeHiddenContactFields
+
+ public static boolean exemptFromMembershipRequirement(int level)
+ {
+ return (level>=GLOBAL_ANYADMIN);
+
+ } // end exemptFromMembershipRequirement
+
+ public static boolean hideHiddenSearchSIGs(int level)
+ {
+ return (level=GLOBAL_ANYADMIN);
+
+ } // end canJoinPrivateSIGWithoutKey
+
+ public static boolean showHiddenSearchCategories(int level)
+ {
+ return (level>=GLOBAL_ANYADMIN);
+
+ } // end hideHiddenSearchSIGs
+
+ public static boolean showHiddenSIGMembers(int level)
+ {
+ return (level>=SIG_ANYADMIN);
+
+ } // end showHiddenSIGMembers
+
+ public static boolean canCreateSIG(int level)
+ {
+ return (level>=GLOBAL_NORMAL);
+
+ } // end canCreateSIG
+
+ public static boolean hideHiddenConferences(int level)
+ {
+ return (level.
+ *
+ * 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 Community 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.security;
+
+public class DefaultLevels implements SecLevels
+{
+ public static int newUser()
+ {
+ return GLOBAL_UNVERIFIED;
+
+ } // end newUser
+
+ public static int memberSIG()
+ {
+ return SIG_MEMBER;
+
+ } // end memberSIG
+
+ public static int PFY()
+ {
+ return GLOBAL_PFY;
+
+ } // end PFY
+
+ public static int afterEmailVerification()
+ {
+ return GLOBAL_NORMAL;
+
+ } // end afterEmailVerification
+
+ public static int afterEmailAddressChange()
+ {
+ return GLOBAL_UNVERIFIED;
+
+ } // end afterEmailAddressChange
+
+ public static int newSIGRead()
+ {
+ return SIG_MEMBER;
+
+ } // end newSIGRead
+
+ public static int newSIGWrite()
+ {
+ return SIG_COHOST;
+
+ } // end newSIGWrite
+
+ public static int newSIGCreate()
+ {
+ return SIG_COHOST;
+
+ } // end newSIGCreate
+
+ public static int newSIGDelete()
+ {
+ return SIG_HOST;
+
+ } // end newSIGDelete
+
+ public static int newSIGJoin()
+ {
+ return GLOBAL_NORMAL;
+
+ } // end newSIGJoin
+
+ public static int creatorSIG()
+ {
+ return SIG_HOST;
+
+ } // end creatorSIG
+
+ public static int hostPrivsConference()
+ {
+ return CONFERENCE_ANYADMIN;
+
+ } // end hostPrivsConference
+
+ public static int memberConference()
+ {
+ return CONFERENCE_MEMBER;
+
+ } // end memberConference
+
+ public static int hostConference()
+ {
+ return CONFERENCE_HOST;
+
+ } // end hostConference
+
+ public static int newConferenceRead(boolean pvt)
+ {
+ return (pvt ? CONFERENCE_MEMBER : SIG_MEMBER);
+
+ } // end newConferenceRead
+
+ public static int newConferencePost(boolean pvt)
+ {
+ return (pvt ? CONFERENCE_MEMBER : SIG_MEMBER);
+
+ } // end newConferencePost
+
+ public static int newConferenceCreate(boolean pvt)
+ {
+ return (pvt ? CONFERENCE_MEMBER : SIG_MEMBER);
+
+ } // end newConferencePost
+
+ public static int newConferenceHide()
+ {
+ return CONFERENCE_HOST;
+
+ } // end newConferenceHide
+
+ public static int newConferenceNuke()
+ {
+ return CONFERENCE_HOST;
+
+ } // end newConferenceHide
+
+ public static int newConferenceChange()
+ {
+ return CONFERENCE_HOST;
+
+ } // end newConferenceHide
+
+ public static int newConferenceDelete()
+ {
+ return SIG_COHOST;
+
+ } // end newConferenceHide
+
+} // end class DefaultLevels
diff --git a/src/com/silverwrist/venice/security/PasswordHash.java b/src/com/silverwrist/venice/security/PasswordHash.java
new file mode 100644
index 0000000..37a70ed
--- /dev/null
+++ b/src/com/silverwrist/venice/security/PasswordHash.java
@@ -0,0 +1,137 @@
+/*
+ * 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 Community 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.security;
+
+import java.security.MessageDigest;
+
+public class PasswordHash
+{
+ // Attributes
+ private String value; // the hashed password value
+
+ public PasswordHash()
+ {
+ value = "";
+
+ } // end constructor
+
+ public PasswordHash(String password)
+ {
+ if ((password!=null) && (password.length()>0))
+ { // hash the password and save the hash value
+ MessageDigest hasher;
+
+ try
+ { // get a hasher implementing the Secure Hashing Algorithm
+ hasher = MessageDigest.getInstance("SHA");
+
+ } // end try
+ catch (java.security.NoSuchAlgorithmException e)
+ { // SHA should be a standard algorithm...if it isn't, we're h0sed
+ throw new RuntimeException("HOSED JRE - SHA should be a standard algorithm");
+
+ } // end catch
+
+ try
+ { // update the hasher with the UTF-8 bytes of the password
+ hasher.update(password.getBytes("UTF8"));
+
+ } // end try
+ catch (java.io.UnsupportedEncodingException e)
+ { // WTF? How can the JRE NOT know about UTF-8? HOW?!?
+ throw new RuntimeException("HOSED JRE - UTF-8 encoding should be supported");
+
+ } // end catch
+
+ // Retrieve the raw hash value (should be 160 bits, or 20 bytes)
+ byte[] raw_hash = hasher.digest();
+
+ // Convert the hash value to a hexadecimal string (40 chars in length)
+ StringBuffer hash_buf = new StringBuffer(raw_hash.length * 2);
+ StringBuffer tmp_buf = new StringBuffer();
+ String tmp;
+ for (int i=0; i.
+ *
+ * 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 Community 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.security;
+
+import java.util.*;
+
+public class Role implements Comparable, SecLevels
+{
+ /*--------------------------------------------------------------------------------
+ * Private implementation of ReadOnlyVector
+ *--------------------------------------------------------------------------------
+ */
+
+ static class ReadOnlyVector extends AbstractList
+ {
+ private Vector my_vec; // local vector
+
+ ReadOnlyVector(Vector vec)
+ {
+ my_vec = vec;
+ my_vec.trimToSize();
+
+ } // end constructor
+
+ protected void finalize() throws Throwable
+ {
+ my_vec = null;
+ super.finalize();
+
+ } // end finalize
+
+ public Object get(int index)
+ {
+ return my_vec.elementAt(index);
+
+ } // end get
+
+ public int size()
+ {
+ return my_vec.size();
+
+ } // end size
+
+ } // end class ReadOnlyVector
+
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Role no_access = null;
+ private static Role unrestricted_user = null;
+ private static Vector global_low = null;
+ private static Vector global_high = null;
+ private static Vector sig_low = null;
+ private static Vector sig_high = null;
+ private static Vector conf_low = null;
+ private static Vector conf_high = null;
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private int level;
+ private String name;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ protected Role(int level, String name)
+ {
+ this.level = level;
+ this.name = name;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static void initAllSets()
+ {
+ if (no_access==null)
+ no_access = new Role(NO_ACCESS,"No Access");
+
+ if (unrestricted_user==null)
+ unrestricted_user = new Role(UNRESTRICTED_USER,"'Unrestricted' User");
+
+ if (global_low==null)
+ { // initialize the "global lowband" vector
+ global_low = new Vector(3);
+ global_low.addElement(new Role(GLOBAL_ANONYMOUS,"Anonymous User"));
+ global_low.addElement(new Role(GLOBAL_UNVERIFIED,"Unauthenticated User"));
+ global_low.addElement(new Role(GLOBAL_NORMAL,"Normal User"));
+ global_low.trimToSize();
+
+ } // end if
+
+ if (global_high==null)
+ { // initialize the "global highband" vector
+ global_high = new Vector(3);
+ global_high.addElement(new Role(GLOBAL_ANYADMIN,"Any System Administrator"));
+ global_high.addElement(new Role(GLOBAL_PFY,"System Assistant Administrator"));
+ global_high.addElement(new Role(GLOBAL_BOFH,"Global System Administrator"));
+ global_high.trimToSize();
+
+ } // end if
+
+ if (sig_low==null)
+ { // initialize the "SIG lowband" vector
+ sig_low = new Vector(1);
+ sig_low.addElement(new Role(SIG_MEMBER,"SIG Member"));
+ sig_low.trimToSize();
+
+ } // end if
+
+ if (sig_high==null)
+ { // initialize the "SIG highband" vector
+ sig_high = new Vector(3);
+ sig_high.addElement(new Role(SIG_ANYADMIN,"Any SIG Administrator"));
+ sig_high.addElement(new Role(SIG_COHOST,"SIG Co-Host"));
+ sig_high.addElement(new Role(SIG_HOST,"SIG Host"));
+ sig_high.trimToSize();
+
+ } // end if
+
+ if (conf_low==null)
+ { // initialize the "conference lowband" vector
+ conf_low = new Vector(1);
+ conf_low.addElement(new Role(CONFERENCE_MEMBER,"Conference Member"));
+ conf_low.trimToSize();
+
+ } // end if
+
+ if (conf_high==null)
+ { // initialize the "conference highband" vector
+ conf_high = new Vector(1);
+ conf_high.addElement(new Role(CONFERENCE_ANYADMIN,"Any Conference Administrator"));
+ conf_high.addElement(new Role(CONFERENCE_HOST,"Conference Host"));
+ conf_high.trimToSize();
+
+ } // end if
+
+ } // end initAllSets
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getLevel()
+ {
+ return level;
+
+ } // end getLevel
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String toString()
+ {
+ StringBuffer buf = new StringBuffer(name);
+ buf.append('[').append(level).append(']');
+ return buf.toString();
+
+ } // end toString
+
+ public boolean equals(Object obj)
+ {
+ if (obj==null)
+ return false;
+ else if (obj==this)
+ return true;
+ if (obj instanceof Role)
+ { // compare levels
+ Role other = (Role)obj;
+ return (level==other.getLevel());
+
+ } // end if
+
+ return obj.toString().equals(toString());
+
+ } // end equals
+
+ public int hashCode()
+ {
+ return level;
+
+ } // end hashCode
+
+ public int compareTo(Object obj)
+ {
+ if (!(obj instanceof Role))
+ throw new ClassCastException("comparing non-Role to Role");
+ Role other = (Role)obj;
+ return level - other.getLevel();
+
+ } // end compareTo
+
+ /*--------------------------------------------------------------------------------
+ * External static operations which generate lists of roles
+ *--------------------------------------------------------------------------------
+ */
+
+ public static List getSIGReadList()
+ {
+ initAllSets();
+ Vector rc = new Vector();
+ rc.addAll(global_low);
+ rc.addAll(sig_low);
+ rc.add(unrestricted_user);
+ rc.addAll(sig_high);
+ rc.add(global_high.firstElement());
+ return new ReadOnlyVector(rc);
+
+ } // end getSIGReadList
+
+ public static List getSIGWriteList()
+ {
+ initAllSets();
+ Vector rc = new Vector();
+ rc.addAll(sig_high);
+ rc.addAll(global_high);
+ return new ReadOnlyVector(rc);
+
+ } // end getSIGWriteList
+
+ public static List getSIGCreateList()
+ {
+ initAllSets();
+ Vector rc = new Vector();
+ rc.add(global_low.lastElement());
+ rc.addAll(sig_low);
+ rc.add(unrestricted_user);
+ rc.addAll(sig_high);
+ rc.add(global_high.firstElement());
+ return new ReadOnlyVector(rc);
+
+ } // end getSIGCreateList
+
+ public static List getSIGDeleteList()
+ {
+ initAllSets();
+ Vector rc = new Vector();
+ rc.addAll(sig_high);
+ rc.addAll(global_high);
+ rc.add(no_access);
+ return new ReadOnlyVector(rc);
+
+ } // end getSIGDeleteList
+
+ public static List getSIGJoinList()
+ {
+ initAllSets();
+ return new ReadOnlyVector(global_low);
+
+ } // end getSIGJoinList
+
+} // end class Role
diff --git a/src/com/silverwrist/venice/security/SecLevels.java b/src/com/silverwrist/venice/security/SecLevels.java
new file mode 100644
index 0000000..32a1159
--- /dev/null
+++ b/src/com/silverwrist/venice/security/SecLevels.java
@@ -0,0 +1,98 @@
+/*
+ * 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 Community 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.security;
+
+public interface SecLevels
+{
+ /**
+ * Indicates "no access" (not even to the global system administrator). Used as the
+ * "delete" level for the Administration SIG, so it can't be accidentally deleted.
+ */
+ public static final int NO_ACCESS = 65500;
+ /**
+ * Indicates a user with unrestricted access to all objects, but no admin privilege.
+ * (Above the "low bands" of all scopes, but below the "high bands" of any of them.)
+ */
+ public static final int UNRESTRICTED_USER = 32500;
+ /**
+ * Indicates a user that has not logged in ("Anonymous Honyak"). Can be used as a
+ * permission level for SIGs and conferences to permit public reading and/or anonymous
+ * posting.
+ */
+ public static final int GLOBAL_ANONYMOUS = 100;
+ /**
+ * Indicates a user that has been registered, but has not yet had their email address
+ * verified.
+ */
+ public static final int GLOBAL_UNVERIFIED = 500;
+ /**
+ * Indicates a user that has registered and been verified. Can be used as a permission
+ * level for SIGs and conferences to permit reading and/or posting by nonmembers.
+ */
+ public static final int GLOBAL_NORMAL = 1000;
+ /**
+ * The security level of the global system administrator ("Administrator" account, sometimes
+ * known as the "BOFH" (Bastard Operator From Hell) account).
+ */
+ public static final int GLOBAL_BOFH = 64999;
+ /**
+ * A security level for "assistant admin" accounts (sometimes known as "PFY" (Pimply-
+ * Faced Youth) accounts).
+ */
+ public static final int GLOBAL_PFY = 64000;
+ /**
+ * A security level used to indicate any account with global admin privileges. Used
+ * to control access to the Administration community.
+ */
+ public static final int GLOBAL_ANYADMIN = 63000;
+ /**
+ * The security level assigned to members of a SIG within that SIG.
+ */
+ public static final int SIG_MEMBER = 6500;
+ /**
+ * The security level assigned to cohosts of a SIG within that SIG.
+ */
+ public static final int SIG_COHOST = 58000;
+ /**
+ * The security level assigned to hosts of a SIG within that SIG.
+ */
+ public static final int SIG_HOST = 58500;
+ /**
+ * A security level used to indicate any account with admin privileges over a specific SIG.
+ */
+ public static final int SIG_ANYADMIN = 57000;
+ /**
+ * The maximum level in the "high band" of the SIG scope; used to test if a user already has
+ * maximum privs within the SIG (because of being an admin at global scope, perhaps).
+ */
+ public static final int SIG_MAXADMIN = 58999;
+ /**
+ * The security level assigned to members of a (private) conference within that conference.
+ */
+ public static final int CONFERENCE_MEMBER = 12500;
+ /**
+ * The security level assigned to hosts of a conference within that conference.
+ */
+ public static final int CONFERENCE_HOST = 52500;
+ /**
+ * A security level used to indicate any account with admin privileges over a specific
+ * conference.
+ */
+ public static final int CONFERENCE_ANYADMIN = 51000;
+
+} // end interface SecLevels
diff --git a/src/com/silverwrist/venice/servlets/Account.java b/src/com/silverwrist/venice/servlets/Account.java
new file mode 100644
index 0000000..d268a9f
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/Account.java
@@ -0,0 +1,583 @@
+/*
+ * 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 Community 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;
+
+import java.io.*;
+import java.net.URLEncoder;
+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 Account extends VeniceServlet
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(Account.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private NewAccountDialog makeNewAccountDialog() throws ServletException
+ {
+ final String desired_name = "NewAccountDialog";
+ DialogCache cache = DialogCache.getDialogCache(getServletContext());
+
+ if (!(cache.isCached(desired_name)))
+ { // create a template and save it off
+ NewAccountDialog template = new NewAccountDialog(getCountryList());
+ cache.saveTemplate(template);
+
+ } // end if
+
+ // return a new copy
+ return (NewAccountDialog)(cache.getNewDialog(desired_name));
+
+ } // end makeNewAccountDialog
+
+ private LoginDialog makeLoginDialog()
+ {
+ final String desired_name = "LoginDialog";
+ DialogCache cache = DialogCache.getDialogCache(getServletContext());
+
+ if (!(cache.isCached(desired_name)))
+ { // create a template and save it off
+ LoginDialog template = new LoginDialog();
+ cache.saveTemplate(template);
+
+ } // end if
+
+ // return a new copy
+ return (LoginDialog)(cache.getNewDialog(desired_name));
+
+ } // end makeLoginDialog
+
+ private VerifyEmailDialog makeVerifyEmailDialog()
+ {
+ final String desired_name = "VerifyEmailDialog";
+ DialogCache cache = DialogCache.getDialogCache(getServletContext());
+
+ if (!(cache.isCached(desired_name)))
+ { // create a template and save it off
+ VerifyEmailDialog template = new VerifyEmailDialog();
+ cache.saveTemplate(template);
+
+ } // end if
+
+ // return a new copy
+ return (VerifyEmailDialog)(cache.getNewDialog(desired_name));
+
+ } // end makeVerifyEmailDialog
+
+ private EditProfileDialog makeEditProfileDialog() throws ServletException
+ {
+ final String desired_name = "EditProfileDialog";
+ DialogCache cache = DialogCache.getDialogCache(getServletContext());
+
+ if (!(cache.isCached(desired_name)))
+ { // create a template and save it off
+ EditProfileDialog template = new EditProfileDialog(getCountryList());
+ cache.saveTemplate(template);
+
+ } // end if
+
+ // return a new copy
+ return (EditProfileDialog)(cache.getNewDialog(desired_name));
+
+ } // end makeEditProfileDialog
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class HttpServlet
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getServletInfo()
+ {
+ String rc = "Account servlet - Handles login, logout, account creation, and profiles\n"
+ + "Part of the Venice Web Communities System\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ RenderData rdat = createRenderData(request,response);
+ UserContext user = getUserContext(request);
+ String page_title = null;
+ ContentRender content = null;
+ boolean display_login = false;
+
+ String tgt = request.getParameter("tgt"); // target location
+ if (tgt==null)
+ tgt = "top"; // go back to the Top screen if nothing else
+ String cmd = request.getParameter("cmd"); // command parameter
+
+ if (cmd.equals("L"))
+ { // "L" = Log in/out
+ if (user.isLoggedIn())
+ { // log the user out and send 'em back to the "top" page
+ clearUserContext(request);
+ // TODO: here is where the persistent cookie gets nuked, if it does...
+ rdat.redirectTo("top");
+ return;
+
+ } // end if (logging out)
+ else
+ { // display the Login page
+ LoginDialog dlg = makeLoginDialog();
+ dlg.setupNew(tgt);
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end else
+
+ } // end if ("L" command)
+ else if (cmd.equals("C"))
+ { // "C" = create new account
+ if (user.isLoggedIn())
+ { // you can't create a new account while logged in on an existing one!
+ page_title = "Error";
+ content = new ErrorBox(page_title,"You cannot create a new account while logged in on "
+ + "an existing one. You must log out first.",tgt);
+
+ } // end if
+ else
+ { // display the "Create Account" page
+ NewAccountDialog dlg = makeNewAccountDialog();
+ dlg.setEngine(getVeniceEngine());
+ page_title = dlg.getTitle();
+ dlg.setTarget(tgt);
+ dlg.setFieldValue("country","US");
+ content = dlg;
+
+ } // end else
+
+ } // end if ("C" command)
+ else if (cmd.equals("P"))
+ { // "P" = user profile
+ if (user.isLoggedIn())
+ { // display the User Profile page
+ EditProfileDialog dlg = makeEditProfileDialog();
+ try
+ { // load the profile information
+ dlg.setupDialog(user,tgt);
+
+ // prepare for display
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end try
+ catch (DataException e)
+ { // we couldn't load the contact info for the profile
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error retrieving profile: " + e.getMessage(),tgt);
+
+ } // end catch
+
+ } // end if
+ else
+ { // you have to be logged in for this one!
+ page_title = "Error";
+ content = new ErrorBox(page_title,"You must log in before you can modify the profile "
+ + "on your account.",tgt);
+
+ } // end else
+
+ } // end if ("P" command)
+ else if (cmd.equals("V"))
+ { // "V" = verify email address
+ display_login = true;
+
+ if (user.isLoggedIn())
+ { // display the Verify E-mail Address page
+ VerifyEmailDialog dlg = makeVerifyEmailDialog();
+ page_title = dlg.getTitle();
+ dlg.setTarget(tgt);
+ content = dlg;
+
+ } // end if
+ else
+ { // you have to be logged in for this one!
+ page_title = "Error";
+ content = new ErrorBox(page_title,"You must log in before you can verify your account's "
+ + "email address.",tgt);
+
+ } // end else
+
+ } // end else if ("V" command)
+ else
+ { // unknown command
+ page_title = "Internal Error";
+ logger.error("invalid command to Account.doGet: " + cmd);
+ content = new ErrorBox(page_title,"Invalid command to Account.doGet",tgt);
+
+ } // end else
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"account?cmd=" + cmd,content);
+ basedat.displayLoginLinks(display_login);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doGet
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ RenderData rdat = createRenderData(request,response);
+ UserContext user = getUserContext(request);
+ String page_title = null;
+ ContentRender content = null;
+ boolean display_login = false;
+
+ String tgt = request.getParameter("tgt"); // target location
+ if (tgt==null)
+ tgt = "top"; // go back to Top screen if nothing else
+ String cmd = request.getParameter("cmd"); // command parameter
+
+ if (cmd.equals("L"))
+ { // log the user in
+ LoginDialog dlg = makeLoginDialog();
+
+ if (dlg.isButtonClicked(request,"cancel"))
+ { // go back where we came from - we decided not to log in anyhoo
+ rdat.redirectTo(tgt);
+ return;
+
+ } // end if (canceled)
+
+ if (dlg.isButtonClicked(request,"remind"))
+ { // this will email a password reminder to the owner's account
+ dlg.loadValues(request); // load the dialog values
+ try
+ { // send the password reminder
+ getVeniceEngine().sendPasswordReminder(dlg.getFieldValue("user"));
+
+ // recycle and redisplay the dialog box
+ dlg.resetOnError("Password reminder has been sent to your e-mail address.");
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end try
+ catch (DataException e1)
+ { // this indicates a database error - display an ErrorBox
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error finding user: " + e1.getMessage(),tgt);
+
+ } // end catch
+ catch (AccessError e2)
+ { // this indicates a problem with the user account or password
+ page_title = "User E-mail Address Not Found";
+ content = new ErrorBox(page_title,e2.getMessage(),tgt);
+
+ } // end catch
+ catch (EmailException ee)
+ { // error sending the confirmation email
+ page_title = "E-mail Error";
+ content = new ErrorBox(page_title,"E-mail error sending reminder: " + ee.getMessage(),tgt);
+
+ } // end catch
+
+ } // end if ("reminder" button clicked)
+ else if (dlg.isButtonClicked(request,"login"))
+ { // we actually want to try and log in! imagine that!
+ dlg.loadValues(request); // load the values
+
+ try
+ { // 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...
+
+ // assuming it worked OK, redirect them back where they came from
+ // (or to the verification page if they need to go there)
+ String url;
+ if (user.isEmailVerified())
+ url = tgt;
+ else // they haven't verified yet - remind them to do so
+ url = "account?cmd=V&tgt=" + URLEncoder.encode(tgt);
+
+ clearMenu(request);
+ rdat.redirectTo(url);
+ return;
+
+ } // end try
+ catch (DataException e1)
+ { // this indicates a database error - display an ErrorBox
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error logging in: " + e1.getMessage(),tgt);
+
+ } // end catch
+ catch (AccessError e2)
+ { // this indicates a problem with the user account or password
+ dlg.resetOnError(e2.getMessage());
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end catch
+
+ } // end else if ("login" button clicked)
+ else
+ { // the button must be wrong!
+ page_title = "Internal Error";
+ logger.error("no known button click on Account.doPost, cmd=L");
+ content = new ErrorBox(page_title,"Unknown command button pressed",tgt);
+
+ } // end else
+
+ } // end if ("L" command)
+ else if (cmd.equals("C"))
+ { // C = Create New Account
+ NewAccountDialog dlg = makeNewAccountDialog();
+ dlg.setEngine(getVeniceEngine());
+
+ if (dlg.isButtonClicked(request,"cancel"))
+ { // go back where we came from - we decided not to create the account anyhoo
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
+ response.sendRedirect(url);
+ return;
+
+ } // end if ("cancel" button clicked)
+
+ if (dlg.isButtonClicked(request,"create"))
+ { // OK, actually want to create the account!
+ dlg.loadValues(request); // load field values
+
+ try
+ { // attempt to create the account
+ UserContext uc = dlg.doDialog(request);
+ putUserContext(request,uc); // effectively logging in the new user
+ user = uc;
+
+ // now jump to the Verify page
+ String partial = "account?cmd=V&tgt=" + URLEncoder.encode(tgt);
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(partial));
+ response.sendRedirect(url);
+ return;
+
+ } // end try
+ catch (ValidationException ve)
+ { // unable to validate some of the data in the form
+ dlg.resetOnError(ve.getMessage() + " Please try again.");
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end catch
+ catch (DataException de)
+ { // data error in setting up account
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error creating account: " + de.getMessage(),tgt);
+
+ } // end catch
+ catch (AccessError ae)
+ { // access error in setting up the account
+ dlg.resetOnError(ae.getMessage());
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end catch
+ catch (EmailException ee)
+ { // error sending the confirmation email
+ page_title = "E-mail Error";
+ content = new ErrorBox(page_title,"E-mail error creating account: " + ee.getMessage(),tgt);
+
+ } // end catch
+
+ } // end if ("create" button clicked)
+ else
+ { // the button must be wrong!
+ page_title = "Internal Error";
+ logger.error("no known button click on Account.doPost, cmd=C");
+ content = new ErrorBox(page_title,"Unknown command button pressed",tgt);
+
+ } // end else
+
+ } // end else if ("C" command)
+ else if (cmd.equals("V"))
+ { // V = Verify E-mail Address
+ display_login = true;
+ VerifyEmailDialog dlg = makeVerifyEmailDialog();
+
+ if (dlg.isButtonClicked(request,"cancel"))
+ { // go back to our desired location
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
+ response.sendRedirect(url);
+ return;
+
+ } // end if ("cancel" button clicked)
+
+ if (dlg.isButtonClicked(request,"again"))
+ { // do a "send again"
+ try
+ { // resend the email confirmation
+ user.resendEmailConfirmation();
+
+ // now force the form to be redisplayed
+ dlg.clearAllFields();
+ dlg.setTarget(tgt);
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end try
+ catch (DataException de)
+ { // data error in setting up account
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error sending confirmation: " + de.getMessage(),tgt);
+
+ } // end catch
+ catch (EmailException ee)
+ { // error sending the confirmation email
+ page_title = "E-mail Error";
+ content = new ErrorBox(page_title,"E-mail error sending confirmation: " + ee.getMessage(),tgt);
+
+ } // end catch
+
+ } // end if ("again" clicked)
+ else if (dlg.isButtonClicked(request,"ok"))
+ { // try to verify the confirmation number
+ dlg.loadValues(request); // load field values
+
+ try
+ { // validate that we have a good number
+ dlg.validate();
+ user.confirmEmail(dlg.getConfirmationNumber());
+
+ // go back to our desired location
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
+ response.sendRedirect(url);
+ return;
+
+ } // end try
+ catch (ValidationException ve)
+ { // there was a validation error...
+ dlg.resetOnError(ve.getMessage() + " Please try again.");
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end catch
+ catch (DataException de)
+ { // data error in setting up account
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error verifying email: " + de.getMessage(),tgt);
+
+ } // end catch
+ catch (AccessError ae)
+ { // access error in setting up the account
+ dlg.resetOnError(ae.getMessage());
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end catch
+
+ } // end else if ("OK" clicked)
+ else
+ { // the button must be wrong!
+ page_title = "Internal Error";
+ logger.error("no known button click on Account.doPost, cmd=V");
+ content = new ErrorBox(page_title,"Unknown command button pressed",tgt);
+
+ } // end else
+
+ } // end else if ("V" command)
+ else if (cmd.equals("P"))
+ { // P = Edit User Profile
+ display_login = true;
+ EditProfileDialog dlg = makeEditProfileDialog();
+
+ if (dlg.isButtonClicked(request,"cancel"))
+ { // go back to our desired location
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
+ response.sendRedirect(url);
+ return;
+
+ } // end if ("cancel" button clicked)
+
+ if (dlg.isButtonClicked(request,"update"))
+ { // we're ready to update the user profile
+ dlg.loadValues(request); // load field values
+
+ try
+ { // validate the dialog and start setting info
+ String url;
+ if (dlg.doDialog(user))
+ { // the email address was changed - need to jump to the "Verify" page
+ String partial = "account?cmd=V&tgt=" + URLEncoder.encode(tgt);
+ url = response.encodeRedirectURL(rdat.getFullServletPath(partial));
+
+ } // end if
+ else // just go back where we came from
+ url = response.encodeRedirectURL(rdat.getFullServletPath(tgt));
+
+ response.sendRedirect(url);
+ return;
+
+ } // end try
+ catch (ValidationException ve)
+ { // there was a validation error...
+ dlg.resetOnError(ve.getMessage() + " Please try again.");
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end catch
+ catch (DataException de)
+ { // data error in setting up account
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error updating profile: " + de.getMessage(),tgt);
+
+ } // end catch
+ catch (EmailException ee)
+ { // error sending the confirmation email
+ page_title = "E-mail Error";
+ content = new ErrorBox(page_title,"E-mail error sending confirmation: " + ee.getMessage(),tgt);
+
+ } // end catch
+
+ } // end if ("update" button pressed)
+ else
+ { // the button must be wrong!
+ page_title = "Internal Error";
+ logger.error("no known button click on Account.doPost, cmd=P");
+ content = new ErrorBox(page_title,"Unknown command button pressed",tgt);
+
+ } // end else
+
+ } // end else if ("P" command)
+ else
+ { // unknown command
+ page_title = "Internal Error";
+ logger.error("invalid command to Account.doPost: " + cmd);
+ content = new ErrorBox(page_title,"Invalid command to Account.doPost",tgt);
+
+ } // end else
+
+ changeMenuTop(request);
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"account?cmd=" + cmd,content);
+ basedat.displayLoginLinks(display_login);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doPost
+
+} // end class Account
diff --git a/src/com/silverwrist/venice/servlets/ConfDisplay.java b/src/com/silverwrist/venice/servlets/ConfDisplay.java
new file mode 100644
index 0000000..01115d5
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/ConfDisplay.java
@@ -0,0 +1,321 @@
+/*
+ * 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;
+
+import java.io.*;
+import java.util.*;
+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 ConfDisplay extends VeniceServlet
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(ConfDisplay.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static SIGContext getSIGParameter(ServletRequest request, UserContext user)
+ throws ValidationException, DataException
+ {
+ String str = request.getParameter("sig");
+ if (str==null)
+ { // no SIG parameter - bail out now!
+ logger.error("SIG parameter not specified!");
+ throw new ValidationException("No SIG specified.");
+
+ } // end if
+
+ try
+ { // turn the string into a SIGID, and thence to a SIGContext
+ int sigid = Integer.parseInt(str);
+ return user.getSIGContext(sigid);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // error in Integer.parseInt
+ logger.error("Cannot convert SIG parameter '" + str + "'!");
+ throw new ValidationException("Invalid SIG parameter.");
+
+ } // end catch
+
+ } // end getSIGParameter
+
+ private static ConferenceContext getConferenceParameter(ServletRequest request, SIGContext sig)
+ throws ValidationException, DataException, AccessError
+ {
+ String str = request.getParameter("conf");
+ if (str==null)
+ { // no conference parameter - bail out now!
+ logger.error("Conference parameter not specified!");
+ throw new ValidationException("No conference specified.");
+
+ } // end if
+
+ try
+ { // turn the string into a ConfID, and thence to a ConferenceContext
+ int confid = Integer.parseInt(str);
+ return sig.getConferenceContext(confid);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // error in Integer.parseInt
+ logger.error("Cannot convert conference parameter '" + str + "'!");
+ throw new ValidationException("Invalid conference parameter.");
+
+ } // end catch
+
+ } // end getConferenceParameter
+
+ private static TopicContext getTopicParameter(ServletRequest request, ConferenceContext conf)
+ throws ValidationException, DataException, AccessError
+ {
+ String str = request.getParameter("top");
+ if (StringUtil.isStringEmpty(str))
+ return null; // no topic specified
+
+ try
+ { // turn the string into a TopicID, and thence to a TopicContext
+ short topicid = Short.parseShort(str);
+ return conf.getTopic(topicid);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // error in Integer.parseInt
+ logger.error("Cannot convert topic parameter '" + str + "'!");
+ throw new ValidationException("Invalid topic parameter.");
+
+ } // end catch
+
+ } // end getTopicParameter
+
+ private static void getViewSortDefaults(ServletRequest request, int confid, TopicSortHolder tsc)
+ throws ValidationException
+ {
+ String str = request.getParameter("view");
+ if (!(StringUtil.isStringEmpty(str)))
+ { // we need to change the view parameter
+ try
+ { // convert the parameter to an integer and then check it against defined values
+ int p = Integer.parseInt(str);
+ switch (p)
+ {
+ case ConferenceContext.DISPLAY_NEW:
+ case ConferenceContext.DISPLAY_ACTIVE:
+ case ConferenceContext.DISPLAY_ALL:
+ case ConferenceContext.DISPLAY_HIDDEN:
+ case ConferenceContext.DISPLAY_ARCHIVED:
+ tsc.setViewOption(confid,p);
+ break;
+
+ default:
+ throw new ValidationException("Invalid view parameter.");
+
+ } // end switch
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // failure in parseInt
+ logger.error("Cannot convert view parameter '" + str + "'!");
+ throw new ValidationException("Invalid view parameter.");
+
+ } // end catch
+
+ } // end if
+
+ str = request.getParameter("sort");
+ if (!(StringUtil.isStringEmpty(str)))
+ { // we need to change the sort parameter
+ try
+ { // convert the parameter to an integer and then check it against defined values
+ int p = Integer.parseInt(str);
+ int real_p = ((p<0) ? -p : p);
+ switch (real_p)
+ {
+ case ConferenceContext.SORT_NUMBER:
+ case ConferenceContext.SORT_NAME:
+ case ConferenceContext.SORT_UNREAD:
+ case ConferenceContext.SORT_TOTAL:
+ case ConferenceContext.SORT_DATE:
+ tsc.setSortOption(confid,p);
+ break;
+
+ default:
+ throw new ValidationException("Invalid sort parameter.");
+
+ } // end switch
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // failure in parseInt
+ logger.error("Cannot convert sort parameter '" + str + "'!");
+ throw new ValidationException("Invalid sort parameter.");
+
+ } // end catch
+
+ } // end if
+
+ } // end getViewSortDefaults
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class HttpServlet
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getServletInfo()
+ {
+ String rc = "ConfDisplay servlet - Display of conference topic and message lists\n"
+ + "Part of the Venice Web Communities System\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ Object content = null;
+ SIGContext sig = null; // SIG context
+ ConferenceContext conf = null; // conference context
+ TopicContext topic = null; // topic context
+
+ try
+ { // this outer try is to catch ValidationException
+ try
+ { // all commands require a SIG parameter
+ sig = getSIGParameter(request,user);
+ changeMenuSIG(request,sig);
+
+ } // end try
+ catch (DataException de)
+ { // error looking up the SIG
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
+
+ } // end catch
+
+ if (content!=null)
+ { // we got the SIG parameter OK
+ try
+ { // all commands require a conference parameter
+ conf = getConferenceParameter(request,sig);
+
+ } // end try
+ catch (DataException de)
+ { // error looking up the conference
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error finding conference: " + de.getMessage(),"top");
+
+ } // end catch
+
+ } // end if
+
+ if (content!=null)
+ { // we got the conference parameter OK
+ try
+ { // there's an optional topic parameter
+ topic = getTopicParameter(request,conf);
+
+ } // end try
+ catch (DataException de)
+ { // error looking up the conference
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error finding topic: " + de.getMessage(),"top");
+
+ } // end catch
+
+ } // end if
+
+ } // end try
+ catch (ValidationException ve)
+ { // these all get handled in pretty much the same way
+ page_title = "Error";
+ content = new ErrorBox(null,ve.getMessage(),"top");
+
+ } // end catch
+ catch (AccessError ae)
+ { // these all get handled in pretty much the same way
+ page_title = "Access Error";
+ content = new ErrorBox(page_title,ae.getMessage(),"top");
+
+ } // end catch
+
+ if (content!=null)
+ { // OK, let's handle the display now
+ if (topic!=null)
+ { // we're handling messages within a single topic
+ // TODO: handle this somehow
+ } // end if
+ else
+ { // we're displaying the conference's topic list
+ TopicSortHolder opts = TopicSortHolder.retrieve(request.getSession(true));
+ try
+ { // get any changes to view or sort options
+ getViewSortDefaults(request,conf.getConfID(),opts);
+
+ // get the topic list in the desired order!
+ List topic_list = conf.getTopicList(opts.getViewOption(conf.getConfID()),
+ opts.getSortOption(conf.getConfID()));
+
+ // TODO: create the "next topic" list to use for "read next"
+
+ // TODO: create the page view
+
+ } // end try
+ catch (ValidationException ve)
+ { // there was some sort of a parameter error in the display
+ page_title = "Error";
+ content = new ErrorBox(null,ve.getMessage(),"top");
+
+ } // end catch
+ catch (DataException de)
+ { // there was a database error retrieving topics
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error listing topics: " + de.getMessage(),"top");
+
+ } // end catch
+ catch (AccessError ae)
+ { // we were unable to retrieve the topic list
+ page_title = "Access Error";
+ content = new ErrorBox(page_title,ae.getMessage(),"top");
+
+ } // end catch
+
+ } // end else
+
+ } // end if
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"confdisp?" + request.getQueryString(),content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doGet
+
+} // end class ConfDisplay
diff --git a/src/com/silverwrist/venice/servlets/ConfOperations.java b/src/com/silverwrist/venice/servlets/ConfOperations.java
new file mode 100644
index 0000000..e5ff4d3
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/ConfOperations.java
@@ -0,0 +1,303 @@
+/*
+ * 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 Community 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;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.servlets.format.*;
+
+public class ConfOperations extends VeniceServlet
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(ConfOperations.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static SIGContext getSIGParameter(ServletRequest request, UserContext user)
+ throws ValidationException, DataException
+ {
+ String str = request.getParameter("sig");
+ if (str==null)
+ { // no SIG parameter - bail out now!
+ logger.error("SIG parameter not specified!");
+ throw new ValidationException("No SIG specified.");
+
+ } // end if
+
+ try
+ { // turn the string into a SIGID, and thence to a SIGContext
+ int sigid = Integer.parseInt(str);
+ return user.getSIGContext(sigid);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // error in Integer.parseInt
+ logger.error("Cannot convert SIG parameter '" + str + "'!");
+ throw new ValidationException("Invalid SIG parameter.");
+
+ } // end catch
+
+ } // end getSIGParameter
+
+ private CreateConferenceDialog makeCreateConferenceDialog() throws ServletException
+ {
+ final String desired_name = "CreateConferenceDialog";
+ DialogCache cache = DialogCache.getDialogCache(getServletContext());
+
+ if (!(cache.isCached(desired_name)))
+ { // create a template and save it off
+ CreateConferenceDialog template = new CreateConferenceDialog();
+ cache.saveTemplate(template);
+
+ } // end if
+
+ // return a new copy
+ return (CreateConferenceDialog)(cache.getNewDialog(desired_name));
+
+ } // end makeCreateConferenceDialog
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class HttpServlet
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getServletInfo()
+ {
+ String rc = "ConfOperations servlet - General conference operations (list, create, etc.)\n"
+ + "Part of the Venice Web Communities System\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ Object content = null;
+ SIGContext sig = null;
+
+ try
+ { // all conference commands require a SIG parameter as well
+ sig = getSIGParameter(request,user);
+ changeMenuSIG(request,sig);
+
+ } // end try
+ catch (ValidationException ve)
+ { // no SIG specified
+ page_title = "Error";
+ content = new ErrorBox(null,ve.getMessage(),"top");
+
+ } // end catch
+ catch (DataException de)
+ { // error looking up the SIG
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
+
+ } // end catch
+
+ if (content==null)
+ { // get the command we want to use
+ String cmd = request.getParameter("cmd");
+ if (cmd==null)
+ cmd = "???";
+
+ if (cmd.equals("C"))
+ { // "C" = "Create conference"
+ if (sig.canCreateConference())
+ { // make the create conference dialog!
+ CreateConferenceDialog dlg = makeCreateConferenceDialog();
+ dlg.setupDialog(getVeniceEngine(),sig);
+ content = dlg;
+ page_title = dlg.getTitle();
+
+ } // end if
+ else
+ { // we can't create conferences
+ page_title = "Error";
+ content = new ErrorBox("SIG Error","You are not permitted to create conferences in this SIG.","top");
+
+ } // end else
+
+ } // end if
+ else
+ { // any unrecognized command jumps us to "conference list"
+ try
+ { // show the conference listing
+ content = new ConferenceListing(sig);
+ page_title = "Conference Listing: " + sig.getName();
+
+ } // end try
+ catch (DataException de)
+ { // something wrong in the database
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error finding conferences: " + de.getMessage(),
+ "sigprofile?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+ catch (AccessError ae)
+ { // some lack of access is causing problems
+ page_title = "Access Error";
+ content = new ErrorBox(page_title,ae.getMessage(),
+ "sigprofile?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+
+ } // end else
+
+ } // end if (SIG parameter retrieved OK)
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"confops?" + request.getQueryString(),content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doGet
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ Object content = null;
+ SIGContext sig = null;
+ String location;
+
+ try
+ { // all conference commands require a SIG parameter as well
+ sig = getSIGParameter(request,user);
+ changeMenuSIG(request,sig);
+ location = "confops?sig=" + String.valueOf(sig.getSIGID());
+
+ } // end try
+ catch (ValidationException ve)
+ { // no SIG specified
+ page_title = "Error";
+ content = new ErrorBox(null,ve.getMessage(),"top");
+ location = "top";
+
+ } // end catch
+ catch (DataException de)
+ { // error looking up the SIG
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
+ location = "top";
+
+ } // end catch
+
+ if (content==null)
+ { // get the command we want to use
+ String cmd = request.getParameter("cmd");
+ if (cmd==null)
+ cmd = "???";
+
+ if (cmd.equals("C"))
+ { // "C" = "Create Conference"
+ if (sig.canCreateConference())
+ { // load up the create conference dialog!
+ CreateConferenceDialog dlg = makeCreateConferenceDialog();
+ dlg.setupDialog(getVeniceEngine(),sig);
+
+ if (dlg.isButtonClicked(request,"cancel"))
+ { // they chickened out - go back to the conference list
+ rdat.redirectTo(location);
+ return;
+
+ } // end if
+
+ if (dlg.isButtonClicked(request,"create"))
+ { // OK, they actually want to create the new conference...
+ dlg.loadValues(request); // load the form data
+
+ try
+ { // attempt to create the conference!
+ ConferenceContext conf = dlg.doDialog(sig);
+
+ // success! go back to the conference list
+ // TODO: want to jump to the conference's "topic list" page if possible
+ rdat.redirectTo(location);
+ return;
+
+ } // end try
+ catch (ValidationException ve)
+ { // validation error - throw it back to the user
+ dlg.resetOnError(ve.getMessage() + " Please try again.");
+ content = dlg;
+ page_title = dlg.getTitle();
+
+ } // end catch
+ catch (AccessError ae)
+ { // some sort of access error - display an error dialog
+ page_title = "Access Error";
+ content = new ErrorBox(page_title,ae.getMessage(),location);
+
+ } // end catch
+ catch (DataException de)
+ { // database error creating the conference
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error creating conference: " + de.getMessage(),
+ location);
+
+ } // end catch
+
+ } // end if
+ else
+ { // error - don't know what button was clicked
+ page_title = "Internal Error";
+ logger.error("no known button click on ConfOperations.doPost, cmd=C");
+ content = new ErrorBox(page_title,"Unknown command button pressed",location);
+
+ } // end else
+
+ } // end if
+ else
+ { // we can't create conferences
+ page_title = "Error";
+ content = new ErrorBox("SIG Error","You are not permitted to create conferences in this SIG.",
+ location);
+
+ } // end else
+
+ } // end if
+ else
+ { // unrecognized command!
+ page_title = "Internal Error";
+ logger.error("invalid command to ConfOperations.doPost: " + cmd);
+ content = new ErrorBox(page_title,"Invalid command to ConfOperations.doPost",location);
+
+ } // end else
+
+ } // end if (SIG parameter retrieved OK)
+
+ BaseJSPData basedat = new BaseJSPData(page_title,location,content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doPost
+
+} // end class ConfOperations
diff --git a/src/com/silverwrist/venice/servlets/Find.java b/src/com/silverwrist/venice/servlets/Find.java
new file mode 100644
index 0000000..8edb580
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/Find.java
@@ -0,0 +1,194 @@
+/*
+ * 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 Community 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;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.servlets.format.*;
+
+public class Find extends VeniceServlet
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ protected static final String DISPLAY_PARAM_ATTRIBUTE = "servlet.Find.display";
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static int getDisplayParam(HttpServletRequest request, int nchoices)
+ {
+ HttpSession session = request.getSession(true);
+
+ try
+ { // attempt to get the display parameter
+ String dp_str = request.getParameter("disp");
+ if (dp_str!=null)
+ { // attempt to convert to an integer and range-check it
+ int dp = Integer.parseInt(dp_str);
+ if ((dp>=0) && (dp.
+ *
+ * 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 Community 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;
+
+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 SIGAdmin extends VeniceServlet
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(SIGAdmin.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private SIGAdminTop makeSIGAdminTop() throws ServletException
+ {
+ final String desired_name = "SIGAdminTop";
+ MenuPanelCache cache = MenuPanelCache.getMenuPanelCache(getServletContext());
+
+ if (!(cache.isCached(desired_name)))
+ { // create a template and save it off
+ SIGAdminTop template = new SIGAdminTop();
+ cache.saveTemplate(template);
+
+ } // end if
+
+ // return a new copy
+ return (SIGAdminTop)(cache.getNewMenuPanel(desired_name));
+
+ } // end makeSIGAdminTop
+
+ private EditSIGProfileDialog makeEditSIGProfileDialog() throws ServletException
+ {
+ final String desired_name = "EditSIGProfileDialog";
+ DialogCache cache = DialogCache.getDialogCache(getServletContext());
+
+ if (!(cache.isCached(desired_name)))
+ { // create a template and save it off
+ EditSIGProfileDialog template = new EditSIGProfileDialog(getCountryList(),getLanguageList());
+ cache.saveTemplate(template);
+
+ } // end if
+
+ // return a new copy
+ return (EditSIGProfileDialog)(cache.getNewDialog(desired_name));
+
+ } // end makeEditSIGProfileDialog
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class HttpServlet
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getServletInfo()
+ {
+ String rc = "SIGAdmin servlet - Administrative functions for SIGs\n"
+ + "Part of the Venice Web Communities System\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ Object content = null;
+
+ SIGContext sig = null;
+ try
+ { // first get the SIG context we're working with
+ int sigid = Integer.parseInt(request.getParameter("sig"));
+ sig = user.getSIGContext(sigid);
+ changeMenuSIG(request,sig);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // an improperly formatted SIGID brought us down!
+ page_title = "Input Error";
+ logger.error("Somebody fed 'sig=" + request.getParameter("sig") + "' to this page, that's bogus");
+ content = new ErrorBox(page_title,"SIG ID not valid: " + request.getParameter("sig"),"top");
+
+ } // end catch
+ catch (DataException de)
+ { // unable to pull SIG data out of the database
+ page_title = "Database Error";
+ logger.error("database error looking up SIGID " + request.getParameter("sig"));
+ content = new ErrorBox(page_title,"Database error accessing SIG: " + de.getMessage(),"top");
+
+ } // end catch
+
+ if (logger.isDebugEnabled() && (sig!=null))
+ logger.debug("SIGAdmin/doGet operating on SIG \"" + sig.getName() + "\" ("
+ + String.valueOf(sig.getSIGID()) + ")");
+
+ if (content==null)
+ { // now decide what to do based on the "cmd" parameter
+ String cmd = request.getParameter("cmd");
+ if (cmd==null)
+ cmd = "???"; // something pretty much guaranteed not to be used
+
+ if (logger.isDebugEnabled())
+ logger.debug("SIGAdmin/doGet command value = " + cmd);
+
+ if (cmd.equals("P"))
+ { // this is the profile editing screen
+ if (sig.canModifyProfile())
+ { // construct the edit profile dialog and load it up for use
+ EditSIGProfileDialog dlg = makeEditSIGProfileDialog();
+
+ try
+ { // load the values for this dialog
+ dlg.setupDialog(getVeniceEngine(),sig);
+
+ // prepare for display
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end try
+ catch (DataException de)
+ { // we could not load the values because of a data exception
+ page_title = "Database Error";
+ logger.error("DB error loading SIG profile: " + de.getMessage(),de);
+ content = new ErrorBox(page_title,"Database error retrieving profile: " + de.getMessage(),
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+ catch (AccessError ae)
+ { // we don't have enough privilege
+ page_title = "Unauthorized";
+ logger.error("Access error loading SIG profile: " + ae.getMessage(),ae);
+ content = new ErrorBox(page_title,"You do not have access to modify this SIG's profile.",
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+
+ } // end if
+ else
+ { // no access - sorry, dude
+ page_title = "Unauthorized";
+ logger.error("tried to call up SIG profile screen without access...naughty naughty!");
+ content = new ErrorBox(page_title,"You do not have access to modify this SIG's profile.",
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end else
+
+ } // end if (profile editing)
+ else if (cmd.equals("T"))
+ { // this is the category set code!
+ if (sig.canModifyProfile())
+ { // did they actually send a "set" parameter?
+ String p = request.getParameter("set");
+ if (!(StringUtil.isStringEmpty(p)))
+ { // OK, we're setting the category ID...
+ try
+ { // get the new category ID and set it
+ int catid = Integer.parseInt(p);
+ if (!(getVeniceEngine().isValidCategoryID(catid)))
+ throw new NumberFormatException(); // dump the category if it's not valid
+
+ sig.setCategoryID(catid);
+
+ // now that the category ID is set, go back to the admin menu
+ String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
+ response.sendRedirect(url);
+ return;
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // we got an invalid category value...
+ page_title = "Invalid Input";
+ content = new ErrorBox(page_title,"Invalid category ID passed to category browser.",
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+ catch (DataException de)
+ { // unable to update the SIG properly
+ page_title = "Database Error";
+ logger.error("DB error updating SIG: " + de.getMessage(),de);
+ content = new ErrorBox(page_title,"Database error updating SIG: " + de.getMessage(),
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+ catch (AccessError ae)
+ { // database access error - display an error box
+ page_title = "Access Error";
+ logger.error("Access error updating SIG: " + ae.getMessage(),ae);
+ content = new ErrorBox(page_title,ae.getMessage(),
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+
+ } // end if (actually setting the category
+ else
+ { // we're browsing - try and figure out what to display
+ try
+ { // get the "go" parameter to see what the current category ID is
+ p = request.getParameter("go");
+ int curr_catid;
+ if (StringUtil.isStringEmpty(p))
+ curr_catid = sig.getCategoryID();
+ else
+ curr_catid = Integer.parseInt(p);
+
+ if (!(getVeniceEngine().isValidCategoryID(curr_catid)))
+ throw new NumberFormatException(); // dump the category if it's not valid
+
+ // create the browser panel and let it rip
+ content = new SIGCategoryBrowseData(user,sig,curr_catid);
+ page_title = "Set SIG Category";
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // we got an invalid category value...
+ page_title = "Invalid Input";
+ content = new ErrorBox(page_title,"Invalid category ID passed to category browser.",
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+ catch (DataException de)
+ { // unable to get the categories properly
+ page_title = "Database Error";
+ logger.error("DB error browsing categories: " + de.getMessage(),de);
+ content = new ErrorBox(page_title,"Database error browsing categories: " + de.getMessage(),
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+
+ } // end else (browsing through categories)
+
+ } // end if
+ else
+ { // no access - sorry man
+ page_title = "Unauthorized";
+ logger.error("tried to call up SIG category set screen without access...naughty naughty!");
+ content = new ErrorBox(page_title,"You do not have access to modify this SIG's profile.",
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end else
+
+ } // end else if (category selector)
+ else // other request
+ { // all unknown requests get turned into menu display requests
+ if (sig.canAdministerSIG())
+ { // create a SIG administration menu
+ SIGAdminTop menu = makeSIGAdminTop();
+ menu.setSIG(sig);
+ content = menu;
+ page_title = "SIG Administration";
+
+ } // end if
+ else
+ { // no access - sorry buddy
+ page_title = "Access Error";
+ logger.error("tried to call up SIG admin menu without access...naughty naughty!");
+ content = new ErrorBox(page_title,"You do not have access to administer this SIG.",
+ "sigprofile?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end else
+
+ } // end else (other request i.e. menu request)
+
+ } // end if
+ // else getting the SIG already caused problems
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"sigadmin?" + request.getQueryString(),content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doGet
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ ContentRender content = null;
+
+ SIGContext sig = null;
+ try
+ { // first get the SIG context we're working with
+ int sigid = Integer.parseInt(request.getParameter("sig"));
+ sig = user.getSIGContext(sigid);
+ changeMenuSIG(request,sig);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // an improperly formatted SIGID brought us down!
+ page_title = "Input Error";
+ logger.error("Somebody fed 'sig=" + request.getParameter("sig") + "' to this page, that's bogus");
+ content = new ErrorBox(page_title,"SIG ID not valid: " + request.getParameter("sig"),"top");
+
+ } // end catch
+ catch (DataException de)
+ { // unable to pull SIG data out of the database
+ page_title = "Database Error";
+ logger.error("database error looking up SIGID " + request.getParameter("sig"));
+ content = new ErrorBox(page_title,"Database error accessing SIG: " + de.getMessage(),"top");
+
+ } // end catch
+
+ if (logger.isDebugEnabled() && (sig!=null))
+ logger.debug("SIGAdmin/doPost operating on SIG \"" + sig.getName() + "\" ("
+ + String.valueOf(sig.getSIGID()) + ")");
+
+ if (content==null)
+ { // now decide what to do based on the "cmd" parameter
+ String cmd = request.getParameter("cmd");
+ if (cmd==null)
+ cmd = "???"; // something pretty much guaranteed not to be used
+
+ if (logger.isDebugEnabled())
+ logger.debug("SIGAdmin/doPost command value = " + cmd);
+
+ if (cmd.equals("P"))
+ { // we just finished editing the profile...
+ if (sig.canModifyProfile())
+ { // construct the edit profile dialog and load it up for use
+ EditSIGProfileDialog dlg = makeEditSIGProfileDialog();
+ dlg.setupDialogBasic(getVeniceEngine(),sig);
+
+ if (dlg.isButtonClicked(request,"cancel"))
+ { // go back to our desired location
+ String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
+ response.sendRedirect(url);
+ return;
+
+ } // end if ("cancel" button clicked)
+
+ if (dlg.isButtonClicked(request,"update"))
+ { // begin updating the SIG's contents
+ dlg.loadValues(request); // do value loading now
+
+ try
+ { // attempt to change the SIG profile now...
+ dlg.doDialog(sig);
+
+ // go back to the Admin menu on success
+ clearMenu(request); // menu title may have been invalidated
+ String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
+ response.sendRedirect(url);
+ return;
+
+ } // end try
+ catch (ValidationException ve)
+ { // simple validation exception
+ if (logger.isDebugEnabled())
+ logger.debug("validation failure: " + ve.getMessage());
+ dlg.resetOnError(sig,ve.getMessage() + " Please try again.");
+ page_title = dlg.getTitle();
+ content = dlg;
+
+ } // end catch
+ catch (DataException de)
+ { // database error updating the SIG values
+ page_title = "Database Error";
+ logger.error("DB error updating SIG: " + de.getMessage(),de);
+ content = new ErrorBox(page_title,"Database error updating SIG: " + de.getMessage(),
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+ catch (AccessError ae)
+ { // access error changing the SIG values
+ page_title = "Access Error";
+ logger.error("Access error updating SIG: " + ae.getMessage(),ae);
+ content = new ErrorBox(page_title,ae.getMessage(),
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end catch
+
+ } // end if ("update" button pressed);
+ else
+ { // what the hell was that button?
+ page_title = "Internal Error";
+ logger.error("no known button click on SIGAdmin.doPost, cmd=P");
+ content = new ErrorBox(page_title,"Unknown command button pressed",
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end else
+
+ } // end if
+ else
+ { // no access - sorry, dude
+ page_title = "Unauthorized";
+ logger.error("tried to edit SIG profile without access...naughty naughty!");
+ content = new ErrorBox(page_title,"You do not have access to modify this SIG's profile.",
+ "sigadmin?sig=" + String.valueOf(sig.getSIGID()));
+
+ } // end else
+
+ } // end if (editing profile)
+ else // unknown command
+ { // just use that to redirect to the GET url
+ String target = "sigadmin?sig=" + String.valueOf(sig.getSIGID()) + "&cmd=" + cmd;
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(target));
+ response.sendRedirect(url);
+ return;
+
+ } // end else (unknown command)
+
+ } // end if
+ // else getting the SIG already caused problems
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"sigadmin?sig=" + String.valueOf(sig.getSIGID()),content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doPost
+
+} // end class SIGAdmin
diff --git a/src/com/silverwrist/venice/servlets/SIGFrontEnd.java b/src/com/silverwrist/venice/servlets/SIGFrontEnd.java
new file mode 100644
index 0000000..6117141
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/SIGFrontEnd.java
@@ -0,0 +1,77 @@
+/*
+ * 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 Community 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;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.servlets.format.*;
+
+public class SIGFrontEnd extends VeniceServlet
+{
+ public String getServletInfo()
+ {
+ String rc = "SIGFrontEnd servlet - Redirects to the \"default feature\" of a SIG\n"
+ + "Part of the Venice Web conferencing system\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ ContentRender content = null;
+
+ try
+ { // get the SIG alias name from the request path info
+ String sigalias = request.getPathInfo().substring(1);
+
+ // get the SIG's context from the alias name
+ SIGContext sig = user.getSIGContext(sigalias);
+
+ // get the default servlet from the SIG context
+ String def_applet = sig.getDefaultApplet();
+ if (def_applet==null)
+ throw new DataException("unable to get SIG default servlet");
+
+ // redirect to the appropriate top-level page!
+ String url = response.encodeRedirectURL(rdat.getFullServletPath(def_applet));
+ response.sendRedirect(url);
+ return;
+
+ } // end try
+ catch (DataException de)
+ { // set up to display an ErrorBox
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error finding SIG: " + de.getMessage(),"top");
+
+ } // end catch
+
+ changeMenuTop(request);
+
+ // this code is only used if we have to display an ErrorBox
+ BaseJSPData basedat = new BaseJSPData(page_title,"sig" + request.getPathInfo(),content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doGet
+
+} // end class SIGFrontEnd
diff --git a/src/com/silverwrist/venice/servlets/SIGOperations.java b/src/com/silverwrist/venice/servlets/SIGOperations.java
new file mode 100644
index 0000000..2b5d995
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/SIGOperations.java
@@ -0,0 +1,456 @@
+/*
+ * 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 Community 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;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.servlets.format.*;
+
+public class SIGOperations extends VeniceServlet
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final String UNJOIN_CONFIRM_ATTR = "servlets.SIGOperations.unjoin.confirm";
+ private static final String UNJOIN_CONFIRM_PARAM = "confirm";
+
+ private static Category logger = Category.getInstance(SIGOperations.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static SIGContext getSIGParameter(ServletRequest request, UserContext user)
+ throws ValidationException, DataException
+ {
+ String str = request.getParameter("sig");
+ if (str==null)
+ { // no SIG parameter - bail out now!
+ logger.error("SIG parameter not specified!");
+ throw new ValidationException("No SIG specified.");
+
+ } // end if
+
+ try
+ { // turn the string into a SIGID, and thence to a SIGContext
+ int sigid = Integer.parseInt(str);
+ return user.getSIGContext(sigid);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // error in Integer.parseInt
+ logger.error("Cannot convert SIG parameter '" + str + "'!");
+ throw new ValidationException("Invalid SIG parameter.");
+
+ } // end catch
+
+ } // end getSIGParameter
+
+ private JoinKeyDialog makeJoinKeyDialog()
+ {
+ final String desired_name = "JoinKeyDialog";
+ DialogCache cache = DialogCache.getDialogCache(getServletContext());
+
+ if (!(cache.isCached(desired_name)))
+ { // create a template and save it off
+ JoinKeyDialog template = new JoinKeyDialog();
+ cache.saveTemplate(template);
+
+ } // end if
+
+ // return a new copy
+ return (JoinKeyDialog)(cache.getNewDialog(desired_name));
+
+ } // end makeJoinKeyDialog
+
+ private CreateSIGDialog makeCreateSIGDialog() throws ServletException
+ {
+ final String desired_name = "CreateSIGDialog";
+ DialogCache cache = DialogCache.getDialogCache(getServletContext());
+
+ if (!(cache.isCached(desired_name)))
+ { // create a template and save it off
+ CreateSIGDialog template = new CreateSIGDialog(getCountryList(),getLanguageList());
+ cache.saveTemplate(template);
+
+ } // end if
+
+ // return a new copy
+ return (CreateSIGDialog)(cache.getNewDialog(desired_name));
+
+ } // end makeCreateSIGDialog
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class HttpServlet
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getServletInfo()
+ {
+ String rc = "SIGOperations servlet - General SIG operations (join, unjoin, etc.)\n"
+ + "Part of the Venice Web Communities System\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ Object content = null;
+
+ // get the command we want to use
+ String cmd = request.getParameter("cmd");
+ if (cmd==null)
+ cmd = "???";
+
+ if (cmd.equals("J"))
+ { // "J" = "Join" (requires SIG parameter)
+ try
+ { // get the SIG parameter first!
+ SIGContext sig = getSIGParameter(request,user);
+
+ if (sig.canJoin())
+ { // OK, we can join the SIG, now, is it public or private?
+ if (sig.isPublicSIG())
+ { // attempt to join right now! (no join key required)
+ sig.join(null);
+
+ // success! display the "welcome" page
+ content = new SIGWelcome(sig);
+ page_title = "Welcome to " + sig.getName();
+ clearMenu(request); // force the clear to regen the menus
+ changeMenuSIG(request,sig);
+
+ } // end if (public SIG)
+ else
+ { // we need to prompt them for the join key...
+ JoinKeyDialog dlg = makeJoinKeyDialog();
+ dlg.setupDialog(sig);
+ content = dlg;
+ page_title = "Join SIG";
+ changeMenuSIG(request,sig);
+
+ } // end else (private SIG)
+
+ } // end if (allowed to join the SIG)
+ else
+ { // throw an error
+ page_title = "Error";
+ content = new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
+
+ } // end else
+
+ } // end try
+ catch (AccessError ae)
+ { // access error
+ page_title = "Access Error";
+ content = new ErrorBox(page_title,"Unable to join SIG: " + ae.getMessage(),"top");
+
+ } // end catch
+ catch (DataException de)
+ { // data exception doing something
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error joining SIG: " + de.getMessage(),"top");
+
+ } // end catch
+ catch (ValidationException ve)
+ { // validation error - wrong parameters, likely
+ page_title = "Error";
+ content = new ErrorBox(null,ve.getMessage(),"top");
+
+ } // end catch
+
+ } // end if ("J" command)
+ else if (cmd.equals("U"))
+ { // "U" = "Unjoin (requires SIG parameter)
+ try
+ { // get the SIG parameter first!
+ SIGContext sig = getSIGParameter(request,user);
+
+ if (sig.canUnjoin())
+ { // OK, let's test for a confirmation...
+ if (ConfirmBox.isConfirmed(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM))
+ { // OK, if you say so, let's unjoin!
+ sig.unjoin();
+
+ // after which, let's just go back to top
+ clearMenu(request); // force the clear to regen the menus
+ rdat.redirectTo("top");
+ return;
+
+ } // end if
+ else
+ { // not a proper confirmation - better display one
+ String message = "Are you sure you want to unjoin the '" + sig.getName() + "' SIG?";
+ String confirm_url = "sigops?cmd=U&sig=" + String.valueOf(sig.getSIGID());
+ String deny_url = "sig/" + sig.getAlias();
+ page_title = "Unjoining SIG";
+ content = new ConfirmBox(request,UNJOIN_CONFIRM_ATTR,UNJOIN_CONFIRM_PARAM,page_title,
+ message,confirm_url,deny_url);
+
+ } // end else
+
+ } // end if
+ else
+ { // throw an error
+ page_title = "Error";
+ content = new ErrorBox("SIG Error","You cannot unjoin this SIG.","top");
+
+ } // end else
+
+ } // end try
+ catch (AccessError ae)
+ { // access error
+ page_title = "Access Error";
+ content = new ErrorBox(page_title,"Unable to unjoin SIG: " + ae.getMessage(),"top");
+
+ } // end catch
+ catch (DataException de)
+ { // data exception doing something
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error unjoining SIG: " + de.getMessage(),"top");
+
+ } // end catch
+ catch (ValidationException ve)
+ { // validation error - wrong parameters, likely
+ page_title = "Error";
+ content = new ErrorBox(null,ve.getMessage(),"top");
+
+ } // end catch
+
+ } // end else if ("U" command)
+ else if (cmd.equals("C"))
+ { // "C" - Create SIG (no parameters)
+ if (user.canCreateSIG())
+ { // present the "Create New SIG" dialog
+ CreateSIGDialog dlg = makeCreateSIGDialog();
+ dlg.setupDialog(getVeniceEngine());
+
+ // prepare for display
+ page_title = dlg.getTitle();
+ content = dlg;
+ changeMenuTop(request);
+
+ } // end if
+ else
+ { // the user isn't permitted to make new SIGs...
+ page_title = "Error";
+ content = new ErrorBox("SIG Error","You are not permitted to create SIGs.","top");
+
+ } // end else
+
+ } // end else if ("C" command)
+ else
+ { // this is an error!
+ page_title = "Internal Error";
+ logger.error("invalid command to SIGOperations.doGet: " + cmd);
+ content = new ErrorBox(page_title,"Invalid command to SIGOperations.doGet","top");
+
+ } // end else
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"sigops?" + request.getQueryString(),content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doGet
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ Object content = null;
+
+ // get the command we want to use
+ String cmd = request.getParameter("cmd");
+ if (cmd==null)
+ cmd = "???";
+
+ if (cmd.equals("J"))
+ { // "J" = Join SIG (requires SIG parameter)
+ try
+ { // get the SIG we're talking about
+ SIGContext sig = getSIGParameter(request,user);
+ JoinKeyDialog dlg = makeJoinKeyDialog();
+
+ if (dlg.isButtonClicked(request,"cancel"))
+ { // canceled join - return to SIG opening page
+ rdat.redirectTo("sig/" + sig.getAlias());
+ return;
+
+ } // end if
+
+ if (dlg.isButtonClicked(request,"join"))
+ { // they clicked the "join" button
+ if (sig.canJoin())
+ { // we are permitted to join this SIG...
+ dlg.loadValues(request); // load the dialog
+
+ try
+ { // attempt to join the SIG!
+ dlg.doDialog(sig);
+
+ // success! display the "welcome" page
+ content = new SIGWelcome(sig);
+ page_title = "Welcome to " + sig.getName();
+ clearMenu(request); // force the clear to regen the menus
+ changeMenuSIG(request,sig);
+
+ } // end try
+ catch (ValidationException ve2)
+ { // here, a validation exception causes us to recycle and retry
+ dlg.resetOnError(ve2.getMessage() + " Please try again.");
+ content = dlg;
+ page_title = "Join SIG";
+ changeMenuSIG(request,sig);
+
+ } // end catch
+ catch (AccessError ae)
+ { // this is probably a bogus key - let them retry
+ dlg.resetOnError(ae.getMessage() + " Please try again.");
+ content = dlg;
+ page_title = "Join SIG";
+ changeMenuSIG(request,sig);
+
+ } // end catch
+
+ } // end if
+ else
+ { // throw an error
+ page_title = "Error";
+ content = new ErrorBox("SIG Error","You are not permitted to join this SIG.","top");
+
+ } // end else
+
+ } // end if ("join" button clicked)
+ else
+ { // error - don't know what button was clicked
+ page_title = "Internal Error";
+ logger.error("no known button click on SIGOperations.doPost, cmd=J");
+ content = new ErrorBox(page_title,"Unknown command button pressed","top");
+
+ } // end else
+
+ } // end try
+ catch (DataException de)
+ { // database error joining something
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error joining SIG: " + de.getMessage(),"top");
+
+ } // end catch
+ catch (ValidationException ve)
+ { // validation error - bogus parameter, I think
+ page_title = "Error";
+ content = new ErrorBox(null,ve.getMessage(),"top");
+
+ } // end catch
+
+ } // end if ("J" command)
+ else if (cmd.equals("C"))
+ { // "C" = Create New SIG
+ if (user.canCreateSIG())
+ { // load the "Create SIG" dialog
+ CreateSIGDialog dlg = makeCreateSIGDialog();
+ dlg.setupDialog(getVeniceEngine());
+
+ if (dlg.isButtonClicked(request,"cancel"))
+ { // canceled create - return to top page
+ rdat.redirectTo("top");
+ return;
+
+ } // end if
+
+ if (dlg.isButtonClicked(request,"create"))
+ { // OK, they actually want to create the new SIG...
+ dlg.loadValues(request); // load the form data
+
+ try
+ { // attempt to create the SIG!
+ SIGContext sig = dlg.doDialog(user);
+
+ // created successfully - display a "new SIG welcome" page
+ content = new NewSIGWelcome(sig);
+ page_title = "SIG Created";
+ changeMenuSIG(request,sig); // display menus for the first time!
+
+ } // end try
+ catch (ValidationException ve2)
+ { // here, a validation exception causes us to recycle and retry
+ dlg.resetOnError(ve2.getMessage() + " Please try again.");
+ content = dlg;
+ page_title = dlg.getTitle();
+ changeMenuTop(request);
+
+ } // end catch
+ catch (AccessError ae)
+ { // this is probably a bogus key - let them retry
+ dlg.resetOnError(ae.getMessage() + " Please try again.");
+ content = dlg;
+ page_title = dlg.getTitle();
+ changeMenuTop(request);
+
+ } // end catch
+ catch (DataException de)
+ { // database error doing something
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error creating SIG: " + de.getMessage(),"top");
+
+ } // end catch
+
+ } // end if
+ else
+ { // error - don't know what button was clicked
+ page_title = "Internal Error";
+ logger.error("no known button click on SIGOperations.doPost, cmd=C");
+ content = new ErrorBox(page_title,"Unknown command button pressed","top");
+
+ } // end else
+
+ } // end if
+ else
+ { // the user isn't permitted to make new SIGs...
+ page_title = "Error";
+ content = new ErrorBox("SIG Error","You are not permitted to create SIGs.","top");
+
+ } // end else
+
+ } // end else if ("C" command)
+ else
+ { // this is an error!
+ page_title = "Internal Error";
+ logger.error("invalid command to SIGOperations.doPost: " + cmd);
+ content = new ErrorBox(page_title,"Invalid command to SIGOperations.doPost","top");
+
+ } // end else
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doPost
+
+} // end class SIGOperations
diff --git a/src/com/silverwrist/venice/servlets/SIGProfile.java b/src/com/silverwrist/venice/servlets/SIGProfile.java
new file mode 100644
index 0000000..06e7ce0
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/SIGProfile.java
@@ -0,0 +1,75 @@
+/*
+ * 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 Community 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;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.servlets.format.*;
+
+public class SIGProfile extends VeniceServlet
+{
+ public String getServletInfo()
+ {
+ String rc = "SIGProfile servlet - Displays the profile of a SIG\n"
+ + "Part of the Venice Web Communities System\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ Object content = null;
+
+ try
+ { // get the ID of the SIG we want to see the profile of
+ int sigid = Integer.parseInt(request.getParameter("sig"));
+
+ // get the SIG context for the user
+ SIGContext sig = user.getSIGContext(sigid);
+
+ // create the profile display
+ content = new SIGProfileData(getVeniceEngine(),user,sig);
+ page_title = "SIG Profile: " + sig.getName();
+ changeMenuSIG(request,sig);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // something as simple as an improper SIGID brought us down?!?!?
+ page_title = "Input Error";
+ content = new ErrorBox(page_title,"SIG ID not valid: " + request.getParameter("sig"),"top");
+
+ } // end catch
+ catch (DataException de)
+ { // in this case, we had database trouble
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error accessing SIG: " + de.getMessage(),"top");
+
+ } // end catch
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"sigprofile?" + request.getQueryString(),content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doGet
+
+} // end class SIGProfile
diff --git a/src/com/silverwrist/venice/servlets/Top.java b/src/com/silverwrist/venice/servlets/Top.java
new file mode 100644
index 0000000..6788ef0
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/Top.java
@@ -0,0 +1,87 @@
+/*
+ * 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 Community 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;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.log4j.*;
+import org.apache.log4j.xml.DOMConfigurator;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.servlets.format.*;
+
+public class Top extends VeniceServlet
+{
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config); // required before we do anything else
+ ServletContext ctxt = config.getServletContext();
+
+ // Initialize LOG4J logging.
+ DOMConfigurator.configure(ctxt.getInitParameter("logging.config"));
+
+ // Initialize the Venice engine.
+ VeniceEngine engine = getVeniceEngine(ctxt);
+
+ // Initialize the Venice rendering system.
+ RenderConfig.getRenderConfig(ctxt);
+
+ } // end init
+
+ public void destroy()
+ {
+ super.destroy();
+
+ } // end destroy
+
+ public String getServletInfo()
+ {
+ String rc = "Top applet - Displays the Venice front page\n"
+ + "Part of the Venice Web conferencing system\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ ContentRender content = null;
+ String page_title = "My Front Page";
+
+ try
+ { // attempt to get the user content
+ content = new TopContent(user);
+
+ } // end try
+ catch (DataException e)
+ { // there was a database error, whoops!
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Error loading front page: " + e.getMessage(),null);
+
+ } // end catch
+
+ changeMenuTop(request);
+
+ BaseJSPData basedat = new BaseJSPData(page_title,"top",content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doGet
+
+} // end class Top
diff --git a/src/com/silverwrist/venice/servlets/TopicSortHolder.java b/src/com/silverwrist/venice/servlets/TopicSortHolder.java
new file mode 100644
index 0000000..0e8abca
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/TopicSortHolder.java
@@ -0,0 +1,161 @@
+/*
+ * 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;
+
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import com.silverwrist.venice.core.ConferenceContext;
+
+public class TopicSortHolder
+{
+ /*--------------------------------------------------------------------------------
+ * Internal class for holding view and sort options
+ *--------------------------------------------------------------------------------
+ */
+
+ static class SortHolderItem
+ {
+ int view_opt;
+ int sort_opt;
+
+ SortHolderItem(int view_opt, int sort_opt)
+ {
+ this.view_opt = view_opt;
+ this.sort_opt = sort_opt;
+
+ } // end constructor
+
+ int getViewOption()
+ {
+ return view_opt;
+
+ } // end getViewOption
+
+ void setViewOption(int val)
+ {
+ view_opt = val;
+
+ } // end setViewOption
+
+ int getSortOption()
+ {
+ return sort_opt;
+
+ } // end getSortOption
+
+ void setSortOption(int val)
+ {
+ sort_opt = val;
+
+ } // end setSortOption
+
+ } // end class SortHolderItem
+
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ protected static final String ATTRIBUTE = "conf.display.topic.sort";
+ protected static final int DEFAULT_VIEW = ConferenceContext.DISPLAY_ACTIVE;
+ protected static final int DEFAULT_SORT = ConferenceContext.SORT_NUMBER;
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private Hashtable hash = new Hashtable();
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ protected TopicSortHolder()
+ { // this does nothing
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private SortHolderItem getItem(int confid)
+ {
+ Integer the_confid = new Integer(confid);
+ SortHolderItem item = (SortHolderItem)(hash.get(the_confid));
+ if (item==null)
+ { // create a new item...
+ item = new SortHolderItem(DEFAULT_VIEW,DEFAULT_SORT);
+ hash.put(the_confid,item);
+
+ } // end if
+
+ return item;
+
+ } // end getItem
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static TopicSortHolder retrieve(HttpSession session)
+ {
+ Object tmp = session.getAttribute(ATTRIBUTE);
+ if (tmp!=null)
+ return (TopicSortHolder)tmp;
+
+ TopicSortHolder rc = new TopicSortHolder();
+ session.setAttribute(ATTRIBUTE,rc);
+ return rc;
+
+ } // end retrieve
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getViewOption(int confid)
+ {
+ return getItem(confid).getViewOption();
+
+ } // end getViewOption
+
+ public void setViewOption(int confid, int opt)
+ {
+ getItem(confid).setViewOption(opt);
+
+ } // end setViewOption
+
+ public int getSortOption(int confid)
+ {
+ return getItem(confid).getSortOption();
+
+ } // end getSortOption
+
+ public void setSortOption(int confid, int opt)
+ {
+ getItem(confid).setSortOption(opt);
+
+ } // end setSortOption
+
+} // end class TopicSortHolder
diff --git a/src/com/silverwrist/venice/servlets/UserDisplay.java b/src/com/silverwrist/venice/servlets/UserDisplay.java
new file mode 100644
index 0000000..9b65b63
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/UserDisplay.java
@@ -0,0 +1,67 @@
+/*
+ * 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 Community 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;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.servlets.format.*;
+
+public class UserDisplay extends VeniceServlet
+{
+ public String getServletInfo()
+ {
+ String rc = "UserDisplay servlet - Displays Venice user profiles\n"
+ + "Part of the Venice Web conferencing system\n";
+ return rc;
+
+ } // end getServletInfo
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ UserContext user = getUserContext(request);
+ RenderData rdat = createRenderData(request,response);
+ String page_title = null;
+ Object content = null;
+
+ try
+ { // use the request path info to get the username to load the profile from
+ String uname = request.getPathInfo().substring(1);
+ UserProfile prof = user.getProfile(uname);
+ content = new UserProfileData(prof);
+ page_title = "User Profile - " + prof.getUserName();
+
+ } // end try
+ catch (DataException de)
+ { // unable to get the user name
+ page_title = "Database Error";
+ content = new ErrorBox(page_title,"Database error finding user: " + de.getMessage(),"top");
+
+ } // end catch
+
+ changeMenuTop(request);
+
+ // format and display the user
+ BaseJSPData basedat = new BaseJSPData(page_title,"user" + request.getPathInfo(),content);
+ basedat.transfer(getServletContext(),rdat);
+
+ } // end doGet
+
+} // end class UserDisplay
diff --git a/src/com/silverwrist/venice/servlets/Variables.java b/src/com/silverwrist/venice/servlets/Variables.java
new file mode 100644
index 0000000..2e62758
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/Variables.java
@@ -0,0 +1,235 @@
+/*
+ * 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 Community 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;
+
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.servlets.format.*;
+
+public class Variables
+{
+ /*--------------------------------------------------------------------------------
+ * Static data values
+ *--------------------------------------------------------------------------------
+ */
+
+ // ServletContext ("application") attributes
+ 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";
+
+ // Servlet initialization parameters
+ protected static final String ENGINE_INIT_PARAM = "venice.config";
+
+ // Cookie name
+ public static final String LOGIN_COOKIE = "VeniceLogin";
+
+ private static Category logger = Category.getInstance(Variables.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException
+ {
+ Object foo = ctxt.getAttribute(ENGINE_ATTRIBUTE);
+ if (foo!=null)
+ return (VeniceEngine)foo;
+
+ String cfgfile = ctxt.getInitParameter(ENGINE_INIT_PARAM); // get the config file name
+ logger.info("Initializing Venice engine using config file: " + cfgfile);
+
+ try
+ { // extract the configuration file name and create the engine
+ VeniceEngine engine = Startup.createEngine(cfgfile);
+ ctxt.setAttribute(ENGINE_ATTRIBUTE,engine);
+ return engine;
+
+ } // end try
+ catch (ConfigException e)
+ { // configuration failed! post an error message
+ logger.fatal("Engine configuration failed: " + e.getMessage(),e);
+ throw new ServletException("Venice engine configuration failed: " + e.getMessage(),e);
+
+ } // end catch
+ catch (DataException e2)
+ { // configuration failed! post an error message
+ logger.fatal("Engine data load failed: " + e2.getMessage(),e2);
+ throw new ServletException("Venice engine data load failed: " + e2.getMessage(),e2);
+
+ } // end catch
+
+ } // end getVeniceEngine
+
+ public static UserContext getUserContext(ServletContext ctxt, ServletRequest request, HttpSession session)
+ throws ServletException
+ {
+ Object uctmp = session.getAttribute(USERCTXT_ATTRIBUTE);
+ if (uctmp!=null)
+ return (UserContext)uctmp;
+
+ try
+ { // use the Venice engine to create a new user context and save it off
+ VeniceEngine engine = getVeniceEngine(ctxt);
+ UserContext user = engine.createUserContext(request.getRemoteAddr());
+ session.setAttribute(USERCTXT_ATTRIBUTE,user);
+ return user;
+
+ } // end try
+ catch (DataException e)
+ { // context creation failed - remap the exception
+ logger.error("Session creation failed: " + e.getMessage(),e);
+ throw new ServletException("Session creation failed: " + e.getMessage(),e);
+
+ } // end catch
+
+ } // end getUserContext
+
+ public static void putUserContext(HttpSession session, UserContext user)
+ {
+ session.setAttribute(USERCTXT_ATTRIBUTE,user);
+ session.removeAttribute(MENU_ATTRIBUTE);
+
+ } // end putUserContext
+
+ public static void clearUserContext(HttpSession session)
+ {
+ session.removeAttribute(USERCTXT_ATTRIBUTE);
+ session.removeAttribute(MENU_ATTRIBUTE);
+
+ } // end clearUserContext
+
+ public static List getCountryList(ServletContext ctxt) throws ServletException
+ {
+ Object foo = ctxt.getAttribute(COUNTRYLIST_ATTRIBUTE);
+ if (foo!=null)
+ return (List)foo;
+
+ VeniceEngine engine = getVeniceEngine(ctxt);
+
+ try
+ { // get the country list via the engine and save it
+ List rc = engine.getCountryList();
+ ctxt.setAttribute(COUNTRYLIST_ATTRIBUTE,rc);
+ return rc;
+
+ } // end try
+ catch (DataException e)
+ { // the country list could not be retrieved
+ logger.error("Failed to retrieve country list from engine: " + e.getMessage(),e);
+ throw new ServletException("Country list retrieval failed: " + e.getMessage(),e);
+
+ } // end catch
+
+ } // end getCountryList
+
+ public static List getLanguageList(ServletContext ctxt) throws ServletException
+ {
+ Object foo = ctxt.getAttribute(LANGUAGELIST_ATTRIBUTE);
+ if (foo!=null)
+ return (List)foo;
+
+ VeniceEngine engine = getVeniceEngine(ctxt);
+
+ try
+ { // get the country list via the engine and save it
+ List rc = engine.getLanguageList();
+ ctxt.setAttribute(LANGUAGELIST_ATTRIBUTE,rc);
+ return rc;
+
+ } // end try
+ catch (DataException e)
+ { // the country list could not be retrieved
+ logger.error("Failed to retrieve language list from engine: " + e.getMessage(),e);
+ throw new ServletException("Language list retrieval failed: " + e.getMessage(),e);
+
+ } // end catch
+
+ } // end getLanguageList
+
+ public static ContentRender getMenu(HttpSession session)
+ {
+ return (ContentRender)(session.getAttribute(MENU_ATTRIBUTE));
+
+ } // end getMenu
+
+ 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;
+
+ } // end if
+
+ session.setAttribute(MENU_ATTRIBUTE,obj);
+
+ } // end if
+
+ } // end setMenuTop
+
+ public static void setMenuSIG(HttpSession session, SIGContext sig)
+ {
+ Object obj = session.getAttribute(MENU_ATTRIBUTE);
+ boolean do_change;
+ if ((obj==null) || !(obj instanceof MenuSIG))
+ do_change = true;
+ else
+ { // look at the actual SIGIDs underlying the MenuSIG
+ MenuSIG tmp = (MenuSIG)obj;
+ do_change = (tmp.getID()!=sig.getSIGID());
+
+ } // end else
+
+ if (do_change)
+ { // switch to the appropriate MenuSIG
+ MenuSIG ms = new MenuSIG(sig);
+ session.setAttribute(MENU_ATTRIBUTE,ms);
+
+ } // end if
+
+ } // end setMenuSIG
+
+ public static void clearMenu(HttpSession session)
+ {
+ session.removeAttribute(MENU_ATTRIBUTE);
+
+ } // end clearMenu
+
+ public static void failIfNull(Object obj) throws ServletException
+ {
+ if (obj==null)
+ throw new ServletException("improper context - data not set");
+
+ } // end failIfNull
+
+} // end class Variables
diff --git a/src/com/silverwrist/venice/servlets/VeniceServlet.java b/src/com/silverwrist/venice/servlets/VeniceServlet.java
new file mode 100644
index 0000000..cdec44e
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/VeniceServlet.java
@@ -0,0 +1,127 @@
+/*
+ * 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 Community 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;
+
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.servlets.format.*;
+
+public abstract class VeniceServlet extends HttpServlet
+{
+ /*--------------------------------------------------------------------------------
+ * Static data values
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(VeniceServlet.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Internal operations intended for use by derived classes
+ *--------------------------------------------------------------------------------
+ */
+
+ protected static boolean isImageButtonClicked(ServletRequest request, String name)
+ {
+ String val = request.getParameter(name + ".x");
+ return (val!=null);
+
+ } // end isImageButtonClicked
+
+ protected static VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException
+ {
+ return Variables.getVeniceEngine(ctxt);
+
+ } // end getVeniceEngine
+
+ protected VeniceEngine getVeniceEngine() throws ServletException
+ {
+ return Variables.getVeniceEngine(getServletContext());
+
+ } // end getVeniceEngine
+
+ protected UserContext getUserContext(HttpServletRequest request) throws ServletException
+ {
+ return Variables.getUserContext(getServletContext(),request,request.getSession(true));
+
+ } // end getUserContext
+
+ protected void putUserContext(HttpServletRequest request, UserContext ctxt)
+ {
+ Variables.putUserContext(request.getSession(true),ctxt);
+
+ } // end putUserContext
+
+ protected void clearUserContext(HttpServletRequest request)
+ {
+ Variables.clearUserContext(request.getSession(true));
+
+ } // end clearUserContext
+
+ protected static List getCountryList(ServletContext ctxt) throws ServletException
+ {
+ return Variables.getCountryList(ctxt);
+
+ } // end getCountryList
+
+ protected List getCountryList() throws ServletException
+ {
+ return Variables.getCountryList(getServletContext());
+
+ } // end getCountryList
+
+ protected List getLanguageList(ServletContext ctxt) throws ServletException
+ {
+ return Variables.getLanguageList(ctxt);
+
+ } // end getLanguageList
+
+ protected List getLanguageList() throws ServletException
+ {
+ return Variables.getLanguageList(getServletContext());
+
+ } // end getLanguageList
+
+ protected void changeMenuTop(HttpServletRequest request)
+ {
+ Variables.setMenuTop(getServletContext(),request.getSession(true));
+
+ } // end changeMenuTop
+
+ protected void changeMenuSIG(HttpServletRequest request, SIGContext sig)
+ {
+ Variables.setMenuSIG(request.getSession(true),sig);
+
+ } // end changeMenuSIG
+
+ protected void clearMenu(HttpServletRequest request)
+ {
+ Variables.clearMenu(request.getSession(true));
+
+ } // end clearMenu
+
+ protected RenderData createRenderData(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException
+ {
+ return RenderConfig.createRenderData(getServletContext(),request,response);
+
+ } // end createRenderData
+
+} // end class VeniceServlet
diff --git a/src/com/silverwrist/venice/servlets/format/BaseJSPData.java b/src/com/silverwrist/venice/servlets/format/BaseJSPData.java
new file mode 100644
index 0000000..4fa3d72
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/BaseJSPData.java
@@ -0,0 +1,151 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.log4j.*;
+
+public class BaseJSPData
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+ protected static final String ATTR_NAME = "com.silverwrist.venice.BaseJSPData";
+
+ private static Category logger = Category.getInstance(BaseJSPData.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String title; // title string to use for this page
+ private String location; // location string to use for this page
+ private Object content; // the actual content
+ private boolean login_links = true; // show login links up top?
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public BaseJSPData(String title, String location, Object content)
+ {
+ this.title = title;
+ this.location = location;
+ this.content = content;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static BaseJSPData retrieve(ServletRequest request)
+ {
+ return (BaseJSPData)(request.getAttribute(ATTR_NAME));
+
+ } // end retrieve
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void store(ServletRequest request)
+ {
+ request.setAttribute(ATTR_NAME,this);
+
+ } // end store
+
+ public String getTitle()
+ {
+ return title;
+
+ } // end getTitle
+
+ public String getLocation()
+ {
+ return location;
+
+ } // end getLocation
+
+ public boolean displayLoginLinks()
+ {
+ return login_links;
+
+ } // end displayLoginLinks
+
+ public void displayLoginLinks(boolean value)
+ {
+ login_links = value;
+
+ } // end displayLoginLinks
+
+ public void transfer(ServletContext ctxt, RenderData rdat) throws IOException, ServletException
+ {
+ rdat.storeBaseJSPData(this);
+ RequestDispatcher dispatcher = ctxt.getRequestDispatcher(rdat.getFormatJSPPath("base.jsp"));
+ rdat.forwardDispatch(dispatcher);
+
+ } // end transfer
+
+ public void renderContent(ServletContext ctxt, Writer out, RenderData rdat)
+ throws IOException, ServletException
+ {
+ if (content==null)
+ { // there is no content!
+ ErrorBox box = new ErrorBox(null,"Internal Error: There is no content available",null);
+ box.renderHere(out,rdat);
+ return;
+
+ } // end if
+
+ if (content instanceof ContentRender)
+ { // we have an old-style ContentRender
+ ContentRender cr = (ContentRender)content;
+ cr.renderHere(out,rdat);
+ return;
+
+ } // end if
+
+ if (content instanceof JSPRender)
+ { // we have a JSP-rendered page - include it
+ JSPRender jr = (JSPRender)content;
+ rdat.storeJSPRender(jr);
+ RequestDispatcher dispatcher = ctxt.getRequestDispatcher(rdat.getFormatJSPPath(jr.getTargetJSPName()));
+ out.flush();
+ rdat.flushOutput(); // make sure the stuff to be output first is output
+ rdat.includeDispatch(dispatcher);
+ rdat.flushOutput(); // now make sure the included page is properly flushed
+ return;
+
+ } // end if
+
+ // this is the fallback if we don't recognize the content
+ ErrorBox box2 = new ErrorBox(null,"Internal Error: Content of invalid type",null);
+ box2.renderHere(out,rdat);
+
+ } // end renderContent
+
+} // end class BaseJSPData
diff --git a/src/com/silverwrist/venice/servlets/format/CDBaseFormField.java b/src/com/silverwrist/venice/servlets/format/CDBaseFormField.java
new file mode 100644
index 0000000..6a71466
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDBaseFormField.java
@@ -0,0 +1,136 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+
+public abstract class CDBaseFormField implements CDFormField
+{
+ private String name;
+ private String caption;
+ private String caption2;
+ private boolean required;
+ private String value = null;
+ private boolean enabled;
+
+ protected CDBaseFormField(String name, String caption, String caption2, boolean required)
+ {
+ this.name = name;
+ this.caption = caption;
+ this.caption2 = caption2;
+ this.required = required;
+ this.enabled = true;
+
+ } // end constructor
+
+ protected CDBaseFormField(CDBaseFormField other)
+ {
+ this.name = other.name;
+ this.caption = other.caption;
+ this.caption2 = other.caption2;
+ this.required = other.required;
+ this.enabled = true;
+ // N.B.: do NOT copy value!
+
+ } // end constructor
+
+ protected abstract void renderActualField(Writer out, RenderData rdat)
+ throws IOException;
+
+ protected void validateContents(String value) throws ValidationException
+ { // this is a do-nothing value
+ } // end validateContents
+
+ protected final String getCaption()
+ {
+ return caption;
+
+ } // end getCaption
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("
\n
");
+ if (!enabled)
+ out.write("");
+ out.write(StringUtil.encodeHTML(caption));
+ if (caption2!=null)
+ out.write(" " + StringUtil.encodeHTML(caption2));
+ if (!enabled)
+ out.write("");
+ if (required)
+ out.write(rdat.getRequiredBullet());
+ out.write(":
\n
");
+ renderActualField(out,rdat);
+ out.write("
\n
\n");
+
+ } // end renderHere
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String getValue()
+ {
+ return value;
+
+ } // end getValue
+
+ public void setValue(String value)
+ {
+ this.value = value;
+
+ } // end setValue
+
+ public boolean isRequired()
+ {
+ return required;
+
+ } // end isRequired
+
+ public CDCommandButton findButton(String name)
+ {
+ return null;
+
+ } // end findButton
+
+ public void validate() throws ValidationException
+ {
+ if (required && enabled && StringUtil.isStringEmpty(value))
+ throw new ValidationException("The '" + caption + "' field is required.");
+ validateContents(value);
+
+ } // end validate
+
+ public boolean isEnabled()
+ {
+ return enabled;
+
+ } // end isEnabled
+
+ public void setEnabled(boolean flag)
+ {
+ enabled = flag;
+
+ } // end setEnabled
+
+} // end CDBaseFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDBaseFormFieldReverse.java b/src/com/silverwrist/venice/servlets/format/CDBaseFormFieldReverse.java
new file mode 100644
index 0000000..e699717
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDBaseFormFieldReverse.java
@@ -0,0 +1,136 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+
+public abstract class CDBaseFormFieldReverse implements CDFormField
+{
+ private String name;
+ private String caption;
+ private String caption2;
+ private boolean required;
+ private String value = null;
+ private boolean enabled;
+
+ protected CDBaseFormFieldReverse(String name, String caption, String caption2, boolean required)
+ {
+ this.name = name;
+ this.caption = caption;
+ this.caption2 = caption2;
+ this.required = required;
+ this.enabled = true;
+
+ } // end constructor
+
+ protected CDBaseFormFieldReverse(CDBaseFormFieldReverse other)
+ {
+ this.name = other.name;
+ this.caption = other.caption;
+ this.caption2 = other.caption2;
+ this.required = other.required;
+ this.enabled = true;
+ // N.B.: do NOT copy value!
+
+ } // end constructor
+
+ protected abstract void renderActualField(Writer out, RenderData rdat)
+ throws IOException;
+
+ protected void validateContents(String value) throws ValidationException
+ { // this is a do-nothing value
+ } // end validateContents
+
+ protected final String getCaption()
+ {
+ return caption;
+
+ } // end getCaption
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("
\n
");
+ renderActualField(out,rdat);
+ out.write("
\n
");
+ if (!enabled)
+ out.write("");
+ out.write(StringUtil.encodeHTML(caption));
+ if (caption2!=null)
+ out.write(" " + StringUtil.encodeHTML(caption2));
+ if (!enabled)
+ out.write("");
+ if (required)
+ out.write(rdat.getRequiredBullet());
+ out.write("
\n
\n");
+
+ } // end renderHere
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public String getValue()
+ {
+ return value;
+
+ } // end getValue
+
+ public void setValue(String value)
+ {
+ this.value = value;
+
+ } // end setValue
+
+ public boolean isRequired()
+ {
+ return required;
+
+ } // end isRequired
+
+ public CDCommandButton findButton(String name)
+ {
+ return null;
+
+ } // end findButton
+
+ public void validate() throws ValidationException
+ {
+ if (required && enabled && StringUtil.isStringEmpty(value))
+ throw new ValidationException("The '" + caption + "' field is required.");
+ validateContents(value);
+
+ } // end validate
+
+ public boolean isEnabled()
+ {
+ return enabled;
+
+ } // end isEnabled
+
+ public void setEnabled(boolean flag)
+ {
+ enabled = flag;
+
+ } // end setEnabled
+
+} // end CDBaseFormFieldReverse
diff --git a/src/com/silverwrist/venice/servlets/format/CDCheckBoxFormField.java b/src/com/silverwrist/venice/servlets/format/CDCheckBoxFormField.java
new file mode 100644
index 0000000..310f8e6
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDCheckBoxFormField.java
@@ -0,0 +1,60 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+
+public class CDCheckBoxFormField extends CDBaseFormFieldReverse
+{
+ private String on_value;
+
+ public CDCheckBoxFormField(String name, String caption, String caption2, String on_value)
+ {
+ super(name,caption,caption2,false);
+ this.on_value = on_value;
+
+ } // end constructor
+
+ protected CDCheckBoxFormField(CDCheckBoxFormField other)
+ {
+ super(other);
+ this.on_value = other.on_value;
+
+ } // end constructor
+
+ protected void renderActualField(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("");
+
+ } // end renderActualField
+
+ public CDFormField duplicate()
+ {
+ return new CDCheckBoxFormField(this);
+
+ } // end clone
+
+} // end class CDCheckBoxFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDCommandButton.java b/src/com/silverwrist/venice/servlets/format/CDCommandButton.java
new file mode 100644
index 0000000..99bb632
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDCommandButton.java
@@ -0,0 +1,28 @@
+/*
+ * 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 Community 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 javax.servlet.ServletRequest;
+
+public interface CDCommandButton extends ContentRender
+{
+ public abstract String getName();
+
+ public abstract boolean isClicked(ServletRequest request);
+
+} // end interface CDCommandButton
diff --git a/src/com/silverwrist/venice/servlets/format/CDCountryListFormField.java b/src/com/silverwrist/venice/servlets/format/CDCountryListFormField.java
new file mode 100644
index 0000000..dda4985
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDCountryListFormField.java
@@ -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 .
+ *
+ * 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 Community 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.util.List;
+import java.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.core.Country;
+
+public class CDCountryListFormField extends CDPickListFormField
+{
+ public CDCountryListFormField(String name, String caption, String caption2, boolean required,
+ List country_list)
+ {
+ super(name,caption,caption2,required,country_list);
+
+ } // end constructor
+
+ protected CDCountryListFormField(CDCountryListFormField other)
+ {
+ super(other);
+
+ } // end constructor
+
+ protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
+ {
+ Country c = (Country)obj;
+ out.write("\n");
+
+ } // end renderChoice
+
+ public CDFormField duplicate()
+ {
+ return new CDCountryListFormField(this);
+
+ } // end duplicate
+
+} // end class CDCountryListFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDEmailAddressFormField.java b/src/com/silverwrist/venice/servlets/format/CDEmailAddressFormField.java
new file mode 100644
index 0000000..1447442
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDEmailAddressFormField.java
@@ -0,0 +1,51 @@
+/*
+ * 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 Community 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 com.silverwrist.venice.core.IDUtils;
+import com.silverwrist.venice.ValidationException;
+
+public class CDEmailAddressFormField extends CDTextFormField
+{
+ public CDEmailAddressFormField(String name, String caption, String caption2, boolean required,
+ int size, int maxlength)
+ {
+ super(name,caption,caption2,required,size,maxlength);
+
+ } // end constructor
+
+ protected CDEmailAddressFormField(CDEmailAddressFormField other)
+ {
+ super(other);
+
+ } // end constructor
+
+ protected void validateContents(String value) throws ValidationException
+ {
+ if (!IDUtils.isValidEmailAddress(value))
+ throw new ValidationException("The value of '" + getCaption() + "' must be a correct Internet address.");
+
+ } // end validateContents
+
+ public Object clone()
+ {
+ return new CDEmailAddressFormField(this);
+
+ } // end clone
+
+} // end class CDEmailAddressFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDFormCategoryHeader.java b/src/com/silverwrist/venice/servlets/format/CDFormCategoryHeader.java
new file mode 100644
index 0000000..ffa9e80
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDFormCategoryHeader.java
@@ -0,0 +1,132 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import javax.servlet.ServletRequest;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+
+public class CDFormCategoryHeader implements CDFormField
+{
+ private String caption;
+ private String rtext;
+ private boolean enabled;
+
+ public CDFormCategoryHeader(String caption)
+ {
+ this.caption = caption;
+ this.rtext = null;
+ this.enabled = true;
+
+ } // end constructor
+
+ public CDFormCategoryHeader(String caption, String rtext)
+ {
+ this.caption = caption;
+ this.rtext = rtext;
+ this.enabled = true;
+
+ } // end constructor
+
+ protected CDFormCategoryHeader(CDFormCategoryHeader other)
+ {
+ this.caption = other.caption;
+ this.rtext = other.rtext;
+ this.enabled = true;
+
+ } // end constructor
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("
");
+ if (!enabled)
+ out.write("");
+ out.write("" + StringUtil.encodeHTML(caption) + ":");
+ if (!enabled)
+ out.write("");
+ out.write("
");
+ if (rtext==null)
+ out.write(" ");
+ else
+ { // display in the correct state
+ if (!enabled)
+ out.write("");
+ out.write(StringUtil.encodeHTML(rtext));
+ if (!enabled)
+ out.write("");
+
+ } // end else
+
+ out.write("
\n");
+
+ } // end renderHere
+
+ public String getName()
+ {
+ return null;
+
+ } // end getName
+
+ public String getValue()
+ {
+ return null;
+
+ } // end getValue
+
+ public void setValue(String value)
+ { // do nothing
+ } // end setValue
+
+ public boolean isRequired()
+ {
+ return false;
+
+ } // end isRequired
+
+ public void validate()
+ { // do nothing
+ } // end validate
+
+ public CDCommandButton findButton(String name)
+ {
+ return null;
+
+ } // end findButton
+
+ public boolean isEnabled()
+ {
+ return enabled;
+
+ } // end isEnabled
+
+ public void setEnabled(boolean flag)
+ {
+ enabled = flag;
+
+ } // end setEnabled
+
+ public CDFormField duplicate()
+ {
+ return new CDFormCategoryHeader(this);
+
+ } // end clone
+
+} // end class CDFormCategoryHeader
+
diff --git a/src/com/silverwrist/venice/servlets/format/CDFormField.java b/src/com/silverwrist/venice/servlets/format/CDFormField.java
new file mode 100644
index 0000000..6bfea45
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDFormField.java
@@ -0,0 +1,42 @@
+/*
+ * 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 Community 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 com.silverwrist.venice.ValidationException;
+
+public interface CDFormField extends ContentRender
+{
+ public abstract String getName();
+
+ public abstract String getValue();
+
+ public abstract void setValue(String value);
+
+ public abstract boolean isRequired();
+
+ public abstract void validate() throws ValidationException;
+
+ public abstract CDCommandButton findButton(String name);
+
+ public abstract boolean isEnabled();
+
+ public abstract void setEnabled(boolean flag);
+
+ public abstract CDFormField duplicate();
+
+} // end interface CDFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDImageButton.java b/src/com/silverwrist/venice/servlets/format/CDImageButton.java
new file mode 100644
index 0000000..15639dc
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDImageButton.java
@@ -0,0 +1,64 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import javax.servlet.ServletRequest;
+
+public class CDImageButton implements CDCommandButton
+{
+ private String name; // name of the button field
+ private String image; // image file to output
+ private String alt_text; // alt text to output
+ private int width; // width of button image
+ private int height; // height of button image
+
+ public CDImageButton(String name, String image, String alt_text, int width, int height)
+ {
+ this.name = name;
+ this.image = image;
+ this.alt_text = alt_text;
+ this.width = width;
+ this.height = height;
+
+ } // end constructor
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("");
+
+ } // end renderHere
+
+ public String getName()
+ {
+ return name;
+
+ } // end getName
+
+ public boolean isClicked(ServletRequest request)
+ {
+ String val = request.getParameter(name + ".x");
+ return (val!=null);
+
+ } // end isClicked
+
+} // end class CDImageButton
diff --git a/src/com/silverwrist/venice/servlets/format/CDLanguageListFormField.java b/src/com/silverwrist/venice/servlets/format/CDLanguageListFormField.java
new file mode 100644
index 0000000..cf1037f
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDLanguageListFormField.java
@@ -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 .
+ *
+ * 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 Community 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.util.List;
+import java.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.core.Language;
+
+public class CDLanguageListFormField extends CDPickListFormField
+{
+ public CDLanguageListFormField(String name, String caption, String caption2, boolean required,
+ List language_list)
+ {
+ super(name,caption,caption2,required,language_list);
+
+ } // end constructor
+
+ protected CDLanguageListFormField(CDLanguageListFormField other)
+ {
+ super(other);
+
+ } // end constructor
+
+ protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
+ {
+ Language l = (Language)obj;
+ out.write("\n");
+
+ } // end renderChoice
+
+ public CDFormField duplicate()
+ {
+ return new CDLanguageListFormField(this);
+
+ } // end clone
+
+} // end class CDLanguageListFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDPasswordFormField.java b/src/com/silverwrist/venice/servlets/format/CDPasswordFormField.java
new file mode 100644
index 0000000..002e5bd
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDPasswordFormField.java
@@ -0,0 +1,69 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import com.silverwrist.venice.ValidationException;
+
+public class CDPasswordFormField extends CDBaseFormField
+{
+ private int size;
+ private int maxlength;
+
+ public CDPasswordFormField(String name, String caption, String caption2, boolean required,
+ int size, int maxlength)
+ {
+ super(name,caption,caption2,required);
+ this.size = size;
+ this.maxlength = maxlength;
+
+ } // end constructor
+
+ protected CDPasswordFormField(CDPasswordFormField other)
+ {
+ super(other);
+ this.size = other.size;
+ this.maxlength = other.maxlength;
+
+ } // end constructor
+
+ protected void renderActualField(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("");
+
+ } // end renderActualField
+
+ protected void validateContents(String value) throws ValidationException
+ { // this is a do-nothing value
+ } // end validateContents
+
+ public CDFormField duplicate()
+ {
+ return new CDPasswordFormField(this);
+
+ } // end clone
+
+} // end class CDPasswordFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDPasswordFormFieldCommand.java b/src/com/silverwrist/venice/servlets/format/CDPasswordFormFieldCommand.java
new file mode 100644
index 0000000..7066b1b
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDPasswordFormFieldCommand.java
@@ -0,0 +1,70 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import javax.servlet.ServletRequest;
+
+public class CDPasswordFormFieldCommand extends CDPasswordFormField
+{
+ private CDCommandButton button;
+
+ public CDPasswordFormFieldCommand(String name, String caption, String caption2, boolean required,
+ int size, int maxlength, CDCommandButton button)
+ {
+ super(name,caption,caption2,required,size,maxlength);
+ this.button = button;
+
+ } // end constructor
+
+ protected CDPasswordFormFieldCommand(CDPasswordFormFieldCommand other)
+ {
+ super(other);
+ this.button = other.button;
+
+ } // end constructor
+
+ protected void renderActualField(Writer out, RenderData rdat) throws IOException
+ {
+ super.renderActualField(out,rdat);
+ if (button!=null)
+ { // add the button
+ out.write(" ");
+ button.renderHere(out,rdat);
+
+ } // end if
+
+ } // end renderActualField
+
+ public CDCommandButton findButton(String name)
+ {
+ if ((button!=null) && (button.getName().equals(name)))
+ return button;
+ else
+ return super.findButton(name);
+
+ } // end findButton
+
+ public CDFormField duplicate()
+ {
+ return new CDPasswordFormFieldCommand(this);
+
+ } // end clone
+
+} // end class CDPasswordFormFieldCommand
diff --git a/src/com/silverwrist/venice/servlets/format/CDPickListFormField.java b/src/com/silverwrist/venice/servlets/format/CDPickListFormField.java
new file mode 100644
index 0000000..bd67ee9
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDPickListFormField.java
@@ -0,0 +1,66 @@
+/*
+ * 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 Community 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.util.Iterator;
+import java.util.List;
+import java.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+
+public abstract class CDPickListFormField extends CDBaseFormField
+{
+ private List choices;
+
+ protected CDPickListFormField(String name, String caption, String caption2, boolean required,
+ List choices)
+ {
+ super(name,caption,caption2,required);
+ this.choices = choices;
+
+ } // end constructor
+
+ protected CDPickListFormField(CDPickListFormField other)
+ {
+ super(other);
+ this.choices = other.choices;
+
+ } // end constructor
+
+ protected abstract void renderChoice(Writer out, RenderData rdat, Object obj, String my_value)
+ throws IOException;
+
+ protected void renderActualField(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("\n"); // all done
+
+ } // end renderActualField
+
+} // end class CDPickListFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDRoleListFormField.java b/src/com/silverwrist/venice/servlets/format/CDRoleListFormField.java
new file mode 100644
index 0000000..9e4f0c8
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDRoleListFormField.java
@@ -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 .
+ *
+ * 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 Community 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.util.List;
+import java.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.security.Role;
+
+public class CDRoleListFormField extends CDPickListFormField
+{
+ public CDRoleListFormField(String name, String caption, String caption2, boolean required,
+ List role_list)
+ {
+ super(name,caption,caption2,required,role_list);
+
+ } // end constructor
+
+ protected CDRoleListFormField(CDRoleListFormField other)
+ {
+ super(other);
+
+ } // end constructor
+
+ protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
+ {
+ Role r = (Role)obj;
+ out.write("\n");
+
+ } // end renderChoice
+
+ public CDFormField duplicate()
+ {
+ return new CDRoleListFormField(this);
+
+ } // end clone
+
+} // end class CDRoleListFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDSimplePickListFormField.java b/src/com/silverwrist/venice/servlets/format/CDSimplePickListFormField.java
new file mode 100644
index 0000000..f4dca99
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDSimplePickListFormField.java
@@ -0,0 +1,62 @@
+/*
+ * 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 Community 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.util.List;
+import java.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+
+public class CDSimplePickListFormField extends CDPickListFormField
+{
+ private char separator;
+
+ public CDSimplePickListFormField(String name, String caption, String caption2, boolean required,
+ List string_list, char separator)
+ {
+ super(name,caption,caption2,required,string_list);
+ this.separator = separator;
+
+ } // end constructor
+
+ protected CDSimplePickListFormField(CDSimplePickListFormField other)
+ {
+ super(other);
+ this.separator = other.separator;
+
+ } // end constructor
+
+ protected void renderChoice(Writer out, RenderData rdat, Object obj, String my_value) throws IOException
+ {
+ String full = (String)obj;
+ int breakpt = full.indexOf(separator);
+ String val = full.substring(0,breakpt);
+ out.write("\n");
+
+ } // end renderChoice
+
+ public CDFormField duplicate()
+ {
+ return new CDSimplePickListFormField(this);
+
+ } // end duplicate
+
+} // end class CDSimplePickListFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDTextFormField.java b/src/com/silverwrist/venice/servlets/format/CDTextFormField.java
new file mode 100644
index 0000000..3fa0322
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDTextFormField.java
@@ -0,0 +1,69 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import com.silverwrist.venice.ValidationException;
+
+public class CDTextFormField extends CDBaseFormField
+{
+ private int size;
+ private int maxlength;
+
+ public CDTextFormField(String name, String caption, String caption2, boolean required,
+ int size, int maxlength)
+ {
+ super(name,caption,caption2,required);
+ this.size = size;
+ this.maxlength = maxlength;
+
+ } // end constructor
+
+ protected CDTextFormField(CDTextFormField other)
+ {
+ super(other);
+ this.size = other.size;
+ this.maxlength = other.maxlength;
+
+ } // end constructor
+
+ protected void renderActualField(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("");
+
+ } // end renderActualField
+
+ protected void validateContents(String value) throws ValidationException
+ { // this is a do-nothing value
+ } // end validateContents
+
+ public CDFormField duplicate()
+ {
+ return new CDTextFormField(this);
+
+ } // end clone
+
+} // end class CDTextFormField
diff --git a/src/com/silverwrist/venice/servlets/format/CDVeniceIDFormField.java b/src/com/silverwrist/venice/servlets/format/CDVeniceIDFormField.java
new file mode 100644
index 0000000..f820a20
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CDVeniceIDFormField.java
@@ -0,0 +1,52 @@
+/*
+ * 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 Community 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 com.silverwrist.venice.core.IDUtils;
+import com.silverwrist.venice.ValidationException;
+
+public class CDVeniceIDFormField extends CDTextFormField
+{
+ public CDVeniceIDFormField(String name, String caption, String caption2, boolean required,
+ int size, int maxlength)
+ {
+ super(name,caption,caption2,required,size,maxlength);
+
+ } // end constructor
+
+ protected CDVeniceIDFormField(CDVeniceIDFormField other)
+ {
+ super(other);
+
+ } // end constructor
+
+ protected void validateContents(String value) throws ValidationException
+ {
+ if (!IDUtils.isValidVeniceID(value))
+ throw new ValidationException("There is an invalid character in the '" + getCaption() + "'field. "
+ + "Valid characters are letters, digits, -, _, !, ~, *, ', and $.");
+
+ } // end validateContents
+
+ public CDFormField duplicate()
+ {
+ return new CDVeniceIDFormField(this);
+
+ } // end clone
+
+} // end class CDVeniceIDFormField
diff --git a/src/com/silverwrist/venice/servlets/format/ConferenceListing.java b/src/com/silverwrist/venice/servlets/format/ConferenceListing.java
new file mode 100644
index 0000000..1235adc
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/ConferenceListing.java
@@ -0,0 +1,151 @@
+/*
+ * 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 Community 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.util.*;
+import javax.servlet.ServletRequest;
+import com.silverwrist.venice.core.*;
+
+public class ConferenceListing implements JSPRender
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ // Attribute name for request attribute
+ protected static final String ATTR_NAME = "com.silverwrist.venice.content.ConferenceListing";
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private SIGContext sig;
+ private List conferences;
+ private List[] hosts;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public ConferenceListing(SIGContext sig) throws DataException, AccessError
+ {
+ this.sig = sig;
+ this.conferences = sig.getConferences();
+ this.hosts = new List[this.conferences.size()];
+ for (int i=0; i.
+ *
+ * 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 Community 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.util.*;
+import java.io.Writer;
+import java.io.IOException;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import com.silverwrist.util.StringUtil;
+
+public class ConfirmBox implements ContentRender
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final long TIMEOUT = 60000; // 1 minute
+
+ private static Random rng = null;
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private int conf_num;
+ private String title;
+ private String message;
+ private String confirm_url;
+ private String deny_url;
+ private Date created;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public ConfirmBox(HttpServletRequest request, String attr_name, String param_name, String title,
+ String message, String confirm_url, String deny_url)
+ {
+ if (rng==null)
+ { // initialize the random number gnerator
+ Date now = new Date();
+ rng = new Random(now.getTime());
+
+ } // end if
+
+ // Fill in all the parameters except created.
+ this.conf_num = rng.nextInt(0x1000000);
+ this.title = title;
+ this.message = message;
+ this.confirm_url = confirm_url + "&" + param_name + "=" + String.valueOf(this.conf_num);
+ this.deny_url = deny_url;
+
+ // Stash this object in the HTTP session.
+ HttpSession session = request.getSession(true);
+ session.setAttribute(attr_name,this);
+
+ // Now start the timer ticking...
+ this.created = new Date();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal operations
+ *--------------------------------------------------------------------------------
+ */
+
+ protected boolean doConfirm(int test_num)
+ {
+ Date now = new Date();
+ if ((now.getTime()-created.getTime())>TIMEOUT)
+ return false;
+ return (test_num==conf_num);
+
+ } // end doConfirm
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from class ContentRender
+ *--------------------------------------------------------------------------------
+ */
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("
\n");
+ rdat.writeFooter(out);
+
+ } // end renderHere
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static boolean isConfirmed(HttpServletRequest request, String attr_name, String param_name)
+ {
+ // First, get the ConfirmBox out of the session data
+ HttpSession session = request.getSession(true);
+ Object obj = session.getAttribute(attr_name);
+ session.removeAttribute(attr_name); // we can only get it out once!
+ if ((obj==null) || !(obj instanceof ConfirmBox)) // this is not a valid ConfirmBox!
+ return false;
+ ConfirmBox cb = (ConfirmBox)obj;
+
+ // Now get the confirmation number out of the URL parameters.
+ String test_num_str = request.getParameter(param_name);
+ if (test_num_str==null)
+ return false; // no confirmation!
+
+ int test_num;
+ try
+ { // convert to an integer
+ test_num = Integer.parseInt(test_num_str);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // if the confirmation number is bogus, we're h0sed
+ return false;
+
+ } // end catch
+
+ return cb.doConfirm(test_num);
+
+ } // end isConfirmed
+
+} // end class ConfirmBox
diff --git a/src/com/silverwrist/venice/servlets/format/ContentDialog.java b/src/com/silverwrist/venice/servlets/format/ContentDialog.java
new file mode 100644
index 0000000..a7f3322
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/ContentDialog.java
@@ -0,0 +1,408 @@
+/*
+ * 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 Community 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.util.*;
+import java.io.Writer;
+import java.io.IOException;
+import javax.servlet.ServletRequest;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+
+public class ContentDialog implements Cloneable, ContentRender
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String title; // dialog title
+ private String subtitle; // dialog subtitle
+ private String formname; // name of the built-in form
+ private String action; // action applet
+ private String error_message = null; // error message
+ private String instructions = null; // instructions
+ private Hashtable hidden_fields; // list of all hidden fields & values
+ private Hashtable command_buttons; // command buttons by name
+ private Vector command_order; // command buttons in order (left to right)
+ private Hashtable form_fields; // form fields by name
+ private Vector form_order; // form fields in order (top to bottom)
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public ContentDialog(String title, String subtitle, String formname, String action)
+ {
+ this.title = title;
+ this.subtitle = subtitle;
+ this.formname = formname;
+ this.action = action;
+ hidden_fields = new Hashtable();
+ command_buttons = new Hashtable();
+ command_order = new Vector();
+ form_fields = new Hashtable();
+ form_order = new Vector();
+
+ } // end constructor
+
+ protected ContentDialog(ContentDialog other)
+ {
+ this.title = other.title;
+ this.subtitle = other.subtitle;
+ this.formname = other.formname;
+ this.action = other.action;
+ this.instructions = other.instructions;
+ this.hidden_fields = (Hashtable)(other.hidden_fields.clone());
+ command_buttons = new Hashtable();
+ command_order = new Vector();
+ form_fields = new Hashtable();
+ form_order = new Vector();
+
+ Enumeration enum = other.command_order.elements();
+ while (enum.hasMoreElements())
+ { // share the command buttons with the new dialog
+ CDCommandButton button = (CDCommandButton)(enum.nextElement());
+ addCommandButton(button);
+
+ } // end while
+
+ enum = other.form_order.elements();
+ while (enum.hasMoreElements())
+ { // clone the form fields and put them in the new dialog
+ CDFormField field = (CDFormField)(enum.nextElement());
+ addFormField(field.duplicate());
+
+ } // end while
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private boolean anyRequired()
+ {
+ boolean rc = false;
+ Enumeration enum = form_order.elements();
+ while (!rc && enum.hasMoreElements())
+ { // look for the first field that's marked "required"
+ CDFormField fld = (CDFormField)(enum.nextElement());
+ rc = fld.isRequired();
+
+ } // end while
+
+ return rc;
+
+ } // end anyRequired
+
+ /*--------------------------------------------------------------------------------
+ * Overrideable operations
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void validateWholeForm() throws ValidationException
+ { // do nothing at this level
+ } // end validateWholeForm
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ContentRender
+ *--------------------------------------------------------------------------------
+ */
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ Enumeration enum;
+
+ // Output the content header
+ rdat.writeContentHeader(out,title,subtitle);
+
+ if (error_message!=null)
+ { // print the error message
+ out.write("
\n");
+
+ } // end if
+
+ // Output the start of the form
+ out.write("\n");
+ rdat.writeFooter(out);
+
+ } // end renderHere
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getTitle()
+ {
+ return title;
+
+ } // end getTitle
+
+ public void setErrorMessage(String message)
+ {
+ this.error_message = message;
+
+ } // end setErrorMessage
+
+ public void setInstructions(String instructions)
+ {
+ this.instructions = StringUtil.encodeHTML(instructions);
+
+ } // end setInstructions
+
+ public void setHiddenField(String name, String value)
+ {
+ if (value!=null)
+ hidden_fields.put(name,value);
+
+ } // end setHiddenField
+
+ public void removeHiddenField(String name)
+ {
+ hidden_fields.remove(name);
+
+ } // end removeHiddenField
+
+ public void addCommandButton(CDCommandButton button, int position)
+ {
+ command_buttons.put(button.getName(),button);
+ if (position<0)
+ command_order.addElement(button);
+ else
+ command_order.insertElementAt(button,position);
+
+ } // end addCommandButton
+
+ public void addCommandButton(CDCommandButton button)
+ {
+ addCommandButton(button,-1);
+
+ } // end addCommandButton
+
+ public void addFormField(CDFormField field, int position)
+ {
+ String name = field.getName();
+ if (name!=null)
+ form_fields.put(name,field);
+ if (position<0)
+ form_order.addElement(field);
+ else
+ form_order.insertElementAt(field,position);
+
+ } // end addFormField
+
+ public void addFormField(CDFormField field)
+ {
+ addFormField(field,-1);
+
+ } // end addFormField
+
+ public boolean isButtonClicked(ServletRequest request, String name)
+ {
+ CDCommandButton button = (CDCommandButton)(command_buttons.get(name));
+ if (button!=null)
+ return button.isClicked(request);
+
+ // now look in all form fields for the embedded button
+ Enumeration enum = form_order.elements();
+ while (enum.hasMoreElements())
+ { // zap the state of the fields
+ CDFormField fld = (CDFormField)(enum.nextElement());
+ button = fld.findButton(name);
+ if (button!=null)
+ return button.isClicked(request);
+
+ } // end while
+
+ return false;
+
+ } // end isButtonClicked
+
+ public void loadValues(ServletRequest request)
+ {
+ // Look for the values of the hidden fields first.
+ Enumeration enum = hidden_fields.keys();
+ Hashtable updates = new Hashtable();
+ while (enum.hasMoreElements())
+ { // get updates to the hidden field values
+ String name = (String)(enum.nextElement());
+ String value = request.getParameter(name);
+ if (value!=null)
+ updates.put(name,value);
+
+ } // end while
+
+ hidden_fields.putAll(updates); // make all the updates be recognized
+
+ // Now look for the values of the form fields.
+ enum = form_order.elements();
+ while (enum.hasMoreElements())
+ { // look for the first field that's marked "required"
+ CDFormField fld = (CDFormField)(enum.nextElement());
+ String name = fld.getName();
+ if (name!=null) // load the parameter value
+ fld.setValue(request.getParameter(name));
+
+ } // end while
+
+ } // end loadValues
+
+ public void clearAllFields()
+ {
+ Enumeration enum = form_order.elements();
+ while (enum.hasMoreElements())
+ { // zap the state of the fields
+ CDFormField fld = (CDFormField)(enum.nextElement());
+ fld.setValue(null);
+
+ } // end while
+
+ } // end clearAllFields
+
+ public String getFieldValue(String fieldname)
+ {
+ String value = (String)(hidden_fields.get(fieldname));
+ if (value!=null)
+ return value;
+
+ CDFormField fld = (CDFormField)(form_fields.get(fieldname));
+ if (fld!=null)
+ return fld.getValue();
+ else
+ return null;
+
+ } // end getFieldValue
+
+ public void setFieldValue(String fieldname, String value)
+ {
+ CDFormField fld = (CDFormField)(form_fields.get(fieldname));
+ if (fld!=null)
+ fld.setValue(value);
+ else if (value!=null)
+ setHiddenField(fieldname,value);
+
+ } // end setFieldValue
+
+ public boolean isFieldEnabled(String fieldname)
+ {
+ CDFormField fld = (CDFormField)(form_fields.get(fieldname));
+ if (fld!=null)
+ return fld.isEnabled();
+ else
+ return false;
+
+ } // end isFieldEnabled
+
+ public void setFieldEnabled(String fieldname, boolean flag)
+ {
+ CDFormField fld = (CDFormField)(form_fields.get(fieldname));
+ if (fld!=null)
+ fld.setEnabled(flag);
+
+ } // end setFieldEnabled
+
+ public void validate() throws ValidationException
+ {
+ // validate each field in isolation
+ Enumeration enum = form_order.elements();
+ while (enum.hasMoreElements())
+ { // look for the first field that's marked "required"
+ CDFormField fld = (CDFormField)(enum.nextElement());
+ fld.validate();
+
+ } // end while
+
+ // now validate the form as a whole
+ validateWholeForm();
+
+ } // end validate
+
+ public Object clone()
+ {
+ return new ContentDialog(this);
+
+ } // end clone
+
+} // end class Dialog
diff --git a/src/com/silverwrist/venice/servlets/format/ContentMenuPanel.java b/src/com/silverwrist/venice/servlets/format/ContentMenuPanel.java
new file mode 100644
index 0000000..0603475
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/ContentMenuPanel.java
@@ -0,0 +1,166 @@
+/*
+ * 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 Community 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.util.*;
+import java.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+
+public class ContentMenuPanel implements Cloneable, ContentRender
+{
+ /*--------------------------------------------------------------------------------
+ * Internal class for storing content items
+ *--------------------------------------------------------------------------------
+ */
+
+ class ContentMenuPanelItem
+ {
+ private String title;
+ private String url;
+
+ public ContentMenuPanelItem(String title, String url)
+ {
+ this.title = title;
+ this.url = url;
+
+ } // end constructor
+
+ public void renderHere(Writer out, RenderData rdat, Hashtable params) throws IOException
+ {
+ StringBuffer buf = new StringBuffer(url);
+ Enumeration enum = params.keys();
+ while (enum.hasMoreElements())
+ { // do the parameter replacement
+ String curkey = (String)(enum.nextElement());
+ String rparam = "$" + curkey;
+ int p = buf.toString().indexOf(rparam);
+ while (p>=0)
+ { // replace the parameter and look for another instance
+ buf.replace(p,p+rparam.length(),(String)(params.get(curkey)));
+ p = buf.toString().indexOf(rparam);
+
+ } // end while
+
+ } // end while
+
+ out.write("");
+ out.write(StringUtil.encodeHTML(title) + "");
+
+ } // end renderHere
+
+ } // end class ContentMenuPanelItem
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String title; // menu title
+ private String subtitle; // menu subtitle
+ private Vector items; // list of menu items
+ private Hashtable params; // set of parameters
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public ContentMenuPanel(String title, String subtitle)
+ {
+ this.title = title;
+ this.subtitle = subtitle;
+ this.items = new Vector();
+ this.params = new Hashtable();
+
+ } // end constructor
+
+ protected ContentMenuPanel(ContentMenuPanel other)
+ {
+ this.title = other.title;
+ this.subtitle = other.subtitle;
+ this.items = other.items;
+ this.params = (Hashtable)(other.params.clone());
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface ContentRender
+ *--------------------------------------------------------------------------------
+ */
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ rdat.writeContentHeader(out,title,subtitle);
+
+ out.write("
\n");
+ rdat.writeFooter(out);
+
+ } // end renderHere
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void addChoice(String title, String url)
+ {
+ items.add(new ContentMenuPanelItem(title,url));
+
+ } // end addChoice
+
+ public void setParameter(String name, String value)
+ {
+ params.put(name,value);
+
+ } // end setParameter
+
+ public void setTitle(String s)
+ {
+ title = s;
+
+ } // end setTitle
+
+ public void setSubtitle(String s)
+ {
+ subtitle = s;
+
+ } // end setSubtitle
+
+ public Object clone()
+ {
+ return new ContentMenuPanel(this);
+
+ } // end clone
+
+} // end class ContentMenuPanel
diff --git a/src/com/silverwrist/venice/servlets/format/ContentRender.java b/src/com/silverwrist/venice/servlets/format/ContentRender.java
new file mode 100644
index 0000000..7cfbd6d
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/ContentRender.java
@@ -0,0 +1,27 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+
+public interface ContentRender
+{
+ public abstract void renderHere(Writer out, RenderData rdat) throws IOException;
+
+} // end interface ContentRender
diff --git a/src/com/silverwrist/venice/servlets/format/CreateConferenceDialog.java b/src/com/silverwrist/venice/servlets/format/CreateConferenceDialog.java
new file mode 100644
index 0000000..f234f00
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CreateConferenceDialog.java
@@ -0,0 +1,116 @@
+/*
+ * 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.util.*;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.*;
+
+public class CreateConferenceDialog extends ContentDialog
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private VeniceEngine engine;
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public CreateConferenceDialog()
+ {
+ super("Create New Conference",null,"newconfform","confops");
+ setHiddenField("cmd","C");
+ setHiddenField("sig","");
+
+ Vector vec_pubpriv = new Vector(2);
+ vec_pubpriv.add("0|Public");
+ vec_pubpriv.add("1|Private");
+ vec_pubpriv.trimToSize();
+
+ addFormField(new CDTextFormField("name","Conference Name",null,true,32,128));
+ addFormField(new CDVeniceIDFormField("alias","Conference Alias",null,true,32,64));
+ addFormField(new CDTextFormField("descr","Description",null,false,32,255));
+ addFormField(new CDSimplePickListFormField("ctype","Conference type",null,true,vec_pubpriv,'|'));
+ addFormField(new CDCheckBoxFormField("hide","Hide conference in the SIG's conference list",null,"Y"));
+ addCommandButton(new CDImageButton("create","bn_create.gif","Create",80,24));
+ addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
+
+ } // end constructor
+
+ protected CreateConferenceDialog(CreateConferenceDialog other)
+ {
+ super(other);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class ContentDialog
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void validateWholeForm() throws ValidationException
+ {
+ if (engine.confAliasExists(getFieldValue("alias")))
+ throw new ValidationException("That alias is already used by another conference on the system.");
+
+ } // end validateWholeForm
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void setupDialog(VeniceEngine engine, SIGContext sig)
+ {
+ this.engine = engine;
+ setHiddenField("sig",String.valueOf(sig.getSIGID()));
+
+ } // end setupDialog
+
+ public ConferenceContext doDialog(SIGContext sig) throws ValidationException, DataException, AccessError
+ {
+ validate(); // validate the form
+
+ // Convert a couple of fields to Booleans, which we need.
+ final String yes = "Y";
+ boolean pvt = getFieldValue("ctype").equals("1");
+ boolean hide_list = yes.equals(getFieldValue("hide"));
+
+ // create the conference!
+ return sig.createConference(getFieldValue("name"),getFieldValue("alias"),getFieldValue("descr"),pvt,
+ hide_list);
+
+ } // end if
+
+ public void resetOnError(String message)
+ {
+ setErrorMessage(message);
+
+ } // end resetOnError
+
+ public Object clone()
+ {
+ return new CreateConferenceDialog(this);
+
+ } // end clone
+
+} // end class CreateConferenceDialog
diff --git a/src/com/silverwrist/venice/servlets/format/CreateSIGDialog.java b/src/com/silverwrist/venice/servlets/format/CreateSIGDialog.java
new file mode 100644
index 0000000..605543f
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/CreateSIGDialog.java
@@ -0,0 +1,163 @@
+/*
+ * 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.util.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.*;
+
+public class CreateSIGDialog extends ContentDialog
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private VeniceEngine engine;
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public CreateSIGDialog(List country_list, List language_list)
+ {
+ super("Create New SIG",null,"createsigform","sigops");
+ setHiddenField("cmd","C");
+
+ Vector vec_pubpriv = new Vector(2);
+ vec_pubpriv.add("0|Public");
+ vec_pubpriv.add("1|Private");
+ vec_pubpriv.trimToSize();
+
+ Vector vec_hidemode = new Vector(3);
+ vec_hidemode.add(String.valueOf(SIGContext.HIDE_NONE) + "|Show in both directory and search");
+ vec_hidemode.add(String.valueOf(SIGContext.HIDE_DIRECTORY) + "|Hide in directory, but not in search");
+ vec_hidemode.add(String.valueOf(SIGContext.HIDE_BOTH) + "|Hide in both directory and search");
+ vec_hidemode.trimToSize();
+
+ addFormField(new CDFormCategoryHeader("Basic Information"));
+ addFormField(new CDTextFormField("name","SIG Name",null,true,32,128));
+ addFormField(new CDVeniceIDFormField("alias","SIG Alias",null,true,32,32));
+ addFormField(new CDTextFormField("synopsis","Synopsis",null,false,32,255));
+ addFormField(new CDTextFormField("rules","Rules",null,false,32,255));
+ addFormField(new CDLanguageListFormField("language","Primary language",null,true,language_list));
+ addFormField(new CDFormCategoryHeader("Location"));
+ addFormField(new CDTextFormField("loc","City",null,false,32,64));
+ addFormField(new CDTextFormField("reg","State/Province",null,false,32,64));
+ addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
+ addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
+ addFormField(new CDFormCategoryHeader("Security"));
+ addFormField(new CDSimplePickListFormField("comtype","SIG type:",null,true,vec_pubpriv,'|'));
+ addFormField(new CDTextFormField("joinkey","Join key","(for private SIGs)",false,32,64));
+ addFormField(new CDSimplePickListFormField("hidemode","SIG visibility:",null,true,vec_hidemode,'|'));
+ addCommandButton(new CDImageButton("create","bn_create.gif","Create",80,24));
+ addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
+
+ } // end constructor
+
+ protected CreateSIGDialog(CreateSIGDialog other)
+ {
+ super(other);
+
+ } // end CreateSIGDialog
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class ContentDialog
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void validateWholeForm() throws ValidationException
+ {
+ if (engine.aliasExists(getFieldValue("alias"),-1))
+ throw new ValidationException("That alias is already used by another SIG on the system.");
+
+ if (getFieldValue("comtype").equals("1"))
+ { // make sure if they flagged it as Private that they specified a join key
+ if (StringUtil.isStringEmpty(getFieldValue("joinkey")))
+ throw new ValidationException("Private SIGs must specify a join key value.");
+
+ } // end if
+
+ } // end validateWholeForm
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void setupDialog(VeniceEngine engine)
+ {
+ this.engine = engine;
+
+ } // end setupDialog
+
+ public SIGContext doDialog(UserContext user) throws ValidationException, DataException, AccessError
+ {
+ validate(); // validate the dialog entries
+
+ int hidemode;
+
+ try
+ { // attempt to get the hide mode first...
+ hidemode = Integer.parseInt(getFieldValue("hidemode"));
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // how rude!
+ throw new InternalStateError("somehow we got a non-numeric result from a numeric dropdown list!");
+
+ } // end catch
+
+ // Determine what the "join key" should be.
+ String jkey;
+ if (getFieldValue("comtype").equals("1"))
+ jkey = getFieldValue("joinkey");
+ else
+ jkey = null;
+
+ // Create the new SIG context.
+ SIGContext rc = user.createSIG(getFieldValue("name"),getFieldValue("alias"),getFieldValue("language"),
+ getFieldValue("synopsis"),getFieldValue("rules"),jkey,hidemode);
+
+ // Get the new SIG's contact record and fill in the pieces of info we know.
+ ContactInfo ci = rc.getContactInfo();
+ ci.setLocality(getFieldValue("loc"));
+ ci.setRegion(getFieldValue("reg"));
+ ci.setPostalCode(getFieldValue("pcode"));
+ ci.setCountry(getFieldValue("country"));
+ rc.putContactInfo(ci);
+
+ return rc; // all done!
+
+ } // end doDialog
+
+ public void resetOnError(String message)
+ {
+ setErrorMessage(message);
+
+ } // end resetOnError
+
+ public Object clone()
+ {
+ return new CreateSIGDialog(this);
+
+ } // end clone
+
+} // end class CreateSIGDialog
diff --git a/src/com/silverwrist/venice/servlets/format/DialogCache.java b/src/com/silverwrist/venice/servlets/format/DialogCache.java
new file mode 100644
index 0000000..731b5b2
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/DialogCache.java
@@ -0,0 +1,103 @@
+/*
+ * 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 Community 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.util.Hashtable;
+import javax.servlet.ServletContext;
+import org.apache.log4j.*;
+
+public class DialogCache
+{
+ /*--------------------------------------------------------------------------------
+ * Static data values
+ *--------------------------------------------------------------------------------
+ */
+
+ protected static final String ATTR_NAME = "com.silverwrist.venice.servlets.DialogCache";
+
+ private static Category logger = Category.getInstance(DialogCache.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ Hashtable cache;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ protected DialogCache()
+ {
+ cache = new Hashtable();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public boolean isCached(String name)
+ {
+ return (cache.get(name)!=null);
+
+ } // end isCached
+
+ public void saveTemplate(ContentDialog template)
+ {
+ String fullname = template.getClass().getName();
+ int clip_pos = fullname.lastIndexOf('.');
+ if (clip_pos>=0)
+ fullname = fullname.substring(clip_pos+1);
+ cache.put(fullname,template);
+
+ } // end saveTemplate
+
+ public ContentDialog getNewDialog(String name)
+ {
+ ContentDialog template = (ContentDialog)(cache.get(name));
+ if (template!=null)
+ return (ContentDialog)(template.clone());
+ else
+ return null;
+
+ } // end getNewDialog
+
+ /*--------------------------------------------------------------------------------
+ * Static operations for use by servlets
+ *--------------------------------------------------------------------------------
+ */
+
+ public static DialogCache getDialogCache(ServletContext ctxt)
+ {
+ // Look in the servlet attributes first.
+ Object foo = ctxt.getAttribute(ATTR_NAME);
+ if (foo!=null)
+ return (DialogCache)foo;
+
+ // create a new one and return it
+ DialogCache cache = new DialogCache();
+ ctxt.setAttribute(ATTR_NAME,cache);
+ return cache;
+
+ } // end getDialogCache
+
+} // end class DialogCache
diff --git a/src/com/silverwrist/venice/servlets/format/EditProfileDialog.java b/src/com/silverwrist/venice/servlets/format/EditProfileDialog.java
new file mode 100644
index 0000000..9d30265
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/EditProfileDialog.java
@@ -0,0 +1,201 @@
+/*
+ * 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 Community 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.util.List;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.*;
+
+public class EditProfileDialog extends ContentDialog
+{
+ public EditProfileDialog(List country_list)
+ {
+ super("Edit Your Profile",null,"profform","account");
+ setHiddenField("cmd","P");
+ setHiddenField("tgt","");
+ addFormField(new CDFormCategoryHeader("Password","To change your password, enter a new password "
+ + "into the fields below."));
+ addFormField(new CDPasswordFormField("pass1","Password",null,false,32,128));
+ addFormField(new CDPasswordFormField("pass2","Password","(retype)",false,32,128));
+ addFormField(new CDTextFormField("remind","Password reminder phrase",null,false,32,255));
+ addFormField(new CDFormCategoryHeader("Name"));
+ addFormField(new CDTextFormField("prefix","Prefix","(Mr., Ms., etc.)",false,8,8));
+ addFormField(new CDTextFormField("first","First name",null,true,32,64));
+ addFormField(new CDTextFormField("mid","Middle initial",null,false,1,1));
+ addFormField(new CDTextFormField("last","Last name",null,true,32,64));
+ addFormField(new CDTextFormField("suffix","Suffix","(Jr., III, etc.)",false,16,16));
+ addFormField(new CDFormCategoryHeader("Location"));
+ addFormField(new CDTextFormField("company","Company",null,false,32,255));
+ addFormField(new CDTextFormField("addr1","Address",null,false,32,255));
+ addFormField(new CDTextFormField("addr2","Address","(line 2)",false,32,255));
+ addFormField(new CDCheckBoxFormField("pvt_addr","Hide address in profile",null,"Y"));
+ addFormField(new CDTextFormField("loc","City",null,true,32,64));
+ addFormField(new CDTextFormField("reg","State/Province",null,true,32,64));
+ addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
+ addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
+ addFormField(new CDFormCategoryHeader("Phone Numbers"));
+ addFormField(new CDTextFormField("phone","Telephone",null,false,32,32));
+ addFormField(new CDTextFormField("mobile","Mobile/cellphone",null,false,32,32));
+ addFormField(new CDCheckBoxFormField("pvt_phone","Hide phone/mobile numbers in profile",null,"Y"));
+ addFormField(new CDTextFormField("fax","Fax",null,false,32,32));
+ addFormField(new CDCheckBoxFormField("pvt_fax","Hide fax number in profile",null,"Y"));
+ addFormField(new CDFormCategoryHeader("Internet"));
+ addFormField(new CDEmailAddressFormField("email","E-mail address",null,true,32,255));
+ addFormField(new CDCheckBoxFormField("pvt_email","Hide e-mail address in profile",null,"Y"));
+ addFormField(new CDTextFormField("url","Home page","(URL)",false,32,255));
+ addFormField(new CDFormCategoryHeader("Personal"));
+ addFormField(new CDTextFormField("descr","Personal description",null,false,32,255));
+ // TODO: add photo selection/uploading method here
+ addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
+ addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
+
+ } // end constructor
+
+ protected EditProfileDialog(EditProfileDialog other)
+ {
+ super(other);
+
+ } // end constructor
+
+ protected void validateWholeForm() throws ValidationException
+ {
+ String pass1 = getFieldValue("pass1");
+ String pass2 = getFieldValue("pass2");
+
+ if (StringUtil.isStringEmpty(pass1))
+ { // empty must match empty
+ if (!StringUtil.isStringEmpty(pass2))
+ throw new ValidationException("The typed passwords do not match.");
+
+ } // end if
+ else
+ { // the two passwords must match
+ if (!(pass1.equals(pass2)))
+ throw new ValidationException("The typed passwords do not match.");
+
+ } // end if
+
+ } // end validateWholeForm
+
+ public void setTarget(String target)
+ {
+ setHiddenField("tgt",target);
+
+ } // end setTarget
+
+ public void setupDialog(UserContext uc, String target) throws DataException
+ {
+ setTarget(target);
+ ContactInfo ci = uc.getContactInfo(); // get the main contact info
+
+ setFieldValue("prefix",ci.getNamePrefix());
+ setFieldValue("first",ci.getGivenName());
+ char init = ci.getMiddleInitial();
+ if (init!=' ')
+ setFieldValue("mid",String.valueOf(init));
+ setFieldValue("last",ci.getFamilyName());
+ setFieldValue("suffix",ci.getNameSuffix());
+ setFieldValue("company",ci.getCompany());
+ setFieldValue("addr1",ci.getAddressLine1());
+ setFieldValue("addr2",ci.getAddressLine2());
+ if (ci.getPrivateAddress())
+ setFieldValue("pvt_addr","Y");
+ setFieldValue("loc",ci.getLocality());
+ setFieldValue("reg",ci.getRegion());
+ setFieldValue("pcode",ci.getPostalCode());
+ setFieldValue("country",ci.getCountry());
+ setFieldValue("phone",ci.getPhone());
+ setFieldValue("mobile",ci.getMobile());
+ if (ci.getPrivatePhone())
+ setFieldValue("pvt_phone","Y");
+ setFieldValue("fax",ci.getFax());
+ if (ci.getPrivateFax())
+ setFieldValue("pvt_fax","Y");
+ setFieldValue("email",ci.getEmail());
+ if (ci.getPrivateEmail())
+ setFieldValue("pvt_email","Y");
+ setFieldValue("url",ci.getURL());
+ setFieldValue("descr",uc.getDescription());
+
+ } // end setupDialog
+
+ public boolean doDialog(UserContext uc) throws ValidationException, DataException, EmailException
+ {
+ validate(); // validate the dialog
+
+ final String yes = "Y"; // the "yes" string
+ ContactInfo ci = uc.getContactInfo(); // get the main contact info
+
+ // Reset all the contact info fields.
+ ci.setNamePrefix(getFieldValue("prefix"));
+ ci.setGivenName(getFieldValue("first"));
+ String foo = getFieldValue("mid");
+ if ((foo==null) || (foo.length()<1))
+ ci.setMiddleInitial(' ');
+ else
+ ci.setMiddleInitial(foo.charAt(0));
+ ci.setFamilyName(getFieldValue("last"));
+ ci.setNameSuffix(getFieldValue("suffix"));
+ ci.setCompany(getFieldValue("company"));
+ ci.setAddressLine1(getFieldValue("addr1"));
+ ci.setAddressLine2(getFieldValue("addr2"));
+ ci.setPrivateAddress(yes.equals(getFieldValue("pvt_addr")));
+ ci.setLocality(getFieldValue("loc"));
+ ci.setRegion(getFieldValue("reg"));
+ ci.setPostalCode(getFieldValue("pcode"));
+ ci.setCountry(getFieldValue("country"));
+ ci.setPhone(getFieldValue("phone"));
+ ci.setMobile(getFieldValue("mobile"));
+ ci.setPrivatePhone(yes.equals(getFieldValue("pvt_phone")));
+ ci.setFax(getFieldValue("fax"));
+ ci.setPrivateFax(yes.equals(getFieldValue("pvt_fax")));
+ ci.setEmail(getFieldValue("email"));
+ ci.setPrivateEmail(yes.equals(getFieldValue("pvt_email")));
+ ci.setURL(getFieldValue("url"));
+
+ // Store the completed contact info.
+ boolean retval = uc.putContactInfo(ci);
+
+ // Save off the user's description.
+ uc.setDescription(getFieldValue("descr"));
+
+ // Finally, change the password if applicable.
+ foo = getFieldValue("pass1");
+ if (!StringUtil.isStringEmpty(foo))
+ uc.setPassword(foo,getFieldValue("remind"));
+
+ return retval; // pass back up so we can decide where to jump
+
+ } // end doDialog
+
+ public void resetOnError(String message)
+ {
+ setErrorMessage(message);
+ setFieldValue("pass1",null);
+ setFieldValue("pass2",null);
+
+ } // end resetOnError
+
+ public Object clone()
+ {
+ return new EditProfileDialog(this);
+
+ } // end clone
+
+} // end class EditProfileDialog
diff --git a/src/com/silverwrist/venice/servlets/format/EditSIGProfileDialog.java b/src/com/silverwrist/venice/servlets/format/EditSIGProfileDialog.java
new file mode 100644
index 0000000..35d344c
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/EditSIGProfileDialog.java
@@ -0,0 +1,270 @@
+/*
+ * 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.util.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.security.Role;
+import com.silverwrist.venice.core.*;
+
+public class EditSIGProfileDialog extends ContentDialog
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private VeniceEngine engine;
+ private int sigid;
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public EditSIGProfileDialog(List country_list, List language_list)
+ {
+ super("Edit SIG Profile:",null,"sigprofform","sigadmin");
+ setHiddenField("cmd","P");
+ setHiddenField("sig","");
+
+ Vector vec_pubpriv = new Vector(2);
+ vec_pubpriv.add("0|Public");
+ vec_pubpriv.add("1|Private");
+ vec_pubpriv.trimToSize();
+
+ Vector vec_hidemode = new Vector(3);
+ vec_hidemode.add(String.valueOf(SIGContext.HIDE_NONE) + "|Show in both directory and search");
+ vec_hidemode.add(String.valueOf(SIGContext.HIDE_DIRECTORY) + "|Hide in directory, but not in search");
+ vec_hidemode.add(String.valueOf(SIGContext.HIDE_BOTH) + "|Hide in both directory and search");
+ vec_hidemode.trimToSize();
+
+ addFormField(new CDFormCategoryHeader("Basic Information"));
+ addFormField(new CDTextFormField("name","SIG Name",null,true,32,128));
+ addFormField(new CDVeniceIDFormField("alias","SIG Alias",null,true,32,32));
+ addFormField(new CDTextFormField("synopsis","Synopsis",null,false,32,255));
+ addFormField(new CDTextFormField("rules","Rules",null,false,32,255));
+ addFormField(new CDLanguageListFormField("language","Primary language",null,true,language_list));
+ addFormField(new CDTextFormField("url","Home page",null,false,32,255));
+ addFormField(new CDFormCategoryHeader("Location"));
+ addFormField(new CDTextFormField("company","Company",null,false,32,255));
+ addFormField(new CDTextFormField("addr1","Address",null,false,32,255));
+ addFormField(new CDTextFormField("addr2","Address","(line 2)",false,32,255));
+ addFormField(new CDTextFormField("loc","City",null,false,32,64));
+ addFormField(new CDTextFormField("reg","State/Province",null,false,32,64));
+ addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
+ addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
+ addFormField(new CDFormCategoryHeader("Security"));
+ addFormField(new CDSimplePickListFormField("comtype","SIG type",null,true,vec_pubpriv,'|'));
+ addFormField(new CDTextFormField("joinkey","Join key","(for private SIGs)",false,32,64));
+ addFormField(new CDCheckBoxFormField("membersonly","Allow only members to access this SIG",null,"Y"));
+ addFormField(new CDSimplePickListFormField("hidemode","SIG visibility",null,true,vec_hidemode,'|'));
+ addFormField(new CDRoleListFormField("read_lvl","Security level required to read contents",null,true,
+ Role.getSIGReadList()));
+ addFormField(new CDRoleListFormField("write_lvl","Security level required to update profile",null,true,
+ Role.getSIGWriteList()));
+ addFormField(new CDRoleListFormField("create_lvl","Security level required to create new subobjects",
+ null,true,Role.getSIGCreateList()));
+ addFormField(new CDRoleListFormField("delete_lvl","Security level required to delete SIG",null,true,
+ Role.getSIGDeleteList()));
+ addFormField(new CDRoleListFormField("join_lvl","Security level required to join SIG",null,true,
+ Role.getSIGJoinList()));
+ // TODO: add logo selection/uploading method here
+ addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
+ addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
+
+ } // end EditSIGProfileDialog
+
+ protected EditSIGProfileDialog(EditSIGProfileDialog other)
+ {
+ super(other);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private void doDisable(SIGContext sig)
+ {
+ if (sig.isAdminSIG())
+ { // make sure certain fields are disabled for admin SIGs
+ setFieldEnabled("comtype",false);
+ setFieldEnabled("joinkey",false);
+ setFieldEnabled("membersonly",false);
+ setFieldEnabled("hidemode",false);
+ setFieldEnabled("read_lvl",false);
+ setFieldEnabled("write_lvl",false);
+ setFieldEnabled("create_lvl",false);
+ setFieldEnabled("delete_lvl",false);
+ setFieldEnabled("join_lvl",false);
+
+ } // end if
+
+ } // end doDisable
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class ContentDialog
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void validateWholeForm() throws ValidationException
+ {
+ if (engine.aliasExists(getFieldValue("alias"),sigid))
+ throw new ValidationException("That alias is already used by another SIG on the system.");
+
+ if (getFieldValue("comtype").equals("1"))
+ { // make sure if they flagged it as Private that they specified a join key
+ if (StringUtil.isStringEmpty(getFieldValue("joinkey")))
+ throw new ValidationException("Private SIGs must specify a join key value.");
+
+ } // end if
+
+ } // end validateWholeForm
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void setupDialogBasic(VeniceEngine engine, SIGContext sig)
+ {
+ this.engine = engine;
+ this.sigid = sig.getSIGID();
+
+ } // end setupDialogBasic
+
+ public void setupDialog(VeniceEngine engine, SIGContext sig) throws DataException, AccessError
+ {
+ setupDialogBasic(engine,sig);
+ ContactInfo ci = sig.getContactInfo();
+
+ setHiddenField("sig",String.valueOf(sig.getSIGID()));
+ setFieldValue("name",sig.getName());
+ setFieldValue("alias",sig.getAlias());
+ setFieldValue("synopsis",sig.getSynopsis());
+ setFieldValue("rules",sig.getRules());
+ setFieldValue("language",sig.getLanguageCode());
+ setFieldValue("url",ci.getURL());
+ setFieldValue("company",ci.getCompany());
+ setFieldValue("addr1",ci.getAddressLine1());
+ setFieldValue("addr2",ci.getAddressLine2());
+ setFieldValue("loc",ci.getLocality());
+ setFieldValue("reg",ci.getRegion());
+ setFieldValue("pcode",ci.getPostalCode());
+ setFieldValue("country",ci.getCountry());
+ if (sig.isPublicSIG())
+ { // public SIG - no join key
+ setFieldValue("comtype","0");
+ setFieldValue("joinkey","");
+
+ } // end if
+ else
+ { // private SIG - display the join key
+ setFieldValue("comtype","1");
+ setFieldValue("joinkey",sig.getJoinKey());
+
+ } // end else
+
+ if (sig.getMembersOnly())
+ setFieldValue("membersonly","Y");
+ setFieldValue("hidemode",String.valueOf(sig.getHideMode()));
+ setFieldValue("read_lvl",String.valueOf(sig.getReadLevel()));
+ setFieldValue("write_lvl",String.valueOf(sig.getWriteLevel()));
+ setFieldValue("create_lvl",String.valueOf(sig.getCreateLevel()));
+ setFieldValue("delete_lvl",String.valueOf(sig.getDeleteLevel()));
+ setFieldValue("join_lvl",String.valueOf(sig.getJoinLevel()));
+
+ doDisable(sig);
+
+ } // end setupDialog
+
+ public void doDialog(SIGContext sig) throws ValidationException, DataException, AccessError
+ {
+ final String yes = "Y"; // the "yes" string
+ validate(); // validate the dialog entries
+
+ int hidemode, read_lvl, write_lvl, create_lvl, delete_lvl, join_lvl;
+ try
+ { // convert the values of some dropdowns to real numbers
+ hidemode = Integer.parseInt(getFieldValue("hidemode"));
+ read_lvl = Integer.parseInt(getFieldValue("read_lvl"));
+ write_lvl = Integer.parseInt(getFieldValue("write_lvl"));
+ create_lvl = Integer.parseInt(getFieldValue("create_lvl"));
+ delete_lvl = Integer.parseInt(getFieldValue("delete_lvl"));
+ join_lvl = Integer.parseInt(getFieldValue("join_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
+
+ // save off the ContactInfo-related fields first
+ ContactInfo ci = sig.getContactInfo();
+ ci.setURL(getFieldValue("url"));
+ ci.setCompany(getFieldValue("company"));
+ ci.setAddressLine1(getFieldValue("addr1"));
+ ci.setAddressLine2(getFieldValue("addr2"));
+ ci.setLocality(getFieldValue("loc"));
+ ci.setRegion(getFieldValue("reg"));
+ ci.setPostalCode(getFieldValue("pcode"));
+ ci.setCountry(getFieldValue("country"));
+ sig.putContactInfo(ci);
+
+ // now save the big text fields
+ sig.setName(getFieldValue("name"));
+ sig.setAlias(getFieldValue("alias"));
+ sig.setSynopsis(getFieldValue("synopsis"));
+ sig.setRules(getFieldValue("rules"));
+ sig.setLanguage(getFieldValue("language"));
+
+ if (!(sig.isAdminSIG()))
+ { // save off the security information
+ String jkey;
+ if (getFieldValue("comtype").equals("1"))
+ jkey = getFieldValue("joinkey");
+ else
+ jkey = null;
+ sig.setJoinKey(jkey);
+ sig.setMembersOnly(yes.equals(getFieldValue("membersonly")));
+ sig.setHideMode(hidemode);
+ sig.setSecurityLevels(read_lvl,write_lvl,create_lvl,delete_lvl,join_lvl);
+
+ } // end if
+
+ } // end doDialog
+
+ public void resetOnError(SIGContext sig, String message)
+ {
+ setErrorMessage(message);
+ doDisable(sig);
+
+ } // end resetOnError
+
+ public Object clone()
+ {
+ return new EditSIGProfileDialog(this);
+
+ } // end clone
+
+} // end class EditSIGProfileDialog
+
diff --git a/src/com/silverwrist/venice/servlets/format/ErrorBox.java b/src/com/silverwrist/venice/servlets/format/ErrorBox.java
new file mode 100644
index 0000000..6cb2505
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/ErrorBox.java
@@ -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 .
+ *
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import com.silverwrist.util.StringUtil;
+
+public class ErrorBox implements ContentRender
+{
+ private String title;
+ private String message;
+ private String back;
+
+ public ErrorBox(String title, String message, String back)
+ {
+ this.title = title;
+ this.message = message;
+ this.back = back;
+
+ if (this.title==null)
+ this.title = "Error!";
+
+ } // end constructor
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("
\n");
+ if (back==null)
+ out.write("Use your browser's Back button to go back.\n");
+ else
+ out.write("Go back.\n");
+ out.write("
\n");
+ rdat.writeFooter(out);
+
+ } // end renderHere
+
+} // end class ErrorBox
diff --git a/src/com/silverwrist/venice/servlets/format/FindData.java b/src/com/silverwrist/venice/servlets/format/FindData.java
new file mode 100644
index 0000000..91a000e
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/FindData.java
@@ -0,0 +1,376 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import java.util.*;
+import javax.servlet.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.*;
+
+public class FindData implements JSPRender, SearchMode
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ // Attribute name for request attribute
+ protected static final String ATTR_NAME = "com.silverwrist.venice.content.FindData";
+
+ // The various display categories
+ public static final int FD_SIGS = 0;
+ public static final int FD_USERS = 1;
+ public static final int FD_CATEGORIES = 2;
+
+ // The titles and URLs of the header data
+ private static Vector header_titles = null;
+ private static Vector header_urls = null;
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private VeniceEngine engine;
+ private UserContext user;
+ private int disp;
+ private int field = -1;
+ private int mode = -1;
+ private String term = null;
+ private int offset = 0;
+ private CategoryDescriptor cat = null;
+ private List subcats = null;
+ private List results = null;
+ private int find_count = -1;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public FindData(VeniceEngine engine, UserContext user, int disp)
+ {
+ this.engine = engine;
+ this.user = user;
+ this.disp = disp;
+
+ if (header_titles==null)
+ { // construct the title and URL vectors
+ header_titles = new Vector();
+ header_titles.add("SIGs");
+ header_titles.add("Users");
+ header_titles.add("Categories");
+ header_titles.trimToSize();
+
+ header_urls = new Vector();
+ header_urls.add("find?disp=" + String.valueOf(FD_SIGS));
+ header_urls.add("find?disp=" + String.valueOf(FD_USERS));
+ header_urls.add("find?disp=" + String.valueOf(FD_CATEGORIES));
+ header_urls.trimToSize();
+
+ } // end if
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static int getParamInt(ServletRequest request, String name, int default_val)
+ {
+ String str = request.getParameter(name);
+ if (str==null)
+ return -1;
+
+ try
+ { // parse the integer value
+ return Integer.parseInt(str);
+
+ } // end try
+ catch (NumberFormatException nfe)
+ { // in case of conversion error, return default
+ return default_val;
+
+ } // end catch
+
+ } // end getParamInt
+
+ private static boolean isImageButtonClicked(ServletRequest request, String name)
+ {
+ String val = request.getParameter(name + ".x");
+ return (val!=null);
+
+ } // end isImageButtonClicked
+
+ /*--------------------------------------------------------------------------------
+ * External static functions
+ *--------------------------------------------------------------------------------
+ */
+
+ public static int getNumChoices()
+ {
+ return FD_CATEGORIES + 1;
+
+ } // end getNumChoices
+
+ public static FindData retrieve(ServletRequest request)
+ {
+ return (FindData)(request.getAttribute(ATTR_NAME));
+
+ } // end retrieve
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface JSPRender
+ *--------------------------------------------------------------------------------
+ */
+
+ public void store(ServletRequest request)
+ {
+ request.setAttribute(ATTR_NAME,this);
+
+ } // end store
+
+ public String getTargetJSPName()
+ {
+ return "find.jsp";
+
+ } // end getTargetJSPName
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void writeHeader(RenderData rdat, Writer out) throws IOException
+ {
+ rdat.writeContentSelectorHeader(out,"Find:",header_titles,header_urls,disp);
+
+ } // end writeHeader
+
+ public int getDisplayOption()
+ {
+ return disp;
+
+ } // end getDisplayOption
+
+ public int getSearchField()
+ {
+ return field;
+
+ } // end getSearchField
+
+ public boolean searchFieldIs(int value)
+ {
+ return (value==field);
+
+ } // end searchFieldIs
+
+ public int getSearchMode()
+ {
+ return mode;
+
+ } // end getSearchMode
+
+ public boolean searchModeIs(int value)
+ {
+ return (value==mode);
+
+ } // end searchModeIs
+
+ public String getSearchTerm()
+ {
+ return term;
+
+ } // end getSearchTerm
+
+ public CategoryDescriptor getCategory()
+ {
+ return cat;
+
+ } // end getCategory
+
+ public List getSubCategoryList()
+ {
+ return subcats;
+
+ } // end getSubCategoryList
+
+ public List getResultsList()
+ {
+ return results;
+
+ } // end getResultsList
+
+ public int getNumResultsDisplayed()
+ {
+ return engine.getStdNumSearchResults();
+
+ } // end getNumResultsDisplayed
+
+ public int getFindCount()
+ {
+ return find_count;
+
+ } // end getFindCount
+
+ public int getOffset()
+ {
+ return offset;
+
+ } // end getOffset
+
+ public void loadGet(int catid) throws DataException
+ {
+ if (disp==FD_SIGS)
+ { // fill in the list of subcategories and of SIGs in this category
+ cat = user.getCategoryDescriptor(catid);
+ subcats = cat.getSubCategories();
+ if (cat.getCategoryID()>=0)
+ { // fill in the SIGs that are in this category
+ results = user.getSIGsInCategory(cat,offset,getNumResultsDisplayed());
+ find_count = user.getNumSIGsInCategory(cat);
+
+ } // end if
+ field = FIELD_SIG_NAME;
+
+ } // end if
+ else if (disp==FD_USERS)
+ field = FIELD_USER_NAME;
+
+ mode = SEARCH_PREFIX;
+ term = "";
+
+ } // end loadGet
+
+ public void loadPost(ServletRequest request) throws ValidationException, DataException
+ {
+ int catid = -1;
+
+ // Retrieve all the posted parameters from the form and validate them. First validate the
+ // category ID (if specified) and the field identifier.
+ switch (disp)
+ {
+ case FD_SIGS:
+ catid = getParamInt(request,"cat",-1);
+ if (!engine.isValidCategoryID(catid))
+ throw new ValidationException("The category ID parameter is not valid.");
+ field = getParamInt(request,"field",FIELD_SIG_NAME);
+ if ((field!=FIELD_SIG_NAME) && (field!=FIELD_SIG_SYNOPSIS))
+ throw new ValidationException("The field search parameter is not valid.");
+ break;
+
+ case FD_USERS:
+ field = getParamInt(request,"field",FIELD_USER_NAME);
+ if ( (field!=FIELD_USER_NAME) && (field!=FIELD_USER_DESCRIPTION) && (field!=FIELD_USER_GIVEN_NAME)
+ && (field!=FIELD_USER_FAMILY_NAME))
+ throw new ValidationException("The field search parameter is not valid.");
+ break;
+
+ case FD_CATEGORIES:
+ // no parameters to set here - there's no "field" for category search
+ break;
+
+ default:
+ throw new InternalStateError("loadPost failure - invalid display parameter");
+
+ } // end switch
+
+ // Validate the search mode parameter.
+ mode = getParamInt(request,"mode",SEARCH_PREFIX);
+ if ((mode!=SEARCH_PREFIX) && (mode!=SEARCH_SUBSTRING) && (mode!=SEARCH_REGEXP))
+ throw new ValidationException("The search mode parameter is not valid.");
+
+ // Retrieve the search term parameter.
+ term = request.getParameter("term");
+ if (term==null)
+ term = "";
+
+ // Retrieve the offset and find count parameters.
+ offset = getParamInt(request,"ofs",0);
+ find_count = getParamInt(request,"fcount",-1);
+
+ // Adjust the search return offset based on the command button click.
+ int count = getNumResultsDisplayed();
+ if (isImageButtonClicked(request,"search"))
+ offset = 0;
+ else if (isImageButtonClicked(request,"previous"))
+ { // adjust the offset in the reverse direction
+ offset -= count;
+ if (offset<0)
+ offset = 0;
+
+ } // end else if
+ else if (isImageButtonClicked(request,"next"))
+ offset += count; // go forwards instead
+ else
+ throw new ValidationException("Unable to determine what action triggered the form.");
+
+ // Run the actual search.
+ switch (disp)
+ {
+ case FD_SIGS:
+ if (catid>=0)
+ { // retrieve the category descriptor and the subcategory list
+ cat = user.getCategoryDescriptor(catid);
+ subcats = cat.getSubCategories();
+ if (cat.getCategoryID()>=0)
+ { // fill in the SIGs that are in this category
+ results = user.getSIGsInCategory(cat,offset,count);
+ if (find_count<0)
+ find_count = user.getNumSIGsInCategory(cat);
+
+ } // end if
+
+ } // end if
+ else
+ { // retrieve the SIG search data
+ results = user.searchForSIGs(field,mode,term,offset,count);
+ if (find_count<0)
+ find_count = user.getSearchSIGCount(field,mode,term);
+
+ } // end else
+ break;
+
+ case FD_USERS:
+ results = engine.searchForUsers(field,mode,term,offset,count);
+ if (find_count<0)
+ find_count = engine.getSearchUserCount(field,mode,term);
+ break;
+
+ case FD_CATEGORIES:
+ results = user.searchForCategories(mode,term,offset,count);
+ if (find_count<0)
+ find_count = user.getSearchCategoryCount(mode,term);
+ break;
+
+ } // end switch
+
+ } // end loadPost
+
+ public static String getCatJumpLink(RenderData rdat, int catid)
+ {
+ return rdat.getEncodedServletPath("find?disp=" + String.valueOf(FD_SIGS) + "&cat="
+ + String.valueOf(catid));
+
+ } // end getCatJumpLink
+
+} // end class FindData
diff --git a/src/com/silverwrist/venice/servlets/format/JSPRender.java b/src/com/silverwrist/venice/servlets/format/JSPRender.java
new file mode 100644
index 0000000..d826db3
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/JSPRender.java
@@ -0,0 +1,28 @@
+/*
+ * 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 Community 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 javax.servlet.ServletRequest;
+
+public interface JSPRender
+{
+ public abstract void store(ServletRequest request);
+
+ public abstract String getTargetJSPName();
+
+} // end interface JSPRender
diff --git a/src/com/silverwrist/venice/servlets/format/JoinKeyDialog.java b/src/com/silverwrist/venice/servlets/format/JoinKeyDialog.java
new file mode 100644
index 0000000..caa8f4c
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/JoinKeyDialog.java
@@ -0,0 +1,95 @@
+/*
+ * 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 Community 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 com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.*;
+
+public class JoinKeyDialog extends ContentDialog
+{
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public JoinKeyDialog()
+ {
+ super("Join Key Required",null,"joinkeyform","sigops");
+ setHiddenField("cmd","J");
+ setHiddenField("sig","");
+ setInstructions("You must specify a join key before you can join this SIG. You might have received "
+ + "the join key from the SIG's host, or via an invitation e-mail message. Please "
+ + "enter it in the box below.");
+ addFormField(new CDTextFormField("key","Join key",null,false,32,64));
+ addCommandButton(new CDImageButton("join","bn_join_now.gif","Join Now",80,24));
+ addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
+
+ } // end constructor
+
+ protected JoinKeyDialog(JoinKeyDialog other)
+ {
+ super(other);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class ContentDialog
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void validateWholeForm() throws ValidationException
+ {
+ if (StringUtil.isStringEmpty(getFieldValue("key")))
+ throw new ValidationException("No join key specified.");
+
+ } // end validateWholeForm
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void setupDialog(SIGContext sig)
+ {
+ setHiddenField("sig",String.valueOf(sig.getSIGID()));
+
+ } // end setupDialog
+
+ public void doDialog(SIGContext sig) throws ValidationException, DataException, AccessError
+ {
+ validate();
+ sig.join(getFieldValue("key"));
+
+ } // end doDialog
+
+ public void resetOnError(String message)
+ {
+ setErrorMessage(message);
+ setFieldValue("key",null);
+
+ } // end resetOnError
+
+ public Object clone()
+ {
+ return new JoinKeyDialog(this);
+
+ } // end clone
+
+} // end class JoinKeyDialog
+
diff --git a/src/com/silverwrist/venice/servlets/format/LoginDialog.java b/src/com/silverwrist/venice/servlets/format/LoginDialog.java
new file mode 100644
index 0000000..68d3172
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/LoginDialog.java
@@ -0,0 +1,83 @@
+/*
+ * 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 Community 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 com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.servlets.Variables;
+
+public class LoginDialog extends ContentDialog
+{
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public LoginDialog()
+ {
+ super("Log In",null,"loginform","account");
+ setHiddenField("cmd","L");
+ setHiddenField("tgt","");
+ addFormField(new CDVeniceIDFormField("user","User name",null,false,32,64));
+ 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"));
+ addCommandButton(new CDImageButton("login","bn_log_in.gif","Log In",80,24));
+ addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
+
+ } // end constructor
+
+ protected LoginDialog(LoginDialog other)
+ {
+ super(other);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void setTarget(String target)
+ {
+ setHiddenField("tgt",target);
+
+ } // end setTarget
+
+ public void setupNew(String target)
+ {
+ setHiddenField("tgt",target);
+
+ } // end setupNew
+
+ public void resetOnError(String message)
+ {
+ setErrorMessage(message);
+ setFieldValue("pass",null);
+
+ } // end resetOnError
+
+ public Object clone()
+ {
+ return new LoginDialog(this);
+
+ } // end clone
+
+} // end class LoginDialog
diff --git a/src/com/silverwrist/venice/servlets/format/MenuPanelCache.java b/src/com/silverwrist/venice/servlets/format/MenuPanelCache.java
new file mode 100644
index 0000000..504b978
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/MenuPanelCache.java
@@ -0,0 +1,103 @@
+/*
+ * 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 Community 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.util.Hashtable;
+import javax.servlet.ServletContext;
+import org.apache.log4j.*;
+
+public class MenuPanelCache
+{
+ /*--------------------------------------------------------------------------------
+ * Static data values
+ *--------------------------------------------------------------------------------
+ */
+
+ protected static final String ATTR_NAME = "com.silverwrist.venice.servlets.MenuPanelCache";
+
+ private static Category logger = Category.getInstance(MenuPanelCache.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ Hashtable cache;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ protected MenuPanelCache()
+ {
+ cache = new Hashtable();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public boolean isCached(String name)
+ {
+ return (cache.get(name)!=null);
+
+ } // end isCached
+
+ public void saveTemplate(ContentMenuPanel template)
+ {
+ String fullname = template.getClass().getName();
+ int clip_pos = fullname.lastIndexOf('.');
+ if (clip_pos>=0)
+ fullname = fullname.substring(clip_pos+1);
+ cache.put(fullname,template);
+
+ } // end saveTemplate
+
+ public ContentMenuPanel getNewMenuPanel(String name)
+ {
+ ContentMenuPanel template = (ContentMenuPanel)(cache.get(name));
+ if (template!=null)
+ return (ContentMenuPanel)(template.clone());
+ else
+ return null;
+
+ } // end getNewMenuPanel
+
+ /*--------------------------------------------------------------------------------
+ * Static operations for use by servlets
+ *--------------------------------------------------------------------------------
+ */
+
+ public static MenuPanelCache getMenuPanelCache(ServletContext ctxt)
+ {
+ // Look in the servlet attributes first.
+ Object foo = ctxt.getAttribute(ATTR_NAME);
+ if (foo!=null)
+ return (MenuPanelCache)foo;
+
+ // create a new one and return it
+ MenuPanelCache cache = new MenuPanelCache();
+ ctxt.setAttribute(ATTR_NAME,cache);
+ return cache;
+
+ } // end getMenuPanelCache
+
+} // end class MenuPanelCache
diff --git a/src/com/silverwrist/venice/servlets/format/MenuSIG.java b/src/com/silverwrist/venice/servlets/format/MenuSIG.java
new file mode 100644
index 0000000..b7618d4
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/MenuSIG.java
@@ -0,0 +1,105 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import java.util.*;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.core.*;
+
+public class MenuSIG implements ContentRender
+{
+ private String image_url;
+ private boolean image_url_needs_fixup = false;
+ private String title;
+ private List items_list;
+ private int sigid;
+ private boolean show_unjoin;
+
+ public MenuSIG(SIGContext ctxt)
+ {
+ try
+ { // retrieve the contact info for this puppy
+ ContactInfo ci = ctxt.getContactInfo();
+ image_url = ci.getPhotoURL();
+ if (StringUtil.isStringEmpty(image_url))
+ { // just hit the default
+ image_url = "default_sig_logo.gif";
+ image_url_needs_fixup = true;
+
+ } // end if
+
+ } // end try
+ catch (DataException e)
+ { // if we couldn't get the contact info, screw it
+ image_url = null;
+
+ } // end catch
+
+ title = ctxt.getName();
+ items_list = ctxt.getSIGFeaturesList();
+ sigid = ctxt.getSIGID();
+ show_unjoin = ctxt.canUnjoin();
+
+ } // end constructor
+
+ public int getID()
+ {
+ return sigid;
+
+ } // end getID
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ if (image_url!=null)
+ { // display the image by URL
+ if (image_url_needs_fixup)
+ { // fix up the URL...
+ image_url = rdat.getFullImagePath(image_url);
+ image_url_needs_fixup = false;
+
+ } // end if
+
+ out.write("
\n");
+
+ } // end if
+
+ // display the title
+ out.write("" + StringUtil.encodeHTML(title) + "");
+
+ // display the menu items
+ Iterator it = items_list.iterator();
+ while (it.hasNext())
+ { // display each menu item in turn
+ SIGFeature ftr = (SIGFeature)(it.next());
+ out.write(" \n" + StringUtil.encodeHTML(ftr.getName()) + "\n");
+
+ } // end while
+
+ if (show_unjoin)
+ out.write("
\nUnjoin\n");
+
+ out.write("\n"); // all done...
+
+ } // end renderHere
+
+} // end class MenuTop
diff --git a/src/com/silverwrist/venice/servlets/format/MenuTop.java b/src/com/silverwrist/venice/servlets/format/MenuTop.java
new file mode 100644
index 0000000..9af54e5
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/MenuTop.java
@@ -0,0 +1,37 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+
+public class MenuTop implements ContentRender
+{
+ public MenuTop()
+ { // constructor does nothing
+ } // end constructor
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ out.write("Front Page \n");
+ out.write("Calendar \n"); // TODO: fill this link in
+ out.write("Chat\n"); // TODO: fill this link in
+
+ } // end renderHere
+
+} // end class MenuTop
diff --git a/src/com/silverwrist/venice/servlets/format/NewAccountDialog.java b/src/com/silverwrist/venice/servlets/format/NewAccountDialog.java
new file mode 100644
index 0000000..c958eee
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/NewAccountDialog.java
@@ -0,0 +1,155 @@
+/*
+ * 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 Community 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.util.List;
+import javax.servlet.ServletRequest;
+import com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.*;
+
+public class NewAccountDialog extends ContentDialog
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private VeniceEngine engine = null;
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public NewAccountDialog(List country_list)
+ {
+ super("Create Account",null,"createform","account");
+ setInstructions("To create a new account, please enter your information below.");
+ setHiddenField("cmd","C");
+ setHiddenField("tgt","");
+ addFormField(new CDFormCategoryHeader("Name"));
+ addFormField(new CDTextFormField("prefix","Prefix","(Mr., Ms., etc.)",false,8,8));
+ addFormField(new CDTextFormField("first","First name",null,true,32,64));
+ addFormField(new CDTextFormField("mid","Middle initial",null,false,1,1));
+ addFormField(new CDTextFormField("last","Last name",null,true,32,64));
+ addFormField(new CDTextFormField("suffix","Suffix","(Jr., III, etc.)",false,16,16));
+ addFormField(new CDFormCategoryHeader("Location"));
+ addFormField(new CDTextFormField("loc","City",null,true,32,64));
+ addFormField(new CDTextFormField("reg","State/Province",null,true,32,64));
+ addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
+ addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
+ addFormField(new CDFormCategoryHeader("E-mail"));
+ addFormField(new CDEmailAddressFormField("email","E-mail address",null,true,32,255));
+ addFormField(new CDFormCategoryHeader("Account Information"));
+ addFormField(new CDVeniceIDFormField("user","User name",null,true,32,64));
+ addFormField(new CDPasswordFormField("pass1","Password",null,true,32,128));
+ addFormField(new CDPasswordFormField("pass2","Password","(retype)",true,32,128));
+ addFormField(new CDTextFormField("remind","Password reminder phrase",null,false,32,255));
+ addCommandButton(new CDImageButton("create","bn_create.gif","Create",80,24));
+ addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
+
+ } // end constructor
+
+ protected NewAccountDialog(NewAccountDialog other)
+ {
+ super(other);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Overrides from class ContentDialog
+ *--------------------------------------------------------------------------------
+ */
+
+ protected void validateWholeForm() throws ValidationException
+ {
+ if (!(getFieldValue("pass1").equals(getFieldValue("pass2"))))
+ throw new ValidationException("The typed passwords do not match.");
+
+ if (engine.isEmailAddressBanned(getFieldValue("email")))
+ throw new ValidationException("This email address may not register a new account.");
+
+ } // end validateWholeForm
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void setEngine(VeniceEngine engine)
+ {
+ this.engine = engine;
+
+ } // end setEngine
+
+ public void setTarget(String target)
+ {
+ setHiddenField("tgt",target);
+
+ } // end setTarget
+
+ public UserContext doDialog(ServletRequest request)
+ throws ValidationException, DataException, AccessError, EmailException
+ {
+ validate(); // validate the dialog
+
+ // Create the new user account and set up its initial context.
+ UserContext uc = engine.createNewAccount(request.getRemoteAddr(),getFieldValue("user"),
+ getFieldValue("pass1"),getFieldValue("remind"));
+
+ // Set up the account's contact info.
+ ContactInfo ci = uc.getContactInfo();
+ ci.setNamePrefix(getFieldValue("prefix"));
+ ci.setGivenName(getFieldValue("first"));
+ String blort = getFieldValue("mid");
+ if ((blort==null) || (blort.length()<1))
+ ci.setMiddleInitial(' ');
+ else
+ ci.setMiddleInitial(blort.charAt(0));
+ ci.setFamilyName(getFieldValue("last"));
+ ci.setNameSuffix(getFieldValue("suffix"));
+ ci.setLocality(getFieldValue("loc"));
+ ci.setRegion(getFieldValue("reg"));
+ ci.setPostalCode(getFieldValue("pcode"));
+ ci.setCountry(getFieldValue("country"));
+ ci.setEmail(getFieldValue("email"));
+
+ // save the contact info for the user (this also sends email confirmation messages as needed)
+ uc.putContactInfo(ci);
+
+ return uc;
+
+ } // end doDialog
+
+ public void resetOnError(String message)
+ {
+ setErrorMessage(message);
+ setFieldValue("pass1",null);
+ setFieldValue("pass2",null);
+
+ } // end resetOnError
+
+ public Object clone()
+ {
+ return new NewAccountDialog(this);
+
+ } // end clone
+
+} // end class NewAccountDialog
+
+
diff --git a/src/com/silverwrist/venice/servlets/format/NewSIGWelcome.java b/src/com/silverwrist/venice/servlets/format/NewSIGWelcome.java
new file mode 100644
index 0000000..88ee8e3
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/NewSIGWelcome.java
@@ -0,0 +1,104 @@
+/*
+ * 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 Community 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 javax.servlet.ServletRequest;
+import com.silverwrist.venice.core.SIGContext;
+
+public class NewSIGWelcome implements JSPRender
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ // Attribute name for request attribute
+ protected static final String ATTR_NAME = "com.silverwrist.venice.content.NewSIGWelcome";
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String name;
+ private String entry_url;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public NewSIGWelcome(SIGContext sig)
+ {
+ name = sig.getName();
+ entry_url = "sig/" + sig.getAlias();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External static functions
+ *--------------------------------------------------------------------------------
+ */
+
+ public static NewSIGWelcome retrieve(ServletRequest request)
+ {
+ return (NewSIGWelcome)(request.getAttribute(ATTR_NAME));
+
+ } // end retrieve
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface JSPRender
+ *--------------------------------------------------------------------------------
+ */
+
+ public void store(ServletRequest request)
+ {
+ request.setAttribute(ATTR_NAME,this);
+
+ } // end store
+
+ public String getTargetJSPName()
+ {
+ return "newsigwelcome.jsp";
+
+ } // end getTargetJSPName
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getSIGName()
+ {
+ return name;
+
+ } // end getSIGName
+
+ public String getEntryURL(RenderData rdat)
+ {
+ return rdat.getEncodedServletPath(entry_url);
+
+ } // end getEntryURL
+
+ public String getDisplayURL(RenderData rdat)
+ {
+ return rdat.getFullServletPath(entry_url);
+
+ } // end getEntryURL
+
+} // end class NewSIGWelcome
diff --git a/src/com/silverwrist/venice/servlets/format/RenderConfig.java b/src/com/silverwrist/venice/servlets/format/RenderConfig.java
new file mode 100644
index 0000000..ad5e587
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/RenderConfig.java
@@ -0,0 +1,357 @@
+/*
+ * 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 Community 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.io.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.xml.parsers.*;
+import org.apache.log4j.*;
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import com.silverwrist.util.DOMElementHelper;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.core.ConfigException;
+
+public class RenderConfig
+{
+ /*--------------------------------------------------------------------------------
+ * Static data values
+ *--------------------------------------------------------------------------------
+ */
+
+ protected static final String ATTR_NAME = "com.silverwrist.venice.servlets.RenderConfig";
+ protected static final String CONFIG_FILE_PARAM = "render.config";
+
+ private static Category logger = Category.getInstance(RenderConfig.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private Document config;
+ private String site_title;
+ private boolean want_comments;
+ private boolean allow_gzip;
+ private String font_face;
+ private String base_url;
+ private String image_url;
+ private String site_logo;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ protected RenderConfig(String config_file) throws ConfigException
+ {
+ config = loadConfiguration(config_file);
+
+ // Make sure the configuration is valid...
+ Element root = config.getDocumentElement();
+ if (!(root.getTagName().equals("render-config")))
+ { // not the correct root tag name
+ logger.fatal("config document is not a document (root tag: <"
+ + root.getTagName() + "/>)");
+ throw new ConfigException("document is not a document",root);
+
+ } // end if
+
+ // Get the site name.
+ DOMElementHelper root_h = new DOMElementHelper(root);
+ site_title = root_h.getSubElementText("site-name");
+ if (site_title==null)
+ { // no section - bail out now!
+ logger.fatal("config document has no element");
+ throw new ConfigException("no section found in config file",root);
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("Site title: " + site_title);
+
+ Element render_sect = root_h.getSubElement("rendering");
+ if (render_sect==null)
+ { // no section - bail out now!
+ logger.fatal("config document has no section");
+ throw new ConfigException("no section found in config file",root);
+
+ } // end if
+
+ DOMElementHelper render_sect_h = new DOMElementHelper(render_sect);
+ want_comments = render_sect_h.hasChildElement("html-comments");
+ allow_gzip = render_sect_h.hasChildElement("gzip-output");
+ if (logger.isDebugEnabled())
+ { // log the read values
+ logger.debug("Use HTML comments: " + String.valueOf(want_comments));
+ logger.debug("Use GZIP encoding: " + String.valueOf(allow_gzip));
+
+ } // end if
+
+ font_face = render_sect_h.getSubElementText("font");
+ if (font_face==null)
+ { // no tag - bail out now!
+ logger.fatal(" section has no element");
+ throw new ConfigException("no found in section",render_sect);
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("Font face: " + font_face);
+
+ Element paths_sect = root_h.getSubElement("paths");
+ if (paths_sect==null)
+ { // no section - bail out now!
+ logger.fatal("config document has no section");
+ throw new ConfigException("no section found in config file",root);
+
+ } // end if
+
+ DOMElementHelper paths_sect_h = new DOMElementHelper(paths_sect);
+ base_url = paths_sect_h.getSubElementText("base");
+ if (base_url==null)
+ { // no tag - bail out now!
+ logger.fatal(" section has no element");
+ throw new ConfigException("no found in section",paths_sect);
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("Base path: " + base_url);
+
+ image_url = paths_sect_h.getSubElementText("image");
+ if (image_url==null)
+ { // no tag - bail out now!
+ logger.fatal(" section has no element");
+ throw new ConfigException("no found in section",paths_sect);
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("Image path: " + image_url);
+
+ site_logo = paths_sect_h.getSubElementText("site-logo");
+ if (site_logo==null)
+ { // no tag - bail out now!
+ logger.fatal(" section has no element");
+ throw new ConfigException("no found in section",paths_sect);
+
+ } // end if
+
+ if (logger.isDebugEnabled())
+ logger.debug("Site logo: " + image_url);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal functions
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Document loadConfiguration(String configname) throws ConfigException
+ {
+ try
+ { // create a simple DOM parser by using the Java XML parsing API
+ DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
+ fac.setNamespaceAware(false);
+ fac.setValidating(false);
+ DocumentBuilder parser = fac.newDocumentBuilder();
+
+ // access the config file and parse it into our config data tree
+ File configfile = new File(configname);
+ Document rc = parser.parse(configfile);
+ if (logger.isDebugEnabled())
+ logger.debug("configuration loaded successfully");
+ return rc;
+
+ } // end try
+ catch (FactoryConfigurationError e1)
+ { // if the document builder factory could not be created
+ logger.fatal("Parser factory configuration error: " + e1.getMessage(),e1);
+ throw new ConfigException("XML parser factory could not be created - " + e1.getMessage());
+
+ } // end catch
+ catch (ParserConfigurationException e2)
+ { // if the XML parser itself could not be created
+ logger.fatal("Parser configuration error: " + e2.getMessage(),e2);
+ throw new ConfigException("XML parser could not be created - " + e2.getMessage(),e2);
+
+ } // end catch
+ catch (SAXException e3)
+ { // if the XML parser choked on our document
+ if (e3 instanceof SAXParseException)
+ { // we have a detailed message - make a proper exception
+ SAXParseException e3a = (SAXParseException)e3;
+ logger.fatal("Config file error [" + configname + ":" + e3a.getLineNumber() + ","
+ + e3a.getColumnNumber() + "]: " + e3a.getMessage(),e3a);
+ throw new ConfigException("Configuration file error: " + e3a.getMessage() + " at line "
+ + e3a.getLineNumber() + ", column " + e3a.getColumnNumber(),e3a);
+
+ } // end if
+ else
+ { // generic exception - just send up a simple error message
+ logger.fatal("Config file error [" + configname + "]: " + e3.getMessage(),e3);
+ throw new ConfigException("Configuration file error - " + e3.getMessage(),e3);
+
+ } // end else
+
+ } // end catch
+ catch (IOException e4)
+ { // error reading the config file itself off the disk
+ logger.fatal("IO error reading config: " + e4.getMessage(),e4);
+ throw new ConfigException("unable to read config file \"" + configname + "\" - " + e4.getMessage(),e4);
+
+ } // end catch
+
+ } // end loadConfiguration
+
+ /*--------------------------------------------------------------------------------
+ * External operations usable only by RenderData
+ *--------------------------------------------------------------------------------
+ */
+
+ boolean useHTMLComments()
+ {
+ return want_comments;
+
+ } // end useHTMLComments
+
+ boolean isGZIPAllowed()
+ {
+ return allow_gzip;
+
+ } // end isGZIPAllowed
+
+ String getFullServletPath(String name)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append(base_url).append(name);
+ return buf.toString();
+
+ } // end getFullServletPath
+
+ String getFullImagePath(String name)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append(image_url).append(name);
+ return buf.toString();
+
+ } // end getFullImagePath
+
+ String getTitleTag(String specific)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append("").append(specific).append(" - ").append(site_title).append("");
+ return buf.toString();
+
+ } // end getTitleTag
+
+ String getSiteImageTag(int hspace, int vspace)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append("0)
+ buf.append(" HSPACE=").append(hspace);
+ if (vspace>0)
+ buf.append(" VSPACE=").append(vspace);
+ buf.append('>');
+ return buf.toString();
+
+ } // end getSiteImageTag
+
+ String getStdFontTag(String color, int size)
+ {
+ StringBuffer buf = new StringBuffer("');
+ return buf.toString();
+
+ } // end getStdFontTag
+
+ public String getRequiredBullet()
+ {
+ StringBuffer buf = new StringBuffer("*");
+ return buf.toString();
+
+ } // end getRequiredBullet
+
+ void writeFooter(Writer out) throws IOException
+ {
+ out.write("
\n\n
\n");
+
+ } // end writeFooter
+
+ void writeContentHeader(Writer out, String primary, String secondary) throws IOException
+ {
+ out.write(getStdFontTag("#3333AA",5) + "" + StringUtil.encodeHTML(primary) + "");
+ if (secondary!=null)
+ out.write(" " + getStdFontTag("#3333AA",3) + "" + StringUtil.encodeHTML(secondary)
+ + "");
+ out.write("\n");
+
+ } // end writeContentHeader
+
+ /*--------------------------------------------------------------------------------
+ * Static operations for use by VeniceServlet
+ *--------------------------------------------------------------------------------
+ */
+
+ public static RenderConfig getRenderConfig(ServletContext ctxt) throws ServletException
+ {
+ // Look in the servlet attributes first.
+ Object obj = ctxt.getAttribute(ATTR_NAME);
+ if (obj!=null)
+ return (RenderConfig)obj;
+
+ // Get the parameter for the renderer's config file.
+ String cfgfile = ctxt.getInitParameter(CONFIG_FILE_PARAM);
+ logger.info("Initializing Venice rendering using config file: " + cfgfile);
+
+ try
+ { // create the RenderConfig object and save it to attributes.
+ RenderConfig rconf = new RenderConfig(cfgfile);
+ ctxt.setAttribute(ATTR_NAME,rconf);
+ return rconf;
+
+ } // end try
+ catch (ConfigException e)
+ { // configuration failed! post an error message
+ logger.fatal("Rendering configuration failed: " + e.getMessage(),e);
+ throw new ServletException("Venice rendering configuration failed: " + e.getMessage(),e);
+
+ } // end catch
+
+ } // end getRenderConfig
+
+ public static RenderData createRenderData(ServletContext ctxt, HttpServletRequest request,
+ HttpServletResponse response) throws ServletException
+ {
+ return new RenderData(getRenderConfig(ctxt),request,response);
+
+ } // end createRenderData
+
+} // end class RenderConfig
diff --git a/src/com/silverwrist/venice/servlets/format/RenderData.java b/src/com/silverwrist/venice/servlets/format/RenderData.java
new file mode 100644
index 0000000..d3f8a12
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/RenderData.java
@@ -0,0 +1,296 @@
+/*
+ * 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 Community 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.util.*;
+import java.io.*;
+import java.text.DateFormat;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.log4j.*;
+import com.silverwrist.util.StringUtil;
+
+public class RenderData
+{
+ /*--------------------------------------------------------------------------------
+ * Static data values
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final String ATTR_NAME = "com.silverwrist.venice.RenderData";
+
+ private static Category logger = Category.getInstance(RenderData.class.getName());
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private RenderConfig rconf;
+ private HttpServletRequest request;
+ private HttpServletResponse response;
+ private boolean can_gzip = false;
+ private Locale my_locale;
+ private TimeZone my_timezone;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ RenderData(RenderConfig rconf, HttpServletRequest request, HttpServletResponse response)
+ {
+ this.rconf = rconf;
+ this.request = request;
+ this.response = response;
+
+ // determine whether this browser can accept GZIP-encoded content
+ String encodings = request.getHeader("Accept-Encoding");
+ if ((encodings!=null) && (encodings.indexOf("gzip")>=0))
+ can_gzip = true;
+
+ // TODO: replace with reading user's preferences
+ my_locale = Locale.getDefault();
+ my_timezone = TimeZone.getDefault();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External static operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public static RenderData retrieve(ServletRequest request)
+ {
+ return (RenderData)(request.getAttribute(ATTR_NAME));
+
+ } // end retrieve
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void store(ServletRequest request)
+ {
+ request.setAttribute(ATTR_NAME,this);
+
+ } // end store
+
+ public boolean useHTMLComments()
+ {
+ return rconf.useHTMLComments();
+
+ } // end useHTMLComments
+
+ public boolean canGZIPEncode()
+ {
+ return rconf.isGZIPAllowed() && can_gzip;
+
+ } // end canGZIPEncode
+
+ public String getSiteImageTag(int hspace, int vspace)
+ {
+ return rconf.getSiteImageTag(hspace,vspace);
+
+ } // end getSiteImageTag
+
+ public String getFullServletPath(String name)
+ {
+ return rconf.getFullServletPath(name);
+
+ } // end getFullServletPath
+
+ public String getEncodedServletPath(String name)
+ {
+ return response.encodeURL(rconf.getFullServletPath(name));
+
+ } // end getEncodedServletPath
+
+ public String getFullImagePath(String name)
+ {
+ return rconf.getFullImagePath(name);
+
+ } // end getFullImagePath
+
+ public String getFormatJSPPath(String name)
+ {
+ return "/format/" + name;
+
+ } // end getFullFormatJSPPath
+
+ public String getStdFontTag(String color, int size)
+ {
+ return rconf.getStdFontTag(color,size);
+
+ } // end getStdFontTag
+
+ public String getTitleTag(String specific)
+ {
+ return rconf.getTitleTag(specific);
+
+ } // end getTitleTag
+
+ public String getRequiredBullet()
+ {
+ return rconf.getRequiredBullet();
+
+ } // 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);
+
+ } // end writeContentHeader
+
+ public void writeContentSelectorHeader(Writer out, String caption, List choices,
+ List urls, int selected) throws IOException
+ {
+ int nchoice = choices.size();
+ if (urls.size()" + StringUtil.encodeHTML(caption)
+ + " " + rconf.getStdFontTag("#3333AA",3));
+ for (int i=0; i");
+ else
+ out.write("");
+ out.write(StringUtil.encodeHTML((String)(choices.get(i))));
+ if (i==selected)
+ out.write("");
+ else
+ out.write("");
+ out.write(" ");
+
+ } // end for
+
+ out.write("]\n");
+
+ } // end writeContentSelectorHeader
+
+ public String formatDateForDisplay(Date date)
+ {
+ DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM,my_locale);
+ fmt.setTimeZone(my_timezone);
+ return fmt.format(date);
+
+ } // end formatDateForDisplay
+
+ public Calendar createCalendar()
+ {
+ return new GregorianCalendar(my_timezone,my_locale);
+
+ } // end createCalendar
+
+ public Calendar createCalendar(Date date)
+ {
+ Calendar rc = new GregorianCalendar(my_timezone,my_locale);
+ rc.setTime(date);
+ return rc;
+
+ } // end createCalendar
+
+ public void flushOutput() throws IOException
+ {
+ response.flushBuffer();
+
+ } // end flushOutput
+
+ public String encodeURL(String url)
+ {
+ return response.encodeURL(url);
+
+ } // end encodeURL
+
+ public void storeBaseJSPData(BaseJSPData data)
+ {
+ data.store(request);
+
+ } // end storeBaseJSPData
+
+ public void storeJSPRender(JSPRender jr)
+ {
+ jr.store(request);
+
+ } // end storeJSPRender
+
+ public void forwardDispatch(RequestDispatcher dispatcher) throws IOException, ServletException
+ {
+ dispatcher.forward(request,response);
+
+ } // end forwardDispatch
+
+ public void includeDispatch(RequestDispatcher dispatcher) throws IOException, ServletException
+ {
+ dispatcher.include(request,response);
+
+ } // end forwardDispatch
+
+ public void redirectTo(String servlet) throws IOException
+ {
+ String url = response.encodeRedirectURL(rconf.getFullServletPath(servlet));
+ response.sendRedirect(url);
+
+ } // end redirectTo
+
+ public String getActivityString(Date date)
+ {
+ if (date==null)
+ return "Never"; // safeguard
+
+ Calendar c_last = createCalendar(date);
+ Calendar c_now = createCalendar(new Date());
+ int delta_days = 0;
+ while ( (c_last.get(Calendar.YEAR)!=c_now.get(Calendar.YEAR))
+ || (c_last.get(Calendar.DAY_OF_YEAR)!=c_now.get(Calendar.DAY_OF_YEAR)))
+ { // advance until we're pointing at the same year and the same day of the year
+ delta_days++;
+ c_last.add(Calendar.DAY_OF_YEAR,1);
+
+ } // end while
+
+ switch (delta_days)
+ { // now return a string based on the difference in days
+ case 0:
+ return "Today";
+
+ case 1:
+ return "Yesterday";
+
+ default:
+ return String.valueOf(delta_days) + " days ago";
+
+ } // end switch
+
+ } // end getActivityString
+
+} // end class RenderData
diff --git a/src/com/silverwrist/venice/servlets/format/SIGAdminTop.java b/src/com/silverwrist/venice/servlets/format/SIGAdminTop.java
new file mode 100644
index 0000000..d8d3b43
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/SIGAdminTop.java
@@ -0,0 +1,68 @@
+/*
+ * 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 Community 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.util.*;
+import java.io.Writer;
+import java.io.IOException;
+import com.silverwrist.venice.core.SIGContext;
+
+public class SIGAdminTop extends ContentMenuPanel
+{
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
+ public SIGAdminTop()
+ {
+ super("SIG Administration:",null);
+ addChoice("SIG Profile","sigadmin?sig=$s&cmd=P");
+ addChoice("Set SIG Category","sigadmin?sig=$s&cmd=T");
+ addChoice("Set SIG Features","sigadmin?sig=$s&cmd=F");
+ addChoice("Membership Control","sigadmin?sig=$s&cmd=M");
+ // TODO: More options
+ addChoice("Delete SIG","sigadmin?sig=$s&cmd=DEL");
+
+ } // end constructor
+
+ protected SIGAdminTop(SIGAdminTop other)
+ {
+ super(other);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public void setSIG(SIGContext sig)
+ {
+ setSubtitle(sig.getName());
+ setParameter("s",String.valueOf(sig.getSIGID()));
+
+ } // end setSIG
+
+ public Object clone()
+ {
+ return new SIGAdminTop(this);
+
+ } // end clone
+
+} // end class SIGAdminTop
diff --git a/src/com/silverwrist/venice/servlets/format/SIGCategoryBrowseData.java b/src/com/silverwrist/venice/servlets/format/SIGCategoryBrowseData.java
new file mode 100644
index 0000000..cf84363
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/SIGCategoryBrowseData.java
@@ -0,0 +1,144 @@
+/*
+ * 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 Community 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.util.*;
+import javax.servlet.ServletRequest;
+import com.silverwrist.venice.core.*;
+
+public class SIGCategoryBrowseData implements JSPRender
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ // Attribute name for request attribute
+ protected static final String ATTR_NAME = "com.silverwrist.venice.content.UserProfileData";
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String name;
+ private String base_applet;
+ private CategoryDescriptor prev_cat;
+ private CategoryDescriptor curr_cat;
+ private List subcats;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public SIGCategoryBrowseData(UserContext user, SIGContext sig, int current_id) throws DataException
+ {
+ name = sig.getName();
+ base_applet = "sigadmin?sig=" + String.valueOf(sig.getSIGID());
+ prev_cat = sig.getCategory();
+ if (prev_cat.getCategoryID()==current_id)
+ curr_cat = prev_cat;
+ else
+ curr_cat = user.getCategoryDescriptor(current_id);
+ subcats = curr_cat.getSubCategories();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External static functions
+ *--------------------------------------------------------------------------------
+ */
+
+ public static SIGCategoryBrowseData retrieve(ServletRequest request)
+ {
+ return (SIGCategoryBrowseData)(request.getAttribute(ATTR_NAME));
+
+ } // end retrieve
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface JSPRender
+ *--------------------------------------------------------------------------------
+ */
+
+ public void store(ServletRequest request)
+ {
+ request.setAttribute(ATTR_NAME,this);
+
+ } // end store
+
+ public String getTargetJSPName()
+ {
+ return "sigcatbrowser.jsp";
+
+ } // end getTargetJSPName
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getSIGName()
+ {
+ return name;
+
+ } // end if
+
+ public String getCancelURL(RenderData rdat)
+ {
+ return rdat.getEncodedServletPath(base_applet);
+
+ } // end getCancelURL
+
+ public String getPreviousCategory()
+ {
+ return prev_cat.toString();
+
+ } // end getPreviousCategory
+
+ public CategoryDescriptor getCurrentCategory()
+ {
+ return curr_cat;
+
+ } // end getCurrentCategory
+
+ public String getGoLink(RenderData rdat, int catid)
+ {
+ return rdat.getEncodedServletPath(base_applet + "&cmd=T&go=" + String.valueOf(catid));
+
+ } // end getGoLink
+
+ public String getSetLink(RenderData rdat, int catid)
+ {
+ return rdat.getEncodedServletPath(base_applet + "&cmd=T&set=" + String.valueOf(catid));
+
+ } // end getGoLink
+
+ public Iterator getSubcategoryIterator()
+ {
+ return subcats.iterator();
+
+ } // end getSubcategoryIterator
+
+ public boolean hasSubcategories()
+ {
+ return (subcats.size()>0);
+
+ } // end hasSubcategories
+
+} // end class SIGCategoryBrowseData
diff --git a/src/com/silverwrist/venice/servlets/format/SIGProfileData.java b/src/com/silverwrist/venice/servlets/format/SIGProfileData.java
new file mode 100644
index 0000000..b1d8572
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/SIGProfileData.java
@@ -0,0 +1,158 @@
+/*
+ * 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 Community 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 javax.servlet.ServletRequest;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.core.*;
+
+public class SIGProfileData implements JSPRender
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ // Attribute name for request attribute
+ protected static final String ATTR_NAME = "com.silverwrist.venice.content.SIGProfileData";
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private VeniceEngine engine; // the Venice engine
+ private UserContext user; // the current user managing this
+ private SIGContext sig; // the SIG being displayed
+ private ContactInfo ci; // SIG's contact info
+ private UserProfile host_prof; // SIG host's user profile
+ private CategoryDescriptor cat; // SIG's full category descriptor
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public SIGProfileData(VeniceEngine engine, UserContext user, SIGContext ctxt) throws DataException
+ {
+ this.engine = engine;
+ this.user = user;
+ this.sig = ctxt;
+ this.ci = ctxt.getContactInfo();
+ this.host_prof = ctxt.getHostProfile();
+ this.cat = ctxt.getCategory();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External static functions
+ *--------------------------------------------------------------------------------
+ */
+
+ public static SIGProfileData retrieve(ServletRequest request)
+ {
+ return (SIGProfileData)(request.getAttribute(ATTR_NAME));
+
+ } // end retrieve
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface JSPRender
+ *--------------------------------------------------------------------------------
+ */
+
+ public void store(ServletRequest request)
+ {
+ request.setAttribute(ATTR_NAME,this);
+
+ } // end store
+
+ public String getTargetJSPName()
+ {
+ return "sigprofile.jsp";
+
+ } // end getTargetJSPName
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public SIGContext getSIGContext()
+ {
+ return sig;
+
+ } // end getSIGContext
+
+ public String getSIGLogoURL(RenderData rdat)
+ {
+ String tmp = ci.getPhotoURL();
+ if (StringUtil.isStringEmpty(tmp))
+ tmp = rdat.getFullImagePath("default_sig_logo.gif");
+ return tmp;
+
+ } // end getSIGLogoURL
+
+ public boolean isUserLoggedIn()
+ {
+ return user.isLoggedIn();
+
+ } // end isUserLoggedIn
+
+ public String getHostUserName()
+ {
+ return host_prof.getUserName();
+
+ } // end getHostUserName
+
+ public ContactInfo getSIGContactInfo()
+ {
+ return ci;
+
+ } // end getSIGContactInfo
+
+ public String getAddressLastLine()
+ {
+ String tmp_c = ci.getLocality();
+ String tmp_s = ci.getRegion();
+ StringBuffer buf = new StringBuffer();
+ if (!(StringUtil.isStringEmpty(tmp_c)) && !(StringUtil.isStringEmpty(tmp_s)))
+ buf.append(tmp_c).append(", ").append(tmp_s);
+ else if (!(StringUtil.isStringEmpty(tmp_c)))
+ buf.append(tmp_c);
+ else if (!(StringUtil.isStringEmpty(tmp_s)))
+ buf.append(tmp_s);
+ tmp_s = ci.getPostalCode();
+ if (!(StringUtil.isStringEmpty(tmp_s)))
+ buf.append(' ').append(tmp_s);
+ return buf.toString();
+
+ } // end getAddressLastLine
+
+ public String getFullCountry()
+ {
+ return engine.getNameOfCountry(ci.getCountry());
+
+ } // end getFullCountry
+
+ public CategoryDescriptor getCategory()
+ {
+ return cat;
+
+ } // end getCategory
+
+} // end class SIGProfileData
diff --git a/src/com/silverwrist/venice/servlets/format/SIGWelcome.java b/src/com/silverwrist/venice/servlets/format/SIGWelcome.java
new file mode 100644
index 0000000..0924990
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/SIGWelcome.java
@@ -0,0 +1,98 @@
+/*
+ * 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 Community 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 javax.servlet.ServletRequest;
+import com.silverwrist.venice.core.SIGContext;
+
+public class SIGWelcome implements JSPRender
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ // Attribute name for request attribute
+ protected static final String ATTR_NAME = "com.silverwrist.venice.content.SIGWelcome";
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private String name;
+ private String entry_url;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public SIGWelcome(SIGContext sig)
+ {
+ name = sig.getName();
+ entry_url = "sig/" + sig.getAlias();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External static functions
+ *--------------------------------------------------------------------------------
+ */
+
+ public static SIGWelcome retrieve(ServletRequest request)
+ {
+ return (SIGWelcome)(request.getAttribute(ATTR_NAME));
+
+ } // end retrieve
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface JSPRender
+ *--------------------------------------------------------------------------------
+ */
+
+ public void store(ServletRequest request)
+ {
+ request.setAttribute(ATTR_NAME,this);
+
+ } // end store
+
+ public String getTargetJSPName()
+ {
+ return "sigwelcome.jsp";
+
+ } // end getTargetJSPName
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public String getSIGName()
+ {
+ return name;
+
+ } // end getSIGName
+
+ public String getEntryURL(RenderData rdat)
+ {
+ return rdat.getEncodedServletPath(entry_url);
+
+ } // end getEntryURL
+
+} // end class SIGWelcome
diff --git a/src/com/silverwrist/venice/servlets/format/TCPanelConferences.java b/src/com/silverwrist/venice/servlets/format/TCPanelConferences.java
new file mode 100644
index 0000000..bd4e10c
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/TCPanelConferences.java
@@ -0,0 +1,67 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import com.silverwrist.venice.core.UserContext;
+import com.silverwrist.venice.core.DataException;
+
+public class TCPanelConferences extends TCStandardPanel
+{
+ public TCPanelConferences()
+ {
+ super("Your Favorite Conferences:",null);
+ addButton("bn_manage.gif","Manage",null,true,80,24);
+
+ } // end constructor
+
+ public TCPanelConferences(TCPanelConferences other)
+ {
+ super(other);
+
+ } // end constructor
+
+ public void renderContent(Writer out, RenderData rdat) throws IOException
+ {
+ /* BEGIN TEMP */
+ out.write("
\n");
+ out.write("
BOFH (Benevolent Dictators)
\n");
+ out.write("
Playground (Electric Minds)
\n");
+ out.write("
Commons (Electric Minds)
\n");
+ out.write("
Top Ten Lists (Pamela's Lounge)
\n");
+ out.write("
\n");
+ /* END TEMP */
+
+ } // end renderHere
+
+ public void configure(UserContext uc, String parameter) throws DataException
+ { // TEMP - do nothing
+ super.configure(uc,parameter);
+ if (!(uc.isLoggedIn()))
+ setTitle("Featured Conferences:");
+
+ } // end configure
+
+ public Object clone()
+ {
+ return new TCPanelConferences(this);
+
+ } // end clone
+
+} // end class TCPanelSIGs
diff --git a/src/com/silverwrist/venice/servlets/format/TCPanelSIGs.java b/src/com/silverwrist/venice/servlets/format/TCPanelSIGs.java
new file mode 100644
index 0000000..d63cf14
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/TCPanelSIGs.java
@@ -0,0 +1,92 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import java.util.List;
+import java.util.Iterator;
+import com.silverwrist.venice.core.SIGContext;
+import com.silverwrist.venice.core.UserContext;
+import com.silverwrist.venice.core.DataException;
+
+public class TCPanelSIGs extends TCStandardPanel
+{
+ private List my_sigs = null;
+
+ public TCPanelSIGs()
+ {
+ super("Your SIGs:",null);
+ addButton("bn_manage.gif","Manage",null,true,80,24);
+ addButton("bn_create_new.gif","Create New","sigops?cmd=C",true,80,24);
+
+ } // end constructor
+
+ protected TCPanelSIGs(TCPanelSIGs other)
+ {
+ super(other);
+
+ } // end constructor
+
+ public void renderContent(Writer out, RenderData rdat) throws IOException
+ {
+ out.write(rdat.getStdFontTag(null,2) + "\n");
+ if (my_sigs.size()>0)
+ { // display the list of available SIGs
+ out.write("
\n");
+
+ Iterator it = my_sigs.iterator();
+ while (it.hasNext())
+ { // display the names of the SIGs one by one
+ SIGContext sig = (SIGContext)(it.next());
+ // TODO: make this fancier than just an unordered list
+ out.write("
\n");
+
+ } // end if
+ else
+ out.write("You are not a member of any SIGs.\n");
+
+ out.write("\n");
+
+ } // end renderContent
+
+ public void configure(UserContext uc, String parameter) throws DataException
+ {
+ super.configure(uc,parameter);
+ if (!(uc.isLoggedIn()))
+ setTitle("Featured SIGs:");
+ my_sigs = uc.getMemberSIGs();
+
+ } // end configure
+
+ public Object clone()
+ {
+ return new TCPanelSIGs(this);
+
+ } // end clone
+
+} // end class TCPanelSIGs
diff --git a/src/com/silverwrist/venice/servlets/format/TCStandardPanel.java b/src/com/silverwrist/venice/servlets/format/TCStandardPanel.java
new file mode 100644
index 0000000..728ea97
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/TCStandardPanel.java
@@ -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 .
+ *
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+import com.silverwrist.venice.core.UserContext;
+import com.silverwrist.venice.core.DataException;
+
+public abstract class TCStandardPanel extends TopContentPanel
+{
+ class TCButton implements ContentRender
+ {
+ private String image;
+ private String alt_text;
+ private String url;
+ private boolean login_only;
+ private int width;
+ private int height;
+
+ public TCButton(String image, String alt_text, String url, boolean login_only, int width, int height)
+ {
+ this.image = image;
+ this.alt_text = alt_text;
+ this.url = url;
+ this.login_only = login_only;
+ this.width = width;
+ this.height = height;
+
+ } // end constructor
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ if (url!=null)
+ out.write("");
+ out.write("");
+ if (url!=null)
+ out.write("");
+
+ } // end renderHere
+
+ public boolean isLoginOnly()
+ {
+ return login_only;
+
+ } // end isLoginOnly
+
+ } // end class TCButton
+
+ // Attributes
+ private String title;
+ private String subtitle;
+ private Vector buttons;
+
+ private String real_title;
+ private String real_subtitle;
+ private boolean logged_in;
+
+ protected TCStandardPanel(String title, String subtitle)
+ {
+ this.title = title;
+ this.subtitle = subtitle;
+ this.buttons = new Vector();
+ this.real_title = title;
+ this.real_subtitle = subtitle;
+
+ } // end constructor
+
+ protected TCStandardPanel(TCStandardPanel other)
+ {
+ super(other);
+ this.title = other.title;
+ this.subtitle = other.subtitle;
+ this.buttons = other.buttons;
+ this.real_title = other.title;
+ this.real_subtitle = other.subtitle;
+
+ } // end constructor
+
+ private boolean displayButtons()
+ {
+ if (buttons.size()==0)
+ return false;
+ else if (logged_in)
+ return true;
+
+ boolean login_only = true;
+ Enumeration enum = buttons.elements();
+ while (login_only && enum.hasMoreElements())
+ { // attempt to determine if there are any non-"login only" buttons
+ TCButton bn = (TCButton)(enum.nextElement());
+ login_only = bn.isLoginOnly();
+
+ } // end while
+
+ return !login_only;
+
+ } // end displayButtons
+
+ protected void addButton(String image, String alt_text, String url, boolean login_only, int width,
+ int height)
+ {
+ buttons.addElement(new TCButton(image,alt_text,url,login_only,width,height));
+
+ } // end addButton
+
+ protected abstract void renderContent(Writer out, RenderData rdat) throws IOException;
+
+ public void renderHere(Writer out, RenderData rdat) throws IOException
+ {
+ rdat.writeContentHeader(out,real_title,real_subtitle);
+
+ if (displayButtons())
+ { // want to print the buttons
+ out.write("
\n");
+ Enumeration enum = buttons.elements();
+
+ boolean first_post = true;
+ while (enum.hasMoreElements())
+ { // figure out whether to display this button
+ TCButton bn = (TCButton)(enum.nextElement());
+ boolean display_me = logged_in;
+ if (logged_in)
+ display_me = true;
+ else
+ display_me = !(bn.isLoginOnly());
+
+ if (display_me)
+ { // display this button
+ if (first_post)
+ first_post = false;
+ else
+ out.write(" ");
+ bn.renderHere(out,rdat);
+
+ } // end if
+
+ } // end while
+
+ out.write("\n
\n");
+
+ } // end if
+
+ renderContent(out,rdat);
+
+ } // end renderHere
+
+ public void configure(UserContext uc, String parameter) throws DataException
+ {
+ logged_in = uc.isLoggedIn();
+
+ } // end configure
+
+ public void setTitle(String title)
+ {
+ this.real_title = title;
+
+ } // end setTitle
+
+ public void setSubtitle(String title)
+ {
+ this.real_subtitle = subtitle;
+
+ } // end setTitle
+
+} // end class TCPanelSIGs
diff --git a/src/com/silverwrist/venice/servlets/format/TopContent.java b/src/com/silverwrist/venice/servlets/format/TopContent.java
new file mode 100644
index 0000000..295c078
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/TopContent.java
@@ -0,0 +1,113 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import java.util.*;
+import com.silverwrist.venice.core.*;
+
+public class TopContent implements ContentRender
+{
+ // Static constants
+ public static final int MAX_COLS = 2;
+
+ // Attributes
+ private int actual_cols = MAX_COLS;
+ private int[] col_sizes;
+ private Vector panels = new Vector();
+ private boolean display_configure;
+
+ public TopContent(UserContext uc) throws DataException
+ {
+ int i; // loop counter
+
+ // get the current view configuration
+ FrontPageViewConfig vconfig = uc.getFrontPageViewConfig(MAX_COLS);
+ if (vconfig.getNumColumns()\n");
+
+ Enumeration enum = panels.elements();
+ while (enum.hasMoreElements())
+ { // output each row in turn
+ TopContentPanel[] rowarray = (TopContentPanel[])(enum.nextElement());
+ out.write("
\n");
+
+ for (int i=0; i\n");
+ rowarray[i].renderHere(out,rdat);
+ out.write("\n");
+
+ } // end for
+
+ out.write("
\n");
+
+ } // end while
+
+ out.write("\n");
+
+ if (display_configure)
+ { // display the Configure button
+ out.write("
\n\n
\n");
+
+ } // end if
+
+ rdat.writeFooter(out);
+
+ } /* end renderHere */
+
+} // end class TopContent
diff --git a/src/com/silverwrist/venice/servlets/format/TopContentPanel.java b/src/com/silverwrist/venice/servlets/format/TopContentPanel.java
new file mode 100644
index 0000000..887adf9
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/TopContentPanel.java
@@ -0,0 +1,50 @@
+/*
+ * 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 Community 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.io.Writer;
+import java.io.IOException;
+import com.silverwrist.venice.core.UserContext;
+import com.silverwrist.venice.core.DataException;
+
+public abstract class TopContentPanel implements ContentRender, Cloneable
+{
+ protected TopContentPanel()
+ { // do nothing
+ } // end constructor
+
+ protected TopContentPanel(TopContentPanel other)
+ { // do nothing
+ } // end constructor
+
+ public abstract void renderHere(Writer out, RenderData rdat) throws IOException;
+
+ public abstract void configure(UserContext uc, String parameter) throws DataException;
+
+ public static TopContentPanel create(String partid)
+ {
+ if (partid.equals("SIGS"))
+ return new TCPanelSIGs();
+ if (partid.equals("CONF"))
+ return new TCPanelConferences();
+ return null;
+
+ } // end create
+
+} // end class TopContentPanel
+
diff --git a/src/com/silverwrist/venice/servlets/format/UserProfileData.java b/src/com/silverwrist/venice/servlets/format/UserProfileData.java
new file mode 100644
index 0000000..e5f16a1
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/UserProfileData.java
@@ -0,0 +1,138 @@
+/*
+ * 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 Community 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 javax.servlet.ServletRequest;
+import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.core.UserProfile;
+
+public class UserProfileData implements JSPRender
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ // Attribute name for request attribute
+ protected static final String ATTR_NAME = "com.silverwrist.venice.content.UserProfileData";
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private UserProfile prof;
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ public UserProfileData(UserProfile prof)
+ {
+ this.prof = prof;
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * External static functions
+ *--------------------------------------------------------------------------------
+ */
+
+ public static UserProfileData retrieve(ServletRequest request)
+ {
+ return (UserProfileData)(request.getAttribute(ATTR_NAME));
+
+ } // end retrieve
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface JSPRender
+ *--------------------------------------------------------------------------------
+ */
+
+ public void store(ServletRequest request)
+ {
+ request.setAttribute(ATTR_NAME,this);
+
+ } // end store
+
+ public String getTargetJSPName()
+ {
+ return "userprofile.jsp";
+
+ } // end getTargetJSPName
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ public UserProfile getUserProfile()
+ {
+ return prof;
+
+ } // end getUserProfile
+
+ public String getAddressLastLine()
+ {
+ String tmp_c = prof.getLocality();
+ String tmp_s = prof.getRegion();
+ StringBuffer buf = new StringBuffer();
+ if (!(StringUtil.isStringEmpty(tmp_c)) && !(StringUtil.isStringEmpty(tmp_s)))
+ buf.append(tmp_c).append(", ").append(tmp_s);
+ else if (!(StringUtil.isStringEmpty(tmp_c)))
+ buf.append(tmp_c);
+ else if (!(StringUtil.isStringEmpty(tmp_s)))
+ buf.append(tmp_s);
+ tmp_s = prof.getPostalCode();
+ if (!(StringUtil.isStringEmpty(tmp_s)))
+ buf.append(' ').append(tmp_s);
+ return buf.toString();
+
+ } // end getAddressLastLine
+
+ public String getFullName()
+ {
+ StringBuffer buf = new StringBuffer(prof.getGivenName());
+ String tmp = prof.getNamePrefix();
+ if (!(StringUtil.isStringEmpty(tmp)))
+ { // insert prefix at beginning
+ buf.insert(0,' ');
+ buf.insert(0,tmp);
+
+ } // end if
+ if (prof.getMiddleInitial()!=' ')
+ buf.append(' ').append(prof.getMiddleInitial()).append('.');
+ buf.append(' ').append(prof.getFamilyName());
+ tmp = prof.getNameSuffix();
+ if (!(StringUtil.isStringEmpty(tmp)))
+ buf.append(' ').append(tmp);
+ return buf.toString();
+
+ } // end getFullName
+
+ public String getPhotoURL(RenderData rdat)
+ {
+ String tmp = prof.getPhotoURL();
+ if (StringUtil.isStringEmpty(tmp))
+ tmp = rdat.getFullImagePath("photo_not_avail.gif");
+ return tmp;
+
+ } // end getPhotoURL
+
+} // end class UserProfileData
diff --git a/src/com/silverwrist/venice/servlets/format/VerifyEmailDialog.java b/src/com/silverwrist/venice/servlets/format/VerifyEmailDialog.java
new file mode 100644
index 0000000..2a99ae8
--- /dev/null
+++ b/src/com/silverwrist/venice/servlets/format/VerifyEmailDialog.java
@@ -0,0 +1,98 @@
+/*
+ * 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 Community 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 com.silverwrist.venice.ValidationException;
+import com.silverwrist.venice.core.IDUtils;
+
+public class VerifyEmailDialog extends ContentDialog
+{
+ int confirm_num = 0;
+
+ public VerifyEmailDialog()
+ {
+ super("Verify E-mail Address",null,"verifyform","account");
+ setInstructions("Check your e-mail, then enter the confirmation number that was e-mailed to you "
+ + "in the field below. Once you do so, your account will be fully validated. "
+ + "If you have not received your confirmation, click on the 'Send Again' button "
+ + "below.");
+ setHiddenField("cmd","V");
+ setHiddenField("tgt","");
+ addFormField(new CDTextFormField("num","Confirmation number",null,false,7,7));
+ addCommandButton(new CDImageButton("ok","bn_ok.gif","OK",80,24));
+ addCommandButton(new CDImageButton("again","bn_send_again.gif","Send Again",80,24));
+ addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
+
+ } // end constructor
+
+ protected VerifyEmailDialog(VerifyEmailDialog other)
+ {
+ super(other);
+
+ } // end constructor
+
+ protected void validateWholeForm() throws ValidationException
+ {
+ try
+ { // convert to a number and check its range
+ int num = Integer.parseInt(getFieldValue("num"));
+
+ if (!IDUtils.isValidConfirmationNumber(num))
+ throw new ValidationException("The value you have entered is not a valid confirmation number.");
+
+ confirm_num = num; // save off for later
+
+ } // end try
+ catch (NumberFormatException e)
+ { // conversion error!
+ throw new ValidationException("The value you have entered is not a valid number.");
+
+ } // end catch
+
+ } // end validateWholeForm
+
+ public void setTarget(String target)
+ {
+ setHiddenField("tgt",target);
+
+ } // end setTarget
+
+ public int getConfirmationNumber()
+ {
+ return confirm_num;
+
+ } // end getConfirmationNumber
+
+ public void resetOnError(String message)
+ {
+ setErrorMessage(message);
+ setFieldValue("num",null);
+
+ } // end resetOnError
+
+ public Object clone()
+ {
+ return new VerifyEmailDialog(this);
+
+ } // end clone
+
+} // end class VerifyEmailDialog
+
+
+
+
diff --git a/web/format/base.jsp b/web/format/base.jsp
new file mode 100644
index 0000000..9a93ef4
--- /dev/null
+++ b/web/format/base.jsp
@@ -0,0 +1,130 @@
+<%--
+ 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 Community 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.net.URLEncoder" %>
+<%@ 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.*" %>
+<%!
+
+private static void renderMenu(HttpSession session, java.io.Writer out, RenderData rdat) throws java.io.IOException
+{
+ ContentRender menu = Variables.getMenu(session);
+ if (menu==null)
+ menu = new MenuTop();
+ menu.renderHere(out,rdat);
+
+} // end renderMenu
+
+%>
+<%
+ UserContext user = Variables.getUserContext(application,request,session);
+ RenderData rdat = RenderConfig.createRenderData(application,request,response);
+ BaseJSPData basedat = BaseJSPData.retrieve(request);
+%>
+
+
+
+ <%= rdat.getTitleTag(basedat.getTitle()) %>
+
+
+
+
+
+
diff --git a/web/format/conferences.jsp b/web/format/conferences.jsp
new file mode 100644
index 0000000..ddd3024
--- /dev/null
+++ b/web/format/conferences.jsp
@@ -0,0 +1,67 @@
+<%--
+ 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 Community 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.*" %>
+<%
+ ConferenceListing data = ConferenceListing.retrieve(request);
+ Variables.failIfNull(data);
+ RenderData rdat = RenderConfig.createRenderData(application,request,response);
+%>
+<% if (rdat.useHTMLComments()) { %><% } %>
+<% rdat.writeContentHeader(out,"Conference List:",data.getSIGName()); %>
+<%-- TODO: controls go here for creating new conferences and such --%>
+<% if (data.getNumConferences()>0) { %>
+
+ <% for (int i=0; i
+
+
+ " ALT="*" WIDTH=14 HEIGHT=14 BORDER=0>
+
+
<%= rdat.getStdFontTag(null,2) %>
+ <% String path = "TODO?sig=" + String.valueOf(data.getSIGID()) + "&conf="
+ + String.valueOf(data.getConferenceID(i)); %>
+ <%= StringUtil.encodeHTML(data.getConferenceName(i)) %> -
+ Latest activity: <%= rdat.getActivityString(data.getLastUpdateDate(i)) %>
+ <% int count = data.getNumHosts(i); %>
+ <% if (count>0) { %>
+ <% if (count>1) { %>Hosts<% } else { %>Host<% } %>:
+ <% for (int j=0; j
+ "><%= data.getHostName(i,j) %><% if (j<(count-1)) { %>,<% } %>
+ <% } // end for (each hostname) %>
+ <% } else { %>
+ Hosts: (none)
+ <% } // end if (hosts present in the conference) %>
+ <%= StringUtil.encodeHTML(data.getDescription(i)) %>
+
+
+ <% } // end for (each conference) %>
+
+<% } else { %>
+ No conferences found in this SIG.
+<% } // end if (conferences present) %>
+<% if (data.canCreateConference()) { %>
+
+<% } // end if %>
+<% rdat.writeFooter(out); %>
diff --git a/web/format/find.jsp b/web/format/find.jsp
new file mode 100644
index 0000000..1fb9315
--- /dev/null
+++ b/web/format/find.jsp
@@ -0,0 +1,290 @@
+<%--
+ 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 Community 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.*" %>
+<%!
+private static String getSIGHostName(SIGContext sig)
+{
+ try
+ { // get the host name for the specified SIG
+ UserProfile prof = sig.getHostProfile();
+ return prof.getUserName();
+
+ } // end try
+ catch (DataException e)
+ { // just return NULL if an exception strikes
+ return null;
+
+ } // end catch
+
+} // end getSIGHostName
+
+private static int getSIGMemberCount(SIGContext sig)
+{
+ try
+ { // get the member count for the specified SIG
+ return sig.getMemberCount();
+
+ } // end try
+ catch (DataException e)
+ { // just return -1 if an exception strikes
+ return -1;
+
+ } // end catch
+
+} // end getSIGMemberCount
+
+private static String getActivityString(SIGContext sig, RenderData rdat)
+{
+ return rdat.getActivityString(sig.getLastAccessDate());
+
+} // end getActivityString
+
+%>
+<%
+ FindData data = FindData.retrieve(request);
+ Variables.failIfNull(data);
+ RenderData rdat = RenderConfig.createRenderData(application,request,response);
+%>
+<% data.writeHeader(rdat,out); %>
+
+<%-- Display the search form --%>
+<% if (rdat.useHTMLComments()) { %><% } %>
+
+
+<%-- Display the current category --%>
+<% String a_head, a_tail; // used for formatting category display %>
+<% CategoryDescriptor cat = data.getCategory(); %>
+<% if (cat!=null) { %>
+ <% if (rdat.useHTMLComments()) { %><% } %>
+ <%= rdat.getStdFontTag(null,3) %>Category:
+ <%
+ a_head = "";
+ a_tail = "";
+ if (cat.getCategoryID()>=0)
+ { // assign the anchor tags
+ a_head = "";
+ a_tail = "";
+
+ } // end if
+ %>
+ <%= a_head %>Top<%= a_tail %>
+ <% if (cat.getCategoryID()>=0) { %>
+ <% for (int i=0; i
+ <%
+ a_head = ": ";
+ a_tail = "";
+ if (i<(cat.getNumLevels()-1))
+ { // assign the anchor tags
+ a_head = ": ";
+ a_tail = "";
+
+ } // end if
+ %>
+ <%= a_head %><%= StringUtil.encodeHTML(cat.getTitleAtLevel(i)) %><%= a_tail %>
+ <% } // end for %>
+ <% } // end if (displaying the entire subcategory tree) %>
+
+
+ <%-- Display the subcategory list --%>
+ <% List subcats = data.getSubCategoryList(); %>
+ <% if ((subcats!=null) && (subcats.size()>0)) { %>
+ <% if (rdat.useHTMLComments()) { %><% } %>
+ Subcategories:
+
+ <% Iterator it = subcats.iterator(); %>
+ <% while (it.hasNext()) { %>
+
+ <% } // end if (displaying subcategory list) %>
+
+<% } // end if (category specified) %>
+
+<% List results = data.getResultsList(); %>
+<% if (results!=null) { %>
+ <% if (rdat.useHTMLComments()) { %><% } %>
+ <%
+ // Determine the number of results to display and whether to display a "next" button
+ int dcount = results.size();
+ boolean go_next = false;
+ if (dcount>data.getNumResultsDisplayed())
+ { // there's a "next"
+ dcount = data.getNumResultsDisplayed();
+ go_next = true;
+
+ } // end if
+ %>
+
+
+ <% if (go_next || (data.getOffset()>0)) { %>
+ <%-- The navigational form that allows us to page through the results --%>
+ <% if (rdat.useHTMLComments()) { %><% } %>
+
+ <% } else { %> <% } %>
+
+
+
+ <%-- Display the results of the search --%>
+
+ <% for (int i=0; i
+
+
+ " ALT="*" WIDTH=14 HEIGHT=14 BORDER=0>
+
+
<%= rdat.getStdFontTag(null,2) %>
+ <% Object item = results.get(i); %>
+ <% if (data.getDisplayOption()==FindData.FD_SIGS) { %>
+ <%
+ SIGContext sig = (SIGContext)item;
+ String host_name = getSIGHostName(sig);
+ int members = getSIGMemberCount(sig);
+ %>
+ "><%= StringUtil.encodeHTML(sig.getName()) %>
+ <% if (host_name!=null) { %>
+ Host: "><%= host_name %>
+ <% } // end if (got host name) %>
+ <% if (members>=0) { %>
+ <% if (host_name!=null) { %> - <% } %>
+ <%= members %> members
+ <% } // end if (got member count) %>
+ <% if ((host_name!=null) || (members>=0)) { %> <% } %>
+ Latest activity: <%= getActivityString(sig,rdat) %>
+ <%= StringUtil.encodeHTML(sig.getSynopsis()) %>
+
+ <% } else if (data.getDisplayOption()==FindData.FD_USERS) { %>
+ <% UserFound uf = (UserFound)item; %>
+ "><%= uf.getName() %>
+ <%= StringUtil.encodeHTML(uf.getGivenName()) %> <%= StringUtil.encodeHTML(uf.getFamilyName()) %>,
+ from <%= StringUtil.encodeHTML(uf.getLocality()) %>, <%= StringUtil.encodeHTML(uf.getRegion()) %>
+ <%= uf.getCountry() %>
+ <% if (uf.getDescription()!=null) { %> <%= StringUtil.encodeHTML(uf.getDescription()) %><% } %>
+
+ <% } else if (data.getDisplayOption()==FindData.FD_CATEGORIES) { %>
+ <% CategoryDescriptor cd = (CategoryDescriptor)item; %>
+ <%= StringUtil.encodeHTML(cd.toString()) %>
+
+ <% } %>
+
+
+ <% } // end for %>
+
+
+<% } // end if (results found) %>
+<% rdat.writeFooter(out); %>
diff --git a/web/format/newsigwelcome.jsp b/web/format/newsigwelcome.jsp
new file mode 100644
index 0000000..8d6ce15
--- /dev/null
+++ b/web/format/newsigwelcome.jsp
@@ -0,0 +1,44 @@
+<%--
+ 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 Community 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.*" %>
+<%
+ NewSIGWelcome data = NewSIGWelcome.retrieve(request);
+ Variables.failIfNull(data);
+ RenderData rdat = RenderConfig.createRenderData(application,request,response);
+%>
+<% if (rdat.useHTMLComments()) { %><% } %>
+<% rdat.writeContentHeader(out,"Welcome!",null); %>
+<%= rdat.getStdFontTag(null,2) %>
+ Your new SIG "<%= StringUtil.encodeHTML(data.getSIGName()) %>" has been created, and
+ you are its host. You may now wish to send out invitations to other people to join your new SIG.
+ You will also want to enter your SIG's administration page and set its category and/or additional
+ security options, if desired.
+
+<% rdat.writeFooter(out); %>
+
diff --git a/web/format/sigcatbrowser.jsp b/web/format/sigcatbrowser.jsp
new file mode 100644
index 0000000..cbc8c48
--- /dev/null
+++ b/web/format/sigcatbrowser.jsp
@@ -0,0 +1,72 @@
+<%--
+ 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 Community 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.*" %>
+<%
+ SIGCategoryBrowseData data = SIGCategoryBrowseData.retrieve(request);
+ Variables.failIfNull(data);
+ RenderData rdat = RenderConfig.createRenderData(application,request,response);
+ CategoryDescriptor cat = data.getCurrentCategory();
+ int catid = cat.getCategoryID();
+%>
+<% rdat.writeContentHeader(out,"Set SIG Category:",data.getSIGName()); %>
+
+ <% } else { %>(None)<% } // end if (subcategory display) %>
+
+ Click on a subcategory name to make that category the currently displayed one.
+ Click on a [set] link to set that category as the SIG's new category and return to the
+ SIG Administration menu.
+
+
+<% rdat.writeFooter(out); %>
diff --git a/web/format/sigprofile.jsp b/web/format/sigprofile.jsp
new file mode 100644
index 0000000..24a8c38
--- /dev/null
+++ b/web/format/sigprofile.jsp
@@ -0,0 +1,99 @@
+<%--
+ 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 Community 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.*" %>
+<%
+ SIGProfileData data = SIGProfileData.retrieve(request);
+ Variables.failIfNull(data);
+ RenderData rdat = RenderConfig.createRenderData(application,request,response);
+ SIGContext sig = data.getSIGContext();
+ ContactInfo ci = data.getSIGContactInfo();
+ CategoryDescriptor cat = data.getCategory();
+ String tmp;
+%>
+<% if (rdat.useHTMLComments()) { %><% } %>
+<% rdat.writeContentHeader(out,"SIG Profile:",sig.getName()); %>
+
+
<%= rdat.getStdFontTag(null,1) %>
+
+
+ <% Date tmpd = sig.getCreationDate(); %>
+ <% if (tmpd!=null) { %>
+ SIG created: <%= StringUtil.encodeHTML(rdat.formatDateForDisplay(tmpd)) %>
+ <% } // end if %>
+ <% tmpd = sig.getLastAccessDate(); %>
+ <% if (tmpd!=null) { %>
+ Last accessed: <%= StringUtil.encodeHTML(rdat.formatDateForDisplay(tmpd)) %>
+ <% } // end if %>
+ <% tmpd = sig.getLastUpdateDate(); %>
+ <% if (tmpd!=null) { %>
+ Profile last updated: <%= StringUtil.encodeHTML(rdat.formatDateForDisplay(tmpd)) %>
+ <% } // end if %>
+
+ <% if (data.isUserLoggedIn()) { %>
+
+<% rdat.writeFooter(out); %>
diff --git a/web/format/sigwelcome.jsp b/web/format/sigwelcome.jsp
new file mode 100644
index 0000000..fe8fd29
--- /dev/null
+++ b/web/format/sigwelcome.jsp
@@ -0,0 +1,36 @@
+<%--
+ 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 Community 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.*" %>
+<%
+ SIGWelcome data = SIGWelcome.retrieve(request);
+ Variables.failIfNull(data);
+ RenderData rdat = RenderConfig.createRenderData(application,request,response);
+%>
+<% if (rdat.useHTMLComments()) { %><% } %>
+<% rdat.writeContentHeader(out,"Welcome!",null); %>
+<%= rdat.getStdFontTag(null,2) %>
+ Welcome to the "<%= StringUtil.encodeHTML(data.getSIGName()) %>" SIG!
+ As a SIG member, you now have access to the various resources which your SIG's host
+ has elected to provide. Enjoy your membership!
+
+<% rdat.writeFooter(out); %>
diff --git a/web/format/userprofile.jsp b/web/format/userprofile.jsp
new file mode 100644
index 0000000..49aa240
--- /dev/null
+++ b/web/format/userprofile.jsp
@@ -0,0 +1,92 @@
+<%--
+ 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 Community 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.*" %>
+<%
+ UserProfileData data = UserProfileData.retrieve(request);
+ Variables.failIfNull(data);
+ UserProfile prof = data.getUserProfile();
+ RenderData rdat = RenderConfig.createRenderData(application,request,response);
+ String tmp;
+%>
+<% if (rdat.useHTMLComments()) { %><% } %>
+<% rdat.writeContentHeader(out,"User Profile:",prof.getUserName()); %>
+
+
+
<%= rdat.getStdFontTag(null,1) %>
+
+
+ <% Date tmpd = prof.getCreateDate(); %>
+ <% if (tmpd!=null) { %>
+ Account created: <%= StringUtil.encodeHTML(rdat.formatDateForDisplay(tmpd)) %>
+ <% } // end if %>
+ <% tmpd = prof.getLastLoginDate(); %>
+ <% if (tmpd!=null) { %>
+ Last login: <%= StringUtil.encodeHTML(rdat.formatDateForDisplay(tmpd)) %>
+ <% } // end if %>
+ <% tmpd = prof.getLastUpdate(); %>
+ <% if (tmpd!=null) { %>
+ Profile last updated: <%= StringUtil.encodeHTML(rdat.formatDateForDisplay(tmpd)) %>
+ <% } // end if %>
+