| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
package net.sourceforge.pebble.web.action; |
| 33 |
|
|
| 34 |
|
import net.sourceforge.pebble.Constants; |
| 35 |
|
import net.sourceforge.pebble.domain.Blog; |
| 36 |
|
import net.sourceforge.pebble.logging.Log; |
| 37 |
|
import net.sourceforge.pebble.logging.LogEntry; |
| 38 |
|
import net.sourceforge.pebble.logging.Request; |
| 39 |
|
import net.sourceforge.pebble.web.view.View; |
| 40 |
|
import net.sourceforge.pebble.web.view.impl.RequestsByTypeView; |
| 41 |
|
|
| 42 |
|
import javax.servlet.ServletException; |
| 43 |
|
import javax.servlet.http.HttpServletRequest; |
| 44 |
|
import javax.servlet.http.HttpServletResponse; |
| 45 |
|
import java.util.Collection; |
| 46 |
|
import java.util.HashSet; |
| 47 |
|
import java.util.Set; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
@author |
| 53 |
|
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 4 |
Complexity Density: 0,11 |
|
| 54 |
|
public class ViewRequestsByTypeAction extends AbstractLogAction { |
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
@param |
| 60 |
|
@param |
| 61 |
|
@return |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 41 (41) |
Complexity: 4 |
Complexity Density: 0,11 |
|
| 63 |
0
|
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... |
| 64 |
0
|
Blog blog = (Blog)getModel().get(Constants.BLOG_KEY); |
| 65 |
0
|
Log log = getLog(request, response); |
| 66 |
|
|
| 67 |
0
|
Collection<Request> requests = log.getRequests(); |
| 68 |
0
|
Set<String> uniqueIps = new HashSet<String>(); |
| 69 |
0
|
Set<String> uniqueIpsForNewsFeeds = new HashSet<String>(); |
| 70 |
0
|
Set<String> uniqueIpsForPageViews = new HashSet<String>(); |
| 71 |
0
|
Set<String> uniqueIpsForFileDownloads = new HashSet<String>(); |
| 72 |
0
|
int totalNewsFeedRequests = 0; |
| 73 |
0
|
int totalPageViews = 0; |
| 74 |
0
|
int totalFileDownloads = 0; |
| 75 |
|
|
| 76 |
0
|
for (Request aRequest : requests) { |
| 77 |
0
|
for (LogEntry logEntry : aRequest.getLogEntries()) { |
| 78 |
0
|
uniqueIps.add(logEntry.getHost()); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
0
|
if (aRequest.isNewsFeed()) { |
| 82 |
0
|
totalNewsFeedRequests += aRequest.getCount(); |
| 83 |
0
|
for (LogEntry logEntry : aRequest.getLogEntries()) { |
| 84 |
0
|
uniqueIpsForNewsFeeds.add(logEntry.getHost()); |
| 85 |
|
} |
| 86 |
0
|
} else if (aRequest.isPageView()) { |
| 87 |
0
|
totalPageViews += aRequest.getCount(); |
| 88 |
0
|
for (LogEntry logEntry : aRequest.getLogEntries()) { |
| 89 |
0
|
uniqueIpsForPageViews.add(logEntry.getHost()); |
| 90 |
|
} |
| 91 |
0
|
} else if (aRequest.isFileDownload()) { |
| 92 |
0
|
totalFileDownloads += aRequest.getCount(); |
| 93 |
0
|
for (LogEntry logEntry : aRequest.getLogEntries()) { |
| 94 |
0
|
uniqueIpsForFileDownloads.add(logEntry.getHost()); |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
|
|
| 99 |
0
|
getModel().put("logAction", "viewRequestsByType"); |
| 100 |
0
|
getModel().put("totalRequests", log.getTotalLogEntries()); |
| 101 |
0
|
getModel().put("uniqueIps", uniqueIps.size()); |
| 102 |
0
|
getModel().put("totalNewsfeedRequests", totalNewsFeedRequests); |
| 103 |
0
|
getModel().put("uniqueIpsForNewsFeeds", uniqueIpsForNewsFeeds.size()); |
| 104 |
0
|
getModel().put("totalPageViews", totalPageViews); |
| 105 |
0
|
getModel().put("uniqueIpsForPageViews", uniqueIpsForPageViews.size()); |
| 106 |
0
|
getModel().put("totalFileDownloads", totalFileDownloads); |
| 107 |
0
|
getModel().put("uniqueIpsForFileDownloads", uniqueIpsForFileDownloads.size()); |
| 108 |
|
|
| 109 |
0
|
return new RequestsByTypeView(); |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
} |