Source Code Cross Referenced for ChannelContainerBaseBean.java in  » Portal » Open-Portal » com » sun » portal » admin » console » desktop » 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 » Portal » Open Portal » com.sun.portal.admin.console.desktop 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: ChannelContainerBaseBean.java,v 1.15 2005/10/21 01:29:26 cathywu Exp $
003:         * Copyright 2005 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.admin.console.desktop;
014:
015:        import java.util.Map;
016:        import java.util.LinkedList;
017:        import java.util.logging.Level;
018:
019:        import java.text.MessageFormat;
020:
021:        import javax.management.MBeanServerConnection;
022:        import javax.management.ObjectName;
023:        import javax.management.InstanceNotFoundException;
024:        import javax.management.MBeanException;
025:        import javax.management.ReflectionException;
026:
027:        import javax.faces.validator.ValidatorException;
028:        import javax.faces.component.UIComponent;
029:        import javax.faces.application.FacesMessage;
030:        import javax.faces.context.FacesContext;
031:        import javax.faces.el.VariableResolver;
032:
033:        import com.sun.web.ui.model.Option;
034:
035:        import com.sun.portal.admin.common.util.AdminClientUtil;
036:        import com.sun.portal.admin.common.PSMBeanException;
037:
038:        import com.sun.portal.admin.console.common.PSBaseBean;
039:        import com.sun.portal.admin.console.fabric.ListPortalsBean;
040:
041:        /**
042:         * @author cathywu
043:         */
044:        public class ChannelContainerBaseBean extends PSBaseBean {
045:            public static final String RB_NAME = "desktop";
046:            public static final int CREATE_CHANNEL = 1;
047:            public static final int DELETE_CHANNEL = 2;
048:            public static final int CREATE_CONTAINER = 3;
049:            public static final int DELETE_CONTAINER = 4;
050:            public static final String CHANNEL = "Channel";
051:            public static final String CONTAINER = "Container";
052:
053:            protected Map rbMap;
054:            protected String cancelText = "Cancel";
055:            //protected Boolean disableDelete;
056:
057:            //alert member variables
058:            protected Boolean displayError;
059:            protected String alertSummary;
060:            protected String alertDetail;
061:            protected String alertType;
062:            protected String logMessage;
063:
064:            //Member variables for JMX connection
065:            protected MBeanServerConnection mbsc;
066:            protected String portalId;
067:            protected String dn;
068:            protected String treeContainer = null;
069:
070:            //flag to regenerate channel/container list to be deleted
071:            protected Boolean regenerate = null;
072:            protected Boolean disableCreate;
073:            protected String channelOrContainer;
074:
075:            protected Option[] channelContainerSelections = {
076:                    new Option(CHANNEL, "Channel"),
077:                    new Option(CONTAINER, "Container") };
078:
079:            public ChannelContainerBaseBean() {
080:                //setup initial screen
081:                rbMap = getResourceStringMap(RB_NAME);
082:                if (rbMap != null) {
083:                    cancelText = (String) rbMap.get("cancel.button");
084:
085:                    //initialize channel or container selections
086:                    channelContainerSelections[0].setLabel((String) rbMap
087:                            .get("createChannel.channelorContainer.channel"));
088:                    channelContainerSelections[0].setValue(CHANNEL);
089:                    channelContainerSelections[1].setLabel((String) rbMap
090:                            .get("createChannel.channelorContainer.container"));
091:                    channelContainerSelections[1].setValue(CONTAINER);
092:                }
093:
094:                //setup jmx connection, portal Id, and dn
095:                mbsc = getMBeanServerConnection();
096:                portalId = (String) getSessionAttribute(ATTR_SELECTED_PORTAL);
097:                dn = (String) getCurrentDN();
098:
099:                if (portalId == null) {
100:                    FacesContext context = FacesContext.getCurrentInstance();
101:                    VariableResolver vr = context.getApplication()
102:                            .getVariableResolver();
103:                    Object obj = (Object) vr.resolveVariable(context,
104:                            "ListPortalsBean");
105:                    if ((obj != null) && (obj instanceof  ListPortalsBean)) {
106:                        ListPortalsBean epropsbean = (ListPortalsBean) obj;
107:                        portalId = epropsbean.getCurrentPortal();
108:                        setSessionAttribute(ATTR_SELECTED_PORTAL, portalId);
109:                    }
110:                }
111:
112:                if (dn == null) {
113:                    dn = GLOBAL_LOCATION_DN;
114:                }
115:
116:                log(Level.FINEST, "ChannelContainerBean(), current dn: " + dn);
117:                log(Level.FINEST, "ChannelContainerBean(), portal: " + portalId);
118:
119:                displayError = Boolean.FALSE;
120:            }
121:
122:            public void setChannelOrContainer(String value) {
123:                channelOrContainer = value;
124:            }
125:
126:            public String getChannelOrContainer() {
127:                return channelOrContainer;
128:            }
129:
130:            /**
131:             * Channel or Container 
132:             */
133:            public Object[] getChannelContainerSelections() {
134:                if (getDisplayError() == Boolean.TRUE) {
135:                    setDisplayError(Boolean.FALSE);
136:                }
137:                return (Object[]) channelContainerSelections;
138:            }
139:
140:            /**
141:             * validator for channel and container name
142:             */
143:            public void validateChannelName(FacesContext ctx, UIComponent comp,
144:                    Object value) {
145:
146:                String sm = (String) rbMap.get("error.validation.summary");
147:                String dm = (String) rbMap.get("error.letterordigit");
148:                String cn = (String) value;
149:                for (int i = 0; i < cn.length(); i++) {
150:                    char c = cn.charAt(i);
151:                    if (!Character.isLetterOrDigit(c) && (c != '_')) {
152:                        throw new ValidatorException(new FacesMessage(sm, dm));
153:                    }
154:                }
155:            }
156:
157:            /**
158:             * Regenerate flag
159:             */
160:            public void setRegenerate(boolean val) {
161:                regenerate = new Boolean(val);
162:                setSessionAttribute(ATTR_REGENERATE_CHANNELS, regenerate);
163:            }
164:
165:            public boolean getRegenerate() {
166:                regenerate = (Boolean) getSessionAttribute(ATTR_REGENERATE_CHANNELS);
167:                if (regenerate != null) {
168:                    return regenerate.booleanValue();
169:                } else {
170:                    return false;
171:                }
172:
173:            }
174:
175:            /**
176:             * This method figures out which container is being selected in
177:             * the tree view. If the selected item is not a container, set
178:             * treeContainer to null.
179:             */
180:            public void setupTreeContainer() {
181:                // Get EditPropertiesBean
182:                FacesContext fc = FacesContext.getCurrentInstance();
183:                VariableResolver vr = fc.getApplication().getVariableResolver();
184:                Object obj = (EditPropertiesBean) vr.resolveVariable(fc,
185:                        "EditPropertiesBean");
186:                EditPropertiesBean epb = null;
187:                if (obj == null) {
188:                    setupAlert(null, "error.createChannel.summary",
189:                            "error.createChannel.failed.checkLogs.noToken",
190:                            "error", null, null);
191:                    return;
192:                } else if ((obj instanceof  EditPropertiesBean)) {
193:                    epb = (EditPropertiesBean) obj;
194:                }
195:                // Get Current selected container name, if the
196:                // selected node is a container, set the value, else
197:                // set value null.
198:                log(Level.INFO,
199:                        "CreateChannelBean.setupTreeContainer(), isContainer: "
200:                                + epb.isContainer() + " channel name: "
201:                                + epb.getChannelName());
202:
203:                treeContainer = (epb.isContainer() == true) ? epb
204:                        .getChannelName() : null;
205:
206:            }
207:
208:            public String getTreeContainer() {
209:                setupTreeContainer();
210:
211:                if ((treeContainer != null && treeContainer.equals("_root"))) {
212:                    treeContainer = null;
213:                }
214:
215:                return treeContainer;
216:            }
217:
218:            public void setTreeContainer(String val) {
219:                treeContainer = val;
220:            }
221:
222:            /**
223:             * Cancel operation
224:             */
225:            public String getCancelText() {
226:                return cancelText;
227:            }
228:
229:            public void setCancelText(String val) {
230:                cancelText = val;
231:            }
232:
233:            public String cancel() {
234:                setCancelText((String) rbMap.get("cancel.button"));
235:                return "goDesktopManager";
236:            }
237:
238:            /**
239:             * disable delete
240:             */
241:            public boolean isDisableCreate() {
242:                if (disableCreate == null) {
243:                    disableCreate = new Boolean(false);
244:                }
245:                return disableCreate.booleanValue();
246:            }
247:
248:            public void setDisableCreate(boolean val) {
249:                disableCreate = new Boolean(val);
250:            }
251:
252:            /**
253:             * Alert methods
254:             */
255:            public Boolean getDisplayError() {
256:                return displayError;
257:            }
258:
259:            public void setDisplayError(Boolean value) {
260:                displayError = value;
261:            }
262:
263:            public String getAlertSummary() {
264:                return alertSummary;
265:            }
266:
267:            public void setAlertSummary(String summary) {
268:                alertSummary = summary;
269:            }
270:
271:            public String getAlertDetail() {
272:                return alertDetail;
273:            }
274:
275:            public void setAlertDetail(String detail) {
276:                alertDetail = detail;
277:            }
278:
279:            public String getAlertType() {
280:                return alertType;
281:            }
282:
283:            public void setAlertType(String type) {
284:                alertType = type;
285:            }
286:
287:            public String getLogMessage() {
288:                return logMessage;
289:            }
290:
291:            public void setLogMessage(String val) {
292:                logMessage = val;
293:            }
294:
295:            protected String composeLogMessage(Exception e) {
296:                StringBuffer msg = new StringBuffer();
297:                msg.append(e.getMessage());
298:                msg.append('\n');
299:                msg.append(getStackTrace(e));
300:                return msg.toString();
301:            }
302:
303:            /**
304:             * Alert Utility methods
305:             */
306:
307:            public void setupAlert(Object[] tokens, String summary,
308:                    String detail, String type, String defaultKey,
309:                    String message) {
310:
311:                String sm = (String) rbMap.get(summary);
312:                String dm = (String) rbMap.get(detail);
313:
314:                //if it was not possible to localize the message from the 
315:                //mbean then show a generic message
316:                if (dm == null || dm.startsWith("???")) {
317:                    dm = (String) rbMap.get(defaultKey);
318:                }
319:
320:                if (tokens != null) {
321:                    String pattern = dm;
322:                    MessageFormat mf = new MessageFormat(pattern);
323:                    dm = mf.format(tokens);
324:                }
325:
326:                if (message != null) {
327:                    dm = dm + " "
328:                            + (String) rbMap.get("general.error.viewSource");
329:                    setLogMessage(message);
330:                } else {
331:                    setLogMessage("");
332:                }
333:
334:                setDisplayError(Boolean.TRUE);
335:                setAlertSummary(sm);
336:                setAlertDetail(dm);
337:                setAlertType(type);
338:            }
339:
340:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.