Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
be9ed91a
Commit
be9ed91a
authored
Jul 10, 2015
by
Leon Roy
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #250 from igniterealtime/OF-929
OF-929
https://igniterealtime.org/issues/browse/OF-929
parents
51b22088
d532c456
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
127 additions
and
13 deletions
+127
-13
.gitignore
.gitignore
+1
-0
ConversationManager.java
...rg/jivesoftware/openfire/archive/ConversationManager.java
+20
-3
UserCreationPlugin.java
.../org/jivesoftware/openfire/plugin/UserCreationPlugin.java
+83
-0
users-creation.jsp
src/plugins/userCreation/src/web/users-creation.jsp
+23
-10
No files found.
.gitignore
View file @
be9ed91a
target/
work/
*.class
# Ignore Intellij Idea project files
*.iml
...
...
src/plugins/monitoring/src/java/org/jivesoftware/openfire/archive/ConversationManager.java
View file @
be9ed91a
...
...
@@ -79,7 +79,7 @@ import org.xmpp.packet.Message;
*
* @author Matt Tucker
*/
public
class
ConversationManager
implements
Startable
,
ComponentEventListener
{
public
class
ConversationManager
implements
Startable
,
ComponentEventListener
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
ConversationManager
.
class
);
...
...
@@ -95,6 +95,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
private
static
final
int
DEFAULT_IDLE_TIME
=
10
;
private
static
final
int
DEFAULT_MAX_TIME
=
60
;
public
static
final
int
DEFAULT_MAX_TIME_DEBUG
=
30
;
public
static
final
int
DEFAULT_MAX_RETRIEVABLE
=
0
;
private
static
final
int
DEFAULT_MAX_AGE
=
0
;
...
...
@@ -191,6 +192,11 @@ public class ConversationManager implements Startable, ComponentEventListener {
};
taskEngine
.
scheduleAtFixedRate
(
archiveTask
,
JiveConstants
.
MINUTE
,
JiveConstants
.
MINUTE
);
if
(
JiveGlobals
.
getProperty
(
"conversation.maxTimeDebug"
)
!=
null
)
{
Log
.
info
(
"Monitoring plugin max time value deleted. Must be left over from stalled userCreation plugin run."
);
JiveGlobals
.
deleteProperty
(
"conversation.maxTimeDebug"
);
}
// Schedule a task to do conversation cleanup.
cleanupTask
=
new
TimerTask
()
{
@Override
...
...
@@ -1119,8 +1125,17 @@ public class ConversationManager implements Startable, ComponentEventListener {
Log
.
error
(
e
.
getMessage
(),
e
);
maxAge
=
DEFAULT_MAX_AGE
*
JiveConstants
.
DAY
;
}
}
else
if
(
property
.
equals
(
"conversation.maxTimeDebug"
))
{
String
value
=
(
String
)
params
.
get
(
"value"
);
try
{
Log
.
info
(
"Monitoring plugin max time overridden (as used by userCreation plugin)"
);
maxTime
=
Integer
.
parseInt
(
value
);
}
catch
(
Exception
e
)
{
Log
.
error
(
e
.
getMessage
(),
e
);
Log
.
info
(
"Monitoring plugin max time reset back to "
+
DEFAULT_MAX_TIME
+
" minutes"
);
maxTime
=
DEFAULT_MAX_TIME
*
JiveConstants
.
MINUTE
;
}
}
}
public
void
propertyDeleted
(
String
property
,
Map
<
String
,
Object
>
params
)
{
...
...
@@ -1140,8 +1155,10 @@ public class ConversationManager implements Startable, ComponentEventListener {
maxAge
=
DEFAULT_MAX_AGE
*
JiveConstants
.
DAY
;
}
else
if
(
property
.
equals
(
"conversation.maxRetrievable"
))
{
maxRetrievable
=
DEFAULT_MAX_RETRIEVABLE
*
JiveConstants
.
DAY
;
}
else
if
(
property
.
equals
(
"conversation.maxTimeDebug"
))
{
Log
.
info
(
"Monitoring plugin max time reset back to "
+
DEFAULT_MAX_TIME
+
" minutes"
);
maxTime
=
DEFAULT_MAX_TIME
*
JiveConstants
.
MINUTE
;
}
}
public
void
xmlPropertySet
(
String
property
,
Map
<
String
,
Object
>
params
)
{
...
...
src/plugins/userCreation/src/java/org/jivesoftware/openfire/plugin/UserCreationPlugin.java
View file @
be9ed91a
package
org
.
jivesoftware
.
openfire
.
plugin
;
import
org.apache.commons.lang.RandomStringUtils
;
import
org.apache.commons.lang.math.RandomUtils
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentHelper
;
import
org.dom4j.Element
;
import
org.jivesoftware.util.JiveGlobals
;
import
org.jivesoftware.util.LocaleUtils
;
import
org.jivesoftware.util.Log
;
import
org.jivesoftware.openfire.SharedGroupException
;
...
...
@@ -12,17 +15,23 @@ import org.jivesoftware.openfire.container.PluginManager;
import
org.jivesoftware.openfire.roster.Roster
;
import
org.jivesoftware.openfire.roster.RosterItem
;
import
org.jivesoftware.openfire.roster.RosterManager
;
import
org.jivesoftware.openfire.user.User
;
import
org.jivesoftware.openfire.user.UserAlreadyExistsException
;
import
org.jivesoftware.openfire.user.UserManager
;
import
org.jivesoftware.openfire.user.UserNotFoundException
;
import
org.jivesoftware.openfire.vcard.VCardManager
;
import
org.xmpp.packet.JID
;
import
org.xmpp.packet.Message
;
import
org.xmpp.packet.Presence
;
import
java.io.File
;
import
java.util.Arrays
;
import
java.util.Hashtable
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
/**
* Created by IntelliJ IDEA.
...
...
@@ -36,6 +45,7 @@ public class UserCreationPlugin implements Plugin {
private
static
Hashtable
<
RosterItem
.
SubType
,
Map
<
String
,
Map
<
Presence
.
Type
,
Change
>>>
stateTable
=
new
Hashtable
<
RosterItem
.
SubType
,
Map
<
String
,
Map
<
Presence
.
Type
,
Change
>>>();
private
Element
vCard
;
public
static
final
int
DEFAULT_MAX_TIME_DEBUG
=
30
;
static
{
Hashtable
<
Presence
.
Type
,
Change
>
subrTable
;
...
...
@@ -282,6 +292,79 @@ public class UserCreationPlugin implements Plugin {
}
System
.
out
.
println
(
"VCards created successfully: "
+
created
);
}
public
static
final
int
NUMBER_CONVERSATION
=
10
;
public
static
final
int
NUMBER_MESSAGES
=
10
;
//+ RandomUtils.nextInt(9);
public
void
generateMessages
()
{
JiveGlobals
.
setProperty
(
"conversation.maxTimeDebug"
,
String
.
valueOf
(
DEFAULT_MAX_TIME_DEBUG
));
XMPPServer
server
=
XMPPServer
.
getInstance
();
ExecutorService
taskExecutor
=
Executors
.
newFixedThreadPool
(
8
);
for
(
User
user
:
UserManager
.
getInstance
().
getUsers
())
{
final
JID
userJid
=
server
.
createJID
(
user
.
getUsername
(),
null
);
System
.
out
.
println
(
"Creating messages for user: "
+
userJid
.
getNode
());
for
(
RosterItem
ri
:
user
.
getRoster
().
getRosterItems
())
{
final
JID
rosterItemJid
=
ri
.
getJid
();
taskExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
for
(
int
j
=
0
;
j
<
NUMBER_CONVERSATION
;
j
++)
{
String
thread
=
RandomStringUtils
.
randomAlphanumeric
(
6
);
for
(
int
i
=
0
;
i
<
NUMBER_MESSAGES
;
i
++)
{
if
(
i
%
2
==
0
)
{
Message
msg
=
new
Message
();
msg
.
setBody
(
"Hello to "
+
rosterItemJid
.
getNode
()
+
" from "
+
userJid
.
getNode
()
+
", conversation number "
+
j
+
" of "
+
NUMBER_CONVERSATION
+
", message "
+
i
+
" of "
+
NUMBER_MESSAGES
+
" thread "
+
thread
);
msg
.
setType
(
Message
.
Type
.
chat
);
msg
.
setFrom
(
userJid
);
msg
.
setTo
(
rosterItemJid
);
msg
.
setThread
(
thread
);
XMPPServer
.
getInstance
().
getMessageRouter
().
route
(
msg
);
try
{
/* otherwise monitoring plugin stores messages out of order */
Thread
.
sleep
(
1
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
else
{
Message
msg
=
new
Message
();
msg
.
setBody
(
"Hello to "
+
userJid
.
getNode
()
+
" from "
+
rosterItemJid
.
getNode
()
+
", conversation number "
+
j
+
" of "
+
NUMBER_CONVERSATION
+
", message "
+
i
+
" of "
+
NUMBER_MESSAGES
+
" thread "
+
thread
);
msg
.
setType
(
Message
.
Type
.
chat
);
msg
.
setFrom
(
rosterItemJid
);
msg
.
setTo
(
userJid
);
msg
.
setThread
(
thread
);
XMPPServer
.
getInstance
().
getMessageRouter
().
route
(
msg
);
try
{
/* otherwise monitoring plugin stores messages out of order */
Thread
.
sleep
(
1
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
try
{
Thread
.
sleep
(
DEFAULT_MAX_TIME_DEBUG
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
});
}
}
taskExecutor
.
shutdown
();
try
{
taskExecutor
.
awaitTermination
(
2
,
TimeUnit
.
HOURS
);
System
.
out
.
println
(
"Conversation generation finished"
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
JiveGlobals
.
deleteProperty
(
"conversation.maxTimeDebug"
);
}
private
Element
getDefaultVCard
()
{
if
(
vCard
!=
null
)
{
...
...
src/plugins/userCreation/src/web/users-creation.jsp
View file @
be9ed91a
<%@page
import=
"org.jivesoftware.util.JiveGlobals"
%>
<%@ page
import=
"org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.TaskEngine,
org.jivesoftware.openfire.XMPPServer,
...
...
@@ -21,7 +22,8 @@
String
from
=
ParamUtils
.
getParameter
(
request
,
"from"
);
String
total
=
ParamUtils
.
getParameter
(
request
,
"total"
);
String
usersPerRoster
=
ParamUtils
.
getParameter
(
request
,
"usersPerRoster"
);
boolean
generateMessages
=
request
.
getParameter
(
"messageGenerate"
)
!=
null
;
Map
<
String
,
String
>
errors
=
new
HashMap
<
String
,
String
>
();
boolean
running
=
false
;
...
...
@@ -31,8 +33,10 @@
final
int
intFrom
=
Integer
.
parseInt
(
from
);
final
int
maxUsers
=
Integer
.
parseInt
(
total
);
final
int
usersRoster
=
Integer
.
parseInt
(
usersPerRoster
)
+
1
;
final
boolean
boolGenerateMessages
=
generateMessages
;
if
(
maxUsers
%
usersRoster
!=
0
||
maxUsers
<=
usersRoster
)
{
errors
.
put
(
"arguments"
,
""
);
errors
.
put
(
"arguments"
,
""
);
}
if
(
errors
.
isEmpty
())
{
...
...
@@ -43,6 +47,10 @@
plugin
.
createUsers
(
userPrefix
,
intFrom
,
maxUsers
);
plugin
.
populateRosters
(
userPrefix
,
intFrom
,
maxUsers
,
usersRoster
);
plugin
.
createVCards
(
userPrefix
,
intFrom
,
maxUsers
);
if
(
boolGenerateMessages
)
{
plugin
.
generateMessages
();
}
}
});
running
=
true
;
...
...
@@ -92,7 +100,7 @@
<tr
class=
"c1"
>
<td
width=
"1%"
colspan=
"2"
nowrap
>
User prefix:
<input
type=
"text"
name=
"prefix"
value=
"
<%=
(
prefix
!=
null
?
prefix
:
""
)
%>
"
size=
"30"
maxlength=
"75"
/>
<input
type=
"text"
name=
"prefix"
value=
"
<%=
(
prefix
!=
null
?
prefix
:
"
user
"
)
%>
"
size=
"30"
maxlength=
"75"
/>
</td>
</tr>
<tr
class=
"c1"
>
...
...
@@ -104,20 +112,25 @@
<tr
class=
"c1"
>
<td
width=
"1%"
colspan=
"2"
nowrap
>
Total users:
<input
type=
"text"
name=
"total"
value=
"
<%=
(
total
!=
null
?
total
:
"
100
0"
)
%>
"
size=
"5"
maxlength=
"15"
/>
<input
type=
"text"
name=
"total"
value=
"
<%=
(
total
!=
null
?
total
:
"
2
0"
)
%>
"
size=
"5"
maxlength=
"15"
/>
</td>
</tr>
<tr
class=
"c1"
>
<td
width=
"1%"
colspan=
"2"
nowrap
>
Contacts in roster:
<input
type=
"text"
name=
"usersPerRoster"
value=
"
<%=
(
usersPerRoster
!=
null
?
usersPerRoster
:
"
30
"
)
%>
"
size=
"5"
maxlength=
"15"
/>
<input
type=
"text"
name=
"usersPerRoster"
value=
"
<%=
(
usersPerRoster
!=
null
?
usersPerRoster
:
"
9
"
)
%>
"
size=
"5"
maxlength=
"15"
/>
</td>
</tr>
<tr
class=
"c1"
>
<td
width=
"1%"
colspan=
"2"
nowrap
>
<input
type=
"submit"
name=
"Create"
/>
</td>
</tr>
<tr>
<td
colspan=
"2"
width=
"90%"
><label
class=
"jive-label"
for=
"messageGenerate"
>
Generate chat messages:
</label><br>
Generates dummy chat messages between users. Useful for testing message archiving.
</td>
<td><input
type=
"checkbox"
id=
"messageGenerate"
name=
"messageGenerate"
<%=
"checked"
%>
/></td>
</tr>
<tr
class=
"c1"
>
<td
width=
"1%"
colspan=
"2"
nowrap
>
<input
type=
"submit"
name=
"Create"
/>
</td>
</tr>
</table>
</div>
</fieldset>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment