Source Code Cross Referenced for CmsGroupTransferList.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/CmsGroupTransferList.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:26 $
004:         * Version: $Revision: 1.6 $
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.CmsUser;
036:        import org.opencms.jsp.CmsJspActionElement;
037:        import org.opencms.main.CmsException;
038:        import org.opencms.main.CmsRuntimeException;
039:        import org.opencms.main.OpenCms;
040:        import org.opencms.security.CmsPrincipal;
041:        import org.opencms.util.CmsRequestUtil;
042:        import org.opencms.util.CmsStringUtil;
043:        import org.opencms.util.CmsUUID;
044:        import org.opencms.workplace.list.A_CmsListDialog;
045:        import org.opencms.workplace.list.CmsHtmlList;
046:        import org.opencms.workplace.list.CmsListColumnAlignEnum;
047:        import org.opencms.workplace.list.CmsListColumnDefinition;
048:        import org.opencms.workplace.list.CmsListDefaultAction;
049:        import org.opencms.workplace.list.CmsListDirectAction;
050:        import org.opencms.workplace.list.CmsListItem;
051:        import org.opencms.workplace.list.CmsListItemDetails;
052:        import org.opencms.workplace.list.CmsListItemDetailsFormatter;
053:        import org.opencms.workplace.list.CmsListMetadata;
054:        import org.opencms.workplace.list.CmsListOrderEnum;
055:
056:        import java.io.IOException;
057:        import java.util.ArrayList;
058:        import java.util.HashSet;
059:        import java.util.Iterator;
060:        import java.util.List;
061:        import java.util.Set;
062:
063:        import javax.servlet.ServletException;
064:        import javax.servlet.http.HttpServletRequest;
065:        import javax.servlet.http.HttpServletResponse;
066:        import javax.servlet.jsp.PageContext;
067:
068:        /**
069:         * Allows to select a group to transfer the permissions and attributes from another one.<p>
070:         * 
071:         * @author Michael Moossen  
072:         * 
073:         * @version $Revision: 1.6 $ 
074:         * 
075:         * @since 6.0.0 
076:         */
077:        public class CmsGroupTransferList extends A_CmsListDialog {
078:
079:            /** list action id constant. */
080:            public static final String LIST_ACTION_TRANSFER = "at";
081:
082:            /** list column id constant. */
083:            public static final String LIST_COLUMN_DESCRIPTION = "cc";
084:
085:            /** list column id constant. */
086:            public static final String LIST_COLUMN_NAME = "cn";
087:
088:            /** list column id constant. */
089:            public static final String LIST_COLUMN_PARENT = "cp";
090:
091:            /** list column id constant. */
092:            public static final String LIST_COLUMN_TRANSFER = "ct";
093:
094:            /** list column id constant. */
095:            public static final String LIST_COLUMN_USERS = "cu";
096:
097:            /** list action id constant. */
098:            public static final String LIST_DEFACTION_TRANSFER = "dt";
099:
100:            /** list item detail id constant. */
101:            public static final String LIST_DETAIL_CHILDREN = "dc";
102:
103:            /** list item detail id constant. */
104:            public static final String LIST_DETAIL_USERS = "du";
105:
106:            /** List id constant. */
107:            public static final String LIST_ID = "lgt";
108:
109:            /** Stores the value of the group name, could be a list of names. */
110:            private String m_groupName;
111:
112:            /** Stores the value of the request parameter for the group id, could be a list of ids. */
113:            private String m_paramGroupid;
114:
115:            /**
116:             * Public constructor.<p>
117:             * 
118:             * @param jsp an initialized JSP action element
119:             */
120:            public CmsGroupTransferList(CmsJspActionElement jsp) {
121:
122:                this (LIST_ID, jsp);
123:            }
124:
125:            /**
126:             * Public constructor with JSP variables.<p>
127:             * 
128:             * @param context the JSP page context
129:             * @param req the JSP request
130:             * @param res the JSP response
131:             */
132:            public CmsGroupTransferList(PageContext context,
133:                    HttpServletRequest req, HttpServletResponse res) {
134:
135:                this (new CmsJspActionElement(context, req, res));
136:            }
137:
138:            /**
139:             * Protected constructor.<p>
140:             * 
141:             * @param listId the id of the specialized list
142:             * @param jsp an initialized JSP action element
143:             */
144:            protected CmsGroupTransferList(String listId,
145:                    CmsJspActionElement jsp) {
146:
147:                super (jsp, listId, Messages.get().container(
148:                        Messages.GUI_GROUPS_TRANSFER_LIST_NAME_0),
149:                        LIST_COLUMN_NAME, CmsListOrderEnum.ORDER_ASCENDING,
150:                        LIST_COLUMN_NAME);
151:            }
152:
153:            /**
154:             * This method should handle every defined list multi action,
155:             * by comparing <code>{@link #getParamListAction()}</code> with the id 
156:             * of the action to execute.<p> 
157:             * 
158:             * @throws CmsRuntimeException to signal that an action is not supported
159:             * 
160:             */
161:            public void executeListMultiActions() throws CmsRuntimeException {
162:
163:                throwListUnsupportedActionException();
164:            }
165:
166:            /**
167:             * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
168:             */
169:            public void executeListSingleActions() throws IOException,
170:                    ServletException, CmsRuntimeException {
171:
172:                if (getParamListAction().equals(LIST_DEFACTION_TRANSFER)
173:                        || getParamListAction().equals(LIST_ACTION_TRANSFER)) {
174:                    try {
175:                        getCms().deleteGroup(new CmsUUID(getParamGroupid()),
176:                                new CmsUUID(getSelectedItem().getId()));
177:                        CmsRequestUtil.forwardRequest(getParamCloseLink(),
178:                                getJsp().getRequest(), getJsp().getResponse());
179:                        setForwarded(true);
180:                    } catch (CmsException e) {
181:                        throw new CmsRuntimeException(Messages.get().container(
182:                                Messages.ERR_TRANSFER_GROUP_1,
183:                                getSelectedItem().get(LIST_COLUMN_NAME)), e);
184:                    }
185:                } else {
186:                    throwListUnsupportedActionException();
187:                }
188:                listSave();
189:            }
190:
191:            /**
192:             * Returns the group Name.<p>
193:             *
194:             * @return the group Name
195:             */
196:            public String getGroupName() {
197:
198:                return m_groupName;
199:            }
200:
201:            /**
202:             * Returns the group id parameter value.<p>
203:             * 
204:             * @return the group id parameter value
205:             */
206:            public String getParamGroupid() {
207:
208:                return m_paramGroupid;
209:            }
210:
211:            /**
212:             * Sets the group id parameter value.<p>
213:             * 
214:             * @param groupId the group id parameter value
215:             */
216:            public void setParamGroupid(String groupId) {
217:
218:                m_paramGroupid = groupId;
219:            }
220:
221:            /**
222:             * @see org.opencms.workplace.list.A_CmsListDialog#customHtmlStart()
223:             */
224:            protected String customHtmlStart() {
225:
226:                StringBuffer result = new StringBuffer(2048);
227:                result
228:                        .append(dialogBlockStart(Messages.get().container(
229:                                Messages.GUI_GROUPS_TRANSFER_NOTICE_0).key(
230:                                getLocale())));
231:                result.append("\n");
232:                if (getCurrentToolPath().indexOf("/edit/") < 0) {
233:                    result
234:                            .append(key(Messages.GUI_GROUP_DEPENDENCIES_SELECTED_GROUPS_0));
235:                    result.append(":<br>\n");
236:                    List users = CmsStringUtil.splitAsList(getGroupName(),
237:                            CmsHtmlList.ITEM_SEPARATOR, true);
238:                    result.append("<ul>\n");
239:                    Iterator it = users.iterator();
240:                    while (it.hasNext()) {
241:                        String name = (String) it.next();
242:                        result.append("<li>");
243:                        result.append(name);
244:                        result.append("</li>\n");
245:                    }
246:                    result.append("</ul>\n");
247:                }
248:                result.append(key(Messages.GUI_GROUPS_TRANSFER_NOTICE_TEXT_0));
249:                result.append(dialogBlockEnd());
250:                return result.toString();
251:            }
252:
253:            /**
254:             * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
255:             */
256:            protected void fillDetails(String detailId) {
257:
258:                // get content
259:                List groups = getList().getAllContent();
260:                Iterator itGroups = groups.iterator();
261:                while (itGroups.hasNext()) {
262:                    CmsListItem item = (CmsListItem) itGroups.next();
263:                    String groupName = item.get(LIST_COLUMN_NAME).toString();
264:                    StringBuffer html = new StringBuffer(512);
265:                    try {
266:                        if (detailId.equals(LIST_DETAIL_USERS)) {
267:                            // users
268:                            Iterator itUsers = getCms().getUsersOfGroup(
269:                                    groupName).iterator();
270:                            while (itUsers.hasNext()) {
271:                                html.append(((CmsUser) itUsers.next())
272:                                        .getFullName());
273:                                if (itUsers.hasNext()) {
274:                                    html.append("<br>");
275:                                }
276:                                html.append("\n");
277:                            }
278:                        } else if (detailId.equals(LIST_DETAIL_CHILDREN)) {
279:                            // children
280:                            Iterator itChildren = getCms().getChildren(
281:                                    groupName, false).iterator();
282:                            while (itChildren.hasNext()) {
283:                                html.append(((CmsGroup) itChildren.next())
284:                                        .getName());
285:                                if (itChildren.hasNext()) {
286:                                    html.append("<br>");
287:                                }
288:                                html.append("\n");
289:                            }
290:                        } else {
291:                            continue;
292:                        }
293:                    } catch (Exception e) {
294:                        // ignore
295:                    }
296:                    item.set(detailId, html.toString());
297:                }
298:            }
299:
300:            /**
301:             * Returns the list of groups to display.<p>
302:             * 
303:             * @return the list of groups to display
304:             * 
305:             * @throws CmsException if something goes wrong
306:             */
307:            protected List getGroups() throws CmsException {
308:
309:                return CmsPrincipal.filterCore(OpenCms.getOrgUnitManager()
310:                        .getGroups(getCms(), "", true));
311:            }
312:
313:            /**
314:             * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
315:             */
316:            protected List getListItems() throws CmsException {
317:
318:                List ret = new ArrayList();
319:                // get content
320:                List groups = getGroups();
321:                Set selGroups = new HashSet(CmsStringUtil.splitAsList(
322:                        getParamGroupid(), CmsHtmlList.ITEM_SEPARATOR, true));
323:                Iterator itGroups = groups.iterator();
324:                while (itGroups.hasNext()) {
325:                    CmsGroup group = (CmsGroup) itGroups.next();
326:                    if (selGroups.contains(group.getId().toString())) {
327:                        continue;
328:                    }
329:                    CmsListItem item = getList().newItem(
330:                            group.getId().toString());
331:                    item.set(LIST_COLUMN_NAME, group.getName());
332:                    item.set(LIST_COLUMN_DESCRIPTION, group
333:                            .getDescription(getLocale()));
334:                    try {
335:                        item.set(LIST_COLUMN_PARENT, getCms().readGroup(
336:                                group.getParentId()).getName());
337:                    } catch (Exception e) {
338:                        // ignore
339:                    }
340:                    ret.add(item);
341:                }
342:
343:                return ret;
344:            }
345:
346:            /**
347:             * @see org.opencms.workplace.CmsWorkplace#initMessages()
348:             */
349:            protected void initMessages() {
350:
351:                // add specific dialog resource bundle
352:                addMessages(Messages.get().getBundleName());
353:                // add default resource bundles
354:                super .initMessages();
355:            }
356:
357:            /**
358:             * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
359:             */
360:            protected void setColumns(CmsListMetadata metadata) {
361:
362:                // create column for transfer
363:                CmsListColumnDefinition transferCol = new CmsListColumnDefinition(
364:                        LIST_COLUMN_TRANSFER);
365:                transferCol.setName(Messages.get().container(
366:                        Messages.GUI_GROUPS_TRANSFER_LIST_COLS_TRANSFER_0));
367:                transferCol
368:                        .setHelpText(Messages
369:                                .get()
370:                                .container(
371:                                        Messages.GUI_GROUPS_TRANSFER_LIST_COLS_TRANSFER_HELP_0));
372:                transferCol.setWidth("20");
373:                transferCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
374:                transferCol.setSorteable(false);
375:
376:                // add transfer action
377:                setTransferAction(transferCol);
378:                // add it to the list definition
379:                metadata.addColumn(transferCol);
380:
381:                // create column for name
382:                CmsListColumnDefinition nameCol = new CmsListColumnDefinition(
383:                        LIST_COLUMN_NAME);
384:                nameCol.setName(Messages.get().container(
385:                        Messages.GUI_GROUPS_LIST_COLS_NAME_0));
386:                nameCol.setWidth("20%");
387:
388:                // create default transfer action
389:                CmsListDefaultAction defTransferAction = new CmsListDefaultAction(
390:                        LIST_DEFACTION_TRANSFER);
391:                defTransferAction
392:                        .setName(Messages
393:                                .get()
394:                                .container(
395:                                        Messages.GUI_GROUPS_TRANSFER_LIST_DEFACTION_TRANSFER_NAME_0));
396:                defTransferAction
397:                        .setHelpText(Messages
398:                                .get()
399:                                .container(
400:                                        Messages.GUI_GROUPS_TRANSFER_LIST_DEFACTION_TRANSFER_HELP_0));
401:                nameCol.addDefaultAction(defTransferAction);
402:
403:                // add it to the list definition
404:                metadata.addColumn(nameCol);
405:
406:                // add column for description
407:                CmsListColumnDefinition descriptionCol = new CmsListColumnDefinition(
408:                        LIST_COLUMN_DESCRIPTION);
409:                descriptionCol.setName(Messages.get().container(
410:                        Messages.GUI_GROUPS_LIST_COLS_DESCRIPTION_0));
411:                descriptionCol.setWidth("60%");
412:                metadata.addColumn(descriptionCol);
413:
414:                // add column for parent
415:                CmsListColumnDefinition parentCol = new CmsListColumnDefinition(
416:                        LIST_COLUMN_PARENT);
417:                parentCol.setName(Messages.get().container(
418:                        Messages.GUI_GROUPS_LIST_COLS_PARENT_0));
419:                parentCol.setWidth("20%");
420:                metadata.addColumn(parentCol);
421:            }
422:
423:            /**
424:             * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
425:             */
426:            protected void setIndependentActions(CmsListMetadata metadata) {
427:
428:                // add user users details
429:                CmsListItemDetails usersDetails = new CmsListItemDetails(
430:                        LIST_DETAIL_USERS);
431:                usersDetails.setAtColumn(LIST_COLUMN_NAME);
432:                usersDetails.setVisible(false);
433:                usersDetails.setShowActionName(Messages.get().container(
434:                        Messages.GUI_GROUPS_DETAIL_SHOW_USERS_NAME_0));
435:                usersDetails.setShowActionHelpText(Messages.get().container(
436:                        Messages.GUI_GROUPS_DETAIL_SHOW_USERS_HELP_0));
437:                usersDetails.setHideActionName(Messages.get().container(
438:                        Messages.GUI_GROUPS_DETAIL_HIDE_USERS_NAME_0));
439:                usersDetails.setHideActionHelpText(Messages.get().container(
440:                        Messages.GUI_GROUPS_DETAIL_HIDE_USERS_HELP_0));
441:                usersDetails.setName(Messages.get().container(
442:                        Messages.GUI_GROUPS_DETAIL_USERS_NAME_0));
443:                usersDetails.setFormatter(new CmsListItemDetailsFormatter(
444:                        Messages.get().container(
445:                                Messages.GUI_GROUPS_DETAIL_USERS_NAME_0)));
446:                metadata.addItemDetails(usersDetails);
447:
448:                // add user children details
449:                CmsListItemDetails childDetails = new CmsListItemDetails(
450:                        LIST_DETAIL_CHILDREN);
451:                childDetails.setAtColumn(LIST_COLUMN_NAME);
452:                childDetails.setVisible(false);
453:                childDetails.setShowActionName(Messages.get().container(
454:                        Messages.GUI_GROUPS_DETAIL_SHOW_CHILDREN_NAME_0));
455:                childDetails.setShowActionHelpText(Messages.get().container(
456:                        Messages.GUI_GROUPS_DETAIL_SHOW_CHILDREN_HELP_0));
457:                childDetails.setHideActionName(Messages.get().container(
458:                        Messages.GUI_GROUPS_DETAIL_HIDE_CHILDREN_NAME_0));
459:                childDetails.setHideActionHelpText(Messages.get().container(
460:                        Messages.GUI_GROUPS_DETAIL_HIDE_CHILDREN_HELP_0));
461:                childDetails.setName(Messages.get().container(
462:                        Messages.GUI_GROUPS_DETAIL_CHILDREN_NAME_0));
463:                childDetails.setFormatter(new CmsListItemDetailsFormatter(
464:                        Messages.get().container(
465:                                Messages.GUI_GROUPS_DETAIL_CHILDREN_NAME_0)));
466:                metadata.addItemDetails(childDetails);
467:            }
468:
469:            /**
470:             * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
471:             */
472:            protected void setMultiActions(CmsListMetadata metadata) {
473:
474:                // no-op
475:            }
476:
477:            /**
478:             * Sets the icon actions for the transfer list.<p>
479:             * 
480:             * @param transferCol the column to set the action
481:             */
482:            protected void setTransferAction(CmsListColumnDefinition transferCol) {
483:
484:                CmsListDirectAction transferAction = new CmsListDirectAction(
485:                        LIST_ACTION_TRANSFER);
486:                transferAction
487:                        .setName(Messages
488:                                .get()
489:                                .container(
490:                                        Messages.GUI_GROUPS_TRANSFER_LIST_ACTION_TRANSFER_NAME_0));
491:                transferAction
492:                        .setHelpText(Messages
493:                                .get()
494:                                .container(
495:                                        Messages.GUI_GROUPS_TRANSFER_LIST_ACTION_TRANSFER_HELP_0));
496:                transferAction.setIconPath(A_CmsUsersList.PATH_BUTTONS
497:                        + "group.png");
498:                transferCol.addDirectAction(transferAction);
499:            }
500:
501:            /**
502:             * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
503:             */
504:            protected void validateParamaters() throws Exception {
505:
506:                // test the needed parameters
507:                m_groupName = "";
508:                Iterator itGroups = CmsStringUtil.splitAsList(
509:                        getParamGroupid(), CmsHtmlList.ITEM_SEPARATOR, true)
510:                        .iterator();
511:                while (itGroups.hasNext()) {
512:                    CmsUUID id = new CmsUUID(itGroups.next().toString());
513:                    m_groupName += getCms().readGroup(id).getName();
514:                    if (itGroups.hasNext()) {
515:                        m_groupName += CmsHtmlList.ITEM_SEPARATOR;
516:                    }
517:                }
518:            }
519:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.