1 | package de.ugoe.cs.eventbench.web.data;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 |
|
---|
5 | import de.ugoe.cs.eventbench.data.ReplayableEvent;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * <p>
|
---|
9 | * This class defines web events (of PHP-based web applications).
|
---|
10 | * </p>
|
---|
11 | *
|
---|
12 | * @author Steffen Herbold
|
---|
13 | * @version 1.0
|
---|
14 | *
|
---|
15 | */
|
---|
16 | public class WebEvent extends ReplayableEvent<WebRequest> {
|
---|
17 |
|
---|
18 | private static final long serialVersionUID = 1L;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * <p>
|
---|
22 | * Timestamp of the event.
|
---|
23 | * </p>
|
---|
24 | */
|
---|
25 | private final long timestamp;
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * <p>
|
---|
29 | * Helper method that generates the type of the event based on the of the
|
---|
30 | * URI, the POST variables, and the GET variables.
|
---|
31 | * </p>
|
---|
32 | *
|
---|
33 | * @param path
|
---|
34 | * path of the URI of the event
|
---|
35 | * @param postVars
|
---|
36 | * POST variables send with the event
|
---|
37 | * @param getVars
|
---|
38 | * GET variables send with the event
|
---|
39 | * @return type of the event
|
---|
40 | */
|
---|
41 | private final static String makeType(String path, List<String> postVars,
|
---|
42 | List<String> getVars) {
|
---|
43 | String type = path;
|
---|
44 | if (getVars != null && !getVars.isEmpty()) {
|
---|
45 | type += "+GET" + getVars.toString().replace(" ", "");
|
---|
46 | }
|
---|
47 | if (postVars != null && !postVars.isEmpty()) {
|
---|
48 | type += "+POST" + postVars.toString().replace(" ", "");
|
---|
49 | }
|
---|
50 | return type;
|
---|
51 | }
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * <p>
|
---|
55 | * Constructor. Creates a new WebEvent.
|
---|
56 | * </p>
|
---|
57 | *
|
---|
58 | * @param url
|
---|
59 | * URL of the server that received the event
|
---|
60 | * @param path
|
---|
61 | * path of the URI
|
---|
62 | * @param timestamp
|
---|
63 | * timestamp of when the event took place
|
---|
64 | * @param postVars
|
---|
65 | * POST variables send with the event
|
---|
66 | * @param getVars
|
---|
67 | * GET variables send with the event
|
---|
68 | */
|
---|
69 | public WebEvent(String url, String path, long timestamp,
|
---|
70 | List<String> postVars, List<String> getVars) {
|
---|
71 | super(makeType(path, postVars, getVars));
|
---|
72 | this.timestamp = timestamp;
|
---|
73 | super.setTarget(path);
|
---|
74 | addReplayEvent(new WebRequest(url, path, postVars, getVars));
|
---|
75 | }
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * <p>
|
---|
79 | * Returns the timestamp of the event.
|
---|
80 | * </p>
|
---|
81 | *
|
---|
82 | * @return timestamp of th event
|
---|
83 | */
|
---|
84 | public long getTimestamp() {
|
---|
85 | return timestamp;
|
---|
86 | }
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * (non-Javadoc)
|
---|
90 | *
|
---|
91 | * @see de.ugoe.cs.eventbench.data.ReplayableEvent#equals(java.lang.Object)
|
---|
92 | */
|
---|
93 | @Override
|
---|
94 | public boolean equals(Object other) {
|
---|
95 | return super.equals(other);
|
---|
96 | }
|
---|
97 |
|
---|
98 | /*
|
---|
99 | * (non-Javadoc)
|
---|
100 | *
|
---|
101 | * @see de.ugoe.cs.eventbench.data.ReplayableEvent#hashCode()
|
---|
102 | */
|
---|
103 | @Override
|
---|
104 | public int hashCode() {
|
---|
105 | return super.hashCode();
|
---|
106 | }
|
---|
107 |
|
---|
108 | }
|
---|