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


001:        /**
002:         * Copyright 2002 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         *
013:         * Author: Anurag Gupta
014:         */package com.sun.portal.netfile.admin;
015:
016:        // JDK classes
017:        import java.io.IOException;
018:        import com.sun.portal.log.common.PortalLogger;
019:        import java.net.URLEncoder;
020:        import java.util.HashMap;
021:        import java.util.HashSet;
022:        import java.util.Iterator;
023:        import java.util.Map;
024:        import java.util.NoSuchElementException;
025:        import java.util.Set;
026:        import java.util.StringTokenizer;
027:        import java.util.Vector;
028:        import java.security.AccessController;
029:
030:        import com.sun.identity.security.EncryptAction;
031:
032:        // Servlet classes
033:        import javax.servlet.http.HttpServletRequest;
034:        import javax.servlet.http.HttpServletResponse;
035:
036:        // iPlanet JATO classes
037:        import com.iplanet.jato.model.ModelControlException;
038:        import com.iplanet.jato.view.View;
039:        import com.iplanet.jato.view.event.DisplayEvent;
040:        import com.iplanet.jato.view.event.RequestInvocationEvent;
041:        import com.iplanet.jato.view.html.ComboBox;
042:        import com.iplanet.jato.view.html.HiddenField;
043:        import com.iplanet.jato.view.html.HREF;
044:        import com.iplanet.jato.view.html.ListBox;
045:        import com.iplanet.jato.view.html.OptionList;
046:        import com.iplanet.jato.view.html.StaticTextField;
047:        import com.iplanet.jato.view.html.TextField;
048:
049:        // iDS/AME classes
050:        import com.iplanet.am.console.base.AMViewBeanBase;
051:        import com.iplanet.am.console.components.view.html.IPlanetButton;
052:        import com.iplanet.am.console.components.view.html.MessageBox;
053:
054:        // NetFile admin console classes
055:        import com.sun.portal.netfile.admin.model.NetFileModel;
056:        import com.sun.portal.netfile.admin.model.NetFileModelImpl;
057:
058:        public class NetFileHostsViewBean extends AMViewBeanBase implements 
059:                NetFileAdminService, NetFileHostConstants,
060:                NetFileHostTypeConstants, NetFileEncodingTypeConstants {
061:            public static final String PAGE_NAME = "NetFileHosts";
062:            public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileHosts.jsp";
063:
064:            public static final String ATTR_OSCHARSET = "sunPortalNetFileOSCharSet";
065:
066:            private NetFileAdminModelManager modelManager = null;
067:            private NetFileModel model = null;
068:
069:            private Vector netFileHosts = null;
070:            private int currentRow = -1;
071:
072:            /**
073:             * Default Constructor
074:             */
075:            public NetFileHostsViewBean() {
076:                super (PAGE_NAME);
077:                setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
078:                registerChildren();
079:            }
080:
081:            public NetFileHostsViewBean(String pageName) {
082:                super (pageName);
083:                registerChildren();
084:            }
085:
086:            /**
087:             * Creates the child view objects for this viewbean.
088:             * @param name the name of the child view object to be created.
089:             * @return the child view object.
090:             */
091:            protected View createChild(String name) {
092:                getModelMgr();
093:                if (name.equals(PAGE_TITLE)) {
094:                    return new StaticTextField(this , PAGE_TITLE, modelManager
095:                            .getString("HTMLPage.title"));
096:                } else if (name.equals(PAGE_DESC)) {
097:                    return new StaticTextField(this , PAGE_DESC, "");
098:                } else if (name.equals(PAGE_DESC_HREF)) {
099:                    return new HREF(this , PAGE_DESC_HREF, "");
100:                } else if (name.equals(PAGE_DESC_ACTION)) {
101:                    return new StaticTextField(this , PAGE_DESC_ACTION,
102:                            modelManager.getString("edithost.pagetitle"));
103:                } else if (name.equals(CHILD_CC_MSGBOX)) {
104:                    return new MessageBox(this , CHILD_CC_MSGBOX, "");
105:                } else if (name.equals(CHILD_HOSTNAME_LBL)) {
106:                    return new StaticTextField(this , CHILD_HOSTNAME_LBL,
107:                            modelManager.getString("hostname.label"));
108:                } else if (name.equals(CHILD_HOSTNAME)) {
109:                    return new TextField(this , CHILD_HOSTNAME, "");
110:                } else if (name.equals(CHILD_HOSTTYPE_LBL)) {
111:                    return new StaticTextField(this , CHILD_HOSTTYPE_LBL,
112:                            modelManager.getString("hosttype.label"));
113:                } else if (name.equals(CHILD_HOSTTYPE)) {
114:                    return new ComboBox(this , CHILD_HOSTTYPE, "");
115:                } else if (name.equals(CHILD_HOSTENCODING_LBL)) {
116:                    return new StaticTextField(this , CHILD_HOSTENCODING_LBL,
117:                            modelManager.getString("hostencoding.label"));
118:                } else if (name.equals(CHILD_HOSTENCODING)) {
119:                    return new ComboBox(this , CHILD_HOSTENCODING, "");
120:                } else if (name.equals(CHILD_HOSTDOMAIN_LBL)) {
121:                    return new StaticTextField(this , CHILD_HOSTDOMAIN_LBL,
122:                            modelManager.getString("hostdomain.label"));
123:                } else if (name.equals(CHILD_HOSTDOMAIN)) {
124:                    return new TextField(this , CHILD_HOSTDOMAIN, "");
125:                } else if (name.equals(CHILD_HOSTUSERNAME_LBL)) {
126:                    return new StaticTextField(this , CHILD_HOSTUSERNAME_LBL,
127:                            modelManager.getString("hostusername.label"));
128:                } else if (name.equals(CHILD_HOSTUSERNAME)) {
129:                    return new TextField(this , CHILD_HOSTUSERNAME, "");
130:                } else if (name.equals(CHILD_HOSTPASSWORD_LBL)) {
131:                    return new StaticTextField(this , CHILD_HOSTPASSWORD_LBL,
132:                            modelManager.getString("hostpassword.label"));
133:                } else if (name.equals(CHILD_HOSTPASSWORD)) {
134:                    return new TextField(this , CHILD_HOSTPASSWORD, "");
135:                } else if (name.equals(CHILD_HOSTSHARELIST_LBL)) {
136:                    return new StaticTextField(this , CHILD_HOSTSHARELIST_LBL,
137:                            modelManager.getString("hostsharelist.label"));
138:                } else if (name.equals(CHILD_HOSTSHARELIST)) {
139:                    return new ListBox(this , CHILD_HOSTSHARELIST, "");
140:                } else if (name.equals(CHILD_HOSTSHARENAME_LBL)) {
141:                    return new StaticTextField(this , CHILD_HOSTSHARENAME_LBL,
142:                            modelManager.getString("hostsharename.label"));
143:                } else if (name.equals(CHILD_HOSTSHARENAME)) {
144:                    return new TextField(this , CHILD_HOSTSHARENAME, "");
145:                } else if (name.equals(CHILD_HOSTSHAREPASSWORD_LBL)) {
146:                    return new StaticTextField(this ,
147:                            CHILD_HOSTSHAREPASSWORD_LBL, modelManager
148:                                    .getString("hostsharepassword.label"));
149:                } else if (name.equals(CHILD_HOSTSHAREPASSWORD)) {
150:                    return new TextField(this , CHILD_HOSTSHAREPASSWORD, "");
151:
152:                    /*
153:                     } else if ( name.equals(CHILD_HOSTSHAREUSER_LBL) ) {
154:                     return new StaticTextField(this, CHILD_HOSTSHAREUSER_LBL, modelManager.getString("hostshareuser.label"));
155:                     } else if ( name.equals(CHILD_HOSTSHAREUSER) ) {
156:                     return new TextField(this, CHILD_HOSTSHAREUSER, "");
157:                     } else if ( name.equals(CHILD_HOSTSHAREPASS_LBL) ) {
158:                     return new StaticTextField(this, CHILD_HOSTSHAREPASS_LBL, modelManager.getString("hostsharepass.label"));
159:                     } else if ( name.equals(CHILD_HOSTSHAREPASS) ) {
160:                     return new TextField(this, CHILD_HOSTSHAREPASS, "");
161:                     */
162:                } else if (name.equals(CHILD_HOST_INDEX)) {
163:                    return new HiddenField(this , CHILD_HOST_INDEX, "");
164:                } else if (name.equals(CHILD_SAVE_BTN)) {
165:                    return new IPlanetButton(this , CHILD_SAVE_BTN, modelManager
166:                            .getString("ok.button"));
167:                } else if (name.equals(CHILD_CANCEL_BTN)) {
168:                    return new IPlanetButton(this , CHILD_CANCEL_BTN,
169:                            modelManager.getString("cancel.button"));
170:                } else if (name.equals(CHILD_REMOVE_BTN)) {
171:                    return new StaticTextField(this , CHILD_REMOVE_BTN,
172:                            modelManager.getString("remove.button"));
173:                } else if (name.equals(CHILD_ADDTOLIST_BTN)) {
174:                    return new StaticTextField(this , CHILD_ADDTOLIST_BTN,
175:                            modelManager.getString("addtolist.button"));
176:                } else if (name.equals(CHILD_ERRORMSGS)) {
177:                    return new StaticTextField(this , CHILD_ERRORMSGS, "");
178:                } else {
179:                    return super .createChild(name);
180:                }
181:            }
182:
183:            /**
184:             * To register all the child view objects and their classes.
185:             */
186:            protected void registerChildren() {
187:                registerChild(PAGE_TITLE, StaticTextField.class);
188:                registerChild(PAGE_DESC, StaticTextField.class);
189:                registerChild(PAGE_DESC_HREF, HREF.class);
190:                registerChild(PAGE_DESC_ACTION, StaticTextField.class);
191:                registerChild(CHILD_CC_MSGBOX, MessageBox.class);
192:                registerChild(CHILD_HOSTNAME_LBL, StaticTextField.class);
193:                registerChild(CHILD_HOSTNAME, TextField.class);
194:                registerChild(CHILD_HOSTTYPE_LBL, StaticTextField.class);
195:                registerChild(CHILD_HOSTTYPE, ComboBox.class);
196:                registerChild(CHILD_HOSTENCODING_LBL, StaticTextField.class);
197:                registerChild(CHILD_HOSTENCODING, ComboBox.class);
198:                registerChild(CHILD_HOSTDOMAIN_LBL, StaticTextField.class);
199:                registerChild(CHILD_HOSTDOMAIN, TextField.class);
200:                registerChild(CHILD_HOSTUSERNAME_LBL, StaticTextField.class);
201:                registerChild(CHILD_HOSTUSERNAME, TextField.class);
202:                registerChild(CHILD_HOSTPASSWORD_LBL, StaticTextField.class);
203:                registerChild(CHILD_HOSTPASSWORD, TextField.class);
204:                registerChild(CHILD_HOSTSHARELIST_LBL, StaticTextField.class);
205:                registerChild(CHILD_HOSTSHARELIST, ListBox.class);
206:                registerChild(CHILD_HOSTSHARENAME_LBL, StaticTextField.class);
207:                registerChild(CHILD_HOSTSHARENAME, TextField.class);
208:                /*
209:                 registerChild(CHILD_HOSTSHAREUSER_LBL, StaticTextField.class);
210:                 registerChild(CHILD_HOSTSHAREUSER, TextField.class);
211:                 registerChild(CHILD_HOSTSHAREPASS_LBL, StaticTextField.class);
212:                 registerChild(CHILD_HOSTSHAREPASS, TextField.class);
213:                 */
214:                registerChild(CHILD_HOST_INDEX, HiddenField.class);
215:                registerChild(CHILD_ERRORMSGS, StaticTextField.class);
216:                registerChild(CHILD_SAVE_BTN, IPlanetButton.class);
217:                registerChild(CHILD_CANCEL_BTN, IPlanetButton.class);
218:                registerChild(CHILD_REMOVE_BTN, StaticTextField.class);
219:                registerChild(CHILD_ADDTOLIST_BTN, StaticTextField.class);
220:            }
221:
222:            public void beginDisplay(DisplayEvent event)
223:                    throws ModelControlException {
224:                getModel();
225:                getModelMgr();
226:                setChildValues(model);
227:                model.process();
228:                Set s = model.getNetFileHosts();
229:                netFileHosts = new Vector(s);
230:                currentRow = modelManager.getCurrentNetFileHostsRow();
231:                setDisplayFieldValue(PAGE_DESC, model.getServiceDisplayName());
232:                setDisplayFieldValue(CHILD_ERRORMSGS, getErrorMessages());
233:                setDisplayFieldValue(HELP_DOC_URL, modelManager
234:                        .getString(NetFileAdminService.SRA_BASE_HLP_URL));
235:                setDisplayFieldValue(HELP_ANCHOR_TAG, model
236:                        .getHelpUrl(modelManager
237:                                .getString(NetFileAdminService.SRA_NF_HLP_URL)));
238:
239:                ComboBox hostTypeCB = setHostTypeOptions();
240:                ComboBox hostEncodingCB = setHostEncodingOptions();
241:                String currentHost = null;
242:
243:                if (currentRow == -1) { // Adding new host
244:                    currentHost = SAMPLE_HOST;
245:                    // Set the encoding type to default OS Char Set
246:                    model.setCurrentRow(NetFileModel.DYNAMIC_TYPE, model
247:                            .getNetFileAttributeIndex(ATTR_OSCHARSET));
248:                    Set valueSet = model.getAttrValues();
249:                    String value = null;
250:                    if (valueSet != null && valueSet.iterator().hasNext()) {
251:                        value = (String) valueSet.iterator().next();
252:                    }
253:                    currentHost = currentHost.substring(0, currentHost
254:                            .indexOf(hostListStrEncoding))
255:                            + hostListStrEncoding
256:                            + value
257:                            + "\n"
258:                            + currentHost.substring(currentHost
259:                                    .indexOf(hostListStrDomain));
260:                    setDisplayFieldValue(PAGE_DESC_ACTION, modelManager
261:                            .getString("addhost.pagetitle"));
262:                } else { // Editing an existing host
263:                    currentHost = (String) netFileHosts.get(currentRow);
264:                    setDisplayFieldValue(PAGE_DESC_ACTION, modelManager
265:                            .getString("edithost.pagetitle"));
266:                }
267:                setDisplayFieldValue(CHILD_HOST_INDEX, currentRow);
268:
269:                //NetFileAdminModelManager.debugMessage("CurrentHost -> " + currentHost);
270:
271:                StringTokenizer st = new StringTokenizer(currentHost,
272:                        HOST_DELIM);
273:                String tmp = null;
274:                try {
275:                    tmp = st.nextToken();
276:                    setDisplayFieldValue(CHILD_HOSTNAME, tmp
277:                            .substring(hostListStrHost.length()));
278:
279:                    tmp = st.nextToken();
280:                    tmp = tmp.substring(hostListStrType.length());
281:                    if ("NT".equals(tmp)) {
282:                        hostTypeCB.setValue("WIN");
283:                    } else {
284:                        hostTypeCB.setValue(tmp);
285:                    }
286:
287:                    tmp = st.nextToken();
288:                    hostEncodingCB.setValue(tmp.substring(hostListStrEncoding
289:                            .length()));
290:
291:                    tmp = st.nextToken();
292:                    setDisplayFieldValue(CHILD_HOSTDOMAIN, tmp
293:                            .substring(hostListStrDomain.length()));
294:
295:                    tmp = st.nextToken();
296:                    setDisplayFieldValue(CHILD_HOSTPASSWORD, tmp
297:                            .substring(hostListStrPass.length()));
298:
299:                    tmp = st.nextToken();
300:                    setDisplayFieldValue(CHILD_HOSTUSERNAME, tmp
301:                            .substring(hostListStrUser.length()));
302:
303:                    OptionList optList = new OptionList();
304:                    ListBox lb = (ListBox) getChild(CHILD_HOSTSHARELIST);
305:                    String shareName;
306:                    String sharePassword;
307:                    String shareentry = null;
308:                    while (st.hasMoreTokens()) {
309:                        shareName = st.nextToken(); //Share Name
310:                        shareName = shareName.substring(hostListStrShare
311:                                .length());
312:                        sharePassword = st.nextToken(); //Share Password
313:                        sharePassword = sharePassword
314:                                .substring(hostListStrSharePass.length());
315:                        shareentry = shareName + HOST_DELIM + sharePassword;
316:                        optList.add(shareName, shareentry);
317:                    }
318:                    optList.add("---------------------------------------", "");
319:                    lb.setOptions(optList);
320:                } catch (NoSuchElementException nsee) {
321:                    NetFileAdminModelManager.debugError(
322:                            "Error parsing netfile hosts ", nsee);
323:                }
324:            }
325:
326:            public void handleSaveButtonRequest(RequestInvocationEvent event)
327:                    throws ModelControlException {
328:                /*
329:                 *  Get all the display field values and store it to the backend
330:                 */
331:                getModel();
332:                getModelMgr();
333:                model.process();
334:                Set s = model.getNetFileHosts();
335:                netFileHosts = new Vector(s);
336:                String currRow = (String) getDisplayFieldValue(CHILD_HOST_INDEX);
337:                try {
338:                    currentRow = Integer.parseInt(currRow);
339:                } catch (NumberFormatException nfe) {
340:                    currentRow = -1;
341:                    NetFileAdminModelManager.debugError(
342:                            "Error getting host index : ", nfe);
343:                }
344:                StringBuffer nhBuffer = new StringBuffer();
345:                String newHost = null;
346:                Set newHostSet = null;
347:                Map newMap = null;
348:
349:                String str1 = (String) getDisplayFieldValue(CHILD_HOSTNAME);
350:
351:                //Check for empty hostname when adding a new host
352:                if ((str1 == null) || (str1.trim().length() == 0)) {
353:                    MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
354:                    msgBox.setTitle(modelManager.getString("error.title"));
355:                    msgBox.setMessage(modelManager.getString("hostname.error"));
356:                    msgBox.setType(MessageBox.TYPE_ERROR);
357:                    msgBox.setVisible(true);
358:
359:                    /* Redisplay the page with the error */
360:                    forwardTo();
361:                    return;
362:                }
363:
364:                //Check for invalid hostname when adding a new host
365:                char ch = str1.charAt(0);
366:                if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) {
367:
368:                    MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
369:                    msgBox.setTitle(modelManager.getString("error.title"));
370:                    msgBox.setMessage(modelManager.getString("hostname.error"));
371:                    msgBox.setType(MessageBox.TYPE_ERROR);
372:                    msgBox.setVisible(true);
373:
374:                    /* Redisplay the page with the error */
375:                    forwardTo();
376:                    return;
377:                }
378:
379:                /*
380:                 *  Test for duplicate hostnames when adding a new host
381:                 */
382:                if (netFileHosts != null) {
383:                    for (int i = 0; i < netFileHosts.size(); i++) {
384:                        if (i == currentRow) {
385:                            continue;
386:                        }
387:                        StringTokenizer st1 = new StringTokenizer(
388:                                (String) netFileHosts.get(i), HOST_DELIM);
389:                        String str2 = null;
390:                        if (st1.hasMoreTokens()) {
391:                            str2 = st1.nextToken();
392:                            str2 = str2.substring(hostListStrHost.length());
393:                            if (str1.equals(str2)) {
394:
395:                                MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
396:                                msgBox.setTitle(modelManager
397:                                        .getString("error.title"));
398:                                msgBox.setMessage(modelManager
399:                                        .getString("duplicatehostname.error"));
400:                                msgBox.setType(MessageBox.TYPE_ERROR);
401:                                msgBox.setVisible(true);
402:
403:                                /* Redisplay the page with the error */
404:                                forwardTo();
405:                                return;
406:                            }
407:                        }
408:                    }
409:                }
410:
411:                nhBuffer.append(hostListStrHost + str1);
412:
413:                String hostDomain = (String) getDisplayFieldValue(CHILD_HOSTDOMAIN);
414:
415:                ComboBox cb = (ComboBox) getDisplayField(CHILD_HOSTTYPE);
416:                String hostType = (String) (cb.getValue());
417:                //str1 = (String)(cb.getValue());
418:
419:                if (hostDomain != null && hostDomain.trim().length() != 0
420:                        && "WIN".equals(hostType)) {
421:                    hostType = "NT";
422:                }
423:
424:                /*
425:                 for (int count = 0; count < hostTypeOptionList.length; count++) {
426:                 tmp = modelManager.getString("hostType." + hostTypeOptionList[count]);
427:                 if (str1.equals(tmp)) {
428:                 str1 = hostTypeOptionList[count];
429:                 break;
430:                 }
431:                 }
432:                 */
433:                nhBuffer.append(HOST_DELIM + hostListStrType + hostType);
434:
435:                cb = (ComboBox) getDisplayField(CHILD_HOSTENCODING);
436:                str1 = (String) (cb.getValue());
437:                String tmp;
438:                for (int count = 0; count < encodingTypeOptionList.length; count++) {
439:                    tmp = modelManager.getString("encoding_"
440:                            + encodingTypeOptionList[count]);
441:                    if (str1.equals(tmp)) {
442:                        //str1 = encodingTypeOptionList[count];
443:                        break;
444:                    }
445:                }
446:                nhBuffer.append(HOST_DELIM + hostListStrEncoding + str1);
447:
448:                /*
449:                 str1 = (String)getDisplayFieldValue(CHILD_HOSTDOMAIN);
450:                 nhBuffer.append(HOST_DELIM + hostListStrDomain + str1);
451:                 */
452:                nhBuffer.append(HOST_DELIM + hostListStrDomain + hostDomain);
453:
454:                String hostPassword = (String) getDisplayFieldValue(CHILD_HOSTPASSWORD);
455:                //str1 = (String)getDisplayFieldValue(CHILD_HOSTPASSWORD);
456:                nhBuffer.append(HOST_DELIM + hostListStrPass + hostPassword);
457:
458:                str1 = (String) getDisplayFieldValue(CHILD_HOSTUSERNAME);
459:                nhBuffer.append(HOST_DELIM + hostListStrUser + str1);
460:
461:                ListBox lb = (ListBox) getDisplayField(CHILD_HOSTSHARELIST);
462:                Object[] objValues = (Object[]) lb.getValues();
463:
464:                if ((objValues == null) || (objValues.length == 0)) {
465:                    //Empty Share list is allowed
466:                } else {
467:                    int size = objValues.length;
468:                    for (int i = 0; i < size; i++) {
469:                        String shareentry = (String) objValues[i];
470:                        StringTokenizer tok = new StringTokenizer(shareentry,
471:                                "\n");
472:                        StringBuffer sb = new StringBuffer();
473:                        try {
474:                            sb.append(hostListStrShare + tok.nextToken()); //Share Name
475:                            if ("WIN".equals(hostType) || "NT".equals(hostType)) {
476:                                if (tok.hasMoreElements()) {
477:                                    sb.append(HOST_DELIM + hostListStrSharePass
478:                                            + tok.nextToken()); // Share password.
479:                                } else {
480:                                    sb.append(HOST_DELIM + hostListStrSharePass
481:                                            + ""); // Share password.
482:                                }
483:                            } else {
484:                                sb.append(HOST_DELIM + hostListStrSharePass
485:                                        + hostPassword); // Share password.
486:                            }
487:                            /*
488:                             sb.append(HOST_DELIM + hostListStrShareUser + tok.nextToken());	//Share Username
489:                             */
490:                            //sb.append(HOST_DELIM + hostListStrSharePass + (String)getDisplayFieldValue(CHILD_HOSTPASSWORD));	//Share Password is currently same as machine password
491:                            nhBuffer.append(HOST_DELIM + sb.toString());
492:                        } catch (NoSuchElementException nsee) {
493:                            NetFileAdminModelManager.debugError("NSEE ", nsee);
494:                        }
495:                    }
496:                }
497:
498:                newHost = nhBuffer.toString();
499:                //NetFileAdminModelManager.debugMessage("Saving new host -> " + newHost);
500:
501:                if (netFileHosts != null) {
502:                    if (currentRow == -1) { // New host
503:                        netFileHosts.add(netFileHosts.size(), newHost);
504:                    } else {
505:                        netFileHosts.set(currentRow, newHost);
506:                    }
507:                    newHostSet = new HashSet();
508:                    if (!netFileHosts.isEmpty()) {
509:                        Iterator hosts = netFileHosts.iterator();
510:                        while (hosts.hasNext())
511:                            newHostSet.add((String) AccessController
512:                                    .doPrivileged(new EncryptAction(
513:                                            (String) hosts.next())));
514:                    }
515:
516:                    newMap = new HashMap();
517:                    newMap.put("sunPortalNetFileCommonHostData", newHostSet);
518:                    model.store(NetFileModel.DYNAMIC_TYPE, newMap);
519:                }
520:
521:                /*
522:                 *  Forward the request to the NetFileTotalOneViewBean
523:                 */
524:
525:                String nasURL = getNetFileAdminServiceURL();
526:                HttpServletResponse response = getRequestContext()
527:                        .getResponse();
528:                try {
529:                    response.sendRedirect(nasURL);
530:                } catch (IOException ioe) {
531:                    forwardTo();
532:                }
533:            }
534:
535:            public void handleCancelButtonRequest(RequestInvocationEvent event)
536:                    throws ModelControlException {
537:                String nasURL = getNetFileAdminServiceURL();
538:                HttpServletResponse response = getRequestContext()
539:                        .getResponse();
540:                try {
541:                    response.sendRedirect(nasURL);
542:                } catch (IOException ioe) {
543:                    forwardTo();
544:                }
545:            }
546:
547:            public void handleServiceDescHrefRequest(
548:                    RequestInvocationEvent event) throws ModelControlException {
549:                String nasURL = getNetFileAdminServiceURL();
550:                HttpServletResponse response = getRequestContext()
551:                        .getResponse();
552:                try {
553:                    response.sendRedirect(nasURL);
554:                } catch (IOException ioe) {
555:                    forwardTo();
556:                }
557:            }
558:
559:            public boolean isTemplate() {
560:                Map attributes = getPageSessionAttributes();
561:                String template = null;
562:                if (attributes != null)
563:                    template = (String) attributes
564:                            .get(NetFileTotalOneViewBean.TEMPLATE_ATTR);
565:                if (template != null && template.equals("true")) {
566:                    return true;
567:                } else {
568:                    return false;
569:                }
570:            }
571:
572:            public String getServiceName() {
573:                Map attributes = getPageSessionAttributes();
574:                String svcName = (String) attributes
575:                        .get(NetFileTotalOneViewBean.SVC_NAME_ATTR);
576:                return svcName;
577:            }
578:
579:            public NetFileModel getModel() {
580:                if (model == null) {
581:                    HttpServletRequest req = getRequestContext().getRequest();
582:                    req
583:                            .setAttribute(
584:                                    NetFileAdminModelManager.SRAP_NETFILE_MODEL_MGR_KEY,
585:                                    getModelMgr());
586:                    getModelMgr();
587:                    model = new NetFileModelImpl(req, "srapNetFileAdminMsgs",
588:                            getPageSessionAttributes(), getServiceName(),
589:                            isTemplate());
590:                }
591:                return model;
592:            }
593:
594:            public NetFileAdminModelManager getModelMgr() {
595:                if (modelManager == null) {
596:                    modelManager = (NetFileAdminModelManager) getRequestContext()
597:                            .getModelManager();
598:                }
599:                return modelManager;
600:            }
601:
602:            public String getNetFileAdminServiceURL() {
603:                String nasURL = null;
604:                getModel();
605:                if (model != null) {
606:                    nasURL = model.getPropsUrl();
607:                    String queryParam = "?ServiceName="
608:                            + getPageSessionAttribute(NetFileTotalOneViewBean.SVC_NAME_ATTR)
609:                            + "&Location="
610:                            + URLEncoder
611:                                    .encode((String) getPageSessionAttribute(NetFileTotalOneViewBean.LOCATION_DN))
612:                            + "&Template="
613:                            + getPageSessionAttribute(NetFileTotalOneViewBean.TEMPLATE_ATTR);
614:                    nasURL += queryParam;
615:                }
616:                return nasURL;
617:            }
618:
619:            private String getErrorMessages() {
620:                getModelMgr();
621:                StringBuffer sb = new StringBuffer();
622:                sb.append("errorMessages['invalidsharename'] = '"
623:                        + modelManager.getString("invalidsharename") + "';\n");
624:                sb.append("errorMessages['invalidshareuser'] = '"
625:                        + modelManager.getString("invalidshareuser") + "';\n");
626:                sb.append("errorMessages['duplicateshares'] = '"
627:                        + modelManager.getString("duplicateshares") + "';");
628:                return sb.toString();
629:            }
630:
631:            public ComboBox setHostTypeOptions() {
632:                OptionList optList = new OptionList();
633:                String tmp;
634:                for (int count = 0; count < hostTypeOptionList.length; count++) {
635:                    tmp = modelManager.getString("hostType."
636:                            + hostTypeOptionList[count]);
637:                    optList.add(tmp, hostTypeOptionList[count]);
638:                }
639:                ComboBox cb = (ComboBox) getDisplayField(CHILD_HOSTTYPE);
640:                cb.setOptions(optList);
641:                return cb;
642:            }
643:
644:            public ComboBox setHostEncodingOptions() {
645:                OptionList optList = new OptionList();
646:                String tmp;
647:                for (int count = 0; count < encodingTypeOptionList.length; count++) {
648:                    tmp = modelManager.getString("encoding_"
649:                            + encodingTypeOptionList[count]);
650:                    optList.add(tmp, tmp);
651:                }
652:                ComboBox cb = (ComboBox) getDisplayField(CHILD_HOSTENCODING);
653:                cb.setOptions(optList);
654:                return cb;
655:            }
656:
657:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.