11 |
import javax.servlet.http.HttpServletResponse; |
import javax.servlet.http.HttpServletResponse; |
12 |
|
|
13 |
import dk.thoerup.circuitbreaker.CircuitBreakerException; |
import dk.thoerup.circuitbreaker.CircuitBreakerException; |
14 |
|
import dk.thoerup.traininfoservice.Statistics; |
15 |
|
|
16 |
/** |
/** |
17 |
* Servlet implementation class TimetableServlet |
* Servlet implementation class TimetableServlet |
40 |
response.sendError(400, "not enough parameters"); |
response.sendError(400, "not enough parameters"); |
41 |
return; |
return; |
42 |
} |
} |
43 |
|
Statistics.getInstance().incrementTimetableLookups(); |
44 |
|
|
45 |
String train = request.getParameter("train").trim(); |
String train = request.getParameter("train").trim(); |
46 |
|
String trainID; |
47 |
|
String type = request.getParameter("type"); |
48 |
|
|
49 |
String sections[] = train.split(" "); |
if (type != null) { |
50 |
if (sections.length != 2) { |
trainID = train; |
51 |
response.sendError(400, "Invalid parameter"); |
} else { //remove this failover sometime after release of client 0.6.4 |
52 |
return; |
String sections[] = train.split(" "); |
53 |
|
if (sections.length != 2) { |
54 |
|
response.sendError(400, "Invalid parameter"); |
55 |
|
return; |
56 |
|
} |
57 |
|
|
58 |
|
type = lookupType(sections[0]); |
59 |
|
trainID = sections[1]; |
60 |
} |
} |
61 |
|
|
|
String type = lookupType(sections[0]); |
|
|
String trainID = sections[1]; |
|
62 |
try |
try |
63 |
{ |
{ |
64 |
List<TimetableBean> timetable = fetcher.cachedLookupTimetable(trainID, type); |
List<TimetableBean> timetable = fetcher.cachedLookupTimetable(trainID, type); |
79 |
} |
} |
80 |
|
|
81 |
} |
} |
82 |
|
/*remove /outcomment/deprecate after 0.6.4 release */ |
83 |
String lookupType(String trainCode) { |
String lookupType(String trainCode) { |
84 |
trainCode = trainCode.toLowerCase(); |
trainCode = trainCode.toLowerCase(); |
85 |
|
|