Commit 69c4b7c0 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Additional group work.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@530 b35dd754-fafc-0310-a699-88a17e54d16e
parent a38f4e11
...@@ -74,11 +74,8 @@ CREATE TABLE jiveVCard ( ...@@ -74,11 +74,8 @@ CREATE TABLE jiveVCard (
CREATE TABLE jiveGroup ( CREATE TABLE jiveGroup (
name VARCHAR(50) NOT NULL, name VARCHAR(50) NOT NULL,
description VARCHAR(255), description VARCHAR(255),
creationDate CHAR(15) NOT NULL,
modificationDate CHAR(15) NOT NULL,
CONSTRAINT jiveGroup_pk PRIMARY KEY (name) CONSTRAINT jiveGroup_pk PRIMARY KEY (name)
); );
CREATE INDEX jiveGrp_cDate_idx ON jiveGroup (creationDate ASC);
CREATE TABLE jiveGroupProp ( CREATE TABLE jiveGroupProp (
......
...@@ -85,11 +85,8 @@ CREATE TABLE jiveDomain ( ...@@ -85,11 +85,8 @@ CREATE TABLE jiveDomain (
CREATE TABLE jiveGroup ( CREATE TABLE jiveGroup (
name VARCHAR(50) NOT NULL, name VARCHAR(50) NOT NULL,
description VARCHAR(255), description VARCHAR(255),
creationDate VARCHAR(15) NOT NULL,
modificationDate VARCHAR(15) NOT NULL,
CONSTRAINT jiveGroup_pk PRIMARY KEY (name) CONSTRAINT jiveGroup_pk PRIMARY KEY (name)
); );
CREATE INDEX jiveGroup_cDate_idx ON jiveGroup (creationDate);
CREATE TABLE jiveGroupProp ( CREATE TABLE jiveGroupProp (
......
...@@ -23,10 +23,7 @@ CREATE TABLE jiveUserProp ( ...@@ -23,10 +23,7 @@ CREATE TABLE jiveUserProp (
CREATE TABLE jiveGroup ( CREATE TABLE jiveGroup (
name VARCHAR(50) NOT NULL, name VARCHAR(50) NOT NULL,
description VARCHAR(255), description VARCHAR(255),
creationDate CHAR(15) NOT NULL,
modificationDate CHAR(15) NOT NULL,
PRIMARY KEY (name), PRIMARY KEY (name),
INDEX jiveGroup_cDate_idx (creationDate)
); );
CREATE TABLE jiveGroupProp ( CREATE TABLE jiveGroupProp (
......
...@@ -74,11 +74,8 @@ CREATE TABLE jiveVCard ( ...@@ -74,11 +74,8 @@ CREATE TABLE jiveVCard (
CREATE TABLE jiveGroup ( CREATE TABLE jiveGroup (
name VARCHAR2(50) NOT NULL, name VARCHAR2(50) NOT NULL,
description VARCHAR2(255), description VARCHAR2(255),
creationDate CHAR(15) NOT NULL,
modificationDate CHAR(15) NOT NULL,
CONSTRAINT jiveGroup_pk PRIMARY KEY (groupName) CONSTRAINT jiveGroup_pk PRIMARY KEY (groupName)
); );
CREATE INDEX jiveGroup_cDate_idx ON jiveGroup (creationDate ASC);
CREATE TABLE jiveGroupProp ( CREATE TABLE jiveGroupProp (
groupName VARCHAR(50) NOT NULL, groupName VARCHAR(50) NOT NULL,
......
...@@ -77,11 +77,8 @@ CREATE TABLE jiveVCard ( ...@@ -77,11 +77,8 @@ CREATE TABLE jiveVCard (
CREATE TABLE jiveGroup ( CREATE TABLE jiveGroup (
name VARCHAR(50) NOT NULL, name VARCHAR(50) NOT NULL,
description VARCHAR(255), description VARCHAR(255),
creationDate CHAR(15) NOT NULL,
modificationDate CHAR(15) NOT NULL,
CONSTRAINT jiveGroup_pk PRIMARY KEY (name) CONSTRAINT jiveGroup_pk PRIMARY KEY (name)
); );
CREATE INDEX jiveGroup_cDate_idx ON jiveGroup (creationDate);
CREATE TABLE jiveGroupProp ( CREATE TABLE jiveGroupProp (
......
...@@ -77,11 +77,8 @@ CREATE TABLE jiveVCard ( ...@@ -77,11 +77,8 @@ CREATE TABLE jiveVCard (
CREATE TABLE jiveGroup ( CREATE TABLE jiveGroup (
name NVARCHAR(100) NOT NULL, name NVARCHAR(100) NOT NULL,
description NVARCHAR(255), description NVARCHAR(255),
creationDate CHAR(15) NOT NULL,
modificationDate CHAR(15) NOT NULL,
CONSTRAINT group_pk PRIMARY KEY (name) CONSTRAINT group_pk PRIMARY KEY (name)
); );
CREATE INDEX jiveGroup_cDate_idx ON jiveGroup (creationDate);
CREATE TABLE jiveGroupProp ( CREATE TABLE jiveGroupProp (
......
...@@ -19,7 +19,6 @@ import java.sql.Connection; ...@@ -19,7 +19,6 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Date;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Collection; import java.util.Collection;
...@@ -32,11 +31,9 @@ import java.util.Collection; ...@@ -32,11 +31,9 @@ import java.util.Collection;
public class DbGroupProvider implements GroupProvider { public class DbGroupProvider implements GroupProvider {
private static final String INSERT_GROUP = private static final String INSERT_GROUP =
"INSERT INTO jiveGroup (name, description, creationDate, modificationDate) " + "INSERT INTO jiveGroup (name, description) VALUES (?, ?)";
"VALUES (?, ?, ?, ?)";
private static final String SAVE_GROUP = private static final String SAVE_GROUP =
"UPDATE jiveGroup SET description=?, creationDate=?, modificationDate=? " + "UPDATE jiveGroup SET description=? WHERE name=?";
"WHERE name=?";
private static final String SET_GROUP_NAME_1 = private static final String SET_GROUP_NAME_1 =
"UPDATE jiveGroup SET name=? WHERE name=?"; "UPDATE jiveGroup SET name=? WHERE name=?";
private static final String SET_GROUP_NAME_2 = private static final String SET_GROUP_NAME_2 =
...@@ -53,7 +50,7 @@ public class DbGroupProvider implements GroupProvider { ...@@ -53,7 +50,7 @@ public class DbGroupProvider implements GroupProvider {
private static final String LOAD_MEMBERS = private static final String LOAD_MEMBERS =
"SELECT username FROM jiveGroupUser WHERE administrator=0 AND groupName=?"; "SELECT username FROM jiveGroupUser WHERE administrator=0 AND groupName=?";
private static final String SELECT_GROUP_BY_NAME = private static final String SELECT_GROUP_BY_NAME =
"SELECT description, creationDate, modificationDate FROM jiveGroup WHERE name=?"; "SELECT description FROM jiveGroup WHERE name=?";
private static final String REMOVE_USER = private static final String REMOVE_USER =
"DELETE FROM jiveGroupUser WHERE groupName=? AND username=?"; "DELETE FROM jiveGroupUser WHERE groupName=? AND username=?";
private static final String ADD_USER = private static final String ADD_USER =
...@@ -63,8 +60,6 @@ public class DbGroupProvider implements GroupProvider { ...@@ -63,8 +60,6 @@ public class DbGroupProvider implements GroupProvider {
private static final String ALL_GROUPS = "SELECT name FROM jiveGroup"; private static final String ALL_GROUPS = "SELECT name FROM jiveGroup";
public Group createGroup(String name) throws GroupAlreadyExistsException { public Group createGroup(String name) throws GroupAlreadyExistsException {
long now = System.currentTimeMillis();
Date nowDate = new Date(now);
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try { try {
...@@ -72,8 +67,6 @@ public class DbGroupProvider implements GroupProvider { ...@@ -72,8 +67,6 @@ public class DbGroupProvider implements GroupProvider {
pstmt = con.prepareStatement(INSERT_GROUP); pstmt = con.prepareStatement(INSERT_GROUP);
pstmt.setString(1, name); pstmt.setString(1, name);
pstmt.setString(2, ""); pstmt.setString(2, "");
pstmt.setString(3, StringUtils.dateToMillis(nowDate));
pstmt.setString(4, StringUtils.dateToMillis(nowDate));
pstmt.executeUpdate(); pstmt.executeUpdate();
} }
catch (SQLException e) { catch (SQLException e) {
...@@ -87,13 +80,11 @@ public class DbGroupProvider implements GroupProvider { ...@@ -87,13 +80,11 @@ public class DbGroupProvider implements GroupProvider {
} }
Collection<String> members = getMembers(name, false); Collection<String> members = getMembers(name, false);
Collection<String> administrators = getMembers(name, true); Collection<String> administrators = getMembers(name, true);
return new Group(this, name, "", nowDate, nowDate, members, administrators); return new Group(this, name, "", members, administrators);
} }
public Group getGroup(String name) throws GroupNotFoundException { public Group getGroup(String name) throws GroupNotFoundException {
String description = null; String description = null;
Date creationDate = null;
Date modificationDate = null;
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
...@@ -108,8 +99,6 @@ public class DbGroupProvider implements GroupProvider { ...@@ -108,8 +99,6 @@ public class DbGroupProvider implements GroupProvider {
} }
if (rs.next()) { if (rs.next()) {
description = rs.getString(1); description = rs.getString(1);
creationDate = new java.util.Date(Long.parseLong(rs.getString(2).trim()));
modificationDate = new java.util.Date(Long.parseLong(rs.getString(3).trim()));
} }
} }
catch (SQLException e) { catch (SQLException e) {
...@@ -123,12 +112,11 @@ public class DbGroupProvider implements GroupProvider { ...@@ -123,12 +112,11 @@ public class DbGroupProvider implements GroupProvider {
} }
Collection<String> members = getMembers(name, false); Collection<String> members = getMembers(name, false);
Collection<String> administrators = getMembers(name, true); Collection<String> administrators = getMembers(name, true);
return new Group(this, name, description, creationDate, modificationDate, return new Group(this, name, description, members, administrators);
members, administrators);
} }
public void updateGroup(String name, String description, Date creationDate, public void setDescription(String name, String description)
Date modificationDate) throws GroupNotFoundException throws GroupNotFoundException
{ {
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
...@@ -136,9 +124,7 @@ public class DbGroupProvider implements GroupProvider { ...@@ -136,9 +124,7 @@ public class DbGroupProvider implements GroupProvider {
con = DbConnectionManager.getConnection(); con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(SAVE_GROUP); pstmt = con.prepareStatement(SAVE_GROUP);
pstmt.setString(1, description); pstmt.setString(1, description);
pstmt.setString(2, StringUtils.dateToMillis(creationDate)); pstmt.setString(2, name);
pstmt.setString(3, StringUtils.dateToMillis(modificationDate));
pstmt.setString(4, name);
pstmt.executeUpdate(); pstmt.executeUpdate();
} }
catch (SQLException e) { catch (SQLException e) {
...@@ -153,7 +139,7 @@ public class DbGroupProvider implements GroupProvider { ...@@ -153,7 +139,7 @@ public class DbGroupProvider implements GroupProvider {
} }
} }
public void setGroupName(String oldName, String newName) throws UnsupportedOperationException, public void setName(String oldName, String newName) throws UnsupportedOperationException,
GroupAlreadyExistsException GroupAlreadyExistsException
{ {
Connection con = null; Connection con = null;
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
package org.jivesoftware.messenger.group; package org.jivesoftware.messenger.group;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.Cacheable;
import org.jivesoftware.util.CacheSizes;
import org.jivesoftware.database.DbConnectionManager; import org.jivesoftware.database.DbConnectionManager;
import java.util.*; import java.util.*;
...@@ -28,7 +30,7 @@ import java.sql.SQLException; ...@@ -28,7 +30,7 @@ import java.sql.SQLException;
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
public class Group { public class Group implements Cacheable {
private static final String LOAD_PROPERTIES = private static final String LOAD_PROPERTIES =
"SELECT name, propValue FROM jiveGroupProp WHERE groupID=?"; "SELECT name, propValue FROM jiveGroupProp WHERE groupID=?";
...@@ -43,8 +45,6 @@ public class Group { ...@@ -43,8 +45,6 @@ public class Group {
private GroupManager groupManager; private GroupManager groupManager;
private String name; private String name;
private String description; private String description;
private Date creationDate;
private Date modificationDate;
private Map<String, String> properties; private Map<String, String> properties;
private Collection<String> members; private Collection<String> members;
private Collection<String> administrators; private Collection<String> administrators;
...@@ -55,20 +55,16 @@ public class Group { ...@@ -55,20 +55,16 @@ public class Group {
* @param provider the group provider. * @param provider the group provider.
* @param name the name. * @param name the name.
* @param description the description. * @param description the description.
* @param creationDate the date the group was created.
* @param modificationDate the date the group was latest modified.
* @param members a Collection of the group members (includes administrators). * @param members a Collection of the group members (includes administrators).
* @param administrators a Collection of the group administrators. * @param administrators a Collection of the group administrators.
*/ */
protected Group(GroupProvider provider, String name, String description, Date creationDate, protected Group(GroupProvider provider, String name, String description,
Date modificationDate, Collection<String> members, Collection<String> administrators) Collection<String> members, Collection<String> administrators)
{ {
this.provider = provider; this.provider = provider;
this.groupManager = GroupManager.getInstance(); this.groupManager = GroupManager.getInstance();
this.name = name; this.name = name;
this.description = description; this.description = description;
this.creationDate = creationDate;
this.modificationDate = modificationDate;
this.members = members; this.members = members;
this.administrators = administrators; this.administrators = administrators;
} }
...@@ -90,7 +86,7 @@ public class Group { ...@@ -90,7 +86,7 @@ public class Group {
*/ */
public void setName(String name) { public void setName(String name) {
try { try {
provider.setGroupName(this.name, name); provider.setName(this.name, name);
groupManager.groupCache.remove(this.name); groupManager.groupCache.remove(this.name);
this.name = name; this.name = name;
groupManager.groupCache.put(name, this); groupManager.groupCache.put(name, this);
...@@ -120,7 +116,7 @@ public class Group { ...@@ -120,7 +116,7 @@ public class Group {
*/ */
public void setDescription(String description) { public void setDescription(String description) {
try { try {
provider.updateGroup(name, description, creationDate, modificationDate); provider.setDescription(name, description);
this.description = description; this.description = description;
} }
catch (Exception e) { catch (Exception e) {
...@@ -128,59 +124,6 @@ public class Group { ...@@ -128,59 +124,6 @@ public class Group {
} }
} }
/**
* Returns the date that the group was created.
*
* @return the date the group was created.
*/
public Date getCreationDate() {
return creationDate;
}
/**
* Sets the creation date of the group. In most cases, the
* creation date will default to when the group was entered
* into the system. However, the date needs to be set manually when
* importing data.
*
* @param creationDate the date the group was created.
*/
public void setCreationDate(Date creationDate) {
try {
provider.updateGroup(name, description, creationDate, modificationDate);
this.creationDate = creationDate;
}
catch (Exception e) {
Log.error(e);
}
}
/**
* Returns the date that the group was last modified.
*
* @return the date the group record was last modified.
*/
public Date getModificationDate() {
return modificationDate;
}
/**
* Sets the date the group was last modified. Skin authors
* should ignore this method since it only intended for
* system maintenance.
*
* @param modificationDate the date the group was modified.
*/
public void setModificationDate(Date modificationDate) {
try {
provider.updateGroup(name, description, creationDate, modificationDate);
this.modificationDate = modificationDate;
}
catch (Exception e) {
Log.error(e);
}
}
/** /**
* Returns all extended properties of the group. Groups * Returns all extended properties of the group. Groups
* have an arbitrary number of extended properties. * have an arbitrary number of extended properties.
...@@ -221,6 +164,16 @@ public class Group { ...@@ -221,6 +164,16 @@ public class Group {
return new MemberCollection(members, false); return new MemberCollection(members, false);
} }
public int getCachedSize() {
// Approximate the size of the object in bytes by calculating the size
// of each field.
int size = 0;
size += CacheSizes.sizeOfObject(); // overhead of object
size += CacheSizes.sizeOfString(name);
size += CacheSizes.sizeOfString(description);
return size;
}
/** /**
* Collection implementation that notifies the GroupProvider of any * Collection implementation that notifies the GroupProvider of any
* changes to the collection. * changes to the collection.
......
...@@ -33,8 +33,15 @@ public class GroupManager { ...@@ -33,8 +33,15 @@ public class GroupManager {
Cache groupMemberCache; Cache groupMemberCache;
private GroupProvider provider; private GroupProvider provider;
private static GroupManager instance = new GroupManager();
/**
* Returns a singleton instance of GroupManager.
*
* @return a GroupManager instance.
*/
public static GroupManager getInstance() { public static GroupManager getInstance() {
return null; return instance;
} }
private GroupManager() { private GroupManager() {
......
...@@ -14,7 +14,6 @@ package org.jivesoftware.messenger.group; ...@@ -14,7 +14,6 @@ package org.jivesoftware.messenger.group;
import org.jivesoftware.messenger.user.User; import org.jivesoftware.messenger.user.User;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
/** /**
* Group providers load and store group information from a back-end store * Group providers load and store group information from a back-end store
...@@ -68,19 +67,17 @@ public interface GroupProvider { ...@@ -68,19 +67,17 @@ public interface GroupProvider {
* @throws UnsupportedOperationException if the provider does not * @throws UnsupportedOperationException if the provider does not
* support the operation. * support the operation.
*/ */
public void setGroupName(String oldName, String newName) throws UnsupportedOperationException, void setName(String oldName, String newName) throws UnsupportedOperationException,
GroupAlreadyExistsException; GroupAlreadyExistsException;
/** /**
* Updates the backend storage with the group's information. * Updates the group's description.
* *
* @param name the group name. * @param name the group name.
* @param description the group description. * @param description the group description.
* @param creationDate the date the group was created.
* @param modificationDate the date the group was last modified.
* @throws GroupNotFoundException if no existing group could be found to update. * @throws GroupNotFoundException if no existing group could be found to update.
*/ */
void updateGroup(String name, String description, Date creationDate, Date modificationDate) void setDescription(String name, String description)
throws GroupNotFoundException; throws GroupNotFoundException;
/** /**
......
...@@ -16,8 +16,11 @@ import org.jivesoftware.messenger.user.UserInfo; ...@@ -16,8 +16,11 @@ import org.jivesoftware.messenger.user.UserInfo;
import org.jivesoftware.messenger.user.UserInfoProvider; import org.jivesoftware.messenger.user.UserInfoProvider;
import org.jivesoftware.messenger.user.UserNotFoundException; import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.messenger.user.spi.BasicUserInfo; import org.jivesoftware.messenger.user.spi.BasicUserInfo;
import org.jivesoftware.util.Log;
import java.util.Date; import java.util.Date;
import javax.naming.directory.*; import javax.naming.directory.*;
import javax.naming.NamingException;
/** /**
* LDAP implementation of the UserInfoProvider interface. The LdapUserIDProvider * LDAP implementation of the UserInfoProvider interface. The LdapUserIDProvider
...@@ -104,4 +107,7 @@ public class LdapUserInfoProvider implements UserInfoProvider { ...@@ -104,4 +107,7 @@ public class LdapUserInfoProvider implements UserInfoProvider {
} }
return userInfo; return userInfo;
} }
} }
\ No newline at end of file
...@@ -25,6 +25,7 @@ import org.jivesoftware.messenger.PrivateStorage; ...@@ -25,6 +25,7 @@ import org.jivesoftware.messenger.PrivateStorage;
import org.jivesoftware.messenger.PresenceManager; import org.jivesoftware.messenger.PresenceManager;
import org.jivesoftware.messenger.SessionManager; import org.jivesoftware.messenger.SessionManager;
import org.jivesoftware.messenger.XMPPServerInfo; import org.jivesoftware.messenger.XMPPServerInfo;
import org.jivesoftware.messenger.group.GroupManager;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
...@@ -94,6 +95,10 @@ public class WebManager extends WebBean { ...@@ -94,6 +95,10 @@ public class WebManager extends WebBean {
return (UserManager)getServiceLookup().lookup(UserManager.class); return (UserManager)getServiceLookup().lookup(UserManager.class);
} }
public GroupManager getGroupManager() {
return GroupManager.getInstance();
}
public RosterManager getRosterManager() { public RosterManager getRosterManager() {
return (RosterManager)getServiceLookup().lookup(RosterManager.class); return (RosterManager)getServiceLookup().lookup(RosterManager.class);
} }
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</sidebar> </sidebar>
</tab> </tab>
<tab id="tab-users" name="Users" url="user-summary.jsp" description="Click to manage users"> <tab id="tab-users" name="Users/Groups" url="user-summary.jsp" description="Click to manage users and groups">
<sidebar id="sidebar-users" name="Users"> <sidebar id="sidebar-users" name="Users">
...@@ -86,6 +86,28 @@ ...@@ -86,6 +86,28 @@
url="user-search.jsp" url="user-search.jsp"
description="Click to search for a particular user" /> description="Click to search for a particular user" />
</sidebar> </sidebar>
<sidebar id="sidebar-groups" name="Groups">
<item id="group-summary" name="Group Summary"
url="group-summary.jsp"
description="Click to see a list of groups in the system">
<sidebar id="sidebar-group-options" name="Group Options">
<item id="group-properties" name="Group Properties"
url="group-properties.jsp"
description="Click to edit the groups's properties" />
<item id="group-delete" name="Delete Group"
url="group-delete.jsp"
description="Click to delete the group" />
</sidebar>
</item>
<item id="group-create" name="Create New Group"
url="group-create.jsp"
description="Click to add a new group to the system" />
</sidebar>
</tab> </tab>
<tab id="tab-session" name="Sessions" url="session-summary.jsp" description="Click to manage connected sessions"> <tab id="tab-session" name="Sessions" url="session-summary.jsp" description="Click to manage connected sessions">
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
org.jivesoftware.messenger.JiveGlobals, org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.messenger.auth.UnauthorizedException, org.jivesoftware.messenger.auth.UnauthorizedException,
org.jivesoftware.messenger.user.UserNotFoundException, org.jivesoftware.messenger.user.UserNotFoundException,
org.jivesoftware.messenger.auth.GroupNotFoundException" org.jivesoftware.messenger.group.GroupNotFoundException"
isErrorPage="true" isErrorPage="true"
%> %>
......
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 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.
--%>
<%@ page import="org.jivesoftware.util.*,
java.util.HashMap,
java.util.Map,
java.util.*,
org.jivesoftware.messenger.*,
org.jivesoftware.admin.*,
java.io.StringWriter,
java.io.StringWriter,
java.io.IOException,
org.jivesoftware.messenger.auth.UnauthorizedException,
java.io.PrintStream,
org.dom4j.xpath.DefaultXPath,
org.dom4j.*,
org.jivesoftware.messenger.group.*"
errorPage="error.jsp"
%>
<%@ taglib uri="core" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<jsp:useBean id="errors" class="java.util.HashMap" />
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters //
boolean create = request.getParameter("create") != null;
boolean cancel = request.getParameter("cancel") != null;
String name = ParamUtils.getParameter(request,"name");
String description = ParamUtils.getParameter(request,"description");
// Handle a cancel
if (cancel) {
response.sendRedirect("group-summary.jsp");
return;
}
// Handle a request to create a group:
if (create) {
// Validate
if (name == null) {
errors.put("name","");
}
// do a create if there were no errors
if (errors.size() == 0) {
try {
Group newGroup = webManager.getGroupManager().createGroup(name);
if (description != null) {
newGroup.setDescription(description);
}
// Successful, so redirect
response.sendRedirect("group-properties.jsp?success=true&group=" + newGroup.getName());
return;
}
catch (GroupAlreadyExistsException e) {
e.printStackTrace();
errors.put("groupAlreadyExists","");
}
catch (Exception e) {
e.printStackTrace();
errors.put("general","");
Log.error(e);
}
}
}
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "Create Group";
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-create.jsp"));
pageinfo.setPageID("group-create");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<c:set var="submit" value="${param.create}" />
<c:set var="errors" value="${errors}" />
<% if (errors.get("general") != null) { %>
<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">
Error creating the group. Please check your error logs.
</td></tr>
</tbody>
</table>
</div><br>
<% } %>
<table class="box" cellpadding="3" cellspacing="1" border="0" width="600">
<form name="f" action="group-create.jsp" method="post">
<tr><td class="text" colspan="2">
Use the form below to create a new group in the system.
</td></tr>
<tr class="jive-even">
<td>
Group: *
</td>
<td>
<input type="text" name="name" size="30" maxlength="75"
value="<%= ((name!=null) ? name : "") %>">
<% if (errors.get("name") != null) { %>
<span class="jive-error-text">
Invalid name.
</span>
<% } else if (errors.get("groupAlreadyExists") != null) { %>
<span class="jive-error-text">
Group already exists - please choose a different name.
</span>
<% } %>
</td>
</tr>
<tr class="jive-odd">
<td>
Description:
</td>
<td>
<input type="text" name="description" size="30" maxlength="75"
value="<%= ((description!=null) ? description : "") %>">
<% if (errors.get("description") != null) { %>
<span class="jive-error-text">
Invalid description.
</span>
<% } %>
</td>
</tr>
</table>
</div>
<p>
* Required fields
</p>
<input type="submit" name="create" value="Create Group">
<input type="submit" name="cancel" value="Cancel">
</form>
<script language="JavaScript" type="text/javascript">
document.f.name.focus();
function checkFields() {
}
</script>
<jsp:include page="bottom.jsp" flush="true" />
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 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.
--%>
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.admin.*,
org.jivesoftware.messenger.XMPPAddress,
org.jivesoftware.messenger.group.Group"
errorPage="error.jsp"
%>
<%@ taglib uri="core" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters //
boolean cancel = request.getParameter("cancel") != null;
boolean delete = request.getParameter("delete") != null;
String groupName = ParamUtils.getParameter(request,"group");
// Handle a cancel
if (cancel) {
response.sendRedirect("group-properties.jsp?group=" + groupName);
return;
}
// Load the group object
Group group = webManager.getGroupManager().getGroup(groupName);
// Handle a group delete:
if (delete) {
// Delete the group
webManager.getGroupManager().deleteGroup(group);
// Done, so redirect
response.sendRedirect("group-summary.jsp?deletesuccess=true");
return;
}
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "Delete Group";
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-delete.jsp?group="+groupName));
pageinfo.setSubPageID("group-delete");
pageinfo.setExtraParams("group="+groupName);
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<p>
Are you sure you want to delete the group
<b><a href="group-properties.jsp?group=<%= group.getName() %>"><%= group.getName() %></a></b>
from the system?
</p>
<form action="group-delete.jsp">
<input type="hidden" name="group" value="<%= groupName %>">
<input type="submit" name="delete" value="Delete Group">
<input type="submit" name="cancel" value="Cancel">
</form>
<jsp:include page="bottom.jsp" flush="true" />
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 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.
--%>
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.messenger.user.*,
java.text.DateFormat,
java.util.*,
org.jivesoftware.admin.*,
org.jivesoftware.messenger.*,
org.jivesoftware.messenger.group.Group,
org.jivesoftware.messenger.group.GroupNotFoundException"
errorPage="error.jsp"
%>
<%@ taglib uri="core" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% // Get parameters //
boolean cancel = request.getParameter("cancel") != null;
boolean delete = request.getParameter("delete") != null;
String groupName = ParamUtils.getParameter(request,"group");
// Handle a cancel
if (cancel) {
response.sendRedirect("group-summary.jsp");
return;
}
// Handle a delete
if (delete) {
response.sendRedirect("group-delete.jsp?group=" + groupName);
return;
}
// Load the group object
Group group = null;
try {
group = webManager.getGroupManager().getGroup(groupName);
}
catch (GroupNotFoundException gnfe) {
group = webManager.getGroupManager().getGroup(groupName);
}
PresenceManager presenceManager = webManager.getPresenceManager();
// Date formatter for dates
DateFormat formatter = DateFormat.getDateInstance(DateFormat.MEDIUM);
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "Group Properties";
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-properties.jsp?group="+groupName));
pageinfo.setSubPageID("group-properties");
pageinfo.setExtraParams("group="+groupName);
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<p>
Below is a summary of the group. To edit properties, click the "Edit" button below.
</p>
<% if (request.getParameter("success") != null) { %>
<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">
New group created successfully.
</td></tr>
</tbody>
</table>
</div><br>
<% } else if (request.getParameter("editsuccess") != null) { %>
<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">
Group properties updated successfully.
</td></tr>
</tbody>
</table>
</div><br>
<% } %>
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th colspan="2">
Group Properties
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="c1">
Name:
</td>
<td>
<%= group.getName() %>
</td>
</tr>
<tr>
<td class="c1">
Description:
</td>
<td>
<% if (group.getDescription() == null) { %>
&nbsp;
<% } else { %>
<%= group.getDescription() %>
<% } %>
</td>
</tr>
</tbody>
</table>
</div>
<br><br>
<form action="group-edit-form.jsp">
<input type="hidden" name="group" value="<%= group.getName() %>">
<input type="submit" value="Edit Properties">
</form>
<jsp:include page="bottom.jsp" flush="true" />
\ No newline at end of file
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 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.
--%>
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.messenger.user.*,
java.util.*,
java.text.DateFormat,
org.jivesoftware.admin.*,
org.jivesoftware.messenger.group.*"
%>
<%@ taglib uri="core" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "Group Summary";
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-summary.jsp"));
pageinfo.setPageID("group-summary");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<% // Get parameters
try {
int start = ParamUtils.getIntParameter(request,"start",0);
int range = ParamUtils.getIntParameter(request,"range",15);
// Get the user manager
int groupCount = webManager.getGroupManager().getGroupCount();
// paginator vars
int numPages = (int)Math.ceil((double)groupCount/(double)range);
int curPage = (start/range) + 1;
%>
<p>
Below is a list of groups in the system.
</p>
<% if (request.getParameter("deletesuccess") != null) { %>
<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">
Group deleted successfully.
</td></tr>
</tbody>
</table>
</div><br>
<% } %>
<p>
Total Groups: <%= webManager.getGroupManager().getGroupCount() %>,
<% if (numPages > 1) { %>
Showing <%= (start+1) %>-<%= (start+range) %>,
<% } %>
Sorted by Group Name
</p>
<% if (numPages > 1) { %>
<p>
Pages:
[
<% for (int i=0; i<numPages; i++) {
String sep = ((i+1)<numPages) ? " " : "";
boolean isCurrent = (i+1) == curPage;
%>
<a href="group-summary.jsp?start=<%= (i*range) %>"
class="<%= ((isCurrent) ? "jive-current" : "") %>"
><%= (i+1) %></a><%= sep %>
<% } %>
]
</p>
<% } %>
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th>&nbsp;</th>
<th>Name</th>
<th>Members</th>
<th>Admins</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<% // Print the list of groups
Collection<Group> groups = webManager.getGroupManager().getGroups(start, range);
if (groups.isEmpty()) {
%>
<tr>
<td align="center" colspan="6">
No groups in the system.
</td>
</tr>
<%
}
int i = start;
for (Group group : groups) {
i++;
%>
<tr class="jive-<%= (((i%2)==0) ? "even" : "odd") %>">
<td width="1%">
<%= i %>
</td>
<td width="60%">
<a href="group-properties.jsp?group=<%= group.getName() %>"><%= group.getName() %></a>
<br>
<span class="jive-description">
<%= group.getDescription() %>
</span>
</td>
<td width="10%">
<%= group.getMembers().size() %>
</td>
<td width="10%">
<%= group.getAdministrators().size() %>
</td>
<td width="1%" align="center">
<a href="user-edit-form.jsp?group=<%= group.getName() %>"
title="Click to edit..."
><img src="images/edit-16x16.gif" width="17" height="17" border="0"></a>
</td>
<td width="1%" align="center" style="border-right:1px #ccc solid;">
<a href="group-delete.jsp?group=<%= group.getName() %>"
title="Click to delete..."
><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
</td>
</tr>
<%
}
%>
</tbody>
</table>
</div>
<% if (numPages > 1) { %>
<p>
Pages:
[
<% for (i=0; i<numPages; i++) {
String sep = ((i+1)<numPages) ? " " : "";
boolean isCurrent = (i+1) == curPage;
%>
<a href="group-summary.jsp?start=<%= (i*range) %>"
class="<%= ((isCurrent) ? "jive-current" : "") %>"
><%= (i+1) %></a><%= sep %>
<% } %>
]
</p>
<% } %>
<% } catch (Exception e) { e.printStackTrace(); } %>
<jsp:include page="bottom.jsp" flush="true" />
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