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