KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > security > accounts > AccountList


1 // $Id: AccountList.java 3567 2003-06-30 22:32:03Z shuber $
2
//
3
// ____.
4
// __/\ ______| |__/\. _______
5
// __ .____| | \ | +----+ \
6
// _______| /--| | | - \ _ | : - \_________
7
// \\______: :---| : : | : | \________>
8
// |__\---\_____________:______: :____|____:_____\
9
// /_____|
10
//
11
// . . . i n j a h i a w e t r u s t . . .
12
//
13

14 package org.jahia.security.accounts;
15
16 import java.util.Vector JavaDoc;
17
18 import org.jahia.exceptions.database.JahiaDatabaseException;
19
20 /**
21  * This class hold a list of Accounts.
22  *
23  * @author Fulco Houkes
24  * @version 1.0
25  */

26 public class AccountList extends Vector JavaDoc
27 {
28     //-------------------------------------------------------------------------
29
/**
30      * Default Constructor.
31      */

32     public AccountList () {
33         super();
34     }
35
36
37     //-------------------------------------------------------------------------
38
// Foux 17 Apr. 2001
39
/** Return a list of {@link Account Account} objects associated
40      * with the specified site. These objects will not hold a reference to the
41      * account owner. The users associated with an account can be obtained
42      * through the User Manager Service (see
43      * {@link JahiaUserManagerService JahiaUserManagerService} for more
44      * information.
45      *
46      * @param siteKey
47      * Site unique identification key
48      *
49      * @return
50      * Return a {@link java.util.Vector Vector} holding the requested
51      * account objects. The returned {@link java.util.Vector Vector} is
52      * always non <code>null</code>, and is empty if no account is defined
53      * in the specified site.
54      *
55      * @exception JahiaDatabaseException
56      * Throws this exception on any database failure.
57      */

58     public static AccountList getAccountsList (String JavaDoc siteKey)
59         throws JahiaDatabaseException
60     {
61         AccountList list = new AccountList ();
62         if (siteKey == null) {
63             return list;
64         }
65
66         AccountDBUtils dbUtils = AccountDBUtils.getInstance();
67         if (dbUtils != null) {
68             list = dbUtils.getAccountsList (siteKey, -1);
69         }
70
71         return list;
72     }
73
74
75     //-------------------------------------------------------------------------
76
// Foux 17 Apr. 2001
77
/** Return a list of enabled accounts associated with the specified site.
78      * These accounts will not hold a reference to the account owner. The user
79      * associated with an account can be obtained through the User Manager
80      * Service (see {@link JahiaUserManagerService JahiaUserManagerService}
81      * for more information.
82      *
83      * @param siteKey
84      * Site unique identification key
85      *
86      * @return
87      * Return a {@link java.util.Vector Vector} holding the requested
88      * {@link Account Account} account objects. The returned
89      * {@link java.util.Vector Vector} is always non <code>null</code>, and
90      * is empty if any enabled account could be found in the specified
91      * site.
92      *
93      * @exception JahiaDatabaseException
94      * Throws this exception on any database failure.
95      */

96     static public AccountList getEnabledAccountsList (String JavaDoc siteKey)
97         throws JahiaDatabaseException
98     {
99         AccountList list = new AccountList ();
100         if (siteKey == null) {
101             return list;
102         }
103
104         AccountDBUtils dbUtils = AccountDBUtils.getInstance();
105         if (dbUtils != null) {
106             list = dbUtils.getAccountsList (siteKey, 1);
107         }
108
109         return list;
110     }
111
112
113     //-------------------------------------------------------------------------
114
// Foux 17 Apr. 2001
115
/** Return a list of disabled accounts associated with the specified site.
116      * These accounts will not hold a reference to the account owner. The user
117      * associated with an account can be obtained through the User Manager
118      * Service (see {@link JahiaUserManagerService JahiaUserManagerService}
119      * for more information.
120      *
121      * @param siteKey
122      * Site unique identification key
123      *
124      * @return
125      * Return a {@link AccountList AccountList} holding the requested
126      * {@link Account Account} account objects. The returned
127      * list is always non <code>null</code>, and is empty if any disabled
128      * account could be found in the specified site.
129      *
130      * @exception JahiaDatabaseException
131      * Throws this exception on any database failure.
132      */

133     static public AccountList getDisabledAccountsList (String JavaDoc siteKey)
134         throws JahiaDatabaseException
135     {
136         AccountList list = new AccountList ();
137         if (siteKey == null) {
138             return list;
139         }
140
141         AccountDBUtils dbUtils = AccountDBUtils.getInstance();
142         if (dbUtils != null) {
143             list = dbUtils.getAccountsList (siteKey, 0);
144         }
145
146         return list;
147     }
148
149
150     //-------------------------------------------------------------------------
151
/**
152      * Return the list of accounts related to this user.
153      *
154      * @param userKey
155      * The user unique identification key.
156      *
157      * @return
158      * Return a list of accounts, which is always non-null. The list is
159      * empty if no account was found for the specified user.
160      *
161      * @exception JahiaDatabaseException
162      * Throws this exception on any database failure.
163      */

164     static public AccountList getUserAccounts (String JavaDoc userKey)
165         throws JahiaDatabaseException
166     {
167         AccountList list = new AccountList ();
168         if (userKey != null) {
169             AccountDBUtils dbUtils = AccountDBUtils.getInstance();
170             if (dbUtils != null) {
171                 list = dbUtils.getUserAccounts (userKey);
172             }
173         }
174         return list;
175     }
176 }
177
178
Popular Tags