- Timestamp:
- 07/07/11 11:04:27 (13 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.