001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.workplace.tools.accounts;
029
030import org.opencms.security.CmsOrganizationalUnit;
031
032import java.util.ArrayList;
033import java.util.List;
034
035/**
036 * Organizational unit bean for use in new organizational unit dialog.<p>
037 *
038 * @since 6.5.6
039 */
040public class CmsOrgUnitBean {
041
042    /** The description of this object. */
043    private String m_description;
044
045    /** The fqn of this object. */
046    private String m_fqn;
047
048    /** The name of this object. */
049    private String m_name;
050
051    /** The hidden login form flag. */
052    private boolean m_nologin;
053
054    /** The parent ou of this object. */
055    private String m_parentOu;
056
057    /** The description of the parent ou. */
058    private String m_parentOuDesc;
059
060    /** The resource list of this object. */
061    private List<String> m_resources;
062
063    /** The webusers flag. */
064    private boolean m_webusers;
065
066    /**
067     * Public constructor.<p>
068     */
069    public CmsOrgUnitBean() {
070
071        m_resources = new ArrayList<String>();
072    }
073
074    /**
075     * Returns the description.<p>
076     *
077     * @return the description
078     */
079    public String getDescription() {
080
081        return m_description;
082    }
083
084    /**
085     * Returns the flag value depending on the boolean flag set.<p>
086     *
087     * @return  the flag value
088     */
089    public int getFlags() {
090
091        int flags = 0;
092        if (isNologin()) {
093            flags += CmsOrganizationalUnit.FLAG_HIDE_LOGIN;
094        }
095        if (isWebusers()) {
096            flags += CmsOrganizationalUnit.FLAG_WEBUSERS;
097        }
098        return flags;
099    }
100
101    /**
102     * Returns the fqn.<p>
103     *
104     * @return the fqn
105     */
106    public String getFqn() {
107
108        if (m_fqn != null) {
109            return m_fqn;
110        } else {
111            return m_parentOu + m_name;
112        }
113    }
114
115    /**
116     * Returns the name.<p>
117     *
118     * @return the name
119     */
120    public String getName() {
121
122        return m_name;
123    }
124
125    /**
126     * Returns the parentOu.<p>
127     *
128     * @return the parentOu
129     */
130    public String getParentOu() {
131
132        if (m_parentOu == null) {
133            return "";
134        }
135        return CmsOrganizationalUnit.SEPARATOR + m_parentOu;
136    }
137
138    /**
139     * Returns the description of the parent ou.<p>
140     *
141     * @return the description of the parent ou
142     */
143    public String getParentOuDesc() {
144
145        return m_parentOuDesc;
146    }
147
148    /**
149     * Returns the resources.<p>
150     *
151     * @return the resources
152     */
153    public List<String> getResources() {
154
155        return m_resources;
156    }
157
158    /**
159     * Returns the hidden login form flag.<p>
160     *
161     * @return the hidden login form flag
162     */
163    public boolean isNologin() {
164
165        if (isWebusers()) {
166            return true;
167        }
168        return m_nologin;
169    }
170
171    /**
172     * Returns the webusers flag.<p>
173     *
174     * @return the webusers flag
175     */
176    public boolean isWebusers() {
177
178        return m_webusers;
179    }
180
181    /**
182     * Sets the description.<p>
183     *
184     * @param description the description to set
185     */
186    public void setDescription(String description) {
187
188        m_description = description;
189    }
190
191    /**
192     * Sets the fqn.<p>
193     *
194     * @param fqn the fqn to set
195     */
196    public void setFqn(String fqn) {
197
198        m_fqn = fqn;
199    }
200
201    /**
202     * Sets the name.<p>
203     *
204     * @param name the name to set
205     */
206    public void setName(String name) {
207
208        m_name = name;
209    }
210
211    /**
212     * Sets the hidden login form flag.<p>
213     *
214     * @param nologin the hidden login form flag to set
215     */
216    public void setNologin(boolean nologin) {
217
218        m_nologin = nologin;
219    }
220
221    /**
222     * Sets the parentOu.<p>
223     *
224     * @param parentOu the parentOu to set
225     */
226    public void setParentOu(String parentOu) {
227
228        if (parentOu.startsWith(CmsOrganizationalUnit.SEPARATOR)) {
229            parentOu = parentOu.substring(1);
230        }
231        m_parentOu = parentOu;
232    }
233
234    /**
235     * Sets the description of the parent ou.<p>
236     *
237     * @param parentOuDesc the description of the parent ou to set
238     */
239    public void setParentOuDesc(String parentOuDesc) {
240
241        m_parentOuDesc = parentOuDesc;
242    }
243
244    /**
245     * Sets the resources.<p>
246     *
247     * @param resources the resources to set
248     */
249    public void setResources(List<String> resources) {
250
251        m_resources = resources;
252    }
253
254    /**
255     * Sets the webusers flag.<p>
256     *
257     * @param webusers the webusers flag to set
258     */
259    public void setWebusers(boolean webusers) {
260
261        m_webusers = webusers;
262    }
263}