Commit 0453069d authored by Matt Tucker's avatar Matt Tucker Committed by matt

Pubsub fixes, improved compatability of pubsub database tables: JM-639, JM-640, JM-641.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3763 b35dd754-fafc-0310-a699-88a17e54d16e
parent 051f80f3
-- $Revision: $
-- $Date: $
-- Drop old columns of pubSubNode
ALTER TABLE pubsubNode DROP COLUMN contacts;
ALTER TABLE pubsubNode DROP COLUMN rosterGroups;
ALTER TABLE pubsubNode DROP COLUMN replyRooms;
ALTER TABLE pubsubNode DROP COLUMN replyTo;
ALTER TABLE pubsubNode DROP COLUMN associationTrusted;
-- Add new pubsub tables
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
jid VARCHAR(1024) NOT NULL,
associationType VARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
rosterGroup VARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
UPDATE jiveVersion set version=8 where name = 'wildfire';
// $Revision: $
// $Date: $
// Drop old columns of pubSubNode
ALTER TABLE pubsubNode DROP COLUMN contacts;
ALTER TABLE pubsubNode DROP COLUMN rosterGroups;
ALTER TABLE pubsubNode DROP COLUMN replyRooms;
ALTER TABLE pubsubNode DROP COLUMN replyTo;
ALTER TABLE pubsubNode DROP COLUMN associationTrusted;
// Add new pubsub tables
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
jid VARCHAR(1024) NOT NULL,
associationType VARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
rosterGroup VARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
UPDATE jiveVersion set version=8 where name = 'wildfire';
# $Revision: $
# $Date: $
# Drop old columns of pubSubNode
ALTER TABLE pubsubNode DROP COLUMN contacts;
ALTER TABLE pubsubNode DROP COLUMN rosterGroups;
ALTER TABLE pubsubNode DROP COLUMN replyRooms;
ALTER TABLE pubsubNode DROP COLUMN replyTo;
ALTER TABLE pubsubNode DROP COLUMN associationTrusted;
# Add new pubsub tables
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
jid VARCHAR(255) NOT NULL,
associationType VARCHAR(20) NOT NULL,
PRIMARY KEY (serviceID, nodeID, jid(70))
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
rosterGroup VARCHAR(100) NOT NULL,
INDEX pubsubNodeGroups_idx (serviceID, nodeID)
);
UPDATE jiveVersion set version=8 where name = 'wildfire';
REM // $Revision: $
REM // $Date: $
REM // Drop old columns of pubSubNode
ALTER TABLE pubsubNode DROP COLUMN contacts;
ALTER TABLE pubsubNode DROP COLUMN rosterGroups;
ALTER TABLE pubsubNode DROP COLUMN replyRooms;
ALTER TABLE pubsubNode DROP COLUMN replyTo;
ALTER TABLE pubsubNode DROP COLUMN associationTrusted;
REM // Add new pubsub tables
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR2(100) NOT NULL,
nodeID VARCHAR2(100) NOT NULL,
jid VARCHAR2(1024) NOT NULL,
associationType VARCHAR2(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR2(100) NOT NULL,
nodeID VARCHAR2(100) NOT NULL,
rosterGroup VARCHAR2(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
UPDATE jiveVersion set version=8 where name = 'wildfire';
-- $Revision: $
-- $Date: $
-- Drop old columns of pubSubNode
ALTER TABLE pubsubNode DROP COLUMN contacts;
ALTER TABLE pubsubNode DROP COLUMN rosterGroups;
ALTER TABLE pubsubNode DROP COLUMN replyRooms;
ALTER TABLE pubsubNode DROP COLUMN replyTo;
ALTER TABLE pubsubNode DROP COLUMN associationTrusted;
-- Add new pubsub tables
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
jid VARCHAR(1024) NOT NULL,
associationType VARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
rosterGroup VARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
UPDATE jiveVersion set version=8 where name = 'wildfire';
/* $Revision: $ */
/* $Date: $ */
/* Drop old columns of pubSubNode */
ALTER TABLE pubsubNode DROP COLUMN contacts;
ALTER TABLE pubsubNode DROP COLUMN rosterGroups;
ALTER TABLE pubsubNode DROP COLUMN replyRooms;
ALTER TABLE pubsubNode DROP COLUMN replyTo;
ALTER TABLE pubsubNode DROP COLUMN associationTrusted;
/* Reduce columns size to avoid warnings */
ALTER TABLE pubsubNode ALTER COLUMN creator NVARCHAR(255) NOT NULL;
/* Reduce columns size to avoid warnings */
ALTER TABLE pubsubAffiliation DROP CONSTRAINT pubsubAffil_pk;
ALTER TABLE pubsubAffiliation ALTER COLUMN jid NVARCHAR(250) NOT NULL;
ALTER TABLE pubsubAffiliation ADD CONSTRAINT pubsubAffil_pk PRIMARY KEY (serviceID, nodeID, jid);
/* Add new pubsub tables */
CREATE TABLE pubsubNodeJIDs (
serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL,
jid NVARCHAR(250) NOT NULL,
associationType NVARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL,
rosterGroup NVARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
UPDATE jiveVersion set version=8 where name = 'wildfire';
/* $Revision: $ */
/* $Date: $ */
/* Drop old columns of pubSubNode */
ALTER TABLE pubsubNode DROP COLUMN contacts;
ALTER TABLE pubsubNode DROP COLUMN rosterGroups;
ALTER TABLE pubsubNode DROP COLUMN replyRooms;
ALTER TABLE pubsubNode DROP COLUMN replyTo;
ALTER TABLE pubsubNode DROP COLUMN associationTrusted;
/* Add new pubsub tables */
CREATE TABLE pubsubNodeJIDs (
serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL,
jid NVARCHAR(1024) NOT NULL,
associationType NVARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL,
rosterGroup NVARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
UPDATE jiveVersion set version=8 where name = 'wildfire';
...@@ -224,8 +224,6 @@ CREATE TABLE pubsubNode ( ...@@ -224,8 +224,6 @@ CREATE TABLE pubsubNode (
publisherModel VARCHAR(15) NOT NULL, publisherModel VARCHAR(15) NOT NULL,
subscriptionEnabled INTEGER NOT NULL, subscriptionEnabled INTEGER NOT NULL,
configSubscription INTEGER NOT NULL, configSubscription INTEGER NOT NULL,
contacts VARCHAR(4000) NULL,
rosterGroups VARCHAR(4000) NULL,
accessModel VARCHAR(10) NOT NULL, accessModel VARCHAR(10) NOT NULL,
payloadType VARCHAR(100) NULL, payloadType VARCHAR(100) NULL,
bodyXSLT VARCHAR(100) NULL, bodyXSLT VARCHAR(100) NULL,
...@@ -235,14 +233,26 @@ CREATE TABLE pubsubNode ( ...@@ -235,14 +233,26 @@ CREATE TABLE pubsubNode (
language VARCHAR(255) NULL, language VARCHAR(255) NULL,
name VARCHAR(50) NULL, name VARCHAR(50) NULL,
replyPolicy VARCHAR(15) NULL, replyPolicy VARCHAR(15) NULL,
replyRooms VARCHAR(4000) NULL,
replyTo VARCHAR(1024) NULL,
associationPolicy VARCHAR(15) NULL, associationPolicy VARCHAR(15) NULL,
associationTrusted VARCHAR(4000) NULL,
maxLeafNodes INTEGER NULL, maxLeafNodes INTEGER NULL,
CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID) CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID)
); );
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
jid VARCHAR(1024) NOT NULL,
associationType VARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
rosterGroup VARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
CREATE TABLE pubsubAffiliation ( CREATE TABLE pubsubAffiliation (
serviceID VARCHAR(100) NOT NULL, serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL, nodeID VARCHAR(100) NOT NULL,
......
...@@ -223,8 +223,6 @@ CREATE TABLE pubsubNode ( ...@@ -223,8 +223,6 @@ CREATE TABLE pubsubNode (
publisherModel VARCHAR(15) NOT NULL, publisherModel VARCHAR(15) NOT NULL,
subscriptionEnabled INTEGER NOT NULL, subscriptionEnabled INTEGER NOT NULL,
configSubscription INTEGER NOT NULL, configSubscription INTEGER NOT NULL,
contacts VARCHAR(4000) NULL,
rosterGroups VARCHAR(4000) NULL,
accessModel VARCHAR(10) NOT NULL, accessModel VARCHAR(10) NOT NULL,
payloadType VARCHAR(100) NULL, payloadType VARCHAR(100) NULL,
bodyXSLT VARCHAR(100) NULL, bodyXSLT VARCHAR(100) NULL,
...@@ -234,14 +232,26 @@ CREATE TABLE pubsubNode ( ...@@ -234,14 +232,26 @@ CREATE TABLE pubsubNode (
language VARCHAR(255) NULL, language VARCHAR(255) NULL,
name VARCHAR(50) NULL, name VARCHAR(50) NULL,
replyPolicy VARCHAR(15) NULL, replyPolicy VARCHAR(15) NULL,
replyRooms VARCHAR(4000) NULL,
replyTo VARCHAR(1024) NULL,
associationPolicy VARCHAR(15) NULL, associationPolicy VARCHAR(15) NULL,
associationTrusted VARCHAR(4000) NULL,
maxLeafNodes INTEGER NULL, maxLeafNodes INTEGER NULL,
CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID) CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID)
); );
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
jid VARCHAR(1024) NOT NULL,
associationType VARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
rosterGroup VARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
CREATE TABLE pubsubAffiliation ( CREATE TABLE pubsubAffiliation (
serviceID VARCHAR(100) NOT NULL, serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL, nodeID VARCHAR(100) NOT NULL,
......
...@@ -211,29 +211,39 @@ CREATE TABLE pubsubNode ( ...@@ -211,29 +211,39 @@ CREATE TABLE pubsubNode (
publisherModel VARCHAR(15) NOT NULL, publisherModel VARCHAR(15) NOT NULL,
subscriptionEnabled TINYINT NOT NULL, subscriptionEnabled TINYINT NOT NULL,
configSubscription TINYINT NOT NULL, configSubscription TINYINT NOT NULL,
contacts VARCHAR(4000) NULL,
rosterGroups VARCHAR(4000) NULL,
accessModel VARCHAR(10) NOT NULL, accessModel VARCHAR(10) NOT NULL,
payloadType VARCHAR(100) NULL, payloadType VARCHAR(100) NULL,
bodyXSLT VARCHAR(100) NULL, bodyXSLT VARCHAR(100) NULL,
dataformXSLT VARCHAR(100) NULL, dataformXSLT VARCHAR(100) NULL,
creator VARCHAR(1024) NOT NULL, creator VARCHAR(255) NOT NULL,
description VARCHAR(255) NULL, description VARCHAR(255) NULL,
language VARCHAR(255) NULL, language VARCHAR(255) NULL,
name VARCHAR(50) NULL, name VARCHAR(50) NULL,
replyPolicy VARCHAR(15) NULL, replyPolicy VARCHAR(15) NULL,
replyRooms VARCHAR(4000) NULL,
replyTo VARCHAR(1024) NULL,
associationPolicy VARCHAR(15) NULL, associationPolicy VARCHAR(15) NULL,
associationTrusted VARCHAR(4000) NULL,
maxLeafNodes INTEGER NULL, maxLeafNodes INTEGER NULL,
PRIMARY KEY (serviceID, nodeID) PRIMARY KEY (serviceID, nodeID)
); );
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
jid VARCHAR(255) NOT NULL,
associationType VARCHAR(20) NOT NULL,
PRIMARY KEY (serviceID, nodeID, jid(70))
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
rosterGroup VARCHAR(100) NOT NULL,
INDEX pubsubNodeGroups_idx (serviceID, nodeID)
);
CREATE TABLE pubsubAffiliation ( CREATE TABLE pubsubAffiliation (
serviceID VARCHAR(100) NOT NULL, serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL, nodeID VARCHAR(100) NOT NULL,
jid VARCHAR(1024) NOT NULL, jid VARCHAR(255) NOT NULL,
affiliation VARCHAR(10) NOT NULL, affiliation VARCHAR(10) NOT NULL,
PRIMARY KEY (serviceID, nodeID, jid(70)) PRIMARY KEY (serviceID, nodeID, jid(70))
); );
...@@ -242,7 +252,7 @@ CREATE TABLE pubsubItem ( ...@@ -242,7 +252,7 @@ CREATE TABLE pubsubItem (
serviceID VARCHAR(100) NOT NULL, serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL, nodeID VARCHAR(100) NOT NULL,
id VARCHAR(100) NOT NULL, id VARCHAR(100) NOT NULL,
jid VARCHAR(1024) NOT NULL, jid VARCHAR(255) NOT NULL,
creationDate CHAR(15) NOT NULL, creationDate CHAR(15) NOT NULL,
payload TEXT NULL, payload TEXT NULL,
PRIMARY KEY (serviceID, nodeID, id) PRIMARY KEY (serviceID, nodeID, id)
...@@ -252,15 +262,15 @@ CREATE TABLE pubsubSubscription ( ...@@ -252,15 +262,15 @@ CREATE TABLE pubsubSubscription (
serviceID VARCHAR(100) NOT NULL, serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL, nodeID VARCHAR(100) NOT NULL,
id VARCHAR(100) NOT NULL, id VARCHAR(100) NOT NULL,
jid VARCHAR(1024) NOT NULL, jid VARCHAR(255) NOT NULL,
owner VARCHAR(1024) NOT NULL, owner VARCHAR(255) NOT NULL,
state VARCHAR(15) NOT NULL, state VARCHAR(15) NOT NULL,
deliver TINYINT NOT NULL, deliver TINYINT NOT NULL,
digest TINYINT NOT NULL, digest TINYINT NOT NULL,
digest_frequency TINYINT NOT NULL, digest_frequency TINYINT NOT NULL,
expire CHAR(15) NULL, expire CHAR(15) NULL,
includeBody TINYINT NOT NULL, includeBody TINYINT NOT NULL,
showValues VARCHAR(30) NOT NULL, showValues VARCHAR(30) NULL,
subscriptionType VARCHAR(10) NOT NULL, subscriptionType VARCHAR(10) NOT NULL,
subscriptionDepth TINYINT NOT NULL, subscriptionDepth TINYINT NOT NULL,
keyword VARCHAR(200) NULL, keyword VARCHAR(200) NULL,
......
...@@ -217,8 +217,6 @@ CREATE TABLE pubsubNode ( ...@@ -217,8 +217,6 @@ CREATE TABLE pubsubNode (
publisherModel VARCHAR2(15) NOT NULL, publisherModel VARCHAR2(15) NOT NULL,
subscriptionEnabled INTEGER NOT NULL, subscriptionEnabled INTEGER NOT NULL,
configSubscription INTEGER NOT NULL, configSubscription INTEGER NOT NULL,
contacts VARCHAR2(4000) NULL,
rosterGroups VARCHAR2(4000) NULL,
accessModel VARCHAR2(10) NOT NULL, accessModel VARCHAR2(10) NOT NULL,
payloadType VARCHAR2(100) NULL, payloadType VARCHAR2(100) NULL,
bodyXSLT VARCHAR2(100) NULL, bodyXSLT VARCHAR2(100) NULL,
...@@ -228,14 +226,26 @@ CREATE TABLE pubsubNode ( ...@@ -228,14 +226,26 @@ CREATE TABLE pubsubNode (
language VARCHAR2(255) NULL, language VARCHAR2(255) NULL,
name VARCHAR2(50) NULL, name VARCHAR2(50) NULL,
replyPolicy VARCHAR2(15) NULL, replyPolicy VARCHAR2(15) NULL,
replyRooms VARCHAR2(4000) NULL,
replyTo VARCHAR2(1024) NULL,
associationPolicy VARCHAR2(15) NULL, associationPolicy VARCHAR2(15) NULL,
associationTrusted VARCHAR2(4000) NULL,
maxLeafNodes INTEGER NULL, maxLeafNodes INTEGER NULL,
CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID) CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID)
); );
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR2(100) NOT NULL,
nodeID VARCHAR2(100) NOT NULL,
jid VARCHAR2(1024) NOT NULL,
associationType VARCHAR2(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR2(100) NOT NULL,
nodeID VARCHAR2(100) NOT NULL,
rosterGroup VARCHAR2(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
CREATE TABLE pubsubAffiliation ( CREATE TABLE pubsubAffiliation (
serviceID VARCHAR2(100) NOT NULL, serviceID VARCHAR2(100) NOT NULL,
nodeID VARCHAR2(100) NOT NULL, nodeID VARCHAR2(100) NOT NULL,
......
...@@ -226,8 +226,6 @@ CREATE TABLE pubsubNode ( ...@@ -226,8 +226,6 @@ CREATE TABLE pubsubNode (
publisherModel VARCHAR(15) NOT NULL, publisherModel VARCHAR(15) NOT NULL,
subscriptionEnabled INTEGER NOT NULL, subscriptionEnabled INTEGER NOT NULL,
configSubscription INTEGER NOT NULL, configSubscription INTEGER NOT NULL,
contacts VARCHAR(4000) NULL,
rosterGroups VARCHAR(4000) NULL,
accessModel VARCHAR(10) NOT NULL, accessModel VARCHAR(10) NOT NULL,
payloadType VARCHAR(100) NULL, payloadType VARCHAR(100) NULL,
bodyXSLT VARCHAR(100) NULL, bodyXSLT VARCHAR(100) NULL,
...@@ -237,14 +235,26 @@ CREATE TABLE pubsubNode ( ...@@ -237,14 +235,26 @@ CREATE TABLE pubsubNode (
language VARCHAR(255) NULL, language VARCHAR(255) NULL,
name VARCHAR(50) NULL, name VARCHAR(50) NULL,
replyPolicy VARCHAR(15) NULL, replyPolicy VARCHAR(15) NULL,
replyRooms VARCHAR(4000) NULL,
replyTo VARCHAR(1024) NULL,
associationPolicy VARCHAR(15) NULL, associationPolicy VARCHAR(15) NULL,
associationTrusted VARCHAR(4000) NULL,
maxLeafNodes INTEGER NULL, maxLeafNodes INTEGER NULL,
CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID) CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID)
); );
CREATE TABLE pubsubNodeJIDs (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
jid VARCHAR(1024) NOT NULL,
associationType VARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL,
rosterGroup VARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
CREATE TABLE pubsubAffiliation ( CREATE TABLE pubsubAffiliation (
serviceID VARCHAR(100) NOT NULL, serviceID VARCHAR(100) NOT NULL,
nodeID VARCHAR(100) NOT NULL, nodeID VARCHAR(100) NOT NULL,
......
...@@ -224,29 +224,39 @@ CREATE TABLE pubsubNode ( ...@@ -224,29 +224,39 @@ CREATE TABLE pubsubNode (
publisherModel NVARCHAR(15) NOT NULL, publisherModel NVARCHAR(15) NOT NULL,
subscriptionEnabled INT NOT NULL, subscriptionEnabled INT NOT NULL,
configSubscription INT NOT NULL, configSubscription INT NOT NULL,
contacts NVARCHAR(4000) NULL,
rosterGroups NVARCHAR(4000) NULL,
accessModel NVARCHAR(10) NOT NULL, accessModel NVARCHAR(10) NOT NULL,
payloadType NVARCHAR(100) NULL, payloadType NVARCHAR(100) NULL,
bodyXSLT NVARCHAR(100) NULL, bodyXSLT NVARCHAR(100) NULL,
dataformXSLT NVARCHAR(100) NULL, dataformXSLT NVARCHAR(100) NULL,
creator NVARCHAR(1024) NOT NULL, creator NVARCHAR(255) NOT NULL,
description NVARCHAR(255) NULL, description NVARCHAR(255) NULL,
language NVARCHAR(255) NULL, language NVARCHAR(255) NULL,
name NVARCHAR(50) NULL, name NVARCHAR(50) NULL,
replyPolicy NVARCHAR(15) NULL, replyPolicy NVARCHAR(15) NULL,
replyRooms NVARCHAR(4000) NULL,
replyTo NVARCHAR(1024) NULL,
associationPolicy NVARCHAR(15) NULL, associationPolicy NVARCHAR(15) NULL,
associationTrusted NVARCHAR(4000) NULL,
maxLeafNodes INT NULL, maxLeafNodes INT NULL,
CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID) CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID)
); );
CREATE TABLE pubsubNodeJIDs (
serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL,
jid NVARCHAR(250) NOT NULL,
associationType NVARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL,
rosterGroup NVARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
CREATE TABLE pubsubAffiliation ( CREATE TABLE pubsubAffiliation (
serviceID NVARCHAR(100) NOT NULL, serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL, nodeID NVARCHAR(100) NOT NULL,
jid NVARCHAR(1024) NOT NULL, jid NVARCHAR(250) NOT NULL,
affiliation NVARCHAR(10) NOT NULL, affiliation NVARCHAR(10) NOT NULL,
CONSTRAINT pubsubAffil_pk PRIMARY KEY (serviceID, nodeID, jid) CONSTRAINT pubsubAffil_pk PRIMARY KEY (serviceID, nodeID, jid)
); );
......
...@@ -224,8 +224,6 @@ CREATE TABLE pubsubNode ( ...@@ -224,8 +224,6 @@ CREATE TABLE pubsubNode (
publisherModel NVARCHAR(15) NOT NULL, publisherModel NVARCHAR(15) NOT NULL,
subscriptionEnabled INT NOT NULL, subscriptionEnabled INT NOT NULL,
configSubscription INT NOT NULL, configSubscription INT NOT NULL,
contacts NVARCHAR(4000) NULL,
rosterGroups NVARCHAR(4000) NULL,
accessModel NVARCHAR(10) NOT NULL, accessModel NVARCHAR(10) NOT NULL,
payloadType NVARCHAR(100) NULL, payloadType NVARCHAR(100) NULL,
bodyXSLT NVARCHAR(100) NULL, bodyXSLT NVARCHAR(100) NULL,
...@@ -235,14 +233,26 @@ CREATE TABLE pubsubNode ( ...@@ -235,14 +233,26 @@ CREATE TABLE pubsubNode (
language NVARCHAR(255) NULL, language NVARCHAR(255) NULL,
name NVARCHAR(50) NULL, name NVARCHAR(50) NULL,
replyPolicy NVARCHAR(15) NULL, replyPolicy NVARCHAR(15) NULL,
replyRooms NVARCHAR(4000) NULL,
replyTo NVARCHAR(1024) NULL,
associationPolicy NVARCHAR(15) NULL, associationPolicy NVARCHAR(15) NULL,
associationTrusted NVARCHAR(4000) NULL,
maxLeafNodes INT NULL, maxLeafNodes INT NULL,
CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID) CONSTRAINT pubsubNode_pk PRIMARY KEY (serviceID, nodeID)
); );
CREATE TABLE pubsubNodeJIDs (
serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL,
jid NVARCHAR(1024) NOT NULL,
associationType NVARCHAR(20) NOT NULL,
CONSTRAINT pubsubJID_pk PRIMARY KEY (serviceID, nodeID, jid)
);
CREATE TABLE pubsubNodeGroups (
serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL,
rosterGroup NVARCHAR(100) NOT NULL
);
CREATE INDEX pubsubNodeGroups_idx ON pubsubNodeGroups (serviceID, nodeID);
CREATE TABLE pubsubAffiliation ( CREATE TABLE pubsubAffiliation (
serviceID NVARCHAR(100) NOT NULL, serviceID NVARCHAR(100) NOT NULL,
nodeID NVARCHAR(100) NOT NULL, nodeID NVARCHAR(100) NOT NULL,
......
...@@ -41,7 +41,7 @@ public class DbConnectionManager { ...@@ -41,7 +41,7 @@ public class DbConnectionManager {
/** /**
* Database schema version. * Database schema version.
*/ */
private static final int DATABASE_VERSION = 7; private static final int DATABASE_VERSION = 8;
private static ConnectionProvider connectionProvider; private static ConnectionProvider connectionProvider;
......
...@@ -73,7 +73,7 @@ public class CollectionNode extends Node { ...@@ -73,7 +73,7 @@ public class CollectionNode extends Node {
associationTrusted = new ArrayList<JID>(); associationTrusted = new ArrayList<JID>();
for (String value : field.getValues()) { for (String value : field.getValues()) {
try { try {
associationTrusted.add(new JID(value)); addAssociationTrusted(new JID(value));
} }
catch (Exception e) { catch (Exception e) {
// Do nothing // Do nothing
...@@ -276,7 +276,18 @@ public class CollectionNode extends Node { ...@@ -276,7 +276,18 @@ public class CollectionNode extends Node {
* @return the users that are allowed to associate leaf nodes with this collection node. * @return the users that are allowed to associate leaf nodes with this collection node.
*/ */
public Collection<JID> getAssociationTrusted() { public Collection<JID> getAssociationTrusted() {
return associationTrusted; return Collections.unmodifiableCollection(associationTrusted);
}
/**
* Adds a new trusted user that is allowed to associate leaf nodes with this collection node.
* The new user is not going to be added to the database. Instead it is just kept in memory.
*
* @param user the new trusted user that is allowed to associate leaf nodes with this
* collection node.
*/
void addAssociationTrusted(JID user) {
associationTrusted.add(user);
} }
/** /**
......
...@@ -435,7 +435,8 @@ public class LeafNode extends Node { ...@@ -435,7 +435,8 @@ public class LeafNode extends Node {
synchronized (publishedItems) { synchronized (publishedItems) {
if (publishedItems.size() > 1) { if (publishedItems.size() > 1) {
// Remove all items except the last one // Remove all items except the last one
toDelete = publishedItems.subList(0, publishedItems.size() - 1); toDelete = new ArrayList<PublishedItem>(
publishedItems.subList(0, publishedItems.size() - 1));
// Remove items to delete from memory // Remove items to delete from memory
publishedItems.removeAll(toDelete); publishedItems.removeAll(toDelete);
// Update fast look up cache of published items // Update fast look up cache of published items
......
...@@ -562,7 +562,7 @@ public abstract class Node { ...@@ -562,7 +562,7 @@ public abstract class Node {
// Get the new list of roster group(s) allowed to subscribe and retrieve items // Get the new list of roster group(s) allowed to subscribe and retrieve items
rosterGroupsAllowed = new ArrayList<String>(); rosterGroupsAllowed = new ArrayList<String>();
for (String value : field.getValues()) { for (String value : field.getValues()) {
rosterGroupsAllowed.add(value); addAllowedRosterGroup(value);
} }
} }
else if ("pubsub#contact".equals(field.getVariable())) { else if ("pubsub#contact".equals(field.getVariable())) {
...@@ -570,7 +570,7 @@ public abstract class Node { ...@@ -570,7 +570,7 @@ public abstract class Node {
contacts = new ArrayList<JID>(); contacts = new ArrayList<JID>();
for (String value : field.getValues()) { for (String value : field.getValues()) {
try { try {
contacts.add(new JID(value)); addContact(new JID(value));
} }
catch (Exception e) { catch (Exception e) {
// Do nothing // Do nothing
...@@ -600,7 +600,7 @@ public abstract class Node { ...@@ -600,7 +600,7 @@ public abstract class Node {
replyRooms = new ArrayList<JID>(); replyRooms = new ArrayList<JID>();
for (String value : field.getValues()) { for (String value : field.getValues()) {
try { try {
replyRooms.add(new JID(value)); addReplyRoom(new JID(value));
} }
catch (Exception e) { catch (Exception e) {
// Do nothing // Do nothing
...@@ -612,7 +612,7 @@ public abstract class Node { ...@@ -612,7 +612,7 @@ public abstract class Node {
replyTo = new ArrayList<JID>(); replyTo = new ArrayList<JID>();
for (String value : field.getValues()) { for (String value : field.getValues()) {
try { try {
replyTo.add(new JID(value)); addReplyTo(new JID(value));
} }
catch (Exception e) { catch (Exception e) {
// Do nothing // Do nothing
...@@ -1312,15 +1312,34 @@ public abstract class Node { ...@@ -1312,15 +1312,34 @@ public abstract class Node {
* @return the roster group(s) allowed to subscribe and retrieve items. * @return the roster group(s) allowed to subscribe and retrieve items.
*/ */
public Collection<String> getRosterGroupsAllowed() { public Collection<String> getRosterGroupsAllowed() {
return rosterGroupsAllowed; return Collections.unmodifiableCollection(rosterGroupsAllowed);
}
/**
* Adds a new roster group that is allowed to subscribe and retrieve items.
* The new roster group is not going to be added to the database. Instead it is just
* kept in memory.
*
* @param groupName the new roster group that is allowed to subscribe and retrieve items.
*/
void addAllowedRosterGroup(String groupName) {
rosterGroupsAllowed.add(groupName);
} }
public Collection<JID> getReplyRooms() { public Collection<JID> getReplyRooms() {
return replyRooms; return Collections.unmodifiableCollection(replyRooms);
}
void addReplyRoom(JID roomJID) {
replyRooms.add(roomJID);
} }
public Collection<JID> getReplyTo() { public Collection<JID> getReplyTo() {
return replyTo; return Collections.unmodifiableCollection(replyTo);
}
void addReplyTo(JID entity) {
replyTo.add(entity);
} }
/** /**
...@@ -1410,7 +1429,16 @@ public abstract class Node { ...@@ -1410,7 +1429,16 @@ public abstract class Node {
* @return the JIDs of those to contact with questions. * @return the JIDs of those to contact with questions.
*/ */
public Collection<JID> getContacts() { public Collection<JID> getContacts() {
return contacts; return Collections.unmodifiableCollection(contacts);
}
/**
* Adds a new user as a candidate to answer questions about the node.
*
* @param user the JID of the new user.
*/
void addContact(JID user) {
contacts.add(user);
} }
/** /**
......
...@@ -246,6 +246,7 @@ public class PubSubEngine { ...@@ -246,6 +246,7 @@ public class PubSubEngine {
// Process ad-hoc command // Process ad-hoc command
IQ reply = manager.process(iq); IQ reply = manager.process(iq);
router.route(reply); router.route(reply);
return true;
} }
return false; return false;
} }
......
...@@ -39,31 +39,45 @@ public class PubSubPersistenceManager { ...@@ -39,31 +39,45 @@ public class PubSubPersistenceManager {
"SELECT nodeID, leaf, creationDate, modificationDate, parent, deliverPayloads, " + "SELECT nodeID, leaf, creationDate, modificationDate, parent, deliverPayloads, " +
"maxPayloadSize, persistItems, maxItems, notifyConfigChanges, notifyDelete, " + "maxPayloadSize, persistItems, maxItems, notifyConfigChanges, notifyDelete, " +
"notifyRetract, presenceBased, sendItemSubscribe, publisherModel, " + "notifyRetract, presenceBased, sendItemSubscribe, publisherModel, " +
"subscriptionEnabled, configSubscription, contacts, rosterGroups, accessModel, " + "subscriptionEnabled, configSubscription, accessModel, payloadType, " +
"payloadType, bodyXSLT, dataformXSLT, creator, description, language, name, " + "bodyXSLT, dataformXSLT, creator, description, language, name, " +
"replyPolicy, replyRooms, replyTo, associationPolicy, associationTrusted, " + "replyPolicy, associationPolicy, maxLeafNodes FROM pubsubNode " +
"maxLeafNodes FROM pubsubNode WHERE serviceID=? ORDER BY nodeID"; "WHERE serviceID=? ORDER BY nodeID";
private static final String UPDATE_NODE = private static final String UPDATE_NODE =
"UPDATE pubsubNode SET modificationDate=?, parent=?, deliverPayloads=?, " + "UPDATE pubsubNode SET modificationDate=?, parent=?, deliverPayloads=?, " +
"maxPayloadSize=?, persistItems=?, maxItems=?, " + "maxPayloadSize=?, persistItems=?, maxItems=?, " +
"notifyConfigChanges=?, notifyDelete=?, notifyRetract=?, presenceBased=?, " + "notifyConfigChanges=?, notifyDelete=?, notifyRetract=?, presenceBased=?, " +
"sendItemSubscribe=?, publisherModel=?, subscriptionEnabled=?, configSubscription=?, " + "sendItemSubscribe=?, publisherModel=?, subscriptionEnabled=?, configSubscription=?, " +
"contacts=?, rosterGroups=?, accessModel=?, payloadType=?, bodyXSLT=?, " + "accessModel=?, payloadType=?, bodyXSLT=?, dataformXSLT=?, description=?, " +
"dataformXSLT=?, description=?, language=?, name=?, replyPolicy=?, replyRooms=?, " + "language=?, name=?, replyPolicy=?, associationPolicy=?, maxLeafNodes=? " +
"replyTo=?, associationPolicy=?, associationTrusted=?, maxLeafNodes=? " +
"WHERE serviceID=? AND nodeID=?"; "WHERE serviceID=? AND nodeID=?";
private static final String ADD_NODE = private static final String ADD_NODE =
"INSERT INTO pubsubNode (serviceID, nodeID, leaf, creationDate, modificationDate, " + "INSERT INTO pubsubNode (serviceID, nodeID, leaf, creationDate, modificationDate, " +
"parent, deliverPayloads, maxPayloadSize, persistItems, maxItems, " + "parent, deliverPayloads, maxPayloadSize, persistItems, maxItems, " +
"notifyConfigChanges, notifyDelete, notifyRetract, presenceBased, " + "notifyConfigChanges, notifyDelete, notifyRetract, presenceBased, " +
"sendItemSubscribe, publisherModel, subscriptionEnabled, configSubscription, " + "sendItemSubscribe, publisherModel, subscriptionEnabled, configSubscription, " +
"accessModel, contacts, rosterGroups, payloadType, bodyXSLT, dataformXSLT, " + "accessModel, payloadType, bodyXSLT, dataformXSLT, creator, description, " +
"creator, description, language, name, replyPolicy, replyRooms, replyTo, " + "language, name, replyPolicy, associationPolicy, maxLeafNodes) " +
"associationPolicy, associationTrusted, maxLeafNodes) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
private static final String DELETE_NODE = private static final String DELETE_NODE =
"DELETE FROM pubsubNode WHERE serviceID=? AND nodeID=?"; "DELETE FROM pubsubNode WHERE serviceID=? AND nodeID=?";
private static final String LOAD_NODES_JIDS =
"SELECT nodeID, jid, associationType FROM pubsubNodeJIDs WHERE serviceID=?";
private static final String ADD_NODE_JIDS =
"INSERT INTO pubsubNodeJIDs (serviceID, nodeID, jid, associationType) " +
"VALUES (?,?,?,?)";
private static final String DELETE_NODE_JIDS =
"DELETE FROM pubsubNodeJIDs WHERE serviceID=? AND nodeID=?";
private static final String LOAD_NODES_GROUPS =
"SELECT nodeID, rosterGroup FROM pubsubNodeGroups WHERE serviceID=?";
private static final String ADD_NODE_GROUPS =
"INSERT INTO pubsubNodeGroups (serviceID, nodeID, rosterGroup) " +
"VALUES (?,?,?)";
private static final String DELETE_NODE_GROUPS =
"DELETE FROM pubsubNodeGroups WHERE serviceID=? AND nodeID=?";
private static final String LOAD_AFFILIATIONS = private static final String LOAD_AFFILIATIONS =
"SELECT nodeID,jid,affiliation FROM pubsubAffiliation WHERE serviceID=? " + "SELECT nodeID,jid,affiliation FROM pubsubAffiliation WHERE serviceID=? " +
"ORDER BY nodeID"; "ORDER BY nodeID";
...@@ -148,8 +162,9 @@ public class PubSubPersistenceManager { ...@@ -148,8 +162,9 @@ public class PubSubPersistenceManager {
public static void createNode(PubSubService service, Node node) { public static void createNode(PubSubService service, Node node) {
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
boolean abortTransaction = false;
try { try {
con = DbConnectionManager.getConnection(); con = DbConnectionManager.getTransactionConnection();
pstmt = con.prepareStatement(ADD_NODE); pstmt = con.prepareStatement(ADD_NODE);
pstmt.setString(1, service.getServiceID()); pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID())); pstmt.setString(2, encodeNodeID(node.getNodeID()));
...@@ -177,43 +192,40 @@ public class PubSubPersistenceManager { ...@@ -177,43 +192,40 @@ public class PubSubPersistenceManager {
pstmt.setInt(17, (node.isSubscriptionEnabled() ? 1 : 0)); pstmt.setInt(17, (node.isSubscriptionEnabled() ? 1 : 0));
pstmt.setInt(18, (node.isSubscriptionConfigurationRequired() ? 1 : 0)); pstmt.setInt(18, (node.isSubscriptionConfigurationRequired() ? 1 : 0));
pstmt.setString(19, node.getAccessModel().getName()); pstmt.setString(19, node.getAccessModel().getName());
pstmt.setString(20, encodeJIDs(node.getContacts())); pstmt.setString(20, node.getPayloadType());
pstmt.setString(21, encodeGroups(node.getRosterGroupsAllowed())); pstmt.setString(21, node.getBodyXSLT());
pstmt.setString(22, node.getPayloadType()); pstmt.setString(22, node.getDataformXSLT());
pstmt.setString(23, node.getBodyXSLT()); pstmt.setString(23, node.getCreator().toString());
pstmt.setString(24, node.getDataformXSLT()); pstmt.setString(24, node.getDescription());
pstmt.setString(25, node.getCreator().toString()); pstmt.setString(25, node.getLanguage());
pstmt.setString(26, node.getDescription()); pstmt.setString(26, node.getName());
pstmt.setString(27, node.getLanguage());
pstmt.setString(28, node.getName());
if (node.getReplyPolicy() != null) { if (node.getReplyPolicy() != null) {
pstmt.setString(29, node.getReplyPolicy().name()); pstmt.setString(27, node.getReplyPolicy().name());
} }
else { else {
pstmt.setString(29, null); pstmt.setString(27, null);
} }
pstmt.setString(30, encodeJIDs(node.getReplyRooms()));
pstmt.setString(31, encodeJIDs(node.getReplyTo()));
if (node.isCollectionNode()) { if (node.isCollectionNode()) {
pstmt.setString(32, ((CollectionNode)node).getAssociationPolicy().name()); pstmt.setString(28, ((CollectionNode)node).getAssociationPolicy().name());
pstmt.setString(33, encodeJIDs(((CollectionNode)node).getAssociationTrusted())); pstmt.setInt(29, ((CollectionNode)node).getMaxLeafNodes());
pstmt.setInt(34, ((CollectionNode)node).getMaxLeafNodes());
} }
else { else {
pstmt.setString(32, null); pstmt.setString(28, null);
pstmt.setString(33, null); pstmt.setInt(29, 0);
pstmt.setInt(34, 0);
} }
pstmt.executeUpdate(); pstmt.executeUpdate();
// Save associated JIDs and roster groups
saveAssociatedElements(con, node, service);
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle);
abortTransaction = true;
} }
finally { finally {
try {if (pstmt != null) {pstmt.close();}} try {if (pstmt != null) {pstmt.close();}}
catch (Exception e) {Log.error(e);} catch (Exception e) {Log.error(e);}
try {if (con != null) {con.close();}} DbConnectionManager.closeTransactionConnection(con, abortTransaction);
catch (Exception e) {Log.error(e);}
} }
} }
...@@ -226,8 +238,9 @@ public class PubSubPersistenceManager { ...@@ -226,8 +238,9 @@ public class PubSubPersistenceManager {
public static void updateNode(PubSubService service, Node node) { public static void updateNode(PubSubService service, Node node) {
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
boolean abortTransaction = false;
try { try {
con = DbConnectionManager.getConnection(); con = DbConnectionManager.getTransactionConnection();
pstmt = con.prepareStatement(UPDATE_NODE); pstmt = con.prepareStatement(UPDATE_NODE);
pstmt.setString(1, StringUtils.dateToMillis(node.getModificationDate())); pstmt.setString(1, StringUtils.dateToMillis(node.getModificationDate()));
pstmt.setString(2, node.getParent() != null ? encodeNodeID(node.getParent().getNodeID()) : null); pstmt.setString(2, node.getParent() != null ? encodeNodeID(node.getParent().getNodeID()) : null);
...@@ -250,45 +263,107 @@ public class PubSubPersistenceManager { ...@@ -250,45 +263,107 @@ public class PubSubPersistenceManager {
pstmt.setString(12, node.getPublisherModel().getName()); pstmt.setString(12, node.getPublisherModel().getName());
pstmt.setInt(13, (node.isSubscriptionEnabled() ? 1 : 0)); pstmt.setInt(13, (node.isSubscriptionEnabled() ? 1 : 0));
pstmt.setInt(14, (node.isSubscriptionConfigurationRequired() ? 1 : 0)); pstmt.setInt(14, (node.isSubscriptionConfigurationRequired() ? 1 : 0));
pstmt.setString(15, encodeJIDs(node.getContacts())); pstmt.setString(15, node.getAccessModel().getName());
pstmt.setString(16, encodeGroups(node.getRosterGroupsAllowed())); pstmt.setString(16, node.getPayloadType());
pstmt.setString(17, node.getAccessModel().getName()); pstmt.setString(17, node.getBodyXSLT());
pstmt.setString(18, node.getPayloadType()); pstmt.setString(18, node.getDataformXSLT());
pstmt.setString(19, node.getBodyXSLT()); pstmt.setString(19, node.getDescription());
pstmt.setString(20, node.getDataformXSLT()); pstmt.setString(20, node.getLanguage());
pstmt.setString(21, node.getDescription()); pstmt.setString(21, node.getName());
pstmt.setString(22, node.getLanguage());
pstmt.setString(23, node.getName());
if (node.getReplyPolicy() != null) { if (node.getReplyPolicy() != null) {
pstmt.setString(24, node.getReplyPolicy().name()); pstmt.setString(22, node.getReplyPolicy().name());
} }
else { else {
pstmt.setString(24, null); pstmt.setString(22, null);
} }
pstmt.setString(25, encodeJIDs(node.getReplyRooms()));
pstmt.setString(26, encodeJIDs(node.getReplyTo()));
if (node.isCollectionNode()) { if (node.isCollectionNode()) {
pstmt.setString(27, ((CollectionNode) node).getAssociationPolicy().name()); pstmt.setString(23, ((CollectionNode) node).getAssociationPolicy().name());
pstmt.setString(28, encodeJIDs(((CollectionNode) node).getAssociationTrusted())); pstmt.setInt(24, ((CollectionNode) node).getMaxLeafNodes());
pstmt.setInt(29, ((CollectionNode) node).getMaxLeafNodes());
} }
else { else {
pstmt.setString(27, null); pstmt.setString(23, null);
pstmt.setString(28, null); pstmt.setInt(24, 0);
pstmt.setInt(29, 0);
} }
pstmt.setString(30, service.getServiceID()); pstmt.setString(25, service.getServiceID());
pstmt.setString(31, encodeNodeID(node.getNodeID())); pstmt.setString(26, encodeNodeID(node.getNodeID()));
pstmt.executeUpdate();
// Remove existing JIDs associated with the the node
pstmt = con.prepareStatement(DELETE_NODE_JIDS);
pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID()));
pstmt.executeUpdate(); pstmt.executeUpdate();
pstmt.close();
// Remove roster groups associated with the the node being deleted
pstmt = con.prepareStatement(DELETE_NODE_GROUPS);
pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID()));
pstmt.executeUpdate();
pstmt.close();
pstmt = null;
// Save associated JIDs and roster groups
saveAssociatedElements(con, node, service);
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle);
abortTransaction = true;
} }
finally { finally {
try {if (pstmt != null) {pstmt.close();}} try {if (pstmt != null) {pstmt.close();}}
catch (Exception e) {Log.error(e);} catch (Exception e) {Log.error(e);}
try {if (con != null) {con.close();}} DbConnectionManager.closeTransactionConnection(con, abortTransaction);
catch (Exception e) {Log.error(e);} }
}
private static void saveAssociatedElements(Connection con, Node node,
PubSubService service) throws SQLException {
// Add new JIDs associated with the the node
PreparedStatement pstmt = con.prepareStatement(ADD_NODE_JIDS);
try {
for (JID jid : node.getContacts()) {
pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID()));
pstmt.setString(3, jid.toString());
pstmt.setString(4, "contacts");
pstmt.executeUpdate();
}
for (JID jid : node.getReplyRooms()) {
pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID()));
pstmt.setString(3, jid.toString());
pstmt.setString(4, "replyRooms");
pstmt.executeUpdate();
}
for (JID jid : node.getReplyTo()) {
pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID()));
pstmt.setString(3, jid.toString());
pstmt.setString(4, "replyTo");
pstmt.executeUpdate();
}
if (node.isCollectionNode()) {
for (JID jid : ((CollectionNode) node).getAssociationTrusted()) {
pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID()));
pstmt.setString(3, jid.toString());
pstmt.setString(4, "associationTrusted");
pstmt.executeUpdate();
}
}
pstmt.close();
// Add new roster groups associated with the the node
pstmt = con.prepareStatement(ADD_NODE_GROUPS);
for (String groupName : node.getRosterGroupsAllowed()) {
pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID()));
pstmt.setString(3, groupName);
pstmt.executeUpdate();
}
}
finally {
pstmt.close();
} }
} }
...@@ -312,6 +387,20 @@ public class PubSubPersistenceManager { ...@@ -312,6 +387,20 @@ public class PubSubPersistenceManager {
pstmt.executeUpdate(); pstmt.executeUpdate();
pstmt.close(); pstmt.close();
// Remove JIDs associated with the the node being deleted
pstmt = con.prepareStatement(DELETE_NODE_JIDS);
pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID()));
pstmt.executeUpdate();
pstmt.close();
// Remove roster groups associated with the the node being deleted
pstmt = con.prepareStatement(DELETE_NODE_GROUPS);
pstmt.setString(1, service.getServiceID());
pstmt.setString(2, encodeNodeID(node.getNodeID()));
pstmt.executeUpdate();
pstmt.close();
// Remove published items of the node being deleted // Remove published items of the node being deleted
pstmt = con.prepareStatement(DELETE_ITEMS); pstmt = con.prepareStatement(DELETE_ITEMS);
pstmt.setString(1, service.getServiceID()); pstmt.setString(1, service.getServiceID());
...@@ -366,6 +455,28 @@ public class PubSubPersistenceManager { ...@@ -366,6 +455,28 @@ public class PubSubPersistenceManager {
rs.close(); rs.close();
pstmt.close(); pstmt.close();
// Get JIDs associated with all nodes
pstmt = con.prepareStatement(LOAD_NODES_JIDS);
pstmt.setString(1, service.getServiceID());
rs = pstmt.executeQuery();
// Add to each node the associated JIDs
while(rs.next()) {
loadAssociatedJIDs(nodes, rs);
}
rs.close();
pstmt.close();
// Get roster groups associateds with all nodes
pstmt = con.prepareStatement(LOAD_NODES_GROUPS);
pstmt.setString(1, service.getServiceID());
rs = pstmt.executeQuery();
// Add to each node the associated Groups
while(rs.next()) {
loadAssociatedGroups(nodes, rs);
}
rs.close();
pstmt.close();
// Get affiliations of all nodes // Get affiliations of all nodes
pstmt = con.prepareStatement(LOAD_AFFILIATIONS); pstmt = con.prepareStatement(LOAD_AFFILIATIONS);
pstmt.setString(1, service.getServiceID()); pstmt.setString(1, service.getServiceID());
...@@ -425,7 +536,7 @@ public class PubSubPersistenceManager { ...@@ -425,7 +536,7 @@ public class PubSubPersistenceManager {
String nodeID = decodeNodeID(rs.getString(1)); String nodeID = decodeNodeID(rs.getString(1));
boolean leaf = rs.getInt(2) == 1; boolean leaf = rs.getInt(2) == 1;
String parent = decodeNodeID(rs.getString(5)); String parent = decodeNodeID(rs.getString(5));
JID creator = new JID(rs.getString(24)); JID creator = new JID(rs.getString(22));
CollectionNode parentNode = null; CollectionNode parentNode = null;
if (parent != null) { if (parent != null) {
// Check if the parent has already been loaded // Check if the parent has already been loaded
...@@ -461,25 +572,20 @@ public class PubSubPersistenceManager { ...@@ -461,25 +572,20 @@ public class PubSubPersistenceManager {
node.setPublisherModel(PublisherModel.valueOf(rs.getString(15))); node.setPublisherModel(PublisherModel.valueOf(rs.getString(15)));
node.setSubscriptionEnabled(rs.getInt(16) == 1); node.setSubscriptionEnabled(rs.getInt(16) == 1);
node.setSubscriptionConfigurationRequired(rs.getInt(17) == 1); node.setSubscriptionConfigurationRequired(rs.getInt(17) == 1);
node.setContacts(decodeJIDs(rs.getString(18))); node.setAccessModel(AccessModel.valueOf(rs.getString(18)));
node.setRosterGroupsAllowed(decodeGroups(rs.getString(19))); node.setPayloadType(rs.getString(19));
node.setAccessModel(AccessModel.valueOf(rs.getString(20))); node.setBodyXSLT(rs.getString(20));
node.setPayloadType(rs.getString(21)); node.setDataformXSLT(rs.getString(21));
node.setBodyXSLT(rs.getString(22)); node.setDescription(rs.getString(23));
node.setDataformXSLT(rs.getString(23)); node.setLanguage(rs.getString(24));
node.setDescription(rs.getString(25)); node.setName(rs.getString(25));
node.setLanguage(rs.getString(26)); if (rs.getString(26) != null) {
node.setName(rs.getString(27)); node.setReplyPolicy(Node.ItemReplyPolicy.valueOf(rs.getString(26)));
if (rs.getString(28) != null) { }
node.setReplyPolicy(Node.ItemReplyPolicy.valueOf(rs.getString(28)));
}
node.setReplyRooms(decodeJIDs(rs.getString(29)));
node.setReplyTo(decodeJIDs(rs.getString(30)));
if (!leaf) { if (!leaf) {
((CollectionNode) node).setAssociationPolicy( ((CollectionNode) node).setAssociationPolicy(
CollectionNode.LeafNodeAssociationPolicy.valueOf(rs.getString(31))); CollectionNode.LeafNodeAssociationPolicy.valueOf(rs.getString(27)));
((CollectionNode) node).setAssociationTrusted(decodeJIDs(rs.getString(32))); ((CollectionNode) node).setMaxLeafNodes(rs.getInt(28));
((CollectionNode) node).setMaxLeafNodes(rs.getInt(33));
} }
// Add the load to the list of loaded nodes // Add the load to the list of loaded nodes
...@@ -490,6 +596,49 @@ public class PubSubPersistenceManager { ...@@ -490,6 +596,49 @@ public class PubSubPersistenceManager {
} }
} }
private static void loadAssociatedJIDs(Map<String, Node> nodes, ResultSet rs) {
try {
String nodeID = decodeNodeID(rs.getString(1));
Node node = nodes.get(nodeID);
if (node == null) {
Log.warn("JID associated to a non-existent node: " + nodeID);
return;
}
JID jid = new JID(rs.getString(2));
String associationType = rs.getString(3);
if ("contacts".equals(associationType)) {
node.addContact(jid);
}
else if ("replyRooms".equals(associationType)) {
node.addReplyRoom(jid);
}
else if ("replyTo".equals(associationType)) {
node.addReplyTo(jid);
}
else if ("associationTrusted".equals(associationType)) {
((CollectionNode) node).addAssociationTrusted(jid);
}
}
catch (Exception ex) {
Log.error(ex);
}
}
private static void loadAssociatedGroups(Map<String, Node> nodes, ResultSet rs) {
try {
String nodeID = decodeNodeID(rs.getString(1));
Node node = nodes.get(nodeID);
if (node == null) {
Log.warn("Roster Group associated to a non-existent node: " + nodeID);
return;
}
node.addAllowedRosterGroup(rs.getString(2));
}
catch (SQLException ex) {
Log.error(ex);
}
}
private static void loadAffiliations(Map<String, Node> nodes, ResultSet rs) { private static void loadAffiliations(Map<String, Node> nodes, ResultSet rs) {
try { try {
String nodeID = decodeNodeID(rs.getString(1)); String nodeID = decodeNodeID(rs.getString(1));
...@@ -1188,49 +1337,6 @@ public class PubSubPersistenceManager { ...@@ -1188,49 +1337,6 @@ public class PubSubPersistenceManager {
return node; return node;
}*/ }*/
private static String encodeJIDs(Collection<JID> jids) {
StringBuilder sb = new StringBuilder(90);
for (JID jid : jids) {
sb.append(jid.toString()).append(",");
}
if (!jids.isEmpty()) {
sb.setLength(sb.length()-1);
}
return sb.toString();
}
private static Collection<JID> decodeJIDs(String jids) {
if (jids == null) {
return Collections.emptyList();
}
Collection<JID> decodedJIDs = new ArrayList<JID>();
StringTokenizer tokenizer = new StringTokenizer(jids, ",");
while (tokenizer.hasMoreTokens()) {
decodedJIDs.add(new JID(tokenizer.nextToken()));
}
return decodedJIDs;
}
private static String encodeGroups(Collection<String> groups) {
StringBuilder sb = new StringBuilder(90);
for (String group : groups) {
sb.append(group).append("\u2008");
}
if (!groups.isEmpty()) {
sb.setLength(sb.length()-1);
}
return sb.toString();
}
private static Collection<String> decodeGroups(String groups) {
Collection<String> decodedGroups = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(groups, "\u2008");
while (tokenizer.hasMoreTokens()) {
decodedGroups.add(tokenizer.nextToken());
}
return decodedGroups;
}
private static String encodeWithComma(Collection<String> strings) { private static String encodeWithComma(Collection<String> strings) {
StringBuilder sb = new StringBuilder(90); StringBuilder sb = new StringBuilder(90);
for (String group : strings) { for (String group : strings) {
...@@ -1239,12 +1345,16 @@ public class PubSubPersistenceManager { ...@@ -1239,12 +1345,16 @@ public class PubSubPersistenceManager {
if (!strings.isEmpty()) { if (!strings.isEmpty()) {
sb.setLength(sb.length()-1); sb.setLength(sb.length()-1);
} }
else {
// Add a blank so an empty string is never replaced with NULL (oracle...arggg!!!)
sb.append(" ");
}
return sb.toString(); return sb.toString();
} }
private static Collection<String> decodeWithComma(String strings) { private static Collection<String> decodeWithComma(String strings) {
Collection<String> decodedStrings = new ArrayList<String>(); Collection<String> decodedStrings = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(strings, ","); StringTokenizer tokenizer = new StringTokenizer(strings.trim(), ",");
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
decodedStrings.add(tokenizer.nextToken()); decodedStrings.add(tokenizer.nextToken());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment