Source Code Cross Referenced for CmsNotOrgUnitUsersList.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/CmsNotOrgUnitUsersList.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:25 $
004:         * Version: $Revision: 1.4 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
015:         *
016:         * This library is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019:         * Lesser General Public License for more details.
020:         *
021:         * For further information about Alkacon Software GmbH, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.workplace.tools.accounts;
033:
034:        import org.opencms.file.CmsUser;
035:        import org.opencms.i18n.CmsMessageContainer;
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.workplace.list.CmsListColumnAlignEnum;
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.CmsListMetadata;
046:        import org.opencms.workplace.list.CmsListMultiAction;
047:
048:        import java.util.ArrayList;
049:        import java.util.HashSet;
050:        import java.util.Iterator;
051:        import java.util.List;
052:        import java.util.Set;
053:
054:        import javax.servlet.http.HttpServletRequest;
055:        import javax.servlet.http.HttpServletResponse;
056:        import javax.servlet.jsp.PageContext;
057:
058:        /**
059:         * Not organizational unit users view.<p>
060:         * 
061:         * @author Raphael Schnuck  
062:         * 
063:         * @version $Revision: 1.4 $ 
064:         * 
065:         * @since 6.5.6
066:         */
067:        public class CmsNotOrgUnitUsersList extends A_CmsOrgUnitUsersList {
068:
069:            /** list action id constant. */
070:            public static final String LIST_ACTION_ADD = "aa";
071:
072:            /** list action id constant. */
073:            public static final String LIST_DEFACTION_ADD = "da";
074:
075:            /** list id constant. */
076:            public static final String LIST_ID = "lnouu";
077:
078:            /** list action id constant. */
079:            public static final String LIST_MACTION_ADD = "ma";
080:
081:            /** a set of action id's to use for adding. */
082:            protected static Set m_addActionIds = new HashSet();
083:
084:            /**
085:             * Public constructor.<p>
086:             * 
087:             * @param jsp an initialized JSP action element
088:             */
089:            public CmsNotOrgUnitUsersList(CmsJspActionElement jsp) {
090:
091:                this (jsp, LIST_ID);
092:            }
093:
094:            /**
095:             * Public constructor with JSP variables.<p>
096:             * 
097:             * @param context the JSP page context
098:             * @param req the JSP request
099:             * @param res the JSP response
100:             */
101:            public CmsNotOrgUnitUsersList(PageContext context,
102:                    HttpServletRequest req, HttpServletResponse res) {
103:
104:                this (new CmsJspActionElement(context, req, res));
105:            }
106:
107:            /**
108:             * Protected constructor.<p>
109:             * @param jsp an initialized JSP action element
110:             * @param listId the id of the specialized list
111:             */
112:            protected CmsNotOrgUnitUsersList(CmsJspActionElement jsp,
113:                    String listId) {
114:
115:                super (jsp, listId, Messages.get().container(
116:                        Messages.GUI_NOTORGUNITUSERS_LIST_NAME_0), true);
117:            }
118:
119:            /**
120:             * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions()
121:             */
122:            public void executeListMultiActions() throws CmsRuntimeException {
123:
124:                if (getParamListAction().equals(LIST_MACTION_ADD)) {
125:                    // execute the remove multiaction
126:                    try {
127:                        Iterator itItems = getSelectedItems().iterator();
128:                        while (itItems.hasNext()) {
129:                            CmsListItem listItem = (CmsListItem) itItems.next();
130:
131:                            CmsUser user = getCms().readUser(
132:                                    (String) listItem.get(LIST_COLUMN_LOGIN));
133:                            List currentUsers = OpenCms.getOrgUnitManager()
134:                                    .getUsers(getCms(), getParamOufqn(), false);
135:
136:                            boolean inOrgUnit = false;
137:                            Iterator itCurrentUsers = currentUsers.iterator();
138:                            while (itCurrentUsers.hasNext()) {
139:                                CmsUser currentUser = (CmsUser) itCurrentUsers
140:                                        .next();
141:                                if (currentUser.getSimpleName().equals(
142:                                        user.getSimpleName())) {
143:                                    inOrgUnit = true;
144:                                }
145:                            }
146:                            if (!inOrgUnit) {
147:                                List ouUsers = (ArrayList) getJsp()
148:                                        .getRequest()
149:                                        .getSession()
150:                                        .getAttribute(
151:                                                A_CmsOrgUnitUsersList.ORGUNIT_USERS);
152:                                if (ouUsers == null) {
153:                                    ouUsers = new ArrayList();
154:                                }
155:                                ouUsers.add(user);
156:                                setOuUsers(ouUsers);
157:
158:                                List notOuUsers = (ArrayList) getJsp()
159:                                        .getRequest()
160:                                        .getSession()
161:                                        .getAttribute(
162:                                                A_CmsOrgUnitUsersList.NOT_ORGUNIT_USERS);
163:                                notOuUsers.remove(user);
164:                                setNotOuUsers(notOuUsers);
165:                            }
166:                        }
167:                    } catch (CmsException e) {
168:                        // noop
169:                    }
170:                } else {
171:                    throwListUnsupportedActionException();
172:                }
173:                listSave();
174:            }
175:
176:            /**
177:             * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
178:             */
179:            public void executeListSingleActions() throws CmsRuntimeException {
180:
181:                if (m_addActionIds.contains(getParamListAction())) {
182:                    CmsListItem listItem = getSelectedItem();
183:                    try {
184:                        CmsUser user = getCms().readUser(
185:                                (String) listItem.get(LIST_COLUMN_LOGIN));
186:                        List ouUsers = (ArrayList) getJsp().getRequest()
187:                                .getSession().getAttribute(
188:                                        A_CmsOrgUnitUsersList.ORGUNIT_USERS);
189:                        if (ouUsers == null) {
190:                            ouUsers = new ArrayList();
191:                        }
192:                        ouUsers.add(user);
193:                        setOuUsers(ouUsers);
194:
195:                        List notOuUsers = (ArrayList) getJsp()
196:                                .getRequest()
197:                                .getSession()
198:                                .getAttribute(
199:                                        A_CmsOrgUnitUsersList.NOT_ORGUNIT_USERS);
200:                        notOuUsers.remove(user);
201:                        setNotOuUsers(notOuUsers);
202:                    } catch (CmsException e) {
203:                        // should never happen
204:                        throw new CmsRuntimeException(Messages.get().container(
205:                                Messages.ERR_ADD_SELECTED_ORGUNITUSER_0), e);
206:                    }
207:                } else {
208:                    throwListUnsupportedActionException();
209:                }
210:                listSave();
211:            }
212:
213:            /**
214:             * @see org.opencms.workplace.tools.accounts.A_CmsOrgUnitUsersList#getUsers()
215:             */
216:            protected List getUsers() throws CmsException {
217:
218:                List notOuUsers = (ArrayList) getJsp().getRequest()
219:                        .getSession().getAttribute(
220:                                A_CmsOrgUnitUsersList.NOT_ORGUNIT_USERS);
221:
222:                if (notOuUsers == null) {
223:                    List orgUnitsUser = OpenCms.getOrgUnitManager().getUsers(
224:                            getCms(), getParamOufqn(), false);
225:                    List notOrgUnitUsers = OpenCms.getRoleManager()
226:                            .getManageableUsers(getCms(), "", true);
227:
228:                    notOrgUnitUsers.removeAll(orgUnitsUser);
229:                    setNotOuUsers(notOrgUnitUsers);
230:                } else {
231:                    setNotOuUsers(notOuUsers);
232:                }
233:
234:                return getNotOuUsers();
235:            }
236:
237:            /**
238:             * @see org.opencms.workplace.tools.accounts.A_CmsOrgUnitUsersList#setDefaultAction(org.opencms.workplace.list.CmsListColumnDefinition)
239:             */
240:            protected void setDefaultAction(CmsListColumnDefinition loginCol) {
241:
242:                // add add action
243:                CmsListDefaultAction addAction = new CmsListDefaultAction(
244:                        LIST_DEFACTION_ADD) {
245:
246:                    /**
247:                     * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getHelpText()
248:                     */
249:                    public CmsMessageContainer getHelpText() {
250:
251:                        if (!isEnabled()) {
252:                            return Messages
253:                                    .get()
254:                                    .container(
255:                                            Messages.GUI_ORGUNITUSERS_LIST_DISABLED_DELETE_HELP_0);
256:                        }
257:                        return super .getHelpText();
258:                    }
259:
260:                    /**
261:                     * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isEnabled()
262:                     */
263:                    public boolean isEnabled() {
264:
265:                        if (getItem() != null) {
266:                            try {
267:                                String userName = getItem().get(
268:                                        LIST_COLUMN_NAME).toString();
269:                                List currentUsers = OpenCms
270:                                        .getOrgUnitManager()
271:                                        .getUsers(
272:                                                getWp().getCms(),
273:                                                ((A_CmsOrgUnitUsersList) getWp())
274:                                                        .getParamOufqn(), false);
275:                                Iterator itCurrentUsers = currentUsers
276:                                        .iterator();
277:                                while (itCurrentUsers.hasNext()) {
278:                                    CmsUser user = (CmsUser) itCurrentUsers
279:                                            .next();
280:                                    if (user.getSimpleName().equals(userName)) {
281:                                        return false;
282:                                    }
283:                                    if (((A_CmsOrgUnitUsersList) getWp())
284:                                            .getCms().getGroupsOfUser(
285:                                                    getItem().get(
286:                                                            LIST_COLUMN_LOGIN)
287:                                                            .toString(), false)
288:                                            .size() > 0) {
289:                                        return false;
290:                                    }
291:                                }
292:                                return true;
293:                            } catch (CmsException e) {
294:                                return super .isVisible();
295:                            }
296:                        }
297:                        return super .isVisible();
298:                    }
299:                };
300:                addAction.setName(Messages.get().container(
301:                        Messages.GUI_ORGUNITUSERS_LIST_DEFACTION_ADD_NAME_0));
302:                addAction.setHelpText(Messages.get().container(
303:                        Messages.GUI_ORGUNITUSERS_LIST_DEFACTION_ADD_HELP_0));
304:                loginCol.addDefaultAction(addAction);
305:                // keep the id
306:                m_addActionIds.add(addAction.getId());
307:            }
308:
309:            /**
310:             * @see org.opencms.workplace.tools.accounts.A_CmsOrgUnitUsersList#setIconAction(org.opencms.workplace.list.CmsListColumnDefinition)
311:             */
312:            protected void setIconAction(CmsListColumnDefinition iconCol) {
313:
314:                CmsListDirectAction iconAction = new CmsListDirectAction(
315:                        LIST_ACTION_ICON) {
316:
317:                    /**
318:                     * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#getIconPath()
319:                     */
320:                    public String getIconPath() {
321:
322:                        return ((A_CmsOrgUnitUsersList) getWp())
323:                                .getIconPath(getItem());
324:                    }
325:                };
326:                iconAction.setName(Messages.get().container(
327:                        Messages.GUI_ORGUNITUSERS_LIST_AVAILABLE_NAME_0));
328:                iconAction.setHelpText(Messages.get().container(
329:                        Messages.GUI_ORGUNITUSERS_LIST_AVAILABLE_HELP_0));
330:                iconAction
331:                        .setIconPath(A_CmsUsersList.PATH_BUTTONS + "user.png");
332:                iconAction.setEnabled(false);
333:                iconCol.addDirectAction(iconAction);
334:            }
335:
336:            /**
337:             * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
338:             */
339:            protected void setMultiActions(CmsListMetadata metadata) {
340:
341:                // add add multi action
342:                CmsListMultiAction addMultiAction = new CmsListMultiAction(
343:                        LIST_MACTION_ADD);
344:                addMultiAction.setName(Messages.get().container(
345:                        Messages.GUI_ORGUNITUSERS_LIST_MACTION_ADD_NAME_0));
346:                addMultiAction.setHelpText(Messages.get().container(
347:                        Messages.GUI_ORGUNITUSERS_LIST_MACTION_ADD_HELP_0));
348:                addMultiAction.setIconPath(ICON_MULTI_ADD);
349:                metadata.addMultiAction(addMultiAction);
350:            }
351:
352:            /**
353:             * @see org.opencms.workplace.tools.accounts.A_CmsOrgUnitUsersList#setStateActionCol(org.opencms.workplace.list.CmsListMetadata)
354:             */
355:            protected void setStateActionCol(CmsListMetadata metadata) {
356:
357:                // create column for state change
358:                CmsListColumnDefinition stateCol = new CmsListColumnDefinition(
359:                        LIST_COLUMN_STATE);
360:                stateCol.setName(Messages.get().container(
361:                        Messages.GUI_ORGUNITUSERS_LIST_COLS_STATE_0));
362:                stateCol.setHelpText(Messages.get().container(
363:                        Messages.GUI_ORGUNITUSERS_LIST_COLS_STATE_HELP_0));
364:                stateCol.setWidth("20");
365:                stateCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
366:                stateCol.setSorteable(false);
367:                // add add action
368:                CmsListDirectAction stateAction = new CmsListDirectAction(
369:                        LIST_ACTION_ADD) {
370:
371:                    /**
372:                     * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getHelpText()
373:                     */
374:                    public CmsMessageContainer getHelpText() {
375:
376:                        if (!isEnabled()) {
377:                            return Messages
378:                                    .get()
379:                                    .container(
380:                                            Messages.GUI_ORGUNITUSERS_LIST_DISABLED_DELETE_HELP_0);
381:                        }
382:                        return super .getHelpText();
383:                    }
384:
385:                    /**
386:                     * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isEnabled()
387:                     */
388:                    public boolean isEnabled() {
389:
390:                        if (getItem() != null) {
391:                            try {
392:                                String userName = getItem().get(
393:                                        LIST_COLUMN_NAME).toString();
394:                                List currentUsers = OpenCms
395:                                        .getOrgUnitManager()
396:                                        .getUsers(
397:                                                getWp().getCms(),
398:                                                ((A_CmsOrgUnitUsersList) getWp())
399:                                                        .getParamOufqn(), false);
400:                                Iterator itCurrentUsers = currentUsers
401:                                        .iterator();
402:                                while (itCurrentUsers.hasNext()) {
403:                                    CmsUser user = (CmsUser) itCurrentUsers
404:                                            .next();
405:                                    if (user.getSimpleName().equals(userName)) {
406:                                        return false;
407:                                    }
408:                                    if (((A_CmsOrgUnitUsersList) getWp())
409:                                            .getCms().getGroupsOfUser(
410:                                                    getItem().get(
411:                                                            LIST_COLUMN_LOGIN)
412:                                                            .toString(), false)
413:                                            .size() > 0) {
414:                                        return false;
415:                                    }
416:                                }
417:                                return true;
418:                            } catch (CmsException e) {
419:                                return super .isVisible();
420:                            }
421:                        }
422:                        return super .isVisible();
423:                    }
424:                };
425:                stateAction.setName(Messages.get().container(
426:                        Messages.GUI_ORGUNITUSERS_LIST_DEFACTION_ADD_NAME_0));
427:                stateAction.setHelpText(Messages.get().container(
428:                        Messages.GUI_ORGUNITUSERS_LIST_DEFACTION_ADD_HELP_0));
429:                stateAction.setIconPath(ICON_ADD);
430:                stateCol.addDirectAction(stateAction);
431:                // add it to the list definition
432:                metadata.addColumn(stateCol);
433:                // keep the id
434:                m_addActionIds.add(stateAction.getId());
435:            }
436:
437:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.