Source Code Cross Referenced for SubmitDemo.java in  » Portal » Open-Portal » com » sun » portal » search » demo » 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.demo 
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.demo;
007:
008:        import com.sun.portal.search.soif.*;
009:
010:        import java.applet.Applet;
011:        import java.awt.*;
012:        import java.net.*;
013:
014:        /**
015:         * Applet for populating the Search database. It uses the static
016:         * strings defined below for input. The basic process is to convert
017:         * the input to SOIF and then add it to the database using rdsubmit.
018:         * If you are adding a lot of data, you will probably want to batch
019:         * the input to rdsubmit. You are not limited to just the DB fields
020:         * used in this example, you can add any fields at all and they will
021:         * behave according to their schema definitions, if any.
022:         */
023:
024:        class SimpleSubmit {
025:
026:            public static final String DATA_URL[] = { "http://url1",
027:                    "http://url2", "http://url3" };
028:            public static final String DATA_CLASS[] = { "Cars", "Boats",
029:                    "Planes" };
030:            public static final String DATA_DESC[] = { "Document 1",
031:                    "Document 2", "Document 3" };
032:
033:            String RDMServer;
034:            String dbname;
035:            String SOIFOutputFile;
036:
037:            /**
038:             * SimpleSubmit constructor
039:             * @param rdm - url of rdm server, eg, http://search_server:port
040:             * @param db - the database to submit to on this rdm server
041:             * if null, server will use the default db
042:             */
043:            public SimpleSubmit(String rdm, String db) {
044:                System.out.println("Sun ONE Search Java Submit Demo\n");
045:                RDMServer = rdm;
046:                dbname = db;
047:            }
048:
049:            public void doSubmit() throws Exception {
050:
051:                try {
052:                    URLConnection pc = new URL(RDMServer).openConnection();
053:                    pc.setAllowUserInteraction(true);
054:                    pc.setUseCaches(false);
055:                    pc.setDoOutput(true);
056:                    pc.setDoInput(true);
057:                    SOIFOutputStream sos = new SOIFOutputStream(pc
058:                            .getOutputStream());
059:                    pc.connect();
060:
061:                    System.out.println(">>> Request\n");
062:                    SOIF hdr = new SOIF("RDMHEADER", "-");
063:                    hdr.insert("rdm-type", "rd-submit-request");
064:                    if (dbname != null)
065:                        hdr.insert("submit-database", dbname);
066:                    sos.write(hdr);
067:                    System.out.print(hdr);
068:
069:                    /*
070:                    // submit request header
071:                    // - specifies the operation to be performed on each submitted RD
072:                    String SUBMIT_TYPE		= "submit-type";	// see below
073:                    String SUBMIT_OPER		= "submit-operation";	// see below
074:                    String SUBMIT_VIEW		= "submit-view";	// attribute list, eg, title,author,classification
075:                    
076:                    // submit types 
077:                    // - controls the type of data processed
078:                    String SUBMIT_PERSISTENT	= "persistent";	    // persistent RD data only
079:                    String SUBMIT_NONPERSISTENT = "nonpersistent";  // non-persistent RD data only
080:                    String SUBMIT_MERGED	= "merged";	    // merged P/NP data (with P attributes 'covering' NP attributes)
081:
082:                    // submit operations
083:                    String SUBMIT_RETRIEVE	= "retrieve";	    // fetch RDs filtered by submit-view
084:                    String SUBMIT_INSERT	= "insert";	    // insert/replace entire RDs
085:                    String SUBMIT_DELETE	= "delete";	    // delete entire RDs
086:                    String SUBMIT_UPDATE	= "update";	    // update the given RD attributes only, can also be filtered by submit-view
087:                     */
088:
089:                    SOIF req = new SOIF("Request", "-");
090:                    req.insert("submit-type", "nonpersistent");
091:                    req.insert("submit-operation", "retrieve");
092:                    req.insert("submit-view", "classification,description");
093:                    sos.write(req);
094:                    System.out.print(req);
095:
096:                    for (int i = 0; i < DATA_URL.length; i++) {
097:                        SOIF doc = new SOIF("DOCUMENT", DATA_URL[i]);
098:                        doc.insert("classification", DATA_CLASS[i]);
099:                        doc.insert("description", DATA_DESC[i]);
100:                        sos.write(doc);
101:                        System.out.print(doc);
102:                    }
103:                    sos.close();
104:
105:                    System.out.println(">>> Response\n");
106:                    SOIFInputStream sis = new SOIFInputStream(pc
107:                            .getInputStream());
108:                    SOIF s;
109:                    while ((s = sis.readSOIF()) != null)
110:                        System.out.println(s);
111:
112:                    System.out.println("Done: " + DATA_URL.length
113:                            + " RDs processed.\n");
114:
115:                } catch (Exception e) {
116:                    System.out.println("Error: " + e);
117:                    throw e;
118:                }
119:
120:            }
121:
122:            /**
123:             * @param filename - a file to dump raw SOIF results into - only
124:             * use if running from the command line or an applet with file
125:             * system access
126:             */
127:            public void setSOIFfile(String filename) {
128:                SOIFOutputFile = filename;
129:            }
130:
131:        }
132:
133:        class SubmitPanel extends Panel {
134:
135:            Button submitBtn;
136:            TextField submitLog;
137:            SimpleSubmit ss;
138:
139:            /** C'tor */
140:            public SubmitPanel(SimpleSubmit ss) {
141:                this .ss = ss;
142:                submitBtn = new Button("Submit");
143:                submitLog = new TextField("", 40);
144:                submitLog.setEditable(false);
145:                setLayout(new FlowLayout(FlowLayout.CENTER));
146:                add(submitBtn);
147:                add(submitLog);
148:            }
149:
150:            public void actionPerformed(java.awt.event.ActionEvent e) {
151:                if (e.getID() == Event.ACTION_EVENT) {
152:                    submitBtn.setEnabled(false);
153:                    try {
154:                        ss.doSubmit();
155:                    } catch (Exception ex) {
156:                        System.out.println("Exception during submit: " + ex);
157:                    }
158:                    submitBtn.setEnabled(true);
159:                } else
160:                    super .processEvent(e);
161:            }
162:
163:        }
164:
165:        public class SubmitDemo extends Applet {
166:
167:            /** Run as an applet. */
168:            public void init() {
169:                String rdm = getParameter("RDMServer");
170:                String db = getParameter("Database");
171:                SimpleSubmit ss = new SimpleSubmit(rdm, db);
172:                SubmitPanel sp = new SubmitPanel(ss);
173:                setLayout(new FlowLayout(FlowLayout.CENTER));
174:                add(sp);
175:            }
176:
177:            /** Run as an application. */
178:            public static void main(String argv[]) throws Exception {
179:
180:                int args = argv.length;
181:                String SOIFOutputFile = null;
182:
183:                if (args != 1 && args != 2 && args != 3) {
184:                    System.out
185:                            .println("args: RDMServer [soif_output_file_name]");
186:                    return;
187:                }
188:
189:                String rdm = argv[0]; // rdm server, eg, http://server:port
190:                String db = null; // server will use default db
191:
192:                SimpleSubmit ss = new SimpleSubmit(rdm, db);
193:
194:                if (args == 2) {
195:                    --args;
196:                    ss.setSOIFfile(argv[1]); // dump raw soif results to this file
197:                }
198:
199:                // run from command line
200:                ss.doSubmit();
201:
202:            }
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.