Source Code Cross Referenced for A_CmsRolesList.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_CmsRolesList.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:25 $
004:         * Version: $Revision: 1.5 $
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.i18n.CmsMessageContainer;
035:        import org.opencms.jsp.CmsJspActionElement;
036:        import org.opencms.main.CmsException;
037:        import org.opencms.main.OpenCms;
038:        import org.opencms.security.CmsOrganizationalUnit;
039:        import org.opencms.security.CmsRole;
040:        import org.opencms.workplace.list.A_CmsListDialog;
041:        import org.opencms.workplace.list.CmsListColumnDefinition;
042:        import org.opencms.workplace.list.CmsListDefaultAction;
043:        import org.opencms.workplace.list.CmsListDirectAction;
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:        import org.opencms.workplace.list.I_CmsListFormatter;
050:
051:        import java.util.ArrayList;
052:        import java.util.Iterator;
053:        import java.util.List;
054:        import java.util.Locale;
055:
056:        /**
057:         * User roles overview view.<p>
058:         * 
059:         * @author Raphael Schnuck  
060:         * 
061:         * @version $Revision: 1.5 $ 
062:         * 
063:         * @since 6.5.6 
064:         */
065:        public abstract class A_CmsRolesList extends A_CmsListDialog {
066:
067:            /** list action id constant. */
068:            public static final String LIST_ACTION_ICON = "ai";
069:
070:            /** list column id constant. */
071:            public static final String LIST_COLUMN_DEPENDENCY = "cd";
072:
073:            /** list column id constant. */
074:            public static final String LIST_COLUMN_GROUP_NAME = "cgn";
075:
076:            /** list column id constant. */
077:            public static final String LIST_COLUMN_HIDDEN_NAME = "chn";
078:
079:            /** list column id constant. */
080:            public static final String LIST_COLUMN_ICON = "ci";
081:
082:            /** list column id constant. */
083:            public static final String LIST_COLUMN_NAME = "cn";
084:
085:            /** list item detail id constant. */
086:            public static final String LIST_DETAIL_DESCRIPTION = "dd";
087:
088:            /** list item detail id constant. */
089:            public static final String LIST_DETAIL_PATH = "dp";
090:
091:            /** Path to the list buttons. */
092:            public static final String PATH_BUTTONS = "tools/accounts/buttons/";
093:
094:            /** Stores the value of the request parameter for the organizational unit. */
095:            private String m_paramOufqn;
096:
097:            /**
098:             * Public constructor.<p>
099:             * 
100:             * @param jsp an initialized JSP action element
101:             * @param listId the id of the list
102:             * @param listName the name of the list
103:             */
104:            protected A_CmsRolesList(CmsJspActionElement jsp, String listId,
105:                    CmsMessageContainer listName) {
106:
107:                super (jsp, listId, listName, LIST_COLUMN_HIDDEN_NAME,
108:                        CmsListOrderEnum.ORDER_ASCENDING, null);
109:            }
110:
111:            /**
112:             * Returns the right icon path for the given list item.<p>
113:             * 
114:             * @param item the list item to get the icon path for
115:             * 
116:             * @return the icon path for the given role
117:             */
118:            public abstract String getIconPath(CmsListItem item);
119:
120:            /**
121:             * Returns the organizational unit parameter value.<p>
122:             * 
123:             * @return the organizational unit parameter value
124:             */
125:            public String getParamOufqn() {
126:
127:                return m_paramOufqn;
128:            }
129:
130:            /**
131:             * Sets the user organizational unit value.<p>
132:             * 
133:             * @param ouFqn the organizational unit parameter value
134:             */
135:            public void setParamOufqn(String ouFqn) {
136:
137:                if (ouFqn == null) {
138:                    ouFqn = "";
139:                }
140:                m_paramOufqn = ouFqn;
141:            }
142:
143:            /**
144:             * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
145:             */
146:            protected void fillDetails(String detailId) {
147:
148:                // get content
149:                List roles = getList().getAllContent();
150:                Iterator itRoles = roles.iterator();
151:                while (itRoles.hasNext()) {
152:                    CmsListItem item = (CmsListItem) itRoles.next();
153:                    String roleName = item.get(LIST_COLUMN_GROUP_NAME)
154:                            .toString();
155:                    StringBuffer html = new StringBuffer(512);
156:                    try {
157:                        if (detailId.equals(LIST_DETAIL_PATH)) {
158:                            html.append(OpenCms.getOrgUnitManager()
159:                                    .readOrganizationalUnit(
160:                                            getCms(),
161:                                            CmsOrganizationalUnit
162:                                                    .getParentFqn(roleName))
163:                                    .getDisplayName(getLocale()));
164:                        } else if (detailId.equals(LIST_DETAIL_DESCRIPTION)) {
165:                            CmsRole role = CmsRole.valueOf(getCms().readGroup(
166:                                    roleName));
167:                            html.append(role.getDescription(getCms()
168:                                    .getRequestContext().getLocale()));
169:                        } else {
170:                            continue;
171:                        }
172:                    } catch (Exception e) {
173:                        // noop
174:                    }
175:                    item.set(detailId, html.toString());
176:                }
177:            }
178:
179:            /**
180:             * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
181:             */
182:            protected List getListItems() throws CmsException {
183:
184:                List ret = new ArrayList();
185:                List roles = getRoles();
186:                List pRoles = new ArrayList(roles);
187:                Iterator itRoles = roles.iterator();
188:                while (itRoles.hasNext()) {
189:                    CmsRole role = (CmsRole) itRoles.next();
190:                    CmsListItem item = getList().newItem(role.getGroupName());
191:                    Locale locale = getCms().getRequestContext().getLocale();
192:                    item.set(LIST_COLUMN_NAME, role.getName(locale));
193:                    String dependency = "";
194:                    CmsRole parent = role;
195:                    while ((parent.getParentRole() != null)
196:                            && (parent.getParentRole().getParentRole() != null)) {
197:                        String roleName = parent.getParentRole()
198:                                .getName(locale);
199:                        if (dependency.length() > 0) {
200:                            roleName += ", ";
201:                        }
202:                        dependency = roleName + dependency;
203:                        parent = parent.getParentRole();
204:                    }
205:                    String hiddenName = dependency;
206:                    if (role.forOrgUnit(null).equals(CmsRole.WORKPLACE_USER)) {
207:                        // add all roles as parent of the workplace user role
208:                        dependency = "";
209:                        Iterator itWuParents = pRoles.iterator();
210:                        while (itWuParents.hasNext()) {
211:                            CmsRole wuParent = (CmsRole) itWuParents.next();
212:                            if (wuParent.forOrgUnit(null).equals(
213:                                    CmsRole.WORKPLACE_USER)
214:                                    || (wuParent.forOrgUnit(null)
215:                                            .equals(CmsRole.ROOT_ADMIN))) {
216:                                continue;
217:                            }
218:                            String roleName = wuParent.getName(locale);
219:                            if (dependency.length() > 0) {
220:                                roleName += ", ";
221:                            }
222:                            dependency = roleName + dependency;
223:                        }
224:                    }
225:                    item.set(LIST_COLUMN_DEPENDENCY, dependency);
226:                    if (hiddenName.length() > 0) {
227:                        hiddenName = CmsRole.ROOT_ADMIN.getName(locale) + ", "
228:                                + hiddenName;
229:                    } else {
230:                        hiddenName = CmsRole.ROOT_ADMIN.getName(locale);
231:                    }
232:                    if (role.getParentRole() != null) {
233:                        hiddenName += ", " + role.getName(locale);
234:                    }
235:                    item.set(LIST_COLUMN_HIDDEN_NAME, hiddenName);
236:                    item.set(LIST_COLUMN_GROUP_NAME, role.getGroupName());
237:                    ret.add(item);
238:                }
239:                return ret;
240:            }
241:
242:            /**
243:             * Returns all roles to display.<p>
244:             * 
245:             * @return a list of {@link CmsRole} objects
246:             * 
247:             * @throws CmsException if something goes wrong
248:             */
249:            protected abstract List getRoles() throws CmsException;
250:
251:            /**
252:             * Returns if the organizational unit details button should be displayed.<p>
253:             * 
254:             * @return if the organizational unit details button should be displayed
255:             */
256:            protected boolean includeOuDetails() {
257:
258:                return true;
259:            }
260:
261:            /**
262:             * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
263:             */
264:            protected void setColumns(CmsListMetadata metadata) {
265:
266:                // create column for icon display
267:                CmsListColumnDefinition iconCol = new CmsListColumnDefinition(
268:                        LIST_COLUMN_ICON);
269:                iconCol.setName(Messages.get().container(
270:                        Messages.GUI_ROLEEDIT_LIST_COLS_ICON_0));
271:                iconCol.setHelpText(Messages.get().container(
272:                        Messages.GUI_ROLEEDIT_LIST_COLS_ICON_HELP_0));
273:                iconCol.setWidth("1%");
274:                iconCol.setSorteable(false);
275:
276:                // adds a role icon
277:                CmsListDirectAction dirAction = new CmsListDefaultAction(
278:                        LIST_ACTION_ICON) {
279:
280:                    /**
281:                     * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getIconPath()
282:                     */
283:                    public String getIconPath() {
284:
285:                        return ((A_CmsRolesList) getWp())
286:                                .getIconPath(getItem());
287:                    }
288:
289:                };
290:                dirAction.setName(Messages.get().container(
291:                        Messages.GUI_ROLEEDIT_LIST_ICON_NAME_0));
292:                dirAction.setHelpText(Messages.get().container(
293:                        Messages.GUI_ROLEEDIT_LIST_ICON_HELP_0));
294:                dirAction.setIconPath(PATH_BUTTONS + "role.png");
295:                dirAction.setEnabled(false);
296:                iconCol.addDirectAction(dirAction);
297:                // add it to the list definition
298:                metadata.addColumn(iconCol);
299:
300:                // create column for name
301:                CmsListColumnDefinition nameCol = new CmsListColumnDefinition(
302:                        LIST_COLUMN_NAME);
303:                nameCol.setName(Messages.get().container(
304:                        Messages.GUI_ROLEEDIT_LIST_COLS_NAME_0));
305:                nameCol.setWidth("40%");
306:                // add it to the list definition
307:                metadata.addColumn(nameCol);
308:
309:                // create column for path
310:                CmsListColumnDefinition depCol = new CmsListColumnDefinition(
311:                        LIST_COLUMN_DEPENDENCY);
312:                depCol.setName(Messages.get().container(
313:                        Messages.GUI_ROLEEDIT_LIST_COLS_DEPENDENCY_0));
314:                depCol.setWidth("60%");
315:                depCol.setTextWrapping(true);
316:                // add it to the list definition
317:                metadata.addColumn(depCol);
318:
319:                // create column for hidden name
320:                CmsListColumnDefinition hideNameCol = new CmsListColumnDefinition(
321:                        LIST_COLUMN_HIDDEN_NAME);
322:                hideNameCol.setSorteable(true);
323:                hideNameCol.setVisible(false);
324:                // add it to the list definition
325:                metadata.addColumn(hideNameCol);
326:                hideNameCol.setPrintable(false);
327:
328:                // create column for group name
329:                CmsListColumnDefinition groupNameCol = new CmsListColumnDefinition(
330:                        LIST_COLUMN_GROUP_NAME);
331:                groupNameCol.setVisible(false);
332:                // add it to the list definition
333:                metadata.addColumn(groupNameCol);
334:                groupNameCol.setPrintable(false);
335:            }
336:
337:            /**
338:             * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
339:             */
340:            protected void setIndependentActions(CmsListMetadata metadata) {
341:
342:                // add description details
343:                CmsListItemDetails descriptionDetails = new CmsListItemDetails(
344:                        LIST_DETAIL_DESCRIPTION);
345:                descriptionDetails.setAtColumn(LIST_COLUMN_NAME);
346:                descriptionDetails.setVisible(true);
347:                descriptionDetails.setShowActionName(Messages.get().container(
348:                        Messages.GUI_ROLEEDIT_DETAIL_SHOW_DESCRIPTION_NAME_0));
349:                descriptionDetails
350:                        .setShowActionHelpText(Messages
351:                                .get()
352:                                .container(
353:                                        Messages.GUI_ROLEEDIT_DETAIL_SHOW_DESCRIPTION_HELP_0));
354:                descriptionDetails.setHideActionName(Messages.get().container(
355:                        Messages.GUI_ROLEEDIT_DETAIL_HIDE_DESCRIPTION_NAME_0));
356:                descriptionDetails
357:                        .setHideActionHelpText(Messages
358:                                .get()
359:                                .container(
360:                                        Messages.GUI_ROLEEDIT_DETAIL_HIDE_DESCRIPTION_HELP_0));
361:                descriptionDetails.setName(Messages.get().container(
362:                        Messages.GUI_ROLEEDIT_DETAIL_DESCRIPTION_NAME_0));
363:                descriptionDetails.setFormatter(new I_CmsListFormatter() {
364:
365:                    /**
366:                     * @see org.opencms.workplace.list.I_CmsListFormatter#format(java.lang.Object, java.util.Locale)
367:                     */
368:                    public String format(Object data, Locale locale) {
369:
370:                        StringBuffer html = new StringBuffer(512);
371:                        html
372:                                .append("<table border='0' cellspacing='0' cellpadding='0'>\n");
373:                        html.append("\t<tr>\n");
374:                        html.append("\t\t<td style='white-space:normal;' >\n");
375:                        html.append("\t\t\t");
376:                        html.append(data == null ? "" : data);
377:                        html.append("\n");
378:                        html.append("\t\t</td>\n");
379:                        html.append("\t</tr>\n");
380:                        html.append("</table>\n");
381:                        return html.toString();
382:                    }
383:                });
384:                metadata.addItemDetails(descriptionDetails);
385:
386:                if (includeOuDetails()) {
387:                    // add role path
388:                    CmsListItemDetails pathDetails = new CmsListItemDetails(
389:                            LIST_DETAIL_PATH);
390:                    pathDetails.setAtColumn(LIST_COLUMN_NAME);
391:                    pathDetails.setVisible(false);
392:                    pathDetails.setShowActionName(Messages.get().container(
393:                            Messages.GUI_ROLES_DETAIL_SHOW_PATH_NAME_0));
394:                    pathDetails.setShowActionHelpText(Messages.get().container(
395:                            Messages.GUI_ROLES_DETAIL_SHOW_PATH_HELP_0));
396:                    pathDetails.setHideActionName(Messages.get().container(
397:                            Messages.GUI_ROLES_DETAIL_HIDE_PATH_NAME_0));
398:                    pathDetails.setHideActionHelpText(Messages.get().container(
399:                            Messages.GUI_ROLES_DETAIL_HIDE_PATH_HELP_0));
400:                    pathDetails.setName(Messages.get().container(
401:                            Messages.GUI_ROLES_DETAIL_PATH_NAME_0));
402:                    pathDetails.setFormatter(new CmsListItemDetailsFormatter(
403:                            Messages.get().container(
404:                                    Messages.GUI_ROLES_DETAIL_PATH_NAME_0)));
405:                    metadata.addItemDetails(pathDetails);
406:                }
407:            }
408:
409:            /**
410:             * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
411:             */
412:            protected void validateParamaters() throws Exception {
413:
414:                OpenCms.getRoleManager().checkRole(getCms(),
415:                        CmsRole.ACCOUNT_MANAGER.forOrgUnit(getParamOufqn()));
416:            }
417:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.