Commit 2014c03e authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Updated change log with latest changes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6976 b35dd754-fafc-0310-a699-88a17e54d16e
parent 34ec53b1
......@@ -16,7 +16,9 @@
<root url="jar://$MODULE_DIR$/src/web/WEB-INF/lib/dwr.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<SOURCES>
<root url="file://$MODULE_DIR$/../../java/dwr-1.1.4-src/java" />
</SOURCES>
</library>
</orderEntry>
<orderEntryProperties />
......@@ -41,6 +43,11 @@
<attribute name="URI" value="/WEB-INF/lib/ant-contrib.jar" />
<url>jar://$MODULE_DIR$/build/lib/ant-contrib.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/ant-jive-edition.jar" />
<url>jar://$MODULE_DIR$/build/lib/ant-jive-edition.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/ant-subdirtask.jar" />
......@@ -131,6 +138,11 @@
<attribute name="URI" value="/WEB-INF/lib/commons-logging.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/commons-logging.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/dbutil.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/dbutil.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/dom4j.jar" />
......@@ -166,11 +178,31 @@
<attribute name="URI" value="/WEB-INF/lib/jstl.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/jstl.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/jstun-0.6.1.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/jstun-0.6.1.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/jzlib.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/jzlib.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/mina-core-1.2.0.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/mina-core-1.2.0.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/mina-filter-compression-1.2.0.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/mina-filter-compression-1.2.0.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/mina-filter-ssl-1.2.0.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/mina-filter-ssl-1.2.0.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/shaj.jar" />
......@@ -181,6 +213,16 @@
<attribute name="URI" value="/WEB-INF/lib/sitemesh.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/sitemesh.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/slf4j-api-1.1.0.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/slf4j-api-1.1.0.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/slf4j-simple-1.1.0.jar" />
<url>jar://$MODULE_DIR$/build/lib/merge/slf4j-simple-1.1.0.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/standard.jar" />
......
......@@ -391,7 +391,9 @@
<root url="jar://$MODULE_DIR$/build/lib/merge/mina-filter-ssl-1.2.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<SOURCES>
<root url="file://$MODULE_DIR$/../../java/mina-1.2/filter-ssl/src/main/java" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" exported="">
......@@ -400,7 +402,9 @@
<root url="jar://$MODULE_DIR$/build/lib/merge/mina-core-1.2.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<SOURCES>
<root url="file://$MODULE_DIR$/../../java/mina-1.2/core/src/main/java" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
......@@ -409,7 +413,9 @@
<root url="jar://$MODULE_DIR$/build/lib/merge/mina-filter-compression-1.2.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<SOURCES>
<root url="file://$MODULE_DIR$/../../java/mina-1.2/filter-compression/src/main/java" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
......
......@@ -228,6 +228,7 @@ hr {
<li>[<a href='http://www.igniterealtime.org/issues/browse/ENT-56'>ENT-56</a>] - Warning message is now displayed when license is about to expire (30 days).</li>
<li>[<a href='http://www.igniterealtime.org/issues/browse/ENT-54'>ENT-54</a>] - Added support for iq:version to components to discover Wildfire version.</li>
<li>[<a href='http://www.igniterealtime.org/issues/browse/ENT-55'>ENT-55</a>] - Changed license validation to validate maintenance date.</li>
<li>[<a href='http://www.igniterealtime.org/issues/browse/ENT-62'>ENT-62</a>] - Fixed display error in dashboard when accessing the page immediately after start up.</li>
<li>[<a href='http://www.igniterealtime.org/issues/browse/ENT-37'>ENT-37</a>] - Fixed error in MSSQL due to conflict with keyword.</li>
<li>[<a href='http://www.igniterealtime.org/issues/browse/ENT-59'>ENT-59</a>] - Added Portuguese translation.</li>
</ul>
......
......@@ -672,11 +672,11 @@ public class ClientSession extends Session {
// Include Stream Compression Mechanism
// TODO Fix stream compression when using MINA and then enable this code
/*if (conn.getCompressionPolicy() != Connection.CompressionPolicy.disabled &&
if (conn.getCompressionPolicy() != Connection.CompressionPolicy.disabled &&
!conn.isCompressed()) {
sb.append(
"<compression xmlns=\"http://jabber.org/features/compress\"><method>zlib</method></compression>");
}*/
}
if (getAuthToken() == null) {
// Advertise that the server supports Non-SASL Authentication
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
Plugin configuration for the broadcast plugin.
-->
<plugin>
<class>org.jivesoftware.wildfire.plugin.UserCreationPlugin</class>
<name>User Creation</name>
<description>Creates users and populates rosters.</description>
<author>Jive Software</author>
<version>1.0</version>
<date>12/10/2006</date>
<url>http://www.igniterealtime.org</url>
<minServerVersion>3.1.0</minServerVersion>
<adminconsole>
<tab id="tab-users">
<sidebar id="sidebar-users">
<item id="users-creation" name="Users Creation"
url="users-creation.jsp"
description="Quickly create users and populate their rosters" />
</sidebar>
</tab>
</adminconsole>
</plugin>
\ No newline at end of file
package org.jivesoftware.wildfire.plugin;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.SharedGroupException;
import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.container.Plugin;
import org.jivesoftware.wildfire.container.PluginManager;
import org.jivesoftware.wildfire.roster.Roster;
import org.jivesoftware.wildfire.roster.RosterItem;
import org.jivesoftware.wildfire.roster.RosterManager;
import org.jivesoftware.wildfire.user.UserAlreadyExistsException;
import org.jivesoftware.wildfire.user.UserManager;
import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.jivesoftware.wildfire.vcard.VCardManager;
import org.xmpp.packet.JID;
import org.xmpp.packet.Presence;
import java.io.File;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Map;
/**
* Created by IntelliJ IDEA.
* User: gato
* Date: Dec 8, 2006
* Time: 10:09:20 AM
* To change this template use File | Settings | File Templates.
*/
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;
static {
Hashtable<Presence.Type, Change> subrTable;
Hashtable<Presence.Type, Change> subsTable;
Hashtable<String, Map<Presence.Type, Change>> sr;
sr = new Hashtable<String, Map<Presence.Type, Change>>();
subrTable = new Hashtable<Presence.Type, Change>();
subsTable = new Hashtable<Presence.Type, Change>();
sr.put("recv", subrTable);
sr.put("send", subsTable);
stateTable.put(RosterItem.SUB_NONE, sr);
// Item wishes to subscribe from owner
// Set flag and update roster if this is a new state, this is the normal way to begin
// a roster subscription negotiation.
subrTable.put(Presence.Type.subscribe, new Change(RosterItem.RECV_SUBSCRIBE, null, null)); // no transition
// Item granted subscription to owner
// The item's state immediately goes from NONE to TO and ask is reset
subrTable.put(Presence.Type.subscribed, new Change(null, RosterItem.SUB_TO, RosterItem.ASK_NONE));
// Item wishes to unsubscribe from owner
// This makes no sense, there is no subscription to remove
subrTable.put(Presence.Type.unsubscribe, new Change(null, null, null));
// Owner has subscription to item revoked
// Valid response if item requested subscription and we're denying request
subrTable.put(Presence.Type.unsubscribed, new Change(null, null, RosterItem.ASK_NONE));
// Owner asking to subscribe to item this is the normal way to begin
// a roster subscription negotiation.
subsTable.put(Presence.Type.subscribe, new Change(null, null, RosterItem.ASK_SUBSCRIBE));
// Item granted a subscription from owner
subsTable.put(Presence.Type.subscribed, new Change(RosterItem.RECV_NONE, RosterItem.SUB_FROM, null));
// Owner asking to unsubscribe to item
// This makes no sense (there is no subscription to unsubscribe from)
subsTable.put(Presence.Type.unsubscribe, new Change(null, null, null));
// Item has subscription from owner revoked
// Valid response if item requested subscription and we're denying request
subsTable.put(Presence.Type.unsubscribed, new Change(RosterItem.RECV_NONE, null, null));
sr = new Hashtable<String, Map<Presence.Type, Change>>();
subrTable = new Hashtable<Presence.Type, Change>();
subsTable = new Hashtable<Presence.Type, Change>();
sr.put("recv", subrTable);
sr.put("send", subsTable);
stateTable.put(RosterItem.SUB_FROM, sr);
// Owner asking to subscribe to item
// Set flag and update roster if this is a new state, this is the normal way to begin
// a mutual roster subscription negotiation.
subsTable.put(Presence.Type.subscribe, new Change(null, null, RosterItem.ASK_SUBSCRIBE));
// Item granted a subscription from owner
// This may be necessary if the recipient didn't get an earlier subscribed grant
// or as a denial of an unsubscribe request
subsTable.put(Presence.Type.subscribed, new Change(RosterItem.RECV_NONE, null, null));
// Owner asking to unsubscribe to item
// This makes no sense (there is no subscription to unsubscribe from)
subsTable.put(Presence.Type.unsubscribe, new Change(null, RosterItem.SUB_NONE, null));
// Item has subscription from owner revoked
// Immediately transition to NONE state
subsTable.put(Presence.Type.unsubscribed, new Change(RosterItem.RECV_NONE, RosterItem.SUB_NONE, null));
// Item wishes to subscribe from owner
// Item already has a subscription so only interesting if item had requested unsubscribe
// Set flag and update roster if this is a new state, this is the normal way to begin
// a mutual roster subscription negotiation.
subrTable.put(Presence.Type.subscribe, new Change(RosterItem.RECV_NONE, null, null));
// Item granted subscription to owner
// The item's state immediately goes from FROM to BOTH and ask is reset
subrTable.put(Presence.Type.subscribed, new Change(null, RosterItem.SUB_BOTH, RosterItem.ASK_NONE));
// Item wishes to unsubscribe from owner
// This is the normal mechanism of removing subscription
subrTable.put(Presence.Type.unsubscribe, new Change(RosterItem.RECV_UNSUBSCRIBE, RosterItem.SUB_NONE, null));
// Owner has subscription to item revoked
// Valid response if owner requested subscription and item is denying request
subrTable.put(Presence.Type.unsubscribed, new Change(null, null, RosterItem.ASK_NONE));
sr = new Hashtable<String, Map<Presence.Type, Change>>();
subrTable = new Hashtable<Presence.Type, Change>();
subsTable = new Hashtable<Presence.Type, Change>();
sr.put("recv", subrTable);
sr.put("send", subsTable);
stateTable.put(RosterItem.SUB_TO, sr);
// Owner asking to subscribe to item
// We're already subscribed, may be trying to unset a unsub request
subsTable.put(Presence.Type.subscribe, new Change(null, null, RosterItem.ASK_NONE));
// Item granted a subscription from owner
// Sets mutual subscription
subsTable.put(Presence.Type.subscribed, new Change(RosterItem.RECV_NONE, RosterItem.SUB_BOTH, null));
// Owner asking to unsubscribe to item
// Normal method of removing subscription
subsTable.put(Presence.Type.unsubscribe, new Change(null, RosterItem.SUB_NONE, RosterItem.ASK_UNSUBSCRIBE));
// Item has subscription from owner revoked
// No subscription to unsub, makes sense if denying subscription request or for
// situations where the original unsubscribed got lost
subsTable.put(Presence.Type.unsubscribed, new Change(RosterItem.RECV_NONE, null, null));
// Item wishes to subscribe from owner
// This is the normal way to negotiate a mutual subscription
subrTable.put(Presence.Type.subscribe, new Change(RosterItem.RECV_SUBSCRIBE, null, null));
// Item granted subscription to owner
// Owner already subscribed to item, could be a unsub denial or a lost packet
subrTable.put(Presence.Type.subscribed, new Change(null, null, RosterItem.ASK_NONE));
// Item wishes to unsubscribe from owner
// There is no subscription. May be trying to cancel earlier subscribe request.
subrTable.put(Presence.Type.unsubscribe, new Change(RosterItem.RECV_NONE, RosterItem.SUB_NONE, null));
// Owner has subscription to item revoked
// Setting subscription to none
subrTable.put(Presence.Type.unsubscribed, new Change(null, RosterItem.SUB_NONE, RosterItem.ASK_NONE));
sr = new Hashtable<String, Map<Presence.Type, Change>>();
subrTable = new Hashtable<Presence.Type, Change>();
subsTable = new Hashtable<Presence.Type, Change>();
sr.put("recv", subrTable);
sr.put("send", subsTable);
stateTable.put(RosterItem.SUB_BOTH, sr);
// Owner asking to subscribe to item
// Makes sense if trying to cancel previous unsub request
subsTable.put(Presence.Type.subscribe, new Change(null, null, RosterItem.ASK_NONE));
// Item granted a subscription from owner
// This may be necessary if the recipient didn't get an earlier subscribed grant
// or as a denial of an unsubscribe request
subsTable.put(Presence.Type.subscribed, new Change(RosterItem.RECV_NONE, null, null));
// Owner asking to unsubscribe to item
// Set flags
subsTable.put(Presence.Type.unsubscribe, new Change(null, RosterItem.SUB_FROM, RosterItem.ASK_UNSUBSCRIBE));
// Item has subscription from owner revoked
// Immediately transition them to TO state
subsTable.put(Presence.Type.unsubscribed, new Change(RosterItem.RECV_NONE, RosterItem.SUB_TO, null));
// Item wishes to subscribe to owner
// Item already has a subscription so only interesting if item had requested unsubscribe
// Set flag and update roster if this is a new state, this is the normal way to begin
// a mutual roster subscription negotiation.
subrTable.put(Presence.Type.subscribe, new Change(RosterItem.RECV_NONE, null, null));
// Item granted subscription to owner
// Redundant unless denying unsub request
subrTable.put(Presence.Type.subscribed, new Change(null, null, RosterItem.ASK_NONE));
// Item wishes to unsubscribe from owner
// This is the normal mechanism of removing subscription
subrTable.put(Presence.Type.unsubscribe, new Change(RosterItem.RECV_UNSUBSCRIBE, RosterItem.SUB_TO, null));
// Owner has subscription to item revoked
// Immediately downgrade state to FROM
subrTable.put(Presence.Type.unsubscribed,
new Change(RosterItem.RECV_NONE, RosterItem.SUB_FROM, RosterItem.ASK_NONE));
}
/**
* <p>Indicate a state change.</p>
* <p>Use nulls to indicate fields that should not be changed.</p>
*/
private static class Change {
public Change(RosterItem.RecvType recv, RosterItem.SubType sub, RosterItem.AskType ask) {
newRecv = recv;
newSub = sub;
newAsk = ask;
}
public RosterItem.RecvType newRecv;
public RosterItem.SubType newSub;
public RosterItem.AskType newAsk;
}
public void initializePlugin(PluginManager manager, File pluginDirectory) {
// Do nothing
}
public void destroyPlugin() {
// Do nothing
}
public void createUsers(String userPrefix, int from, int total) {
// Create users
UserManager userManager = XMPPServer.getInstance().getUserManager();
System.out.println("Creating users accounts: " + total);
int created = 0;
for (int i = from; i < from + total; i++) {
try {
String username = userPrefix + i;
userManager.createUser(username, username, username, null);
created++;
} catch (UserAlreadyExistsException e) {
// Ignore
}
}
System.out.println("Accounts created successfully: " + created);
}
public void populateRosters(String userPrefix, int from, int total, int usersPerRoster) {
XMPPServer server = XMPPServer.getInstance();
RosterManager rosterManager = server.getRosterManager();
int batchTotal = total / usersPerRoster;
System.out.println("Total batches of users: " + batchTotal);
for (int batchNumber = 0; batchNumber < batchTotal; batchNumber++) {
System.out.println("Current batch: " + batchNumber + ". Users: " + batchNumber*usersPerRoster + " - " + ((batchNumber*usersPerRoster)+usersPerRoster));
// Add rosters items between connected users
for (int i = (batchNumber * usersPerRoster) + from;
i < (batchNumber * usersPerRoster) + usersPerRoster + from; i++) {
String username = userPrefix + i;
Roster roster;
try {
roster = rosterManager.getRoster(username);
} catch (UserNotFoundException e) {
continue;
}
if (roster.getRosterItems().size() >= usersPerRoster) {
// Roster already populated. Skip it.
continue;
}
for (int j = (batchNumber * usersPerRoster) + from;
j < (batchNumber * usersPerRoster) + usersPerRoster + from; j++) {
if (i == j) {
continue;
}
try {
Roster recipientRoster = rosterManager.getRoster(userPrefix + j);
manageSub(server.createJID(userPrefix + j, null), true, Presence.Type.subscribe, roster);
manageSub(server.createJID(username, null), false, Presence.Type.subscribe, recipientRoster);
manageSub(server.createJID(userPrefix + j, null), true, Presence.Type.subscribed, roster);
manageSub(server.createJID(username, null), false, Presence.Type.subscribed, recipientRoster);
} catch (UserNotFoundException e) {
// Ignore
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
System.out.println("Rosters populated with " + usersPerRoster + " contacts.");
}
public void createVCards(String userPrefix, int from, int total) {
// Create users
System.out.println("Creating users vCards: " + total);
int created = 0;
for (int i = from; i < from + total; i++) {
try {
String username = userPrefix + i;
VCardManager.getInstance().setVCard(username, getDefaultVCard());
created++;
} catch (Exception e) {
// Ignore
}
}
System.out.println("VCards created successfully: " + created);
}
private Element getDefaultVCard() {
if (vCard != null) {
return vCard;
}
try {
String xml = "<vCard xmlns=\"vcard-temp\"><N><FAMILY>Dombiak</FAMILY><GIVEN>Gaston</GIVEN><MIDDLE>Maximiliano</MIDDLE></N><ORG><ORGNAME>Jive Software</ORGNAME><ORGUNIT/></ORG><FN>Gaston Maximiliano Dombiak</FN><ROLE/><DESC/><JABBERID>gato@jivesoftware.com</JABBERID><userName>12011349</userName><server>ss.ctbc.com.br</server><URL/><NICKNAME>Gato</NICKNAME><TITLE/><PHOTO><TYPE>image/jpeg</TYPE><BINVAL>iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAAKx0lEQVR42u1ZZ1dU1xqeXwECztARRJRYEBHrFQtRY0sMYjeoqHhVFObsI85Qld4UoxQFxIigIE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23MiHn10/rqk+GJjkORU0hIV183SUOIZjLSUfnphEI0wsJfOhAV50fbqPr+uhARhiA+iD8vS0GVxOBs4goEGwP7HwH2ne02InuEfYOQqZH0oIXVII2TYZZZM4fhBoNEiqHek8lJ+gGWW+wNMGZOStXiKfz5Fxkg+S0Mc8u3paHBDy95TMT2WeJT2R15A0covDLHZBhG2MDY5ydBGOj3JkQt+xOTMh4RQH+pcFb9anoQdl6Z0/nIWgT46ejCYHcJL5mGQgJmpINvSUjRZ6fy37pSTlRpa2NSsc6rqXbQUQt8AroRDr/a2sv70ClD7Uq5P4Di9SmbpJ5sgHMhopRkxYCbY4TDpIwINddbA+9TRLJSknfNikb4+YMJGDKNkI9e//6/i/A/Qf/fyvPizBqwQAAAAASUVORK5CYII=</BINVAL></PHOTO><EMAIL><WORK/><INTERNET/><PREF/><USERID>gaston@jivesoftware.com</USERID></EMAIL><EMAIL><HOME/><INTERNET/><PREF/><USERID>gaston@jivesoftware.com</USERID></EMAIL><TEL><PAGER/><WORK/><NUMBER/></TEL><TEL><CELL/><WORK/><NUMBER/></TEL><TEL><VOICE/><WORK/><NUMBER/></TEL><TEL><FAX/><WORK/><NUMBER/></TEL><TEL><PAGER/><HOME/><NUMBER/></TEL><TEL><CELL/><HOME/><NUMBER/></TEL><TEL><VOICE/><HOME/><NUMBER/></TEL><TEL><FAX/><HOME/><NUMBER/></TEL><ADR><WORK/><EXTADD/><PCODE>97204</PCODE><REGION>Oregon</REGION><STREET>317 SW Alder St Ste 500</STREET><CTRY>USA</CTRY><LOCALITY>Portland</LOCALITY></ADR><ADR><HOME/><EXTADD/><PCODE/><REGION/><STREET/><CTRY/><LOCALITY/></ADR></vCard>";
vCard = DocumentHelper.parseText(xml).getRootElement();
return vCard;
} catch (DocumentException e) {
return null;
}
}
private boolean manageSub(JID target, boolean isSending, Presence.Type type, Roster roster)
throws UserAlreadyExistsException, SharedGroupException {
RosterItem item = null;
RosterItem.AskType oldAsk;
RosterItem.SubType oldSub = null;
RosterItem.RecvType oldRecv;
boolean newItem = false;
try {
if (roster.isRosterItem(target)) {
item = roster.getRosterItem(target);
} else {
if (Presence.Type.unsubscribed == type || Presence.Type.unsubscribe == type ||
Presence.Type.subscribed == type) {
// Do not create a roster item when processing a confirmation of
// an unsubscription or receiving an unsubscription request or a
// subscription approval from an unknown user
return false;
}
item = roster.createRosterItem(target, false, true);
item.setGroups(Arrays.asList("Friends"));
roster.updateRosterItem(item);
newItem = true;
}
// Get a snapshot of the item state
oldAsk = item.getAskStatus();
oldSub = item.getSubStatus();
oldRecv = item.getRecvStatus();
// Update the item state based in the received presence type
updateState(item, type, isSending);
// Update the roster IF the item state has changed
if (oldAsk != item.getAskStatus() || oldSub != item.getSubStatus() ||
oldRecv != item.getRecvStatus()) {
roster.updateRosterItem(item);
} else if (newItem) {
// Do not push items with a state of "None + Pending In"
if (item.getSubStatus() != RosterItem.SUB_NONE ||
item.getRecvStatus() != RosterItem.RECV_SUBSCRIBE) {
roster.broadcast(item, false);
}
}
}
catch (UserNotFoundException e) {
// Should be there because we just checked that it's an item
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
return oldSub != item.getSubStatus();
}
private static void updateState(RosterItem item, Presence.Type action, boolean isSending) {
Map<String, Map<Presence.Type, Change>> srTable = stateTable.get(item.getSubStatus());
Map<Presence.Type, Change> changeTable = srTable.get(isSending ? "send" : "recv");
Change change = changeTable.get(action);
if (change.newAsk != null && change.newAsk != item.getAskStatus()) {
item.setAskStatus(change.newAsk);
}
if (change.newSub != null && change.newSub != item.getSubStatus()) {
item.setSubStatus(change.newSub);
}
if (change.newRecv != null && change.newRecv != item.getRecvStatus()) {
item.setRecvStatus(change.newRecv);
}
}
}
<%@ page import="org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.TaskEngine,
org.jivesoftware.wildfire.XMPPServer,
org.jivesoftware.wildfire.plugin.UserCreationPlugin,
java.util.HashMap,
java.util.Map"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<html>
<head>
<title>Quick Users Creation</title>
<meta name="pageID" content="users-creation"/>
</head>
<body>
<%
String prefix = ParamUtils.getParameter(request, "prefix");
String from = ParamUtils.getParameter(request, "from");
String total = ParamUtils.getParameter(request, "total");
String usersPerRoster = ParamUtils.getParameter(request, "usersPerRoster");
Map<String, String> errors = new HashMap<String, String>();
boolean running = false;
if (prefix != null) {
final String userPrefix = prefix;
final int intFrom = Integer.parseInt(from);
final int maxUsers = Integer.parseInt(total);
final int usersRoster = Integer.parseInt(usersPerRoster) + 1;
if (maxUsers % usersRoster != 0 || maxUsers <= usersRoster) {
errors.put("arguments", "");
}
if (errors.isEmpty()) {
final UserCreationPlugin plugin =
(UserCreationPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("usercreation");
TaskEngine.getInstance().submit(new Runnable() {
public void run() {
plugin.createUsers(userPrefix, intFrom, maxUsers);
plugin.populateRosters(userPrefix, intFrom, maxUsers, usersRoster);
plugin.createVCards(userPrefix, intFrom, maxUsers);
}
});
running = true;
}
}
%>
<% if (!errors.isEmpty()) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="/images/error-16x16.gif" width="16" height="16" border="0"/></td>
<td class="jive-icon-label">
<% if (errors.get("arguments") != null) { %>
Number of users per roster should be greater than total number of users. Number of users per roster <b>plus one</b> should also be a multiple of total number of users.
<% } %>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<% } else if (running) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr><td class="jive-icon"><img src="/images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
Users being created in background and getting their rosters populated. Check the stdout for more information.
</td></tr>
</tbody>
</table>
</div><br>
<% } %>
<form name="f" action="users-creation.jsp">
<fieldset>
<legend>Creation Form</legend>
<div>
<table cellpadding="3" cellspacing="1" border="0" width="600">
<tr class="c1">
<td width="1%" colspan="2" nowrap>
User prefix:
&nbsp;<input type="text" name="prefix" value="<%=(prefix != null ? prefix : "") %>" size="30" maxlength="75"/>
</td>
</tr>
<tr class="c1">
<td width="1%" colspan="2" nowrap>
From index:
&nbsp;<input type="text" name="from" value="<%=(from != null ? from : "0") %>" size="5" maxlength="15"/>
</td>
</tr>
<tr class="c1">
<td width="1%" colspan="2" nowrap>
Total users:
&nbsp;<input type="text" name="total" value="<%=(total != null ? total : "1000") %>" size="5" maxlength="15"/>
</td>
</tr>
<tr class="c1">
<td width="1%" colspan="2" nowrap>
Contacts in roster:
&nbsp;<input type="text" name="usersPerRoster" value="<%=(usersPerRoster != null ? usersPerRoster : "30") %>" size="5" maxlength="15"/>
</td>
</tr>
<tr class="c1">
<td width="1%" colspan="2" nowrap>
<input type="submit" name="Create"/>
</td>
</tr>
</table>
</div>
</fieldset>
</form>
</body>
</html>
\ No newline at end of file
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