001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/accounts/CmsGroupsAllOrgUnitsList.java,v $
003: * Date : $Date: 2008-02-27 12:05:27 $
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.file.CmsGroup;
035: import org.opencms.jsp.CmsJspActionElement;
036: import org.opencms.main.CmsException;
037: import org.opencms.main.CmsRuntimeException;
038: import org.opencms.main.OpenCms;
039: import org.opencms.security.CmsOrganizationalUnit;
040: import org.opencms.security.CmsPrincipal;
041: import org.opencms.util.CmsUUID;
042: import org.opencms.workplace.CmsDialog;
043: import org.opencms.workplace.list.CmsListColumnDefinition;
044: import org.opencms.workplace.list.CmsListDirectAction;
045: import org.opencms.workplace.list.CmsListItem;
046: import org.opencms.workplace.list.CmsListItemDetails;
047: import org.opencms.workplace.list.CmsListItemDetailsFormatter;
048: import org.opencms.workplace.list.CmsListMetadata;
049:
050: import java.io.IOException;
051: import java.util.HashMap;
052: import java.util.Iterator;
053: import java.util.List;
054: import java.util.Map;
055:
056: import javax.servlet.ServletException;
057: import javax.servlet.http.HttpServletRequest;
058: import javax.servlet.http.HttpServletResponse;
059: import javax.servlet.jsp.PageContext;
060:
061: /**
062: * Group account view over all manageable organizational units.<p>
063: *
064: * @author Raphael Schnuck
065: *
066: * @version $Revision: 1.4 $
067: *
068: * @since 6.5.6
069: */
070: public class CmsGroupsAllOrgUnitsList extends A_CmsGroupsList {
071:
072: /** list action id constant. */
073: public static final String LIST_ACTION_OVERVIEW = "ao";
074:
075: /** list column id constant. */
076: public static final String LIST_COLUMN_ORGUNIT = "co";
077:
078: /** list item detail id constant. */
079: public static final String LIST_DETAIL_ORGUNIT_DESC = "dd";
080:
081: /** list id constant. */
082: public static final String LIST_ID = "lgaou";
083:
084: /**
085: * Public constructor.<p>
086: *
087: * @param jsp an initialized JSP action element
088: */
089: public CmsGroupsAllOrgUnitsList(CmsJspActionElement jsp) {
090:
091: super (jsp, LIST_ID, Messages.get().container(
092: Messages.GUI_GROUPS_LIST_NAME_0));
093: }
094:
095: /**
096: * Public constructor with JSP variables.<p>
097: *
098: * @param context the JSP page context
099: * @param req the JSP request
100: * @param res the JSP response
101: */
102: public CmsGroupsAllOrgUnitsList(PageContext context,
103: HttpServletRequest req, HttpServletResponse res) {
104:
105: this (new CmsJspActionElement(context, req, res));
106: }
107:
108: /**
109: * @see org.opencms.workplace.tools.accounts.A_CmsGroupsList#executeListSingleActions()
110: */
111: public void executeListSingleActions() throws IOException,
112: ServletException, CmsRuntimeException {
113:
114: String groupId = getSelectedItem().getId();
115: String groupName = getSelectedItem().get(LIST_COLUMN_NAME)
116: .toString();
117:
118: Map params = new HashMap();
119: params.put(A_CmsEditGroupDialog.PARAM_GROUPID, groupId);
120: params.put(A_CmsEditGroupDialog.PARAM_GROUPNAME, groupName);
121: params.put(A_CmsOrgUnitDialog.PARAM_OUFQN, getSelectedItem()
122: .get(LIST_COLUMN_ORGUNIT).toString().substring(1));
123: // set action parameter to initial dialog call
124: params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
125:
126: if (getParamListAction().equals(LIST_ACTION_OVERVIEW)) {
127: // forward
128: getToolManager().jspForwardTool(this ,
129: "/accounts/orgunit/groups/edit", params);
130: } else if (getParamListAction().equals(LIST_DEFACTION_EDIT)) {
131: // forward to the edit user screen
132: getToolManager().jspForwardTool(this ,
133: "/accounts/orgunit/groups/edit", params);
134: } else {
135: super .executeListSingleActions();
136: }
137: listSave();
138: }
139:
140: /**
141: * @see org.opencms.workplace.tools.accounts.A_CmsGroupsList#fillDetails(java.lang.String)
142: */
143: protected void fillDetails(String detailId) {
144:
145: super .fillDetails(detailId);
146:
147: // get content
148: List groups = getList().getAllContent();
149: Iterator itGroups = groups.iterator();
150: while (itGroups.hasNext()) {
151: CmsListItem item = (CmsListItem) itGroups.next();
152: String groupName = item.get(LIST_COLUMN_NAME).toString();
153: StringBuffer html = new StringBuffer(512);
154: try {
155: if (detailId.equals(LIST_DETAIL_ORGUNIT_DESC)) {
156: CmsGroup group = getCms().readGroup(groupName);
157: html.append(OpenCms.getOrgUnitManager()
158: .readOrganizationalUnit(getCms(),
159: group.getOuFqn()).getDescription(
160: getLocale()));
161: } else {
162: continue;
163: }
164: } catch (Exception e) {
165: // ignore
166: }
167: item.set(detailId, html.toString());
168: }
169: }
170:
171: /**
172: * @see org.opencms.workplace.tools.accounts.A_CmsGroupsList#getGroups()
173: */
174: protected List getGroups() throws CmsException {
175:
176: return CmsPrincipal.filterCore(OpenCms.getRoleManager()
177: .getManageableGroups(getCms(), "", true));
178: }
179:
180: /**
181: * @see org.opencms.workplace.tools.accounts.A_CmsGroupsList#getListItems()
182: */
183: protected List getListItems() throws CmsException {
184:
185: List listItems = super .getListItems();
186: Iterator itListItems = listItems.iterator();
187: while (itListItems.hasNext()) {
188: CmsListItem item = (CmsListItem) itListItems.next();
189: CmsGroup group = getCms().readGroup(
190: new CmsUUID(item.getId()));
191: item.set(LIST_COLUMN_ORGUNIT,
192: CmsOrganizationalUnit.SEPARATOR + group.getOuFqn());
193: }
194:
195: return listItems;
196: }
197:
198: /**
199: * @see org.opencms.workplace.tools.accounts.A_CmsGroupsList#setColumns(org.opencms.workplace.list.CmsListMetadata)
200: */
201: protected void setColumns(CmsListMetadata metadata) {
202:
203: super .setColumns(metadata);
204:
205: metadata.getColumnDefinition(LIST_COLUMN_USERS).setVisible(
206: false);
207: metadata.getColumnDefinition(LIST_COLUMN_ACTIVATE).setVisible(
208: false);
209: metadata.getColumnDefinition(LIST_COLUMN_DELETE).setVisible(
210: false);
211:
212: metadata.getColumnDefinition(LIST_COLUMN_DISPLAY).setWidth(
213: "25%");
214: metadata.getColumnDefinition(LIST_COLUMN_DESCRIPTION).setWidth(
215: "50%");
216:
217: // add column for orgunit
218: CmsListColumnDefinition orgUnitCol = new CmsListColumnDefinition(
219: LIST_COLUMN_ORGUNIT);
220: orgUnitCol.setName(Messages.get().container(
221: Messages.GUI_GROUPS_LIST_COLS_ORGUNIT_0));
222: orgUnitCol.setWidth("25%");
223: metadata
224: .addColumn(
225: orgUnitCol,
226: metadata
227: .getColumnDefinitions()
228: .indexOf(
229: metadata
230: .getColumnDefinition(LIST_COLUMN_DESCRIPTION)));
231:
232: }
233:
234: /**
235: * @see org.opencms.workplace.tools.accounts.A_CmsGroupsList#setDeleteAction(org.opencms.workplace.list.CmsListColumnDefinition)
236: */
237: protected void setDeleteAction(CmsListColumnDefinition deleteCol) {
238:
239: // noop
240: }
241:
242: /**
243: * @see org.opencms.workplace.tools.accounts.A_CmsGroupsList#setEditAction(org.opencms.workplace.list.CmsListColumnDefinition)
244: */
245: protected void setEditAction(CmsListColumnDefinition editCol) {
246:
247: CmsListDirectAction editAction = new CmsListDirectAction(
248: LIST_ACTION_OVERVIEW);
249: editAction.setName(Messages.get().container(
250: Messages.GUI_GROUPS_LIST_DEFACTION_EDIT_NAME_0));
251: editAction.setHelpText(Messages.get().container(
252: Messages.GUI_GROUPS_LIST_DEFACTION_EDIT_HELP_0));
253: editAction.setIconPath(A_CmsUsersList.PATH_BUTTONS
254: + "group.png");
255: editCol.addDirectAction(editAction);
256: }
257:
258: /**
259: * @see org.opencms.workplace.tools.accounts.A_CmsGroupsList#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
260: */
261: protected void setIndependentActions(CmsListMetadata metadata) {
262:
263: super .setIndependentActions(metadata);
264:
265: // add orgunit description details
266: CmsListItemDetails orgUnitDescDetails = new CmsListItemDetails(
267: LIST_DETAIL_ORGUNIT_DESC);
268: orgUnitDescDetails.setAtColumn(LIST_COLUMN_DISPLAY);
269: orgUnitDescDetails.setVisible(false);
270: orgUnitDescDetails.setShowActionName(Messages.get().container(
271: Messages.GUI_USERS_DETAIL_SHOW_ORGUNIT_DESC_NAME_0));
272: orgUnitDescDetails
273: .setShowActionHelpText(Messages
274: .get()
275: .container(
276: Messages.GUI_USERS_DETAIL_SHOW_ORGUNIT_DESC_HELP_0));
277: orgUnitDescDetails.setHideActionName(Messages.get().container(
278: Messages.GUI_USERS_DETAIL_HIDE_ORGUNIT_DESC_NAME_0));
279: orgUnitDescDetails
280: .setHideActionHelpText(Messages
281: .get()
282: .container(
283: Messages.GUI_USERS_DETAIL_HIDE_ORGUNIT_DESC_HELP_0));
284: orgUnitDescDetails.setName(Messages.get().container(
285: Messages.GUI_USERS_DETAIL_ORGUNIT_DESC_NAME_0));
286: orgUnitDescDetails
287: .setFormatter(new CmsListItemDetailsFormatter(
288: Messages
289: .get()
290: .container(
291: Messages.GUI_USERS_DETAIL_ORGUNIT_DESC_NAME_0)));
292: metadata.addItemDetails(orgUnitDescDetails);
293:
294: metadata.getSearchAction().addColumn(
295: metadata.getColumnDefinition(LIST_COLUMN_DESCRIPTION));
296: metadata.getSearchAction().addColumn(
297: metadata.getColumnDefinition(LIST_COLUMN_ORGUNIT));
298: }
299:
300: /**
301: * @see org.opencms.workplace.tools.accounts.A_CmsGroupsList#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
302: */
303: protected void setMultiActions(CmsListMetadata metadata) {
304:
305: // noop
306: }
307:
308: /**
309: * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
310: */
311: protected void validateParamaters() throws Exception {
312:
313: // no param check needed
314: }
315: }
|