Changeset 111 for trunk/EventBenchConsole/src/de
- Timestamp:
- 07/07/11 11:04:27 (13 years ago)
- Location:
- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/WeblogParser.java
r78 r111 3 3 import java.io.FileNotFoundException; 4 4 import java.io.IOException; 5 import java.net.URI; 6 import java.net.URISyntaxException; 5 7 import java.text.ParseException; 6 8 import java.text.SimpleDateFormat; … … 47 49 } 48 50 49 public void parseFile(String filename) throws IOException, FileNotFoundException, ParseException {51 public void parseFile(String filename) throws IOException, FileNotFoundException, ParseException, URISyntaxException { 50 52 String[] lines = FileTools.getLinesFromFile(filename); 51 53 … … 66 68 String dateString = values[1]; 67 69 long timestamp = dateFormat.parse(dateString).getTime(); 68 String uri = values[2];70 String uriString = values[2]; 69 71 // String ref = values[3]; // referer is not yet used! 70 72 String agent; … … 77 79 List<String> postedVars = new ArrayList<String>(); 78 80 if( values.length==6 ) { // post vars found 79 for( String postVar : values[5]. split(" ") ) {81 for( String postVar : values[5].trim().split(" ") ) { 80 82 postedVars.add(postVar); 81 83 } 82 84 } 83 85 if( !isRobot(agent) ) { 84 WebEvent event = new WebEvent(uri, timestamp, postedVars); 86 URI uri = new URI(uriString); 87 88 String path = uri.getPath(); 89 List<String> getVars = extractGetVarsFromUri(uri); 90 91 WebEvent event = new WebEvent(path, timestamp, postedVars, getVars); 85 92 86 93 // find session and add event … … 141 148 return agent.matches(robotRegex); 142 149 } 150 151 private List<String> extractGetVarsFromUri(URI uri) { 152 List<String> getVars = new ArrayList<String>(); 153 String query = uri.getQuery(); 154 if( query!=null ) { 155 String[] paramPairs = query.split("&"); 156 for( String paramPair : paramPairs ) { 157 String[] paramSplit = paramPair.split("="); 158 getVars.add(paramSplit[0]); 159 } 160 } 161 return getVars; 162 } 143 163 } -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/commands/CMDloadSessionsFromClickstream.java
r84 r111 3 3 import java.io.FileNotFoundException; 4 4 import java.io.IOException; 5 import java.net.URISyntaxException; 5 6 import java.security.InvalidParameterException; 6 7 import java.text.ParseException; … … 41 42 Console.println("Invalid format of date stamps."); 42 43 Console.println(e.getMessage()); 44 } catch (URISyntaxException e) { 45 Console.println("Invalid URI!"); 46 Console.println(e.getMessage()); 43 47 } 44 48 -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/data/WebEvent.java
r87 r111 8 8 9 9 /** 10 * <p> 10 11 * Id for object serialization. 12 * </p> 11 13 */ 12 14 private static final long serialVersionUID = 1L; 13 15 14 16 private final long timestamp; 15 private String uri;17 16 18 17 private final static String makeType(String uri, List<String> postVars) { 18 String type = uri; 19 private final static String makeType(String path, List<String> postVars, List<String> getVars) { 20 String type = path; 21 if( getVars!=null && !getVars.isEmpty() ) { 22 type += "+GET"+getVars.toString().replace(" ", ""); 23 } 19 24 if( postVars!=null && !postVars.isEmpty() ) { 20 type += postVars.toString().replace(" ", "");25 type += "+POST"+postVars.toString().replace(" ", ""); 21 26 } 22 27 return type; 23 28 } 24 29 25 public WebEvent(String uri, long timestamp, List<String> postVars) {26 super(makeType( uri, postVars));30 public WebEvent(String path, long timestamp, List<String> postVars, List<String> getVars) { 31 super(makeType(path, postVars, getVars)); 27 32 this.timestamp = timestamp; 28 this.uri = uri; 29 addReplayEvent(new WebRequest(uri, postVars)); 33 addReplayEvent(new WebRequest(path, postVars, getVars)); 30 34 } 31 35 -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/data/WebRequest.java
r90 r111 14 14 15 15 List<String> postVars; 16 List<String> getVars; 16 17 17 18 String targetUri; 18 19 19 public WebRequest(String uri, List<String> postVars ) {20 public WebRequest(String uri, List<String> postVars, List<String> getVars) { 20 21 targetUri = uri; 21 22 this.postVars = new ArrayList<String>(postVars); // defensive copy 23 this.getVars = new ArrayList<String>(getVars); 22 24 } 23 25 … … 33 35 return null; 34 36 } 37 38 @Override 39 public boolean equals(Object other) { 40 if( this==other ) { 41 return true; 42 } 43 if( other instanceof WebRequest ) { 44 return targetUri.equals(((WebRequest) other).targetUri) && postVars.equals(((WebRequest) other).postVars); 45 } 46 return false; 47 } 48 49 @Override 50 public int hashCode() { 51 int multiplier = 17; 52 int hash = 42; 53 54 hash = multiplier * hash + targetUri.hashCode(); 55 hash = multiplier * hash + postVars.hashCode(); 56 57 return hash; 58 } 35 59 36 60 }
Note: See TracChangeset
for help on using the changeset viewer.