Source Code Cross Referenced for RDListModel.java in  » Portal » Open-Portal » com » sun » portal » search » admin » model » 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.model 
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.model;
007:
008:        import java.lang.*;
009:        import java.util.*;
010:        import java.util.logging.Logger;
011:        import java.util.logging.Level;
012:        import java.io.*;
013:        import java.net.*;
014:        import javax.servlet.http.HttpServletRequest;
015:
016:        import com.iplanet.jato.model.*;
017:        import com.iplanet.jato.view.html.*;
018:        import com.iplanet.jato.util.Encoder;
019:        import com.sun.portal.search.admin.CSConfig;
020:        import com.sun.portal.search.admin.RDSearch;
021:        import com.sun.portal.search.util.SearchConfig;
022:        import com.sun.portal.search.admin.resources.SearchResource;
023:        import com.sun.portal.search.soif.*;
024:        import com.sun.portal.search.rdm.*;
025:        import com.sun.portal.search.db.SToken;
026:        import com.sun.portal.log.common.PortalLogger;
027:
028:        import com.sun.portal.util.Platform;
029:
030:        /**
031:         * This class supports the MenuListView by providing the data in the
032:         * format expected by the view.
033:         */
034:        public class RDListModel extends DefaultModel implements  DatasetModel,
035:                RetrievingModel, DeletingModel {
036:            public static final String MODEL_NAME = "RDListModel";
037:            public static final String FIELD_URL = "Url";
038:            public static final String FIELD_TITLE = "Title";
039:            public static final String FIELD_DESC = "Desc";
040:            public static final String FIELD_DELETE = "Delete";
041:            public static final String FIELD_ENCODED_URL = "EncodedName";
042:            public Locale userLocale = Locale.getDefault();
043:
044:            public int numPerPage = 25;
045:            public int currPage = 1;
046:            public int totalHits = 0;
047:            String queryString = "*";
048:            String database = null;
049:            int searchOption = 1;
050:            private SToken st = null;
051:
052:            public int RDM_Results = 0;
053:            public int RDM_Hits = 0;
054:            public int RDM_Documents = 0;
055:            private boolean isRetrieved = false;
056:
057:            private String schfn = "";
058:
059:            // Create a Logger for this class
060:            private static Logger debugLogger = PortalLogger
061:                    .getLogger(RDListModel.class);
062:
063:            /**
064:             * @param req The HttpServletRequest object passed to the super class.
065:             * @param rbName The name of the resource bundle.
066:             */
067:            public RDListModel() {
068:                super ();
069:            }
070:
071:            // Model execution methods
072:            ////////////////////////////////////////////////////////////////////////////////
073:
074:            /**
075:             *
076:             *
077:             */
078:            public Object execute(ModelExecutionContext context)
079:                    throws ModelControlException {
080:                String operationName = null;
081:                if (context != null)
082:                    operationName = context.getOperationName();
083:                else
084:                    operationName = ModelExecutionContext.OPERATION_RETRIEVE;
085:
086:                Object result = null;
087:                if (operationName
088:                        .equals(ModelExecutionContext.OPERATION_RETRIEVE)) {
089:                    result = retrieve(context);
090:                } else if (operationName
091:                        .equals(ModelExecutionContext.OPERATION_DELETE)) {
092:                    result = delete(context);
093:                }
094:
095:                return result;
096:            }
097:
098:            /**
099:             *
100:             *
101:             */
102:            public Object delete(ModelExecutionContext context)
103:                    throws ModelControlException {
104:                String tmpFile = CSConfig.getServerRoot() + File.separator
105:                        + "tmp" + File.separator + "tmpRDEditor."
106:                        + Long.toString(System.currentTimeMillis());
107:                SOIFOutputStream so;
108:                try {
109:                    so = new SOIFOutputStream(tmpFile);
110:
111:                    beforeFirst();
112:                    while (next()) {
113:                        String isDelete = (String) getValue(FIELD_DELETE);
114:                        if (isDelete != null
115:                                && isDelete.equalsIgnoreCase("true")) {
116:                            try {
117:                                String delURL = new String(
118:                                        Encoder
119:                                                .decodeBase64((String) getValue(FIELD_ENCODED_URL)),
120:                                        "UTF-8");
121:                                debugLogger.log(Level.FINER, "PSSH_CSPSAM0035",
122:                                        delURL);
123:                                SOIF delRD = new SOIF("DOCUMENT", delURL);
124:                                so.write(delRD);
125:                            } catch (Exception e) {
126:                                debugLogger.log(Level.INFO, "PSSH_CSPSAM0012",
127:                                        e.getMessage());
128:                            }
129:                        }
130:                    }
131:                    so.close();
132:                    Runtime rt = Runtime.getRuntime();
133:                    String db_option = (database != null) ? "-y " + database
134:                            + " " : " ";
135:                    String runCsCli = null;
136:                    runCsCli = Platform.getCommand("run-cs-cli");
137:                    String rdmgr = CSConfig.getServerRoot() + File.separator
138:                            + runCsCli + " rdmgr -d -q " + db_option + tmpFile;
139:
140:                    debugLogger.log(Level.FINER, "PSSH_CSPSAM0033", rdmgr);
141:                    Process p = rt.exec(rdmgr);
142:                    try {
143:                        p.waitFor();
144:                    } catch (java.lang.InterruptedException e) {
145:                        // Might need to do something here
146:                    }
147:                    int exitValue = p.exitValue();
148:                    if (exitValue == 1) {
149:                        debugLogger.log(Level.FINER, "PSSH_CSPSAM0033", Integer
150:                                .toString(exitValue));
151:                    }
152:
153:                } catch (Exception e) {
154:                    throw new ModelControlException(e);
155:                }
156:
157:                return null;
158:            }
159:
160:            private ArrayList actionSearch() {
161:                debugLogger.log(Level.FINER, "PSSH_CSPSAM0037", new String[] {
162:                        Integer.toString(searchOption), queryString });
163:
164:                // XXX try to init SearchServlet in order to use RDMUIBridge
165:                //HttpServletRequest req = getRequestContext().getRequest();
166:                //CSConfig.initSearch((req.isSecure()? "https":"http") + "://" + req.getServerName() + ":" + req.getServerPort()
167:                //                   + CSConfig.getDynamicURI() + "/search");
168:                try {
169:                    RDSearch rdSearch = new RDSearch();
170:                    ArrayList resultList = rdSearch.search(database,
171:                            queryString, searchOption, (currPage - 1)
172:                                    * numPerPage + 1, numPerPage, st);
173:                    RDM_Results = rdSearch.RDM_Results;
174:                    if (searchOption == 5 && RDM_Results == 1) {
175:                        RDM_Hits = 1;
176:                        RDM_Documents = 1;
177:                    } else {
178:                        RDM_Hits = rdSearch.RDM_Hits;
179:                        RDM_Documents = rdSearch.RDM_Documents;
180:                    }
181:                    return resultList;
182:
183:                } catch (Exception e) {
184:                    return null;
185:                }
186:            }
187:
188:            /**
189:             *
190:             *
191:             */
192:            public Object retrieve(ModelExecutionContext context)
193:                    throws ModelControlException {
194:                if (isRetrieved) {
195:                    return null;
196:                }
197:                clear();
198:                ArrayList hits = actionSearch();
199:                if (hits != null) {
200:                    /*adjust currpage to last page if it's out of range*/
201:                    for (int i = 0; i < hits.size(); i++) {
202:                        SOIF s = (SOIF) hits.get(i);
203:                        appendRow();
204:                        String url = s.getURL();
205:                        String base64url = url;
206:                        try {
207:                            base64url = new String(Encoder.encodeBase64(url
208:                                    .getBytes("UTF-8")));
209:                        } catch (Exception e) {
210:                        }
211:
212:                        setValue(FIELD_URL, url);
213:                        setValue(FIELD_TITLE, s.getValue("title"));
214:                        setValue(FIELD_ENCODED_URL, base64url);
215:                    }
216:                }
217:                beforeFirst();
218:                isRetrieved = true;
219:
220:                // Nothing useful to return
221:                return null;
222:            }
223:
224:            public void setDatabase(String database) {
225:                this .database = database;
226:            }
227:
228:            /* the search is actually done in model retrieve function */
229:            public int doSearch(String database, int numPerPage, int currPage,
230:                    String queryString, int searchOption, SToken st) {
231:                this .numPerPage = numPerPage;
232:                this .currPage = currPage;
233:                this .queryString = queryString;
234:                this .searchOption = searchOption;
235:                this .database = database;
236:                this .st = st;
237:                try {
238:                    this .retrieve(null);
239:                } catch (Exception e) {
240:                }
241:                return totalHits;
242:            }
243:
244:            static public boolean isWindows() {
245:                if (System.getProperty("os.name").startsWith("Windows")) {
246:                    return true;
247:                } else {
248:                    return false;
249:                }
250:            }
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.