From 14ba610fdbae0001149ecef5d7691f1478834381 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Wed, 18 Feb 2004 13:03:53 +0000 Subject: [PATCH] Initial check-in git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2232 b35dd754-fafc-0310-a699-88a17e54d16e --- sample/web/moveContact.jsp | 162 +++++++++++++++++++++++++++++++++++-- 1 file changed, 155 insertions(+), 7 deletions(-) diff --git a/sample/web/moveContact.jsp b/sample/web/moveContact.jsp index f79c304a9..1b8924e88 100644 --- a/sample/web/moveContact.jsp +++ b/sample/web/moveContact.jsp @@ -1,7 +1,7 @@ <%-- - - $$RCSfile$$ - - $$Revision$$ - - $$Date$$ + - $RCSfile$ + - $Revision$ + - $Date$ - - Copyright (C) 2002-2003 Jive Software. All rights reserved. - @@ -47,14 +47,162 @@ - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. --%> - +<%@ page import="java.util.*, + org.jivesoftware.smack.*, + org.jivesoftware.smack.packet.*, + org.jivesoftware.smack.util.*"%> +<%@ include file="global.jsp" %> +<% + // If we don't have a valid connection then proceed to login + XMPPConnection conn = (XMPPConnection) session.getAttribute("connection"); + if (conn == null || !conn.isConnected()) { + response.sendRedirect("login.jsp"); + return; + } + Roster roster = conn.getRoster(); + + // Get parameters + String action = getParameter(request, "action"); + String user = getParameter(request, "user"); + String fromGroup = getParameter(request, "fromGroup"); + String toGroup = getParameter(request, "toGroup"); + + // Move the entry from the existing group to a new group + if ("move".equals(action)) { + RosterEntry entry = roster.getEntry(user); + // Remove the entry from the existing group + RosterGroup rosterGroup = roster.getGroup(fromGroup); + rosterGroup.removeEntry(entry); + // Get the new group or create it if it doesn't exist + rosterGroup = roster.getGroup(toGroup); + if (rosterGroup == null) { + rosterGroup = roster.createGroup(toGroup); + } + // Add the new entry to the group + rosterGroup.addEntry(entry); + response.sendRedirect("viewRoster.jsp"); + return; + } + + // Add the entry to a new group + if ("add".equals(action)) { + RosterEntry entry = roster.getEntry(user); + // Get the new group or create it if it doesn't exist + RosterGroup rosterGroup = roster.getGroup(toGroup); + if (rosterGroup == null) { + rosterGroup = roster.createGroup(toGroup); + } + // Add the new entry to the group + rosterGroup.addEntry(entry); + response.sendRedirect("viewRoster.jsp"); + return; + } + + // Delete the entry from a group + if ("delete".equals(action)) { + RosterEntry entry = roster.getEntry(user); + RosterGroup rosterGroup = roster.getGroup(fromGroup); + rosterGroup.removeEntry(entry); + response.sendRedirect("viewRoster.jsp"); + return; + } +%> + -Move entry +Groups Management - -Not implemented yet! View roster + + + + + + + + +
Groups for entry: <%= user%>View roster
 
+ + + + + + + + + +
+ + + + + + +
Add to new group +
+ + + + + + + + + + + + +
Group: 
  + + + + + + + + + + <% if (fromGroup != null) { %> + + + + + + + + + <% } else { %> + + + + <% } %> +
Move + to new group
From To
+ + + + + + +
<%=fromGroup%>Move contact to group +
+
Entry does + not belong to a group (unfiled entry)
 
+ + + + <% + RosterEntry entry = roster.getEntry(user); + RosterGroup group; + for (Iterator it=entry.getGroups(); it.hasNext();) { + group = (RosterGroup) it.next();%> + + + + + <% } %> +
Remove + from groups
<%=group.getName()%>Remove contact from the group