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


001:        /* 
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:
006:        package com.sun.portal.search.admin;
007:
008:        import java.io.*;
009:        import java.util.*;
010:        import java.util.logging.Logger;
011:        import java.util.logging.Level;
012:        import java.net.*;
013:        import javax.servlet.*;
014:        import javax.servlet.http.*;
015:        import javax.servlet.jsp.*;
016:        import com.iplanet.jato.*;
017:        import com.iplanet.jato.model.*;
018:        import com.iplanet.jato.view.*;
019:        import com.iplanet.jato.view.event.*;
020:        import com.iplanet.jato.view.html.*;
021:        import com.iplanet.jato.util.*;
022:        import com.iplanet.am.console.components.view.html.ParentagePath;
023:        import com.iplanet.am.console.components.view.html.IPlanetButton;
024:        import com.iplanet.am.console.components.view.html.MessageBox;
025:
026:        import com.sun.portal.search.rdm.RDMTaxonomy;
027:        import com.sun.portal.search.util.SearchConfig;
028:        import com.sun.portal.search.admin.model.TaxonomyTreeModel;
029:        import com.sun.portal.log.common.PortalLogger;
030:
031:        /**
032:         * A simple, reusable component that displays a model field's Date object as
033:         * three combo boxes, and combines the values of these combo boxes back into
034:         * a Date object.
035:         *
036:         */
037:        public class NCEView extends RequestHandlingViewBase {
038:            // Create a Logger for this class
039:            private static Logger debugLogger = PortalLogger
040:                    .getLogger(NCEView.class);
041:
042:            /**
043:             *
044:             */
045:            public NCEView(View parent, String name) {
046:                super (parent, name);
047:                try {
048:                    registerChildren();
049:                } catch (Exception e) {
050:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
051:                            .getMessage());
052:                }
053:            }
054:
055:            /**
056:             *
057:             */
058:            protected void registerChildren() {
059:                try {
060:                    registerChild(CHILD_TAX_NAME, TextField.class);
061:                    registerChild(CHILD_TAX_DESC, TextField.class);
062:                    registerChild(CHILD_TAX_RULE, TextField.class);
063:                    registerChild(CHILD_TAX_ADD_CHILD, IPlanetButton.class);
064:                    registerChild(CHILD_TAX_ADD_SIBLING, IPlanetButton.class);
065:                    registerChild(CHILD_TAX_DELETE, IPlanetButton.class);
066:                    registerChild(CHILD_TAX_UPDATE, IPlanetButton.class);
067:                    registerChild(CHILD_TAX_CANCEL, IPlanetButton.class);
068:                    registerChild(CHILD_TAX_OK, IPlanetButton.class);
069:                    registerChild(CHILD_EDIT_ACTION, ComboBox.class);
070:                    registerChild(CHILD_CATEGORY_PATH, CategoryPathView.class);
071:                    registerChild(CHILD_ERROR_BOX, MessageBox.class);
072:                } catch (Exception e) {
073:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
074:                            .getMessage());
075:                }
076:            }
077:
078:            /**
079:             *
080:             */
081:            protected View createChild(String name) {
082:                try {
083:                    RequestContext rc = getRequestContext();
084:                    HttpServletRequest req = rc.getRequest();
085:                    CSViewBeanBase pvb = (CSViewBeanBase) getParentViewBean();
086:                    View child = null;
087:
088:                    // CHILD_TAX_NAME
089:                    if (name.equals(CHILD_TAX_NAME)) {
090:                        child = new TextField(this , CHILD_TAX_NAME, "");
091:                        return child;
092:                    }
093:                    // CHILD_TAX_DESC
094:                    if (name.equals(CHILD_TAX_DESC)) {
095:                        child = new TextField(this , CHILD_TAX_DESC, "");
096:                        return child;
097:                    }
098:                    // CHILD_TAX_RULE
099:                    if (name.equals(CHILD_TAX_RULE)) {
100:                        child = new TextField(this , CHILD_TAX_RULE, "");
101:                        return child;
102:                    }
103:                    // CHILD_TAX_ADD_CHILD
104:                    if (name.equals(CHILD_TAX_ADD_CHILD)) {
105:                        child = new IPlanetButton(this , CHILD_TAX_ADD_CHILD, "");
106:                        return child;
107:                    }
108:                    // CHILD_TAX_ADD_SIBLING
109:                    if (name.equals(CHILD_TAX_ADD_SIBLING)) {
110:                        child = new IPlanetButton(this , CHILD_TAX_ADD_SIBLING,
111:                                "");
112:                        return child;
113:                    }
114:                    // CHILD_TAX_DELETE
115:                    if (name.equals(CHILD_TAX_DELETE)) {
116:                        child = new IPlanetButton(this , CHILD_TAX_DELETE, "");
117:                        return child;
118:                    }
119:                    // CHILD_TAX_UPDATE
120:                    if (name.equals(CHILD_TAX_UPDATE)) {
121:                        child = new IPlanetButton(this , CHILD_TAX_UPDATE, "");
122:                        return child;
123:                    }
124:                    if (name.equals(CHILD_EDIT_ACTION)) {
125:                        child = new ComboBox(this , CHILD_EDIT_ACTION, "");
126:                        return child;
127:                    }
128:                    // CHILD_TAX_OK
129:                    if (name.equals(CHILD_TAX_OK)) {
130:                        child = new IPlanetButton(this , CHILD_TAX_OK, "");
131:                        return child;
132:                    }
133:                    // CHILD_TAX_CANCEL
134:                    if (name.equals(CHILD_TAX_CANCEL)) {
135:                        child = new IPlanetButton(this , CHILD_TAX_CANCEL, "");
136:                        return child;
137:                    }
138:                    if (name.equals(CHILD_ERROR_BOX)) {
139:                        child = new MessageBox(this , CHILD_ERROR_BOX, "");
140:                        return child;
141:                    }
142:                    if (name.equals(CHILD_CATEGORY_PATH)) {
143:                        child = new CategoryPathView(this , CHILD_CATEGORY_PATH);
144:                        return child;
145:                    }
146:
147:                    debugLogger.log(Level.FINER, "PSSH_CSPSA0048", name);
148:                    return null;
149:                } catch (Exception e) {
150:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
151:                            .getMessage());
152:                    return null;
153:                }
154:            }
155:
156:            /**
157:             *
158:             *
159:             */
160:            public void beginDisplay(DisplayEvent event)
161:                    throws ModelControlException {
162:                NTEViewBean pvb = (NTEViewBean) getParentViewBean();
163:                RequestContext rc = getRequestContext();
164:                HttpServletRequest req = rc.getRequest();
165:                // setting the "Name" field
166:                currentPageStr = req.getParameter(NTEViewBean.DISPLAY_PAGE);
167:                // setting the target page to be displayed after action completed
168:                pvb.setPageSessionAttribute(NTEViewBean.DISPLAY_PAGE,
169:                        new Integer(currentPageStr));
170:                editedNodeStr = req.getParameter(NTEViewBean.TAX_ACTION_EDIT);
171:                // setting the target node for action to be handle against
172:                pvb.setPageSessionAttribute(NTEViewBean.TAX_ACTION_EDIT,
173:                        editedNodeStr);
174:                categoryName = "";
175:                if (editedNodeStr != null) {
176:                    try {
177:                        editedNode = new Integer(editedNodeStr).intValue();
178:                        categoryName = pvb.findNodeId(editedNode);
179:                        //	pvb.setPageSessionAttribute(CHILD_TAX_NAME, categoryName);
180:                    } catch (NumberFormatException nfe) {
181:                        debugLogger.log(Level.INFO, "PSSH_CSPSA0049",
182:                                editedNodeStr);
183:                    }
184:                }
185:                if (categoryName.equals(RDMTaxonomy.RDM_TAXONOMY_ROOT)) {
186:                    setDisplayFieldValue(CHILD_TAX_NAME, pvb.getTaxonomyName());
187:                } else {
188:                    setDisplayFieldValue(CHILD_TAX_NAME, TaxonomyTreeModel
189:                            .lastNode(categoryName));
190:                }
191:
192:                // setting the "Description" filed
193:                categoryDesc = "";
194:                categoryRule = "";
195:                if (!categoryName.equals("")) {
196:                    //get the description directly from model
197:                    try {
198:                        categoryDesc = getTaxonomyTreeModel().getNodeDesc(
199:                                categoryName);
200:                        categoryRule = getTaxonomyTreeModel().getNodeRule(
201:                                categoryName);
202:                    } catch (ModelControlException mce) {
203:                        debugLogger.log(Level.INFO, "PSSH_CSPSA0050",
204:                                categoryName);
205:                    }
206:                }
207:                setDisplayFieldValue(CHILD_TAX_DESC, categoryDesc);
208:                setDisplayFieldValue(CHILD_TAX_RULE, categoryRule);
209:
210:                // setting the action buttons in the "buttons" editor's Layout
211:                setDisplayFieldValue(CHILD_TAX_UPDATE, pvb
212:                        .getLocalizedString("category.edit.btn_update"));
213:                setDisplayFieldValue(CHILD_TAX_ADD_CHILD, pvb
214:                        .getLocalizedString("category.edit.btn_add_child"));
215:                setDisplayFieldValue(CHILD_TAX_ADD_SIBLING, pvb
216:                        .getLocalizedString("category.edit.btn_add_sibling"));
217:                setDisplayFieldValue(CHILD_TAX_DELETE, pvb
218:                        .getLocalizedString("category.edit.btn_delete"));
219:                setDisplayFieldValue(CHILD_TAX_CANCEL, pvb
220:                        .getLocalizedString("category.edit.btn_cancel"));
221:                // in case of a dropDown action list editor layout
222:                // set the acceptable action according to the node selected
223:                // if ROOT cannot "add as a sibling"
224:                OptionList editActionOptions;
225:                if (categoryName.equals(RDMTaxonomy.RDM_TAXONOMY_ROOT)) {
226:                    // no add sibling action
227:                    editActionOptions = new OptionList(editTaxActionLabels,
228:                            editTaxActionValues);
229:                } else {
230:                    editActionOptions = new OptionList(editCatActionLabels,
231:                            editCatActionValues);
232:                }
233:                ((ComboBox) getChild(CHILD_EDIT_ACTION))
234:                        .setOptions(editActionOptions);
235:                setDisplayFieldValue(CHILD_TAX_OK, pvb
236:                        .getLocalizedString("category.edit.btn_ok"));
237:
238:                // setting the error message
239:                String errorMsg = getErrorMsg();
240:                MessageBox msgBox = (MessageBox) getChild(CHILD_ERROR_BOX);
241:                msgBox.setType(MessageBox.TYPE_ERROR);
242:                if (errorMsg != null) {
243:                    msgBox.setMessage(errorMsg);
244:                    msgBox.setEnabled(true);
245:                } else {
246:                    msgBox.setEnabled(false);
247:                }
248:            }
249:
250:            /*
251:             * choosing the editor - action's layout
252:             */
253:            public boolean beginDropDownLayoutDisplay(ChildDisplayEvent event) {
254:                return !beginButtonsLayoutDisplay(event);
255:            }
256:
257:            /*
258:             *
259:             */
260:            public boolean beginButtonsLayoutDisplay(ChildDisplayEvent event) {
261:                try {
262:                    if (configLayout.equals(BUTTONS_LAYOUT)) {
263:                        return true;
264:                    } else {
265:                        if (configLayout.equals(DROPDOWN_LAYOUT)) {
266:                            return false;
267:                        } else {
268:                            return true;
269:                        }
270:                    }
271:                } catch (Exception e) {
272:                    return true;
273:                }
274:            }
275:
276:            /* 
277:             * conditional display of the "add as sibling" action button
278:             */
279:            public boolean beginIsClassificationDisplay(ChildDisplayEvent event) {
280:                return !isRoot(editedNode);
281:            }
282:
283:            /*
284:             * returns true if modifications where made to the tree
285:             */
286:            public boolean beginModifiedDisplay(ChildDisplayEvent event) {
287:                try {
288:                    return getTaxonomyTreeModel().getModifiedState();
289:                } catch (Exception e) {
290:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
291:                            .getMessage());
292:                    return false;
293:                }
294:            }
295:
296:            /*
297:             *
298:             */
299:            public String getErrorMsg() {
300:                NTEViewBean pvb = (NTEViewBean) getParentViewBean();
301:                try {
302:                    StringBuffer errMsg = new StringBuffer();
303:                    // get model category edition error
304:                    String modelEditErr = (String) getRequestContext()
305:                            .getRequest().getSession().getAttribute(
306:                                    TAX_ACTION_ERROR);
307:                    if (modelEditErr != null) {
308:                        errMsg.append(modelEditErr);
309:                        getRequestContext().getRequest().getSession()
310:                                .removeAttribute(TAX_ACTION_ERROR);
311:                    }
312:                    if (errMsg.length() != 0) {
313:                        return (errMsg.toString());
314:                    } else {
315:                        return null;
316:                    }
317:                } catch (Exception e) {
318:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
319:                            .getMessage());
320:                    if (pvb != null) {
321:                        return pvb
322:                                .getLocalizedString("category.edit.error.default");
323:                    } else {
324:                        return "A system error occured but cannot identify the source";
325:                    }
326:                }
327:            }
328:
329:            //////////////////////////////////////
330:            // Action methods
331:            // action method do not directly interact with the Taxonomy model
332:            // which is a TreeViewModel. 
333:            // Only the TTView ViewBean has this ability and does so
334:            // before the tree element are actually displayed
335:            //////////////////////////////////////
336:
337:            /**
338:             * this methode does following 
339:             * 1. update the nodeName and nodeDesc in the servlet request with
340:             *    the textField value values that user might have modified
341:             * 2. sets the action to be performed
342:             * 3. forward to the refresh the TEViewBean
343:             */
344:            private void handleAction(RequestInvocationEvent event,
345:                    String formAction) {
346:                String errorMsg = null;
347:                NTEViewBean pvb = (NTEViewBean) getParentViewBean();
348:                RequestContext rc = event.getRequestContext();
349:                HttpServletResponse resp = rc.getResponse();
350:                HttpServletRequest req = rc.getRequest();
351:                Integer currentPageInt = ((Integer) pvb
352:                        .getPageSessionAttribute(NTEViewBean.DISPLAY_PAGE));
353:                pvb.removePageSessionAttribute(NTEViewBean.DISPLAY_PAGE);
354:                editedNodeStr = (String) pvb
355:                        .getPageSessionAttribute(NTEViewBean.TAX_ACTION_EDIT);
356:                pvb.removePageSessionAttribute(NTEViewBean.TAX_ACTION_EDIT);
357:                String editedCategory = "";
358:                if (editedNodeStr != null) {
359:                    try {
360:                        editedNode = Integer.parseInt(editedNodeStr);
361:                        editedCategory = pvb.findNodeId(editedNode);
362:                    } catch (NumberFormatException nfe) {
363:
364:                        debugLogger.log(Level.FINER, "PSSH_CSPSA0051",
365:                                editedNodeStr);
366:                        rc
367:                                .getRequest()
368:                                .getSession(true)
369:                                .setAttribute(
370:                                        TAX_ACTION_ERROR,
371:                                        pvb
372:                                                .getLocalizedString("category.edit.error.default"));
373:                        // sending default error message back to user
374:                        try {
375:                            resp
376:                                    .sendRedirect(NTEViewBean.PAGE_NAME
377:                                            + "?"
378:                                            + "gx_charset=UTF-8"
379:                                            + ((currentPageInt != null) ? ("&"
380:                                                    + NTEViewBean.DISPLAY_PAGE
381:                                                    + "=" + currentPageInt
382:                                                    .toString()) : ""));
383:                        } catch (Exception e) {
384:                            debugLogger.info("PSSH_CSPSA0052");
385:                        }
386:                    }
387:                    try {
388:                        Date modelLastActionDate = (Date) getTaxonomyTreeModel()
389:                                .getLastActionDate();
390:                        Date userLastActionDate = (Date) pvb
391:                                .getPageSessionAttribute(NTEViewBean.TAX_ACTION_TIMESTAMP);
392:                        Date userSessionLastActionDate = (Date) rc.getRequest()
393:                                .getSession(true).getAttribute(
394:                                        NTEViewBean.TAX_ACTION_TIMESTAMP);
395:                        // checking if the last model action date is later than the last user's action on the taxonomy model
396:                        if (modelLastActionDate != null
397:                                && userLastActionDate != null
398:                                && modelLastActionDate
399:                                        .after(userLastActionDate)) {
400:                            // if yes, it means that a concurrent user updated the servletContext stroed model meanwhile, 
401:                            // so the action is not taken, and the warning message about concurrent modification is shown
402:                            getTaxonomyTreeModel()
403:                                    .setErrorMsg(
404:                                            pvb
405:                                                    .getLocalizedString("category.edit.warning.concurrent_editing"));
406:                        } else {
407:                            // otherwise perform the action as normal
408:                            if ((formAction != null)
409:                                    && (!formAction.trim().equals(""))) {
410:                                try {
411:                                    String nodeName = new String(
412:                                            getDisplayFieldStringValue(
413:                                                    CHILD_TAX_NAME).trim());
414:                                    String nodeDesc = new String(
415:                                            getDisplayFieldStringValue(
416:                                                    CHILD_TAX_DESC).trim());
417:                                    String nodeRule = new String(
418:                                            getDisplayFieldStringValue(
419:                                                    CHILD_TAX_RULE).trim());
420:                                    String editAction = new String(
421:                                            getDisplayFieldStringValue(CHILD_EDIT_ACTION));
422:                                    try {
423:                                        boolean legalAction = true;
424:                                        if (formAction.equals(TAX_ACTION_OK)) {
425:                                            // This is only when the form editor is in DropDown layout
426:                                            // get the selected action
427:                                            // perform the action
428:                                            formAction = ((editAction == null) || (editAction
429:                                                    .trim().length() == 0)) ? TAX_ACTION_UPDATE
430:                                                    : editAction;
431:                                        }
432:                                        if (formAction
433:                                                .equals(TAX_ACTION_CANCEL)) {
434:                                            // cancellation of the Node Action
435:                                            // TODO - for now do nothing
436:                                        } else if (formAction
437:                                                .equals(TAX_ACTION_DELETE)) {
438:                                            getTaxonomyTreeModel().deleteNode(
439:                                                    editedCategory);
440:                                        } else {
441:                                            getTaxonomyTreeModel().isValidName(
442:                                                    nodeName);
443:                                            TreeView tv = (TreeView) getParentViewBean()
444:                                                    .getChild(
445:                                                            NTEViewBean.CHILD_TREEVIEW1);
446:                                            if (formAction
447:                                                    .equals(TAX_ACTION_ADD_CHILD)) {
448:                                                // add the child
449:                                                getTaxonomyTreeModel()
450:                                                        .insertChildNode(
451:                                                                editedCategory,
452:                                                                nodeName,
453:                                                                nodeDesc,
454:                                                                nodeRule);
455:                                                // expand the parent tree so as new child is appearent
456:                                                if (isRoot()) {
457:                                                    tv
458:                                                            .getStateData()
459:                                                            .setNodeExpanded(
460:                                                                    TaxonomyTreeModel
461:                                                                            .hashNodeId(RDMTaxonomy.RDM_TAXONOMY_ROOT),
462:                                                                    true);
463:                                                } else {
464:                                                    tv
465:                                                            .getStateData()
466:                                                            .setNodeExpanded(
467:                                                                    TaxonomyTreeModel
468:                                                                            .hashNodeId(editedCategory),
469:                                                                    true);
470:                                                }
471:                                            } else if (formAction
472:                                                    .equals(TAX_ACTION_ADD_SIBLING)) {
473:                                                getTaxonomyTreeModel()
474:                                                        .insertSiblingNode(
475:                                                                editedCategory,
476:                                                                nodeName,
477:                                                                nodeDesc,
478:                                                                nodeRule);
479:
480:                                            } else if (formAction
481:                                                    .equals(TAX_ACTION_UPDATE)) {
482:                                                // update the selected node
483:                                                boolean currentHandleState = tv
484:                                                        .getStateData()
485:                                                        .isNodeExpanded(
486:                                                                TaxonomyTreeModel
487:                                                                        .hashNodeId(editedCategory));
488:                                                getTaxonomyTreeModel()
489:                                                        .updateNode(
490:                                                                editedCategory,
491:                                                                nodeName,
492:                                                                nodeDesc,
493:                                                                nodeRule);
494:                                                String newNodeId = editedCategory
495:                                                        .substring(
496:                                                                0,
497:                                                                editedCategory
498:                                                                        .lastIndexOf(TaxonomyTreeModel
499:                                                                                .lastNode(editedCategory)))
500:                                                        + nodeName;
501:                                                if (!editedCategory
502:                                                        .equals(newNodeId)) {
503:                                                    // setting back the updated node handle state similar to previously
504:                                                    tv
505:                                                            .getStateData()
506:                                                            .setNodeExpanded(
507:                                                                    TaxonomyTreeModel
508:                                                                            .hashNodeId(newNodeId),
509:                                                                    currentHandleState);
510:                                                }
511:                                            } else {
512:                                                legalAction = false;
513:                                                debugLogger.log(Level.FINER,
514:                                                        "PSSH_CSPSA0053",
515:                                                        formAction);
516:                                                throw new ModelControlException(
517:                                                        pvb
518:                                                                .getLocalizedString("category.edit.error.default"));
519:                                            }
520:                                            if (legalAction == true) {
521:                                                // setting updating the last action performed taking it from the 
522:                                                Date lastUserEditDate = new Date();
523:                                                rc
524:                                                        .getRequest()
525:                                                        .getSession(true)
526:                                                        .setAttribute(
527:                                                                NTEViewBean.TAX_ACTION_TIMESTAMP,
528:                                                                lastUserEditDate);
529:                                                pvb
530:                                                        .setPageSessionAttribute(
531:                                                                NTEViewBean.TAX_ACTION_TIMESTAMP,
532:                                                                lastUserEditDate);
533:                                            }
534:                                        }
535:                                    } catch (ModelControlException mce) {
536:                                        errorMsg = mce.getMessage();
537:                                        rc.getRequest().getSession(true)
538:                                                .setAttribute(TAX_ACTION_ERROR,
539:                                                        errorMsg);
540:                                    }
541:                                    String editedCatQryStr = (errorMsg == null) ? ""
542:                                            : ("&"
543:                                                    + NTEViewBean.TAX_ACTION_EDIT
544:                                                    + "=" + editedNodeStr);
545:                                    String pageQryStr = (currentPageInt == null) ? ""
546:                                            : ("&" + NTEViewBean.DISPLAY_PAGE
547:                                                    + "=" + currentPageInt
548:                                                    .toString());
549:                                    resp.sendRedirect(NTEViewBean.PAGE_NAME
550:                                            + "?" + "gx_charset=UTF-8"
551:                                            + editedCatQryStr + pageQryStr);
552:
553:                                } catch (Exception e) {
554:                                    debugLogger.log(Level.INFO,
555:                                            "PSSH_CSPSA0054", e.getMessage());
556:                                    resp.sendRedirect(NTEViewBean.PAGE_NAME);
557:                                }
558:                            } else {
559:                                rc
560:                                        .getRequest()
561:                                        .getSession(true)
562:                                        .setAttribute(
563:                                                TAX_ACTION_ERROR,
564:                                                pvb
565:                                                        .getLocalizedString("category.edit.error.default"));
566:                                String pageQryStr = (currentPageInt == null) ? ""
567:                                        : ("&" + NTEViewBean.DISPLAY_PAGE + "=" + currentPageInt);
568:                                String editCatQryStr = (editedCategory == null) ? ""
569:                                        : ("&" + NTEViewBean.TAX_ACTION_EDIT
570:                                                + "=" + editedCategory);
571:
572:                                resp.sendRedirect(NTEViewBean.PAGE_NAME + "?"
573:                                        + "gx_charset=UTF-8" + pageQryStr
574:                                        + editCatQryStr);
575:                            }
576:                        }
577:                    } catch (Exception e) {
578:                        debugLogger.log(Level.INFO, "PSSH_CSPSA0055",
579:                                new Object[] { event.toString(), formAction,
580:                                        e.getMessage() });
581:                    }
582:                } else {
583:                    debugLogger.finer("PSSH_CSPSA0056");
584:                    try {
585:                        rc
586:                                .getRequest()
587:                                .getSession(true)
588:                                .setAttribute(
589:                                        TAX_ACTION_ERROR,
590:                                        pvb
591:                                                .getLocalizedString("category.edit.error.default"));
592:                        String pageQryStr = (currentPageInt == null) ? ""
593:                                : ("&" + NTEViewBean.DISPLAY_PAGE + "=" + currentPageInt
594:                                        .toString());
595:                        resp.sendRedirect(NTEViewBean.PAGE_NAME + "?"
596:                                + "gx_charset=UTF-8" + pageQryStr);
597:                    } catch (Exception e) {
598:                        debugLogger.info("PSSH_CSPSA0052");
599:                    }
600:                }
601:            }
602:
603:            /* 
604:             * Ok btn = confirmation of the action
605:             */
606:            public void handleTaxOkRequest(RequestInvocationEvent event) {
607:                try {
608:                    handleAction(event, TAX_ACTION_OK);
609:                } catch (Exception e) {
610:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0058", new String[] {
611:                            event.toString(), e.getMessage() });
612:                }
613:            }
614:
615:            /*
616:             * ADD_CHILD Action
617:             */
618:            public void handleTaxAddChildRequest(RequestInvocationEvent event) {
619:                try {
620:                    handleAction(event, TAX_ACTION_ADD_CHILD);
621:                } catch (Exception e) {
622:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0058", new String[] {
623:                            event.toString(), e.getMessage() });
624:                }
625:            }
626:
627:            /*
628:             * ADD_SIBLING Action
629:             */
630:            public void handleTaxAddSiblingRequest(RequestInvocationEvent event) {
631:                try {
632:                    handleAction(event, TAX_ACTION_ADD_SIBLING);
633:                } catch (Exception e) {
634:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0058", new String[] {
635:                            event.toString(), e.getMessage() });
636:                }
637:            }
638:
639:            /*
640:             * DELETE Action
641:             */
642:            public void handleTaxDeleteRequest(RequestInvocationEvent event) {
643:                try {
644:                    handleAction(event, TAX_ACTION_DELETE);
645:                } catch (Exception e) {
646:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0058", new String[] {
647:                            event.toString(), e.getMessage() });
648:                }
649:            }
650:
651:            /*
652:             * UPDATE Action
653:             */
654:            public void handleTaxUpdateRequest(RequestInvocationEvent event) {
655:                try {
656:                    handleAction(event, TAX_ACTION_UPDATE);
657:                } catch (Exception e) {
658:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0058", new String[] {
659:                            event.toString(), e.getMessage() });
660:                }
661:            }
662:
663:            /*
664:             * Cancel action
665:             */
666:            public void handleTaxCancelRequest(RequestInvocationEvent event) {
667:                try {
668:                    handleAction(event, TAX_ACTION_CANCEL);
669:                } catch (Exception e) {
670:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0058", new String[] {
671:                            event.toString(), e.getMessage() });
672:                }
673:            }
674:
675:            /* 
676:             * Hack 
677:             * have to create a TaxonomyTreeModel from here because not 
678:             * available from the JATO Framework ModelManager.
679:             * see. TaxonomyTreeModel Constructor comments
680:             */
681:            public TaxonomyTreeModel getTaxonomyTreeModel() {
682:                NTEViewBean pvb = (NTEViewBean) getParentViewBean();
683:                return pvb.getTaxonomyTreeModel();
684:            }
685:
686:            ////////////////////////////////////////
687:            // Utilities
688:            ////////////////////////////////////////
689:            private boolean isRoot() {
690:                return isRoot(editedNode);
691:            }
692:
693:            private boolean isRoot(int nodeID) {
694:                if (nodeID == 1)
695:                    return true;
696:                else
697:                    return false;
698:            }
699:
700:            ////////////////////////////////////////
701:            // Class variables
702:            ////////////////////////////////////////
703:            // JATO elements
704:            public static final String CHILD_TAX_NAME = "TaxName";
705:            public static final String CHILD_TAX_DESC = "TaxDesc";
706:            public static final String CHILD_TAX_RULE = "TaxRule";
707:            public static final String CHILD_TAX_ADD_CHILD = "TaxAddChild";
708:            public static final String CHILD_TAX_ADD_SIBLING = "TaxAddSibling";
709:            public static final String CHILD_TAX_DELETE = "TaxDelete";
710:            public static final String CHILD_TAX_UPDATE = "TaxUpdate";
711:            public static final String CHILD_ERROR_BOX = "errorBox";
712:            public static final String CHILD_EDIT_ACTION = "editAction";
713:            public static final String CHILD_TAX_OK = "TaxOk";
714:            public static final String CHILD_TAX_CANCEL = "TaxCancel";
715:            public static final String CHILD_CATEGORY_PATH = "catPath";
716:            // actions' label
717:            public static final String TAX_ACTION_CANCEL = "Cancel";
718:            public static final String TAX_ACTION_OK = "Ok";
719:            public static final String TAX_ACTION_ADD_CHILD = "add_child";
720:            public static final String TAX_ACTION_ADD_SIBLING = "add_sibling";
721:            public static final String TAX_ACTION_UPDATE = "update";
722:            public static final String TAX_ACTION_DELETE = "delete";
723:            public static final String TAX_ACTION_ERROR = "editingError";
724:
725:            public static final String NODE_ID = "nodeID";
726:            public static final String NODE_NAME = "nodeName";
727:            public static final String NODE_DESC = "nodeDesc";
728:            public static final String NODE_RULE = "nodeRule";
729:
730:            public static final String DISPLAY = "CategoryEditor.Display";
731:            public static final String DROPDOWN_LAYOUT = "dropDown";
732:            public static final String BUTTONS_LAYOUT = "buttons";
733:            ////////////////////////////////////////
734:            // Instance variables
735:            ////////////////////////////////////////
736:            boolean display = false;
737:            private String categoryName = null;
738:            private String categoryDesc = null;
739:            private String categoryRule = null;
740:            private String editedNodeStr = null;
741:            private String currentPageStr = null;
742:            private int editedNode = 1;
743:            public String configLayout = SearchConfig
744:                    .getValue(SearchConfig.CATEGORY_EDITOR_LAYOUT);
745:            public String[] editCatActionLabels = new String[] {
746:                    ((CSViewBeanBase) getParentViewBean())
747:                            .getLocalizedString("category.edit.action_label.update"),
748:                    ((CSViewBeanBase) getParentViewBean())
749:                            .getLocalizedString("category.edit.action_label.add_child"),
750:                    ((CSViewBeanBase) getParentViewBean())
751:                            .getLocalizedString("category.edit.action_label.add_sibling"),
752:                    ((CSViewBeanBase) getParentViewBean())
753:                            .getLocalizedString("category.edit.action_label.delete") };
754:            public String[] editTaxActionLabels = new String[] {
755:                    ((CSViewBeanBase) getParentViewBean())
756:                            .getLocalizedString("category.edit.action_label.update"),
757:                    ((CSViewBeanBase) getParentViewBean())
758:                            .getLocalizedString("category.edit.action_label.add_child"),
759:                    ((CSViewBeanBase) getParentViewBean())
760:                            .getLocalizedString("category.edit.action_label.delete") };
761:
762:            ////////////////////////////////////////
763:            // Class variables
764:            ////////////////////////////////////////
765:            public static String[] editCatActionValues = new String[] {
766:                    TAX_ACTION_UPDATE, TAX_ACTION_ADD_CHILD,
767:                    TAX_ACTION_ADD_SIBLING, TAX_ACTION_DELETE };
768:
769:            public static String[] editTaxActionValues = new String[] {
770:                    TAX_ACTION_UPDATE, TAX_ACTION_ADD_CHILD, TAX_ACTION_DELETE };
771:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.