001: /*
002: * File : $Source: /usr/local/cvs/alkacon/com.alkacon.opencms.registration/src/com/alkacon/opencms/registration/CmsRegistrationInfo.java,v $
003: * Date : $Date: 2008-02-19 13:22:30 $
004: * Version: $Revision: 1.1 $
005: *
006: * This file is part of the Alkacon OpenCms Add-On Module Package
007: *
008: * Copyright (c) 2007 Alkacon Software GmbH (http://www.alkacon.com)
009: *
010: * The Alkacon OpenCms Add-On Module Package is free software:
011: * you can redistribute it and/or modify
012: * it under the terms of the GNU General Public License as published by
013: * the Free Software Foundation, either version 3 of the License, or
014: * (at your option) any later version.
015: *
016: * The Alkacon OpenCms Add-On Module Package is distributed
017: * in the hope that it will be useful,
018: * but WITHOUT ANY WARRANTY; without even the implied warranty of
019: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020: * GNU General Public License for more details.
021: *
022: * You should have received a copy of the GNU General Public License
023: * along with the Alkacon OpenCms Add-On Module Package.
024: * If not, see http://www.gnu.org/licenses/.
025: *
026: * For further information about Alkacon Software GmbH, please see the
027: * company website: http://www.alkacon.com.
028: *
029: * For further information about OpenCms, please see the
030: * project website: http://www.opencms.org.
031: */
032:
033: package com.alkacon.opencms.registration;
034:
035: import org.opencms.file.CmsObject;
036: import org.opencms.file.CmsUser;
037: import org.opencms.main.CmsException;
038: import org.opencms.main.OpenCms;
039: import org.opencms.security.CmsOrganizationalUnit;
040:
041: import java.util.ArrayList;
042: import java.util.Iterator;
043: import java.util.List;
044:
045: /**
046: * This class can be used to display statistical information.<p>
047: *
048: * @author Michael Moossen
049: *
050: * @version $Revision: 1.1 $
051: *
052: * @since 7.0.4
053: */
054: public class CmsRegistrationInfo {
055:
056: private static CmsObject m_cms = CmsRegistrationModuleAction
057: .getAdminCms();
058: private CmsOrganizationalUnit m_ou;
059:
060: /**
061: * Bean Constructor.<p>
062: */
063: public CmsRegistrationInfo() {
064:
065: // empty
066: }
067:
068: /**
069: * Returns the activated users.<p>
070: *
071: * @return the activated users
072: *
073: * @throws CmsException if something goes wrong
074: */
075: public List getActivatedUsers() throws CmsException {
076:
077: List users = new ArrayList(getUsers());
078: Iterator itUsers = users.iterator();
079: while (itUsers.hasNext()) {
080: CmsUser user = (CmsUser) itUsers.next();
081: if (!user.isEnabled()) {
082: itUsers.remove();
083: }
084: }
085: return users;
086: }
087:
088: /**
089: * Returns the registered but not activated users.<p>
090: *
091: * @return the registered but not activated users
092: *
093: * @throws CmsException if something goes wrong
094: */
095: public List getNotActivatedUsers() throws CmsException {
096:
097: List users = new ArrayList(getUsers());
098: Iterator itUsers = users.iterator();
099: while (itUsers.hasNext()) {
100: CmsUser user = (CmsUser) itUsers.next();
101: if (user.isEnabled()) {
102: itUsers.remove();
103: }
104: }
105: return users;
106: }
107:
108: /**
109: * Returns the total number of online users.<p>
110: *
111: * @return the total number of online users
112: *
113: * @throws CmsException if something goes wrong
114: */
115: public int getNumOnlineUsers() throws CmsException {
116:
117: return getOnlineUsers().size();
118: }
119:
120: /**
121: * Returns the total number of users.<p>
122: *
123: * @return the total number of users
124: *
125: * @throws CmsException if something goes wrong
126: */
127: public int getNumUsers() throws CmsException {
128:
129: return getUsers().size();
130: }
131:
132: /**
133: * Returns the logged in users.<p>
134: *
135: * @return the logged in users
136: *
137: * @throws CmsException if something goes wrong
138: */
139: public List getOnlineUsers() throws CmsException {
140:
141: List users = new ArrayList(getUsers());
142: Iterator itUsers = users.iterator();
143: while (itUsers.hasNext()) {
144: CmsUser user = (CmsUser) itUsers.next();
145: if (OpenCms.getSessionManager().getSessionInfos(
146: user.getId()).isEmpty()) {
147: itUsers.remove();
148: }
149: }
150: return users;
151: }
152:
153: /**
154: * Returns the users.<p>
155: *
156: * @return the users
157: *
158: * @throws CmsException if something goes wrong
159: */
160: public List getUsers() throws CmsException {
161:
162: return OpenCms.getOrgUnitManager().getUsers(m_cms,
163: m_ou.getName(), false);
164: }
165:
166: /**
167: * Sets the organizational unit fqn.<p>
168: *
169: * @param oufqn the organizational unit fqn to set
170: *
171: * @throws CmsException if something goes wrong
172: */
173: public void setOu(String oufqn) throws CmsException {
174:
175: m_ou = OpenCms.getOrgUnitManager().readOrganizationalUnit(
176: m_cms, oufqn);
177: }
178: }
|