001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/accounts/A_CmsGroupsList.java,v $
003: * Date : $Date: 2008-02-27 12:05:26 $
004: * Version: $Revision: 1.7 $
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.file.CmsResource;
036: import org.opencms.file.CmsUser;
037: import org.opencms.i18n.CmsMessageContainer;
038: import org.opencms.jsp.CmsJspActionElement;
039: import org.opencms.main.CmsException;
040: import org.opencms.main.CmsRuntimeException;
041: import org.opencms.main.OpenCms;
042: import org.opencms.security.CmsAccessControlEntry;
043: import org.opencms.security.CmsRole;
044: import org.opencms.util.CmsStringUtil;
045: import org.opencms.util.CmsUUID;
046: import org.opencms.workplace.CmsDialog;
047: import org.opencms.workplace.list.A_CmsListDialog;
048: import org.opencms.workplace.list.CmsListColumnAlignEnum;
049: import org.opencms.workplace.list.CmsListColumnDefinition;
050: import org.opencms.workplace.list.CmsListDefaultAction;
051: import org.opencms.workplace.list.CmsListDirectAction;
052: import org.opencms.workplace.list.CmsListItem;
053: import org.opencms.workplace.list.CmsListItemActionIconComparator;
054: import org.opencms.workplace.list.CmsListItemDetails;
055: import org.opencms.workplace.list.CmsListItemDetailsFormatter;
056: import org.opencms.workplace.list.CmsListMetadata;
057: import org.opencms.workplace.list.CmsListMultiAction;
058: import org.opencms.workplace.list.CmsListOrderEnum;
059: import org.opencms.workplace.list.CmsListSearchAction;
060:
061: import java.io.IOException;
062: import java.util.ArrayList;
063: import java.util.HashMap;
064: import java.util.HashSet;
065: import java.util.Iterator;
066: import java.util.List;
067: import java.util.Map;
068: import java.util.Set;
069:
070: import javax.servlet.ServletException;
071:
072: /**
073: * Skeleton for a generic group list.<p>
074: *
075: * @author Michael Moossen
076: * @author Peter Bonrad
077: *
078: * @version $Revision: 1.7 $
079: *
080: * @since 6.0.0
081: */
082: public abstract class A_CmsGroupsList extends A_CmsListDialog {
083:
084: /** list action id constant. */
085: public static final String LIST_ACTION_ACTIVATE = "aa";
086:
087: /** list action id constant. */
088: public static final String LIST_ACTION_DEACTIVATE = "ac";
089:
090: /** list action id constant. */
091: public static final String LIST_ACTION_DELETE = "ad";
092:
093: /** list action id constant. */
094: public static final String LIST_ACTION_EDIT = "ae";
095:
096: /** list action id constant. */
097: public static final String LIST_ACTION_USERS = "au";
098:
099: /** list column id constant. */
100: public static final String LIST_COLUMN_ACTIVATE = "ca";
101:
102: /** list column id constant. */
103: public static final String LIST_COLUMN_DELETE = "cd";
104:
105: /** list column id constant. */
106: public static final String LIST_COLUMN_DESCRIPTION = "cc";
107:
108: /** list column id constant. */
109: public static final String LIST_COLUMN_DISPLAY = "cdn";
110:
111: /** list column id constant. */
112: public static final String LIST_COLUMN_EDIT = "ce";
113:
114: /** list column id constant. */
115: public static final String LIST_COLUMN_NAME = "cn";
116:
117: /** list column id constant. */
118: public static final String LIST_COLUMN_USERS = "cu";
119:
120: /** list action id constant. */
121: public static final String LIST_DEFACTION_EDIT = "de";
122:
123: /** list item detail id constant. */
124: public static final String LIST_DETAIL_CHILDREN = "dc";
125:
126: /** list item detail id constant. */
127: public static final String LIST_DETAIL_PARENT = "dp";
128:
129: /** list item detail id constant. */
130: public static final String LIST_DETAIL_SET_PERM = "dsp";
131:
132: /** list item detail id constant. */
133: public static final String LIST_DETAIL_USERS = "du";
134:
135: /** list action id constant. */
136: public static final String LIST_MACTION_ACTIVATE = "ma";
137:
138: /** list action id constant. */
139: public static final String LIST_MACTION_DEACTIVATE = "mc";
140:
141: /** list action id constant. */
142: public static final String LIST_MACTION_DELETE = "md";
143:
144: /** a set of action id's to use for deletion. */
145: private static Set m_deleteActionIds = new HashSet();
146:
147: /** a set of action id's to use for edition. */
148: private static Set m_editActionIds = new HashSet();
149:
150: /** Stores the value of the request parameter for the organizational unit fqn. */
151: private String m_paramOufqn;
152:
153: /**
154: * Public constructor.<p>
155: *
156: * @param jsp an initialized JSP action element
157: * @param listId the id of the list
158: * @param listName the name of the list
159: */
160: public A_CmsGroupsList(CmsJspActionElement jsp, String listId,
161: CmsMessageContainer listName) {
162:
163: super (jsp, listId, listName, LIST_COLUMN_DISPLAY,
164: CmsListOrderEnum.ORDER_ASCENDING, null);
165: }
166:
167: /**
168: * This method should handle every defined list multi action,
169: * by comparing <code>{@link #getParamListAction()}</code> with the id
170: * of the action to execute.<p>
171: *
172: * @throws CmsRuntimeException to signal that an action is not supported
173: *
174: */
175: public void executeListMultiActions() throws CmsRuntimeException {
176:
177: if (getParamListAction().equals(LIST_MACTION_DELETE)) {
178: // execute the delete multiaction
179: Map params = new HashMap();
180: params.put(A_CmsEditGroupDialog.PARAM_GROUPID,
181: getParamSelItems());
182: // set action parameter to initial dialog call
183: params
184: .put(CmsDialog.PARAM_ACTION,
185: CmsDialog.DIALOG_INITIAL);
186: try {
187: getToolManager().jspForwardTool(this ,
188: getCurrentToolPath() + "/delete", params);
189: } catch (Exception e) {
190: throw new CmsRuntimeException(Messages.get().container(
191: Messages.ERR_DELETE_SELECTED_GROUPS_0), e);
192: }
193: } else if (getParamListAction().equals(LIST_MACTION_ACTIVATE)) {
194: // execute the activate multiaction
195: try {
196: Iterator itItems = getSelectedItems().iterator();
197: while (itItems.hasNext()) {
198: CmsListItem listItem = (CmsListItem) itItems.next();
199: String groupName = listItem.get(LIST_COLUMN_NAME)
200: .toString();
201: CmsGroup group = getCms().readGroup(groupName);
202: if (!group.isEnabled()) {
203: group.setEnabled(true);
204: getCms().writeGroup(group);
205: }
206: }
207: } catch (CmsException e) {
208: throw new CmsRuntimeException(Messages.get().container(
209: Messages.ERR_ACTIVATE_SELECTED_GROUPS_0), e);
210: }
211: // refreshing no needed becaus the activate action does not add/remove rows to the list
212: } else if (getParamListAction().equals(LIST_MACTION_DEACTIVATE)) {
213: // execute the activate multiaction
214: try {
215: Iterator itItems = getSelectedItems().iterator();
216: while (itItems.hasNext()) {
217: CmsListItem listItem = (CmsListItem) itItems.next();
218: String groupName = listItem.get(LIST_COLUMN_NAME)
219: .toString();
220: CmsGroup group = getCms().readGroup(groupName);
221: if (group.isEnabled()) {
222: group.setEnabled(false);
223: getCms().writeGroup(group);
224: }
225: }
226: } catch (CmsException e) {
227: throw new CmsRuntimeException(Messages.get().container(
228: Messages.ERR_DEACTIVATE_SELECTED_GROUPS_0), e);
229: }
230: // refreshing no needed becaus the activate action does not add/remove rows to the list
231: } else {
232: throwListUnsupportedActionException();
233: }
234: listSave();
235: }
236:
237: /**
238: * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
239: */
240: public void executeListSingleActions() throws IOException,
241: ServletException, CmsRuntimeException {
242:
243: String groupId = getSelectedItem().getId();
244: String groupName = getSelectedItem().get(LIST_COLUMN_NAME)
245: .toString();
246:
247: Map params = new HashMap();
248: params.put(A_CmsEditGroupDialog.PARAM_GROUPID, groupId);
249: params.put(A_CmsOrgUnitDialog.PARAM_OUFQN, m_paramOufqn);
250: params.put(A_CmsEditGroupDialog.PARAM_GROUPNAME, groupName);
251: // set action parameter to initial dialog call
252: params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
253:
254: if (getParamListAction().equals(LIST_DEFACTION_EDIT)) {
255: // forward to the edit user screen
256: getToolManager().jspForwardTool(this ,
257: getCurrentToolPath() + "/edit", params);
258: } else if (m_editActionIds.contains(getParamListAction())) {
259: getToolManager().jspForwardTool(this ,
260: getCurrentToolPath() + "/edit/group", params);
261: } else if (getParamListAction().equals(LIST_ACTION_USERS)) {
262: getToolManager().jspForwardTool(this ,
263: getCurrentToolPath() + "/edit/users", params);
264: } else if (m_deleteActionIds.contains(getParamListAction())) {
265: getToolManager().jspForwardTool(this ,
266: getCurrentToolPath() + "/edit/delete", params);
267: } else if (getParamListAction().equals(LIST_ACTION_ACTIVATE)) {
268: // execute the activate action
269: try {
270: CmsGroup group = getCms().readGroup(groupName);
271: group.setEnabled(true);
272: getCms().writeGroup(group);
273: } catch (CmsException e) {
274: throw new CmsRuntimeException(Messages.get().container(
275: Messages.ERR_ACTIVATE_GROUP_1, groupName), e);
276: }
277: } else if (getParamListAction().equals(LIST_ACTION_DEACTIVATE)) {
278: // execute the activate action
279: try {
280: CmsGroup group = getCms().readGroup(groupName);
281: group.setEnabled(false);
282: getCms().writeGroup(group);
283: } catch (CmsException e) {
284: throw new CmsRuntimeException(Messages.get().container(
285: Messages.ERR_DEACTIVATE_GROUP_1, groupName), e);
286: }
287: } else {
288: throwListUnsupportedActionException();
289: }
290: listSave();
291: }
292:
293: /**
294: * Returns the organizational unit fqn parameter value.<p>
295: *
296: * @return the organizational unit fqn parameter value
297: */
298: public String getParamOufqn() {
299:
300: return m_paramOufqn;
301: }
302:
303: /**
304: * Sets the organizational unit fqn parameter value.<p>
305: *
306: * @param ouFqn the organizational unit fqn parameter value
307: */
308: public void setParamOufqn(String ouFqn) {
309:
310: if (ouFqn == null) {
311: ouFqn = "";
312: }
313: m_paramOufqn = ouFqn;
314: }
315:
316: /**
317: * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
318: */
319: protected void fillDetails(String detailId) {
320:
321: // get content
322: List groups = getList().getAllContent();
323: Iterator itGroups = groups.iterator();
324: while (itGroups.hasNext()) {
325: CmsListItem item = (CmsListItem) itGroups.next();
326: String groupName = item.get(LIST_COLUMN_NAME).toString();
327: StringBuffer html = new StringBuffer(512);
328: try {
329: if (detailId.equals(LIST_DETAIL_USERS)) {
330: // users
331: List users = getCms().getUsersOfGroup(groupName,
332: true);
333: Iterator itUsers = users.iterator();
334: while (itUsers.hasNext()) {
335: CmsUser user = (CmsUser) itUsers.next();
336: if (user.getOuFqn().equals(getParamOufqn())) {
337: html.append(user.getFullName());
338: } else {
339: html.append(user.getDisplayName(getCms(),
340: getLocale()));
341: }
342: if (itUsers.hasNext()) {
343: html.append("<br>");
344: }
345: html.append("\n");
346: }
347: } else if (detailId.equals(LIST_DETAIL_CHILDREN)) {
348: // childen
349: Iterator itChildren = getCms().getChildren(
350: groupName, false).iterator();
351: while (itChildren.hasNext()) {
352: CmsGroup group = (CmsGroup) itChildren.next();
353: if (group.getOuFqn().equals(getParamOufqn())) {
354: html.append(group.getSimpleName());
355: } else {
356: html.append(group.getDisplayName(getCms(),
357: getLocale()));
358: }
359: if (itChildren.hasNext()) {
360: html.append("<br>");
361: }
362: html.append("\n");
363: }
364: } else if (detailId.equals(LIST_DETAIL_PARENT)) {
365: // parent
366: CmsGroup parent = getCms()
367: .readGroup(
368: getCms().readGroup(groupName)
369: .getParentId());
370: html.append(parent.getName());
371: } else if (detailId.equals(LIST_DETAIL_SET_PERM)) {
372: // folder permissions
373: String storedSiteRoot = getCms()
374: .getRequestContext().getSiteRoot();
375: try {
376: getCms().getRequestContext().setSiteRoot("/");
377: CmsGroup group = getCms().readGroup(groupName);
378: Iterator itRes = getCms()
379: .getResourcesForPrincipal(
380: group.getId(), null, false)
381: .iterator();
382: while (itRes.hasNext()) {
383: CmsResource resource = (CmsResource) itRes
384: .next();
385: html.append(resource.getRootPath());
386:
387: Iterator itAces = getCms()
388: .getAccessControlEntries(
389: resource.getRootPath(),
390: false).iterator();
391: while (itAces.hasNext()) {
392: CmsAccessControlEntry ace = (CmsAccessControlEntry) itAces
393: .next();
394: if (ace.getPrincipal().equals(
395: group.getId())) {
396: if (CmsStringUtil
397: .isNotEmptyOrWhitespaceOnly(ace
398: .getPermissions()
399: .getPermissionString())) {
400: html
401: .append(" ("
402: + ace
403: .getPermissions()
404: .getPermissionString()
405: + ")");
406: }
407: break;
408: }
409: }
410:
411: if (itRes.hasNext()) {
412: html.append("<br>");
413: }
414: html.append("\n");
415: }
416: } finally {
417: getCms().getRequestContext().setSiteRoot(
418: storedSiteRoot);
419: }
420: } else {
421: continue;
422: }
423: } catch (Exception e) {
424: // ignore
425: }
426: item.set(detailId, html.toString());
427: }
428: }
429:
430: /**
431: * Returns a list of groups.<p>
432: *
433: * @return the list of all groups
434: *
435: * @throws CmsException if something goes wrong
436: */
437: protected abstract List getGroups() throws CmsException;
438:
439: /**
440: * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
441: */
442: protected List getListItems() throws CmsException {
443:
444: List ret = new ArrayList();
445: // get content
446: List groups = getGroups();
447: Iterator itGroups = groups.iterator();
448: while (itGroups.hasNext()) {
449: CmsGroup group = (CmsGroup) itGroups.next();
450: CmsListItem item = getList().newItem(
451: group.getId().toString());
452: item.set(LIST_COLUMN_NAME, group.getName());
453: item.set(LIST_COLUMN_DISPLAY, group.getSimpleName());
454: item.set(LIST_COLUMN_DESCRIPTION, group
455: .getDescription(getLocale()));
456: ret.add(item);
457: }
458:
459: return ret;
460: }
461:
462: /**
463: * @see org.opencms.workplace.CmsWorkplace#initMessages()
464: */
465: protected void initMessages() {
466:
467: // add specific dialog resource bundle
468: addMessages(Messages.get().getBundleName());
469: // add default resource bundles
470: super .initMessages();
471: }
472:
473: /**
474: * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
475: */
476: protected void setColumns(CmsListMetadata metadata) {
477:
478: // create column for edit
479: CmsListColumnDefinition editCol = new CmsListColumnDefinition(
480: LIST_COLUMN_EDIT);
481: editCol.setName(Messages.get().container(
482: Messages.GUI_GROUPS_LIST_COLS_EDIT_0));
483: editCol.setHelpText(Messages.get().container(
484: Messages.GUI_GROUPS_LIST_COLS_EDIT_HELP_0));
485: editCol.setWidth("20");
486: editCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
487: editCol.setSorteable(false);
488:
489: // add edit action
490: setEditAction(editCol);
491: m_editActionIds.addAll(editCol.getDirectActionIds());
492: // add it to the list definition
493: metadata.addColumn(editCol);
494:
495: // create column for group edition
496: CmsListColumnDefinition usersCol = new CmsListColumnDefinition(
497: LIST_COLUMN_USERS);
498: usersCol.setName(Messages.get().container(
499: Messages.GUI_GROUPS_LIST_COLS_USERS_0));
500: usersCol.setHelpText(Messages.get().container(
501: Messages.GUI_GROUPS_LIST_COLS_USERS_HELP_0));
502: usersCol.setWidth("20");
503: usersCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
504: usersCol.setSorteable(false);
505: // add groups action
506: CmsListDirectAction usersAction = new CmsListDirectAction(
507: LIST_ACTION_USERS);
508: usersAction.setName(Messages.get().container(
509: Messages.GUI_GROUPS_LIST_ACTION_USERS_NAME_0));
510: usersAction.setHelpText(Messages.get().container(
511: Messages.GUI_GROUPS_LIST_ACTION_USERS_HELP_0));
512: usersAction.setIconPath(A_CmsUsersList.PATH_BUTTONS
513: + "user.png");
514: usersCol.addDirectAction(usersAction);
515: // add it to the list definition
516: metadata.addColumn(usersCol);
517:
518: // create column for activation/deactivation
519: CmsListColumnDefinition actCol = new CmsListColumnDefinition(
520: LIST_COLUMN_ACTIVATE);
521: actCol.setName(Messages.get().container(
522: Messages.GUI_GROUPS_LIST_COLS_ACTIVATE_0));
523: actCol.setHelpText(Messages.get().container(
524: Messages.GUI_GROUPS_LIST_COLS_ACTIVATE_HELP_0));
525: actCol.setWidth("20");
526: actCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
527: actCol
528: .setListItemComparator(new CmsListItemActionIconComparator());
529:
530: // activate action
531: CmsListDirectAction actAction = new CmsListDirectAction(
532: LIST_ACTION_ACTIVATE) {
533:
534: /**
535: * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
536: */
537: public boolean isVisible() {
538:
539: if (getItem() != null) {
540: String groupId = getItem().getId();
541: try {
542: return !getCms()
543: .readGroup(new CmsUUID(groupId))
544: .isEnabled();
545: } catch (CmsException e) {
546: return false;
547: }
548: }
549: return super .isVisible();
550: }
551: };
552: actAction.setName(Messages.get().container(
553: Messages.GUI_GROUPS_LIST_ACTION_ACTIVATE_NAME_0));
554: actAction.setHelpText(Messages.get().container(
555: Messages.GUI_GROUPS_LIST_ACTION_ACTIVATE_HELP_0));
556: actAction.setConfirmationMessage(Messages.get().container(
557: Messages.GUI_GROUPS_LIST_ACTION_ACTIVATE_CONF_0));
558: actAction.setIconPath(ICON_INACTIVE);
559: actCol.addDirectAction(actAction);
560:
561: // deactivate action
562: CmsListDirectAction deactAction = new CmsListDirectAction(
563: LIST_ACTION_DEACTIVATE) {
564:
565: /**
566: * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
567: */
568: public boolean isVisible() {
569:
570: if (getItem() != null) {
571: String groupId = getItem().getId();
572: try {
573: return getCms().readGroup(new CmsUUID(groupId))
574: .isEnabled();
575: } catch (CmsException e) {
576: return false;
577: }
578: }
579: return super .isVisible();
580: }
581: };
582: deactAction.setName(Messages.get().container(
583: Messages.GUI_GROUPS_LIST_ACTION_DEACTIVATE_NAME_0));
584: deactAction.setHelpText(Messages.get().container(
585: Messages.GUI_GROUPS_LIST_ACTION_DEACTIVATE_HELP_0));
586: deactAction.setConfirmationMessage(Messages.get().container(
587: Messages.GUI_GROUPS_LIST_ACTION_DEACTIVATE_CONF_0));
588: deactAction.setIconPath(ICON_ACTIVE);
589: actCol.addDirectAction(deactAction);
590: // add it to the list definition
591: metadata.addColumn(actCol);
592:
593: // create column for deletion
594: CmsListColumnDefinition deleteCol = new CmsListColumnDefinition(
595: LIST_COLUMN_DELETE);
596: deleteCol.setName(Messages.get().container(
597: Messages.GUI_GROUPS_LIST_COLS_DELETE_0));
598: deleteCol.setHelpText(Messages.get().container(
599: Messages.GUI_GROUPS_LIST_COLS_DELETE_HELP_0));
600: deleteCol.setWidth("20");
601: deleteCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
602: deleteCol.setSorteable(false);
603: // add delete action
604: setDeleteAction(deleteCol);
605: m_deleteActionIds.addAll(deleteCol.getDirectActionIds());
606: // add it to the list definition
607: metadata.addColumn(deleteCol);
608:
609: // create column for name
610: CmsListColumnDefinition nameCol = new CmsListColumnDefinition(
611: LIST_COLUMN_NAME);
612: // add it to the list definition
613: metadata.addColumn(nameCol);
614: nameCol.setVisible(false);
615:
616: // create column for display name
617: CmsListColumnDefinition displayCol = new CmsListColumnDefinition(
618: LIST_COLUMN_DISPLAY);
619: displayCol.setName(Messages.get().container(
620: Messages.GUI_GROUPS_LIST_COLS_NAME_0));
621: displayCol.setWidth("35%");
622:
623: // create default edit action
624: CmsListDefaultAction defEditAction = new CmsListDefaultAction(
625: LIST_DEFACTION_EDIT);
626: defEditAction.setName(Messages.get().container(
627: Messages.GUI_GROUPS_LIST_DEFACTION_EDIT_NAME_0));
628: defEditAction.setHelpText(Messages.get().container(
629: Messages.GUI_GROUPS_LIST_DEFACTION_EDIT_HELP_0));
630: displayCol.addDefaultAction(defEditAction);
631:
632: // add it to the list definition
633: metadata.addColumn(displayCol);
634:
635: // add column for description
636: CmsListColumnDefinition descriptionCol = new CmsListColumnDefinition(
637: LIST_COLUMN_DESCRIPTION);
638: descriptionCol.setName(Messages.get().container(
639: Messages.GUI_GROUPS_LIST_COLS_DESCRIPTION_0));
640: descriptionCol.setWidth("65%");
641: metadata.addColumn(descriptionCol);
642: }
643:
644: /**
645: * Sets the needed delete action(s).<p>
646: *
647: * @param deleteCol the list column for deletion.
648: */
649: protected abstract void setDeleteAction(
650: CmsListColumnDefinition deleteCol);
651:
652: /**
653: * Sets the needed edit action(s).<p>
654: *
655: * @param editCol the list column for edition.
656: */
657: protected abstract void setEditAction(
658: CmsListColumnDefinition editCol);
659:
660: /**
661: * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
662: */
663: protected void setIndependentActions(CmsListMetadata metadata) {
664:
665: // add user users details
666: CmsListItemDetails usersDetails = new CmsListItemDetails(
667: LIST_DETAIL_USERS);
668: usersDetails.setAtColumn(LIST_COLUMN_DISPLAY);
669: usersDetails.setVisible(false);
670: usersDetails.setShowActionName(Messages.get().container(
671: Messages.GUI_GROUPS_DETAIL_SHOW_USERS_NAME_0));
672: usersDetails.setShowActionHelpText(Messages.get().container(
673: Messages.GUI_GROUPS_DETAIL_SHOW_USERS_HELP_0));
674: usersDetails.setHideActionName(Messages.get().container(
675: Messages.GUI_GROUPS_DETAIL_HIDE_USERS_NAME_0));
676: usersDetails.setHideActionHelpText(Messages.get().container(
677: Messages.GUI_GROUPS_DETAIL_HIDE_USERS_HELP_0));
678: usersDetails.setName(Messages.get().container(
679: Messages.GUI_GROUPS_DETAIL_USERS_NAME_0));
680: usersDetails.setFormatter(new CmsListItemDetailsFormatter(
681: Messages.get().container(
682: Messages.GUI_GROUPS_DETAIL_USERS_NAME_0)));
683: metadata.addItemDetails(usersDetails);
684:
685: // add user children details
686: CmsListItemDetails childDetails = new CmsListItemDetails(
687: LIST_DETAIL_CHILDREN);
688: childDetails.setAtColumn(LIST_COLUMN_DISPLAY);
689: childDetails.setVisible(false);
690: childDetails.setShowActionName(Messages.get().container(
691: Messages.GUI_GROUPS_DETAIL_SHOW_CHILDREN_NAME_0));
692: childDetails.setShowActionHelpText(Messages.get().container(
693: Messages.GUI_GROUPS_DETAIL_SHOW_CHILDREN_HELP_0));
694: childDetails.setHideActionName(Messages.get().container(
695: Messages.GUI_GROUPS_DETAIL_HIDE_CHILDREN_NAME_0));
696: childDetails.setHideActionHelpText(Messages.get().container(
697: Messages.GUI_GROUPS_DETAIL_HIDE_CHILDREN_HELP_0));
698: childDetails.setName(Messages.get().container(
699: Messages.GUI_GROUPS_DETAIL_CHILDREN_NAME_0));
700: childDetails.setFormatter(new CmsListItemDetailsFormatter(
701: Messages.get().container(
702: Messages.GUI_GROUPS_DETAIL_CHILDREN_NAME_0)));
703: metadata.addItemDetails(childDetails);
704:
705: // add parent group details
706: CmsListItemDetails parentDetails = new CmsListItemDetails(
707: LIST_DETAIL_PARENT);
708: parentDetails.setAtColumn(LIST_COLUMN_DISPLAY);
709: parentDetails.setVisible(false);
710: parentDetails.setShowActionName(Messages.get().container(
711: Messages.GUI_GROUPS_DETAIL_SHOW_PARENT_NAME_0));
712: parentDetails.setShowActionHelpText(Messages.get().container(
713: Messages.GUI_GROUPS_DETAIL_SHOW_PARENT_HELP_0));
714: parentDetails.setHideActionName(Messages.get().container(
715: Messages.GUI_GROUPS_DETAIL_HIDE_PARENT_NAME_0));
716: parentDetails.setHideActionHelpText(Messages.get().container(
717: Messages.GUI_GROUPS_DETAIL_HIDE_PARENT_HELP_0));
718: parentDetails.setName(Messages.get().container(
719: Messages.GUI_GROUPS_DETAIL_PARENT_NAME_0));
720: parentDetails.setFormatter(new CmsListItemDetailsFormatter(
721: Messages.get().container(
722: Messages.GUI_GROUPS_DETAIL_PARENT_NAME_0)));
723: metadata.addItemDetails(parentDetails);
724:
725: // add folder permission details
726: CmsListItemDetails setPermDetails = new CmsListItemDetails(
727: LIST_DETAIL_SET_PERM);
728: setPermDetails.setAtColumn(LIST_COLUMN_DISPLAY);
729: setPermDetails.setVisible(false);
730: setPermDetails.setShowActionName(Messages.get().container(
731: Messages.GUI_GROUPS_DETAIL_SHOW_SET_PERM_NAME_0));
732: setPermDetails.setShowActionHelpText(Messages.get().container(
733: Messages.GUI_GROUPS_DETAIL_SHOW_SET_PERM_HELP_0));
734: setPermDetails.setHideActionName(Messages.get().container(
735: Messages.GUI_GROUPS_DETAIL_HIDE_SET_PERM_NAME_0));
736: setPermDetails.setHideActionHelpText(Messages.get().container(
737: Messages.GUI_GROUPS_DETAIL_HIDE_SET_PERM_HELP_0));
738: setPermDetails.setName(Messages.get().container(
739: Messages.GUI_GROUPS_DETAIL_SET_PERM_NAME_0));
740: setPermDetails.setFormatter(new CmsListItemDetailsFormatter(
741: Messages.get().container(
742: Messages.GUI_GROUPS_DETAIL_SET_PERM_NAME_0)));
743: metadata.addItemDetails(setPermDetails);
744:
745: // makes the list searchable
746: CmsListSearchAction searchAction = new CmsListSearchAction(
747: metadata.getColumnDefinition(LIST_COLUMN_DISPLAY));
748: metadata.setSearchAction(searchAction);
749: }
750:
751: /**
752: * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
753: */
754: protected void setMultiActions(CmsListMetadata metadata) {
755:
756: // add delete multi action
757: CmsListMultiAction deleteMultiAction = new CmsListMultiAction(
758: LIST_MACTION_DELETE);
759: deleteMultiAction.setName(Messages.get().container(
760: Messages.GUI_GROUPS_LIST_MACTION_DELETE_NAME_0));
761: deleteMultiAction.setHelpText(Messages.get().container(
762: Messages.GUI_GROUPS_LIST_MACTION_DELETE_HELP_0));
763: deleteMultiAction
764: .setConfirmationMessage(Messages.get().container(
765: Messages.GUI_GROUPS_LIST_MACTION_DELETE_CONF_0));
766: deleteMultiAction.setIconPath(ICON_MULTI_DELETE);
767: metadata.addMultiAction(deleteMultiAction);
768:
769: // add the activate user multi action
770: CmsListMultiAction activateUser = new CmsListMultiAction(
771: LIST_MACTION_ACTIVATE);
772: activateUser.setName(Messages.get().container(
773: Messages.GUI_GROUPS_LIST_MACTION_ACTIVATE_NAME_0));
774: activateUser.setHelpText(Messages.get().container(
775: Messages.GUI_GROUPS_LIST_MACTION_ACTIVATE_HELP_0));
776: activateUser.setConfirmationMessage(Messages.get().container(
777: Messages.GUI_GROUPS_LIST_MACTION_ACTIVATE_CONF_0));
778: activateUser.setIconPath(ICON_MULTI_ACTIVATE);
779: metadata.addMultiAction(activateUser);
780:
781: // add the deactivate user multi action
782: CmsListMultiAction deactivateUser = new CmsListMultiAction(
783: LIST_MACTION_DEACTIVATE);
784: deactivateUser.setName(Messages.get().container(
785: Messages.GUI_GROUPS_LIST_MACTION_DEACTIVATE_NAME_0));
786: deactivateUser.setHelpText(Messages.get().container(
787: Messages.GUI_GROUPS_LIST_MACTION_DEACTIVATE_HELP_0));
788: deactivateUser.setConfirmationMessage(Messages.get().container(
789: Messages.GUI_GROUPS_LIST_MACTION_DEACTIVATE_CONF_0));
790: deactivateUser.setIconPath(ICON_MULTI_DEACTIVATE);
791: metadata.addMultiAction(deactivateUser);
792: }
793:
794: /**
795: * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
796: */
797: protected void validateParamaters() throws Exception {
798:
799: // test the needed parameters
800: OpenCms.getRoleManager().checkRole(getCms(),
801: CmsRole.ACCOUNT_MANAGER.forOrgUnit(getParamOufqn()));
802: OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(),
803: getParamOufqn()).getName();
804: }
805: }
|