-
Notifications
You must be signed in to change notification settings - Fork 2
/
VersionLog.java
213 lines (209 loc) · 8.36 KB
/
VersionLog.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class VersionLog extends HttpServlet
{
private ConnectionPool pool;
private ServletContext context;
private static String servletName="VersionLog";
public void init()
{
context = getServletContext();
synchronized(context)
{
pool=(ConnectionPool)context.getAttribute("pool");
if(pool==null)
{
String driverClassName = context.getInitParameter("driverClassName");
String url = context.getInitParameter("url");
String userName = context.getInitParameter("username");
String password = context.getInitParameter("password");
try
{
pool=new ConnectionPool(driverClassName,url,userName,password);
}
catch(Exception error)
{
Routines.writeToLog(servletName,"Unable to create connection pool : " + error,false,context);
}
context.setAttribute("pool",pool);
}
}
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
{
response.setContentType("text/html");
PrintWriter webPageOutput=null;
try
{
webPageOutput=response.getWriter();
}
catch(IOException error)
{
Routines.writeToLog(servletName,"Error getting writer : " + error,false,context);
}
HttpSession session=request.getSession();
session.setAttribute("redirect",request.getRequestURL() + "?" + request.getQueryString());
Connection database=null;
try
{
database=pool.getConnection(servletName);
}
catch(SQLException error)
{
Routines.writeToLog(servletName,"Unable to connect to database : " + error,false,context);
}
Routines.WriteHTMLHead("Version Log",//title
true,//showMenu
0,//menuHighLight
false,//seasonsMenu
false,//weeksMenu
false,//scores
false,//standings
false,//gameCenter
false,//Schedules
false,//previews
false,//teamCenter
false,//draft
database,//database
request,//request
response,//response
webPageOutput,//webPageOutput
context);//context
webPageOutput.println("<CENTER>");
webPageOutput.println("<IMG SRC=\"../Images/Log.gif\"" +
" WIDTH='57' HEIGHT='100' ALT='Version Log'>");
webPageOutput.println("</CENTER>");
Routines.tableStart(false,webPageOutput);
int majorVersion=0;
int minorVersion=0;
if("View".equals((String)session.getAttribute("action")))
{
String version=(String)session.getAttribute("version");
int dot=version.indexOf(".");
majorVersion=Routines.safeParseInt(version.substring(0,dot));
minorVersion=Routines.safeParseInt(version.substring(dot+1,version.length()));
}
else
{
majorVersion=Routines.safeParseInt((String)session.getAttribute("majorVersion"));
minorVersion=Routines.safeParseInt((String)session.getAttribute("minorVersion"));
}
try
{
Statement sql=database.createStatement();
ResultSet queryResults=sql.executeQuery("SELECT MajorVersion,MinorVersion,ChangeDate " +
"FROM changelog " +
"ORDER BY MajorVersion DESC,MinorVersion DESC, ChangeLog DESC");
int currentMajorVersion=0;
int currentMinorVersion=0;
Date currentDate=new Date(0);
String selected="";
String minorVersionText="";
String selectText="<FORM ACTION=\"http://" +
request.getServerName() +
":" +
request.getServerPort() +
request.getContextPath() +
"/servlet/VersionLog\" METHOD=\"GET\">";
selectText=selectText + "<SELECT NAME=\"version\">";
while(queryResults.next())
{
int tempMajorVersion=queryResults.getInt(1);
int tempMinorVersion=queryResults.getInt(2);
currentDate=queryResults.getDate(3);
if(tempMajorVersion!=currentMajorVersion||
tempMinorVersion!=currentMinorVersion)
{
currentMajorVersion=tempMajorVersion;
currentMinorVersion=tempMinorVersion;
if(tempMajorVersion==majorVersion&&
tempMinorVersion==minorVersion)
{
selected="SELECTED ";
}
else
{
selected="";
}
minorVersionText=Routines.minorVersionText(tempMinorVersion);
selectText=selectText +
" " +
"<OPTION " +
selected +
"VALUE=\"" +
tempMajorVersion +
"." +
tempMinorVersion +
"\">" +
"Version " +
tempMajorVersion +
"." +
minorVersionText +
" loaded " +
Routines.reformatDate(currentDate);
}
}
selectText=selectText + " " + "</SELECT>";
selectText=selectText + " " + "<INPUT TYPE=\"SUBMIT\" NAME=\"action\" VALUE=\"View\">";
selectText=selectText + " " + "<INPUT TYPE=\"hidden\" NAME=\"jsessionid\" VALUE=\"" + session.getId() + "\">";
selectText=selectText + " " + "</FORM>";
Routines.tableHeader(selectText,
2,
webPageOutput);
queryResults=sql.executeQuery("SELECT ChangeLog,MajorVersion,MinorVersion,ChangeDate,ChangeType,ChangeText " +
"FROM changelog " +
"WHERE MajorVersion = " + majorVersion + " " +
"AND MinorVersion = " + minorVersion + " " +
"ORDER BY ChangeType,ChangeLog ASC");
int changeLog=0;
int changeType=0;
int currentType=0;
String changeText="";
String typeText="";
Date changeDate;
while(queryResults.next())
{
changeLog=queryResults.getInt(1);
majorVersion=queryResults.getInt(2);
minorVersion=queryResults.getInt(3);
changeDate=queryResults.getDate(4);
changeType=queryResults.getInt(5);
changeText=queryResults.getString(6);
minorVersionText=Routines.minorVersionText(minorVersion);
if(changeType!=currentType)
{
currentType=changeType;
String titleText="";
if(changeType==1)
{
titleText="Bug Fixes";
typeText="B";
}
if(changeType==2)
{
titleText="New Features";
typeText="N";
}
Routines.tableHeader(titleText,2,webPageOutput);
}
Routines.tableDataStart(true,false,false,true,false,15,0,"scoresrow",webPageOutput);
webPageOutput.println(majorVersion + "." + minorVersionText + "-" + changeLog + "-" + typeText);
Routines.tableDataEnd(false,false,false,webPageOutput);
Routines.tableDataStart(true,false,false,false,false,85,0,"scoresrow",webPageOutput);
webPageOutput.println(changeText);
Routines.tableDataEnd(false,false,true,webPageOutput);
}
}
catch(SQLException error)
{
Routines.writeToLog(servletName,"Unable to access ChangeLog : " + error,false,context);
}
Routines.tableEnd(webPageOutput);
pool.returnConnection(database);
webPageOutput.println(Routines.spaceLines(15));
Routines.WriteHTMLTail(request,response,webPageOutput);
}
}