Changeset 96
- Timestamp:
- 01/18/08 16:03:38 (11 months ago)
- Files:
-
- branches/routingservice/configuration.xml (modified) (1 diff)
- branches/routingservice/src/jp/co/orkney/restlet/geo/ClosestEdge.java (modified) (4 diffs)
- branches/routingservice/src/jp/co/orkney/restlet/geo/DrivingDistance.java (modified) (4 diffs)
- branches/routingservice/src/jp/co/orkney/restlet/geo/ShortestPath.java (modified) (4 diffs)
- branches/routingservice/src/jp/co/orkney/restlet/util/Configuration.java (modified) (4 diffs)
- branches/routingservice/src/jp/co/orkney/restlet/util/DatabaseConnection.java (modified) (4 diffs)
- branches/routingservice/src/jp/co/orkney/restlet/util/IOHelper.java (modified) (4 diffs)
- branches/routingservice/src/jp/co/orkney/restlet/util/Log.java (modified) (3 diffs)
- branches/routingservice/src/jp/co/orkney/restlet/WebRouting.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/routingservice/configuration.xml
r94 r96 2 2 <restlet> 3 3 <port>8182</port> 4 <log >./log/access.log</log>4 <log mode="0">./log/access.log</log> 5 5 <localhost>http://localhost</localhost> 6 6 <css>http://localhost/demo/css/style.css</css> branches/routingservice/src/jp/co/orkney/restlet/geo/ClosestEdge.java
r94 r96 22 22 23 23 import jp.co.orkney.restlet.util.IOHelper; 24 import jp.co.orkney.restlet.util.Log; 24 25 import jp.co.orkney.restlet.util.Point; 25 26 import jp.co.orkney.restlet.util.Configuration; … … 57 58 private Point point; 58 59 private Configuration configuration; 60 private Log log; 59 61 60 62 /** … … 72 74 { 73 75 this.configuration = configuration; 76 this.log = configuration.createLog(); 74 77 ioHelper = new IOHelper(configuration); 75 78 … … 140 143 query.setAttribute("sridOut", configuration.getService().getParameter("sridOutput").getValue()); 141 144 142 System.out.println(query.toString());145 log.write(query.toString(),1); 143 146 ResultSet rs = databaseConnection.getResult(query.toString()); 144 147 branches/routingservice/src/jp/co/orkney/restlet/geo/DrivingDistance.java
r95 r96 27 27 import jp.co.orkney.restlet.util.DatabaseConnection; 28 28 import jp.co.orkney.restlet.util.IOHelper; 29 import jp.co.orkney.restlet.util.Log; 29 30 import jp.co.orkney.restlet.util.Point; 30 31 … … 60 61 private int time; 61 62 private int length; 63 private Log log; 62 64 63 65 /** … … 75 77 { 76 78 this.configuration = configuration; 79 this.log = configuration.createLog(); 77 80 ioHelper = new IOHelper(configuration); 78 81 … … 177 180 query.setAttribute("sridOut", configuration.getService().getParameter("sridOutput").getValue()); 178 181 179 System.out.println(query.toString());182 log.write(query.toString(),1); 180 183 ResultSet rs = databaseConnection.getResult(query.toString()); 181 184 branches/routingservice/src/jp/co/orkney/restlet/geo/ShortestPath.java
r94 r96 25 25 26 26 import jp.co.orkney.restlet.util.IOHelper; 27 import jp.co.orkney.restlet.util.Log; 27 28 import jp.co.orkney.restlet.util.Point; 28 29 import jp.co.orkney.restlet.util.Configuration; … … 58 59 private Point endPoint; 59 60 private Configuration configuration; 61 private Log log; 60 62 61 63 /** 62 64 * Constructor ShortestPath 63 65 * <p> 64 * Creates a new ShortestPath object using the specifie d Configuration object66 * Creates a new ShortestPath object using the specifieSystem.out.println(query.toString());d Configuration object 65 67 * and extracts X and Y from the data provides by GET or POST request into a 66 68 * new point (for start and end point). … … 73 75 { 74 76 this.configuration = configuration; 77 this.log = configuration.createLog(); 75 78 ioHelper = new IOHelper(configuration); 76 79 … … 146 149 query.setAttribute("sridOut", configuration.getService().getParameter("sridOutput").getValue()); 147 150 148 System.out.println(query.toString());151 log.write(query.toString(),1); 149 152 ResultSet rs = databaseConnection.getResult(query.toString()); 150 153 branches/routingservice/src/jp/co/orkney/restlet/util/Configuration.java
r67 r96 61 61 private String port; 62 62 private String urlLog; 63 private int modeLog; 63 64 private String localhost; 64 65 private String urlCss; … … 84 85 port = ""; 85 86 urlLog = ""; 87 modeLog = 0; 86 88 localhost = ""; 87 89 urlCss = ""; … … 117 119 port = root.getChild("port").getText(); 118 120 urlLog = root.getChild("log").getText(); 121 modeLog = Integer.parseInt(root.getChild("log").getAttributeValue("mode")); 119 122 localhost = root.getChild("localhost").getText(); 120 123 urlCss = root.getChild("css").getText(); … … 282 285 public Log createLog() 283 286 { 284 return new Log(urlLog );287 return new Log(urlLog,modeLog); 285 288 } 286 289 branches/routingservice/src/jp/co/orkney/restlet/util/DatabaseConnection.java
r67 r96 76 76 public void start() 77 77 { 78 log.write("Database connection started" );78 log.write("Database connection started",1); 79 79 try 80 80 { … … 89 89 { 90 90 start = false; 91 log.write("--ERROR: unkown driver" );91 log.write("--ERROR: unkown driver",0); 92 92 } 93 93 catch (SQLException e) 94 94 { 95 95 start = false; 96 log.write("--ERROR: Can not connect to the database" );96 log.write("--ERROR: Can not connect to the database",0); 97 97 } 98 98 start = true; … … 124 124 catch (SQLException e1) 125 125 { 126 log.write("--ERROR: query execution failed" );127 e1.printStackTrace();126 log.write("--ERROR: query execution failed",0); 127 log.getStackTrace(e1); 128 128 } 129 129 return null; … … 140 140 statement.close(); 141 141 connection.close(); 142 log.write("Database connection finished" );142 log.write("Database connection finished",1); 143 143 } 144 144 catch (SQLException e) 145 145 { 146 log.write("--ERROR: Can not close the connection" );146 log.write("--ERROR: Can not close the connection",0); 147 147 } 148 148 } branches/routingservice/src/jp/co/orkney/restlet/util/IOHelper.java
r94 r96 88 88 catch (JSONException e) 89 89 { 90 log.write("--ERROR: Can not extract X and Y from Json object" );90 log.write("--ERROR: Can not extract X and Y from Json object",0); 91 91 } 92 92 … … 909 909 catch (JSONException e) 910 910 { 911 log.write("*ERROR* getOpenLayersIdFromGEOJSON()" );911 log.write("*ERROR* getOpenLayersIdFromGEOJSON()",0); 912 912 } 913 913 … … 936 936 catch (Exception e) 937 937 { 938 log.write("*ERROR* getOpenLayersIdFromGML()" );938 log.write("*ERROR* getOpenLayersIdFromGML()",0); 939 939 } 940 940 … … 963 963 catch (Exception e) 964 964 { 965 log.write("*ERROR* getOpenLayersIdFromKML()" );965 log.write("*ERROR* getOpenLayersIdFromKML()",0); 966 966 } 967 967 branches/routingservice/src/jp/co/orkney/restlet/util/Log.java
r67 r96 42 42 { 43 43 private String file; 44 private int mode;// 0 default mode, 1: debug mode, 2: full mode 44 45 45 46 /** … … 52 53 * logs file's URL 53 54 */ 54 public Log(String file )55 public Log(String file, int mode) 55 56 { 56 57 this.file = file; 58 this.mode = mode; 57 59 } 58 60 … … 63 65 * the string that is to be write in log file 64 66 */ 65 public void write(String text )67 public void write(String text, int mode) 66 68 { 67 try69 if (this.mode >= mode) 68 70 { 69 FileWriter fileWriter = new FileWriter(file, true); 70 BufferedWriter buffer = new BufferedWriter(fileWriter); 71 Calendar calendar = Calendar.getInstance(); 72 Date now = calendar.getTime(); 73 String datelog = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, Locale.FRANCE).format(now); 74 buffer.write("[" + datelog + "]: " + text); 75 buffer.newLine(); 76 buffer.close(); 71 try 72 { 73 FileWriter fileWriter = new FileWriter(file, true); 74 BufferedWriter buffer = new BufferedWriter(fileWriter); 75 Calendar calendar = Calendar.getInstance(); 76 Date now = calendar.getTime(); 77 String datelog = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, Locale.FRANCE).format(now); 78 buffer.write("[" + datelog + "]: " + text); 79 buffer.newLine(); 80 buffer.close(); 81 } 82 catch (IOException e) 83 { 84 System.out.println(e.getMessage()); 85 } 77 86 } 78 catch (IOException e) 87 } 88 89 /** 90 * Writes the stack trace information of the exception 91 * 92 * @param e 93 * exception 94 */ 95 public void getStackTrace(Exception e) 96 { 97 for (int i = 0; i < e.getStackTrace().length; i++) 79 98 { 80 System.out.println(e.getMessage());99 this.write(e.getStackTrace()[i].toString(), 2); 81 100 } 82 101 } branches/routingservice/src/jp/co/orkney/restlet/WebRouting.java
r94 r96 90 90 { 91 91 error = false; 92 log.write("Restlet HANDLE" );92 log.write("Restlet HANDLE",0); 93 93 94 94 try … … 98 98 catch (Exception e1) 99 99 { 100 log.write("--ERROR: Wrong URL" );100 log.write("--ERROR: Wrong URL",0); 101 101 System.out.println(e1.getMessage()); 102 102 error = true; … … 141 141 catch (IOException e1) 142 142 { 143 log.write("--ERROR: Reading data failed" );143 log.write("--ERROR: Reading data failed",0); 144 144 error = true; 145 145 } … … 157 157 catch (SQLException e) 158 158 { 159 log.write("--ERROR: Exception \"SQLException\" to draw the result"); 159 log.write("--ERROR: Exception \"SQLException\" to draw the result",0); 160 log.getStackTrace(e); 160 161 error = true; 161 162 } 162 163 catch (JSONException e) 163 164 { 164 log.write("--ERROR: Exception \"JSONException\" to draw the result"); 165 error = true; 166 } 167 log.write("Closest Edge algorithm started"); 165 log.write("--ERROR: Exception \"JSONException\" to draw the result",0); 166 log.write(e.getMessage(),1); 167 error = true; 168 } 169 log.write("Closest Edge algorithm started",1); 168 170 result = closestEdge.get(); 169 log.write("Closest Edge algorithm finished" );171 log.write("Closest Edge algorithm finished",1); 170 172 } 171 173 else if (configuration.getService().getName().equals("shortest_path")) … … 178 180 catch (SQLException e) 179 181 { 180 log.write("--ERROR: Exception \"SQLException\" to draw the result"); 182 log.write("--ERROR: Exception \"SQLException\" to draw the result",0); 183 log.write(e.getMessage(),1); 181 184 error = true; 182 185 } 183 186 catch (JSONException e) 184 187 { 185 log.write("--ERROR: Exception \"JSONException\" to draw the result"); 186 error = true; 187 } 188 log.write("Shortest Path algorithm started"); 188 log.write("--ERROR: Exception \"JSONException\" to draw the result",0); 189 log.write(e.getMessage(),1); 190 error = true; 191 } 192 log.write("Shortest Path algorithm started",1); 189 193 result = shortestPath.get(); 190 log.write("Shortest Path algorithm finished" );194 log.write("Shortest Path algorithm finished",1); 191 195 } 192 196 else if (configuration.getService().getName().equals("driving_distance")) … … 199 203 catch (SQLException e) 200 204 { 201 log.write("--ERROR: Exception \"SQLException\" to draw the result"); 205 log.write("--ERROR: Exception \"SQLException\" to draw the result",0); 206 log.write(e.getMessage(),1); 202 207 error = true; 203 208 } 204 209 catch (JSONException e) 205 210 { 206 log.write("--ERROR: Exception \"JSONException\" to draw the result"); 207 error = true; 208 } 209 log.write("Shortest Path algorithm started"); 211 log.write("--ERROR: Exception \"JSONException\" to draw the result",0); 212 log.write(e.getMessage(),1); 213 error = true; 214 } 215 log.write("Driving Distance algorithm started",1); 210 216 result = drivingDistance.get(); 211 log.write(" Shortest Path algorithm finished");217 log.write("Driving Distance algorithm finished",1); 212 218 }// <-- FIN 213 219

