mestihudson / acuteauto

Automatically exported from code.google.com/p/acuteauto
0 stars 0 forks source link

Implement VIN decoder - Phase II #12

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Currently, the dealer has to manually key in all the regular fields while 
adding vehicle to inventory.

Proposed : By entering the VIN, we should be able to use the VIN Decoder to 
pull in all the basic details of the vehicle and prepopulate them on the page 
thereby minimizing the time taken for each entry and enhancing the data quality.

Availability : VIN Decoder is not available as a free algorithm nor as a free 
webservice. Third party sites like VINQuery.com etc. provide a webservice and 
charge on a volume/time basis. 
We can utilize the free online website http://www.decodethis.com to pass the 
VIN number and retrieve the results.

Following details are expected to be pulled from this solution
Make, Model, Style, Year, Engine, Transmission, Exterior Color, Interior Color, 

Original issue reported on code.google.com by Mansur...@gmail.com on 11 Jul 2012 at 6:43

GoogleCodeExporter commented 8 years ago

Original comment by Mansur...@gmail.com on 11 Jul 2012 at 7:49

GoogleCodeExporter commented 8 years ago
Sample Code : 
private static String url = 
"http://www.decodethis.com/Default.aspx?tabId=65&vin={0}";      
// new method
try {
// Create an HTTP client and set up simple parameters
HttpClient client = new HttpClient();   
client.getParams().setCookiePolicy(CookiePolicy.NETSCAPE);              
client.getParams().setConnectionManagerTimeout(10000);
client.getParams().setSoTimeout(ASYNC_WAIT_PERIOD); 
String formattedUrl = MessageFormat.format(url, "2HNYD28219H518968");

HttpMethod method = new GetMethod(formattedUrl);
int htmlStatus = 0;
String htmlResult = "";
try {
System.out.println("BatchProcessor calling '" + formattedUrl + "'.");
htmlStatus = client.executeMethod(method);
} catch (java.net.SocketTimeoutException ste) {
// This is ok... we are just timing out 
if (isAsync) {
System.out.println("... Back to BatchProcessor - Exiting because of ASYNC 
mode.");
}
} catch (ConnectException ce) {
System.out.println("Error: Could not connect to Faces page.");
throw new Exception("Could not connect to faces page: " + url);
} catch (Exception e) {
// Not so good. throw this guy
throw e;
}
// Let go of the connection. Otherwise, it just holds on forever.
htmlResult = method.getResponseBodyAsString();
method.releaseConnection();
Pattern pattern = Pattern.compile("Year</td><td>\\d{4}\\s*</td>");
Matcher matcher = pattern.matcher(htmlResult);
while(matcher.find()) {
System.out.println(htmlResult.substring(matcher.start(), matcher.end()));               
}           
client = null;
if (htmlStatus > 200) {
System.out.println("Error in HTML: " + htmlResult);
result = false;
} else {
if (isAsync) {
result = true;
} 
}
System.out.println("BatchProcessor control returned. Result of batch: " + 
htmlResult);
System.out.println("Batch task '" + report + "' completed with status Success 
");
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
}

Original comment by Mansur...@gmail.com on 11 Jul 2012 at 9:17

GoogleCodeExporter commented 8 years ago

Original comment by Mansur...@gmail.com on 22 Jan 2013 at 7:15