head	1.11;
access;
symbols
	TIGRIS_1_1_0RC2:1.5
	TIGRIS_1_1_0RC1:1.5
	TIGRIS_1_1:1.5.0.4
	TIGRIS_1_0_8:1.5
	TIGRIS_1_0_8RC3:1.5
	TIGRIS_1_0_8RC2:1.5
	TIGRIS_1_0_8RC1:1.5
	TIGRIS_1_0_7:1.5
	TIGRIS_1_0_7RC3:1.5
	TIGRIS_1_0_7RC2:1.5
	TIGRIS_1_0_7RC1:1.5
	TIGRIS_1_0_6:1.5
	TIGRIS_1_0_6RC5:1.5
	TIGRIS_1_0_6RC4:1.5
	TIGRIS_1_0_6RC3:1.5
	TIGRIS_1_0_6RC2:1.5
	TIGRIS_1_0_6RC1:1.5
	TIGRIS_1_0_5:1.5
	TIGRIS_1_0_5RC6:1.5
	TIGRIS_1_0_5RC5:1.5
	TIGRIS_1_0_5RC4:1.5
	TIGRIS_1_0_5RC3:1.5
	TIGRIS_1_0_5RC2:1.5
	TIGRIS_1_0_5RC1:1.5
	TIGRIS_1_0_4:1.5
	TIGRIS_1_0_3:1.5
	TIGRIS_1_0_2:1.5
	TIGRIS_1_0_1:1.5
	TIGRIS_1_0:1.5.0.6
	TIGRIS_1_0_0:1.5
	TIGRIS_1_0_0_RC1:1.5.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.1
	TIGRIS_0_9_2_3:1.1
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.3
	TIGRIS_0_9_2_1:1.3
	TIGRIS_0_9_2:1.1.0.4
	TIGRIS_0_9_0:1.1.0.2;
locks; strict;
comment	@# @;


1.11
date	2001.08.11.09.08.01;	author dlr;	state Exp;
branches;
next	1.10;

1.10
date	2001.07.18.10.05.12;	author dlr;	state Exp;
branches;
next	1.9;

1.9
date	2001.06.01.20.31.13;	author leonardr;	state Exp;
branches;
next	1.8;

1.8
date	2001.06.01.19.52.47;	author leonardr;	state Exp;
branches;
next	1.7;

1.7
date	2001.05.23.01.50.10;	author dlr;	state Exp;
branches;
next	1.6;

1.6
date	2001.04.25.19.27.49;	author dlr;	state Exp;
branches;
next	1.5;

1.5
date	2001.03.07.01.53.20;	author lucas;	state Exp;
branches;
next	1.4;

1.4
date	2001.02.21.01.08.21;	author dlr;	state Exp;
branches;
next	1.3;

1.3
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.3.2.1;
next	1.2;

1.2
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.1;

1.1
date	2000.12.18.23.44.01;	author leonardr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2001.02.21.00.32.32;	author dlr;	state Exp;
branches;
next	;

1.3.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	1.3.2.2;

1.3.2.2
date	2001.02.13.00.04.58;	author leonardr;	state Exp;
branches;
next	1.3.2.3;

1.3.2.3
date	2001.02.15.20.50.35;	author leonardr;	state Exp;
branches;
next	1.3.2.4;

1.3.2.4
date	2001.02.16.03.01.26;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.11
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@/* ================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.collab.net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */

package org.tigris.helm.domain;

import java.util.*;
import javax.servlet.http.*;

import org.apache.velocity.context.Context;

import org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;

import org.tigris.helm.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.tool.ContextAPI;
import org.tigris.helm.tool.paginate.PrebuiltList;
import org.tigris.helm.tool.SessionManager;

/**
 * Displays currently active sessions
 *
 * @@author <a href="mailto:davidp@@collab.net">David C. Pellegrini</a>
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Revision: 1.10 $
 *
 * Copyright (c) 1999 dataweb systems, inc.
 * Copyright (c) 1999-2001 CollabNet, Inc.
 */
public class SessionList extends HelmServlet 
{
    private static final boolean DEBUG = false;
   
    /**
     * Displays active sessions.
     */
    protected String processRequest(Context context)
        throws NestableException, RedirectException
    {
        String templateName = super.processRequest(context);

        String action = getAction(context);
        // Handle the button request
        try
        {
            // Get all of the active sessions
            HttpSession session = ContextAPI.getRunData(context).getSession();
            HttpSessionContext sessionContext = session.getSessionContext();
            Enumeration sessionIDs = sessionContext.getIds();
            int numSessions = 0;
            int zombies = 0;
            int guests = 0;
            SessionManager sMgr = null;
            List activeSessions = new ArrayList(100);

            AccessControlList acl = getACL(context);
            String guestUserID = UserPeer.getAnonymousUser().getID();

            HttpSession activeSession;
            while (sessionIDs.hasMoreElements())
            {
                String sessionID = (String)sessionIDs.nextElement();
                activeSession = sessionContext.getSession(sessionID);
                sMgr = (SessionManager)
                    activeSession.getValue("SessionManager");
                if (sMgr == null)
                {
                    zombies++;
                }
                else
                {
                    String userID = sMgr.getUserID();
                    if (userID.equals(guestUserID))
                    {
                        guests++;
                    }
                    else
                    {
                        User user = UserPeer.getInstance(userID);
                        if (user.isViewableBy(acl))
                        {
                            numSessions++;
                            activeSessions.add(sMgr);
                        }
                    }
                }
            }

            Integer itemsPerPage = (Integer)context.get(ITEMS_PER_PAGE_KEY);
            List prebuiltList = new PrebuiltList(itemsPerPage, activeSessions);
            Log.debug("PrebuildList: " + prebuiltList.size() 
                      + " entries " + ", " + itemsPerPage + " ipp");

            context.put("count", new Integer(numSessions));
            context.put("guests", new Integer(guests));
            context.put("zombies", new Integer(zombies));            
            context.put("activeSessions", prebuiltList);
        }
        catch (Exception e)
        {
            Log.error("Exception thrown in ActiveSessions: ", e);
            throw new NestableException(e);
        }
        return templateName;
    }
}
@


1.10
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d55 1
a55 1
import org.apache.turbine.util.TurbineException;
d59 1
d68 1
a68 1
 * @@version $Revision: 1.9 $
d81 1
a81 1
        throws TurbineException, RedirectException
d90 1
a90 2
            HttpSession session = getRunData(context).getSession();
            HttpSession activeSession = null;
d102 1
d145 1
a145 1
            throw new TurbineException(e);
@


1.9
log
@Paginated session list.
@
text
@a49 1
import java.sql.*;
a56 3
import org.tigris.helm.tool.SessionManager;
import org.joist.security.*;

d60 1
d67 1
a67 1
 * @@version $Revision: 1.8 $
d77 1
a77 6
     *  Displays the active session
     * @@param    connection  A connection to a JDBC database
     * @@param    context  A Context partially populated by WMServlet.
     * @@return    The template name
     * @@exception    HandlerException
     * @@exception    RedirectException
@


1.8
log
@Properly tally guests differently from regular users.
@
text
@a56 1
import org.apache.turbine.util.TurbineException;
d63 2
a64 1
import org.tigris.helm.om.*;
d70 1
a70 1
 * @@version $Revision: 1.7 $
d139 5
d146 2
a147 2
            context.put("zombies", new Integer(zombies));
            context.put("activeSessions", activeSessions);
@


1.7
log
@Ported Helm from WebMacro to Velocity.
@
text
@d70 1
a70 1
 * @@version $Revision: 1.6 $
d103 1
a103 1
            int phantoms = 0;
d108 1
d123 1
a123 1
                    if (userID == null)
d125 1
a125 1
                        phantoms++;
d140 1
a140 1
            context.put("phantoms", new Integer(phantoms));
@


1.6
log
@Formatting cleanup.  No functional change.
@
text
@d53 1
a53 1
import org.webmacro.servlet.*;
d56 2
d59 1
a59 1
import org.joist.session.*;
d70 1
a70 1
 * @@version $Revision: 1.5 $
d82 1
a82 1
     * @@param    context  A WebContext partially populated by WMServlet.
d87 2
a88 2
    protected String processRequest (Connection connection, WebContext context)
        throws HandlerException, RedirectException
d90 1
a90 1
        String templateName = super.processRequest(connection, context);
d97 1
a97 1
            HttpSession session = context.getSession();
d146 1
a146 1
            throw new HandlerException(e.getMessage());
@


1.5
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d64 9
a72 10
  * Displays currently active sessions
  *
  * @@author David C. Pellegrini <A HREF="mailto:davidp@@collab.net">davidp@@collab.net</A>,
  * @@author Leonard Richardson <A HREF="mailto:leonardr@@collab.net">leonardr@@collab.net</A>,
  * @@version $Revision: 1.4 $
  *
  * Copyright (c) 1999 dataweb systems, inc.
  * Copyright (c) 1999-2001 CollabNet, Inc.
  */

d75 1
a75 1
    static private boolean DEBUG = false;
d79 5
a83 5
     * @@param	connection  A connection to a JDBC database
     * @@param	context  A WebContext partially populated by WMServlet.
     * @@return	The template name
     * @@exception	HandlerException
     * @@exception	RedirectException
d88 1
a88 1
	String templateName = super.processRequest(connection, context);
d91 3
a93 3
	// Handle the button request
	try
	{
d116 3
a118 1
                } else {
d121 1
d123 1
d135 1
a135 1
            
d140 7
a146 7
	}
	catch (Exception e)
	{
	    Log.error("Exception thrown in ActiveSessions: ", e);
	    throw new HandlerException(e.getMessage());
	}
	return templateName;
@


1.4
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d62 1
a62 3
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;

d68 1
a68 1
  * @@version $Revision: 1.3.2.4 $
@


1.3
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d2 1
a2 1
 * Copyright (c) 2000 CollabNet.  All rights reserved.
a52 2
import org.tigris.helm.security.*;
import org.webmacro.util.*;
d55 2
d60 5
d70 1
a70 1
  * @@version $Revision: 1.1 $
d73 1
a73 1
  * Copyright (c) 1999, 2000 CollabNet, Inc.
d78 1
a78 2
    static private Log log = new Log("Sessions", "SessionList");
    static private boolean debug = false;
d88 2
a89 3
	protected String
    processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
d108 2
a109 1
            AccessControlList acl = getACL(context, connection);
d125 2
a126 3
                        User user = new User(connection, sMgr.getDataManager(),
                                             userID);
                        if (user.canBeViewedBy(acl))
d134 1
a134 1

d142 2
a143 4
	    log.exception(e);
	    String message ="ActiveSessions: " + e.getMessage();
	    if (debug) log.info(message);
	    throw new HandlerException(message);
@


1.3.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d65 1
a65 1
  * @@version $Revision: 1.3 $
@


1.3.2.2
log
@Ported SessionList servlet.
@
text
@d2 1
a2 1
 * Copyright (c) 2001 CollabNet.  All rights reserved.
d53 2
a56 2
import org.apache.turbine.util.Log;

a59 4
import org.tigris.helm.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;

d68 1
a68 1
  * Copyright (c) 1999-2001 CollabNet, Inc.
d73 2
a74 1
    static private boolean DEBUG = false;
d84 3
a86 2
    protected String processRequest (Connection connection, WebContext context)
        throws HandlerException, RedirectException
d105 1
a105 2
            AccessControlList acl = getACL(context);

d121 3
a123 2
                        User user = UserPeer.getInstance(userID);
                        if (user.isViewableBy(acl))
d131 1
a131 1
            
d139 4
a142 2
	    Log.error("Exception thrown in ActiveSessions: ", e);
	    throw new HandlerException(e.getMessage());
@


1.3.2.3
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d69 1
a69 1
  * @@version $Revision: 1.3.2.2 $
@


1.3.2.4
log
@Added new imports necessitated by Torque.
@
text
@a62 1
import org.tigris.helm.om.base.*;
d69 1
a69 1
  * @@version $Revision: 1.3.2.3 $
@


1.2
log
@revert this stuff to its state as of 2001/01/24 12:42:00 GMT -- with
the following exceptions, which have some different modifications so
they'll work with changes which have happened in joist:

ProjectNewsEdit.java
SkinManager.java
SkinStyleElementValueManager.java
StyleElementManager.java
StyleManager.java

it compiles.  i dunno if it works, though.
@
text
@@


1.1
log
@Ported session list servlet from Joist.
@
text
@d65 1
a65 1
  * @@version $Revision: 1.4 $
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d53 2
a56 2
import org.apache.turbine.util.Log;

a59 5
import org.tigris.helm.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;

d65 1
a65 1
  * @@version $Revision: 1.3.2.4 $
d68 1
a68 1
  * Copyright (c) 1999-2001 CollabNet, Inc.
d73 2
a74 1
    static private boolean DEBUG = false;
d84 3
a86 2
    protected String processRequest (Connection connection, WebContext context)
        throws HandlerException, RedirectException
d105 1
a105 2
            AccessControlList acl = getACL(context);

d121 3
a123 2
                        User user = UserPeer.getInstance(userID);
                        if (user.isViewableBy(acl))
d131 1
a131 1
            
d139 4
a142 2
	    Log.error("Exception thrown in ActiveSessions: ", e);
	    throw new HandlerException(e.getMessage());
@


