Changeset 177


Ignore:
Timestamp:
09/10/11 00:30:54 (13 years ago)
Author:
sherbold
Message:
  • Changed handling of invalid URIs when parsing web usage logs. Before, the parsing was aborted, now, the entry with the invalid URI is ignored.
Location:
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/WeblogParser.java

    r176 r177  
    135135         * @throws ParseException 
    136136         *             thrown the date format is invalid 
    137          * @throws URISyntaxException 
    138          *             thrown if the URI is invalid 
    139137         */ 
    140138        public void parseFile(String filename) throws IOException, 
    141                         FileNotFoundException, ParseException, URISyntaxException { 
     139                        FileNotFoundException, ParseException { 
    142140                String[] lines = FileTools.getLinesFromFile(filename); 
    143141 
     
    151149                sequences = new ArrayList<List<WebEvent>>(); 
    152150 
     151                int lineCounter = 0; 
    153152                for (String line : lines) { 
     153                        lineCounter++; 
    154154                        String[] values = line.substring(1, line.length() - 1).split( 
    155155                                        "\" \""); 
     
    176176                        } 
    177177                        if (!isRobot(agent)) { 
    178                                 URI uri = new URI(uriString); 
    179  
    180                                 String path = uri.getPath(); 
    181                                 List<String> getVars = extractGetVarsFromUri(uri); 
    182  
    183                                 WebEvent event = new WebEvent(path, timestamp, postedVars, 
    184                                                 getVars); 
    185  
    186                                 // find session and add event 
    187                                 List<Integer> sessionIds = cookieSessionMap.get(cookie); 
    188                                 if (sessionIds == null) { 
    189                                         sessionIds = new ArrayList<Integer>(); 
    190                                         // start new session 
    191                                         sessionIds.add(++lastId); 
    192                                         cookieSessionMap.put(cookie, sessionIds); 
    193                                         sequences.add(new LinkedList<WebEvent>()); 
    194                                 } 
    195                                 Integer lastSessionIndex = sessionIds 
    196                                                 .get(sessionIds.size() - 1); 
    197                                 List<WebEvent> lastSession = sequences.get(lastSessionIndex); 
    198                                 long lastEventTime = timestamp; 
    199                                 if (!lastSession.isEmpty()) { 
    200                                         lastEventTime = lastSession.get(lastSession.size() - 1) 
    201                                                         .getTimestamp(); 
    202                                 } 
    203                                 if (timestamp - lastEventTime > timeout) { 
    204                                         sessionIds.add(++lastId); 
    205                                         List<WebEvent> newSession = new LinkedList<WebEvent>(); 
    206                                         newSession.add(event); 
    207                                         sequences.add(newSession); 
    208                                 } else { 
    209                                         lastSession.add(event); 
     178                                try { 
     179                                        URI uri = new URI(uriString); 
     180                                        String path = uri.getPath(); 
     181                                        List<String> getVars = extractGetVarsFromUri(uri); 
     182         
     183                                        WebEvent event = new WebEvent(path, timestamp, postedVars, 
     184                                                        getVars); 
     185         
     186                                        // find session and add event 
     187                                        List<Integer> sessionIds = cookieSessionMap.get(cookie); 
     188                                        if (sessionIds == null) { 
     189                                                sessionIds = new ArrayList<Integer>(); 
     190                                                // start new session 
     191                                                sessionIds.add(++lastId); 
     192                                                cookieSessionMap.put(cookie, sessionIds); 
     193                                                sequences.add(new LinkedList<WebEvent>()); 
     194                                        } 
     195                                        Integer lastSessionIndex = sessionIds 
     196                                                        .get(sessionIds.size() - 1); 
     197                                        List<WebEvent> lastSession = sequences.get(lastSessionIndex); 
     198                                        long lastEventTime = timestamp; 
     199                                        if (!lastSession.isEmpty()) { 
     200                                                lastEventTime = lastSession.get(lastSession.size() - 1) 
     201                                                                .getTimestamp(); 
     202                                        } 
     203                                        if (timestamp - lastEventTime > timeout) { 
     204                                                sessionIds.add(++lastId); 
     205                                                List<WebEvent> newSession = new LinkedList<WebEvent>(); 
     206                                                newSession.add(event); 
     207                                                sequences.add(newSession); 
     208                                        } else { 
     209                                                lastSession.add(event); 
     210                                        } 
     211                                } catch (URISyntaxException e) { 
     212                                        Console.traceln("Ignored line " + lineCounter + ": " + e.getMessage()); 
    210213                                } 
    211214                        } 
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/commands/CMDloadSessionsFromClickstream.java

    r176 r177  
    33import java.io.FileNotFoundException; 
    44import java.io.IOException; 
    5 import java.net.URISyntaxException; 
    65import java.security.InvalidParameterException; 
    76import java.text.ParseException; 
     
    5251                        Console.println("Invalid format of date stamps."); 
    5352                        Console.println(e.getMessage()); 
    54                 } catch (URISyntaxException e) { 
    55                         Console.println("Invalid URI!"); 
    56                         Console.println(e.getMessage()); 
    57                 } 
     53                }  
    5854                 
    5955                if( GlobalDataContainer.getInstance().addData("sequences", parser.getSequences()) ) { 
Note: See TracChangeset for help on using the changeset viewer.