001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/accounts/A_CmsUserDataImexportDialog.java,v $
003: * Date : $Date: 2008-02-27 12:05:26 $
004: * Version: $Revision: 1.4 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace.tools.accounts;
033:
034: import org.opencms.jsp.CmsJspActionElement;
035: import org.opencms.main.CmsException;
036: import org.opencms.main.OpenCms;
037: import org.opencms.security.CmsRole;
038: import org.opencms.widgets.CmsSelectWidgetOption;
039: import org.opencms.workplace.CmsWidgetDialog;
040:
041: import java.io.IOException;
042: import java.util.ArrayList;
043: import java.util.Iterator;
044: import java.util.List;
045:
046: import javax.servlet.ServletException;
047: import javax.servlet.http.HttpServletRequest;
048: import javax.servlet.http.HttpServletResponse;
049: import javax.servlet.jsp.PageContext;
050:
051: /**
052: * Abstract dialog class to import and export user data.<p>
053: *
054: * @author Raphael Schnuck
055: *
056: * @version $Revision: 1.4 $
057: *
058: * @since 6.7.1
059: */
060: public abstract class A_CmsUserDataImexportDialog extends
061: CmsWidgetDialog {
062:
063: /** Defines which pages are valid for this dialog. */
064: public static final String[] PAGES = { "page1" };
065:
066: /** List of groups. */
067: private List m_groups;
068:
069: /** Stores the value of the request parameter for the organizational unit fqn. */
070: private String m_paramOufqn;
071:
072: /** List of roles. */
073: private List m_roles;
074:
075: /**
076: * Public constructor with JSP action element.<p>
077: *
078: * @param jsp an initialized JSP action element
079: */
080: public A_CmsUserDataImexportDialog(CmsJspActionElement jsp) {
081:
082: super (jsp);
083: }
084:
085: /**
086: * Public constructor with JSP variables.<p>
087: *
088: * @param context the JSP page context
089: * @param req the JSP request
090: * @param res the JSP response
091: */
092: public A_CmsUserDataImexportDialog(PageContext context,
093: HttpServletRequest req, HttpServletResponse res) {
094:
095: this (new CmsJspActionElement(context, req, res));
096: }
097:
098: /**
099: * @see org.opencms.workplace.CmsWidgetDialog#actionCommit()
100: */
101: public abstract void actionCommit() throws IOException,
102: ServletException;
103:
104: /**
105: * Returns the list of groups.<p>
106: *
107: * @return the list of groups
108: */
109: public List getGroups() {
110:
111: return m_groups;
112: }
113:
114: /**
115: * Returns the organizational unit fqn parameter value.<p>
116: *
117: * @return the organizational unit fqn parameter value
118: */
119: public String getParamOufqn() {
120:
121: return m_paramOufqn;
122: }
123:
124: /**
125: * Returns the list of roles to export.<p>
126: *
127: * @return the list of roles to export
128: */
129: public List getRoles() {
130:
131: return m_roles;
132: }
133:
134: /**
135: * Sets the groups list.<p>
136: *
137: * @param groups the groups list
138: */
139: public void setGroups(List groups) {
140:
141: m_groups = groups;
142: }
143:
144: /**
145: * Sets the organizational unit fqn parameter value.<p>
146: *
147: * @param ouFqn the organizational unit fqn parameter value
148: */
149: public void setParamOufqn(String ouFqn) {
150:
151: if (ouFqn == null) {
152: ouFqn = "";
153: }
154: m_paramOufqn = ouFqn;
155: }
156:
157: /**
158: * Sets the roles list.<p>
159: *
160: * @param roles the roles list
161: */
162: public void setRoles(List roles) {
163:
164: m_roles = roles;
165: }
166:
167: /**
168: * @see org.opencms.workplace.CmsWidgetDialog#defineWidgets()
169: */
170: protected abstract void defineWidgets();
171:
172: /**
173: * @see org.opencms.workplace.CmsWidgetDialog#getPageArray()
174: */
175: protected String[] getPageArray() {
176:
177: return PAGES;
178: }
179:
180: /**
181: * Returns the role names to show in the select box.<p>
182: *
183: * @return the role names to show in the select box
184: */
185: protected List getSelectRoles() {
186:
187: List retVal = new ArrayList();
188:
189: try {
190:
191: List roles = OpenCms.getRoleManager().getRoles(getCms(),
192: getParamOufqn(), false);
193: Iterator itRoles = roles.iterator();
194: while (itRoles.hasNext()) {
195: CmsRole role = (CmsRole) itRoles.next();
196: retVal.add(new CmsSelectWidgetOption(role
197: .getGroupName(), false, role
198: .getName(getLocale())));
199: }
200: } catch (CmsException e) {
201: // noop
202: }
203: return retVal;
204: }
205: }
|