Source Code Cross Referenced for DiscussionMigrate.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:        /*
002:         * Copyright 2003 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.rdmgr;
007:
008:        import java.io.*;
009:        import java.util.*;
010:
011:        import com.sun.portal.search.soif.*;
012:
013:        /**
014:         * Convert the 301CSP1 migration.soif to 6.2 discussion.soif format
015:         */
016:        class DiscussionMigrate {
017:
018:            private static String parents;
019:
020:            public DiscussionMigrate(String[] args) {
021:
022:                if (args.length == 0) {
023:
024:                    System.out
025:                            .println("\nUsage: DiscussionMigrate <filename1> <filename2> <filename3>\n");
026:                    System.out
027:                            .println("<filename1> is the 301CSP1 migration.soif\n");
028:                    System.out
029:                            .println("<filename2> is the migrated 6.2 migration.soif\n");
030:                    System.out
031:                            .println("<filename3> is the migrated 6.2 discussion.soif\n");
032:                    System.exit(1);
033:                }
034:
035:            }
036:
037:            private static boolean IsAURL(String url) {
038:
039:                int i = url.indexOf("http");
040:                if (i >= 0) {
041:                    return true;
042:                } else {
043:                    return false;
044:                }
045:
046:            }
047:
048:            private static String getCommentID(String cid) {
049:
050:                int i = cid.indexOf("cid=");
051:                if (i > 0) {
052:                    return (cid.substring(i + 4));
053:                } else {
054:                    return (cid);
055:                }
056:
057:            }
058:
059:            private static void FindParents(SOIF s, Map m) {
060:
061:                if (!(s.getURL()).equals(s.getValue("gv-discussion-id"))) {
062:
063:                    FindParents((SOIF) m.get(s.getValue("rd-reference-id")), m);
064:                }
065:
066:                parents = parents.concat(s.getURL()).concat(" ");
067:
068:            }
069:
070:            public static void main(String[] args) throws Exception {
071:
072:                if (args.length < 3) {
073:
074:                    System.out
075:                            .println("\nUsage: DiscussionMigrate <filename1> <filename2> <filename3>\n");
076:                    System.out
077:                            .println("<filename1> is the 301CSP1 migration.soif\n");
078:                    System.out
079:                            .println("<filename2> is the migrated 6.2 migration.soif\n");
080:                    System.out
081:                            .println("<filename3> is the migrated 6.2 discussion.soif\n");
082:                    System.exit(1);
083:
084:                }
085:
086:                if (args.length > 2) {
087:
088:                    String filename1 = args[0];
089:                    String filename2 = args[1];
090:                    String filename3 = args[2];
091:
092:                    //perhaps check the existence or permission of the file1 here
093:
094:                    Map discussion = new HashMap();
095:                    SOIFOutputStream doc = new SOIFOutputStream(filename2);
096:                    SOIFOutputStream sos = new SOIFOutputStream(filename3);
097:                    SOIFInputStream sis = new SOIFInputStream(
098:                            new DataInputStream(new BufferedInputStream(
099:                                    new FileInputStream(filename1))));
100:                    SOIF s;
101:
102:                    while ((s = sis.readSOIF()) != null) {
103:
104:                        if (s.contains("gv-last-modified")) {
105:                            s.rename("gv-last-modified", "rd-last-changed");
106:                        }
107:
108:                        if (s.contains("gv-reference-id")) {
109:                            s.rename("gv-reference-id", "rd-reference-id");
110:                        }
111:
112:                        if (s.contains("gv-num-rating")) {
113:                            s.rename("gv-num-rating", "rd-num-rating");
114:                        }
115:
116:                        if (s.contains("gv-sum-rating")) {
117:                            s.rename("gv-sum-rating", "rd-sum-rating");
118:                        }
119:
120:                        if (s.contains("gv-peak-rating")) {
121:                            s.rename("gv-peak-rating", "rd-peak-rating");
122:                        }
123:
124:                        if (s.contains("gv-rating")) {
125:                            s.rename("gv-rating", "rd-rating");
126:                        }
127:
128:                        if (s.contains("gv_depth")) {
129:                            s.remove("gv_depth");
130:                        }
131:
132:                        if (!s.contains("gv-discussion-id")) {
133:                            doc.write(s);
134:                        } else {
135:
136:                            if (!s.contains("rd-reference-id")) {
137:                                String did = null;
138:                                if (IsAURL(s.getURL())) {
139:                                    did = s.getValue("gv-discussion-id");
140:                                    s.remove("gv-discussion-id");
141:                                    doc.write(s);
142:                                    s.insert("gv-discussion-id", did);
143:                                }
144:                            } else {
145:                                s.replace("rd-reference-id", getCommentID(s
146:                                        .getValue("rd-reference-id")));
147:                            }
148:                            s.replace("gv-discussion-id", getCommentID(s
149:                                    .getValue("gv-discussion-id")));
150:                            String key = getCommentID(s.getURL());
151:                            s.setURL(key);
152:                            discussion.put(key, s);
153:
154:                        }
155:
156:                    } // end of while-loop
157:
158:                    doc.close();
159:
160:                    Map refIDs = new HashMap();
161:                    Set keys = discussion.keySet();
162:                    for (Iterator i = keys.iterator(); i.hasNext();) {
163:                        String url = (String) i.next();
164:                        SOIF disSOIF = (SOIF) discussion.get(url);
165:                        parents = new String(); // clean it up
166:                        FindParents(disSOIF, discussion);
167:
168:                        if ((disSOIF.getURL()).equals(disSOIF
169:                                .getValue("gv-discussion-id"))) {
170:                            parents = "ROOT ".concat(parents);
171:                        } else {
172:                            if ((disSOIF.getValue("rd-reference-id"))
173:                                    .equals(disSOIF
174:                                            .getValue("gv-discussion-id"))) {
175:
176:                                if (IsAURL(disSOIF.getValue("gv-discussion-id"))) {
177:
178:                                    disSOIF.insert("rd-reference-url", disSOIF
179:                                            .getValue("gv-discussion-id"));
180:                                }
181:                            }
182:                        }
183:
184:                        refIDs.put(url, parents);
185:
186:                    } // end of for loop
187:
188:                    // write them out
189:                    for (Iterator i = keys.iterator(); i.hasNext();) {
190:                        SOIF disSOIF = (SOIF) discussion.get(i.next());
191:                        disSOIF.replace("rd-reference-id", (String) refIDs
192:                                .get(disSOIF.getURL()));
193:                        disSOIF.remove("gv-discussion-id");
194:                        sos.write(disSOIF);
195:                    }
196:
197:                    sos.close();
198:
199:                }
200:
201:            } // end of main
202:
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.