Source Code Cross Referenced for ScheduledCheckout.java in  » Source-Control » jcvsweb » com » ice » jcvsweb » schedule » 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 » Source Control » jcvsweb » com.ice.jcvsweb.schedule 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.ice.jcvsweb.schedule;
002:
003:        import java.io.File;
004:        import java.io.FileWriter;
005:        import java.io.IOException;
006:        import java.io.PrintWriter;
007:        import java.text.SimpleDateFormat;
008:        import java.util.Date;
009:        import javax.servlet.ServletContext;
010:
011:        import com.ice.cvsc.*;
012:        import com.ice.jcvsweb.bean.*;
013:        import com.ice.jcvsweb.helper.ContextHelper;
014:        import com.ice.jcvsweb.manager.JCVSConfigManager;
015:
016:        public class ScheduledCheckout extends ScheduledEvent {
017:            private JCVSProjectView view = null;
018:
019:            public ScheduledCheckout(ServletContext ctx, JCVSProjectView view) {
020:                super (ctx);
021:                this .view = view;
022:                this .view.setState(JCVSProjectView.PS_CHKOUT_SCHED);
023:                this .view
024:                        .setReason("The project is scheduled to be checked out.");
025:            }
026:
027:            public void run() {
028:                this .getServletContext().log("ScheduledCheckout: " + this .view);
029:
030:                try {
031:                    this .checkoutProjectView();
032:                } catch (IOException ex) {
033:                    // UNDONE HIGH
034:                    this .getServletContext().log("error checking out", ex);
035:                }
036:
037:                this .getServletContext().log("ScheduledCheckout finished.");
038:            }
039:
040:            private void checkoutProjectView() throws IOException {
041:                CVSClient cvsClient;
042:                CVSProject cvsProject;
043:                CVSRequest cvsRequest;
044:                CVSResponse cvsResponse;
045:                ServletContext ctx = this .getServletContext();
046:
047:                ctx.log("[SCHEDCO] checkoutProjectView() '" + this .view + "'");
048:
049:                JCVSProject project = this .view.getProject();
050:                JCVSProjectDef def = project.getDef();
051:
052:                if (this .view != null) {
053:                    this .view.setState(JCVSProjectView.PS_CHKOUT);
054:                    this .view
055:                            .setReason("The project is currently being checked out.");
056:
057:                    CVSEntryVector entries = new CVSEntryVector();
058:                    CVSArgumentVector arguments = new CVSArgumentVector();
059:
060:                    String coDir = this .view.getCodir();
061:
062:                    ctx.log("[SCHEDCO]   coDirStr = " + coDir);
063:
064:                    if (coDir != null && coDir.length() > 0) {
065:                        arguments.appendArgument("-d");
066:                        arguments.appendArgument(coDir);
067:                    }
068:
069:                    arguments.appendArgument("-r");
070:                    arguments.appendArgument(this .view.getCvsTag());
071:
072:                    boolean dbgCheckout = def.getDebugCheckout();
073:                    ctx.log("[SCHEDCO]   dbgCheckout = " + dbgCheckout);
074:
075:                    arguments.appendArgument(this .view.getCvsModule());
076:
077:                    String viewDir = this .view.getViewDirectory();
078:                    ctx.log("[SCHEDCO]   Local = " + viewDir);
079:
080:                    String coDirPath = ContextHelper.getRealAbsolutePath(ctx,
081:                            viewDir);
082:                    ctx.log("[SCHEDCO]   coDirPath = " + coDirPath);
083:
084:                    File coDirF = new File(coDirPath);
085:                    ctx.log("[SCHEDCO]   coDirF = " + coDirF);
086:
087:                    if (!coDirF.exists()) {
088:                        if (!coDirF.mkdirs()) {
089:                            throw new IOException(
090:                                    "could not create working directory '"
091:                                            + coDirF.getPath() + "'.");
092:                        }
093:                    }
094:
095:                    int cvsPort = def.getCvsPort();
096:                    int connMethod = def.getCvsMethod();
097:                    boolean isPServer = (connMethod == CVSRequest.METHOD_INETD);
098:
099:                    ctx.log("[SCHEDCO]  Connection Port = " + cvsPort);
100:                    ctx.log("[SCHEDCO]  Connection Method = " + connMethod
101:                            + ", '" + CVSRequest.getConnMethodName(connMethod)
102:                            + "'");
103:                    ctx.log("[SCHEDCO]  Connection isPServer = " + isPServer);
104:
105:                    cvsClient = new CVSClient(def.getCvsHost(), cvsPort);
106:
107:                    cvsProject = new CVSProject(cvsClient);
108:
109:                    CVSProjectDef cvsProjectDef = new CVSProjectDef(connMethod,
110:                            isPServer, false, def.getCvsHost(), def
111:                                    .getCvsLogin(), def.getCvsRoot(), this .view
112:                                    .getCvsModule());
113:
114:                    cvsProject.setProjectDef(cvsProjectDef);
115:
116:                    String passwd = (connMethod != CVSRequest.METHOD_INETD ? def
117:                            .getCvsPassword()
118:                            : CVSScramble.scramblePassword(
119:                                    def.getCvsPassword(), 'A'));
120:
121:                    cvsProject.setUserName(def.getCvsLogin());
122:                    cvsProject.setPassword(passwd);
123:
124:                    cvsProject.setRepository(this .view.getCvsModule());
125:
126:                    String tempDir = def.getTempDirectory();
127:                    String tempDirPath = ContextHelper.getRealAbsolutePath(this 
128:                            .getServletContext(), tempDir);
129:                    ctx.log("[SCHEDCO]   tempDirPath = " + tempDirPath);
130:                    cvsProject.setTempDirectory(tempDirPath);
131:
132:                    cvsProject.setRootDirectory(def.getCvsRoot());
133:                    cvsProject.setLocalRootDirectory(coDirF.getPath());
134:                    cvsProject.setPServer(isPServer);
135:                    cvsProject.setConnectionMethod(connMethod);
136:                    cvsProject.setAllowsGzipFileMode(false);
137:
138:                    // We must make sure that the Project has its root entry, as
139:                    // CVSProject will not be able to create it from the context
140:                    // that the server will send with the checkout.
141:
142:                    cvsProject.establishRootEntry(def.getCvsRoot());
143:
144:                    cvsRequest = new CVSRequest();
145:
146:                    cvsRequest.setPServer(isPServer);
147:                    cvsRequest.setUserName(cvsProject.getUserName());
148:                    cvsRequest.setPassword(cvsProject.getPassword());
149:
150:                    cvsRequest.setConnectionMethod(cvsProject
151:                            .getConnectionMethod());
152:                    cvsRequest.setServerCommand(cvsProject.getServerCommand());
153:                    cvsRequest.setRshProcess(cvsProject.getRshProcess());
154:
155:                    cvsRequest.setPort(cvsPort);
156:                    cvsRequest.setHostName(def.getCvsHost());
157:
158:                    cvsRequest.setRepository(this .view.getCvsModule());
159:                    cvsRequest.setLocalDirectory(cvsProject
160:                            .getLocalRootDirectory());
161:                    cvsRequest.setRootDirectory(cvsProject.getRootDirectory());
162:                    cvsRequest.setRootRepository(cvsProject.getRootDirectory());
163:
164:                    cvsRequest.setSetVariables(cvsProject.getSetVariables());
165:
166:                    cvsRequest.setCommand("co");
167:
168:                    cvsRequest.sendModule = false;
169:                    cvsRequest.sendArguments = true;
170:                    cvsRequest.sendEntries = false;
171:                    cvsRequest.handleUpdated = true;
172:                    cvsRequest.allowOverWrites = true;
173:                    cvsRequest.queueResponse = false;
174:                    cvsRequest.responseHandler = cvsProject;
175:                    cvsRequest.includeNotifies = false;
176:                    cvsRequest.handleEntries = true;
177:
178:                    cvsRequest.traceRequest = dbgCheckout;
179:                    cvsRequest.traceResponse = dbgCheckout;
180:                    cvsRequest.traceTCPData = dbgCheckout;
181:                    cvsRequest.traceProcessing = dbgCheckout;
182:
183:                    cvsRequest.allowGzipFileMode = false;
184:                    cvsProject.allowsGzipFileMode();
185:
186:                    cvsRequest.setEntries(entries);
187:
188:                    cvsRequest.appendArguments(arguments);
189:
190:                    CVSBufferedUI cvsUI = new CVSBufferedUI();
191:                    cvsRequest.setUserInterface(cvsUI);
192:
193:                    // UNDONE Better log names, including view, and in subdirs!
194:                    //
195:                    SimpleDateFormat sdf = new SimpleDateFormat(
196:                            "yyyyMMdd-HHmmss");
197:                    Date tStamp = new Date();
198:
199:                    String logDir = this .view.getLogDirectory();
200:                    String logPath = ContextHelper.getRealAbsolutePath(this 
201:                            .getServletContext(), logDir);
202:                    File logDirF = new File(logPath);
203:
204:                    ctx.log("[SCHEDCO]   logDirF = " + logDirF);
205:
206:                    if (!logDirF.exists()) {
207:                        logDirF.mkdirs();
208:                    }
209:
210:                    String logFileName = "co-" + def.getKey() + "-"
211:                            + this .view.getKey() + "-" + sdf.format(tStamp)
212:                            + ".log";
213:
214:                    File logFile = new File(logDirF, logFileName);
215:
216:                    PrintWriter redir = new PrintWriter(new FileWriter(logFile));
217:
218:                    cvsRequest.setRedirectWriter(redir);
219:
220:                    ctx.log("[SCHEDCO]   Sending CVS command");
221:
222:                    cvsResponse = cvsClient.processCVSRequest(cvsRequest);
223:
224:                    cvsProject.processCVSResponse(cvsRequest, cvsResponse);
225:
226:                    ctx.log("[SCHEDCO]   Processed CVS command.");
227:
228:                    if (cvsResponse != null && !cvsRequest.saveTempFiles) {
229:                        cvsResponse.deleteTempFiles();
230:                    }
231:
232:                    if (cvsResponse.getStatus() != CVSResponse.OK) {
233:                        redir.println("*** Checkout Failed:");
234:                        redir.println(cvsResponse.getDisplayResults());
235:                    }
236:
237:                    redir.close();
238:
239:                    if (cvsResponse.getStatus() == CVSResponse.OK) {
240:                        // UNDONE
241:                        // Shouldn't the state be "synchronized" access?!?!
242:                        this .view.setState(JCVSProjectView.PS_INIT);
243:                        this .view.setReason("View checkout success. Log: "
244:                                + logFileName);
245:                    } else {
246:                        this .view.setState(JCVSProjectView.PS_BROKEN);
247:                        this .view.setReason("View checkout failed. Log: "
248:                                + logFileName);
249:                    }
250:                }
251:
252:                Runtime rt = Runtime.getRuntime();
253:                ctx.log("[SCHEDCO] Checked out " + this .view.getViewName());
254:                ctx.log("[SCHEDCO] Memory Free " + rt.freeMemory() + " Total "
255:                        + rt.totalMemory());
256:            }
257:
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.