Source Code Cross Referenced for A_CmsUserGroupsList.java in  » Content-Management-System » opencms » org » opencms » workplace » tools » accounts » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » opencms » org.opencms.workplace.tools.accounts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/accounts/A_CmsUserGroupsList.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:26 $
004:         * Version: $Revision: 1.22 $
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.i18n.CmsMessageContainer;
036:        import org.opencms.jsp.CmsJspActionElement;
037:        import org.opencms.main.CmsException;
038:        import org.opencms.security.CmsOrganizationalUnit;
039:        import org.opencms.util.CmsUUID;
040:        import org.opencms.workplace.list.A_CmsListDialog;
041:        import org.opencms.workplace.list.CmsListColumnAlignEnum;
042:        import org.opencms.workplace.list.CmsListColumnDefinition;
043:        import org.opencms.workplace.list.CmsListIndependentAction;
044:        import org.opencms.workplace.list.CmsListItem;
045:        import org.opencms.workplace.list.CmsListItemDetails;
046:        import org.opencms.workplace.list.CmsListItemDetailsFormatter;
047:        import org.opencms.workplace.list.CmsListMetadata;
048:        import org.opencms.workplace.list.CmsListOrderEnum;
049:
050:        import java.util.ArrayList;
051:        import java.util.Iterator;
052:        import java.util.List;
053:
054:        /**
055:         * Generalized user groups view.<p>
056:         * 
057:         * @author Michael Moossen 
058:         *  
059:         * @version $Revision: 1.22 $ 
060:         * 
061:         * @since 6.0.0 
062:         */
063:        public abstract class A_CmsUserGroupsList extends A_CmsListDialog {
064:
065:            /** list action id constant. */
066:            public static final String LIST_ACTION_ICON = "ai";
067:
068:            /** list action id constant. */
069:            public static final String LIST_ACTION_ICON_DIRECT = "aid";
070:
071:            /** list action id constant. */
072:            public static final String LIST_ACTION_ICON_INDIRECT = "aii";
073:
074:            /** list action id constant. */
075:            public static final String LIST_ACTION_STATE_DIRECT = "asd";
076:
077:            /** list action id constant. */
078:            public static final String LIST_ACTION_STATE_INDIRECT = "asi";
079:
080:            /** list column id constant. */
081:            public static final String LIST_COLUMN_DESCRIPTION = "cd";
082:
083:            /** list column id constant. */
084:            public static final String LIST_COLUMN_DISPLAY = "cdn";
085:
086:            /** list column id constant. */
087:            public static final String LIST_COLUMN_ICON = "ci";
088:
089:            /** list column id constant. */
090:            public static final String LIST_COLUMN_NAME = "cn";
091:
092:            /** list column id constant. */
093:            public static final String LIST_COLUMN_ORGUNIT = "co";
094:
095:            /** list column id constant. */
096:            public static final String LIST_COLUMN_STATE = "cs";
097:
098:            /** list item detail id constant. */
099:            public static final String LIST_DETAIL_OTHEROU = "doo";
100:
101:            /** Cached value. */
102:            private Boolean m_hasGroupsInOtherOus;
103:
104:            /** Stores the value of the request parameter for the organizational unit. */
105:            private String m_paramOufqn;
106:
107:            /** Stores the value of the request parameter for the user id. */
108:            private String m_paramUserid;
109:
110:            /** Stores the value of the request parameter for the user name. */
111:            private String m_paramUsername;
112:
113:            /**
114:             * Public constructor.<p>
115:             * 
116:             * @param jsp an initialized JSP action element
117:             * @param listId the id of the list
118:             * @param listName the name of the list
119:             * @param searchable searchable flag
120:             */
121:            protected A_CmsUserGroupsList(CmsJspActionElement jsp,
122:                    String listId, CmsMessageContainer listName,
123:                    boolean searchable) {
124:
125:                super (jsp, listId, listName, LIST_COLUMN_DISPLAY,
126:                        CmsListOrderEnum.ORDER_ASCENDING,
127:                        searchable ? LIST_COLUMN_DISPLAY : null);
128:            }
129:
130:            /**
131:             * Returns the organizational unit parameter value.<p>
132:             * 
133:             * @return the organizational unit parameter value
134:             */
135:            public String getParamOufqn() {
136:
137:                return m_paramOufqn;
138:            }
139:
140:            /**
141:             * Returns the user id parameter value.<p>
142:             * 
143:             * @return the user id parameter value
144:             */
145:            public String getParamUserid() {
146:
147:                return m_paramUserid;
148:            }
149:
150:            /**
151:             * Returns the User name parameter value.<p>
152:             *
153:             * @return the User name parameter value
154:             */
155:            public String getParamUsername() {
156:
157:                return m_paramUsername;
158:            }
159:
160:            /**
161:             * Returns if the list of groups has groups of other organizational units.<p>
162:             * 
163:             * @return if the list of groups has groups of other organizational units
164:             */
165:            public boolean hasGroupsInOtherOus() {
166:
167:                if (m_hasGroupsInOtherOus == null) {
168:                    // lazzy initialization
169:                    m_hasGroupsInOtherOus = Boolean.FALSE;
170:                    try {
171:                        List groups = getGroups(true);
172:                        Iterator itGroups = groups.iterator();
173:                        while (itGroups.hasNext()) {
174:                            CmsGroup group = (CmsGroup) itGroups.next();
175:                            if (!group.getOuFqn().equals(getParamOufqn())) {
176:                                m_hasGroupsInOtherOus = Boolean.TRUE;
177:                                break;
178:                            }
179:                        }
180:                    } catch (Exception e) {
181:                        // ignore
182:                    }
183:                }
184:                return m_hasGroupsInOtherOus.booleanValue();
185:            }
186:
187:            /**
188:             * Sets the user organizational unit value.<p>
189:             * 
190:             * @param ouFqn the organizational unit parameter value
191:             */
192:            public void setParamOufqn(String ouFqn) {
193:
194:                if (ouFqn == null) {
195:                    ouFqn = "";
196:                }
197:                m_paramOufqn = ouFqn;
198:            }
199:
200:            /**
201:             * Sets the user id parameter value.<p>
202:             * 
203:             * @param userId the user id parameter value
204:             */
205:            public void setParamUserid(String userId) {
206:
207:                m_paramUserid = userId;
208:            }
209:
210:            /**
211:             * Sets the User name parameter value.<p>
212:             * 
213:             * @param username the username to set
214:             */
215:            public void setParamUsername(String username) {
216:
217:                m_paramUsername = username;
218:            }
219:
220:            /**
221:             * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
222:             */
223:            protected void fillDetails(String detailId) {
224:
225:                // noop
226:            }
227:
228:            /**
229:             * Returns a list of groups to display.<p>
230:             * 
231:             * @param withOtherOus if not set only groups of the current ou should be returned
232:             * 
233:             * @return a list of <code><{@link CmsGroup}</code>s
234:             * 
235:             * @throws CmsException if something goes wrong
236:             */
237:            protected abstract List getGroups(boolean withOtherOus)
238:                    throws CmsException;
239:
240:            /**
241:             * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
242:             */
243:            protected List getListItems() throws CmsException {
244:
245:                boolean withOtherOus = hasGroupsInOtherOus()
246:                        && getList().getMetadata().getItemDetailDefinition(
247:                                LIST_DETAIL_OTHEROU) != null
248:                        && getList().getMetadata().getItemDetailDefinition(
249:                                LIST_DETAIL_OTHEROU).isVisible();
250:                List ret = new ArrayList();
251:                // get content        
252:                List groups = getGroups(withOtherOus);
253:                Iterator itGroups = groups.iterator();
254:                while (itGroups.hasNext()) {
255:                    CmsGroup group = (CmsGroup) itGroups.next();
256:                    CmsListItem item = getList().newItem(
257:                            group.getId().toString());
258:                    item.set(LIST_COLUMN_NAME, group.getName());
259:                    item.set(LIST_COLUMN_DISPLAY, group.getSimpleName());
260:                    item.set(LIST_COLUMN_DESCRIPTION, group
261:                            .getDescription(getLocale()));
262:                    item.set(LIST_COLUMN_ORGUNIT,
263:                            CmsOrganizationalUnit.SEPARATOR + group.getOuFqn());
264:                    ret.add(item);
265:                }
266:                return ret;
267:            }
268:
269:            /**
270:             * @see org.opencms.workplace.list.A_CmsListDialog#initializeDetail(java.lang.String)
271:             */
272:            protected void initializeDetail(String detailId) {
273:
274:                super .initializeDetail(detailId);
275:                if (detailId.equals(LIST_DETAIL_OTHEROU)) {
276:                    boolean visible = hasGroupsInOtherOus()
277:                            && getList().getMetadata().getItemDetailDefinition(
278:                                    LIST_DETAIL_OTHEROU).isVisible();
279:                    getList().getMetadata().getColumnDefinition(
280:                            LIST_COLUMN_ORGUNIT).setVisible(visible);
281:                    getList().getMetadata().getColumnDefinition(
282:                            LIST_COLUMN_ORGUNIT).setPrintable(visible);
283:                }
284:            }
285:
286:            /**
287:             * @see org.opencms.workplace.CmsWorkplace#initMessages()
288:             */
289:            protected void initMessages() {
290:
291:                // add specific dialog resource bundle
292:                addMessages(Messages.get().getBundleName());
293:                // add default resource bundles
294:                super .initMessages();
295:            }
296:
297:            /**
298:             * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
299:             */
300:            protected void setColumns(CmsListMetadata metadata) {
301:
302:                // create column for icon display
303:                CmsListColumnDefinition iconCol = new CmsListColumnDefinition(
304:                        LIST_COLUMN_ICON);
305:                iconCol.setName(Messages.get().container(
306:                        Messages.GUI_GROUPS_LIST_COLS_ICON_0));
307:                iconCol.setHelpText(Messages.get().container(
308:                        Messages.GUI_GROUPS_LIST_COLS_ICON_HELP_0));
309:                iconCol.setWidth("20");
310:                iconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
311:                iconCol.setSorteable(false);
312:                // add icon actions
313:                setIconAction(iconCol);
314:                // add it to the list definition
315:                metadata.addColumn(iconCol);
316:                // add state column and actions 
317:                setStateActionCol(metadata);
318:
319:                CmsListColumnDefinition nameCol = new CmsListColumnDefinition(
320:                        LIST_COLUMN_NAME);
321:                nameCol.setVisible(false);
322:                metadata.addColumn(nameCol);
323:
324:                // create column for display name
325:                CmsListColumnDefinition displayCol = new CmsListColumnDefinition(
326:                        LIST_COLUMN_DISPLAY);
327:                displayCol.setName(Messages.get().container(
328:                        Messages.GUI_GROUPS_LIST_COLS_NAME_0));
329:                displayCol.setWidth("35%");
330:                // add default actions
331:                setDefaultAction(displayCol);
332:                // add it to the list definition
333:                metadata.addColumn(displayCol);
334:
335:                // create column for orgunit
336:                CmsListColumnDefinition orgunitCol = new CmsListColumnDefinition(
337:                        LIST_COLUMN_ORGUNIT);
338:                orgunitCol.setName(Messages.get().container(
339:                        Messages.GUI_USERS_LIST_COLS_ORGUNIT_0));
340:                orgunitCol.setVisible(false);
341:                // add it to the list definition
342:                metadata.addColumn(orgunitCol);
343:
344:                // create column for description
345:                CmsListColumnDefinition descCol = new CmsListColumnDefinition(
346:                        LIST_COLUMN_DESCRIPTION);
347:                descCol.setName(Messages.get().container(
348:                        Messages.GUI_GROUPS_LIST_COLS_DESCRIPTION_0));
349:                descCol.setWidth("65%");
350:                descCol.setTextWrapping(true);
351:                // add it to the list definition
352:                metadata.addColumn(descCol);
353:            }
354:
355:            /**
356:             * Sets the optional login default action.<p>
357:             * 
358:             * @param nameCol the group name column
359:             */
360:            protected abstract void setDefaultAction(
361:                    CmsListColumnDefinition nameCol);
362:
363:            /**
364:             * Sets the needed icon action(s).<p>
365:             * 
366:             * @param iconCol the list column for edition.
367:             */
368:            protected abstract void setIconAction(
369:                    CmsListColumnDefinition iconCol);
370:
371:            /**
372:             * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
373:             */
374:            protected void setIndependentActions(CmsListMetadata metadata) {
375:
376:                // add user address details
377:                CmsListItemDetails otherOuDetails = new CmsListItemDetails(
378:                        LIST_DETAIL_OTHEROU);
379:                otherOuDetails.setHideAction(new CmsListIndependentAction(
380:                        LIST_DETAIL_OTHEROU) {
381:
382:                    /**
383:                     * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getIconPath()
384:                     */
385:                    public String getIconPath() {
386:
387:                        return A_CmsListDialog.ICON_DETAILS_HIDE;
388:                    }
389:
390:                    /**
391:                     * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
392:                     */
393:                    public boolean isVisible() {
394:
395:                        return ((A_CmsUserGroupsList) getWp())
396:                                .hasGroupsInOtherOus();
397:                    }
398:                });
399:                otherOuDetails.setShowAction(new CmsListIndependentAction(
400:                        LIST_DETAIL_OTHEROU) {
401:
402:                    /**
403:                     * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getIconPath()
404:                     */
405:                    public String getIconPath() {
406:
407:                        return A_CmsListDialog.ICON_DETAILS_SHOW;
408:                    }
409:
410:                    /**
411:                     * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
412:                     */
413:                    public boolean isVisible() {
414:
415:                        return ((A_CmsUserGroupsList) getWp())
416:                                .hasGroupsInOtherOus();
417:                    }
418:                });
419:                otherOuDetails.setShowActionName(Messages.get().container(
420:                        Messages.GUI_GROUPS_DETAIL_SHOW_OTHEROU_NAME_0));
421:                otherOuDetails.setShowActionHelpText(Messages.get().container(
422:                        Messages.GUI_GROUPS_DETAIL_SHOW_OTHEROU_HELP_0));
423:                otherOuDetails.setHideActionName(Messages.get().container(
424:                        Messages.GUI_GROUPS_DETAIL_HIDE_OTHEROU_NAME_0));
425:                otherOuDetails.setHideActionHelpText(Messages.get().container(
426:                        Messages.GUI_GROUPS_DETAIL_HIDE_OTHEROU_HELP_0));
427:                otherOuDetails.setName(Messages.get().container(
428:                        Messages.GUI_GROUPS_DETAIL_OTHEROU_NAME_0));
429:                otherOuDetails.setFormatter(new CmsListItemDetailsFormatter(
430:                        Messages.get().container(
431:                                Messages.GUI_GROUPS_DETAIL_OTHEROU_NAME_0)));
432:                otherOuDetails.setVisible(true);
433:                metadata.addItemDetails(otherOuDetails);
434:            }
435:
436:            /**
437:             * Sets the optional state change action column.<p>
438:             * 
439:             * @param metadata the list metadata object
440:             */
441:            protected abstract void setStateActionCol(CmsListMetadata metadata);
442:
443:            /**
444:             * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
445:             */
446:            protected void validateParamaters() throws Exception {
447:
448:                // test the needed parameters
449:                m_paramUsername = getCms().readUser(
450:                        new CmsUUID(getParamUserid())).getName();
451:            }
452:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.