KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > accounts > CmsGroupStateAction


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/accounts/CmsGroupStateAction.java,v $
3  * Date : $Date: 2006/03/27 14:52:49 $
4  * Version: $Revision: 1.11 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.tools.accounts;
33
34 import org.opencms.file.CmsGroup;
35 import org.opencms.file.CmsObject;
36 import org.opencms.workplace.list.CmsListDefaultAction;
37
38 import java.util.List JavaDoc;
39
40 /**
41  * Show diferent states depending on user direct/indirect group assignment.<p>
42  *
43  * @author Michael Moossen
44  *
45  * @version $Revision: 1.11 $
46  *
47  * @since 6.0.0
48  */

49 public class CmsGroupStateAction extends CmsListDefaultAction {
50
51     /** Cms context. */
52     private final CmsObject m_cms;
53
54     /** Direct group flag. */
55     private final boolean m_direct;
56
57     /** Current user name. */
58     private String JavaDoc m_userName;
59
60     /**
61      * Default constructor.<p>
62      *
63      * @param id the id of the action
64      * @param cms the cms context
65      * @param direct the direct group flag
66      */

67     public CmsGroupStateAction(String JavaDoc id, CmsObject cms, boolean direct) {
68
69         super(id);
70         m_cms = cms;
71         m_direct = direct;
72     }
73
74     /**
75      * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
76      */

77     public boolean isVisible() {
78
79         try {
80             String JavaDoc groupName = (String JavaDoc)getItem().get(A_CmsUserGroupsList.LIST_COLUMN_NAME);
81             List JavaDoc dGroups = getCms().getDirectGroupsOfUser(getUserName());
82             CmsGroup group = getCms().readGroup(groupName);
83             if (isDirect()) {
84                 return dGroups.contains(group);
85             } else {
86                 return !dGroups.contains(group);
87             }
88         } catch (Exception JavaDoc e) {
89             return false;
90         }
91     }
92
93     /**
94      * Returns the user Name.<p>
95      *
96      * @return the user Name
97      */

98     public String JavaDoc getUserName() {
99
100         return m_userName;
101     }
102
103     /**
104      * Sets the user Name.<p>
105      *
106      * @param userName the user Name to set
107      */

108     public void setUserName(String JavaDoc userName) {
109
110         m_userName = userName;
111     }
112
113     /**
114      * Returns the cms context.<p>
115      *
116      * @return the cms context
117      */

118     public CmsObject getCms() {
119
120         return m_cms;
121     }
122
123     /**
124      * Returns the direct group flag.<p>
125      *
126      * @return the direct group flag
127      */

128     public boolean isDirect() {
129
130         return m_direct;
131     }
132 }
Popular Tags