1
2
3
4
5
6
7 package org.miloss.fgsms.services.das.impl;
8
9 import java.sql.Connection;
10 import java.sql.PreparedStatement;
11 import java.sql.ResultSet;
12 import java.util.GregorianCalendar;
13 import javax.jws.WebParam;
14 import javax.xml.ws.WebServiceContext;
15 import org.apache.log4j.Level;
16 import org.miloss.fgsms.common.AuditLogger;
17 import org.miloss.fgsms.common.Constants;
18 import org.miloss.fgsms.common.DBUtils;
19 import org.miloss.fgsms.common.UserIdentityUtil;
20 import org.miloss.fgsms.common.Utility;
21 import static org.miloss.fgsms.services.das.impl.DAS4jBean.log;
22 import org.miloss.fgsms.services.interfaces.dataaccessservice.AccessDeniedException;
23 import org.miloss.fgsms.services.interfaces.dataaccessservice.ArrayOfTransactionLog;
24 import org.miloss.fgsms.services.interfaces.dataaccessservice.GetMessageLogsResponseMsg;
25 import org.miloss.fgsms.services.interfaces.dataaccessservice.GetRecentMessageLogsRequestMsg;
26 import org.miloss.fgsms.services.interfaces.dataaccessservice.ServiceUnavailableException;
27 import org.miloss.fgsms.services.interfaces.dataaccessservice.TransactionLog;
28 import org.miloss.fgsms.services.interfaces.faults.ServiceUnavailableFaultCodes;
29
30
31
32
33
34 public class QueryGetRecentMessageLogs {
35
36 public static GetMessageLogsResponseMsg getRecentMessageLogs(GetRecentMessageLogsRequestMsg request,
37 WebServiceContext ctx) throws AccessDeniedException, ServiceUnavailableException{
38 String currentUser = UserIdentityUtil.getFirstIdentityToString(ctx);
39 if (request == null) {
40 throw new IllegalArgumentException("request is null");
41 }
42 if (request.isFaultsOnly() && request.isSlaViolationsOnly()) {
43 throw new IllegalArgumentException("specifiy SLA Faults OR Faults Only, but not both");
44 }
45
46 if (Utility.stringIsNullOrEmpty(request.getAgentType())
47 && Utility.stringIsNullOrEmpty(request.getMonitorhostname())
48 && Utility.stringIsNullOrEmpty(request.getServicehostname())
49 && Utility.stringIsNullOrEmpty(request.getURL())) {
50 throw new IllegalArgumentException("at least one of URL, Agent, Monitor hostname, Service hostname");
51 }
52
53 Utility.validateClassification(request.getClassification());
54 AuditLogger.logItem(DAS4jBean.class.getCanonicalName(), "getRecentMessageLogs", currentUser, "", (request.getClassification()), ctx.getMessageContext());
55 boolean ga = false;
56 if (Utility.stringIsNullOrEmpty(request.getURL())) {
57 UserIdentityUtil.assertGlobalAdministratorRole(currentUser, "getRecentMessageLogs", (request.getClassification()), ctx);
58 ga = true;
59 }
60 UserIdentityUtil.assertAuditAccess(request.getURL(), currentUser, "getRecentMessageLogs", (request.getClassification()), ctx);
61
62 Connection con = Utility.getPerformanceDBConnection();
63 PreparedStatement comm = null;
64 PreparedStatement comm2 = null;
65 ResultSet s = null;
66 ResultSet results2=null;
67 try {
68
69 int offset = 0;
70 int limit = 100;
71 if (request.getRecords() >= 1) {
72 limit = request.getRecords();
73 }
74 if (limit < 0 || limit > 300) {
75 limit = 300;
76 }
77 if (request.getOffset() != null && request.getOffset() > 0) {
78 offset = request.getOffset();
79 }
80
81 GetMessageLogsResponseMsg ret = new GetMessageLogsResponseMsg();
82
83 int totalrecords = 0;
84
85
86 if (!Utility.stringIsNullOrEmpty(request.getURL())) {
87
88
89
90 if (Utility.stringIsNullOrEmpty(request.getAgentType())
91 && Utility.stringIsNullOrEmpty(request.getMonitorhostname())
92 && Utility.stringIsNullOrEmpty(request.getServicehostname())) {
93 log.log(Level.DEBUG, "DEBUG DAS Translog 1");
94
95 if (request.isFaultsOnly()) {
96 comm2 = con.prepareStatement("select faults from RawDatatally where (URI=?);");
97 comm2.setString(1, request.getURL());
98
99 results2 = comm2.executeQuery();
100 if (results2.next()) {
101 totalrecords = Long.valueOf(results2.getLong(1)).intValue();
102 }
103 results2.close();
104
105 comm = con.prepareStatement("select * from RawData "
106 + "where (URI=? or originalurl=?) and "
107 + "success=false "
108 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
109 comm.setString(1, request.getURL());
110 comm.setString(2, request.getURL());
111 comm.setLong(3, limit);
112 comm.setLong(4, offset);
113
114 } else if (request.isSlaViolationsOnly()) {
115 comm2 = con.prepareStatement("select slafault from RawDatatally where (URI=?) ;");
116 comm2.setString(1, request.getURL());
117
118 results2 = comm2.executeQuery();
119 if (results2.next()) {
120 totalrecords = Long.valueOf(results2.getLong(1)).intValue();
121 }
122 results2.close();
123 comm = con.prepareStatement("select * from RawData "
124 + "where(URI=? or originalurl=?) and "
125 + "\"slafault\" is not null "
126 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
127 comm.setString(1, request.getURL());
128 comm.setString(2, request.getURL());
129 comm.setLong(3, limit);
130 comm.setLong(4, offset);
131 } else {
132 comm2 = con.prepareStatement("select (success + faults) from rawdatatally where (URI=?) ;");
133 comm2.setString(1, request.getURL());
134
135 results2 = comm2.executeQuery();
136 if (results2.next()) {
137 long x = (results2.getLong(1));
138
139 totalrecords = Long.valueOf(x).intValue();
140 }
141 results2.close();
142 comm = con.prepareStatement("select * from RawData "
143 + "where (URI=? or originalurl=?) "
144 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
145 comm.setString(1, request.getURL());
146 comm.setString(2, request.getURL());
147
148 comm.setLong(3, limit);
149 comm.setLong(4, offset);
150
151 }
152 }
153
154
155
156 if (!Utility.stringIsNullOrEmpty(request.getAgentType())
157 && Utility.stringIsNullOrEmpty(request.getMonitorhostname())
158 && Utility.stringIsNullOrEmpty(request.getServicehostname())) {
159 log.log(Level.DEBUG, "DEBUG DAS Translog 2");
160
161 if (request.isFaultsOnly()) {
162 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
163 + " agenttype=? and success=false;");
164 comm2.setString(1, request.getURL());
165 comm2.setString(2, request.getURL());
166
167 comm2.setString(3, request.getAgentType());
168 results2 = comm2.executeQuery();
169 if (results2.next()) {
170 totalrecords = results2.getInt(1);
171 }
172 results2.close();
173
174 comm = con.prepareStatement("select * from RawData "
175 + "where (URI=? or originalurl=?) and "
176 + "success=false and agenttype=? "
177 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
178 comm.setString(1, request.getURL());
179 comm.setString(2, request.getURL());
180
181 comm.setString(3, request.getAgentType());
182 comm.setLong(4, limit);
183 comm.setLong(5, offset);
184
185 } else if (request.isSlaViolationsOnly()) {
186 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) "
187 + " and agenttype=? and \"slafault\" is not null ;");
188 comm2.setString(1, request.getURL());
189 comm2.setString(2, request.getURL());
190
191 comm2.setString(3, request.getAgentType());
192
193 results2 = comm2.executeQuery();
194 if (results2.next()) {
195 totalrecords = results2.getInt(1);
196 }
197 results2.close();
198 comm = con.prepareStatement("select * from RawData "
199 + "where (URI=? or originalurl=?) and "
200 + "\"slafault\" is not null and agenttype=? "
201 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
202 comm.setString(1, request.getURL());
203 comm.setString(2, request.getURL());
204
205 comm.setString(3, request.getAgentType());
206 comm.setLong(4, limit);
207 comm.setLong(5, offset);
208
209 } else {
210 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and agenttype=?;");
211 comm2.setString(1, request.getURL());
212 comm2.setString(2, request.getURL());
213
214 comm2.setString(3, request.getAgentType());
215 results2 = comm2.executeQuery();
216 if (results2.next()) {
217 totalrecords = results2.getInt(1);
218 }
219 results2.close();
220 comm = con.prepareStatement("select * from RawData "
221 + "where (URI=? or originalurl=?) and agenttype=? "
222 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
223 comm.setString(1, request.getURL());
224 comm.setString(2, request.getURL());
225
226 comm.setString(3, request.getAgentType());
227 comm.setLong(4, limit);
228 comm.setLong(5, offset);
229
230 }
231 }
232
233
234
235 if (!Utility.stringIsNullOrEmpty(request.getAgentType())
236 && Utility.stringIsNullOrEmpty(request.getMonitorhostname())
237 && !Utility.stringIsNullOrEmpty(request.getServicehostname())) {
238 log.log(Level.DEBUG, "DEBUG DAS Translog 3");
239
240 if (request.isFaultsOnly()) {
241 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
242 + " agenttype=? and hostingsource=? and success=false;");
243 comm2.setString(1, request.getURL());
244 comm2.setString(2, request.getURL());
245
246 comm2.setString(3, request.getAgentType());
247 comm2.setString(4, request.getServicehostname());
248 results2 = comm2.executeQuery();
249 if (results2.next()) {
250 totalrecords = results2.getInt(1);
251 }
252 results2.close();
253
254 comm = con.prepareStatement("select * from RawData "
255 + "where (URI=? or originalurl=?) and "
256 + "success=false and agenttype=? and hostingsource=? "
257 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
258 comm.setString(1, request.getURL());
259 comm.setString(2, request.getURL());
260
261 comm.setString(3, request.getAgentType());
262 comm.setString(4, request.getServicehostname());
263
264 comm.setLong(5, limit);
265 comm.setLong(6, offset);
266
267 } else if (request.isSlaViolationsOnly()) {
268 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
269 + " agenttype=? and hostingsource=? and \"slafault\" is not null;");
270 comm2.setString(1, request.getURL());
271 comm2.setString(2, request.getURL());
272
273 comm2.setString(3, request.getAgentType());
274 comm2.setString(4, request.getServicehostname());
275 results2 = comm2.executeQuery();
276 if (results2.next()) {
277 totalrecords = results2.getInt(1);
278 }
279 results2.close();
280
281 comm = con.prepareStatement("select * from RawData "
282 + "where (URI=? or originalurl=?) and "
283 + "\"slafault\" is not null and agenttype=? and hostingsource=? "
284 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
285 comm.setString(1, request.getURL());
286 comm.setString(2, request.getURL());
287
288 comm.setString(3, request.getAgentType());
289 comm.setString(4, request.getServicehostname());
290 comm.setLong(5, limit);
291 comm.setLong(6, offset);
292
293 } else {
294 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
295 + " agenttype=? and hostingsource=?;");
296 comm2.setString(1, request.getURL());
297 comm2.setString(2, request.getURL());
298
299 comm2.setString(3, request.getAgentType());
300 comm2.setString(4, request.getServicehostname());
301 results2 = comm2.executeQuery();
302 if (results2.next()) {
303 totalrecords = results2.getInt(1);
304 }
305 results2.close();
306 comm = con.prepareStatement("select * from RawData "
307 + "where (URI=? or originalurl=?) and "
308 + "agenttype=? and hostingsource=? "
309 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
310 comm.setString(1, request.getURL());
311 comm.setString(2, request.getURL());
312
313 comm.setString(3, request.getAgentType());
314 comm.setString(4, request.getServicehostname());
315 comm.setLong(5, limit);
316 comm.setLong(6, offset);
317
318 }
319 }
320
321
322
323 if (!Utility.stringIsNullOrEmpty(request.getAgentType())
324 && !Utility.stringIsNullOrEmpty(request.getMonitorhostname())
325 && Utility.stringIsNullOrEmpty(request.getServicehostname())) {
326 log.log(Level.DEBUG, "DEBUG DAS Translog 4");
327
328 if (request.isFaultsOnly()) {
329 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
330 + "agenttype=? and monitorsource=? and success=false;");
331 comm2.setString(1, request.getURL());
332 comm2.setString(2, request.getURL());
333
334 comm2.setString(3, request.getAgentType());
335 comm2.setString(4, request.getMonitorhostname());
336 results2 = comm2.executeQuery();
337 if (results2.next()) {
338 totalrecords = results2.getInt(1);
339 }
340 results2.close();
341 comm = con.prepareStatement("select * from RawData "
342 + "where (URI=? or originalurl=?) and "
343 + "success=false and agenttype=? and monitorsource=? "
344 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
345 comm.setString(1, request.getURL());
346 comm.setString(2, request.getURL());
347
348 comm.setString(3, request.getAgentType());
349 comm.setString(4, request.getMonitorhostname());
350 comm.setLong(5, limit);
351 comm.setLong(6, offset);
352
353 } else if (request.isSlaViolationsOnly()) {
354 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and agenttype=? and monitorsource=? and \"slafault\" is not null;");
355 comm2.setString(1, request.getURL());
356 comm2.setString(2, request.getURL());
357
358 comm2.setString(3, request.getAgentType());
359 comm2.setString(4, request.getMonitorhostname());
360 results2 = comm2.executeQuery();
361 if (results2.next()) {
362 totalrecords = results2.getInt(1);
363 }
364 results2.close();
365 comm = con.prepareStatement("select * from RawData "
366 + "where (URI=? or originalurl=?) and "
367 + "\"slafault\" is not null and agenttype=? and monitorsource=? "
368 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
369 comm.setString(1, request.getURL());
370 comm.setString(2, request.getURL());
371
372 comm.setString(3, request.getAgentType());
373 comm.setString(4, request.getMonitorhostname());
374 comm.setLong(5, limit);
375 comm.setLong(6, offset);
376
377 } else {
378 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and agenttype=? and monitorsource=?;");
379 comm2.setString(1, request.getURL());
380 comm2.setString(2, request.getURL());
381 comm2.setString(3, request.getAgentType());
382 comm2.setString(4, request.getMonitorhostname());
383 results2 = comm2.executeQuery();
384 if (results2.next()) {
385 totalrecords = results2.getInt(1);
386 }
387 results2.close();
388 comm = con.prepareStatement("select * from RawData "
389 + "where (URI=? or originalurl=?) and "
390 + " agenttype=? and monitorsource=? "
391 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
392 comm.setString(1, request.getURL());
393 comm.setString(2, request.getURL());
394 comm.setString(3, request.getAgentType());
395 comm.setString(4, request.getMonitorhostname());
396 comm.setLong(5, limit);
397 comm.setLong(6, offset);
398
399 }
400 }
401
402
403
404 if (Utility.stringIsNullOrEmpty(request.getAgentType())
405 && !Utility.stringIsNullOrEmpty(request.getMonitorhostname())
406 && !Utility.stringIsNullOrEmpty(request.getServicehostname())) {
407 log.log(Level.DEBUG, "DEBUG DAS Translog 5");
408
409 if (request.isFaultsOnly()) {
410 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
411 + "hostingsource=? and monitorsource=? and success=false;");
412 comm2.setString(1, request.getURL());
413 comm2.setString(2, request.getURL());
414
415 comm2.setString(3, request.getServicehostname());
416 comm2.setString(4, request.getMonitorhostname());
417 results2 = comm2.executeQuery();
418 if (results2.next()) {
419 totalrecords = results2.getInt(1);
420 }
421 results2.close();
422
423 comm = con.prepareStatement("select * from RawData "
424 + "where (URI=? or originalurl=?) and "
425 + "success=false and hostingsource=? and monitorsource=? "
426 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
427 comm.setString(1, request.getURL());
428 comm.setString(2, request.getURL());
429
430 comm.setString(3, request.getServicehostname());
431 comm.setString(4, request.getMonitorhostname());
432 comm.setLong(5, limit);
433 comm.setLong(6, limit);
434
435 } else if (request.isSlaViolationsOnly()) {
436 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
437 + " hostingsource=? and monitorsource=? and \"slafault\" is not null;");
438 comm2.setString(1, request.getURL());
439 comm2.setString(2, request.getURL());
440
441 comm2.setString(3, request.getServicehostname());
442 comm2.setString(4, request.getMonitorhostname());
443 results2 = comm2.executeQuery();
444 if (results2.next()) {
445 totalrecords = results2.getInt(1);
446 }
447 results2.close();
448 comm = con.prepareStatement("select * from RawData "
449 + "where (URI=? or originalurl=?) and "
450 + "\"slafault\" is not null and hostingsource=? and monitorsource=? "
451 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
452 comm.setString(1, request.getURL());
453 comm.setString(2, request.getURL());
454
455 comm.setString(3, request.getServicehostname());
456 comm.setString(4, request.getMonitorhostname());
457 comm.setLong(5, limit);
458 comm.setLong(6, offset);
459
460 } else {
461 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and hostingsource=? and monitorsource=?;");
462 comm2.setString(1, request.getURL());
463 comm2.setString(2, request.getURL());
464
465 comm2.setString(3, request.getServicehostname());
466 comm2.setString(4, request.getMonitorhostname());
467 results2 = comm2.executeQuery();
468 if (results2.next()) {
469 totalrecords = results2.getInt(1);
470 }
471 results2.close();
472 comm = con.prepareStatement("select * from RawData "
473 + "where (URI=? or originalurl=?) and "
474 + " hostingsource=? and monitorsource=? "
475 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
476 comm.setString(1, request.getURL());
477 comm.setString(2, request.getURL());
478
479 comm.setString(3, request.getServicehostname());
480 comm.setString(4, request.getMonitorhostname());
481 comm.setLong(5, limit);
482 comm.setLong(6, offset);
483 }
484 }
485
486
487
488
489 if (!Utility.stringIsNullOrEmpty(request.getAgentType())
490 && !Utility.stringIsNullOrEmpty(request.getMonitorhostname())
491 && !Utility.stringIsNullOrEmpty(request.getServicehostname())) {
492 log.log(Level.DEBUG, "DEBUG DAS Translog 5-2");
493
494 if (request.isFaultsOnly()) {
495 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
496 + "hostingsource=? and monitorsource=? and agenttype=? and success=false;");
497 comm2.setString(1, request.getURL());
498 comm2.setString(2, request.getURL());
499
500 comm2.setString(3, request.getServicehostname());
501 comm2.setString(4, request.getMonitorhostname());
502 comm2.setString(5, request.getAgentType());
503 results2 = comm2.executeQuery();
504 if (results2.next()) {
505 totalrecords = results2.getInt(1);
506 }
507 results2.close();
508
509 comm = con.prepareStatement("select * from RawData "
510 + "where (URI=? or originalurl=?) and "
511 + "success=false and hostingsource=? and monitorsource=? and agenttype=?"
512 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
513 comm.setString(1, request.getURL());
514 comm.setString(2, request.getURL());
515
516 comm.setString(3, request.getServicehostname());
517 comm.setString(4, request.getMonitorhostname());
518 comm.setString(5, request.getAgentType());
519 comm.setLong(6, limit);
520 comm.setLong(7, offset);
521
522 } else if (request.isSlaViolationsOnly()) {
523 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
524 + " hostingsource=? and monitorsource=? and \"slafault\" is not null and agenttype=?;");
525 comm2.setString(1, request.getURL());
526 comm2.setString(2, request.getURL());
527
528 comm2.setString(3, request.getServicehostname());
529 comm2.setString(4, request.getMonitorhostname());
530 comm2.setString(5, request.getAgentType());
531 results2 = comm2.executeQuery();
532 if (results2.next()) {
533 totalrecords = results2.getInt(1);
534 }
535 results2.close();
536 comm = con.prepareStatement("select * from RawData "
537 + "where (URI=? or originalurl=?) and "
538 + "\"slafault\" is not null and hostingsource=? and monitorsource=? and agenttype=? "
539 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
540 comm.setString(1, request.getURL());
541 comm.setString(2, request.getURL());
542
543 comm.setString(3, request.getServicehostname());
544 comm.setString(4, request.getMonitorhostname());
545 comm.setString(5, request.getAgentType());
546 comm.setLong(6, limit);
547 comm.setLong(7, offset);
548
549 } else {
550 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and hostingsource=? and monitorsource=? and agenttype=?;");
551 comm2.setString(1, request.getURL());
552 comm2.setString(2, request.getURL());
553
554 comm2.setString(3, request.getServicehostname());
555 comm2.setString(4, request.getMonitorhostname());
556 comm2.setString(5, request.getMonitorhostname());
557 results2 = comm2.executeQuery();
558 if (results2.next()) {
559 totalrecords = results2.getInt(1);
560 }
561 results2.close();
562 comm = con.prepareStatement("select * from RawData "
563 + "where (URI=? or originalurl=?) and "
564 + " hostingsource=? and monitorsource=? and agenttype=? "
565 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
566 comm.setString(1, request.getURL());
567 comm.setString(2, request.getURL());
568
569 comm.setString(3, request.getServicehostname());
570 comm.setString(4, request.getMonitorhostname());
571 comm.setString(5, request.getAgentType());
572 comm.setLong(6, limit);
573 comm.setLong(7, offset);
574 }
575 }
576
577
578
579
580 if (Utility.stringIsNullOrEmpty(request.getAgentType())
581 && Utility.stringIsNullOrEmpty(request.getMonitorhostname())
582 && !Utility.stringIsNullOrEmpty(request.getServicehostname())) {
583 log.log(Level.DEBUG, "DEBUG DAS Translog 6");
584
585 if (request.isFaultsOnly()) {
586 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
587 + " hostingsource=? and success=false;");
588 comm2.setString(1, request.getURL());
589 comm2.setString(2, request.getURL());
590
591 comm2.setString(3, request.getServicehostname());
592 results2 = comm2.executeQuery();
593 if (results2.next()) {
594 totalrecords = results2.getInt(1);
595 }
596 results2.close();
597 comm = con.prepareStatement("select * from RawData "
598 + "where (URI=? or originalurl=?) and "
599 + "success=false and hostingsource=? "
600 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
601 comm.setString(1, request.getURL());
602 comm.setString(2, request.getURL());
603
604 comm.setString(3, request.getServicehostname());
605 comm.setLong(4, limit);
606 comm.setLong(5, offset);
607
608 } else if (request.isSlaViolationsOnly()) {
609 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
610 + " hostingsource=? and \"slafault\" is not null;");
611
612 comm2.setString(1, request.getURL());
613 comm2.setString(2, request.getURL());
614
615 comm2.setString(3, request.getServicehostname());
616
617 results2 = comm2.executeQuery();
618 if (results2.next()) {
619 totalrecords = results2.getInt(1);
620 }
621 results2.close();
622 comm = con.prepareStatement("select * from RawData "
623 + "where (URI=? or originalurl=?) and "
624 + "\"slafault\" is not null and hostingsource=? "
625 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
626 comm.setString(1, request.getURL());
627 comm.setString(2, request.getURL());
628 comm.setString(3, request.getServicehostname());
629 comm.setLong(4, limit);
630 comm.setLong(5, offset);
631
632 } else {
633 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
634 + " hostingsource=?;");
635 comm2.setString(1, request.getURL());
636 comm2.setString(2, request.getURL());
637
638 comm2.setString(3, request.getServicehostname());
639 results2 = comm2.executeQuery();
640 if (results2.next()) {
641 totalrecords = results2.getInt(1);
642 results2.close();
643 comm = con.prepareStatement("select * from RawData "
644 + "where (URI=? or originalurl=?) and "
645 + " hostingsource=? "
646 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
647 comm.setString(1, request.getURL());
648 comm.setString(2, request.getURL());
649 comm.setString(3, request.getServicehostname());
650 comm.setLong(4, limit);
651 comm.setLong(5, offset);
652 }
653 }
654 }
655
656
657
658
659 if (Utility.stringIsNullOrEmpty(request.getAgentType())
660 && !Utility.stringIsNullOrEmpty(request.getMonitorhostname())
661 && Utility.stringIsNullOrEmpty(request.getServicehostname())) {
662 log.log(Level.DEBUG, "DEBUG DAS Translog 7");
663
664 if (request.isFaultsOnly()) {
665 comm2 = con.prepareStatement("select count(*) from RawData where (URI=?) and "
666 + " monitorsource=? and success=false;");
667 comm2.setString(1, request.getURL());
668 comm2.setString(2, request.getMonitorhostname());
669
670 results2 = comm2.executeQuery();
671 if (results2.next()) {
672 totalrecords = results2.getInt(1);
673 }
674 results2.close();
675 comm = con.prepareStatement("select * from RawData "
676 + "where (URI=?) and "
677 + "success=false and monitorsource=? "
678 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
679 comm.setString(1, request.getURL());
680
681 comm.setString(2, request.getMonitorhostname());
682
683 comm.setLong(3, limit);
684 comm.setLong(4, offset);
685
686 } else if (request.isSlaViolationsOnly()) {
687 comm2 = con.prepareStatement("select count(*) from RawData where (URI=?) and "
688 + " monitorsource=? and \"slafault\" is not null;");
689 comm2.setString(1, request.getURL());
690 comm2.setString(2, request.getMonitorhostname());
691 results2 = comm2.executeQuery();
692 if (results2.next()) {
693 totalrecords = results2.getInt(1);
694 }
695 results2.close();
696 comm = con.prepareStatement("select * from RawData "
697 + "where (URI=?) and "
698 + "\"slafault\" is not null and monitorsource=? "
699 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
700 comm.setString(1, request.getURL());
701 comm.setString(2, request.getMonitorhostname());
702 comm.setLong(3, limit);
703 comm.setLong(4, offset);
704 } else {
705 comm2 = con.prepareStatement("select count(*) from RawData where (URI=?) and"
706 + " monitorsource=?;");
707 comm2.setString(1, request.getURL());
708 comm2.setString(2, request.getMonitorhostname());
709 results2 = comm2.executeQuery();
710 if (results2.next()) {
711 totalrecords = results2.getInt(1);
712 }
713 results2.close();
714 comm = con.prepareStatement("select * from RawData "
715 + "where (URI=? ) and "
716 + " monitorsource=? "
717 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
718 comm.setString(1, request.getURL());
719 comm.setString(2, request.getMonitorhostname());
720 comm.setLong(3, limit);
721 comm.setLong(4, offset);
722 }
723 }
724
725
726
727 if (!Utility.stringIsNullOrEmpty(request.getAgentType())
728 && !Utility.stringIsNullOrEmpty(request.getMonitorhostname())
729 && !Utility.stringIsNullOrEmpty(request.getServicehostname())) {
730 log.log(Level.DEBUG, "DEBUG DAS Translog 8");
731
732 if (request.isFaultsOnly()) {
733 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
734 + " agenttype=? and hostingsource=? and monitorsource=? and success=false;");
735 comm2.setString(1, request.getURL());
736 comm2.setString(2, request.getURL());
737
738 comm2.setString(3, request.getAgentType());
739 comm2.setString(4, request.getServicehostname());
740 comm2.setString(5, request.getMonitorhostname());
741 results2 = comm2.executeQuery();
742 if (results2.next()) {
743 totalrecords = results2.getInt(1);
744 }
745 results2.close();
746 comm = con.prepareStatement("select * from RawData "
747 + "where (URI=? or originalurl=?) and "
748 + "success=false and agenttype=? and hostingsource=? and monitorsource=? "
749 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
750 comm.setString(1, request.getURL());
751 comm.setString(2, request.getURL());
752
753 comm.setString(3, request.getAgentType());
754 comm.setString(4, request.getServicehostname());
755 comm.setString(5, request.getMonitorhostname());
756 comm.setLong(6, limit);
757 comm.setLong(7, offset);
758
759 } else if (request.isSlaViolationsOnly()) {
760 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and "
761 + " agenttype=? and hostingsource=? and monitorsource=? and \"slafault\" is not null;");
762 comm2.setString(1, request.getURL());
763 comm2.setString(2, request.getURL());
764
765 comm2.setString(3, request.getAgentType());
766 comm2.setString(4, request.getServicehostname());
767 comm2.setString(5, request.getMonitorhostname());
768 results2 = comm2.executeQuery();
769 if (results2.next()) {
770 totalrecords = results2.getInt(1);
771 }
772 results2.close();
773
774 comm = con.prepareStatement("select * from RawData "
775 + "where (URI=? or originalurl=?) and "
776 + "\"slafault\" is not null and agenttype=? and hostingsource=? and monitorsource=? "
777 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
778 comm.setString(1, request.getURL());
779 comm.setString(2, request.getURL());
780
781 comm.setString(3, request.getAgentType());
782 comm.setString(4, request.getServicehostname());
783 comm.setString(5, request.getMonitorhostname());
784 comm.setLong(6, limit);
785 comm.setLong(7, offset);
786
787 } else {
788 comm2 = con.prepareStatement("select count(*) from RawData where (URI=? or originalurl=?) and"
789 + " agenttype=? and hostingsource=? and monitorsource=?;");
790 comm2.setString(1, request.getURL());
791 comm2.setString(2, request.getURL());
792
793 comm2.setString(3, request.getAgentType());
794 comm2.setString(4, request.getServicehostname());
795 comm2.setString(5, request.getMonitorhostname());
796 results2 = comm2.executeQuery();
797 if (results2.next()) {
798 totalrecords = results2.getInt(1);
799 }
800 results2.close();
801 comm = con.prepareStatement("select * from RawData "
802 + "where (URI=? or originalurl=?) and "
803 + "agenttype=? and hostingsource=? and monitorsource=? "
804 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
805 comm.setString(1, request.getURL());
806 comm.setString(2, request.getURL());
807
808 comm.setString(3, request.getAgentType());
809 comm.setString(4, request.getServicehostname());
810 comm.setString(5, request.getMonitorhostname());
811 comm.setLong(6, limit);
812 comm.setLong(7, offset);
813 }
814 }
815
816 } else
817 {
818
819
820
821
822 if (Utility.stringIsNullOrEmpty(request.getAgentType())
823 && Utility.stringIsNullOrEmpty(request.getMonitorhostname())
824 && Utility.stringIsNullOrEmpty(request.getServicehostname())) {
825 log.log(Level.DEBUG, "DEBUG DAS Translog 9");
826
827 if (request.isFaultsOnly()) {
828 comm2 = con.prepareStatement("select sum(faults) from RawDatatally;");
829 results2 = comm2.executeQuery();
830 if (results2.next()) {
831 totalrecords = Long.valueOf(results2.getLong(1)).intValue();
832 }
833 results2.close();
834
835 comm = con.prepareStatement("select * from RawData "
836 + "where "
837 + "success=false "
838 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
839
840 comm.setLong(1, limit);
841 comm.setLong(2, offset);
842
843 } else if (request.isSlaViolationsOnly()) {
844 comm2 = con.prepareStatement("select sum(slafault) from RawDatatally where "
845 + " \"slafault\" is not null ;");
846
847 results2 = comm2.executeQuery();
848 if (results2.next()) {
849 totalrecords = Long.valueOf(results2.getLong(1)).intValue();
850 }
851 results2.close();
852 comm = con.prepareStatement("select * from RawData "
853 + "where "
854 + "\"slafault\" is not null "
855 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
856 comm.setLong(1, limit);
857 comm.setLong(2, offset);
858 } else {
859 comm2 = con.prepareStatement("SELECT sum(success) + sum(faults) FROM rawdatatally;");
860
861 results2 = comm2.executeQuery();
862 if (results2.next()) {
863 totalrecords = Long.valueOf(results2.getLong(1)).intValue();
864 }
865 results2.close();
866 comm = con.prepareStatement("select * from RawData "
867 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
868 comm.setLong(1, limit);
869 comm.setLong(2, offset);
870 }
871 }
872
873
874
875 if (!Utility.stringIsNullOrEmpty(request.getAgentType())
876 && Utility.stringIsNullOrEmpty(request.getMonitorhostname())
877 && Utility.stringIsNullOrEmpty(request.getServicehostname())) {
878 log.log(Level.DEBUG, "DEBUG DAS Translog 10");
879
880 if (request.isFaultsOnly()) {
881 comm2 = con.prepareStatement("select count(*) from RawData where "
882 + "agenttype=? and success=false");
883
884 comm2.setString(1, request.getAgentType());
885 results2 = comm2.executeQuery();
886 if (results2.next()) {
887 totalrecords = results2.getInt(1);
888 }
889 results2.close();
890 comm = con.prepareStatement("select * from RawData "
891 + "where "
892 + "success=false and agenttype=? "
893 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
894 comm.setString(1, request.getAgentType());
895 comm.setLong(2, limit);
896 comm.setLong(3, offset);
897 } else if (request.isSlaViolationsOnly()) {
898 comm2 = con.prepareStatement("select count(*) from RawData where "
899 + "agenttype=? and \"slafault\" is not null;");
900
901 comm2.setString(1, request.getAgentType());
902 results2 = comm2.executeQuery();
903 if (results2.next()) {
904 totalrecords = results2.getInt(1);
905 }
906 results2.close();
907
908 comm = con.prepareStatement("select * from RawData "
909 + "where "
910 + "\"slafault\" is not null and agenttype=? "
911 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
912 comm.setString(1, request.getAgentType());
913 comm.setLong(2, limit);
914 comm.setLong(3, offset);
915 } else {
916 comm2 = con.prepareStatement("select count(*) from RawData where "
917 + " agenttype=?;");
918
919 comm2.setString(1, request.getAgentType());
920
921
922 results2 = comm2.executeQuery();
923 if (results2.next()) {
924 totalrecords = results2.getInt(1);
925 }
926 results2.close();
927 comm = con.prepareStatement("select * from RawData "
928 + "where "
929 + " agenttype=? "
930 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
931 comm.setString(1, request.getAgentType());
932 comm.setLong(2, limit);
933 comm.setLong(3, offset);
934 }
935 }
936
937
938
939
940 if (Utility.stringIsNullOrEmpty(request.getAgentType())
941 && Utility.stringIsNullOrEmpty(request.getMonitorhostname())
942 && !Utility.stringIsNullOrEmpty(request.getServicehostname())) {
943 log.log(Level.DEBUG, "DEBUG DAS Translog 11");
944
945 if (request.isFaultsOnly()) {
946 comm2 = con.prepareStatement("select count(*) from RawData where "
947 + " hostingsource=? and success=false;");
948
949 comm2.setString(1, request.getServicehostname());
950 results2 = comm2.executeQuery();
951 if (results2.next()) {
952 totalrecords = results2.getInt(1);
953 }
954 results2.close();
955
956 comm = con.prepareStatement("select * from RawData "
957 + "where "
958 + "success=false and hostingsource=? "
959 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
960
961 comm.setString(1, request.getServicehostname());
962 comm.setLong(2, limit);
963 comm.setLong(3, offset);
964 } else if (request.isSlaViolationsOnly()) {
965 comm2 = con.prepareStatement("select count(*) from RawData where "
966 + " hostingsource=? and \"slafault\" is not null;");
967
968 comm2.setString(1, request.getServicehostname());
969 results2 = comm2.executeQuery();
970 if (results2.next()) {
971 totalrecords = results2.getInt(1);
972 }
973 results2.close();
974
975 comm = con.prepareStatement("select * from RawData "
976 + "where "
977 + "\"slafault\" is not null and hostingsource=? "
978 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
979
980 comm.setString(1, request.getServicehostname());
981 comm.setLong(2, limit);
982 comm.setLong(3, offset);
983 } else {
984 comm2 = con.prepareStatement("select count(*) from RawData where "
985 + " hostingsource=?;");
986
987 comm2.setString(1, request.getServicehostname());
988 results2 = comm2.executeQuery();
989 if (results2.next()) {
990 totalrecords = results2.getInt(1);
991 }
992 results2.close();
993
994 comm = con.prepareStatement("select * from RawData "
995 + "where "
996 + " hostingsource=? "
997 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
998
999 comm.setString(1, request.getServicehostname());
1000 comm.setLong(2, limit);
1001 comm.setLong(3, offset);
1002 }
1003 }
1004
1005
1006
1007
1008 if (Utility.stringIsNullOrEmpty(request.getAgentType())
1009 && !Utility.stringIsNullOrEmpty(request.getMonitorhostname())
1010 && Utility.stringIsNullOrEmpty(request.getServicehostname())) {
1011 log.log(Level.DEBUG, "DEBUG DAS Translog 12");
1012
1013 if (request.isFaultsOnly()) {
1014 comm2 = con.prepareStatement("select count(*) from RawData where "
1015 + " monitorsource=? and success=false;");
1016
1017 comm2.setString(1, request.getMonitorhostname());
1018 results2 = comm2.executeQuery();
1019 if (results2.next()) {
1020 totalrecords = results2.getInt(1);
1021 }
1022 results2.close();
1023
1024 comm = con.prepareStatement("select * from RawData "
1025 + "where "
1026 + "success=false and monitorsource=? "
1027 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1028
1029 comm.setString(1, request.getMonitorhostname());
1030 comm.setLong(2, limit);
1031 comm.setLong(3, offset);
1032 } else if (request.isSlaViolationsOnly()) {
1033 comm2 = con.prepareStatement("select count(*) from RawData where "
1034 + " monitorsource=? and \"slafault\" is not null;");
1035
1036 comm2.setString(1, request.getMonitorhostname());
1037 results2 = comm2.executeQuery();
1038 if (results2.next()) {
1039 totalrecords = results2.getInt(1);
1040 }
1041 results2.close();
1042 comm = con.prepareStatement("select * from RawData "
1043 + "where "
1044 + "\"slafault\" is not null and monitorsource=? "
1045 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1046 comm.setString(1, request.getMonitorhostname());
1047 comm.setLong(2, limit);
1048 comm.setLong(3, offset);
1049 } else {
1050 comm2 = con.prepareStatement("select count(*) from RawData where "
1051 + " monitorsource=?;");
1052
1053 comm2.setString(1, request.getMonitorhostname());
1054 results2 = comm2.executeQuery();
1055 if (results2.next()) {
1056 totalrecords = results2.getInt(1);
1057 }
1058 results2.close();
1059 comm = con.prepareStatement("select * from RawData "
1060 + "where "
1061 + " monitorsource=? "
1062 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1063
1064 comm.setString(1, request.getMonitorhostname());
1065 comm.setLong(2, limit);
1066 comm.setLong(3, offset);
1067 }
1068 }
1069
1070
1071
1072
1073 if (!Utility.stringIsNullOrEmpty(request.getAgentType())
1074 && !Utility.stringIsNullOrEmpty(request.getMonitorhostname())
1075 && !Utility.stringIsNullOrEmpty(request.getServicehostname())) {
1076 log.log(Level.DEBUG, "DEBUG DAS Translog 13");
1077
1078 if (request.isFaultsOnly()) {
1079 comm2 = con.prepareStatement("select count(*) from RawData where "
1080 + " monitorsource=? and agenttype=? and hostingsource=? and success=false;");
1081
1082 comm2.setString(1, request.getMonitorhostname());
1083 comm2.setString(2, request.getAgentType());
1084 comm2.setString(3, request.getServicehostname());
1085 results2 = comm2.executeQuery();
1086 if (results2.next()) {
1087 totalrecords = results2.getInt(1);
1088 }
1089 results2.close();
1090
1091 comm = con.prepareStatement("select * from RawData "
1092 + "where "
1093 + "success=false and monitorsource=? and agenttype=? and hostingsource=? "
1094 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1095
1096 comm.setString(1, request.getMonitorhostname());
1097 comm.setString(2, request.getAgentType());
1098 comm.setString(3, request.getServicehostname());
1099 comm.setLong(4, limit);
1100 comm.setLong(5, offset);
1101 } else if (request.isSlaViolationsOnly()) {
1102 comm2 = con.prepareStatement("select count(*) from RawData where "
1103 + " monitorsource=? and agenttype=? and hostingsource=? and \"slafault\" is not null;");
1104
1105 comm2.setString(1, request.getMonitorhostname());
1106 comm2.setString(2, request.getAgentType());
1107 comm2.setString(3, request.getServicehostname());
1108 results2 = comm2.executeQuery();
1109 if (results2.next()) {
1110 totalrecords = results2.getInt(1);
1111 }
1112 results2.close();
1113 comm = con.prepareStatement("select * from RawData "
1114 + "where "
1115 + "\"slafault\" is not null and monitorsource=? and agenttype=? and hostingsource=? "
1116 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1117
1118 comm.setString(1, request.getMonitorhostname());
1119 comm.setString(2, request.getAgentType());
1120 comm.setString(3, request.getServicehostname());
1121 comm.setLong(4, limit);
1122 comm.setLong(5, offset);
1123 } else {
1124 comm2 = con.prepareStatement("select count(*) from RawData where "
1125 + " monitorsource=? and agenttype=? and hostingsource=?;");
1126
1127 comm2.setString(1, request.getMonitorhostname());
1128 comm2.setString(2, request.getAgentType());
1129 comm2.setString(3, request.getServicehostname());
1130 results2 = comm2.executeQuery();
1131 if (results2.next()) {
1132 totalrecords = results2.getInt(1);
1133 }
1134 results2.close();
1135
1136 comm = con.prepareStatement("select * from RawData "
1137 + "where "
1138 + " monitorsource=? and agenttype=? and hostingsource=? "
1139 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1140
1141 comm.setString(1, request.getMonitorhostname());
1142 comm.setString(2, request.getAgentType());
1143 comm.setString(3, request.getServicehostname());
1144 comm.setLong(4, limit);
1145 comm.setLong(5, offset);
1146 }
1147 }
1148
1149
1150
1151
1152 if (Utility.stringIsNullOrEmpty(request.getAgentType())
1153 && !Utility.stringIsNullOrEmpty(request.getMonitorhostname())
1154 && !Utility.stringIsNullOrEmpty(request.getServicehostname())) {
1155 log.log(Level.DEBUG, "DEBUG DAS Translog 14");
1156
1157 if (request.isFaultsOnly()) {
1158 comm2 = con.prepareStatement("select count(*) from RawData where "
1159 + " monitorsource=? and hostingsource=? and success=false;");
1160
1161 comm2.setString(1, request.getMonitorhostname());
1162 comm2.setString(2, request.getServicehostname());
1163 results2 = comm2.executeQuery();
1164 if (results2.next()) {
1165 totalrecords = results2.getInt(1);
1166 }
1167 results2.close();
1168 comm = con.prepareStatement("select * from RawData "
1169 + "where "
1170 + "success=false and monitorsource=? and hostingsource=? "
1171 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1172
1173 comm.setString(1, request.getMonitorhostname());
1174 comm.setString(2, request.getServicehostname());
1175 comm.setLong(3, limit);
1176 comm.setLong(4, offset);
1177 } else if (request.isSlaViolationsOnly()) {
1178 comm2 = con.prepareStatement("select count(*) from RawData where "
1179 + " monitorsource=? and hostingsource=? and \"slafault\" is not null;");
1180
1181 comm2.setString(1, request.getMonitorhostname());
1182 comm2.setString(2, request.getServicehostname());
1183 results2 = comm2.executeQuery();
1184 if (results2.next()) {
1185 totalrecords = results2.getInt(1);
1186 }
1187 results2.close();
1188 comm = con.prepareStatement("select * from RawData "
1189 + "where "
1190 + "\"slafault\" is not null and monitorsource=? and hostingsource=? "
1191 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1192
1193 comm.setString(1, request.getMonitorhostname());
1194
1195 comm.setString(2, request.getServicehostname());
1196 comm.setLong(3, limit);
1197 comm.setLong(4, offset);
1198 } else {
1199 comm2 = con.prepareStatement("select count(*) from RawData where "
1200 + " monitorsource=? and hostingsource=?;");
1201
1202 comm2.setString(1, request.getMonitorhostname());
1203 comm2.setString(2, request.getServicehostname());
1204 results2 = comm2.executeQuery();
1205 if (results2.next()) {
1206 totalrecords = results2.getInt(1);
1207 }
1208 results2.close();
1209 comm = con.prepareStatement("select * from RawData "
1210 + "where "
1211 + " monitorsource=? and hostingsource=? "
1212 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1213
1214 comm.setString(1, request.getMonitorhostname());
1215 comm.setString(2, request.getServicehostname());
1216 comm.setLong(3, limit);
1217 comm.setLong(4, offset);
1218 }
1219 }
1220
1221
1222
1223
1224 if (!Utility.stringIsNullOrEmpty(request.getAgentType())
1225 && !Utility.stringIsNullOrEmpty(request.getMonitorhostname())
1226 && Utility.stringIsNullOrEmpty(request.getServicehostname())) {
1227 log.log(Level.DEBUG, "DEBUG DAS Translog 15");
1228
1229 if (request.isFaultsOnly()) {
1230 comm2 = con.prepareStatement("select count(*) from RawData where "
1231 + " monitorsource=? and agenttype=? and success=false;");
1232
1233 comm2.setString(1, request.getMonitorhostname());
1234 comm2.setString(2, request.getAgentType());
1235 results2 = comm2.executeQuery();
1236 if (results2.next()) {
1237 totalrecords = results2.getInt(1);
1238 }
1239 results2.close();
1240 comm = con.prepareStatement("select * from RawData "
1241 + "where "
1242 + "success=false and monitorsource=? and agenttype=? "
1243 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1244
1245 comm.setString(1, request.getMonitorhostname());
1246 comm.setString(2, request.getAgentType());
1247 comm.setLong(3, limit);
1248 comm.setLong(4, offset);
1249 } else if (request.isSlaViolationsOnly()) {
1250 comm2 = con.prepareStatement("select count(*) from RawData where "
1251 + " monitorsource=? and agenttype=? and \"slafault\" is not null;");
1252
1253 comm2.setString(1, request.getMonitorhostname());
1254 comm2.setString(2, request.getAgentType());
1255 results2 = comm2.executeQuery();
1256 if (results2.next()) {
1257 totalrecords = results2.getInt(1);
1258 }
1259 results2.close();
1260 comm = con.prepareStatement("select * from RawData "
1261 + "where "
1262 + "\"slafault\" is not null and monitorsource=? and agenttype=? "
1263 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1264
1265 comm.setString(1, request.getMonitorhostname());
1266 comm.setString(2, request.getAgentType());
1267 comm.setLong(3, limit);
1268 comm.setLong(4, offset);
1269
1270 } else {
1271 comm2 = con.prepareStatement("select count(*) from RawData where "
1272 + " monitorsource=? and agenttype=?;");
1273
1274 comm2.setString(1, request.getMonitorhostname());
1275 comm2.setString(2, request.getAgentType());
1276 results2 = comm2.executeQuery();
1277 if (results2.next()) {
1278 totalrecords = results2.getInt(1);
1279 }
1280 results2.close();
1281 comm = con.prepareStatement("select * from RawData "
1282 + "where "
1283 + " monitorsource=? and agenttype=? "
1284 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1285
1286 comm.setString(1, request.getMonitorhostname());
1287 comm.setString(2, request.getAgentType());
1288 comm.setLong(3, limit);
1289 comm.setLong(4, offset);
1290
1291 }
1292 }
1293
1294
1295
1296
1297 if (!Utility.stringIsNullOrEmpty(request.getAgentType())
1298 && Utility.stringIsNullOrEmpty(request.getMonitorhostname())
1299 && !Utility.stringIsNullOrEmpty(request.getServicehostname())) {
1300 log.log(Level.DEBUG, "DEBUG DAS Translog 16");
1301
1302 if (request.isFaultsOnly()) {
1303 comm2 = con.prepareStatement("select count(*) from RawData where "
1304 + " agenttype=? and hostingsource=? and success=false;");
1305
1306 comm2.setString(1, request.getAgentType());
1307 comm2.setString(2, request.getServicehostname());
1308
1309 results2 = comm2.executeQuery();
1310 if (results2.next()) {
1311 totalrecords = results2.getInt(1);
1312 }
1313 results2.close();
1314 comm = con.prepareStatement("select * from RawData "
1315 + "where "
1316 + "success=false and agenttype=? and hostingsource=? "
1317 + "ORDER BY UTCdatetime DESC LIMIT ? OFFSET ?;");
1318
1319 comm.setString(1, request.getAgentType());
1320 comm.setString(2, request.getServicehostname());
1321 comm.setLong(3, limit);
1322 comm.setLong(4, offset);
1323 } else if (request.isSlaViolationsOnly()) {
1324 comm2 = con.prepareStatement("select count(*) from RawData where "
1325 + " agenttype=? and hostingsource=? and \"slafault\" is not null;");
1326
1327 comm2.setString(1, request.getAgentType());
1328 comm2.setString(2, request.getServicehostname());
1329 results2 = comm2.executeQuery();
1330 if (results2.next()) {
1331 totalrecords = results2.getInt(1);
1332 }
1333 results2.close();
1334 comm = con.prepareStatement("select * from RawData "
1335 + "where "
1336 + "\"slafault\" is not null and agenttype=? and hostingsource=? "
1337 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1338
1339 comm.setString(1, request.getAgentType());
1340 comm.setString(2, request.getServicehostname());
1341 comm.setLong(3, limit);
1342 comm.setLong(4, offset);
1343 } else {
1344 comm2 = con.prepareStatement("select count(*) from RawData where "
1345 + " agenttype=? and hostingsource=?;");
1346
1347 comm2.setString(1, request.getAgentType());
1348 comm2.setString(2, request.getServicehostname());
1349 results2 = comm2.executeQuery();
1350 if (results2.next()) {
1351 totalrecords = results2.getInt(1);
1352 }
1353 results2.close();
1354 comm = con.prepareStatement("select * from RawData "
1355 + "where "
1356 + " agenttype=? and hostingsource=? "
1357 + "ORDER BY UTCdatetime DESC limit ? offset ?;");
1358
1359 comm.setString(1, request.getAgentType());
1360 comm.setString(2, request.getServicehostname());
1361 comm.setLong(3, limit);
1362 comm.setLong(4, offset);
1363 }
1364 }
1365
1366 }
1367
1368
1369
1370
1371
1372
1373 if (comm==null){
1374 log.log(Level.FATAL, "unhandled query case for getRecentMessageLogs ");
1375 ServiceUnavailableException code = new ServiceUnavailableException("", null);
1376 code.getFaultInfo().setCode(ServiceUnavailableFaultCodes.UNEXPECTED_ERROR);
1377 throw code;
1378 }
1379 s = comm.executeQuery();
1380
1381 ArrayOfTransactionLog logs = new ArrayOfTransactionLog();
1382
1383
1384
1385
1386
1387 while (s.next()) {
1388
1389
1390
1391
1392 TransactionLog tl = new TransactionLog();
1393
1394 tl.setURL(s.getString("uri"));
1395 tl.setHasRequestMessage(false);
1396 tl.setHasResponseMessage(false);
1397 tl.setAction(s.getString("soapaction"));
1398 if (!Utility.stringIsNullOrEmpty(s.getString("RequestXML"))) {
1399 tl.setHasRequestMessage(true);
1400 }
1401 tl.setRequestSize(s.getLong("requestSize"));
1402 tl.setResponseSize(s.getLong("responseSize"));
1403 if (!Utility.stringIsNullOrEmpty(s.getString("ResponseXML"))) {
1404 tl.setHasResponseMessage(true);
1405 }
1406 tl.setIsFault(s.getBoolean("success"));
1407 tl.setMonitorHostname(s.getString("MonitorSource"));
1408 tl.setServiceHostname(s.getString("HostingSource"));
1409 tl.setResponseTime(s.getLong("ResponseTimeMS"));
1410 tl.setTransactionId(s.getString("TransactionID"));
1411
1412
1413 String t = null;
1414 try {
1415 t = s.getString("slafault");
1416
1417 } catch (Exception ex) {
1418 }
1419 if (Utility.stringIsNullOrEmpty(t)) {
1420 tl.setIsSLAFault(false);
1421 } else {
1422 tl.setIsSLAFault(true);
1423 PreparedStatement slacom=null;
1424 ResultSet tempset=null;
1425 try {
1426 slacom = con.prepareStatement("select msg from slaviolations where uri=? and incidentid=?;");
1427 slacom.setString(1, request.getURL());
1428 slacom.setString(2, t);
1429 tempset = slacom.executeQuery();
1430 if (tempset.next()) {
1431 byte[] x = (byte[]) tempset.getBytes("msg");
1432 if (x != null) {
1433 tl.setSlaFaultMsg(new String(x, Constants.CHARSET));
1434 }
1435 }
1436 } catch (Exception ex) {
1437 tl.setSlaFaultMsg("Fault message unavailable");
1438 log.log(Level.ERROR, "error parsing sla fault message from db", ex);
1439 } finally {
1440 DBUtils.safeClose(tempset);
1441 DBUtils.safeClose(slacom);
1442 }
1443 }
1444
1445 GregorianCalendar c = new GregorianCalendar();
1446 c.setTimeInMillis(s.getLong("utcdatetime"));
1447 tl.setTimestamp((c));
1448
1449 if (!Utility.stringIsNullOrEmpty(s.getString("ConsumerIdentity"))) {
1450 String temp = s.getString("ConsumerIdentity");
1451 if (!Utility.stringIsNullOrEmpty(temp)) {
1452 String[] ids = temp.split(";");
1453
1454 for (int i = 0; i < ids.length; i++) {
1455
1456 tl.getIdentity().add(ids[i]);
1457 }
1458
1459
1460
1461 }
1462 }
1463
1464 logs.getTransactionLog().add(tl);
1465 }
1466 ret.setTotalRecords(totalrecords);
1467 ret.setClassification(DAS4jBean.getCurrentClassificationLevel());
1468
1469
1470
1471 ret.setLogs((logs));
1472
1473 return ret;
1474 } catch (Exception ex) {
1475 log.log(Level.ERROR, "getMessageLogs", ex);
1476
1477 } finally {
1478 DBUtils.safeClose(results2);
1479 DBUtils.safeClose(s);
1480 DBUtils.safeClose(comm);
1481 DBUtils.safeClose(comm2);
1482 DBUtils.safeClose(con);
1483 }
1484
1485 ServiceUnavailableException code = new ServiceUnavailableException("", null);
1486 code.getFaultInfo().setCode(ServiceUnavailableFaultCodes.UNEXPECTED_ERROR);
1487 throw code;
1488 }
1489 }