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


001:        /*
002:         * Copyright 2005 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.db;
007:
008:        import com.sun.portal.search.rdm.*;
009:        import com.sun.portal.search.soif.*;
010:        import com.sun.portal.search.util.*;
011:
012:        import com.google.soap.search.*;
013:
014:        import java.util.*;
015:        import java.io.*;
016:
017:        /**
018:         *
019:         * Search engine interface implementation using Google search API
020:         *
021:         */
022:        public class GoogleDb implements  RDMDb {
023:
024:            /** Google search engine API authorization key */
025:            private String clientKey;
026:
027:            /** http proxy host for Google search SOAP connection */
028:            private String proxyHost = "";
029:
030:            /** http proxy port for Google search SOAP connection */
031:            private String proxyPort = "";
032:
033:            /**
034:             * Open a database
035:             * @param st Token for search
036:             * @param rootdir Database home dir
037:             * @param dbname Name of database from root database
038:             * @param rw RDMDb.WRITER or RDMDb.WRCREAT or RDMDb.READER
039:             * @param mode Unix mode
040:             * @throws RDMException
041:             */
042:            public void open(SToken st, String rootdir, String dbname, int rw,
043:                    int mode) throws RDMException {
044:                SOIF dbsoif = DbManager.getRootDbEntry(st, dbname);
045:                clientKey = dbsoif.getValue("clientKey");
046:                proxyHost = dbsoif.getValue("proxyHost");
047:                proxyPort = dbsoif.getValue("proxyPort");
048:            }
049:
050:            /**
051:             * Close database and index extents
052:             * @param st Token for search
053:             * @throws RDMException
054:             */
055:            public void close(SToken st) throws RDMException {
056:                ;//do nothing
057:            }
058:
059:            /**
060:             * Empty the database
061:             * @param st Token for search
062:             * @param t RDM transaction handle
063:             * @throws RDMException
064:             */
065:            public int purge(SToken st, RDMTransaction t) throws RDMException {
066:                throw new RDMException("GoogleDb.purge() not implemented");
067:            }
068:
069:            /**
070:             * Obtain the name for the search engine interface
071:             * @return the name of the search engine activity
072:             */
073:            public String getName() {
074:                return "Google Search";
075:            }
076:
077:            /**
078:             * Submit the query to the search engine
079:             * @param st Token for search
080:             * @param query Search query
081:             * @param numHits Number of hits
082:             * @param view Set of attributes to be retrieved
083:             * @param sortOrder Order for sorting the results
084:             * @param t RDM transaction handle
085:             * @return RDMResultSet
086:             * @throws RDMException  
087:             */
088:            public RDMResultSet search(SToken st, String query, int numHits,
089:                    Set view, String sortOrder, RDMTransaction t)
090:                    throws RDMException {
091:
092:                //Google search result set
093:                GoogleSearchResult gsr;
094:
095:                try {
096:                    gsr = googleSearch(clientKey, "search", query);
097:                } catch (GoogleSearchFault f) {
098:                    throw new RDMException(f);
099:                }
100:
101:                GoogleResultSet rs = new GoogleResultSet(st, this , query, t);
102:                rs.setGoogleSearchResult(gsr);
103:                rs.setView(view);
104:                return rs;
105:            }
106:
107:            /**
108:             * Call the Google APIs service to search Google
109:             * @param clientKey Google API authorization key
110:             * @param directive Search method
111:             * @param directiveArg Search query
112:             * @return GoogleSearchResult
113:             * @throws GoogleSearchFault
114:             */
115:            GoogleSearchResult googleSearch(String clientKey, String directive,
116:                    String directiveArg) throws GoogleSearchFault {
117:
118:                // Create a Google Search object, set the authorization key
119:                GoogleSearch s = new GoogleSearch();
120:                s.setKey(clientKey);
121:
122:                if (proxyHost != null && !proxyHost.equals("")
123:                        && proxyHost.indexOf(" ") == -1) {
124:                    s.setProxyHost(proxyHost);
125:
126:                    if (proxyPort != null && !proxyPort.equals("")
127:                            && proxyPort.indexOf(" ") == -1) {
128:                        s.setProxyPort(Integer.parseInt(proxyPort));
129:                    }
130:                }
131:
132:                if (directive.equalsIgnoreCase("search")) {
133:                    s.setQueryString(directiveArg);
134:                    GoogleSearchResult gsr = s.doSearch();
135:                    return gsr;
136:                } else {
137:                    throw new GoogleSearchFault("Invalid directive");
138:                }
139:            }
140:
141:            /**
142:             * Number of documents in the database/index
143:             * @param st Token for search
144:             * @param t RDM transaction handle
145:             * @return search count
146:             * @throws RDMException
147:             */
148:            public int count(SToken st, RDMTransaction t) throws RDMException {
149:                return 2000000000;
150:            }
151:
152:            /**
153:             * Delete RD from database 
154:             * @param st Token for search
155:             * @param s SOIF document
156:             * @param view Set of attributes
157:             * @param flags Options
158:             * @param t RDM transaction handle
159:             * @throws RDMException
160:             */
161:            public void delete(SToken st, SOIF s, Set view, int flags,
162:                    RDMTransaction t) throws RDMException {
163:                throw new RDMException("GoogleDb.delete() not implemented");
164:            }
165:
166:            /**
167:             * Store - creates a transaction for atomic indexing, if none supplied.
168:             * @param st Token for search
169:             * @param soif SOIF document
170:             * @param view Set of Attributes
171:             * @param flags Options
172:             * @param t RDM transaction
173:             * @throws RDMException   
174:             */
175:            public void store(SToken st, SOIF soif, Set view, int flags,
176:                    RDMTransaction t) throws RDMException {
177:                throw new RDMException("GoogleDb.store() not implemented");
178:            }
179:
180:            /**
181:             * Update an RD with attributes set in View
182:             * @param st Token for search
183:             * @param insoif SOIF document
184:             * @param view Set of Attributes
185:             * @param flags Options
186:             * @param t RDM transaction
187:             * @throws RDMException   
188:             */
189:            public void update(SToken st, SOIF insoif, Set view, int flags,
190:                    RDMTransaction t) throws RDMException {
191:                throw new RDMException("GoogleDb.update() not implemented");
192:            }
193:
194:            /**
195:             * Retrieve RD from database, filtered by view
196:             * @param st Token for search
197:             * @param url URL string
198:             * @param view Set of Attributes
199:             * @param flags Options
200:             * @param t RDM transaction
201:             * @throws RDMException   
202:             */
203:            public SOIF fetch(SToken st, String url, Set view, int flags,
204:                    RDMTransaction t) throws RDMException {
205:                throw new RDMException("GoogleDb.fetch() not implemented");
206:            }
207:
208:            /**
209:             * Optimize the db
210:             * @param st Token for search
211:             * @throws RDMException   
212:             */
213:            public void optimize(SToken st) throws RDMException {
214:                throw new RDMException("GoogleDb.optimize() not implemented");
215:            }
216:
217:            /**
218:             * Batch Index
219:             * @param st Token for search
220:             * @throws RDMException   
221:             */
222:            public void indexBatch(SToken st) throws RDMException {
223:                throw new RDMException("GoogleDb.indexBatch() not implemented");
224:            }
225:
226:            /**
227:             * Recover the db - must be run stand alone (ie, no one else has the db open)
228:             * @param st Token for search
229:             * @param dbhome Database home dir
230:             * @param fatal Option
231:             * @throws RDMException   
232:             */
233:            public void recover(SToken st, String dbhome, boolean fatal)
234:                    throws RDMException {
235:                throw new RDMException("GoogleDb.recover() not implemented");
236:            }
237:
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.