Source Code Cross Referenced for AddChannelBean.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: AddChannelBean.java,v 1.8 2005/11/09 23:27:45 rt94277 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.Set;
016:        import java.util.List;
017:        import java.util.ArrayList;
018:        import java.util.Iterator;
019:        import java.util.logging.Level;
020:
021:        import java.net.URLDecoder;
022:        import java.io.UnsupportedEncodingException;
023:
024:        import javax.management.ObjectName;
025:        import javax.management.MBeanServerConnection;
026:
027:        import javax.faces.context.FacesContext;
028:        import javax.faces.el.VariableResolver;
029:
030:        import javax.servlet.http.HttpServletRequest;
031:
032:        import com.sun.web.ui.model.Option;
033:
034:        import com.sun.portal.admin.common.util.AdminClientUtil;
035:        import com.sun.portal.admin.common.PSMBeanException;
036:        import com.sun.portal.admin.console.common.PortalBaseBean;
037:
038:        public class AddChannelBean extends PortalBaseBean {
039:
040:            public static final String VISIBLE = "Visible";
041:            public static final String AVAILABLE = "Available";
042:
043:            private String state = VISIBLE;
044:            private String addActionStatus = "";
045:            private String currentContainer = null;
046:            private Option[] stateOptions = null;
047:            private Option[] existingChannels = null;
048:            private String[] selectedChannels = null;
049:
050:            public AddChannelBean() {
051:                Option visible = new Option(VISIBLE,
052:                        getI18NString("label.visible"));
053:                Option available = new Option(AVAILABLE,
054:                        getI18NString("label.available"));
055:                stateOptions = new Option[] { visible, available };
056:
057:                FacesContext context = FacesContext.getCurrentInstance();
058:
059:                // Try to get the currentContainer from the request param      
060:                HttpServletRequest req = (HttpServletRequest) context
061:                        .getExternalContext().getRequest();
062:                currentContainer = (String) req
063:                        .getParameter(ATTR_SELECTED_CHANNEL_NAME);
064:                if (currentContainer != null) {
065:                    try {
066:                        currentContainer = URLDecoder.decode(currentContainer,
067:                                DEFAULT_CHARSET);
068:                    } catch (UnsupportedEncodingException uee) {
069:                    }
070:                }
071:
072:                // If its not available in the param then try to get it from the 
073:                // EditProperties bean
074:                if (currentContainer == null) {
075:                    VariableResolver vr = context.getApplication()
076:                            .getVariableResolver();
077:                    Object obj = (Object) vr.resolveVariable(context,
078:                            "EditPropertiesBean");
079:                    if ((obj != null) && (obj instanceof  EditPropertiesBean)) {
080:                        EditPropertiesBean epropsbean = (EditPropertiesBean) obj;
081:                        currentContainer = epropsbean.getChannelName();
082:                    }
083:                }
084:                log(Level.FINEST, "Current Container : " + currentContainer);
085:            }
086:
087:            public String getContainer() {
088:                return currentContainer;
089:            }
090:
091:            public void setContainer(String val) {
092:                currentContainer = val;
093:            }
094:
095:            public Option[] getStateOptions() {
096:                return stateOptions;
097:            }
098:
099:            public String getState() {
100:                return state;
101:            }
102:
103:            public void setState(String state) {
104:                this .state = state;
105:            }
106:
107:            public Option[] getExistingChannels() {
108:
109:                Set assignable = null;
110:                List available = null;
111:                List selected = null;
112:                Option[] channels = null;
113:
114:                // Setting the params and signature
115:                String[] signature = { "java.lang.String", "java.lang.String" };
116:                Object[] params = { getCurrentDN(), getContainer() };
117:
118:                try {
119:
120:                    log(Level.FINEST,
121:                            "Invoking get method on Display Profile MBean");
122:
123:                    // Get the Display Profile MBean Object Name
124:                    ObjectName objName = AdminClientUtil
125:                            .getDisplayProfileMBeanObjectName(
126:                                    AdminClientUtil.DEFAULT_DOMAIN,
127:                                    getPortalId());
128:                    // Invoke the get method on the portal Desktop MBean
129:                    MBeanServerConnection msc = getMBeanServerConnection();
130:                    assignable = (Set) msc.invoke(objName,
131:                            "getAssignableChannels", params, signature);
132:                    available = (List) msc.invoke(objName,
133:                            "getAvailableChannels", params, signature);
134:                    selected = (List) msc.invoke(objName,
135:                            "getSelectedChannels", params, signature);
136:
137:                } catch (Exception e) {
138:                    log(
139:                            Level.SEVERE,
140:                            "AddChannelBean.getExistingChannels(): Error Fetching Data",
141:                            e);
142:                    setAlertType("error");
143:                    setAlertSummary(getI18NString("message.fetch.failed.summary"));
144:                    showAlert();
145:                }
146:
147:                if (assignable != null) {
148:                    log(Level.FINEST, "Assignable Set: " + assignable);
149:                    log(Level.FINEST, "Available Set: " + available);
150:                    log(Level.FINEST, "Selected Set: " + selected);
151:
152:                    // Remove all available channels from list
153:                    log(Level.FINEST, "Original Assignable Set Size: "
154:                            + assignable.size());
155:                    if (available != null) {
156:                        assignable.removeAll(available);
157:                    }
158:                    log(Level.FINEST, "Assignable - Available Size: "
159:                            + assignable.size());
160:                    // Remove all selected channels from list
161:                    if (selected != null) {
162:                        assignable.removeAll(selected);
163:                    }
164:                    log(Level.FINEST,
165:                            "Assignable - Available - Selected Size: "
166:                                    + assignable.size());
167:                    channels = new Option[assignable.size()];
168:                    Iterator itr = assignable.iterator();
169:                    int ctr = 0;
170:                    while (itr.hasNext()) {
171:                        String channelName = (String) itr.next();
172:                        channels[ctr] = new Option(channelName, channelName);
173:                        ctr++;
174:                    }
175:                }
176:
177:                return channels;
178:            }
179:
180:            public String[] getSelectedChannels() {
181:                // Display an unselected list of channels
182:                return null;
183:            }
184:
185:            public void setSelectedChannels(String[] channels) {
186:                selectedChannels = channels;
187:            }
188:
189:            public String getActionStatus() {
190:                return addActionStatus;
191:            }
192:
193:            public void setActionStatus(String status) {
194:                addActionStatus = status;
195:            }
196:
197:            // TODO - This method should display errors and alerts.
198:            public void add() {
199:
200:                if (selectedChannels == null || selectedChannels.length < 1) {
201:                    log(Level.FINEST, "No Channels were selected");
202:                    return;
203:                }
204:
205:                try {
206:
207:                    log(Level.FINEST,
208:                            "Invoking get method on Display Profile MBean");
209:
210:                    // Get the Display Profile MBean Object Name
211:                    ObjectName objName = AdminClientUtil
212:                            .getDisplayProfileMBeanObjectName(
213:                                    AdminClientUtil.DEFAULT_DOMAIN,
214:                                    getPortalId());
215:                    // Setting the params and signature
216:                    String[] signature = { "java.lang.String",
217:                            "java.lang.String" };
218:                    Object[] params = { getCurrentDN(), getContainer() };
219:
220:                    // Invoke the get method on the portal Desktop MBean
221:                    MBeanServerConnection msc = getMBeanServerConnection();
222:
223:                    log(Level.FINEST, "Fetching Available Channel List");
224:                    List availableList = (List) msc.invoke(objName,
225:                            "getAvailableChannels", params, signature);
226:                    log(Level.FINEST, "Available Channel List: "
227:                            + availableList);
228:                    // If the list returned is null or empty create a new list
229:                    if (availableList.isEmpty()) {
230:                        availableList = new ArrayList();
231:                    }
232:                    // Add the channels opted by the user to the available list
233:                    for (int i = 0; i < selectedChannels.length; i++) {
234:                        availableList.add(selectedChannels[i]);
235:                    }
236:
237:                    log(Level.FINEST, "Setting Available Channel List: "
238:                            + availableList);
239:                    String[] sig = { "java.lang.String", "java.util.List",
240:                            "java.lang.String" };
241:                    Object[] prms = { getCurrentDN(), availableList,
242:                            getContainer() };
243:                    msc.invoke(objName, "setAvailableChannels", prms, sig);
244:
245:                    if (state.equals(VISIBLE)) {
246:                        log(Level.FINEST, "Fetching Selected Channel List");
247:                        List selectedList = (List) msc.invoke(objName,
248:                                "getSelectedChannels", params, signature);
249:                        log(Level.FINEST, "Selected Channel List: "
250:                                + selectedList);
251:                        // If the list returned is null or empty create a new list
252:                        if (selectedList.isEmpty()) {
253:                            selectedList = new ArrayList();
254:                        }
255:                        // Add the channels opted by the user to the selected list
256:                        for (int i = 0; i < selectedChannels.length; i++) {
257:                            selectedList.add(selectedChannels[i]);
258:                        }
259:
260:                        log(Level.FINEST, "Setting Selected Channel List: "
261:                                + selectedList);
262:                        prms[1] = selectedList;
263:                        msc.invoke(objName, "setSelectedChannels", prms, sig);
264:
265:                    }
266:                    // Set the action status hidden field to "complete" this will ensure
267:                    // that the refresh tree is done by the javascript method after
268:                    // a successful add operation
269:                    setActionStatus("complete");
270:                } catch (Exception e) {
271:                    log(
272:                            Level.SEVERE,
273:                            "AddChannelBean.add(): Error adding channel to container",
274:                            e);
275:                    setAlertType("error");
276:                    setAlertSummary(getI18NString("message.addchannel.failed.summary"));
277:                    showAlert();
278:                }
279:
280:            }
281:
282:            public String cancel() {
283:                return "goDesktopManager";
284:            }
285:
286:            /**
287:             * Gets a localized string from the resoucebundle
288:             * @param key A key string
289:             * @return  A localized String for the key
290:             */
291:            private String getI18NString(String key) {
292:                return getLocalizedString("desktop", key);
293:            }
294:
295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.