| 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.comparator.CountedUrlByCountComparator; |
| 36 |
|
import net.sourceforge.pebble.comparator.CountedUrlByNameComparator; |
| 37 |
|
import net.sourceforge.pebble.domain.Blog; |
| 38 |
|
import net.sourceforge.pebble.logging.CountedUrl; |
| 39 |
|
import net.sourceforge.pebble.logging.Log; |
| 40 |
|
import net.sourceforge.pebble.web.view.View; |
| 41 |
|
import net.sourceforge.pebble.web.view.impl.RequestsView; |
| 42 |
|
|
| 43 |
|
import javax.servlet.ServletException; |
| 44 |
|
import javax.servlet.http.HttpServletRequest; |
| 45 |
|
import javax.servlet.http.HttpServletResponse; |
| 46 |
|
import java.util.ArrayList; |
| 47 |
|
import java.util.Collections; |
| 48 |
|
import java.util.Iterator; |
| 49 |
|
import java.util.List; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@author |
| 55 |
|
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 5 |
Complexity Density: 0,26 |
|
| 56 |
|
public class ViewRequestsAction extends AbstractLogAction { |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
@param |
| 62 |
|
@param |
| 63 |
|
@return |
| 64 |
|
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 5 |
Complexity Density: 0,26 |
|
| 65 |
0
|
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... |
| 66 |
0
|
Blog blog = (Blog)getModel().get(Constants.BLOG_KEY); |
| 67 |
0
|
Log log = getLog(request, response); |
| 68 |
|
|
| 69 |
0
|
List requests = new ArrayList(log.getRequests()); |
| 70 |
|
|
| 71 |
0
|
String sort = request.getParameter("sort"); |
| 72 |
0
|
if (sort == null || sort.trim().equals("")) { |
| 73 |
0
|
sort = "rank"; |
| 74 |
|
} |
| 75 |
0
|
if (sort.equals("name")) { |
| 76 |
0
|
Collections.sort(requests, new CountedUrlByNameComparator()); |
| 77 |
|
} else { |
| 78 |
0
|
Collections.sort(requests, new CountedUrlByCountComparator()); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
0
|
int totalRequests = 0; |
| 83 |
0
|
Iterator it = requests.iterator(); |
| 84 |
0
|
CountedUrl url; |
| 85 |
0
|
while (it.hasNext()) { |
| 86 |
0
|
url = (CountedUrl)it.next(); |
| 87 |
0
|
totalRequests += url.getCount(); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
0
|
getModel().put("logAction", "viewRequests"); |
| 91 |
0
|
getModel().put("requests", requests); |
| 92 |
0
|
getModel().put("totalRequests", new Integer(totalRequests)); |
| 93 |
|
|
| 94 |
0
|
return new RequestsView(); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
} |