Commit f80b6a1e authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Port from 3.5.1.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10312 b35dd754-fafc-0310-a699-88a17e54d16e
parent f8583a62
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Fastpath Plugin Changelog</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
padding-left : 1em;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
TT {
font-family : courier new;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new;
font-size : 100%;
}
</style>
</head>
<body>
<h1>
Fastpath Plugin Changelog
</h1>
<p><b>1.1.0</b> -- July 31, 2008</p>
<ul>
<li>Compatible version with Openfire 3.6.0. </li>
</ul>
<p><b>1.0.0</b> -- April 24, 2008</p>
<ul>
<li>Initial release. </li>
</ul>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<class>org.jivesoftware.openfire.fastpath.FastpathPlugin</class>
<name>Fastpath Service</name>
<description>Support for managed queued chat requests, such as a support team might use.</description>
<author>Jive Software</author>
<version>1.1.0</version>
<date>7/31/2008</date>
<minServerVersion>3.6.0</minServerVersion>
<databaseKey>fastpath</databaseKey>
<databaseVersion>0</databaseVersion>
<adminconsole>
<tab id="workgroup-tab" name="Fastpath"
url="workgroup-summary.jsp"
description="Click to manage FastPath.">
<sidebar id="workgroup-sidebar" name="Workgroups Manager">
<item id="workgroup-summary" name="View Workgroups"
url="workgroup-summary.jsp"
description="Click to view all Workgroups"/>
<item id="workgroup-settings" name="Manage Settings"
url="workgroup-settings.jsp"
description="Click to configure global settings"/>
<item id="workgroup-create" name="Create Workgroup"
url="workgroup-create.jsp"
description="Click to create a Workgroup">
<sidebar id="workgroup-setting-options" name="Workgroup Settings">
<item id="workgroup-queues" name="Manage Queues"
url="workgroup-queues.jsp"
description="Click to edit workgroup Queue(s)"/>
<item id="workgroup-macros" name="Canned Responses"
url="workgroup-macros.jsp"
description="Click to edit the Workgroup Canned Responses"/>
<item id="workgroup-monitors" name="Room Monitors"
url="workgroup-monitors.jsp"
description="Click to Manage Room Monitors"/>
<item id="workgroup-offline" name="Offline Settings"
url="workgroup-offline.jsp"
description="Click to edit Offline instructions"/>
<item id="workgroup-transcript-config" name="Transcripts"
url="workgroup-transcript-config.jsp"
description="Click to edit Transcript settings"/>
<item id="workgroup-forms" name="Form UI"
url="forms/workgroup-dataform.jsp"
description="Click to create or edit the Form used for this workgroup"/>
<item id="workgroup-variables" name="Form Variables"
url="workgroup-variables.jsp"
description="Click to create or edit the Variables to retrieve for this workgroup"/>
<item id="workgroup-image-settings"
name="Images"
url="workgroup-image-settings.jsp"
description="Click to customize Web Chat window"/>
<item id="workgroup-text-settings"
name="Text"
url="workgroup-text-settings.jsp"
description="Click to customize Web Chat window"/>
<item id="workgroup-properties" name="Settings"
url="workgroup-properties.jsp"
description="Click to view workgroup properties"/>
</sidebar>
</item>
</sidebar>
<sidebar id="reporting-sidebar" name="Reports">
<item id="chat-summary" name="View Previous Chats"
url="chat-summary.jsp"
description="Click to view Chat Transcripts">
</item>
<item id="usage-summary" name="View Chat Usage"
url="usage-summary.jsp"
description="Click to view Usage Summary"/>
</sidebar>
</tab>
</adminconsole>
</plugin>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Fastpath Plugin Readme</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
TT {
font-family : courier new;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new;
font-size : 100%;
}
#datatable TH {
color : #fff;
background-color : #2A448C;
text-align : left;
}
#datatable TD {
background-color : #FAF6EF;
}
#datatable .name {
background-color : #DCE2F5;
}
</style>
</head>
<body>
<h1>
Fastpath Plugin Readme
</h1>
<h2>Overview</h2>
<p>
The Fastpath plugin adds support for managed queued chat requests, such as
a support team might use. For example, a web based "Live Support" interface
can point a potential customer at a workgroup representing the Sales team.
Members of that workgroup will receive notification that a someone is
waiting and when someone from that workgroup accepts, the customer and the
team member will be connected to communicate with each other.
</p>
<h2>Installation</h2>
<p>
Copy fastpath.jar into the plugins directory of your Openfire installation. The
plugin will then be automatically deployed. To upgrade to a new version, copy
the new fastpath.jar file over the existing file. <b>Make sure to follow the
upgrading instructions under the Upgrading section, regardless of if
you have the old Fastpath plugin or Enterprise installed currently or not.
The only time you can skip the Upgrading section is if you know for a fact
that you have never run Fastpath or Enterprise.</b>
</p>
<p>
Make sure that the enterprise plugin is removed before installing this plugin.
Otherwise the enterprise plugin will rename the fastpath.jar to fastpath.jar.old
thus removing thus plugin. If this happens just stop the server, remove the
enterprise.jar plugin and rename fastpath.jar.old to fastpath.jar and start the
server again.
</p>
<h2>Upgrading from Pre-Enterprise Fastpath and Enterprise</h2>
<p>
Due to the previous version of Fastpath existing before it was incorporated
into Enterprise, and due to this replacing part of the Enterprise plugin,
upgrading to this Fastpath plugin requires some manual steps. Effectively,
we need to clean up the old database a bit and change the names of a couple of
things. So the steps you will need to perform are as follows:
<ol>
<li>Shut down your server.</li>
<li>Remove <b>enterprise.jar</b> and the directory <b>enterprise</b>.</li>
<li>Log into your database, you can use the embedded-db-viewer scripts in bin/extra to access the Embedded database.</li>
<li>Execute the following SQL: <tt>DELETE FROM ofVersion WHERE name = 'fastpath'</tt></li>
<li>Execute the following SQL (this may fail if you never had enterprise instaled, that is ok): <tt>UPDATE fpWorkgroupProp SET propValue = REPLACE(propValue, 'com.jivesoftware.openfire.fastpath','org.jivesoftware.openfire.fastpath')</tt></li>
<li>Execute the following SQL (this may fail if you never had enterprise installed, that is ok): <tt>UPDATE fpAgentProp SET propValue = REPLACE(propValue, 'com.jivesoftware.openfire.fastpath','org.jivesoftware.openfire.fastpath')</tt></li>
<li>Start up your server. If you had enterprise installed, you -will- see an SQL error show up, but it should only show up once and is ok. (it is an attempt to recreate a table that already exists) The error will look like: <tt>fastpath - Database update failed. Please manually upgrade your database.</tt></li>
</ol>
<b>You only need to do these steps once when moving to this Fastpath plugin.
Do not repeat these steps on future Fastpath plugin updates.</b>
</p>
<h2>Configuration</h2>
Configuration is performed under the <b>Fastpath</b> tab in the Openfire
admin console. The quick start guide can be found
<a href="http://www.igniterealtime.org/community/docs/DOC-1513">here</a>.
</body>
</html>
-- $Revision$
-- $Date$
INSERT INTO ofVersion (name, version) VALUES ('fastpath', 0);
CREATE TABLE fpWorkgroup(
workgroupID INTEGER NOT NULL,
jid VARCHAR(255) NOT NULL,
displayName VARCHAR(50),
description VARCHAR(255) ,
chatserver VARCHAR(255) ,
status INTEGER NOT NULL,
modes INTEGER NOT NULL,
creationDate VARCHAR(15) NOT NULL,
modificationDate VARCHAR(15) NOT NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
requestTimeout INTEGER NOT NULL,
offerTimeout INTEGER NOT NULL,
schedule LONG VARCHAR,
CONSTRAINT fpworkgroup_pk PRIMARY KEY (workgroupID)
);
-- CREATE INDEX fpWg_wgid_idx ON fpWorkgroup (workgroupID);
CREATE TABLE fpWorkgroupProp (
ownerID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue LONG VARCHAR NOT NULL,
CONSTRAINT fpWGProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpAgent(
agentID INTEGER NOT NULL,
agentJID VARCHAR(255) NOT NULL,
name VARCHAR(255) ,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
CONSTRAINT fpAgent_pk PRIMARY KEY (agentJID)
);
CREATE INDEX fpagt_agtid_idx ON fpagent(agentID);
-- CREATE INDEX fpagt_agtjid_idx ON fpagent(agentJID);
CREATE TABLE fpAgentProp (
ownerID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue LONG VARCHAR NOT NULL,
CONSTRAINT fpAgentProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueue(
queueID INTEGER NOT NULL,
workgroupID INTEGER NOT NULL,
name VARCHAR(50) NOT NULL,
description VARCHAR(255) ,
priority INTEGER NOT NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
overflow INTEGER NOT NULL,
backupQueue INTEGER ,
CONSTRAINT fpQueue_pk PRIMARY KEY (workgroupID,queueID)
);
CREATE INDEX fpqueue_wgid_idx ON fpqueue(workgroupID);
CREATE INDEX fpqueue_qid_idx ON fpqueue(queueID);
CREATE TABLE fpDispatcherProp (
ownerID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue LONG VARCHAR NOT NULL,
CONSTRAINT fpDispatProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpDispatcher(
queueID INTEGER NOT NULL,
name VARCHAR(50) ,
description VARCHAR(255) ,
offerTimeout INTEGER NOT NULL,
requestTimeout INTEGER NOT NULL,
CONSTRAINT fpDispatcher_pk PRIMARY KEY (queueID)
);
CREATE TABLE fpQueueProp (
ownerID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue LONG VARCHAR NOT NULL,
CONSTRAINT fpQueueProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueueAgent (
queueID INTEGER NOT NULL,
objectID INTEGER NOT NULL,
objectType INTEGER NOT NULL,
administrator INTEGER,
CONSTRAINT fpQueueAgent_pk PRIMARY KEY (queueID,objectID,objectType)
);
CREATE TABLE fpQueueGroup (
queueID INTEGER NOT NULL,
groupName varChar(1024) NOT NULL
);
CREATE TABLE fpSession(
sessionID varchar(31) NOT NULL,
userID varchar(200) NOT NULL,
workgroupID INTEGER NOT NULL,
transcript LONG VARCHAR,
startTime CHAR(15) NOT NULL,
endTime CHAR(15) NOT NULL,
queueWaitTime INTEGER,
state INTEGER NOT NULL,
caseID varchar(20),
status CHAR(15),
notes LONG VARCHAR,
CONSTRAINT fpSession_pk PRIMARY KEY (sessionID)
);
CREATE INDEX fpses_wgid_idx ON fpSession(workgroupID, userID);
CREATE INDEX fpses_st_idx ON fpSession(workgroupID, startTime);
CREATE TABLE fpAgentSession(
sessionID varchar(31) NOT NULL,
agentJID varchar(255) NOT NULL,
joinTime CHAR(15) NOT NULL,
leftTime CHAR(15)
);
-- CREATE INDEX fpagtss_sesid_idx ON fpSession(sessionID);
CREATE TABLE fpSessionMetadata(
sessionID varchar(31) NOT NULL,
metadataName varChar(200) NOT NULL,
metadataValue LONG VARCHAR NOT NULL
);
CREATE TABLE fpSessionProp(
sessionID varchar(31) NOT NULL,
name varchar(100) NOT NULL,
propValue LONG VARCHAR NOT NULL,
CONSTRAINT fpSessionProp_pk PRIMARY KEY (sessionID,name)
);
CREATE TABLE fpSetting (
workgroupName VARCHAR(255) NOT NULL,
name VARCHAR(100) NOT NULL,
namespace VARCHAR(255) NOT NULL,
value LONG VARCHAR NOT NULL,
CONSTRAINT fpSetting_pk PRIMARY KEY (workgroupName, name, namespace)
);
CREATE TABLE fpSearchIndex (
workgroupID INTEGER NOT NULL,
lastUpdated CHAR(15) NOT NULL,
lastOptimization CHAR(15) NOT NULL,
CONSTRAINT fpSearchIndex_pk PRIMARY KEY (workgroupID)
);
CREATE TABLE fpWorkgroupRoster (
workgroupID INTEGER NOT NULL,
jid VARCHAR(255) NOT NULL,
lastContact CHAR(15),
CONSTRAINT fpRoster_pk PRIMARY KEY (workgroupID, jid)
);
CREATE INDEX fpWgRst_wgjid_idx ON fpWorkgroupRoster(workgroupID);
CREATE TABLE fpChatSetting(
workgroupNode varchar(100),
type INTEGER,
label varchar(100),
description varchar(255),
name varchar(100),
value LONG VARCHAR,
defaultValue LONG VARCHAR
);
CREATE INDEX fpChatSetting_idx ON fpChatSetting(workgroupNode, name);
CREATE TABLE fpOfflineSetting (
workgroupID INTEGER NOT NULL,
redirectPage varChar(255),
emailAddress varChar(255),
subject varChar(255),
offlineText LONG VARCHAR,
CONSTRAINT fpOfflineSet_pk PRIMARY KEY(workgroupID)
);
CREATE TABLE fpRouteRule (
workgroupID INTEGER NOT NULL,
queueID INTEGER NOT NULL,
rulePosition INTEGER NOT NULL,
query LONG VARCHAR
);
// $Revision$
// $Date$
INSERT INTO ofVersion (name, version) VALUES ('fastpath', 0);
CREATE TABLE fpWorkgroup (
workgroupID BIGINT NOT NULL,
jid VARCHAR(255) NOT NULL,
displayName VARCHAR(50) NULL,
description VARCHAR(255) NULL,
status INTEGER NOT NULL,
modes INTEGER NOT NULL,
creationDate VARCHAR(15) NOT NULL,
modificationDate VARCHAR(15) NOT NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
requestTimeout INTEGER NOT NULL,
offerTimeout INTEGER NOT NULL,
schedule varchar(4000) NULL,
PRIMARY KEY (workgroupID)
);
CREATE INDEX fpWorkgroup_workgroupid_idx ON fpWorkgroup (workgroupID);
CREATE TABLE fpWorkgroupProp (
ownerID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue VARCHAR(4000) NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpAgent (
agentID BIGINT NOT NULL,
agentJID VARCHAR(255) NOT NULL,
name VARCHAR(255) NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
PRIMARY KEY (agentJID)
);
CREATE INDEX fpAgent_agentid_idx ON fpAgent(agentID);
CREATE INDEX fpAgent_agentjid_idx ON fpAgent(agentJID);
CREATE TABLE fpAgentProp (
ownerID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue VARCHAR(4000) NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueue (
queueID BIGINT NOT NULL,
workgroupID BIGINT NOT NULL,
name VARCHAR(50) NOT NULL,
description VARCHAR(255) NULL,
priority INTEGER NOT NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
overflow INTEGER NOT NULL,
backupQueue BIGINT NULL,
PRIMARY KEY (workgroupID,queueID)
);
CREATE INDEX fpQueue_workgroupid_idx ON fpQueue(workgroupID);
CREATE INDEX fpQueue_queueid_idx ON fpQueue(queueID);
CREATE TABLE fpDispatcherProp (
ownerID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue varchar(4000) NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpDispatcher (
queueID BIGINT NOT NULL,
name VARCHAR(50) NULL,
description VARCHAR(255) NULL,
offerTimeout INTEGER NOT NULL,
requestTimeout INTEGER NOT NULL,
PRIMARY KEY (queueID)
);
CREATE TABLE fpQueueProp (
ownerID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue VARCHAR(4000) NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueueAgent (
queueID BIGINT NOT NULL,
objectID BIGINT NOT NULL,
objectType INTEGER NOT NULL,
administrator INTEGER NULL,
PRIMARY KEY (queueID,objectID,objectType)
);
CREATE TABLE fpQueueGroup (
queueID BIGINT NOT NULL,
groupName VARCHAR(1024),
PRIMARY KEY (queueID, groupName)
);
CREATE TABLE fpSession (
sessionID VARCHAR(31) NOT NULL,
userID VARCHAR(200) NOT NULL,
workgroupID BIGINT NOT NULL,
transcript LONGVARCHAR,
startTime CHAR(15) NOT NULL,
endTime CHAR(15) NOT NULL,
queueWaitTime BIGINT,
state INTEGER NOT NULL,
caseID VARCHAR(20),
status CHAR(15),
notes LONGVARCHAR,
PRIMARY KEY (sessionID)
);
CREATE INDEX fpSession_workgroupid_idx ON fpSession(workgroupID, userID);
CREATE INDEX fpSession_starttime_idx ON fpSession(workgroupID, startTime);
CREATE TABLE fpAgentSession (
sessionID VARCHAR(31) NOT NULL,
agentJID VARCHAR(255) NOT NULL,
joinTime CHAR(15) NOT NULL,
leftTime CHAR(15)
);
CREATE INDEX fpAgentSession_sessionid_idx ON fpAgentSession(sessionID);
CREATE TABLE fpSessionMetadata (
sessionID VARCHAR(31) NOT NULL,
metadataName VARCHAR(200) NOT NULL,
metadataValue VARCHAR(200) NOT NULL
);
CREATE TABLE fpSessionProp (
sessionID VARCHAR(31) NOT NULL,
name VARCHAR(100) NOT NULL,
propValue LONGVARCHAR NOT NULL,
PRIMARY KEY (sessionID,name)
);
CREATE TABLE fpSetting (
workgroupName VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
namespace VARCHAR(255) NOT NULL,
value LONGVARCHAR NOT NULL,
PRIMARY KEY (workgroupName, name, namespace)
);
CREATE TABLE fpSearchIndex (
workgroupID BIGINT NOT NULL,
lastUpdated CHAR(15) NOT NULL,
lastOptimization CHAR(15) NOT NULL,
PRIMARY KEY (workgroupID)
);
CREATE TABLE fpWorkgroupRoster (
workgroupID BIGINT NOT NULL,
jid VARCHAR(1024) NOT NULL,
lastContact CHAR(15) NULL,
PRIMARY KEY (workgroupID, jid)
);
CREATE INDEX fpWrkgrpRoster_workgroupjid_idx ON fpWorkgroupRoster(workgroupID);
CREATE TABLE fpChatSetting (
workgroupNode varchar(100),
type INTEGER,
label varchar(100),
description varchar(255),
name varchar(100),
value LONGVARCHAR,
defaultValue LONGVARCHAR
);
CREATE INDEX fpChatSetting_idx ON fpChatSetting(workgroupNode, name);
CREATE TABLE fpOfflineSetting (
workgroupID BIGINT NOT NULL,
redirectPage varChar(255),
emailAddress varChar(255),
subject varChar(255),
offlineText LONGVARCHAR,
PRIMARY KEY(workgroupID)
);
CREATE TABLE fpRouteRule (
workgroupID BIGINT NOT NULL,
queueID BIGINT NOT NULL,
rulePosition INT NOT NULL,
query LONGVARCHAR
);
# $Revision$
# $Date$
INSERT INTO ofVersion (name, version) VALUES ('fastpath', 0);
CREATE TABLE fpWorkgroup(
workgroupID BIGINT NOT NULL,
jid VARCHAR(255) NOT NULL,
displayName VARCHAR(50) NULL,
description VARCHAR(255) NULL,
status INTEGER NOT NULL,
modes INTEGER NOT NULL,
creationDate VARCHAR(15) NOT NULL,
modificationDate VARCHAR(15) NOT NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
requestTimeout INTEGER NOT NULL,
offerTimeout INTEGER NOT NULL,
schedule TEXT NULL,
PRIMARY KEY (workgroupID),
INDEX fpWorkgroup_workgroupid_idx(workgroupID)
);
CREATE TABLE fpWorkgroupProp (
ownerID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue MEDIUMTEXT NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpAgent(
agentID BIGINT NOT NULL,
agentJID VARCHAR(255) NOT NULL,
name VARCHAR(255) NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
PRIMARY KEY (agentJID),
INDEX fpagent_agentid_idx(agentID),
INDEX fpagent_agentjid_idx(agentJID)
);
CREATE TABLE fpAgentProp (
ownerID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueue(
queueID BIGINT NOT NULL,
workgroupID BIGINT NOT NULL,
name VARCHAR(50) NOT NULL,
description VARCHAR(255) NULL,
priority INTEGER NOT NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
overflow INTEGER NOT NULL,
backupQueue BIGINT NULL,
PRIMARY KEY (workgroupID,queueID),
INDEX fpqueue_workgroupid_idx(workgroupID),
INDEX fpqueue_queueid_idx(queueID)
);
CREATE TABLE fpDispatcherProp (
ownerID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpDispatcher(
queueID BIGINT NOT NULL,
name VARCHAR(50) NULL,
description VARCHAR(255) NULL,
offerTimeout INTEGER NOT NULL,
requestTimeout INTEGER NOT NULL,
PRIMARY KEY (queueID)
);
CREATE TABLE fpQueueProp (
ownerID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueueAgent (
queueID BIGINT NOT NULL,
objectID BIGINT NOT NULL,
objectType INTEGER NOT NULL,
administrator INTEGER NULL,
PRIMARY KEY (queueID,objectID,objectType)
);
CREATE TABLE fpQueueGroup (
queueID BIGINT NOT NULL,
groupName VARCHAR(50) NOT NULL,
PRIMARY KEY (queueID,groupName)
);
CREATE TABLE fpSession(
sessionID varchar(31) NOT NULL,
userID varchar(255) NOT NULL,
workgroupID BIGINT NOT NULL,
transcript TEXT,
startTime CHAR(15) NOT NULL,
endTime CHAR(15) NOT NULL,
queueWaitTime BIGINT,
state int NOT NULL,
caseID varchar(20),
status CHAR(15),
notes TEXT,
PRIMARY KEY (sessionID),
INDEX fpsession_workgroupid_idx(workgroupID, userID),
INDEX fpsession_starttime_idx(workgroupID, startTime)
);
CREATE TABLE fpAgentSession(
sessionID varchar(31) NOT NULL,
agentJID varchar(255) NOT NULL,
joinTime CHAR(15) NOT NULL,
leftTime CHAR(15),
INDEX fpagentsession_sessionid_idx(sessionID)
);
CREATE TABLE fpSessionMetadata(
sessionID varchar(31) NOT NULL,
metadataName varChar(200) NOT NULL,
metadataValue TEXT NOT NULL
);
CREATE TABLE fpSessionProp(
sessionID varchar(31) NOT NULL,
name varchar(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (sessionID,name)
);
CREATE TABLE fpSetting (
workgroupName VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
namespace VARCHAR(255) NOT NULL,
value TEXT NOT NULL,
PRIMARY KEY (workgroupName, name)
);
CREATE TABLE fpSearchIndex (
workgroupID BIGINT NOT NULL,
lastUpdated CHAR(15) NOT NULL,
lastOptimization CHAR(15) NOT NULL,
PRIMARY KEY (workgroupID)
);
CREATE TABLE fpWorkgroupRoster (
workgroupID BIGINT NOT NULL,
jid TEXT NOT NULL,
lastContact VARCHAR(15) NULL,
PRIMARY KEY (workgroupID, jid(255)),
INDEX fpWrkgrpRoster_workgroupjid_idx(workgroupID)
);
CREATE TABLE fpChatSetting(
workgroupNode varchar(100),
type int,
label varchar(100),
description varchar(255),
name varchar(100),
value text,
defaultValue text,
INDEX fpChatSetting_idx(workgroupNode, name)
);
CREATE TABLE fpOfflineSetting (
workgroupID BIGINT NOT NULL,
redirectPage varChar(255),
emailAddress varChar(255),
subject varChar(255),
offlineText TEXT,
PRIMARY KEY(workgroupID)
);
CREATE TABLE fpRouteRule (
workgroupID BIGINT NOT NULL,
queueID BIGINT NOT NULL,
rulePosition INT NOT NULL,
query TEXT
);
-- $Revision$
-- $Date$
INSERT INTO ofVersion (name, version) VALUES ('fastpath', 0);
CREATE TABLE fpWorkgroup(
workgroupID INT NOT NULL,
jid VARCHAR(255) NOT NULL,
displayName VARCHAR(50) NULL,
description VARCHAR(255) NULL,
status INT NOT NULL,
modes INT NOT NULL,
creationDate CHAR(15) NOT NULL,
modificationDate CHAR(15) NOT NULL,
maxchats INT NOT NULL,
minchats INT NOT NULL,
requestTimeout INT NOT NULL,
offerTimeout INT NOT NULL,
schedule VARCHAR(3900) NULL
);
CREATE INDEX fpWorkgroup_workgroupid_idx on fpWorkgroup(workgroupID);
CREATE TABLE fpWorkgroupProp (
ownerID INT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue LONG,
CONSTRAINT fpWorkgroupProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpAgent(
agentID INT NOT NULL,
agentJID VARCHAR(255) NOT NULL,
name VARCHAR(255) NULL,
maxchats INT NOT NULL,
minchats INT NOT NULL
);
CREATE INDEX fpagent_agentid_idx ON fpAgent(agentID);
CREATE INDEX fpagent_agentjid_idx ON fpAgent(agentJID);
CREATE TABLE fpAgentProp (
ownerID INT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue VARCHAR(3900) NOT NULL,
CONSTRAINT fpAgentProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueue(
queueID INT NOT NULL,
workgroupID INT NOT NULL,
name VARCHAR(50) NOT NULL,
description VARCHAR(255) NULL,
priority INT NOT NULL,
maxchats INT NOT NULL,
minchats INT NOT NULL,
overflow INT NOT NULL,
backupQueue INT NULL,
CONSTRAINT fpQueue_pk PRIMARY KEY (workgroupID,queueID)
);
CREATE INDEX fpqueue_workgroupid_idx ON fpQueue(workgroupID);
CREATE INDEX fpqueue_queueid_idx ON fpQueue(queueID);
CREATE TABLE fpDispatcherProp (
ownerID INT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue VARCHAR(3900) NOT NULL,
CONSTRAINT fpDispatcherProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpDispatcher(
queueID INT NOT NULL,
name VARCHAR(50) NULL,
description VARCHAR(255) NULL,
offerTimeout INT NOT NULL,
requestTimeout INT NOT NULL,
CONSTRAINT fpDispatcher_pk PRIMARY KEY (queueID)
);
CREATE TABLE fpQueueProp (
ownerID INT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue VARCHAR(3900) NOT NULL,
CONSTRAINT fpQueueProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueueAgent (
queueID INT NOT NULL,
objectID INT NOT NULL,
objectType INT NOT NULL,
administrator INT NULL,
CONSTRAINT jive_fpGroupQueue_pk PRIMARY KEY (queueID,objectID,objectType)
);
CREATE TABLE fpQueueGroup (
queueID INT NOT NULL,
groupName VARCHAR(50) NOT NULL,
CONSTRAINT jive_fpQueueGroup_pk PRIMARY KEY (queueID,groupName)
);
CREATE TABLE fpSession(
sessionID varchar(31) NOT NULL,
userID varchar(200) NOT NULL,
workgroupID INTEGER NOT NULL,
transcript LONG,
startTime CHAR(15) NOT NULL,
endTime CHAR(15) NOT NULL,
queueWaitTime INTEGER,
state int NOT NULL,
caseID varchar(20),
status CHAR(15),
notes VARCHAR(4000),
CONSTRAINT fpSession_pk PRIMARY KEY (sessionID)
);
CREATE INDEX fpsession_workgroupid_idx ON fpSession(workgroupID, userID);
CREATE INDEX fpsession_starttime_idx ON fpSession(workgroupID, startTime);
CREATE TABLE fpAgentSession(
sessionID varchar(31) NOT NULL,
agentJID varchar(255) NOT NULL,
joinTime CHAR(15) NOT NULL,
leftTime CHAR(15)
);
CREATE TABLE fpSessionMetadata(
sessionID varchar(31) NOT NULL,
metadataName varChar(200) NOT NULL,
metadataValue LONG NOT NULL
);
CREATE TABLE fpSessionProp(
sessionID varchar(31) NOT NULL,
name varchar(100) NOT NULL,
propValue LONG NOT NULL,
CONSTRAINT fpSessionProp_pk PRIMARY KEY (sessionID,name)
);
CREATE TABLE fpSetting (
workgroupName VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
namespace VARCHAR(255) NOT NULL,
value LONG NOT NULL,
CONSTRAINT fpSetting_pk PRIMARY KEY (workgroupName, name, namespace)
);
CREATE TABLE fpSearchIndex (
workgroupID INTEGER NOT NULL,
lastUpdated CHAR(15) NOT NULL,
lastOptimization CHAR(15) NOT NULL,
PRIMARY KEY (workgroupID)
);
CREATE TABLE fpWorkgroupRoster (
workgroupID INTEGER NOT NULL,
jid VARCHAR2(1024) NOT NULL,
lastContact CHAR(15) NULL,
CONSTRAINT fpWorkgroupRoster_pk PRIMARY KEY (workgroupID, jid)
);
CREATE INDEX fpWrkgrpRoster_wrkgrpjid_idx ON fpWorkgroupRoster(workgroupID);
CREATE TABLE fpChatSetting(
workgroupNode VARCHAR2(100),
type INTEGER,
label VARCHAR2(100),
description VARCHAR2(255),
name VARCHAR2(100),
value LONG,
defaultValue VARCHAR2(4000)
);
CREATE INDEX fpChat_workgroupNode_idx ON fpChatSetting(workgroupNode, name);
CREATE TABLE fpOfflineSetting (
workgroupID INTEGER NOT NULL,
redirectPage VARCHAR2(255),
emailAddress VARCHAR2(255),
subject VARCHAR2(255),
offlineText LONG,
PRIMARY KEY(workgroupID)
);
CREATE TABLE fpRouteRule (
workgroupID INTEGER NOT NULL,
queueID INTEGER NOT NULL,
rulePosition INT NOT NULL,
query LONG
);
-- $Revision$
-- $Date$
INSERT INTO ofVersion (name, version) VALUES ('fastpath', 0);
CREATE TABLE fpWorkgroup(
workgroupID INTEGER NOT NULL,
jid VARCHAR(255) NOT NULL,
displayName VARCHAR(50) NULL,
description VARCHAR(255) NULL,
status INTEGER NOT NULL,
modes INTEGER NOT NULL,
creationDate VARCHAR(15) NOT NULL,
modificationDate VARCHAR(15) NOT NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
requestTimeout INTEGER NOT NULL,
offerTimeout INTEGER NOT NULL,
schedule TEXT NULL,
PRIMARY KEY (workgroupID)
);
CREATE INDEX fpWorkgroup_workgroupid_idx ON fpWorkgroup (workgroupID);
CREATE TABLE fpWorkgroupProp (
ownerID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpAgent(
agentID INTEGER NOT NULL,
agentJID VARCHAR(255) NOT NULL,
name VARCHAR(255) NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
PRIMARY KEY (agentJID)
);
CREATE INDEX fpagent_agentid_idx ON fpagent(agentID);
CREATE INDEX fpagent_agentjid_idx ON fpagent(agentJID);
CREATE TABLE fpAgentProp (
ownerID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueue(
queueID INTEGER NOT NULL,
workgroupID INTEGER NOT NULL,
name VARCHAR(50) NOT NULL,
description VARCHAR(255) NULL,
priority INTEGER NOT NULL,
maxchats INTEGER NOT NULL,
minchats INTEGER NOT NULL,
overflow INTEGER NOT NULL,
backupQueue INTEGER NULL,
PRIMARY KEY (workgroupID,queueID)
);
CREATE INDEX fpqueue_workgroupid_idx ON fpqueue(workgroupID);
CREATE INDEX fpqueue_queueid_idx ON fpqueue(queueID);
CREATE TABLE fpDispatcherProp (
ownerID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpDispatcher(
queueID INTEGER NOT NULL,
name VARCHAR(50) NULL,
description VARCHAR(255) NULL,
offerTimeout INTEGER NOT NULL,
requestTimeout INTEGER NOT NULL,
PRIMARY KEY (queueID)
);
CREATE TABLE fpQueueProp (
ownerID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueueAgent (
queueID INTEGER NOT NULL,
objectID INTEGER NOT NULL,
objectType INTEGER NOT NULL,
administrator INTEGER NULL,
PRIMARY KEY (queueID,objectID,objectType)
);
CREATE TABLE fpQueueGroup (
queueID INTEGER NOT NULL,
groupName VARCHAR(50) NOT NULL,
PRIMARY KEY (queueID,groupName)
);
CREATE TABLE fpSession(
sessionID varchar(31) NOT NULL,
userID varchar(200) NOT NULL,
workgroupID INTEGER NOT NULL,
transcript TEXT,
startTime CHAR(15) NOT NULL,
endTime CHAR(15) NOT NULL,
queueWaitTime INTEGER,
state INTEGER NOT NULL,
caseID varchar(20),
status CHAR(15),
notes TEXT,
PRIMARY KEY (sessionID)
);
CREATE INDEX fpsession_workgroupid_idx ON fpSession(workgroupID, userID);
CREATE INDEX fpsession_starttime_idx ON fpSession(workgroupID, startTime);
CREATE TABLE fpAgentSession(
sessionID varchar(31) NOT NULL,
agentJID varchar(255) NOT NULL,
joinTime CHAR(15) NOT NULL,
leftTime CHAR(15)
);
CREATE INDEX fpagentsession_sessionid_idx ON fpSession(sessionID);
CREATE TABLE fpSessionMetadata(
sessionID varchar(31) NOT NULL,
metadataName varChar(200) NOT NULL,
metadataValue varChar(200) NOT NULL
);
CREATE TABLE fpSessionProp(
sessionID varchar(31) NOT NULL,
name varchar(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (sessionID,name)
);
CREATE TABLE fpSetting (
workgroupName VARCHAR(255) NOT NULL,
name VARCHAR(100) NOT NULL,
namespace VARCHAR(255) NOT NULL,
value TEXT NOT NULL,
PRIMARY KEY (workgroupName, name, namespace)
);
CREATE TABLE fpSearchIndex (
workgroupID INTEGER NOT NULL,
lastUpdated CHAR(15) NOT NULL,
lastOptimization CHAR(15) NOT NULL,
PRIMARY KEY (workgroupID)
);
CREATE TABLE fpWorkgroupRoster (
workgroupID INTEGER NOT NULL,
jid VARCHAR(1024) NOT NULL,
lastContact CHAR(15) NULL,
PRIMARY KEY (workgroupID, jid)
);
CREATE INDEX fpWrkgrpRoster_workgroupjid_idx ON fpWorkgroupRoster(workgroupID);
CREATE TABLE fpChatSetting (
workgroupNode varchar(100),
type INTEGER,
label varchar(100),
description varchar(255),
name varchar(100),
value TEXT,
defaultValue TEXT
);
CREATE INDEX fpChatSettings_idx ON fpChatSetting(workgroupNode, name);
CREATE TABLE fpOfflineSetting (
workgroupID INTEGER NOT NULL,
redirectPage varChar(255),
emailAddress varChar(255),
subject varChar(255),
offlineText TEXT,
PRIMARY KEY(workgroupID)
);
CREATE TABLE fpRouteRule (
workgroupID INTEGER NOT NULL,
queueID INTEGER NOT NULL,
rulePosition INTEGER NOT NULL,
query TEXT
);
/* $Revision$ */
/* $Date$ */
INSERT INTO ofVersion (name, version) VALUES ('fastpath', 0);
CREATE TABLE fpWorkgroup(
workgroupID INT NOT NULL,
jid VARCHAR(255) NOT NULL,
displayName NVARCHAR(50) NULL,
description NVARCHAR(255) NULL,
status INT NOT NULL,
modes INT NOT NULL,
creationDate CHAR(15) NOT NULL,
modificationDate CHAR(15) NOT NULL,
maxchats INT NOT NULL,
minchats INT NOT NULL,
requestTimeout INT NOT NULL,
offerTimeout INT NOT NULL,
schedule NVARCHAR(3400) NULL,
CONSTRAINT fpWorkgroup_pk PRIMARY KEY (workgroupID)
);
CREATE INDEX fpWorkgroup_workgroupid_idx on fpWorkgroup(workgroupID);
CREATE TABLE fpWorkgroupProp (
ownerID INT NOT NULL,
name NVARCHAR(100) NOT NULL,
propValue TEXT,
CONSTRAINT fpWorkgroupProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpAgent(
agentID INT NOT NULL,
agentJID NVARCHAR(255) NOT NULL,
name NVARCHAR(255) NULL,
maxchats INT NOT NULL,
minchats INT NOT NULL,
CONSTRAINT fpAgent_pk PRIMARY KEY (agentJID)
);
CREATE INDEX fpagent_agentid_idx ON fpAgent(agentID);
CREATE INDEX fpagent_agentjid_idx ON fpAgent(agentJID);
CREATE TABLE fpAgentProp (
ownerID INT NOT NULL,
name NVARCHAR(100) NOT NULL,
propValue NVARCHAR(3900) NOT NULL,
CONSTRAINT fpAgentProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueue(
queueID INT NOT NULL,
workgroupID INT NOT NULL,
name NVARCHAR(50) NOT NULL,
description NVARCHAR(255) NULL,
priority INT NOT NULL,
maxchats INT NOT NULL,
minchats INT NOT NULL,
overflow INT NOT NULL,
backupQueue INT NULL,
CONSTRAINT fpQueue_pk PRIMARY KEY (workgroupID,queueID)
);
CREATE INDEX fpqueue_workgroupid_idx ON fpQueue(workgroupID);
CREATE INDEX fpqueue_queueid_idx ON fpQueue(queueID);
CREATE TABLE fpDispatcherProp (
ownerID INT NOT NULL,
name NVARCHAR(100) NOT NULL,
propValue NVARCHAR(3900) NOT NULL,
CONSTRAINT fpDispatcherProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpDispatcher(
queueID INT NOT NULL,
name NVARCHAR(50) NULL,
description NVARCHAR(255) NULL,
offerTimeout INT NOT NULL,
requestTimeout INT NOT NULL,
CONSTRAINT fpDispatcher_pk PRIMARY KEY (queueID)
);
CREATE TABLE fpQueueProp (
ownerID INT NOT NULL,
name NVARCHAR(100) NOT NULL,
propValue NVARCHAR(3900) NOT NULL,
CONSTRAINT fpQueueProp_pk PRIMARY KEY (ownerID,name)
);
CREATE TABLE fpQueueAgent (
queueID INT NOT NULL,
objectID INT NOT NULL,
objectType INT NOT NULL,
administrator INT NULL,
CONSTRAINT jive_fpGroupQueue_pk PRIMARY KEY (queueID,objectID,objectType)
);
CREATE TABLE fpQueueGroup (
queueID INT NOT NULL,
groupName NVARCHAR(50) NOT NULL,
CONSTRAINT jive_fpQueueAgent_pk PRIMARY KEY (queueID,groupName)
);
CREATE TABLE fpSession(
sessionID NVARCHAR(31) NOT NULL,
userID NVARCHAR(200) NOT NULL,
workgroupID INT NOT NULL,
transcript TEXT,
startTime CHAR(15) NOT NULL,
endTime CHAR(15) NOT NULL,
queueWaitTime INT,
state int NOT NULL,
caseID NVARCHAR(20),
status CHAR(15),
notes TEXT,
CONSTRAINT fpSession_pk PRIMARY KEY (sessionID)
);
CREATE INDEX fpsession_workgroupid_idx ON fpSession(workgroupID, userID);
CREATE INDEX fpsession_starttime_idx ON fpSession(workgroupID, startTime);
CREATE TABLE fpAgentSession(
sessionID NVARCHAR(31) NOT NULL,
agentJID NVARCHAR(255) NOT NULL,
joinTime CHAR(15) NOT NULL,
leftTime CHAR(15)
);
CREATE INDEX fpagentsession_sessionid_idx ON fpSession(sessionID);
CREATE TABLE fpSessionMetadata(
sessionID NVARCHAR(31) NOT NULL,
metadataName NVARCHAR(200) NOT NULL,
metadataValue TEXT NOT NULL
);
CREATE TABLE fpSessionProp(
sessionID NVARCHAR(31) NOT NULL,
name NVARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
CONSTRAINT fpSessionProp_pk PRIMARY KEY (sessionID,name)
);
CREATE TABLE fpSetting (
workgroupName NVARCHAR(100) NOT NULL,
name NVARCHAR(100) NOT NULL,
namespace NVARCHAR(245) NOT NULL,
value TEXT NOT NULL,
CONSTRAINT fpSetting_pk PRIMARY KEY (workgroupName, name, namespace)
);
CREATE TABLE fpSearchIndex (
workgroupID INT NOT NULL,
lastUpdated CHAR(15) NOT NULL,
lastOptimization CHAR(15) NOT NULL,
CONSTRAINT fpSearchIndex_pk PRIMARY KEY (workgroupID)
);
CREATE TABLE fpWorkgroupRoster (
workgroupID INT NOT NULL,
jid NVARCHAR(444) NOT NULL,
lastContact CHAR(15) NULL,
CONSTRAINT fpWorkgroupRoster_pk PRIMARY KEY (workgroupID, jid)
);
CREATE INDEX fpWrkgrpRoster_workgroupjid_idx ON fpWorkgroupRoster(workgroupID);
CREATE TABLE fpChatSetting (
workgroupNode NVARCHAR(100),
type INT,
label NVARCHAR(100),
description NVARCHAR(255),
name NVARCHAR(100),
value TEXT,
defaultValue TEXT
);
CREATE INDEX fpChatSetting_idx ON fpChatSetting(workgroupNode, name);
CREATE TABLE fpOfflineSetting (
workgroupID INT NOT NULL,
redirectPage NVARCHAR(255),
emailAddress NVARCHAR(255),
subject NVARCHAR(255),
offlineText TEXT,
CONSTRAINT fpOfflineSetting_pk PRIMARY KEY(workgroupID)
);
CREATE TABLE fpRouteRule (
workgroupID INT NOT NULL,
queueID INT NOT NULL,
rulePosition INT NOT NULL,
query TEXT
);
/**
* $Revision: $
* $Date: $
*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.user.UserNameManager;
import org.jivesoftware.openfire.user.UserNameProvider;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.openfire.cluster.ClusterEventListener;
import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.fastpath.util.TaskEngine;
import org.jivesoftware.xmpp.workgroup.WorkgroupManager;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.component.ComponentException;
import org.xmpp.packet.JID;
import java.io.File;
import java.io.FileFilter;
/**
* Openfire Fastpath plugin.
*
* @author Matt Tucker
*/
public class FastpathPlugin implements Plugin, ClusterEventListener {
/**
* Keep a reference to Fastpath only when the service is up and running in this JVM.
*/
private WorkgroupManager workgroupManager;
public void initializePlugin(PluginManager manager, File pluginDirectory) {
System.out.println("Starting Fastpath Server");
// Check if we Enterprise is installed and stop loading this plugin if found
File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
File[] jars = pluginDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
String fileName = pathname.getName().toLowerCase();
return (fileName.equalsIgnoreCase("enterprise.jar"));
}
});
if (jars.length > 0) {
// Do not load this plugin since Enterprise is still installed
System.out.println("Enterprise plugin found. Stopping Fastpath Plugin");
throw new IllegalStateException("This plugin cannot run next to the Enterprise plugin");
}
// Make sure that the fastpath folder exists under the home directory
File fastpathDir = new File(JiveGlobals.getHomeDirectory() +
File.separator + "fastpath");
if (!fastpathDir.exists()) {
fastpathDir.mkdirs();
}
workgroupManagerStart();
// Listen to cluster events
ClusterManager.addListener(this);
}
public void destroyPlugin() {
workgroupManagerStop();
// Stop listen to cluster events
ClusterManager.removeListener(this);
// Dispose pending tasks
TaskEngine.getInstance().dispose();
}
private void workgroupManagerStart() {
workgroupManager = WorkgroupManager.getInstance();
// Register Fastpath service
try {
ComponentManagerFactory.getComponentManager().addComponent("workgroup", workgroupManager);
}
catch (ComponentException e) {
// Do nothing. Should never happen.
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
// Register the provider of workgroup names
UserNameManager.addUserNameProvider(workgroupManager.getAddress().toString(),
new UserNameProvider() {
public String getUserName(JID entity) {
try {
Workgroup workgroup = workgroupManager.getWorkgroup(entity);
return workgroup.getDisplayName();
}
catch (UserNotFoundException e) {
return entity.toString();
}
}
});
// Start the Fastpath module
workgroupManager.start();
}
private void workgroupManagerStop() {
// Unregister workgroup component
try {
ComponentManagerFactory.getComponentManager().removeComponent("workgroup");
}
catch (ComponentException e) {
Log.error("Error unregistering workgroup component", e);
}
if (workgroupManager != null) {
// Unregister the provider of workgroup names
UserNameManager.removeUserNameProvider(workgroupManager.getAddress().toString());
// Stop the Fastpath module
workgroupManager.stop();
}
// Clean up the reference to the workgroup manager as a way to say that FP is no longer running in this JVM
workgroupManager = null;
}
public void joinedCluster() {
workgroupManagerStop();
}
public void joinedCluster(byte[] nodeID) {
// Do nothing
}
public void leftCluster() {
workgroupManagerStart();
}
public void leftCluster(byte[] nodeID) {
// Do nothing
}
public void markedAsSeniorClusterMember() {
workgroupManagerStart();
}
}
package org.jivesoftware.openfire.fastpath;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupManager;
import org.jivesoftware.openfire.fastpath.settings.chat.ChatSettingsManager;
import org.jivesoftware.openfire.fastpath.settings.chat.ChatSettings;
import org.jivesoftware.openfire.fastpath.settings.chat.ChatSetting;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.packet.JID;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.openfire.user.UserNotFoundException;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* A servlet that displays images.
*/
public class ImageServlet extends HttpServlet {
/**
* The content-type of the images to return.
*/
private static final String CONTENT_TYPE = "image/jpeg";
private ChatSettingsManager chatSettingsManager;
public void init(ServletConfig config) throws ServletException {
super.init(config);
// Initialize chat settings manager.
chatSettingsManager = ChatSettingsManager.getInstance();
}
/**
* Retrieve the image based on it's name.
*
* @param request the httpservletrequest.
* @param response the httpservletresponse.
* @throws ServletException
* @throws IOException
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String imageName = request.getParameter("imageName");
String workgroupName = (String)request.getSession().getAttribute("workgroup");
if (workgroupName == null) {
workgroupName = request.getParameter("workgroup");
}
byte[] bytes = getImage(imageName, workgroupName);
if (bytes != null) {
writeBytesToStream(bytes, response);
}
}
/**
* Writes out a <code>byte</code> to the ServletOuputStream.
*
* @param bytes the bytes to write to the <code>ServletOutputStream</code>.
* @param response the HttpServeltResponse.
*/
public void writeBytesToStream(byte[] bytes, HttpServletResponse response) {
if (bytes == null) {
return;
}
response.setContentType(CONTENT_TYPE);
// Send back image
try {
ServletOutputStream sos = response.getOutputStream();
sos.write(bytes);
sos.flush();
sos.close();
}
catch (IOException e) {
// Ignore.
}
}
/**
* Returns the image bytes of the encoded image.
*
* @param imageName the name of the image.
* @param workgroupName the name of the workgroup.
* @return the image bytes found, otherwise null.
*/
public byte[] getImage(String imageName, String workgroupName) {
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
JID workgroupJID = new JID(workgroupName);
Workgroup workgroup;
try {
workgroup = workgroupManager.getWorkgroup(workgroupJID);
}
catch (UserNotFoundException e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
return null;
}
ChatSettings chatSettings = chatSettingsManager.getChatSettings(workgroup);
ChatSetting setting = chatSettings.getChatSetting(imageName);
String encodedValue = setting.getValue();
if (encodedValue == null) {
return null;
}
return StringUtils.decodeBase64(encodedValue);
}
}
\ No newline at end of file
/**
* $RCSfile: ,v $
* $Revision: 1.0 $
* $Date: 2005/05/25 04:20:03 $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupManager;
import org.xmpp.packet.JID;
import org.xmpp.component.ComponentManagerFactory;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.openfire.user.UserNotFoundException;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet that writes out sound files.
*/
public class SoundServlet extends HttpServlet {
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doGet(request, response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String workgroupName = request.getParameter("workgroup");
String action = request.getParameter("action");
Workgroup workgroup = null;
try {
workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(workgroupName));
}
catch (UserNotFoundException e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
try {
response.setContentType("audio/wav");
if (action != null) {
if ("incoming".equals(action.trim())) {
String incomingMessage = workgroup.getProperties().getProperty("incomingSound");
byte[] incomingBytes = StringUtils.decodeBase64(incomingMessage);
response.getOutputStream().write(incomingBytes);
}
else if ("outgoing".equals(action.trim())) {
String outgoingMessage = workgroup.getProperties().getProperty("outgoingSound");
String outgoingBytes = StringUtils.encodeBase64(outgoingMessage);
response.getOutputStream().write(outgoingBytes.getBytes("UTF-8"));
}
}
}
catch (Exception e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
}
}
\ No newline at end of file
/**
* $RCSfile$
* $Revision: 19545 $
* $Date: 2005-08-18 16:07:35 -0700 (Thu, 18 Aug 2005) $
*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import java.io.StringWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
* Workgroup settings for saving individual workgroup information.
*
* @author Derek DeMoro
*/
public class WorkgroupSettings {
private static final String LOAD_SETTINGS =
"SELECT value FROM fpSetting WHERE workgroupName=? AND namespace=?";
private static final String INSERT_SETTINGS =
"INSERT INTO fpSetting (value,name,workgroupName,namespace) VALUES (?,?,?,?)";
private static final String UPDATE_SETTINGS =
"UPDATE fpSetting SET value=?, name=? WHERE workgroupName=? AND namespace=?";
/**
* Constructs a new <code>WorkgroupSettings</code> instance.
*/
public WorkgroupSettings() {
}
/**
* Stores private data. If the name and namespace of the element matches another
* stored private data XML document, then replace it with the new one.
*
* @param data the data to store (XML element)
* @param workgroupName the name of the workgroup where the data should be stored.
*/
public void add(String workgroupName, Element data) {
Connection con = null;
PreparedStatement pstmt = null;
try {
StringWriter writer = new StringWriter();
data.write(writer);
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(LOAD_SETTINGS);
pstmt.setString(1, workgroupName);
pstmt.setString(2, data.getNamespaceURI());
ResultSet rs = pstmt.executeQuery();
boolean update = false;
if (rs.next()) {
update = true;
}
rs.close();
pstmt.close();
if (update) {
pstmt = con.prepareStatement(UPDATE_SETTINGS);
}
else {
pstmt = con.prepareStatement(INSERT_SETTINGS);
}
DbConnectionManager.setLargeTextField(pstmt, 1, writer.toString());
pstmt.setString(2, data.getName());
pstmt.setString(3, workgroupName);
pstmt.setString(4, data.getNamespaceURI());
pstmt.executeUpdate();
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
}
/**
* Returns the data stored under a key corresponding to the name and namespace
* of the given element. The Element must be in the form:<p>
*
* <code>&lt;name xmlns='namespace'/&gt;</code><p>
*
* If no data is currently stored under the given key, an empty element will be
* returned.
*
* @param data an XML document who's element name and namespace is used to
* match previously stored private data.
* @param workgroupName the name of the workgroup who's data is to be stored.
* @return the data stored under the given key or the data element.
*/
public Element get(String workgroupName, Element data) {
data.clearContent();
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(LOAD_SETTINGS);
pstmt.setString(1, workgroupName);
pstmt.setString(2, data.getNamespaceURI());
rs = pstmt.executeQuery();
if (rs.next()) {
Document document = DocumentHelper.parseText(rs.getString(1).trim());
data = document.getRootElement();
}
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
return data;
}
}
\ No newline at end of file
/**
* $Revision$
* $Date$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.commands;
import org.jivesoftware.openfire.fastpath.util.WorkgroupUtils;
import org.dom4j.Element;
import org.jivesoftware.openfire.commands.AdHocCommand;
import org.jivesoftware.openfire.commands.SessionData;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.util.StringUtils;
import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField;
import org.xmpp.packet.JID;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* Command that allows to create new workgroups.
*
* @author Gaston Dombiak
*
* TODO Use i18n
*/
public class CreateWorkgroup extends AdHocCommand {
public String getCode() {
return "http://jabber.org/protocol/admin#add-workgroup";
}
public String getDefaultLabel() {
return "Add a Workgroup";
}
public int getMaxStages(SessionData data) {
return 1;
}
public void execute(SessionData sessionData, Element command) {
Element note = command.addElement("note");
Map<String, List<String>> data = sessionData.getData();
// Get the name of the new workgroup
String wgName= get(data, "name", 0);
String description = get(data, "description", 0);
List<String> members = data.get("members");
String agents = StringUtils.collectionToString(members);
if (wgName == null) {
note.addAttribute("type", "error");
note.setText("Please specify the name of the workgroup.");
return;
}
Map errors = WorkgroupUtils.createWorkgroup(wgName, description, agents);
if (!errors.isEmpty()) {
note.addAttribute("type", "error");
// TODO check errors. give better error message
note.setText("Error creating workgroup.");
return;
}
// Answer that the operation was successful
note.addAttribute("type", "info");
note.setText("Operation finished successfully");
}
protected void addStageInformation(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.form);
form.setTitle("Adding a new workgroup");
form.addInstruction("Fill out this form to add a workgroup.");
FormField field = form.addField();
field.setType(FormField.Type.hidden);
field.setVariable("FORM_TYPE");
field.addValue("http://jabber.org/protocol/admin");
field = form.addField();
field.setType(FormField.Type.text_single);
field.setLabel("The name of the workgroup to be added");
field.setVariable("name");
field.setRequired(true);
field = form.addField();
field.setType(FormField.Type.text_multi);
field.setLabel("Username of the members");
field.setVariable("members");
field = form.addField();
field.setType(FormField.Type.text_single);
field.setLabel("Description");
field.setVariable("description");
// Add the form to the command
command.add(form.getElement());
}
protected List<Action> getActions(SessionData data) {
return Arrays.asList(AdHocCommand.Action.complete);
}
protected AdHocCommand.Action getExecuteAction(SessionData data) {
return AdHocCommand.Action.complete;
}
public boolean hasPermission(JID requester) {
return super.hasPermission(requester) && !UserManager.getUserProvider().isReadOnly();
}
}
/**
* $Revision$
* $Date$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.commands;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupManager;
import org.dom4j.Element;
import org.jivesoftware.openfire.commands.AdHocCommand;
import org.jivesoftware.openfire.commands.SessionData;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField;
import org.xmpp.packet.JID;
import java.util.Arrays;
import java.util.List;
/**
* Command that allows to delete existing workgroups.
*
* @author Gaston Dombiak
*
* TODO Use i18n
*/
public class DeleteWorkgroup extends AdHocCommand {
protected void addStageInformation(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.form);
form.setTitle("Delete workgroup");
form.addInstruction("Fill out this form to delete a workgroup.");
FormField field = form.addField();
field.setType(FormField.Type.hidden);
field.setVariable("FORM_TYPE");
field.addValue("http://jabber.org/protocol/admin");
field = form.addField();
field.setType(FormField.Type.jid_single);
field.setLabel("Workgroup's JID");
field.setVariable("workgroup");
field.setRequired(true);
// Add the form to the command
command.add(form.getElement());
}
public void execute(SessionData data, Element command) {
Element note = command.addElement("note");
// Get requested group
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
// Load the workgroup
try {
Workgroup workgroup = workgroupManager.getWorkgroup(new JID(data.getData().get("workgroup").get(0)));
workgroupManager.deleteWorkgroup(workgroup);
} catch (UserNotFoundException e) {
// Group not found
note.addAttribute("type", "error");
note.setText("Workgroup not found");
return;
} catch (Exception e) {
// Group not found
note.addAttribute("type", "error");
note.setText("Error executing the command");
return;
}
note.addAttribute("type", "info");
note.setText("Operation finished successfully");
}
public String getCode() {
return "http://jabber.org/protocol/admin#delete-workgroup";
}
public String getDefaultLabel() {
return "Delete workgroup";
}
protected List<Action> getActions(SessionData data) {
return Arrays.asList(AdHocCommand.Action.complete);
}
protected AdHocCommand.Action getExecuteAction(SessionData data) {
return AdHocCommand.Action.complete;
}
public int getMaxStages(SessionData data) {
return 1;
}
}
/**
* $RCSfile$
* $Revision: 19160 $
* $Date: 2005-06-27 16:18:17 -0700 (Mon, 27 Jun 2005) $
*
* Copyright (C) 1999-2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.dataforms;
import java.util.ArrayList;
import java.util.List;
public class FormElement {
private int position;
private String label;
private WorkgroupForm.FormEnum answerType;
private List<String> answers = new ArrayList<String>();
private boolean required;
private boolean visible;
private String variable;
private String description;
public FormElement() {
}
public int getPosition() {
return position;
}
public void setPosition(int position) {
this.position = position;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public List<String> getAnswers() {
return answers;
}
public void setAnswers(List<String> answers) {
this.answers = answers;
}
public boolean isRequired() {
return required;
}
public void setRequired(boolean required) {
this.required = required;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public WorkgroupForm.FormEnum getAnswerType() {
return answerType;
}
public void setAnswerType(WorkgroupForm.FormEnum answerType) {
this.answerType = answerType;
}
public void setAnswerType(String type) {
for (WorkgroupForm.FormEnum formType : WorkgroupForm.FormEnum.values()) {
if (formType.toString().equals(type)) {
setAnswerType(formType);
}
}
}
public String getVariable(){
return variable;
}
public void setVariable(String variable){
this.variable = variable;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
/**
* $RCSfile$
* $Revision: 27972 $
* $Date: 2006-03-02 11:38:43 -0800 (Thu, 02 Mar 2006) $
*
* Copyright (C) 1999-2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.dataforms;
import org.jivesoftware.xmpp.workgroup.DbProperties;
import org.jivesoftware.xmpp.workgroup.UnauthorizedException;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupManager;
import com.thoughtworks.xstream.XStream;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class FormManager {
private static FormManager singleton = new FormManager();
private Map<Workgroup, WorkgroupForm> forms = new ConcurrentHashMap<Workgroup, WorkgroupForm>();
/**
* Returns the singleton instance of <CODE>FormManager</CODE>,
* creating it if necessary.
* <p/>
*
* @return the singleton instance of <Code>FormManager</CODE>
*/
public static FormManager getInstance() {
return singleton;
}
private FormManager() {
// Prevent initialization
loadWebForms();
}
public void addWorkgroupForm(Workgroup workgroup, WorkgroupForm workgroupForm) {
forms.put(workgroup, workgroupForm);
}
public WorkgroupForm getWebForm(Workgroup workgroup) {
return forms.get(workgroup);
}
public void removeForm(Workgroup workgroup) {
forms.remove(workgroup);
}
public void saveWorkgroupForm(Workgroup workgroup) {
// Save Web Form for editing
WorkgroupForm workgroupForm = getWebForm(workgroup);
if (workgroupForm != null) {
XStream xstream = new XStream();
String xmlToSave = xstream.toXML(workgroupForm);
DbProperties props = workgroup.getProperties();
String context = "jive.webform.wg";
try {
props.deleteProperty(context);
props.setProperty(context, xmlToSave);
}
catch (UnauthorizedException e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
}
// Save DataForm for usage
saveDataForm(workgroup);
}
private void saveDataForm(Workgroup workgroup) {
DataForm dataForm = new DataForm(DataForm.Type.form);
WorkgroupForm form = getWebForm(workgroup);
if (form.getTitle() != null) {
dataForm.setTitle(form.getTitle());
}
if (form.getDescription() != null) {
dataForm.addInstruction(form.getDescription());
}
List<FormElement> elems = new ArrayList<FormElement>();
// Add normal elems
int size = form.getFormElements().size();
for (int j = 0; j < size; j++) {
elems.add(form.getFormElementAt(j));
}
size = form.getHiddenVars().size();
for (int k = 0; k < size; k++) {
elems.add(form.getHiddenVars().get(k));
}
size = elems.size();
for (int i = 0; i < size; i++) {
FormElement elem = elems.get(i);
FormField field = dataForm.addField();
field.setLabel(elem.getLabel());
field.setVariable(elem.getVariable());
field.setRequired(elem.isRequired());
if (elem.getDescription() != null) {
field.setDescription(elem.getDescription());
}
if (elem.getAnswerType() == WorkgroupForm.FormEnum.textarea) {
field.setType(FormField.Type.text_multi);
}
else if (elem.getAnswerType() == WorkgroupForm.FormEnum.textfield) {
field.setType(FormField.Type.text_single);
}
else if (elem.getAnswerType() == WorkgroupForm.FormEnum.checkbox) {
field.setType(FormField.Type.boolean_type);
}
else if (elem.getAnswerType() == WorkgroupForm.FormEnum.radio_button) {
field.setType(FormField.Type.list_multi);
}
else if (elem.getAnswerType() == WorkgroupForm.FormEnum.dropdown_box) {
field.setType(FormField.Type.list_single);
}
else if(elem.getAnswerType() == WorkgroupForm.FormEnum.hidden){
field.setType(FormField.Type.hidden);
} else if (elem.getAnswerType() == WorkgroupForm.FormEnum.password) {
field.setType(FormField.Type.text_private);
}
if (elem.getAnswers().size() > 0 && elem.getAnswerType() != WorkgroupForm.FormEnum.hidden) {
Iterator iter = elem.getAnswers().iterator();
while (iter.hasNext()) {
String item = (String)iter.next();
field.addOption(item, item);
}
}
else if (elem.getAnswers().size() > 0) {
// Add hidden element values.
Iterator iter = elem.getAnswers().iterator();
while (iter.hasNext()) {
String item = (String)iter.next();
field.addValue(item);
}
}
}
XStream xstream = new XStream();
String xmlToSave = xstream.toXML(dataForm);
DbProperties props = workgroup.getProperties();
String context = "jive.dataform.wg";
try {
props.deleteProperty(context);
props.setProperty(context, xmlToSave);
}
catch (UnauthorizedException e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
}
public DataForm getDataForm(Workgroup workgroup) {
DbProperties props = workgroup.getProperties();
String context = "jive.dataform.wg";
String form = props.getProperty(context);
if (form != null) {
XStream xstream = new XStream();
xstream.setClassLoader(this.getClass().getClassLoader());
try {
return (DataForm) xstream.fromXML(form);
}
catch (Exception e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
}
return null;
}
private void loadWebForms() {
final WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
for (Workgroup workgroup : workgroupManager.getWorkgroups()) {
DbProperties props = workgroup.getProperties();
String context = "jive.webform.wg";
String form = props.getProperty(context);
if (form != null) {
XStream xstream = new XStream();
xstream.setClassLoader(this.getClass().getClassLoader());
try {
Object object = xstream.fromXML(form);
WorkgroupForm workgroupForm = (WorkgroupForm)object;
if (workgroupForm != null) {
addWorkgroupForm(workgroup, workgroupForm);
}
}
catch (Exception e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
}
else {
// Create a default Web Form
createGenericForm(workgroup);
}
}
}
/**
* Creates a new generic dataform for the Workgroup if one does not exist.
*
* @param workgroup the workgroup without a dataform.
*/
public void createGenericForm(Workgroup workgroup) {
WorkgroupForm workgroupForm = new WorkgroupForm();
FormElement username = new FormElement();
username.setRequired(true);
username.setAnswerType(WorkgroupForm.FormEnum.textfield);
username.setVariable("username");
username.setLabel("Name:");
workgroupForm.addFormElement(username);
FormElement email = new FormElement();
email.setRequired(true);
email.setAnswerType(WorkgroupForm.FormEnum.textfield);
email.setVariable("email");
email.setLabel("Email Address:");
workgroupForm.addFormElement(email);
FormElement question = new FormElement();
question.setRequired(true);
question.setAnswerType(WorkgroupForm.FormEnum.textfield);
question.setVariable("question");
question.setLabel("Question:");
workgroupForm.addFormElement(question);
addWorkgroupForm(workgroup, workgroupForm);
saveWorkgroupForm(workgroup);
}
}
/**
* $RCSfile$
* $Revision: 19158 $
* $Date: 2005-06-27 15:15:06 -0700 (Mon, 27 Jun 2005) $
*
* Copyright (C) 1999-2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.dataforms;
import java.util.Iterator;
import java.util.List;
public class FormUtils {
private FormUtils(){}
public static String createAnswers(FormElement formElement){
String name = formElement.getVariable();
return createAnswers(name, formElement.getAnswerType(), formElement.getAnswers());
}
public static String createAnswers(FormElement formElement, String name){
return createAnswers(name, formElement.getAnswerType(), formElement.getAnswers());
}
public static String createAnswers(String name, WorkgroupForm.FormEnum answerType, List items) {
final StringBuilder builder = new StringBuilder();
if (WorkgroupForm.FormEnum.textfield == answerType) {
builder.append("<input type=\"text\" size=\"30\" name=\"").append(name).append("\">");
}
else if (WorkgroupForm.FormEnum.textarea == answerType) {
builder.append("<textarea name=\"").append(name).append("\" cols=\"30\" rows=\"3\">");
builder.append("</textarea>");
}
else if (WorkgroupForm.FormEnum.dropdown_box == answerType) {
builder.append("<select name=\"").append(name).append("\">");
if (items != null) {
Iterator iterator = items.iterator();
while (iterator.hasNext()) {
String item = (String)iterator.next();
builder.append("<option value=\"").append(item).append("\">").append(item)
.append("</option>");
}
}
builder.append("</select>");
}
else if (WorkgroupForm.FormEnum.checkbox == answerType) {
if(items == null){
return null;
}
Iterator iter = items.iterator();
int counter = 0;
while(iter.hasNext()){
String value = (String)iter.next();
builder.append("<input type=\"checkbox\" value=\"").append(value)
.append("\" name=\"").append(name).append(counter).append("\">");
builder.append("&nbsp;");
builder.append(value);
builder.append("<br/>");
counter++;
}
}
else if(WorkgroupForm.FormEnum.radio_button == answerType){
if(items == null){
return null;
}
Iterator iter = items.iterator();
while(iter.hasNext()){
String value = (String)iter.next();
builder.append("<input type=\"radio\" value=\"").append(value).append("\" name=\"")
.append(name).append("\">");
builder.append("&nbsp;");
builder.append(value);
builder.append("<br/>");
}
}
return builder.toString();
}
}
\ No newline at end of file
/**
* $RCSfile$
* $Revision: 22802 $
* $Date: 2005-10-20 11:06:36 -0700 (Thu, 20 Oct 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.dataforms;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class WorkgroupForm {
private List<FormElement> elements;
private List<FormElement> hiddenVars;
private String title;
private String description;
public WorkgroupForm() {
elements = new ArrayList<FormElement>();
hiddenVars = new ArrayList<FormElement>();
}
public void addFormElement(FormElement element, int index) {
elements.add(index, element);
}
public void addFormElement(FormElement element) {
elements.add(element);
}
public void removeFormElement(int index) {
elements.remove(index);
}
public Collection<FormElement> getFormElements() {
return elements;
}
public FormElement getFormElementAt(int index) {
return elements.get(index);
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<FormElement> getHiddenVars() {
return hiddenVars;
}
public void setHiddenVars(List<FormElement> hiddenVars) {
this.hiddenVars = hiddenVars;
}
public void addHiddenVar(FormElement formElement) {
hiddenVars.add(formElement);
}
public void removeHiddenVarAt(int index) {
hiddenVars.remove(index);
}
public boolean containsHiddenTag(String elementName) {
for (FormElement elem : getHiddenVars()) {
if (elem.getVariable().equals(elementName)) {
return true;
}
}
return false;
}
public void removeHiddenVar(String elementName) {
for (FormElement elem : getHiddenVars()) {
if (elem.getVariable().equals(elementName)) {
hiddenVars.remove(elem);
break;
}
}
}
public enum FormEnum {
// Keys used to create forms
dropdown_box("dropdown_box"),
checkbox("checkbox"),
radio_button("radio_button"),
textfield("textfield"),
textarea("textarea"),
hidden("hidden"),
password("password");
private String key;
FormEnum(String k) {
key = k;
}
public String toString() {
return (key);
}
}
}
\ No newline at end of file
/**
* $RCSfile$
* $Revision: 19158 $
* $Date: 2005-06-27 15:15:06 -0700 (Mon, 27 Jun 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.dataforms;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupProvider;
import org.dom4j.Element;
import org.xmpp.forms.DataForm;
import org.xmpp.packet.IQ;
import org.xmpp.packet.PacketError;
public class WorkgroupFormProvider implements WorkgroupProvider {
public boolean handleGet(IQ packet) {
Element iq = packet.getChildElement();
String name = iq.getName();
if ("workgroup-form".equals(name)) {
return true;
}
return false;
}
public boolean handleSet(IQ packet) {
return false;
}
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
FormManager formManager = FormManager.getInstance();
DataForm dataForm = formManager.getDataForm(workgroup);
if (dataForm == null) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
Element iq = packet.getChildElement();
if (iq.elements().isEmpty()) {
reply.setChildElement(iq.createCopy());
// Send the data form to the requestor
reply.addExtension(dataForm.createCopy());
workgroup.send(reply);
}
}
public void executeSet(IQ packet, Workgroup workgroup) {
}
}
/**
* $RCSfile$
* $Revision: 19158 $
* $Date: 2005-06-27 15:15:06 -0700 (Mon, 27 Jun 2005) $
*
* Copyright (C) 1999-2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.events;
import org.jivesoftware.openfire.fastpath.history.AgentChatSession;
import org.jivesoftware.openfire.fastpath.history.ChatSession;
import org.jivesoftware.openfire.fastpath.history.ChatTranscriptManager;
import org.jivesoftware.xmpp.workgroup.AgentSession;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.event.WorkgroupEventDispatcher;
import org.jivesoftware.xmpp.workgroup.event.WorkgroupEventListener;
import org.jivesoftware.xmpp.workgroup.utils.ModelUtil;
import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.EmailService;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
* EmailTranscriptEvent sends emails to specified users on end of chat events.
*
* @author Derek DeMoro
*/
public class EmailTranscriptEvent implements WorkgroupEventListener {
public EmailTranscriptEvent() {
WorkgroupEventDispatcher.addListener(this);
Log.debug("EmailTranscriptEvent initialized.");
}
public void workgroupCreated(Workgroup workgroup) {
}
public void workgroupDeleting(Workgroup workgroup) {
}
public void workgroupDeleted(Workgroup workgroup) {
}
public void workgroupOpened(Workgroup workgroup) {
}
public void workgroupClosed(Workgroup workgroup) {
}
public void agentJoined(Workgroup workgroup, AgentSession agentSession) {
}
public void agentDeparted(Workgroup workgroup, AgentSession agentSession) {
}
public void chatSupportStarted(Workgroup workgroup, String sessionID) {
}
public void chatSupportFinished(Workgroup workgroup, String sessionID) {
Log.debug("Chat Support Finished, sending transcripts");
final EmailService emailService = EmailService.getInstance();
String property = JiveGlobals.getProperty("mail.configured");
if (!ModelUtil.hasLength(property)) {
Log.debug("Mail settings are not configured, transcripts will not be sent.");
return;
}
final ChatSession chatSession = ChatTranscriptManager.getChatSession(sessionID);
if (chatSession == null || chatSession.getFirstSession() == null) {
return;
}
final StringBuilder builder = new StringBuilder();
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyy hh:mm a");
// Get duration of conversation
Date date = new Date(chatSession.getFirstSession().getStartTime());
int duration = getChatDuration(date, chatSession);
TreeMap<String, List<String>> map = new TreeMap<String, List<String>>(chatSession.getMetadata());
String body = JiveGlobals.getProperty("chat.transcript.body");
if (ModelUtil.hasLength(body)) {
builder.append(body).append("\n\n");
}
builder.append("formname=chat transcript\n");
extractAndDisplay(builder, "question", map);
display(builder, "fullname", chatSession.getCustomerName());
extractAndDisplay(builder, "email", map);
extractAndDisplay(builder, "Location", map);
extractAndDisplay(builder, "userID", map);
extractAndDisplay(builder, "username", map);
extractAndDisplay(builder, "workgroup", map);
display(builder, "chatduration", String.valueOf(duration));
display(builder, "chatdate", formatter.format(date));
if (chatSession.getFirstSession() != null && chatSession.getFirstSession().getAgentJID() != null) {
try {
display(builder, "agent", new JID(chatSession.getFirstSession().getAgentJID()).toBareJID());
}
catch (Exception e) {
Log.debug("Could not display agent in transcript.", e);
}
}
for (Iterator<Map.Entry<String, List<String>>> iterator = map.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, List<String>> entry = iterator.next();
display(builder, entry.getKey(), getListItem(entry.getValue()));
}
builder.append("ctranscript=\n");
builder.append(ChatTranscriptManager.getTextTranscriptFromSessionID(sessionID));
String subject = JiveGlobals.getProperty("chat.transcript.subject");
String from = JiveGlobals.getProperty("chat.transcript.from");
String to = JiveGlobals.getProperty("chat.transcript.to");
if (!ModelUtil.hasLength(subject) || !ModelUtil.hasLength(from)) {
Log.debug("Transcript settings (chat.transcript.subject, chat.transcript.from) are not configured, " +
"transcripts will not be sent.");
return;
}
if (ModelUtil.hasLength(to)) {
emailService.sendMessage("Chat Transcript", to, "Chat Transcript", from, subject, builder.toString(), null);
Log.debug("Transcript sent to " + to);
}
// NOTE: Do not sent to the customer. They will receive a prompt for a seperate chat transcript
// that does not contain agent information.
// Send to Agents
UserManager um = UserManager.getInstance();
for (Iterator iterator = chatSession.getAgents(); iterator.hasNext();) {
AgentChatSession agentSession = (AgentChatSession)iterator.next();
try {
User user = um.getUser(new JID(agentSession.getAgentJID()).getNode());
emailService.sendMessage("Chat Transcript", user.getEmail(), "Chat Transcript", from, subject, builder.toString(), null);
Log.debug("Transcript sent to agent " + agentSession.getAgentJID());
}
catch (UserNotFoundException e) {
Log.error("Email Transcript Not Sent:" +
"Could not load agent user object for jid " + agentSession.getAgentJID());
}
}
}
private void extractAndDisplay(StringBuilder builder, String var, TreeMap<String, List<String>> map) {
List<String> list = map.remove(var);
if (list != null) {
String value = getListItem(list);
if (ModelUtil.hasLength(value)) {
display(builder, var, value);
}
}
}
private void display(StringBuilder builder, String var, String value) {
builder.append(var).append("=").append(value).append("\n");
}
private String getListItem(List<String> list) {
StringBuffer sb = new StringBuffer();
for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) {
String s = iterator.next();
sb.append(s);
if (iterator.hasNext()) {
sb.append(",");
}
}
return sb.toString();
}
private int getChatDuration(Date start, ChatSession session) {
long startTime = start.getTime();
long end = startTime;
List agents = session.getAgentList();
for (Iterator iterator = agents.iterator(); iterator.hasNext();) {
AgentChatSession chatSession = (AgentChatSession)iterator.next();
if (end < chatSession.getEndTime()) {
end = chatSession.getEndTime();
}
}
return (int)((end - startTime) / 1000 / 60);
}
public void agentJoinedChatSupport(Workgroup workgroup, String sessionID, AgentSession agentSession) {
}
public void agentLeftChatSupport(Workgroup workgroup, String sessionID, AgentSession agentSession) {
}
public void shutdown() {
WorkgroupEventDispatcher.removeListener(this);
}
}
/**
* $RCSfile$
* $Revision$
* $Date: 2006-08-07 21:12:21 -0700 (Mon, 07 Aug 2006) $
*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.history;
/**
* Represents the data model for one agent chat session.
*
* @author Derek DeMoro
*/
public class AgentChatSession {
String agentJID;
long startTime;
long endTime;
/**
* Creates a new instance of AgentChatSession
* @param agentJID the agents JID
* @param startTime the time in the agent joined the conversation.
* @param endTime the time the agent left the conversation.
*/
public AgentChatSession(String agentJID, long startTime, long endTime) {
this.agentJID = agentJID;
this.startTime = startTime;
this.endTime = endTime;
}
public String getAgentJID() {
return agentJID;
}
public void setAgentJID(String agentJID) {
this.agentJID = agentJID;
}
public long getStartTime() {
return startTime;
}
public void setStartTime(long startTime) {
this.startTime = startTime;
}
public long getEndTime() {
return endTime;
}
public void setEndTime(long endTime) {
this.endTime = endTime;
}
}
/**
* $RCSfile$
* $Revision$
* $Date: 2006-08-07 21:12:21 -0700 (Mon, 07 Aug 2006) $
*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.history;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Represents the data model for one complete Chat Session in Fastpath.
*
* @author Derek DeMoro
*/
public class ChatSession {
private String sessionID;
private String userID;
private long workgroupID;
private String transcript;
private long startTime;
private long endTime;
private List<AgentChatSession> agentList = new ArrayList<AgentChatSession>();
public Map<String, List<String>> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, List<String>> metadata) {
this.metadata = metadata;
}
public void addAgent(AgentChatSession chatSession) {
agentList.add(chatSession);
}
public Iterator getAgents() {
return agentList.iterator();
}
public List getAgentList() {
return agentList;
}
private Map<String, List<String>> metadata;
public String getSessionID() {
return sessionID;
}
public void setSessionID(String sessionID) {
this.sessionID = sessionID;
}
public String getTranscript() {
return transcript;
}
public void setTranscript(String transcript) {
this.transcript = transcript;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public long getWorkgroupID() {
return workgroupID;
}
public void setWorkgroupID(long workgroupID) {
this.workgroupID = workgroupID;
}
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
public long getStartTime() {
return startTime;
}
public void setStartTime(long startTime) {
this.startTime = startTime;
}
public long getEndTime() {
return endTime;
}
public void setEndTime(long endTime) {
this.endTime = endTime;
}
public long getQueueWaitTime() {
return queueWaitTime;
}
public void setQueueWaitTime(long queueWaitTime) {
this.queueWaitTime = queueWaitTime;
}
public String getCustomerName() {
String name = metadata.get("username") == null || metadata.get("username").isEmpty() ?
null : metadata.get("username").get(0);
if (name == null || name.trim().length() == 0) {
name = "Customer";
}
return name;
}
public String getEmail() {
String email = metadata.get("email") == null || metadata.get("email").isEmpty() ?
null : metadata.get("email").get(0);
if (email == null || email.trim().length() == 0) {
email = "n/ae";
}
return email;
}
public String getQuestion() {
String question = metadata.get("question") == null || metadata.get("question").isEmpty() ? null : metadata.get("question").get(0);
if (question == null || question.trim().length() == 0) {
question = "n/a";
}
return question;
}
public AgentChatSession getFirstSession() {
long startTime = -1;
AgentChatSession returnSession = null;
Iterator iter = getAgents();
while (iter.hasNext()) {
AgentChatSession agent = (AgentChatSession)iter.next();
if (agent.getStartTime() <= startTime || startTime == -1) {
startTime = agent.getStartTime();
returnSession = agent;
}
}
return returnSession;
}
long queueWaitTime;
int state;
}
/**
* $RCSfile$
* $Revision: 19208 $
* $Date: 2005-07-01 08:07:31 -0700 (Fri, 01 Jul 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.macros;
public class Macro {
public static final int TEXT = 0;
public static final int URL = 1;
public static final int IMAGE = 2;
private String title;
private String description;
private String response;
private int type;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getResponse() {
return response;
}
public void setResponse(String response) {
this.response = response;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}
/**
* $RCSfile$
* $Revision: 19201 $
* $Date: 2005-06-30 15:04:29 -0700 (Thu, 30 Jun 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.macros;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class MacroGroup {
private List<Macro> macros;
private List<MacroGroup> macroGroups;
// Define MacroGroup
private String title;
public MacroGroup() {
macros = new ArrayList<Macro>();
macroGroups = new ArrayList<MacroGroup>();
}
public void addMacro(Macro macro) {
macros.add(macro);
}
public void removeMacro(Macro macro) {
macros.remove(macro);
}
public Macro getMacroByTitle(String title) {
Collection<Macro> col = Collections.unmodifiableList(macros);
for (Macro macro : col) {
if (macro.getTitle().equalsIgnoreCase(title)) {
return macro;
}
}
return null;
}
public void addMacroGroup(MacroGroup group){
macroGroups.add(group);
}
public void removeMacroGroup(MacroGroup group){
macroGroups.remove(group);
}
public Macro getMacro(int location) {
return macros.get(location);
}
public MacroGroup getMacroGroupByTitle(String title) {
Collection<MacroGroup> col = Collections.unmodifiableList(macroGroups);
for (MacroGroup group : col) {
if (group.getTitle().equalsIgnoreCase(title)) {
return group;
}
}
return null;
}
public MacroGroup getMacroGroup(int location){
return macroGroups.get(location);
}
public List<Macro> getMacros() {
return macros;
}
public void setMacros(List<Macro> macros) {
this.macros = macros;
}
public List<MacroGroup> getMacroGroups() {
return macroGroups;
}
public void setMacroGroups(List<MacroGroup> macroGroups) {
this.macroGroups = macroGroups;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
/**
* $RCSfile$
* $Revision: 19255 $
* $Date: 2005-07-07 18:49:41 -0700 (Thu, 07 Jul 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.macros;
import org.jivesoftware.xmpp.workgroup.*;
import org.jivesoftware.xmpp.workgroup.utils.ModelUtil;
import com.thoughtworks.xstream.XStream;
import org.dom4j.Element;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.packet.IQ;
import org.xmpp.packet.PacketError;
public class MacroProvider implements WorkgroupProvider {
public boolean handleGet(IQ packet) {
Element iq = packet.getChildElement();
String name = iq.getName();
return "macros".equals(name);
}
public boolean handleSet(IQ packet) {
Element iq = packet.getChildElement();
String name = iq.getName();
return "macros".equals(name);
}
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
Element iq = packet.getChildElement();
String name = iq.getName();
boolean isPersonal = iq.element("personal") != null;
Agent agent;
try {
agent = workgroup.getAgentManager().getAgent(packet.getFrom());
}
catch (AgentNotFoundException e) {
sendItemNotFound(packet, workgroup);
return;
}
if ("macros".equals(name) && !isPersonal) {
Element globalMacros = reply.setChildElement("macros", "http://jivesoftware.com/protocol/workgroup");
DbProperties props = workgroup.getProperties();
String macroModel = props.getProperty("jive.macro" + workgroup.getID());
if (ModelUtil.hasLength(macroModel)) {
globalMacros.addElement("model").setText(macroModel);
}
else {
sendItemNotFound(packet, workgroup);
return;
}
}
else if (isPersonal) {
Element personalMacros = reply.setChildElement("macros", "http://jivesoftware.com/protocol/workgroup");
DbProperties props = agent.getProperties();
String macroModel = props.getProperty("personal.macro");
if (ModelUtil.hasLength(macroModel)) {
personalMacros.addElement("model").setText(macroModel);
}
else {
sendItemNotFound(packet, workgroup);
return;
}
}
else {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
workgroup.send(reply);
}
private void sendItemNotFound(IQ packet, Workgroup workgroup) {
IQ reply;
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
}
public void executeSet(IQ packet, Workgroup workgroup) {
IQ reply;
Element iq = packet.getChildElement();
String personalMacro = iq.element("personalMacro").getTextTrim();
try {
// Verify that an agent is requesting this information.
Agent agent = workgroup.getAgentManager().getAgent(packet.getFrom());
DbProperties props = agent.getProperties();
XStream xstream = new XStream();
xstream.alias("macro", Macro.class);
xstream.alias("macrogroup", MacroGroup.class);
MacroGroup group = (MacroGroup)xstream.fromXML(personalMacro);
String saveString = xstream.toXML(group);
try {
props.deleteProperty("personal.macro");
props.setProperty("personal.macro", saveString);
}
catch (UnauthorizedException e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
reply = IQ.createResultIQ(packet);
}
catch (AgentNotFoundException e) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
}
workgroup.send(reply);
}
}
/**
* $RCSfile$
* $Revision: 25826 $
* $Date: 2006-01-17 10:00:38 -0800 (Tue, 17 Jan 2006) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.macros;
import org.jivesoftware.xmpp.workgroup.DbProperties;
import org.jivesoftware.xmpp.workgroup.UnauthorizedException;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupManager;
import org.jivesoftware.xmpp.workgroup.utils.ModelUtil;
import com.thoughtworks.xstream.XStream;
import java.util.HashMap;
import java.util.Map;
import org.xmpp.component.ComponentManagerFactory;
public class WorkgroupMacros {
private Map<Workgroup, MacroGroup> rootGroups = new HashMap<Workgroup, MacroGroup>();
private static WorkgroupMacros singleton;
private static final Object LOCK = new Object();
private XStream xstream = new XStream();
/**
* Returns the singleton instance of <CODE>WorkgroupMacros</CODE>,
* creating it if necessary.
* <p/>
*
* @return the singleton instance of <Code>WorkgroupMacros</CODE>
*/
public static WorkgroupMacros getInstance() {
// Synchronize on LOCK to ensure that we don't end up creating
// two singletons.
synchronized (LOCK) {
if (singleton == null) {
WorkgroupMacros WorkgroupMacros = new WorkgroupMacros();
singleton = WorkgroupMacros;
return WorkgroupMacros;
}
}
return singleton;
}
private WorkgroupMacros() {
// Load macros
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
xstream.alias("macro", Macro.class);
xstream.alias("macrogroup", MacroGroup.class);
for (Workgroup workgroup : workgroupManager.getWorkgroups()) {
// Load from DB.
DbProperties prop = workgroup.getProperties();
String macros = prop.getProperty("jive.macro" + workgroup.getID());
if (ModelUtil.hasLength(macros)) {
MacroGroup group = (MacroGroup)xstream.fromXML(macros);
rootGroups.put(workgroup, group);
}
}
}
public MacroGroup getMacroGroup(Workgroup workgroup) {
if (rootGroups.containsKey(workgroup)) {
return rootGroups.get(workgroup);
}
MacroGroup rootGroup = new MacroGroup();
rootGroup.setTitle("Parent Category");
rootGroups.put(workgroup, rootGroup);
return rootGroup;
}
public MacroGroup getMacroGroup(Workgroup workgroup, String name) {
final MacroGroup rootGroup = getMacroGroup(workgroup);
if (rootGroup.getTitle().equals(name)) {
return rootGroup;
}
for (MacroGroup groups : rootGroup.getMacroGroups()) {
if (groups.getTitle().equals(name)) {
return groups;
}
MacroGroup foundGroup = getChildGroup(groups, name);
if (foundGroup != null) {
return foundGroup;
}
}
return null;
}
private MacroGroup getChildGroup(MacroGroup rootGroup, String name) {
MacroGroup returnGroup = null;
for (MacroGroup group : rootGroup.getMacroGroups()) {
if (group.getTitle().equals(name)) {
returnGroup = group;
break;
}
else {
returnGroup = getChildGroup(group, name);
if (returnGroup != null) {
break;
}
}
}
return returnGroup;
}
public void setRootGroup(Workgroup workgroup, MacroGroup rootGroup) {
rootGroups.put(workgroup, rootGroup);
}
public void saveMacros(Workgroup workgroup) {
long id = workgroup.getID();
MacroGroup group = getMacroGroup(workgroup);
String saveString = xstream.toXML(group);
DbProperties props = workgroup.getProperties();
try {
props.deleteProperty("jive.macro" + id);
props.setProperty("jive.macro" + id, saveString);
}
catch (UnauthorizedException e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
}
}
/**
* $RCSfile$
* $Revision: 19370 $
* $Date: 2005-07-21 16:52:58 -0700 (Thu, 21 Jul 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.providers;
import org.jivesoftware.xmpp.workgroup.AgentNotFoundException;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupProvider;
import org.jivesoftware.xmpp.workgroup.utils.ModelUtil;
import org.dom4j.Element;
import org.jivesoftware.database.DbConnectionManager;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.packet.IQ;
import org.xmpp.packet.PacketError;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* AgentHistory is responsible for retrieving the information for one agent.
*/
public class AgentHistory implements WorkgroupProvider {
private static final String GET_AGENT_SESSIONS =
"SELECT sessionID, joinTime, leftTime FROM fpAgentSession WHERE agentJID=?";
private static final String GET_SESSION_METADATA =
"SELECT metadataname, metadatavalue FROM fpSessionMetadata WHERE sessionID=?";
public boolean handleGet(IQ packet) {
Element iq = packet.getChildElement();
String name = iq.getName();
return "chat-sessions".equals(name);
}
public boolean handleSet(IQ packet) {
return false;
}
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
try {
if (workgroup.getAgentManager().getAgentSession(packet.getFrom()) == null) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.not_authorized));
workgroup.send(reply);
return;
}
}
catch (AgentNotFoundException e) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.not_authorized));
workgroup.send(reply);
return;
}
// Create session list
List<AgentHistoryModel> sessionList = new ArrayList<AgentHistoryModel>();
Element chatSessions = reply.setChildElement("chat-sessions", "http://jivesoftware.com/protocol/workgroup");
Element iq = packet.getChildElement();
String agentJID = iq.attributeValue("agentJID");
String ms = iq.attributeValue("maxSessions");
String date = iq.attributeValue("startDate");
long startTime = 0;
if (date != null) {
startTime = Long.parseLong(date);
}
int maxSessions = Integer.parseInt(ms);
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GET_AGENT_SESSIONS);
pstmt.setString(1, agentJID);
ResultSet result = pstmt.executeQuery();
while (result.next()) {
String sessionID = result.getString(1);
String joinTime = result.getString(2);
String leftTime = result.getString(3);
AgentHistoryModel model = new AgentHistoryModel();
if (ModelUtil.hasLength(joinTime) && ModelUtil.hasLength(leftTime)) {
try {
long start = Long.valueOf(joinTime);
long end = Long.valueOf(leftTime);
long totalTime = end - start;
model.setSessionID(sessionID);
model.setJoinTime(joinTime);
model.setDuration(Long.toString(totalTime));
if (start >= startTime) {
sessionList.add(model);
}
}
catch (NumberFormatException e) {
ComponentManagerFactory.getComponentManager().getLog().error(e);
}
}
}
result.close();
}
catch (Exception ex) {
ComponentManagerFactory.getComponentManager().getLog().error(ex);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
buildAndSend(sessionList, chatSessions, reply, workgroup, maxSessions);
}
public void buildAndSend(List<AgentHistoryModel> list, Element chatSessions, IQ reply, Workgroup workgroup, int maxSessions) {
for (AgentHistoryModel model : getNewList(list, maxSessions)) {
Element session = chatSessions.addElement("chat-session");
session.addElement("sessionID").setText(model.getSessionID());
session.addElement("date").setText(model.getJoinTime());
session.addElement("duration").setText(model.getDuration());
session.addElement("visitorsName").setText(model.getName() == null ?
"" : model.getName());
session.addElement("visitorsEmail").setText(model.getEmail() == null ?
"" : model.getEmail());
session.addElement("question").setText(model.getQuestion() == null ?
"" : model.getQuestion());
}
workgroup.send(reply);
}
private List<AgentHistoryModel> getNewList(List<AgentHistoryModel> sessions, int maxSessions) {
List<AgentHistoryModel> newList = new ArrayList<AgentHistoryModel>();
Collections.sort(sessions, new Comparator<AgentHistoryModel>() {
public int compare(AgentHistoryModel m1, AgentHistoryModel m2) {
String str1 = m1.getJoinTime();
String str2 = m2.getJoinTime();
long i1 = Long.valueOf(str1);
long i2 = Long.valueOf(str2);
// Check if identical
if (i1 == i2) {
return 0;
}
if (i1 > i2) {
return -1;
}
else if (i1 < i2) {
return 1;
}
else {
return 0;
}
}
});
int max = maxSessions < sessions.size() ? maxSessions : sessions.size();
for (int i = 0; i < max; i++) {
AgentHistoryModel model = sessions.get(i);
appendSessionInformation(model);
newList.add(model);
}
return newList;
}
private void appendSessionInformation(AgentHistoryModel model) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GET_SESSION_METADATA);
pstmt.setString(1, model.getSessionID());
rs = pstmt.executeQuery();
while (rs.next()) {
String name = rs.getString(1);
String value = rs.getString(2);
if (name.equals("username")) {
model.setName(value);
}
else if (name.equals("email")) {
model.setEmail(value);
}
else if (name.equals("question")) {
model.setQuestion(value);
}
}
}
catch (Exception ex) {
ComponentManagerFactory.getComponentManager().getLog().error(ex);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
}
public void executeSet(IQ packet, Workgroup workgroup) {
}
private class AgentHistoryModel {
private String sessionID;
private String joinTime;
private String duration;
private String name;
private String email;
private String question;
AgentHistoryModel() {
}
public String getSessionID() {
return sessionID;
}
public void setSessionID(String sessionID) {
this.sessionID = sessionID;
}
public void setJoinTime(String joinTime) {
this.joinTime = joinTime;
}
public String getJoinTime() {
return joinTime;
}
public void setDuration(String duration) {
this.duration = duration;
}
public String getDuration() {
return duration;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setEmail(String email) {
this.email = email;
}
public String getEmail() {
return email;
}
public void setQuestion(String question) {
this.question = question;
}
public String getQuestion() {
return question;
}
}
}
\ No newline at end of file
/**
* $RCSfile$
* $Revision: 19357 $
* $Date: 2005-07-21 09:40:33 -0700 (Thu, 21 Jul 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.providers;
import org.jivesoftware.xmpp.workgroup.AgentNotFoundException;
import org.jivesoftware.xmpp.workgroup.AgentSession;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupProvider;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.database.DbConnectionManager;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.packet.IQ;
import org.xmpp.packet.PacketError;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;
public class ChatMetadataProvider implements WorkgroupProvider {
private static final String GET_SESSION_METADATA =
"SELECT metadataName, metadataValue FROM fpSessionMetadata WHERE sessionID=?";
public boolean handleGet(IQ packet) {
Element iq = packet.getChildElement();
String name = iq.getName();
return "chat-metadata".equals(name);
}
public boolean handleSet(IQ packet) {
return false;
}
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
try {
AgentSession agentSession = workgroup.getAgentManager().getAgentSession(packet.getFrom());
if (agentSession == null) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.not_authorized));
workgroup.send(reply);
return;
}
}
catch (AgentNotFoundException e) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.not_authorized));
workgroup.send(reply);
return;
}
Element chatSessions = reply.setChildElement("chat-metadata", "http://jivesoftware.com/protocol/workgroup");
Element iq = packet.getChildElement();
String sessionID = iq.element("sessionID").getTextTrim();
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Map<String, String> map = new HashMap<String, String>();
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GET_SESSION_METADATA);
pstmt.setString(1, sessionID);
rs = pstmt.executeQuery();
while (rs.next()) {
String name = rs.getString(1);
String value = rs.getString(2);
map.put(name, value);
}
}
catch (Exception ex) {
ComponentManagerFactory.getComponentManager().getLog().error(ex);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
// Add metadata
chatSessions.add(getMetaDataElement(map));
workgroup.send(reply);
}
public Element getMetaDataElement(Map<String, String> metaData) {
QName qName = DocumentHelper.createQName("metadata", DocumentHelper.createNamespace("",
"http://jivesoftware.com/protocol/workgroup"));
Element metaDataElement = DocumentHelper.createElement(qName);
for (Map.Entry<String, String> entry : metaData.entrySet()) {
String name = entry.getKey();
String value = entry.getValue();
Element elem = metaDataElement.addElement("value");
elem.addAttribute("name", name).setText(value);
}
return metaDataElement;
}
public void executeSet(IQ packet, Workgroup workgroup) {
}
}
/**
* $RCSfile$
* $Revision: 19303 $
* $Date: 2005-07-14 10:43:49 -0700 (Thu, 14 Jul 2005) $
*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.providers;
import org.jivesoftware.xmpp.workgroup.AgentNotFoundException;
import org.jivesoftware.xmpp.workgroup.AgentSession;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupProvider;
import org.dom4j.Element;
import org.jivesoftware.database.DbConnectionManager;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.packet.IQ;
import org.xmpp.packet.PacketError;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
* ChatNotes is responsible for the setting and retrieval off Chat Notes. Each chat note
* is tied directly to a chat session within Live Assistant.
*/
public class ChatNotes implements WorkgroupProvider {
private static final String GET_NOTES = "SELECT notes FROM fpSession WHERE sessionID=?";
private static final String SET_NOTES = "UPDATE fpSession SET notes=? WHERE sessionID=?";
/**
* Updates a note within Live Assistant Database (jlaSession table)
*
* @param sessionID the chat sessionID associated with this note.
* @param note the note itself.
*/
public void appendNote(String sessionID, String note) {
Connection con;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
try {
pstmt = con.prepareStatement(SET_NOTES);
DbConnectionManager.setLargeTextField(pstmt, 1, note);
pstmt.setString(2, sessionID);
pstmt.executeUpdate();
}
catch (Exception ex) {
ComponentManagerFactory.getComponentManager().getLog().error(ex);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
}
catch (Exception ex) {
ComponentManagerFactory.getComponentManager().getLog().error(ex);
}
}
/**
* Retrieves a note from the Live Assistant Database. (jlaSession table)
*
* @param sessionID the sessionID that the note is mapped to.
* @return the note found. If no note is found, null will be returned.
*/
public String getNotes(String sessionID) {
String notes = null;
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GET_NOTES);
pstmt.setString(1, sessionID);
rs = pstmt.executeQuery();
if (rs.next()) {
notes = DbConnectionManager.getLargeTextField(rs, 1);
}
}
catch (Exception ex) {
ComponentManagerFactory.getComponentManager().getLog().error(ex);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
return notes;
}
/**
* Retrieves note from Fastpath.
*
* @param packet the associated IQ Packet.
* @param workgroup the workgroup the request came from.
* @param sessionID the sessionID the note is mapped to.
*/
public void sendNotesPacket(IQ packet, Workgroup workgroup, String sessionID) {
IQ reply = IQ.createResultIQ(packet);
// Retrieve the web chat setting.
String notes = getNotes(sessionID);
if (notes == null) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
Element note = reply.setChildElement("chat-notes", "http://jivesoftware.com/protocol/workgroup");
note.addElement("sessionID").setText(sessionID);
note.addElement("text").setText(notes);
workgroup.send(reply);
}
public boolean handleGet(IQ packet) {
return hasChatNotesNames(packet);
}
public boolean handleSet(IQ packet) {
return hasChatNotesNames(packet);
}
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply;
Element iq = packet.getChildElement();
// Verify that an agent is requesting this information.
try {
AgentSession agentSession = workgroup.getAgentManager().getAgentSession(packet.getFrom());
if (agentSession != null) {
String sessionID = iq.element("sessionID").getTextTrim();
sendNotesPacket(packet, workgroup, sessionID);
}
else {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
}
}
catch (AgentNotFoundException e) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
}
}
public void executeSet(IQ packet, Workgroup workgroup) {
IQ reply;
Element iq = packet.getChildElement();
try {
// Verify that an agent is requesting this information.
AgentSession agentSession = workgroup.getAgentManager().getAgentSession(packet.getFrom());
if (agentSession != null) {
String sessionID = iq.element("sessionID").getTextTrim();
Element notes = iq.element("notes");
String noteText = notes.getTextTrim();
appendNote(sessionID, noteText);
reply = IQ.createResultIQ(packet);
}
else {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
}
}
catch (AgentNotFoundException e) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
}
workgroup.send(reply);
}
private boolean hasChatNotesNames(IQ packet) {
Element iq = packet.getChildElement();
String name = iq.getName();
return "chat-notes".equals(name);
}
}
\ No newline at end of file
/**
* $RCSfile$
* $Revision: 19353 $
* $Date: 2005-07-20 16:25:54 -0700 (Wed, 20 Jul 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.providers;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupProvider;
import org.jivesoftware.xmpp.workgroup.disco.DiscoFeaturesProvider;
import org.jivesoftware.xmpp.workgroup.utils.ModelUtil;
import org.jivesoftware.openfire.fastpath.history.ChatTranscriptManager;
import org.dom4j.Element;
import org.xmpp.packet.IQ;
import org.xmpp.packet.PacketError;
import org.jivesoftware.util.EmailService;
import org.jivesoftware.util.JiveGlobals;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Allows agents and web client w/authentication to send email.
*/
public class EmailProvider implements WorkgroupProvider, DiscoFeaturesProvider {
public boolean handleGet(IQ packet) {
return false;
}
public boolean handleSet(IQ packet) {
Element iq = packet.getChildElement();
String name = iq.getName();
return "send-email".equals(name);
}
public void executeGet(IQ packet, Workgroup workgroup) {
// Nothing.
}
public void executeSet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
Element iq = packet.getChildElement();
String from = iq.element("fromAddress").getTextTrim();
String to = iq.element("toAddress").getTextTrim();
String subject = iq.element("subject").getTextTrim();
String body = iq.element("message").getTextTrim();
// Need to replace the \\n for \n to allow for text sending.
body = body.replace("\\n", "\n");
String html = iq.element("useHTML").getTextTrim();
boolean useHTML = false;
if ("true".equals(html)) {
useHTML = true;
}
String sessionID = null;
if(iq.element("sessionID") != null){
sessionID = iq.element("sessionID").getTextTrim();
}
// Handle missing information.
if (!ModelUtil.hasLength(from) || !ModelUtil.hasLength(to) ||
!ModelUtil.hasLength(subject) || (!ModelUtil.hasLength(body) && !ModelUtil.hasLength(sessionID))) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.not_acceptable));
workgroup.send(reply);
return;
}
if (ModelUtil.hasLength(sessionID)) {
ChatTranscriptManager.sendTranscriptByMail(sessionID, to);
}
else {
EmailService emailService = EmailService.getInstance();
if (!useHTML) {
emailService.sendMessage(null, to, null, from, subject, body, null);
}
else {
emailService.sendMessage(null, to, null, from, subject, null, body);
}
}
workgroup.send(reply);
}
public Collection<String> getFeatures() {
String property = JiveGlobals.getProperty("mail.configured");
if (!ModelUtil.hasLength(property)) {
return Collections.emptyList();
}
List<String> list = new ArrayList<String>();
list.add("jive:email:provider");
return list;
}
}
/**
* $RCSfile$
* $Revision: 19253 $
* $Date: 2005-07-07 17:20:43 -0700 (Thu, 07 Jul 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.providers;
import org.jivesoftware.xmpp.workgroup.AgentNotFoundException;
import org.jivesoftware.xmpp.workgroup.Workgroup;
import org.jivesoftware.xmpp.workgroup.WorkgroupManager;
import org.jivesoftware.xmpp.workgroup.WorkgroupProvider;
import org.dom4j.Element;
import org.xmpp.packet.IQ;
import org.xmpp.packet.PacketError;
public class SearchProvider implements WorkgroupProvider {
public boolean handleGet(IQ packet) {
Element iq = packet.getChildElement();
String name = iq.getName();
return "search-settings".equals(name);
}
public boolean handleSet(IQ packet) {
return false;
}
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
// Retrieve the web chat setting.
String kbURL = workgroup.getProperties().getProperty("kb");
String forumURL = workgroup.getProperties().getProperty("forums");
// Check that the sender of this IQ is an agent
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
try {
workgroupManager.getAgentManager().getAgent(packet.getFrom());
}
catch (AgentNotFoundException e) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
Element searchSetting = reply.setChildElement("search-settings", "http://jivesoftware.com/protocol/workgroup");
if (forumURL != null) {
searchSetting.addElement("forums").setText(forumURL);
}
if (kbURL != null) {
searchSetting.addElement("kb").setText(kbURL);
}
workgroup.send(reply);
}
public void executeSet(IQ packet, Workgroup workgroup) {
}
}
/**
* $RCSfile$
* $Revision: 19036 $
* $Date: 2005-06-13 16:53:54 -0700 (Mon, 13 Jun 2005) $
*
* Copyright (C) 1999-2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.fastpath.settings.offline;
/**
* <p>Flags an exception when an OfflineSetting is requested but not found.</p>
*
* @author Derek DeMoro
*/
public class OfflineSettingsNotFound extends Exception {
public OfflineSettingsNotFound() {
}
public OfflineSettingsNotFound(String message) {
super(message);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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