01: package com.jat.presentation.parameter;
02:
03: import java.util.Enumeration;
04: import java.util.Vector;
05: import javax.servlet.http.HttpServletRequest;
06:
07: import com.jat.business.privileges.Privilege;
08: import com.jat.business.privileges.PrivilegeFactory;
09: import com.jat.presentation.PresentationException;
10: import com.jat.util.StringOrderable;
11: import com.jat.util.OrderVector;
12:
13: /**
14: * <p>Title: JAT</p>
15: * <p>Description: </p>
16: * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
17: * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
18: * @author stf
19: * @version 1.0
20: * @since 1.2
21: */
22:
23: public class PrivilegeOptionList implements OptionPlugin {
24:
25: /**
26: * Return a list of privilege names as String
27: * @param request
28: * @param parameterName
29: * @return
30: * @throws PresentationException
31: */
32: public Enumeration list(HttpServletRequest request,
33: String parameterName) throws PresentationException {
34: Vector ret = new Vector();
35: try {
36: for (Enumeration e = PrivilegeFactory.getDefault()
37: .getDistinctPrivileges(); e.hasMoreElements();) {
38: Privilege priv = (Privilege) e.nextElement();
39: StringOrderable p = new StringOrderable(priv.getName());
40: if (!ret.contains(p))
41: ret.addElement(p);
42: }
43: ret = OrderVector.orderAscendent(ret);
44: } catch (Exception ex) {
45: throw new PresentationException(ex);
46: }
47: return ret.elements();
48: }
49: }
|