From a96eee50560bfa87250a5d134d4a4161a67b3ca3 Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Mon, 9 Jun 2003 18:39:59 +0000 Subject: [PATCH] began database table definition and interface definition for the Universal Message Store (UniStore) --- conf/venice-db-init-mysql.sql | 75 ++++++++++++++++++- .../com/silverwrist/util/MySQLUtils.java | 34 ++++++++- .../dynamo/iface/UniStoreBinaryPart.java | 24 ++++++ .../dynamo/iface/UniStoreMessage.java | 64 ++++++++++++++++ .../dynamo/iface/UniStorePart.java | 42 +++++++++++ .../dynamo/iface/UniStoreTextPart.java | 30 ++++++++ 6 files changed, 267 insertions(+), 2 deletions(-) create mode 100644 src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreBinaryPart.java create mode 100644 src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreMessage.java create mode 100644 src/dynamo-framework/com/silverwrist/dynamo/iface/UniStorePart.java create mode 100644 src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreTextPart.java diff --git a/conf/venice-db-init-mysql.sql b/conf/venice-db-init-mysql.sql index 8f03ae5..a404317 100644 --- a/conf/venice-db-init-mysql.sql +++ b/conf/venice-db-init-mysql.sql @@ -240,7 +240,80 @@ CREATE TABLE dictionary ( word VARCHAR(128) NOT NULL PRIMARY KEY # the word ); -#### following this line are Venice-specific tables #### +# UniStore: Message headers +CREATE TABLE us_head ( + msgid BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, # the message ID + parent BIGINT NOT NULL DEFAULT 0, # parent message (optional) + seq INT NOT NULL DEFAULT 0, # message sequence under parent (optional) + creator INT NOT NULL, # UID of person who created the message + posted DATETIME NOT NULL, # date/time message was posted + aclid INT NULL, # optional ACL ID for message + INDEX by_date (posted), + INDEX by_child (parent, seq) +); + +# UniStore: Message properties +CREATE TABLE us_prop ( + msgid BIGINT NOT NULL, # message ID + nsid INT NOT NULL, # property namespace ID + prop_name VARCHAR(255) BINARY NOT NULL, # property name + prop_value VARCHAR(255), # property value + PRIMARY KEY (msgid, nsid, prop_name) +); + +# UniStore: Text message parts +CREATE TABLE us_text ( + msgid BIGINT NOT NULL, # message ID + part INT NOT NULL, # index of text part + ident_nsid INT NOT NULL, # identity namespace ID + ident_name VARCHAR(255) BINARY NOT NULL, # identity name + mimetype VARCHAR(128), # MIME type of text + charcount INT, # number of characters in text + linecount INT, # number of lines in text + reads INT NOT NULL DEFAULT 0, # number of times this part has been read + last_read DATETIME, # timestamp of when it was last read + data MEDIUMTEXT, # the text (16 Mb available) + PRIMARY KEY (msgid, part), + INDEX by_name (msgid, ident_nsid, ident_name) +); + +# UniStore: Text message part properties +CREATE TABLE us_text_prop ( + msgid BIGINT NOT NULL, # message ID + part INT NOT NULL, # index of text part + nsid INT NOT NULL, # property namespace ID + prop_name VARCHAR(255) BINARY NOT NULL, # property name + prop_value VARCHAR(255), # property value + PRIMARY KEY (msgid, part, nsid, prop_name) +); + +# UniStore: Binary message parts +CREATE TABLE us_binary ( + msgid BIGINT NOT NULL, # message ID + part INT NOT NULL, # index of binary part + ident_nsid INT NOT NULL, # identity namespace ID + ident_name VARCHAR(255) BINARY NOT NULL, # identity name + mimetype VARCHAR(128), # MIME type of data + datalen INT, # data length in bytes + filename VARCHAR(255), # original source filename + reads INT NOT NULL DEFAULT 0, # number of times this part has been read + last_read DATETIME, # timestamp of when it was last read + data MEDIUMBLOB, # the actual data (16 Mb of space available) + PRIMARY KEY (msgid, part), + INDEX by_name (msgid, ident_nsid, ident_name) +); + +# UniStore: Binary message part properties +CREATE TABLE us_binary_prop ( + msgid BIGINT NOT NULL, # message ID + part INT NOT NULL, # index of binary part + nsid INT NOT NULL, # property namespace ID + prop_name VARCHAR(255) BINARY NOT NULL, # property name + prop_value VARCHAR(255), # property value + PRIMARY KEY (msgid, part, nsid, prop_name) +); + +############################ following this line are Venice-specific tables ############################ # The table which defines menus. CREATE TABLE menus ( diff --git a/src/baseutil/com/silverwrist/util/MySQLUtils.java b/src/baseutil/com/silverwrist/util/MySQLUtils.java index 3838530..2cb9cbe 100644 --- a/src/baseutil/com/silverwrist/util/MySQLUtils.java +++ b/src/baseutil/com/silverwrist/util/MySQLUtils.java @@ -87,7 +87,7 @@ public class MySQLUtils extends SQLUtils /** * Gets the ID of the most recent insert made to a table with an AUTO_INCREMENT column. This assumes that the - * column is of integer type. Executes the MySQL statement "SELECT LAST_INSERT_ID();" and returns the value + * column is of integer (INT) type. Executes the MySQL statement "SELECT LAST_INSERT_ID();" and returns the value * that that statement returns. * * @param conn Database connection on which to perform the operation. @@ -117,4 +117,36 @@ public class MySQLUtils extends SQLUtils } // end getLastInsertInt + /** + * Gets the ID of the most recent insert made to a table with an AUTO_INCREMENT column. This assumes that the + * column is of long (BIGINT) type. Executes the MySQL statement "SELECT LAST_INSERT_ID();" and returns the value + * that that statement returns. + * + * @param conn Database connection on which to perform the operation. + * @return The value of the last inserted ID on this connection. + * @exception java.sql.SQLException If an error occurred in the execution, or if the SELECT statement returned + * no rows (which it should not do). + */ + public static final long getLastInsertLong(Connection conn) throws SQLException + { + Statement stmt = null; + ResultSet rs = null; + try + { // perform the operation + stmt = conn.createStatement(); + rs = stmt.executeQuery("SELECT LAST_INSERT_ID();"); + if (!(rs.next())) + throw new SQLException("internal error - getLastInsertLong SELECT should have returned OK"); + return rs.getLong(1); + + } // end try + finally + { // shut down the objects before we go + shutdown(rs); + shutdown(stmt); + + } // end finally + + } // end getLastInsertInt + } // end class MySQLUtils diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreBinaryPart.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreBinaryPart.java new file mode 100644 index 0000000..3a8bc53 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreBinaryPart.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 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +public interface UniStoreBinaryPart extends UniStorePart, DataItem +{ + // no additional methods + +} // end interface UniStoreBinaryPart diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreMessage.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreMessage.java new file mode 100644 index 0000000..549d73c --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreMessage.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 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +import java.security.acl.AclNotFoundException; +import java.util.Date; +import java.util.List; +import com.silverwrist.dynamo.except.DatabaseException; +import com.silverwrist.dynamo.except.DynamoSecurityException; + +public interface UniStoreMessage extends SecureObjectStore +{ + public long getMessageID(); + + public long getParentMessageID(); + + public void setParentMessageID(DynamoUser caller, long id) throws DatabaseException, DynamoSecurityException; + + public int getSequence(); + + public void setSequence(DynamoUser caller, int seq) throws DatabaseException, DynamoSecurityException; + + public int getCreatorUID(); + + public DynamoUser getCreator() throws DatabaseException; + + public java.util.Date getPostDate(); + + public DynamoAcl getAcl() throws DatabaseException, AclNotFoundException; + + public void setAcl(DynamoUser caller, DynamoAcl acl) throws DatabaseException, DynamoSecurityException; + + public int getNumTextParts() throws DatabaseException; + + public int getNumBinaryParts() throws DatabaseException; + + public UniStoreTextPart getTextPart(int index) throws DatabaseException; + + public UniStoreTextPart getTextPart(String namespace, String name) throws DatabaseException; + + public UniStoreBinaryPart getBinaryPart(int index) throws DatabaseException; + + public UniStoreBinaryPart getBinaryPart(String namespace, String name) throws DatabaseException; + + public List getTextParts() throws DatabaseException; + + public List getBinaryParts() throws DatabaseException; + +} // end interface UniStoreMessage diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStorePart.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStorePart.java new file mode 100644 index 0000000..185a65c --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStorePart.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 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +import java.util.Date; +import com.silverwrist.dynamo.except.DatabaseException; +import com.silverwrist.dynamo.util.QualifiedNameKey; + +public interface UniStorePart extends SecureObjectStore +{ + public long getMessageID(); + + public int getPartIndex(); + + public QualifiedNameKey getPartIdentity(); + + public String getMimeType(); + + public int getSize(); + + public int getNumReads(); + + public java.util.Date getLastReadDate(); + + public void touchRead() throws DatabaseException; + +} // end interface UniStorePart diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreTextPart.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreTextPart.java new file mode 100644 index 0000000..4126da5 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/UniStoreTextPart.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 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +import java.io.Reader; + +public interface UniStoreTextPart extends UniStorePart +{ + public int getLineCount(); + + public String getText(); + + public Reader getTextAsReader(); + +} // end interface UniStoreTextPart