Source Code Cross Referenced for RDAddView.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.net.*;
010:        import java.util.*;
011:        import java.util.logging.Logger;
012:        import java.util.logging.Level;
013:
014:        import com.iplanet.jato.view.RequestHandlingTiledViewBase;
015:        import com.iplanet.jato.view.View;
016:        import com.iplanet.jato.view.ViewBean;
017:        import com.iplanet.jato.view.ViewBeanBase;
018:        import com.iplanet.jato.view.TiledView;
019:        import com.iplanet.jato.RequestHandler;
020:        import com.iplanet.jato.model.*;
021:        import com.iplanet.jato.view.event.DisplayEvent;
022:        import com.iplanet.jato.view.event.RequestInvocationEvent;
023:        import com.iplanet.jato.view.event.TiledViewRequestInvocationEvent;
024:        import com.iplanet.jato.view.event.ChildDisplayEvent;
025:        import com.iplanet.jato.view.html.StaticTextField;
026:        import com.iplanet.jato.view.html.ListBox;
027:        import com.iplanet.jato.view.html.TextField;
028:        import com.iplanet.jato.view.html.OptionList;
029:        import com.iplanet.jato.view.html.Button;
030:        import com.iplanet.jato.view.html.ComboBox;
031:        import com.iplanet.jato.view.html.HiddenField;
032:        import com.iplanet.jato.util.Encoder;
033:
034:        import javax.servlet.http.HttpServletRequest;
035:        import javax.servlet.http.HttpServletResponse;
036:
037:        import com.iplanet.am.console.components.view.html.DynamicGUI;
038:        import com.iplanet.am.console.components.view.html.DynamicGUIComp;
039:        import com.iplanet.am.console.components.view.html.IPlanetButton;
040:
041:        import com.iplanet.sso.SSOTokenManager;
042:        import com.iplanet.sso.SSOToken;
043:        import com.iplanet.sso.SSOException;
044:        import com.iplanet.sso.SSOTokenID;
045:
046:        import com.sun.portal.search.rdm.*;
047:        import com.sun.portal.search.soif.*;
048:        import com.sun.portal.search.db.SToken;
049:        import com.sun.portal.search.util.SearchConfig;
050:        import com.sun.portal.search.admin.model.RDListModel;
051:        import com.sun.portal.search.admin.util.DBUtil;
052:        import com.sun.portal.log.common.PortalLogger;
053:
054:        /**
055:         * This view uses model of type AMIndentedListModel to display a tree like
056:         * heirarchichal data structure in expanded tree form. So when a tree is
057:         * expanded its nodes are displayed as indented rows. The indentation is
058:         * relative to the parent node.
059:         * Each row has this structure: [checkbox]name[link]
060:         * The checkbox and link can be turned on or off. Thus,those nodes which are
061:         * only for labeling purpose, can have only the name displayed in the row. 
062:         * This view uses TiledView of JATO, and hence each row is a tile. Typicaly,
063:         * the subclasses will use the link to display the properties associated 
064:         * with the name, and checkbox may be used for add/delete operations.
065:         */
066:        public class RDAddView extends RequestHandlingTiledViewBase implements 
067:                TiledView, RequestHandler {
068:
069:            public static final String RD_AV_SET = "rdAVSet";
070:            public static final String TAXBROWSE_BUTTON = "TaxBrowser";
071:
072:            String database = null;
073:
074:            private SOIF s = null;
075:            private RDMSchema schema = null;
076:            private boolean atClassificationField = false;
077:            private HashMap storedMap = null;
078:            private ArrayList fieldList = new ArrayList();/*stored editable soif attribute column index*/
079:
080:            // Create a Logger for this class
081:            private static Logger debugLogger = PortalLogger
082:                    .getLogger(RDAddView.class);
083:
084:            public RDAddView(View parent, String name) {
085:                super (parent, name);
086:                setPrimaryModel((DatasetModel) getDefaultModel());
087:                registerChildren();
088:                loadSchema();
089:            }
090:
091:            protected void registerChildren() {
092:                registerChild(RD_AV_SET, DynamicGUIComp.class);
093:                registerChild(TAXBROWSE_BUTTON, IPlanetButton.class);
094:
095:            }
096:
097:            protected View createChild(String name) {
098:                if (name.equals(RD_AV_SET)) {
099:                    return new DynamicGUIComp(this , RD_AV_SET, null);
100:                } else if (name.equals(TAXBROWSE_BUTTON)) {
101:                    IPlanetButton btn = new IPlanetButton(this ,
102:                            TAXBROWSE_BUTTON, "");
103:                    btn.validate(true);
104:                    return btn;
105:                } else {
106:                    throw new IllegalArgumentException("Invalid child name: "
107:                            + name);
108:                }
109:
110:            }
111:
112:            OptionList getDBListOption() {
113:                try {
114:                    String[] dbs = DBUtil.getDBStringArray(CSConfig
115:                            .getServerRoot());
116:                    return new OptionList(dbs, dbs);
117:                } catch (Exception e) {
118:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
119:                            .getMessage());
120:                }
121:
122:                return new OptionList();
123:
124:            }
125:
126:            /**
127:             *
128:             *
129:             */
130:            public void beginDisplay(DisplayEvent event)
131:                    throws ModelControlException {
132:                ViewBean pvb = getParentViewBean();
133:
134:                String editTimeStamp = (String) pvb
135:                        .getPageSessionAttribute("editTimeStamp");
136:                database = (String) pvb.getPageSessionAttribute("database"
137:                        + editTimeStamp);
138:                if (database == null) {
139:                    database = getRequestContext().getRequest().getParameter(
140:                            "database" + editTimeStamp);
141:                    if (database != null) {
142:                        pvb.setPageSessionAttribute("database" + editTimeStamp,
143:                                database);
144:                    }
145:                }
146:
147:                fieldList.add("Title");
148:                fieldList.add("URL");
149:                fieldList.add("Description");
150:                fieldList.add("Author");
151:                fieldList.add("Keywords");
152:                fieldList.add("Classification");
153:                fieldList.add("ReadACL");
154:
155:                getPrimaryModel().setSize(fieldList.size());
156:
157:                storedMap = (HashMap) pvb.getRequestContext().getRequest()
158:                        .getSession()
159:                        .getAttribute("DynamicGUI" + editTimeStamp);
160:            }
161:
162:            public boolean beginTaxonomyBrowseDisplay(ChildDisplayEvent event) {
163:                return atClassificationField;
164:            }
165:
166:            /**
167:             * Increments the current tile position to the next available tile position.
168:             * This method sets the current row in the model to the current tile index
169:             * and builds the dynamic gui component for the attribute in the current
170:             * row.
171:             *
172:             * @return True if successful.
173:             * @throws ModelControlException
174:             */
175:            public boolean nextTile() throws ModelControlException {
176:                boolean movedToRow = super .nextTile();
177:                int ndx = getTileIndex();
178:                CSViewBeanBase pvb = (CSViewBeanBase) getParentViewBean();
179:
180:                if (movedToRow) {
181:                    DynamicGUI dg = null;
182:                    DynamicGUIComp dgc = (DynamicGUIComp) getChild(RD_AV_SET);
183:
184:                    // Put row specific logic here
185:                    String name = (String) fieldList.get(ndx);
186:
187:                    boolean required = false;
188:                    int attrType = DynamicGUI.TYPE_SINGLE;
189:                    int attrSyntax = DynamicGUI.SYNTAX_STRING;
190:                    setDisplayFieldValue(TAXBROWSE_BUTTON, pvb
191:                            .getLocalizedString("category.browser.launch"));
192:                    atClassificationField = name
193:                            .equalsIgnoreCase("Classification");
194:                    if (name.equalsIgnoreCase("ReadACL")
195:                            || name.equalsIgnoreCase("Classification")) {
196:                        attrType = DynamicGUI.TYPE_LIST;
197:                    }
198:                    String label = name;
199:                    Set values = null;
200:                    if (storedMap != null) {
201:                        values = (Set) storedMap.get(name);
202:                    }
203:
204:                    //Depending on the type and syntax, get value
205:                    if (attrType == DynamicGUI.TYPE_SINGLE) {
206:                        if (attrSyntax == DynamicGUI.SYNTAX_BOOLEAN) {
207:                            String trueValue = "true";
208:                            String falseValue = "false";
209:                            String value = "";
210:                            if (values != null) {
211:                                value = (String) values.iterator().next();
212:                            }
213:                            dg = new DynamicGUI(name, label, required,
214:                                    attrType, attrSyntax, trueValue,
215:                                    falseValue, value);
216:                        } else {
217:                            dg = new DynamicGUI(name, label, required,
218:                                    attrType, attrSyntax, values);
219:                        }
220:
221:                        if (attrSyntax == DynamicGUI.SYNTAX_PASSWORD) {
222:                            dg.setConfirmPwdLabel("Confirm");
223:                            dg.setPasswordMessage(label + ": " + "Mismatch");
224:                        }
225:                    }
226:                    /* else if(attrType == DynamicGUI.TYPE_SINGLE_CHOICE) ||
227:                        attrType == DynamicGUI.TYPE_MULTIPLE_CHOICE )
228:                    {
229:                        String[] choiceLabels = m.getAttrChoiceLabels();
230:                        String[] choiceValues = m.getAttrChoices();
231:                        OptionList optionList =
232:                            new OptionList(choiceLabels, choiceValues);
233:                        dg = new DynamicGUI(name, label, required, attrType,
234:                             attrSyntax, values, optionList);
235:                    }*/
236:                    else if (attrType == DynamicGUI.TYPE_LIST) {
237:                        dg = new DynamicGUI(name, label, required, attrType,
238:                                attrSyntax, values);
239:                        dg.setAddButtonStr(pvb.getLocalizedString("add.text"));
240:                        dg.setRemoveButtonStr(pvb
241:                                .getLocalizedString("remove.text"));
242:                    }
243:                    if (atClassificationField) {
244:                        String editTimeStamp = (String) pvb
245:                                .getPageSessionAttribute("editTimeStamp");
246:                        String[] insTax = (String[]) pvb
247:                                .getRequestContext()
248:                                .getRequest()
249:                                .getSession()
250:                                .getAttribute(
251:                                        TaxonomyBrowserView.SESION_ATTR_SELECTED_TAX
252:                                                + editTimeStamp);
253:                        if (insTax != null) {
254:                            pvb
255:                                    .getRequestContext()
256:                                    .getRequest()
257:                                    .getSession()
258:                                    .removeAttribute(
259:                                            TaxonomyBrowserView.SESION_ATTR_SELECTED_TAX
260:                                                    + editTimeStamp);
261:                            values = new HashSet(insTax.length);
262:                            for (int i = 0; i < insTax.length; i++) {
263:                                values.add(insTax[i]);
264:                            }
265:                            dg.setValues(values);
266:                        }
267:                    }
268:
269:                    dgc.setValue(dg);
270:                }
271:                return movedToRow;
272:            }
273:
274:            /**
275:             * Gets dynamic gui components from the Http request object and returns
276:             * a List.
277:             *
278:             * @return List of DynamicGUIComp
279:             */
280:            public List getDynamicCompList() {
281:                // cannot tell the size so give a default size
282:                List dynamicGUIs = new ArrayList(10);
283:                HttpServletRequest req = getRequestContext().getRequest();
284:
285:                int count = 0;
286:                while (true) {
287:                    DynamicGUI dGUI = DynamicGUIComp.createDynamicGUI(req,
288:                            getQualifiedName(), RD_AV_SET, count++);
289:
290:                    if (dGUI != null) {
291:                        dynamicGUIs.add(dGUI);
292:                    } else {
293:                        break;
294:                    }
295:                }
296:                return dynamicGUIs;
297:            }
298:
299:            public void loadSchema() {
300:                SearchConfig csidconf = SearchConfig.getSearchConfig();
301:                String schfn;
302:                if ((schfn = SearchConfig.getValue(SearchConfig.SCHEMA)) == null) {
303:                    debugLogger.finer("PSSH_CSPSA0072");
304:                }
305:
306:                // Load the schema
307:                debugLogger.log(Level.FINER, "PSSH_CSPSA0073", schfn);
308:                SOIFInputStream ss = null;
309:                try {
310:                    ss = new SOIFInputStream(schfn);
311:                } catch (Exception e) {
312:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0074", schfn);
313:                }
314:
315:                try {
316:                    schema = new RDMSchema(ss.readSOIF());
317:                } catch (Exception e) {
318:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0075", schfn);
319:                }
320:
321:            }
322:
323:            public void addRD() throws Exception {
324:                ViewBean pvb = getParentViewBean();
325:                String editTimeStamp = (String) pvb
326:                        .getPageSessionAttribute("editTimeStamp");
327:                database = (String) pvb.getPageSessionAttribute("database"
328:                        + editTimeStamp);
329:                List dynList = getDynamicCompList();
330:                String tmpFile = CSConfig.getServerRoot() + File.separator
331:                        + "tmp" + File.separator + "tmpRDEditor."
332:                        + Long.toString(System.currentTimeMillis());
333:                String rdMgrCmd;
334:                if (System.getProperty("os.name").startsWith("win")
335:                        || System.getProperty("os.name").startsWith("Win")
336:                        || System.getProperty("os.name").startsWith("WIN")) {
337:                    rdMgrCmd = CSConfig.getServerRoot() + File.separator
338:                            + "run-cs-cli.bat rdmgr ";
339:                } else {
340:                    rdMgrCmd = CSConfig.getServerRoot() + File.separator
341:                            + "run-cs-cli rdmgr ";
342:                }
343:
344:                if (database != null) {
345:                    rdMgrCmd = rdMgrCmd + "-y " + database + " ";
346:                }
347:
348:                createOneRD(database, dynList, tmpFile);
349:
350:                rdMgrCmd = rdMgrCmd + "-m -P -q " + tmpFile;
351:                runRDMGR(rdMgrCmd);
352:
353:            }
354:
355:            public void createOneRD(String database, List dynList,
356:                    String tmpFile) throws Exception {
357:
358:                SOIFOutputStream so = new SOIFOutputStream(tmpFile);
359:                SOIF newRD = new SOIF();
360:                newRD.setSchemaName("DOCUMENT");
361:                for (int i = 0; i < dynList.size(); i++) {
362:                    DynamicGUI dynGUI = (DynamicGUI) dynList.get(i);
363:                    String name = dynGUI.getName();
364:                    debugLogger.log(Level.FINER, "PSSH_CSPSA0076", name);
365:
366:                    Set vSet = dynGUI.getValues();
367:
368:                    if (vSet.size() == 0) {
369:                        debugLogger.log(Level.FINER, "PSSH_CSPSA0077", name);
370:                        newRD.insert(name, "", 0);
371:                    } else {
372:                        if (name.equalsIgnoreCase("url")) {
373:                            newRD.setURL((String) (vSet.iterator()).next());
374:                            continue;
375:                        }
376:                        Iterator it = vSet.iterator();
377:                        int ndx = 0;
378:                        while (it.hasNext()) {
379:                            String value = (String) it.next();
380:                            debugLogger.log(Level.FINER, "PSSH_CSPSA0078",
381:                                    value);
382:                            newRD.insert(name, value, ndx++);
383:                        }
384:                    }
385:                }
386:
387:                so.write(newRD);
388:                so.close();
389:
390:                String rdMgrCmd;
391:                if (System.getProperty("os.name").startsWith("win")
392:                        || System.getProperty("os.name").startsWith("Win")
393:                        || System.getProperty("os.name").startsWith("WIN")) {
394:                    rdMgrCmd = CSConfig.getServerRoot() + File.separator
395:                            + "run-cs-cli.bat rdmgr ";
396:                } else {
397:                    rdMgrCmd = CSConfig.getServerRoot() + File.separator
398:                            + "run-cs-cli rdmgr ";
399:                }
400:
401:                if (database != null) {
402:                    rdMgrCmd = rdMgrCmd + "-y " + database + " ";
403:                }
404:
405:                rdMgrCmd = rdMgrCmd + "-m " + tmpFile;
406:                runRDMGR(rdMgrCmd);
407:
408:            }
409:
410:            public void runRDMGR(String cmdline) throws Exception {
411:                Runtime rt = Runtime.getRuntime();
412:                debugLogger.log(Level.FINER, "PSSH_CSPSA0079", cmdline);
413:                Process p = rt.exec(cmdline);
414:                p.waitFor();
415:                int exitValue = p.exitValue();
416:                if (exitValue == 1) {
417:                    debugLogger.log(Level.FINER, "PSSH_CSPSA0080", Integer
418:                            .toString(exitValue));
419:                }
420:
421:            }
422:
423:            public void handleTaxBrowserRequest(RequestInvocationEvent event) {
424:                HashMap map = new HashMap();
425:                String[] currTax = null;
426:                List dynList = getDynamicCompList();
427:                for (int i = 0; i < dynList.size(); i++) {
428:                    DynamicGUI dynGUI = (DynamicGUI) dynList.get(i);
429:                    String name = dynGUI.getName();
430:                    debugLogger.log(Level.FINER, "PSSH_CSPSA0081", dynGUI
431:                            .toString());
432:                    Set vSet = dynGUI.getValues();
433:                    if (name.equalsIgnoreCase("classification")) {
434:                        if (!vSet.isEmpty()) {
435:                            currTax = (String[]) vSet.toArray(new String[0]);
436:                        }
437:                    } else {
438:                        if (!vSet.isEmpty()) {
439:                            map.put(name, vSet);
440:                        }
441:                    }
442:                }
443:                ViewBean pvb = getParentViewBean();
444:                String editTimeStamp = (String) pvb
445:                        .getPageSessionAttribute("editTimeStamp");
446:                debugLogger.log(Level.FINER, "PSSH_CSPSA0082", editTimeStamp);
447:                pvb.getRequestContext().getRequest().getSession().setAttribute(
448:                        "DynamicGUI" + editTimeStamp, map);
449:                pvb.setPageSessionAttribute(
450:                        TaxonomyBrowserView.SESION_ATTR_BROWSING_ON, "true");
451:                pvb.setPageSessionAttribute("editTimeStamp", editTimeStamp);
452:                pvb.getRequestContext().getRequest().getSession().setAttribute(
453:                        TaxonomyBrowserView.SESION_ATTR_SELECTED_TAX
454:                                + editTimeStamp,
455:                        (currTax == null ? new String[0] : currTax));
456:                /*
457:                 pvb.setPageSessionAttribute("DynamicGUI", map);
458:                 pvb.setPageSessionAttribute(TaxonomyBrowserView.SESION_ATTR_BROWSING_ON, "true");
459:                 pvb.setPageSessionAttribute(TaxonomyBrowserView.SESION_ATTR_SELECTED_TAX, (currTax == null ? new String[0]:currTax));
460:                 */
461:                debugLogger.finer("PSSH_CSPSA0083");
462:                pvb.forwardTo(getRequestContext());
463:            }
464:
465:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.