Source Code Cross Referenced for CmsSelectReceiverDialog.java in  » Content-Management-System » opencms » org » opencms » workplace » tools » workplace » broadcast » 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.workplace.broadcast 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/workplace/broadcast/CmsSelectReceiverDialog.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:53 $
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.workplace.broadcast;
033:
034:        import org.opencms.file.CmsUser;
035:        import org.opencms.jsp.CmsJspActionElement;
036:        import org.opencms.main.CmsException;
037:        import org.opencms.main.CmsIllegalStateException;
038:        import org.opencms.main.OpenCms;
039:        import org.opencms.util.CmsStringUtil;
040:        import org.opencms.widgets.CmsGroupWidget;
041:        import org.opencms.workplace.CmsDialog;
042:        import org.opencms.workplace.CmsWidgetDialog;
043:        import org.opencms.workplace.CmsWidgetDialogParameter;
044:        import org.opencms.workplace.CmsWorkplaceSettings;
045:        import org.opencms.workplace.list.CmsHtmlList;
046:        import org.opencms.workplace.tools.CmsToolDialog;
047:        import org.opencms.workplace.tools.CmsToolManager;
048:
049:        import java.util.ArrayList;
050:        import java.util.Collections;
051:        import java.util.HashMap;
052:        import java.util.HashSet;
053:        import java.util.Iterator;
054:        import java.util.List;
055:        import java.util.Map;
056:        import java.util.Set;
057:
058:        import javax.servlet.http.HttpServletRequest;
059:        import javax.servlet.http.HttpServletResponse;
060:        import javax.servlet.jsp.PageContext;
061:
062:        /**
063:         * Dialog to select the receiver of a new message.<p>
064:         * 
065:         * @author Michael Moossen 
066:         * 
067:         * @version $Revision: 1.4 $ 
068:         * 
069:         * @since 6.5.6 
070:         */
071:        public class CmsSelectReceiverDialog extends CmsWidgetDialog {
072:
073:            /** Localized messages Keys prefix. */
074:            public static final String KEY_PREFIX = "select";
075:
076:            /** Defines which pages are valid for this dialog. */
077:            public static final String[] PAGES = { "page1" };
078:
079:            /** Parameter name constant. */
080:            public static final String PARAM_MSGTYPE = "msgtype";
081:
082:            /** Message type value constant. */
083:            public static final String MSGTYPE_EMAIL = "email";
084:
085:            /** Message type value constant. */
086:            public static final String MSGTYPE_POPUP = "popup";
087:
088:            /** The selected groups. */
089:            private List m_groups;
090:
091:            /** The message type parameter value. */
092:            private String m_paramMsgtype;
093:
094:            /**
095:             * Public constructor with JSP action element.<p>
096:             * 
097:             * @param jsp an initialized JSP action element
098:             */
099:            public CmsSelectReceiverDialog(CmsJspActionElement jsp) {
100:
101:                super (jsp);
102:            }
103:
104:            /**
105:             * Public constructor with JSP variables.<p>
106:             * 
107:             * @param context the JSP page context
108:             * @param req the JSP request
109:             * @param res the JSP response
110:             */
111:            public CmsSelectReceiverDialog(PageContext context,
112:                    HttpServletRequest req, HttpServletResponse res) {
113:
114:                this (new CmsJspActionElement(context, req, res));
115:            }
116:
117:            /**
118:             * Commits the edited project to the db.<p>
119:             */
120:            public void actionCommit() {
121:
122:                List errors = new ArrayList();
123:
124:                boolean isEmail = (getParamMsgtype() != null)
125:                        && getParamMsgtype().equals(MSGTYPE_EMAIL);
126:
127:                if ((m_groups == null) || m_groups.isEmpty()) {
128:                    setCommitErrors(Collections
129:                            .singletonList(new CmsIllegalStateException(
130:                                    Messages.get().container(
131:                                            Messages.ERR_NO_SELECTED_GROUP_0))));
132:                    return;
133:                }
134:
135:                boolean hasUser = false;
136:                Iterator itGroups = getGroups().iterator();
137:                while (!hasUser && itGroups.hasNext()) {
138:                    String groupName = (String) itGroups.next();
139:                    try {
140:                        Iterator itUsers = getCms().getUsersOfGroup(groupName,
141:                                true).iterator();
142:                        while (!hasUser && itUsers.hasNext()) {
143:                            CmsUser user = (CmsUser) itUsers.next();
144:                            if (!isEmail) {
145:                                if (!OpenCms.getSessionManager()
146:                                        .getSessionInfos(user.getId())
147:                                        .isEmpty()) {
148:                                    hasUser = true;
149:                                }
150:                            } else {
151:                                if (CmsStringUtil
152:                                        .isNotEmptyOrWhitespaceOnly(user
153:                                                .getEmail())) {
154:                                    hasUser = true;
155:                                }
156:                            }
157:                        }
158:                    } catch (CmsException e) {
159:                        // should never happen
160:                    }
161:                }
162:
163:                if (!hasUser) {
164:                    setCommitErrors(Collections
165:                            .singletonList(new CmsIllegalStateException(
166:                                    Messages
167:                                            .get()
168:                                            .container(
169:                                                    Messages.ERR_NO_SELECTED_RECEIVERS_0))));
170:                    return;
171:                }
172:
173:                try {
174:                    Set groups = new HashSet(m_groups);
175:                    Map params = new HashMap();
176:                    params.put(CmsToolDialog.PARAM_STYLE,
177:                            CmsToolDialog.STYLE_NEW);
178:                    params.put(CmsSendEmailGroupsDialog.PARAM_GROUPS,
179:                            CmsStringUtil.collectionAsString(groups,
180:                                    CmsHtmlList.ITEM_SEPARATOR));
181:                    params.put(CmsDialog.PARAM_CLOSELINK, CmsToolManager
182:                            .linkForToolPath(getJsp(), "/workplace/broadcast"));
183:
184:                    if (isEmail) {
185:                        getToolManager()
186:                                .jspForwardPage(
187:                                        this ,
188:                                        "/system/workplace/admin/workplace/groups_send_email.jsp",
189:                                        params);
190:                    } else {
191:                        getToolManager()
192:                                .jspForwardPage(
193:                                        this ,
194:                                        "/system/workplace/admin/workplace/groups_send_popup.jsp",
195:                                        params);
196:                    }
197:                } catch (Throwable t) {
198:                    errors.add(t);
199:                }
200:                // set the list of errors to display when saving failed
201:                setCommitErrors(errors);
202:            }
203:
204:            /**
205:             * Returns the selected groups.<p>
206:             *
207:             * @return the selected groups
208:             */
209:            public List getGroups() {
210:
211:                return m_groups;
212:            }
213:
214:            /**
215:             * Returns the message type parameter value.<p>
216:             *
217:             * @return the message type parameter value
218:             */
219:            public String getParamMsgtype() {
220:
221:                return m_paramMsgtype;
222:            }
223:
224:            /**
225:             * Sets the selected groups.<p>
226:             *
227:             * @param groups the selected groups to set
228:             */
229:            public void setGroups(List groups) {
230:
231:                m_groups = groups;
232:            }
233:
234:            /**
235:             * Sets the message type parameter value.<p>
236:             *
237:             * @param paramMsgtype the message type to set
238:             */
239:            public void setParamMsgtype(String paramMsgtype) {
240:
241:                m_paramMsgtype = paramMsgtype;
242:            }
243:
244:            /**
245:             * @see org.opencms.workplace.CmsWidgetDialog#createDialogHtml(java.lang.String)
246:             */
247:            protected String createDialogHtml(String dialog) {
248:
249:                StringBuffer result = new StringBuffer(1024);
250:
251:                result.append(createWidgetTableStart());
252:                // show error header once if there were validation errors
253:                result.append(createWidgetErrorHeader());
254:
255:                if (dialog.equals(PAGES[0])) {
256:                    // create the widgets for the first dialog page
257:                    result
258:                            .append(dialogBlockStart(key(Messages.GUI_SELECT_EDITOR_LABEL_BLOCK_0)));
259:                    result.append(createWidgetTableStart());
260:                    result.append(createDialogRowsHtml(0, 0));
261:                    result.append(createWidgetTableEnd());
262:                    result.append(dialogBlockEnd());
263:                }
264:
265:                result.append(createWidgetTableEnd());
266:                return result.toString();
267:            }
268:
269:            /**
270:             * Creates the list of widgets for this dialog.<p>
271:             */
272:            protected void defineWidgets() {
273:
274:                // initialize the project object to use for the dialog
275:                initMessageObject();
276:
277:                setKeyPrefix(KEY_PREFIX);
278:
279:                addWidget(new CmsWidgetDialogParameter(this , "groups", "",
280:                        PAGES[0], new CmsGroupWidget(), 0, 10));
281:            }
282:
283:            /**
284:             * @see org.opencms.workplace.CmsWidgetDialog#getPageArray()
285:             */
286:            protected String[] getPageArray() {
287:
288:                return PAGES;
289:            }
290:
291:            /**
292:             * Initializes the message info object to work with depending on the dialog state and request parameters.<p>
293:             */
294:            protected void initMessageObject() {
295:
296:                try {
297:                    if (CmsStringUtil.isEmpty(getParamAction())
298:                            || CmsDialog.DIALOG_INITIAL
299:                                    .equals(getParamAction())) {
300:                        // create a new list
301:                        m_groups = new ArrayList();
302:                    } else {
303:                        // this is not the initial call, get the message info object from session  
304:                        m_groups = (List) getDialogObject();
305:                    }
306:                } catch (Exception e) {
307:                    // create a new list
308:                    m_groups = new ArrayList();
309:                }
310:            }
311:
312:            /**
313:             * @see org.opencms.workplace.CmsWorkplace#initMessages()
314:             */
315:            protected void initMessages() {
316:
317:                // add specific dialog resource bundle
318:                addMessages(Messages.get().getBundleName());
319:                addMessages(org.opencms.workplace.tools.workplace.Messages
320:                        .get().getBundleName());
321:                // add default resource bundles
322:                super .initMessages();
323:            }
324:
325:            /**
326:             * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
327:             */
328:            protected void initWorkplaceRequestValues(
329:                    CmsWorkplaceSettings settings, HttpServletRequest request) {
330:
331:                // initialize parameters and dialog actions in super implementation
332:                super .initWorkplaceRequestValues(settings, request);
333:
334:                // save the current state of the message (may be changed because of the widget values)
335:                setDialogObject(m_groups);
336:            }
337:
338:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.