Source Code Cross Referenced for RDSearch.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 com.sun.portal.search.rdm.*;
009:        import com.sun.portal.search.rdmserver.*;
010:        import com.sun.portal.search.soif.*;
011:        import com.sun.portal.search.util.*;
012:        import com.sun.portal.search.db.SToken;
013:        import com.sun.portal.log.common.PortalLogger;
014:
015:        import java.io.*;
016:        import java.util.*;
017:        import java.util.logging.Level;
018:        import java.util.logging.Logger;
019:        import java.text.*;
020:        import java.net.*;
021:
022:        /**
023:         *  RDSearch:
024:         *      Server-side glue for RDEditor Search
025:         */
026:        public class RDSearch {
027:
028:            public int RDM_Results = 0;
029:            public int RDM_Hits = 0;
030:            public int RDM_Documents = 0;
031:
032:            // Create a Logger for this class
033:            private static Logger debugLogger = PortalLogger
034:                    .getLogger(RDSearch.class);
035:
036:            public RDSearch() {
037:            }
038:
039:            /*    public ArrayList search(String queryString, int searchBy, int startHits, int viewHits)
040:             throws Exception {
041:             return search(null, queryString, searchBy, startHits, viewHits, null);
042:             }*/
043:            public ArrayList search(String database, String queryString,
044:                    int searchBy, int startHits, int viewHits) throws Exception {
045:                return search(database, queryString, searchBy, startHits,
046:                        viewHits, null);
047:            }
048:
049:            /*
050:             public ArrayList search(String queryString, int searchBy, int startHits, int viewHits, SToken st)
051:             throws Exception {
052:             return search(null, queryString, searchBy, startHits, viewHits, st, null);
053:             }
054:             */
055:            public ArrayList search(String database, String queryString,
056:                    int searchBy, int startHits, int viewHits, SToken st)
057:                    throws Exception {
058:                return search(database, queryString, searchBy, startHits,
059:                        viewHits, st, null);
060:            }
061:
062:            public ArrayList search(String database, String queryString,
063:                    int searchBy, int startHits, int viewHits, SToken st,
064:                    String view) throws Exception {
065:
066:                // Convert RDM Header information
067:                debugLogger.log(Level.FINER, "PSSH_CSPSA0087", new String[] {
068:                        Integer.toString(searchBy), queryString });
069:                String type = "rd-request";
070:                String ql = "search";
071:                String scope = queryString;
072:
073:                switch (searchBy) {
074:                case 1:
075:                    scope = "*";
076:                    break;
077:                case 2:
078:                    scope = "<not> (CLASSIFICATION!=\"\")";
079:                    break;
080:                case 3:
081:                    scope = "(Classification!=\"\")";
082:                    break;
083:                case 4:
084:                    scope = "(Classification=\"" + queryString + "\")";
085:                    break;
086:                case 5:
087:                    ql = "url";
088:                    break;
089:                case 6:
090:                    break;
091:                }
092:                RDMHeader hdr = null;
093:                try {
094:                    hdr = new RDMHeader(type, null, ql, null);
095:                } catch (Exception e) {
096:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
097:                            .getMessage());
098:                }
099:
100:                // Convert RDM Query information
101:                String hits = startHits + ".." + (startHits + viewHits - 1);
102:
103:                RDMQuery qry = new RDMQuery(scope);
104:                qry.setViewHits(hits);
105:                if (searchBy != 5) {
106:                    qry.setViewAttr("url,title");
107:                }
108:                if (view != null) {
109:                    qry.setViewAttr(view);
110:                }
111:
112:                if (database != null) {
113:                    qry.setDatabase(database);
114:                }
115:
116:                SOIFBuffer sb = new SOIFBuffer();
117:                SOIFOutputStream sos = new SOIFOutputStream(sb);
118:                sos.write(hdr.getSOIF());
119:                debugLogger.log(Level.FINER, "PSSH_CSPSA0092", hdr.getSOIF());
120:                sos.write(qry.getSOIF());
121:                debugLogger.log(Level.FINER, "PSSH_CSPSA0093", qry.getSOIF());
122:                byte[] ba = RDMUIBridge.rdmui_to_srv(sb.toByteArray(), st);
123:                SOIFInputStream sis = new SOIFInputStream(ba);
124:
125:                RDMHeader rdmHeader = new RDMHeader(sis);
126:                String resp = rdmHeader.getResponseInterpret();
127:                try {
128:                    RDM_Results = getKeyedInt(resp, "result");
129:                } catch (Exception e) {
130:                }
131:
132:                try {
133:                    RDM_Hits = getKeyedInt(resp, "hit");
134:                } catch (Exception e) {
135:                }
136:
137:                try {
138:                    RDM_Documents = getKeyedInt(resp, "document");
139:                } catch (Exception e) {
140:                }
141:                debugLogger.log(Level.FINER, "PSSH_CSPSA0094", new String[] {
142:                        String.valueOf(RDM_Results), String.valueOf(RDM_Hits),
143:                        String.valueOf(RDM_Documents) });
144:                ArrayList rs = new ArrayList();
145:                while (!sis.isEOS()) {
146:                    SOIF ss = sis.readSOIF();
147:                    if (ss != null) {
148:                        rs.add(ss);
149:                    }
150:                }
151:                debugLogger.log(Level.FINER, "PSSH_CSPSA0095", Integer
152:                        .toString(rs.size()));
153:                return rs;
154:            }
155:
156:            /**
157:             * Parses a keyed int out of a string, ie, "... nnn key ..."
158:             * throws NumberFormatException on failure
159:             */
160:            private int getKeyedInt(String str, String rawkey)
161:                    throws NumberFormatException {
162:                int res = 0;
163:                try {
164:                    int i, n1, n2;
165:                    String key = " " + rawkey; // need space(s) before key
166:                    if ((i = str.indexOf(key)) <= 0)
167:                        throw (new Exception());
168:                    for (--i; i >= 0 && str.charAt(i) == ' '; --i)
169:                        ;
170:                    n2 = i + 1;
171:                    for (; i >= 0 && str.charAt(i) != ' '; --i)
172:                        ;
173:                    n1 = i + 1;
174:                    String s1 = str.substring(n1, n2);
175:                    //System.out.println("dbg: " + s1 + " " + n1 + " " + n2);
176:                    res = Integer.parseInt(s1);
177:                } catch (Exception e) {
178:                    throw new NumberFormatException();
179:                }
180:                return res;
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.