Source Code Cross Referenced for NetletAdminServiceViewBean.java in  » Portal » Open-Portal » com » sun » portal » netlet » 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.netlet.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 Bhavanishankar
014:         */package com.sun.portal.netlet.admin;
015:
016:        // JDK classes
017:
018:        import java.io.IOException;
019:        import java.io.Serializable;
020:        import java.net.URLDecoder;
021:        import java.net.URLEncoder;
022:        import java.util.HashMap;
023:        import java.util.HashSet;
024:        import java.util.Iterator;
025:        import java.util.LinkedList;
026:        import java.util.List;
027:        import java.util.Map;
028:        import java.util.Set;
029:        import java.util.StringTokenizer;
030:        import java.util.Vector;
031:
032:        import javax.servlet.http.HttpServletRequest;
033:        import javax.servlet.http.HttpServletResponse;
034:
035:        import com.iplanet.am.console.base.AMMessageViewBean;
036:        import com.iplanet.am.console.base.AMViewBeanBase;
037:        import com.iplanet.am.console.base.model.AMAdminConstants;
038:        import com.iplanet.am.console.base.model.AMConsoleException;
039:        import com.iplanet.am.console.components.view.html.DynamicGUI;
040:        import com.iplanet.am.console.components.view.html.IPlanetButton;
041:        import com.iplanet.am.console.components.view.html.MessageBox;
042:        import com.iplanet.am.console.user.UMCreateSvcTemplateViewBean;
043:        import com.iplanet.jato.model.ModelControlException;
044:        import com.iplanet.jato.view.View;
045:        import com.iplanet.jato.view.ViewBean;
046:        import com.iplanet.jato.view.event.ChildDisplayEvent;
047:        import com.iplanet.jato.view.event.DisplayEvent;
048:        import com.iplanet.jato.view.event.RequestInvocationEvent;
049:        import com.iplanet.jato.view.html.ComboBox;
050:        import com.iplanet.jato.view.html.HiddenField;
051:        import com.iplanet.jato.view.html.OptionList;
052:        import com.iplanet.jato.view.html.StaticTextField;
053:        import com.iplanet.sso.SSOException;
054:        import com.sun.portal.netlet.admin.model.NetletAdminServiceModel;
055:        import com.sun.portal.netlet.admin.model.NetletAdminServiceModelImpl;
056:
057:        public class NetletAdminServiceViewBean extends AMViewBeanBase
058:                implements  NetletAdminService, AMAdminConstants {
059:            public static final String PAGE_DESCRIPTION = "serviceDescription";
060:
061:            public static final String PAGE_NAME = "NetletAdminService";
062:
063:            public static final String DEFAULT_DISPLAY_URL = "/ps/netletadmin/NetletAdminService.jsp";
064:
065:            public static final String GLOBAL_LABEL = "lblGlobal";
066:
067:            public static final String ORG_LABEL = "lblOrg";
068:
069:            public static final String DYNAMIC_LABEL = "lblDynamic";
070:
071:            public static final String GLOBAL_DATA_VIEW = "GlobalDataView";
072:
073:            public static final String ORG_DATA_VIEW = "OrgDataView";
074:
075:            public static final String DYNAMIC_DATA_VIEW = "DynamicDataView";
076:
077:            public static final String CHILD_CC_MSGBOX = "ccMessageBox";
078:
079:            public static final String SUBMIT_BTN = "SubmitButton";
080:
081:            public static final String RESET_BTN = "ResetButton";
082:
083:            public static final String DELETE_BUTTON = "DeleteButton";
084:
085:            public static final String PRIORITY_COMBOBOX = "Priority";
086:
087:            public static final String PRIORITY_LABEL = "lblPriority";
088:
089:            public static final String TITLE_HTML_PAGE = "titleHtmlPage";
090:
091:            public static final String CHILD_TILEDVIEW = "NetletRulesTiledView";
092:
093:            public static final String CHILD_NAME_LABEL = "nameLabel";
094:
095:            public static final String CHILD_ACTION_LABEL = "actionLabel";
096:
097:            public static final String NETLET_RULES_LABEL = "netletRulesLabel";
098:
099:            public static final String ADD_NETLETRULE_BTN = "addruleButton";
100:
101:            public static final String DELETE_NETLETRULES_BTN = "delrulesButton";
102:
103:            public static final String NETLET_RULES_COUNT = "netletRulesCount";
104:
105:            public static final String NO_RULE_SELECTION = "noRuleSelection";
106:
107:            public static final String CONFIRM_RULE_DELETE = "confirmRuleDelete";
108:
109:            // public static final String PAGE_ENCODING = "gx_charset";
110:
111:            private NetletAdminServiceModel model = null;
112:
113:            private NetletAdminModelManager modelManager = null;
114:
115:            private String serviceName = null;
116:
117:            private String template = null;
118:
119:            private boolean templateLevel = false;
120:
121:            public static final String SVC_NAME_ATTR = "com.iplanet.am.console.service.svcName";
122:
123:            public static final String TEMPLATE_ATTR = "com.iplanet.am.console.service.templateLevel";
124:
125:            public static final String LOCATION_DN = "com-iplanet-am-console-location-dn";
126:
127:            public NetletAdminServiceViewBean(String pageName) {
128:                super (pageName);
129:                registerChildren();
130:            }
131:
132:            public NetletAdminServiceViewBean() {
133:                super (PAGE_NAME);
134:                setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
135:                registerChildren();
136:            }
137:
138:            protected void registerChildren() {
139:                registerChild(PAGE_DESCRIPTION, StaticTextField.class);
140:                registerChild(GLOBAL_LABEL, StaticTextField.class);
141:                registerChild(ORG_LABEL, StaticTextField.class);
142:                registerChild(DYNAMIC_LABEL, StaticTextField.class);
143:                registerChild(GLOBAL_DATA_VIEW, NetletAdminServiceView.class);
144:                registerChild(ORG_DATA_VIEW, NetletAdminServiceView.class);
145:                registerChild(DYNAMIC_DATA_VIEW, NetletAdminServiceView.class);
146:                registerChild(CHILD_CC_MSGBOX, MessageBox.class);
147:                registerChild(SUBMIT_BTN, IPlanetButton.class);
148:                registerChild(RESET_BTN, IPlanetButton.class);
149:                registerChild(DELETE_BUTTON, IPlanetButton.class);
150:                registerChild(TITLE_HTML_PAGE, StaticTextField.class);
151:                registerChild(PRIORITY_COMBOBOX, ComboBox.class);
152:                registerChild(PRIORITY_LABEL, StaticTextField.class);
153:                registerChild(CHILD_TILEDVIEW, NetletRulesTiledView.class);
154:                registerChild(CHILD_NAME_LABEL, StaticTextField.class);
155:                registerChild(CHILD_ACTION_LABEL, StaticTextField.class);
156:                registerChild(NETLET_RULES_LABEL, StaticTextField.class);
157:                registerChild(ADD_NETLETRULE_BTN, IPlanetButton.class);
158:                registerChild(DELETE_NETLETRULES_BTN, IPlanetButton.class);
159:                registerChild(NETLET_RULES_COUNT, HiddenField.class);
160:                registerChild(NO_RULE_SELECTION, StaticTextField.class);
161:                registerChild(CONFIRM_RULE_DELETE, StaticTextField.class);
162:                // registerChild(PAGE_ENCODING, StaticTextField.class);
163:            }
164:
165:            /**
166:             * creates child view/component
167:             * 
168:             * @param name
169:             *            of view/component
170:             * @return child view/component
171:             */
172:            protected View createChild(String name) {
173:                /* get the model manager and model ready */
174:                getNetletModelMgr();
175:                View child = null;
176:                if (name.equals(PAGE_DESCRIPTION)) {
177:                    child = new StaticTextField(this , PAGE_DESCRIPTION, "");
178:                } else if (name.equals(GLOBAL_LABEL)) {
179:                    child = new StaticTextField(this , GLOBAL_LABEL, "");
180:                } else if (name.equals(ORG_LABEL)) {
181:                    child = new StaticTextField(this , ORG_LABEL, "");
182:                } else if (name.equals(DYNAMIC_LABEL)) {
183:                    child = new StaticTextField(this , DYNAMIC_LABEL, "");
184:                } else if (name.equals(GLOBAL_DATA_VIEW)) {
185:                    child = new NetletAdminServiceView(this , GLOBAL_DATA_VIEW,
186:                            NetletAdminServiceModel.GLOBAL_TYPE);
187:                } else if (name.equals(ORG_DATA_VIEW)) {
188:                    child = new NetletAdminServiceView(this , ORG_DATA_VIEW,
189:                            NetletAdminServiceModel.ORG_TYPE);
190:                } else if (name.equals(DYNAMIC_DATA_VIEW)) {
191:                    child = new NetletAdminServiceView(this , DYNAMIC_DATA_VIEW,
192:                            NetletAdminServiceModel.DYNAMIC_TYPE);
193:                } else if (name.equals(CHILD_TILEDVIEW)) {
194:                    return new NetletRulesTiledView(this , CHILD_TILEDVIEW);
195:                } else if (name.equals(CHILD_NAME_LABEL)) {
196:                    return new StaticTextField(this , CHILD_NAME_LABEL,
197:                            modelManager.getString("name.label"));
198:                } else if (name.equals(CHILD_ACTION_LABEL)) {
199:                    return new StaticTextField(this , CHILD_ACTION_LABEL,
200:                            modelManager.getString("action.label"));
201:                } else if (name.equals(NETLET_RULES_LABEL)) {
202:                    int netletrulesIndex = model.getNetletRulesIndex();
203:                    model.setCurrentRow(NetletAdminServiceModel.DYNAMIC_TYPE,
204:                            netletrulesIndex);
205:                    return new StaticTextField(this , NETLET_RULES_LABEL, model
206:                            .getDynamicGUI().getLabel()
207:                            + ":");
208:                } else if (name.equals(CHILD_CC_MSGBOX)) {
209:                    return new MessageBox(this , CHILD_CC_MSGBOX, "");
210:                } else if (name.equals(ADD_NETLETRULE_BTN)) {
211:                    child = new IPlanetButton(this , ADD_NETLETRULE_BTN,
212:                            modelManager.getString("add.button"));
213:                } else if (name.equals(DELETE_NETLETRULES_BTN)) {
214:                    child = new IPlanetButton(this , DELETE_NETLETRULES_BTN,
215:                            modelManager.getString("delete.button"));
216:                } else if (name.equals(SUBMIT_BTN)) {
217:                    child = new IPlanetButton(this , SUBMIT_BTN, "");
218:                } else if (name.equals(RESET_BTN)) {
219:                    child = new IPlanetButton(this , RESET_BTN, "");
220:                } else if (name.equals(DELETE_BUTTON)) {
221:                    child = new IPlanetButton(this , DELETE_BUTTON, "");
222:                } else if (name.equals(PRIORITY_COMBOBOX)) {
223:                    child = new ComboBox(this , PRIORITY_COMBOBOX, "");
224:                } else if (name.equals(PRIORITY_LABEL)) {
225:                    child = new ComboBox(this , PRIORITY_LABEL, "");
226:                } else if (name.equals(TITLE_HTML_PAGE)) {
227:                    StaticTextField txtField = new StaticTextField(this ,
228:                            TITLE_HTML_PAGE, modelManager
229:                                    .getString("netlet.admin.title"));
230:                    child = txtField;
231:                } else if (name.equals(NETLET_RULES_COUNT)) {
232:                    return new HiddenField(this , NETLET_RULES_COUNT, "");
233:                } else if (name.equals(NO_RULE_SELECTION)) {
234:                    return new StaticTextField(this , NO_RULE_SELECTION,
235:                            modelManager.getString("noruleselection"));
236:                } else if (name.equals(CONFIRM_RULE_DELETE)) {
237:                    return new StaticTextField(this , CONFIRM_RULE_DELETE,
238:                            modelManager.getString("confirmruledelete"));
239:                    /*
240:                     * } else if (name.equals(PAGE_ENCODING)) { child = new
241:                     * StaticTextField(this, PAGE_ENCODING, "");
242:                     */
243:                } else {
244:                    child = super .createChild(name);
245:                }
246:                return child;
247:            }
248:
249:            public void beginDisplay(DisplayEvent event)
250:                    throws ModelControlException {
251:                getModel();
252:                setChildValues(model);
253:                model.process();
254:                setDisplayFieldValue(PAGE_DESCRIPTION, model
255:                        .getServiceDisplayName());
256:                setDisplayFieldValue(GLOBAL_LABEL, modelManager
257:                        .getString("global"));
258:                setDisplayFieldValue(ORG_LABEL, modelManager
259:                        .getString("organization"));
260:                setDisplayFieldValue(DYNAMIC_LABEL, modelManager
261:                        .getString("dynamic"));
262:                setDisplayFieldValue(SUBMIT_BTN, modelManager
263:                        .getString("save.button"));
264:                setDisplayFieldValue(RESET_BTN, modelManager
265:                        .getString("reset.button"));
266:                setDisplayFieldValue(DELETE_BUTTON, modelManager
267:                        .getString("delete.button"));
268:                setDisplayFieldValue(NETLET_RULES_COUNT, model
269:                        .getNetletRulesCount());
270:                setDisplayFieldValue(HELP_DOC_URL, modelManager
271:                        .getString(NetletAdminService.SRA_BASE_HLP_URL));
272:                setDisplayFieldValue(HELP_ANCHOR_TAG, model
273:                        .getHelpAnchorTag(NetletAdminService.SRA_NL_HLP_URL));
274:
275:                // setPageEncoding();
276:            }
277:
278:            public void passPgSessionMap(ViewBean other) {
279:                Map attributes = getPageSessionAttributes();
280:                if ((attributes != null) && (attributes.size() > 0)) {
281:                    Iterator iter = attributes.keySet().iterator();
282:                    while (iter.hasNext()) {
283:                        String key = (String) iter.next();
284:                        other.setPageSessionAttribute(key,
285:                                (Serializable) attributes.get(key));
286:                    }
287:                }
288:            }
289:
290:            public NetletRulesTiledView getNetletRulesTiledView() {
291:                return (NetletRulesTiledView) getChild(CHILD_TILEDVIEW);
292:            }
293:
294:            public boolean beginGlobalBlockDisplay(ChildDisplayEvent event) {
295:                return (getModel().getSize(NetletAdminServiceModel.GLOBAL_TYPE) != 0);
296:            }
297:
298:            public boolean beginOrgBlockDisplay(ChildDisplayEvent event) {
299:                return (getModel().getSize(NetletAdminServiceModel.ORG_TYPE) != 0);
300:            }
301:
302:            public boolean beginTopLevelBlockDisplay(ChildDisplayEvent event) {
303:                return (!templateLevel && getModel().getSize(
304:                        NetletAdminServiceModel.DYNAMIC_TYPE) != 0);
305:            }
306:
307:            public boolean beginTemplateLevelBlockDisplay(
308:                    ChildDisplayEvent event) {
309:                if (!templateLevel) {
310:                    return false;
311:                } else {
312:                    NetletAdminServiceModel m = getModel();
313:                    boolean visible = (m
314:                            .getSize(NetletAdminServiceModel.DYNAMIC_TYPE) != 0);
315:                    if (visible) {
316:                        setDisplayFieldValue(PRIORITY_LABEL, modelManager
317:                                .getString("priority.label"));
318:                        String[][] options = m.getPriorityOptions();
319:                        OptionList optionList = new OptionList(options[0],
320:                                options[1]);
321:                        ComboBox cb = (ComboBox) getDisplayField(PRIORITY_COMBOBOX);
322:                        cb.setOptions(optionList);
323:                        cb.setValue(m.getPriority());
324:                    }
325:                    return visible;
326:                }
327:            }
328:
329:            public boolean beginDeleteButtonBlockDisplay(ChildDisplayEvent event) {
330:                return templateLevel;
331:            }
332:
333:            public void handleSubmitButtonRequest(RequestInvocationEvent event)
334:                    throws ModelControlException, SSOException {
335:                getModel();
336:                NetletAdminServiceView view = null;
337:                view = (NetletAdminServiceView) getChild(GLOBAL_DATA_VIEW);
338:                if (view != null) {
339:                    store(view, NetletAdminServiceModel.GLOBAL_TYPE);
340:                }
341:                view = (NetletAdminServiceView) getChild(ORG_DATA_VIEW);
342:                if (view != null) {
343:                    store(view, NetletAdminServiceModel.ORG_TYPE);
344:                }
345:                view = (NetletAdminServiceView) getChild(DYNAMIC_DATA_VIEW);
346:                if (view != null) {
347:                    store(view, NetletAdminServiceModel.DYNAMIC_TYPE);
348:                }
349:                MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
350:                msgBox
351:                        .setTitle(modelManager
352:                                .getString("servicepropssaved.msg"));
353:                msgBox.setType(MessageBox.TYPE_INFORMATION);
354:                msgBox.setVisible(true);
355:                forwardTo();
356:            }
357:
358:            /**
359:             * Called when Reset button is clicked. Does nothing and refreshes the page.
360:             */
361:            public void handleResetButtonRequest(RequestInvocationEvent event)
362:                    throws ModelControlException {
363:                redirectToNASURL();
364:            }
365:
366:            public void handleDeleteButtonRequest(RequestInvocationEvent event)
367:                    throws ModelControlException, AMConsoleException {
368:                NetletAdminServiceModel m = getModel();
369:                if (templateLevel) {
370:                    m.deleteTemplate();
371:                    UMCreateSvcTemplateViewBean vb = (UMCreateSvcTemplateViewBean) getViewBean(UMCreateSvcTemplateViewBean.class);
372:                    passPgSessionMap(vb);
373:                    vb.setServiceName(m.getServiceName());
374:                    vb.forwardTo(getRequestContext());
375:                } else {
376:                    forwardTo();
377:                }
378:            }
379:
380:            public void handleAddruleButtonRequest(RequestInvocationEvent event)
381:                    throws ModelControlException {
382:                modelManager.setCurrentNetletRulesRow(-1);
383:                EditNetletRuleViewBean vb = (EditNetletRuleViewBean) getViewBean(EditNetletRuleViewBean.class);
384:                passPgSessionMap(vb);
385:                vb.forwardTo(getRequestContext());
386:            }
387:
388:            public void handleDelrulesButtonRequest(RequestInvocationEvent event)
389:                    throws ModelControlException {
390:
391:                NetletRulesTiledView tileView = getNetletRulesTiledView();
392:                tileView.getPrimaryModel().setSize(
393:                        tileView.getNetletRulesCount());
394:                List selections = new LinkedList();
395:                while (tileView.nextTile()) {
396:                    String value = (String) tileView
397:                            .getDisplayFieldValue(NetletRulesTiledView.CHILD_CB_SELECT_RULE);
398:                    if (value.equals("true")) {
399:                        value = (String) tileView
400:                                .getDisplayFieldValue(NetletRulesTiledView.CHILD_HREF_TEXT);
401:                        selections.add(value);
402:                    }
403:                }
404:
405:                if (selections.size() == 0) {
406:                    getNetletModelMgr();
407:                    MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
408:                    msgBox.setTitle(modelManager
409:                            .getString("noselectionmsgbox.title"));
410:                    msgBox
411:                            .setMessage(modelManager
412:                                    .getString("noruleselection"));
413:                    msgBox.setType(MessageBox.TYPE_ERROR);
414:                    msgBox.setVisible(true);
415:                    /* Redisplay the page with the error */
416:                    forwardTo();
417:                    return;
418:                } else if (selections.size() > 0) {
419:                    Vector netletRules = tileView.getNetletRules();
420:                    int nrSize = netletRules.size();
421:                    if (netletRules != null) {
422:                        for (int i = 0; i < selections.size(); i++) {
423:                            for (int j = 0; j < netletRules.size(); j++) {
424:                                StringTokenizer st1 = new StringTokenizer(
425:                                        (String) netletRules.get(j),
426:                                        EditNetletRuleViewBean.RULE_DELIM);
427:                                if (st1.hasMoreTokens())
428:                                    st1 = new StringTokenizer(st1.nextToken(),
429:                                            EditNetletRuleViewBean.ALGO_DELIM);
430:                                if (st1.hasMoreTokens()) {
431:                                    String rulename = st1.nextToken();
432:                                    if (rulename.equals(selections.get(i))) {
433:                                        netletRules.remove(j);
434:                                        --j;
435:                                    }
436:                                }
437:                            }
438:                        }
439:                    }
440:                    Set newRuleSet = new HashSet(netletRules);
441:                    Map newMap = new HashMap();
442:                    newMap.put("sunPortalNetletRules", newRuleSet);
443:                    getModel();
444:                    model.store(NetletAdminServiceModel.DYNAMIC_TYPE, newMap);
445:                    redirectToNASURL();
446:                }
447:            }
448:
449:            private void store(NetletAdminServiceView view, int type)
450:                    throws SSOException {
451:                NetletAdminServiceModel m = getModel();
452:                m.process();
453:                Map map = new HashMap(10);
454:                List dynComps = view
455:                        .getDynamicCompList(m.getNetletRulesIndex());
456:                if (dynComps != null && !dynComps.isEmpty()) {
457:                    Iterator it = dynComps.iterator();
458:                    while (it.hasNext()) {
459:                        DynamicGUI dGui = (DynamicGUI) it.next();
460:                        if (dGui != null) {
461:                            Set dgValues = dGui.getValues();
462:                            if (dGui.getSyntax() == DynamicGUI.SYNTAX_DATE) {
463:                                try {
464:                                    dgValues = m
465:                                            .getDateInDefaultLocale(dgValues);
466:                                } catch (AMConsoleException ace) {
467:                                    NetletAdminModelManager
468:                                            .debugError("Error in converting value to default locale : "
469:                                                    + ace);
470:                                    // showMessage(MessageBox.TYPE_ERROR,
471:                                    // m.getErrorTitle(),
472:                                    // ace.getMessage());
473:                                    continue;
474:                                }
475:                            }
476:                            // map.put(dGui.getName(), dGui.getValues());
477:
478:                            map.put(dGui.getName(), dgValues);
479:
480:                        }
481:                    }
482:                }
483:                if (type == NetletAdminServiceModel.DYNAMIC_TYPE) {
484:                    String priority = (String) getDisplayFieldValue(PRIORITY_COMBOBOX);
485:                    if (!"".equals(priority))
486:                        map.put("priority", priority);
487:                }
488:
489:                if (!map.isEmpty()) {
490:                    // TOFIX: enclose in a try-catch and handle errors
491:                    m.store(type, map);
492:                }
493:            }
494:
495:            public NetletAdminModelManager getNetletModelMgr() {
496:                if (modelManager == null) {
497:                    modelManager = (NetletAdminModelManager) getRequestContext()
498:                            .getModelManager();
499:                }
500:                return modelManager;
501:            }
502:
503:            public String getServiceName() {
504:                if (serviceName == null) {
505:                    HttpServletRequest req = getRequestContext().getRequest();
506:                    serviceName = req.getParameter("ServiceName");
507:                    if (serviceName == null) {
508:                        serviceName = (String) getPageSessionAttribute(SVC_NAME_ATTR);
509:                    } else {
510:                        setPageSessionAttribute(SVC_NAME_ATTR, serviceName);
511:                    }
512:                }
513:                return serviceName;
514:            }
515:
516:            public boolean isTemplate() {
517:
518:                if (template == null) {
519:                    HttpServletRequest req = getRequestContext().getRequest();
520:                    template = req.getParameter("Template");
521:                    if (template == null) {
522:                        template = (String) getPageSessionAttribute(TEMPLATE_ATTR);
523:                    } else {
524:                        setPageSessionAttribute(TEMPLATE_ATTR, template);
525:                    }
526:                    if (template != null && template.equals("true")) {
527:                        templateLevel = true;
528:                    } else {
529:                        template = "false";
530:                        templateLevel = false;
531:                    }
532:                }
533:                return templateLevel;
534:            }
535:
536:            public String getLocationDN() {
537:                String locationDN = null;
538:                HttpServletRequest req = getRequestContext().getRequest();
539:                String encodedDN = req.getParameter("Location");
540:                if (encodedDN == null) {
541:                    locationDN = (String) getPageSessionAttribute(LOCATION_DN);
542:                } else {
543:                    try {
544:                        locationDN = URLDecoder.decode(encodedDN);
545:                        setPageSessionAttribute(LOCATION_DN, locationDN);
546:                    } catch (Exception e) {
547:                        // Too bad
548:                    }
549:                }
550:                return locationDN;
551:            }
552:
553:            public NetletAdminServiceModel getModel() {
554:
555:                if (model == null) {
556:                    HttpServletRequest req = getRequestContext().getRequest();
557:                    req.setAttribute(
558:                            NetletAdminModelManager.SRAP_NETLET_MODEL_MGR_KEY,
559:                            getNetletModelMgr());
560:                    /*
561:                     * Get all request parameters and set them as pageSessionAttributes
562:                     */
563:                    String locationDN = getLocationDN();
564:                    String svcName = getServiceName();
565:                    boolean isTemplateLevel = isTemplate();
566:
567:                    model = new NetletAdminServiceModelImpl(req,
568:                            "srapnetletadminmsgs", getPageSessionAttributes(),
569:                            svcName, isTemplateLevel);
570:
571:                    /**
572:                     * Chech whether the template exists or not. If not forward the
573:                     * request to UMCreateSvcTemplateViewBean
574:                     */
575:                    model.process();
576:
577:                    if (!model.hasSchema()) {
578:                        AMMessageViewBean vb = (AMMessageViewBean) getViewBean(AMMessageViewBean.class);
579:                        vb.setMessageType(MessageBox.TYPE_INFORMATION);
580:                        // vb.setTitle(model.getNoAttrsMessage());
581:                        vb.setTitle(modelManager.getString("noSchema.message"));
582:                        vb.setMessage("");
583:                        vb.addButton(model.getLocalizedString("ok.button"),
584:                                "../console/html/blank.html");
585:                        vb.forwardTo(getRequestContext());
586:                    } else if (templateLevel && !model.hasTemplate()) {
587:                        UMCreateSvcTemplateViewBean vb = (UMCreateSvcTemplateViewBean) getViewBean(UMCreateSvcTemplateViewBean.class);
588:                        passPgSessionMap(vb);
589:                        vb.setServiceName(svcName);
590:                        vb.forwardTo(getRequestContext());
591:                    }
592:                }
593:                return model;
594:            }
595:
596:            public String getNetletAdminServiceURL() {
597:                String nasURL = null;
598:                getModel();
599:                if (model != null) {
600:                    nasURL = model.getPropsUrl();
601:                    String queryParam = "?ServiceName="
602:                            + getPageSessionAttribute(NetletAdminServiceViewBean.SVC_NAME_ATTR)
603:                            + "&Location="
604:                            + URLEncoder
605:                                    .encode((String) getPageSessionAttribute(NetletAdminServiceViewBean.LOCATION_DN))
606:                            + "&Template="
607:                            + getPageSessionAttribute(NetletAdminServiceViewBean.TEMPLATE_ATTR);
608:                    nasURL += queryParam;
609:                }
610:                return nasURL;
611:            }
612:
613:            public void redirectToNASURL() {
614:                String nasURL = getNetletAdminServiceURL();
615:                HttpServletResponse response = getRequestContext()
616:                        .getResponse();
617:                try {
618:                    response.sendRedirect(nasURL);
619:                } catch (IOException ioe) {
620:                    forwardTo();
621:                }
622:            }
623:
624:            /*
625:             * private void setPageEncoding () { getModel(); HttpServletRequest req =
626:             * getRequestContext().getRequest(); HttpServletResponse res =
627:             * getRequestContext().getResponse(); Locale locale = model.getUserLocale();
628:             * String agentType = model.getClientType(); String contentType =
629:             * model.getContentType(agentType); String charset =
630:             * model.getCharset(agentType,locale); res.setContentType(contentType +
631:             * ";charset=" + charset); String jCharset =
632:             * BrowserEncoding.mapHttp2JavaCharset (charset);
633:             * setDisplayFieldValue(PAGE_ENCODING, jCharset); }
634:             */
635:
636:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.