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


001:        package com.sun.portal.search.rdmgr;
002:
003:        import java.io.*;
004:        import java.util.*;
005:        import com.sun.portal.search.soif.*;
006:        import com.sun.portal.search.rdm.*;
007:        import com.sun.portal.search.util.*;
008:
009:        //import com.sun.portal.search.rdmgr.*;
010:        //import org.w3c.util.*;
011:
012:        public class SearchMigrate extends SearchSetup {
013:            static private String oldversion = "301csp1";
014:            private String search_list = null;
015:
016:            void create_filter_files(String old_base, String old_server_root,
017:                    String server_root) throws Exception {
018:                // not keyview
019:                if (oldversion.equals("301b"))
020:                    return;
021:
022:                BufferedReader in = null;
023:                PrintWriter out = null;
024:                try {
025:                    in = new BufferedReader(new FileReader(old_server_root
026:                            + File.separator + "config" + File.separator
027:                            + "default.cfg"));
028:                    out = new PrintWriter(new BufferedWriter(new FileWriter(
029:                            server_root + File.separator + "config"
030:                                    + File.separator + "converter.cfg")));
031:                    String line;
032:                    boolean done_charset = false;
033:                    while ((line = in.readLine()) != null) {
034:                        String tmp;
035:                        if (line.startsWith("charset")) {
036:                            tmp = line.substring(7).trim();
037:                            if (tmp.equalsIgnoreCase("utf8")) {
038:                                done_charset = true;
039:                            } else {
040:                                out.println("#charset        " + tmp);
041:                                continue;
042:                            }
043:                        } else if (!done_charset && line.startsWith("#charset")) {
044:                            tmp = line.substring(8).trim();
045:                            if (tmp.equalsIgnoreCase("utf8")) {
046:                                out.println("charset        " + tmp);
047:                                done_charset = true;
048:                                continue;
049:                            }
050:                        } else if (line.startsWith("template")) {
051:                            String src = old_server_root + File.separator
052:                                    + "config" + File.separator
053:                                    + "template.htm";
054:                            String dest = server_root + File.separator
055:                                    + "config" + File.separator
056:                                    + "converter.template";
057:                            copy(src, dest);
058:                            out.println("template        " + dest);
059:                            continue;
060:                        }
061:                        out.println(line);
062:                    }
063:                    if (!done_charset)
064:                        out.println("charset        utf8");
065:                } finally {
066:                    if (in != null) {
067:                        in.close();
068:                    }
069:                    if (out != null) {
070:                        out.close();
071:                    }
072:                }
073:            }
074:
075:            void create_web_app(String web_app, String dynmic_uri, String psdir)
076:                    throws Exception {
077:
078:                boolean ok = true;
079:                String tmp = web_app + ".bak";
080:                BufferedReader in = null;
081:                PrintWriter out = null;
082:                try {
083:                    in = new BufferedReader(new FileReader(web_app));
084:                    out = new PrintWriter(new BufferedWriter(
085:                            new FileWriter(tmp)));
086:                    String line;
087:                    while ((line = in.readLine()) != null) {
088:                        out.println(line);
089:                        if (line.trim().equalsIgnoreCase("<vs>")) {
090:                            // rdmservlet only
091:                            out.println("<web-app uri=\"" + dynmic_uri
092:                                    + "\" dir=\"" + psdir + File.separator
093:                                    + "web-apps" + File.separator + "ps"
094:                                    + "\" enable=\"true\"/>");
095:                        }
096:                    }
097:                } catch (Exception e) {
098:                    System.out.print("Failed to modify web-apps.xml");
099:                    ok = false;
100:                }
101:                if (in != null) {
102:                    in.close();
103:                }
104:                if (out != null) {
105:                    out.close();
106:                }
107:                if (ok) {
108:                    copy(tmp, web_app);
109:                    File temp = new File(tmp);
110:                    temp.delete();
111:                }
112:            }
113:
114:            void store_conf_files(String src_dir) throws Exception {
115:                BufferedReader in = null;
116:                try {
117:                    in = new BufferedReader(new FileReader(src_dir
118:                            + File.separator + "rdm.conf"));
119:                    String line;
120:                    while ((line = in.readLine()) != null) {
121:                        if (line.indexOf("disable-rdm-log") >= 0) {
122:                            search_list = line;
123:                        }
124:                    }
125:                } finally {
126:                    if (in != null) {
127:                        in.close();
128:                    }
129:                }
130:            }
131:
132:            void create_conf_file(String src_dir, String dest_dir,
133:                    String file_name, String del_list[], String src_list[],
134:                    String dest_list[]) throws Exception {
135:
136:                int n = src_list.length, dn = del_list.length;
137:                String in_file = file_name;
138:                if (file_name.equalsIgnoreCase("search.conf")) {
139:                    in_file = "csid.conf";
140:                }
141:                if (file_name.equalsIgnoreCase("robot.conf")) {
142:                    in_file = "process.conf";
143:                }
144:                // no more verity type
145:                if (file_name.equalsIgnoreCase("server.rdm")
146:                        && !oldversion.equals("301csp1")) {
147:                    return;
148:                }
149:                // not keyview
150:                if (file_name.equalsIgnoreCase("convert.conf")
151:                        && oldversion.equals("301b")) {
152:                    return;
153:                }
154:
155:                BufferedReader in = null;
156:                PrintWriter out = null;
157:                try {
158:                    in = new BufferedReader(new FileReader(src_dir
159:                            + File.separator + in_file));
160:                    out = new PrintWriter(new BufferedWriter(new FileWriter(
161:                            dest_dir + File.separator + file_name)));
162:                    String line;
163:                    boolean delit;
164:                    while ((line = in.readLine()) != null) {
165:                        delit = false;
166:                        for (int i = 0; i < dn; i++) {
167:                            if (line.indexOf(del_list[i]) >= 0) {
168:                                delit = true;
169:                                break;
170:                            }
171:                        }
172:                        if (delit)
173:                            continue;
174:                        for (int i = 0; i < n; i++) {
175:                            line = replace(line, src_list[i], dest_list[i]);
176:                        }
177:                        if (line.indexOf("database-root") >= 0) {
178:                            line = replace(line, "/root.db", "");
179:                        }
180:                        out.println(line);
181:                    }
182:                    if (file_name.equalsIgnoreCase("search.conf")) {
183:                        out.println("security-mode=OFF");
184:                        out
185:                                .println("security-manager=com.sun.portal.search.rdmserver.DSameSecurityManager");
186:                        out.println("security-dsame-group=OFF");
187:                        out
188:                                .println("admin-category_editor_nodes_per_page=25,50,100,250,500,-1");
189:                        out
190:                                .println("admin-category_editor_max_combo_element=10");
191:
192:                        if (search_list != null)
193:                            out.println(search_list);
194:
195:                    }
196:                } finally {
197:                    if (in != null) {
198:                        in.close();
199:                    }
200:                    if (out != null) {
201:                        out.close();
202:                    }
203:                }
204:            }
205:
206:            public void modifySchema(String src_dir, String dest_dir)
207:                    throws Exception {
208:                ArrayList _to = null;
209:                ArrayList _from = null;
210:                boolean is_include = true;
211:                ArrayList gvlist = null;
212:
213:                String aliasfn = src_dir + File.separator + "alias.conf";
214:                try {
215:                    FileReader fr = new FileReader(aliasfn);
216:                    BufferedReader br = new BufferedReader(fr);
217:                    String nextLine = null;
218:                    StringTokenizer st = null;
219:                    String to = null;
220:                    int countTokens = 0;
221:                    _to = new ArrayList();
222:                    _from = new ArrayList();
223:                    while ((nextLine = br.readLine()) != null) {
224:                        if (!nextLine.startsWith("#")) {
225:                            StringBuffer from = new StringBuffer("");
226:                            // parse the entry
227:                            st = new StringTokenizer(nextLine);
228:                            // verify sanity of line
229:                            countTokens = st.countTokens();
230:                            if (countTokens < 1) {
231:                            } else {
232:                                // 1st token is the Soif Attribut
233:                                to = st.nextToken();
234:                                // rest of line is the list of space separated aliases
235:                                boolean is_1st = true;
236:                                String newAlias = null;
237:                                while (st.hasMoreTokens()) {
238:                                    newAlias = st.nextToken();
239:                                    if (!is_1st)
240:                                        from.append(",");
241:                                    from.append(newAlias);
242:                                    if (is_1st)
243:                                        is_1st = false;
244:                                }
245:                                // adding the entry in 
246:                                _from.add(from.toString().trim());
247:                                _to.add(to.trim());
248:                            }
249:                        }
250:                    }
251:                    br.close();
252:                    // setting to the first available conversion
253:                } catch (Exception e) {
254:                    throw new Exception("Can't read file [" + aliasfn + "]");
255:                }
256:
257:                String gvlistfn = src_dir + File.separator + "gvlist.conf";
258:                if (oldversion.equals("301b"))
259:                    gvlistfn = src_dir + File.separator + "gvList.conf";
260:
261:                try {
262:                    FileReader fr = new FileReader(gvlistfn);
263:                    BufferedReader br = new BufferedReader(fr);
264:                    String nextLine = null;
265:                    gvlist = new ArrayList();
266:                    boolean got_directive = false;
267:                    while ((nextLine = br.readLine()) != null) {
268:                        if (!nextLine.startsWith("#")) {
269:                            nextLine.trim();
270:                            if (!got_directive
271:                                    && nextLine.equalsIgnoreCase("include")) {
272:                                got_directive = true;
273:                                is_include = true;
274:                                continue;
275:                            } else if (!got_directive
276:                                    && nextLine.equalsIgnoreCase("exclude")) {
277:                                got_directive = true;
278:                                is_include = false;
279:                                continue;
280:                            }
281:                            gvlist.add(nextLine);
282:                        }
283:                    }
284:                    br.close();
285:                } catch (Exception e) {
286:                    throw new Exception("Can't read file [" + gvlistfn + "]");
287:                }
288:
289:                String schfn = dest_dir + File.separator + "schema.rdm";
290:                SOIFInputStream ss = null;
291:                RDMSchema schema = null;
292:                try {
293:                    ss = new SOIFInputStream(schfn);
294:                    schema = new RDMSchema(ss.readSOIF());
295:                } catch (Exception e) {
296:                    throw new Exception("Schema Unavailable: " + schfn);
297:                }
298:                ss.close();
299:
300:                for (int i = 0; i < schema.getMaxIndex(); i++) {
301:                    String is_internal = schema.getIsInternal(i);
302:                    if (is_internal != null) {
303:                        if (is_internal.length() > 0) {
304:                            try {
305:                                Integer.parseInt(is_internal);
306:                            } catch (NumberFormatException e) {
307:                                is_internal = "1";
308:                                schema.setIsInternal(i, is_internal);
309:                            }
310:                        } else {
311:                            is_internal = "0";
312:                            schema.setIsInternal(i, is_internal);
313:                        }
314:                    }
315:
316:                    int j;
317:                    String attr = schema.getSOIFAttribute(i);
318:                    if (attr == null)
319:                        continue;
320:
321:                    for (j = 0; j < _to.size(); j++) {
322:                        if (attr.equalsIgnoreCase((String) _to.get(j))) {
323:                            schema.setAliases(i, (String) _from.get(j));
324:                            break;
325:                        }
326:                    }
327:                    boolean found_it = false;
328:                    String value = "0";
329:                    for (j = 0; j < gvlist.size(); j++) {
330:                        if (attr.equalsIgnoreCase((String) gvlist.get(j))) {
331:                            found_it = true;
332:                            break;
333:                        }
334:                    }
335:                    if (found_it) {
336:                        if (is_include)
337:                            value = "1";
338:                    } else {
339:                        if (!is_include)
340:                            value = "1";
341:                    }
342:                    schema.setIsAlertable(i, value);
343:                }
344:
345:                try {
346:                    SOIFOutputStream so = new SOIFOutputStream(schfn);
347:                    so.write(schema.getSOIF());
348:                    so.close();
349:                } catch (Exception e) {
350:                    throw new Exception("Unable to write SOIF to " + schfn
351:                            + ": " + e);
352:                }
353:            }
354:
355:            public void Schema_60_to_62(String dest_dir) throws Exception {
356:                int index_fields = 2;
357:                String pk_fields[] = {
358:                        "rd-last-changed",
359:                        "date when the document was last rated or commented upon",
360:                        "date", "rd-reference-url",
361:                        "Reference Document from the web", "string",
362:                        "rd-reference-id", "Parent ID in the discussion",
363:                        "string", "rd-author-id", "author basedn from IS",
364:                        "string", "rd-rating",
365:                        "Current rating of the document", "int",
366:                        "rd-sum-rating", "Sum of all ratings of the document",
367:                        "int", "rd-peak-rating",
368:                        "Highest rating of the document", "int",
369:                        "rd-num-rating",
370:                        "Number of time the document is rated", "int" };
371:
372:                String schfn = dest_dir + File.separator + "schema.rdm";
373:                SOIFInputStream ss = null;
374:                RDMSchema schema = null;
375:                try {
376:                    ss = new SOIFInputStream(schfn);
377:                    schema = new RDMSchema(ss.readSOIF());
378:                } catch (Exception e) {
379:                    throw new Exception("Schema Unavailable: " + schfn);
380:                }
381:                ss.close();
382:
383:                int j = schema.getMaxIndex() + 1; // next
384:                for (int i = 0; i < pk_fields.length; i += 3, j++) {
385:
386:                    // is_internal, String type
387:                    schema.setSOIFAttribute(j, pk_fields[i]);
388:                    schema.setDescription(j, pk_fields[i + 1]);
389:                    schema.setDataType(j, pk_fields[i + 2]);
390:                    schema.setIsInternal(j, "1");
391:                    schema.setTableName(j, pk_fields[i]);
392:                    schema.setColumnName(j, pk_fields[i]);
393:                    schema.setSysTableName(j, "classtbl");
394:                    schema.setSysColumnName(j, pk_fields[i]);
395:                    schema.setInRoot(j, "1");
396:                    schema.setIndexAttribute(j, i < index_fields * 3 ? "1"
397:                            : "0");
398:                }
399:
400:                String gv_fields[] = { "gv-classification", "gv-classified",
401:                        "gv-discussion-id", "gv-last-modified",
402:                        "gv-num-rating", "gv-peak-rating", "gv-rating",
403:                        "gv-reference-id", "gv-sum-rating" };
404:
405:                for (int i = 0; i < gv_fields.length; i++) {
406:                    schema.deleteColumn(gv_fields[i]);
407:                }
408:
409:                try {
410:                    SOIFOutputStream so = new SOIFOutputStream(schfn);
411:                    so.write(schema.getSOIF());
412:                    so.close();
413:                } catch (Exception e) {
414:                    throw new Exception("Unable to write SOIF to " + schfn
415:                            + ": " + e);
416:                }
417:            }
418:
419:            // 6.0 and 6.1 are sol only
420:            public void searchconf_60_to_62(String base_dir, String filename)
421:                    throws Exception {
422:                boolean ok = true;
423:                String tmp = filename + ".bak";
424:                BufferedReader in = null;
425:                PrintWriter out = null;
426:                try {
427:                    in = new BufferedReader(new FileReader(filename));
428:                    out = new PrintWriter(new BufferedWriter(
429:                            new FileWriter(tmp)));
430:                    String line;
431:                    while ((line = in.readLine()) != null) {
432:                        out.println(line);
433:                    }
434:                    String jss_nss_nspr_lib = "/usr/lib/mps/secv1";
435:                    String jss_nss_nspr_cert7_lib = "/usr/lib/mps";
436:
437:                    if (System.getProperty("os.name").startsWith("HP-UX")) {
438:                        jss_nss_nspr_lib = "/opt/sun/private/lib";
439:                        jss_nss_nspr_cert7_lib = "/opt/sun/private/lib";
440:                    }
441:                    if (System.getProperty("os.name").startsWith("Linux")) {
442:                        jss_nss_nspr_lib = "/opt/sun/private/lib";
443:                        jss_nss_nspr_cert7_lib = "/opt/sun/private/lib";
444:                    }
445:
446:                    // add libpath for new nss libs
447:                    out.println("libpath=\"" + base_dir + "/portal/lib:"
448:                            + jss_nss_nspr_lib + ":" + jss_nss_nspr_cert7_lib
449:                            + ":/usr/lib/lwp\"");
450:                    // add libpath for new nss libs
451:                    out.println("libpath=\"" + base_dir + "/SUNWps/lib:"
452:                            + jss_nss_nspr_lib + ":" + jss_nss_nspr_cert7_lib
453:                            + ":/usr/lib/lwp\"");
454:                } catch (Exception e) {
455:                    System.out.print("Failed to modify search.conf");
456:                    ok = false;
457:                }
458:                if (in != null) {
459:                    in.close();
460:                }
461:                if (out != null) {
462:                    out.close();
463:                }
464:                if (ok) {
465:                    copy(tmp, filename);
466:                    File temp = new File(tmp);
467:                    temp.delete();
468:                }
469:            }
470:
471:            public void migrate_60to62(String base_dir, String old_server_root)
472:                    throws Exception {
473:                String confdestdir = old_server_root + File.separator
474:                        + "config";
475:                Schema_60_to_62(confdestdir);
476:                if (isWindows()) {
477:                    gen_script(base_dir, old_server_root, TYPE_SHELL, HTTP_IWS,
478:                            "run-cs-cli.bat", "%*", "PortalServer");
479:                    gen_script(base_dir, old_server_root, TYPE_JAVA, HTTP_IWS,
480:                            "StartRobot.bat",
481:                            "com.sun.portal.search.admin.cli.RobotController "
482:                                    + old_server_root + " start",
483:                            "PortalServer");
484:                    gen_script(base_dir, old_server_root, TYPE_JAVA, HTTP_IWS,
485:                            "StopRobot.bat",
486:                            "com.sun.portal.search.admin.cli.RobotController "
487:                                    + old_server_root + " stop", "PortalServer");
488:                    searchconf_60_to_62(base_dir, confdestdir + File.separator
489:                            + "search.conf");
490:                }
491:
492:                else {
493:
494:                    gen_script(base_dir, old_server_root, TYPE_SHELL, HTTP_IWS,
495:                            "run-cs-cli", "\"$@\"", "SUNWps");
496:                    gen_script(base_dir, old_server_root, TYPE_JAVA, HTTP_IWS,
497:                            "StartRobot",
498:                            "com.sun.portal.search.admin.cli.RobotController "
499:                                    + old_server_root + " start", "SUNWps");
500:                    gen_script(base_dir, old_server_root, TYPE_JAVA, HTTP_IWS,
501:                            "StopRobot",
502:                            "com.sun.portal.search.admin.cli.RobotController "
503:                                    + old_server_root + " stop", "SUNWps");
504:                    searchconf_60_to_62(base_dir, confdestdir + File.separator
505:                            + "search.conf");
506:                }
507:
508:                // reindex
509:                /* not required Process q = 
510:                Runtime.getRuntime().exec("\"" + old_server_root + File.separator + 
511:                        "run-cs-cli\" rdmgr -I ");
512:                q.waitFor(); */
513:                System.out.println("6.0/6.1 to 6.2 search migration completed");
514:            }
515:
516:            public void migrate_instance(String old_base,
517:                    String old_server_root, String old_csid, String base_dir,
518:                    String nick, String server_root, int http_type,
519:                    String csid, String charset) throws Exception {
520:
521:                String psdir = base_dir + File.separator + "SUNWps";
522:                String confsrcdir = old_server_root + File.separator + "config";
523:                String confdestdir = server_root + File.separator + "config";
524:
525:                File ctmp = new File(confdestdir);
526:                if (!ctmp.isDirectory()) { /* not there yet */
527:                    // server should be stopped 
528:                    try { // in case for an existing CS instance
529:                        mkdir(server_root, "config");
530:                        mkdir(server_root, "logs");
531:                        mkdir(server_root, "robot");
532:                        mkdir(server_root, "tmp");
533:                        mkdir(server_root, "db");
534:                        if (isWindows()) {
535:                            gen_script(base_dir, server_root, TYPE_SHELL,
536:                                    http_type, "run-cs-cli.bat", "%*",
537:                                    "PortalServer");
538:                            gen_script(base_dir, server_root, TYPE_JAVA,
539:                                    http_type, "StartRobot.bat",
540:                                    "com.sun.portal.search.admin.cli.RobotController "
541:                                            + server_root + " start",
542:                                    "PortalServer");
543:                            gen_script(base_dir, server_root, TYPE_JAVA,
544:                                    http_type, "StopRobot.bat",
545:                                    "com.sun.portal.search.admin.cli.RobotController "
546:                                            + server_root + " stop",
547:                                    "PortalServer");
548:                        } else {
549:                            gen_script(base_dir, server_root, TYPE_SHELL,
550:                                    http_type, "run-cs-cli", "$@", "SUNWps");
551:                            gen_script(base_dir, server_root, TYPE_JAVA,
552:                                    http_type, "StartRobot",
553:                                    "com.sun.portal.search.admin.cli.RobotController "
554:                                            + server_root + " start", "SUNWps");
555:                            gen_script(base_dir, server_root, TYPE_JAVA,
556:                                    http_type, "StopRobot",
557:                                    "com.sun.portal.search.admin.cli.RobotController "
558:                                            + server_root + " stop", "SUNWps");
559:                        }
560:                    } catch (Exception e) {
561:                        throw new Exception("Error during setup: " + e);
562:                    }
563:                } else {
564:                    try {
565:                        SearchConfig.init(confdestdir + File.separator
566:                                + "search.conf");
567:                        String new_csid = SearchConfig.getSearchConfig()
568:                                .getValue("csid");
569:                        csid = new_csid;
570:                    } catch (Exception e) {
571:                        throw new Exception("Failed to find target csid: " + e);
572:                    }
573:                }
574:
575:                try {
576:                    String del_list[] = { "nsir-collection-name",
577:                            "nsir-max-field-value", "-rdm-probe",
578:                            "Add Compass", "search-field-multipliers",
579:                            "valid-templates", "template-default",
580:                            "template-dir", "template-refresh-rate",
581:                            "compass-database-sync-rate",
582:
583:                            "query-language-translation", "nsir-config",
584:
585:                            "Compass Server" };
586:                    String[] src_list = new String[36];
587:                    String[] dest_list = new String[36];
588:                    src_list[0] = old_csid;
589:                    dest_list[0] = csid;
590:                    src_list[1] = old_base + "/plugins/compass/bin";
591:                    dest_list[1] = psdir + "/bin";
592:                    src_list[2] = old_base + "/plugins/compass/lib";
593:                    dest_list[2] = psdir + "/lib";
594:                    src_list[3] = "config=./config/";
595:                    dest_list[3] = "config=" + server_root + "/config/";
596:                    src_list[4] = "file=\"config/classification.conf\"";
597:                    dest_list[4] = "file=\"" + server_root
598:                            + "/config/classification.conf\"";
599:                    src_list[5] = "file=./config/";
600:                    dest_list[5] = "file=" + server_root + "/config/";
601:                    src_list[6] = old_base + "/bin/https/httpadmin/bin/cmdHook";
602:                    dest_list[6] = psdir + "/samples/robot/cmdHook";
603:
604:                    src_list[7] = "nsir-max-index-batch";
605:                    dest_list[7] = "search-max-index-batch";
606:                    src_list[8] = "nsirmgr-logfile";
607:                    dest_list[8] = "search-logfile";
608:                    src_list[9] = "search-index-type=Word";
609:                    dest_list[9] = "search-index-type=AWord";
610:                    src_list[10] = "nsir-taxonomy-collection-name";
611:                    dest_list[10] = "taxonomy-database-name";
612:                    src_list[11] = "3.01Csp1";
613:                    dest_list[11] = "6.2";
614:                    src_list[12] = old_base + "/https-" + nick;
615:                    dest_list[12] = server_root;
616:
617:                    src_list[13] = "compass-database-directory";
618:                    dest_list[13] = "database-directory";
619:                    src_list[14] = "compass-database-max-concurrent";
620:                    dest_list[14] = "database-max-concurrent";
621:                    src_list[15] = "compass-database-name=compass";
622:                    dest_list[15] = "database-name=default";
623:                    src_list[16] = "compass-database-partitions";
624:                    dest_list[16] = "database-partitions";
625:                    src_list[17] = "compass-database-logdir";
626:                    dest_list[17] = "database-logdir";
627:                    src_list[18] = "compass-database";
628:                    dest_list[18] = "database-root";
629:                    src_list[19] = "compass-database-cache-size-kb";
630:                    dest_list[19] = "database-cache-size-kb";
631:                    src_list[20] = "compass-database-name";
632:                    dest_list[20] = "database-name";
633:
634:                    src_list[21] = "max-concurrent";
635:                    dest_list[21] = "max-connections";
636:                    src_list[22] = "site-max-connection";
637:                    dest_list[22] = "site-max-connections";
638:
639:                    src_list[23] = old_base + "/bin/compass/bin";
640:                    dest_list[23] = psdir + "/bin";
641:                    src_list[24] = old_base + "/bin/compass/lib";
642:                    dest_list[24] = psdir + "/lib";
643:                    src_list[25] = old_base + "/compass-" + nick;
644:                    dest_list[25] = server_root;
645:                    src_list[26] = old_base + "/bin/compass/admin/bin/cmdHook";
646:                    dest_list[26] = psdir + "/samples/robot/cmdHook";
647:
648:                    src_list[27] = "/robot/state";
649:                    dest_list[27] = "/robot/";
650:                    src_list[28] = "rdmdebug.log";
651:                    dest_list[28] = "rdmserver.log";
652:                    src_list[29] = "nsirmgr.log";
653:                    dest_list[29] = "searchengine.log";
654:                    src_list[30] = "iPlanet-Compass-Robot/3.0";
655:                    dest_list[30] = "SunONERobot/6.0";
656:                    src_list[31] = "Netscape-Compass-Robot/3.0";
657:                    dest_list[31] = "SunONERobot/6.0";
658:                    src_list[32] = "3.01C";
659:                    dest_list[32] = "6.2";
660:                    src_list[33] = "3.01Bp1";
661:                    dest_list[33] = "6.2";
662:                    src_list[34] = "3.01B";
663:                    dest_list[34] = "6.2";
664:                    src_list[35] = "xpdf2html";
665:                    dest_list[35] = "";
666:
667:                    String conf_list[] = { "search.conf", "server.rdm",
668:                            "robot.conf", "filter.conf",
669:                            "import.conf",
670:                            //"gvlist.conf", XXX - values need to be moved to schema Is-Alertable field
671:                            //"alias.conf", XXX - values need to be moved to schema Aliases field
672:                            "filterrules.conf", "convert.conf",
673:                            "classification.conf", "mime.types", "schema.rdm" };
674:
675:                    store_conf_files(confsrcdir);
676:                    for (int i = 0; i < conf_list.length; i++)
677:                        create_conf_file(confsrcdir, confdestdir, conf_list[i],
678:                                del_list, src_list, dest_list);
679:
680:                    create_filter_files(old_base, old_server_root, server_root);
681:                    modifySchema(confsrcdir, confdestdir);
682:
683:                    String tax = File.separator + "config" + File.separator
684:                            + "taxonomy.rdm";
685:                    copy(old_server_root + tax, server_root + tax);
686:
687:                    String taxcmd[] = {
688:                            server_root + File.separator + "run-cs-cli",
689:                            "rdmgr", "-T", "-i", "charset", "tax" };
690:                    taxcmd[4] = charset;
691:                    taxcmd[5] = confdestdir + File.separator + "taxonomy.rdm";
692:                    if (isWindows()) {
693:                        taxcmd[0] = server_root + File.separator
694:                                + "run-cs-cli.bat";
695:                        taxcmd[1] = "rdmgr.bat";
696:                    }
697:
698:                    Process q;
699:                    q = Runtime.getRuntime().exec(taxcmd);
700:                    q.waitFor();
701:
702:                    // upgrade to 62 schema
703:                    Schema_60_to_62(confdestdir);
704:
705:                    // index the data
706:                    String edir = old_server_root + File.separator + "tmp"
707:                            + File.separator;
708:
709:                    String cmd[] = {
710:                            server_root + File.separator + "run-cs-cli",
711:                            "rdmgr", "-i", charset, "-y", "default", "" };
712:
713:                    if (isWindows()) {
714:                        cmd[0] = server_root + File.separator
715:                                + "run-cs-cli.bat";
716:                        cmd[1] = "rdmgr.bat";
717:                    }
718:                    File fdis = new File(edir + "discussion62.soif");
719:                    if (fdis.exists()) { // has discussion split
720:                        cmd[6] = edir + "migration62.soif";
721:                        q = Runtime.getRuntime().exec(cmd);
722:                        q.waitFor();
723:                        cmd[4] = "-y";
724:                        cmd[5] = "discussion";
725:                        cmd[6] = edir + "discussion62.soif";
726:                        q = Runtime.getRuntime().exec(cmd);
727:                        q.waitFor();
728:                    } else {
729:                        cmd[6] = edir + "migration60.soif";
730:                        q = Runtime.getRuntime().exec(cmd);
731:                        q.waitFor();
732:                    }
733:
734:                    if (!oldversion.equals("301b")) {
735:                        // copy anything under robot
736:                        String rcmd[] = { "cp", "-r",
737:                                old_server_root + File.separator + "robot",
738:                                server_root };
739:
740:                        q = Runtime.getRuntime().exec(rcmd);
741:                        q.waitFor();
742:                    }
743:
744:                    System.out.println("Migration completed");
745:                } catch (Exception e) {
746:                    throw new Exception("Error during instance migrate: " + e);
747:                }
748:            }
749:
750:            static void usage() {
751:                System.out
752:                        .println("Usage: java SearchMigrate 60to62 base old_server_root");
753:                System.out
754:                        .println("Usage: java SearchMigrate old_base old_server_root nick is_ias new_base nick new_server_root new_csid charset oldversion");
755:            }
756:
757:            public static void main(String args[]) {
758:                final int expectedargs = 8;
759:
760:                try {
761:                    // 6.x version upgrade
762:                    if (args.length == 3) {
763:                        if (args[0].equalsIgnoreCase("60to62")) {
764:                            new SearchMigrate()
765:                                    .migrate_60to62(args[1], args[2]);
766:                            return;
767:                        } else {
768:                            usage();
769:                            return;
770:                        }
771:                    }
772:
773:                    // sp1 to latest
774:                    if (args.length != expectedargs
775:                            && args.length != expectedargs + 1) {
776:                        usage();
777:                        return;
778:                    }
779:                    String old_base = args[0];
780:                    String old_server_root = args[1];
781:                    int http_type = HTTP_IWS;
782:                    if (args[2].substring(0, 1).equalsIgnoreCase("y"))
783:                        http_type = HTTP_IAS;
784:                    String new_base = args[3];
785:                    String nick = args[4];
786:                    String new_csroot = args[5];
787:                    String new_csid = args[6];
788:                    String charset = args[7];
789:                    if (args.length == expectedargs + 1) {
790:                        oldversion = args[8];
791:                    }
792:
793:                    SearchConfig.init(old_server_root + File.separator
794:                            + "config" + File.separator + "csid.conf");
795:                    SearchConfig.setValue(SearchConfig.FIELD_MULTIPLIERS, null);
796:                    String old_csid = SearchConfig.getSearchConfig().getValue(
797:                            "csid");
798:                    new SearchMigrate().migrate_instance(old_base,
799:                            old_server_root, old_csid, new_base, nick,
800:                            new_csroot, http_type, new_csid, charset);
801:                } catch (Exception e) {
802:                    System.out.println(e);
803:                }
804:            }
805:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.