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