Source Code Cross Referenced for SOIFPutter.java in  » Portal » Open-Portal » soif » 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 » soif 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *	CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003:         *	NETSCAPE COMMUNICATIONS CORPORATION
004:         *
005:         *	Copyright (c) 1996 Netscape Communications Corporation.
006:         *	All Rights Reserved.
007:         *	Use of this Source Code is subject to the terms of the applicable
008:         *	license agreement from Netscape Communications Corporation.
009:         */
010:
011:        package soif;
012:
013:        import communications.PostConnection;
014:        import util.ReportError;
015:
016:        import java.net.URL;
017:
018:        /**
019:         * Thread that puts SOIF.
020:         * <p>
021:         * <b>Open Issues</b>
022:         * <ul>
023:         * <li>Currently the bare minimum.
024:         * As the server stabilizes, more will be done here to do error checking etc.
025:         * <li>Doesn't currently support sending an RDM header
026:         * because current targets for this don't require it.
027:         * That may change.
028:         * <li>May not need CSID?
029:         * <li>Not used in product so not field tested.
030:         */
031:        public class SOIFPutter extends Thread {
032:            /**
033:             * Processing status.
034:             */
035:            private int status;
036:
037:            /**
038:             * Debug flag.
039:             */
040:            public boolean debug;
041:
042:            /**
043:             * Processing status: completed successfully.
044:             */
045:            public final static int COMPLETE = 0;
046:            /**
047:             * Processing status: completed successfully.
048:             */
049:            public final static int PREPARED = 1;
050:            /**
051:             * Processing status: completed successfully.
052:             */
053:            public final static int PROCESSING = 2;
054:            /**
055:             * Processing status: completed successfully.
056:             */
057:            public final static int ABEND = 3;
058:
059:            /**
060:             * Source of SOIF to which a PostConnection will be
061:             * established.
062:             */
063:            private String target;
064:
065:            /**
066:             * Target Compass Server ID.
067:             */
068:            protected CSID csid;
069:
070:            /**
071:             * The SOIF.
072:             */
073:            private String soif;
074:
075:            /**
076:             * Constructor.
077:             * @param CGILocation location of the CGI target of the rdm request
078:             * @param exe CGI executable which will fill rdm request
079:             * @param csid compass server id
080:             * @param soif soif to send
081:             */
082:            public SOIFPutter(String CGILocation, String exe, CSID csid,
083:                    SOIF soif) {
084:                this (CGILocation, exe, csid, ((soif == null) ? null : soif
085:                        .toStringList()));
086:            }
087:
088:            /**
089:             * Constructor.
090:             * @param CGILocation location of the CGI target of the rdm request
091:             * @param exe CGI executable which will fill rdm request
092:             * @param csid compass server id
093:             * @param soif soif to send
094:             */
095:            public SOIFPutter(String CGILocation, String exe, CSID csid,
096:                    String soif) {
097:                if (soif == null)
098:                    throw new IllegalArgumentException(Messages.NOSOIF);
099:                status = PREPARED;
100:                target = CGILocation + exe;
101:                this .csid = csid;
102:                this .soif = soif;
103:            }
104:
105:            /**
106:             * Set processing status.  If the current status is ABEND, it
107:             * will not be changed.
108:             */
109:            protected final void setStatus(int i) {
110:                if (status != ABEND)
111:                    status = i;
112:            }
113:
114:            /**
115:             * Return processing status.
116:             */
117:            public final int getStatus() {
118:                return status;
119:            }
120:
121:            /**
122:             * Return whether or not processing is complete.
123:             */
124:            public final boolean finished() {
125:                return ((status == COMPLETE) || (status == ABEND));
126:            }
127:
128:            /**
129:             * Wait for the putter to finish.
130:             */
131:            public void waitFor() {
132:                while (!finished()) {
133:                    try {
134:                        Thread.sleep(100);
135:                    } catch (InterruptedException e) {
136:                        break;
137:                    }
138:                }
139:            }
140:
141:            /**
142:             * Wait for the putter to finish.
143:             * @param max don't wait longer than max (increments are 100)
144:             */
145:            public void waitFor(int max) {
146:                int counter = 0;
147:                while ((!finished()) && (max > counter)) {
148:                    counter += 100;
149:                    try {
150:                        Thread.sleep(100);
151:                    } catch (InterruptedException e) {
152:                        break;
153:                    }
154:                }
155:            }
156:
157:            /**
158:             * Put some of that SOIF.
159:             */
160:            public void putSOIF() {
161:                URL url;
162:                PostConnection pc = null;
163:                String s = "";
164:                StringBuffer sb = new StringBuffer();
165:                boolean errors = false;
166:                String tmps = "unknown";
167:                SOIF sl = null;
168:                SOIFParser slp = null;
169:
170:                try {
171:                    s = PostConnection.doWrite(target, soif, true);
172:                    if (debug) {
173:                        System.out.println(s);
174:                    }
175:                    if (s == null) {
176:                        return;
177:                    }
178:                    if (s.indexOf("@") != -1) {
179:                        slp = new SOIFParser(s.substring(s.indexOf("@")));
180:                        if (slp.isValid())
181:                            sl = slp.getSOIF();
182:                        else {
183:                            sl = null;
184:                            errors = true;
185:                            return;
186:                        }
187:                    }
188:                } finally {
189:                    if (errors) {
190:                        status = ABEND;
191:                        return;
192:                    }
193:                }
194:
195:                if (sl == null) {
196:                    ReportError.reportError(ReportError.INTERNAL, "SOIFGetter",
197:                            "getSOIF", Messages.NOSOIF);
198:                    status = ABEND;
199:                    return;
200:                }
201:
202:                if (debug)
203:                    System.out.println(sl.toStringList());
204:
205:                RDMHeader rdmh = new RDMHeader(sl);
206:                if (rdmh.getRDMErrorMessage() != null) {
207:                    ReportError.reportError(ReportError.INTERNAL, "SOIFGetter",
208:                            "getSOIF", "RDM Error ["
209:                                    + rdmh.getRDMErrorMessage() + "]");
210:                    status = ABEND;
211:                    return;
212:                }
213:            }
214:
215:            /**
216:             * Run the thread, put the SOIF.
217:             */
218:            public void run() {
219:                status = PROCESSING;
220:
221:                putSOIF();
222:                if (status != ABEND)
223:                    status = COMPLETE;
224:
225:                System.out.println(Messages.COMPLETESOIFTHREAD);
226:            }
227:
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.