| 1 | |
package org.paneris.bibliomania.metasearch.bob; |
| 2 | |
|
| 3 | |
import java.io.File; |
| 4 | |
import java.io.FileNotFoundException; |
| 5 | |
import java.io.IOException; |
| 6 | |
import java.util.Enumeration; |
| 7 | |
|
| 8 | |
import org.melati.poem.transaction.ToTidyList; |
| 9 | |
import org.melati.util.UTF8URLEncoder; |
| 10 | |
import org.paneris.bibliomania.BookStocking; |
| 11 | |
import org.paneris.bibliomania.metasearch.BOLAndBOBBackendBase; |
| 12 | |
import org.paneris.bibliomania.metasearch.BookPageBase; |
| 13 | |
import org.paneris.bibliomania.metasearch.BookStockingFactory; |
| 14 | |
|
| 15 | |
import com.sleepycat.db.DatabaseException; |
| 16 | |
|
| 17 | |
public class Backend extends BOLAndBOBBackendBase { |
| 18 | |
|
| 19 | |
public static final String url = "http://bookshop.blackwell.co.uk"; |
| 20 | |
|
| 21 | |
public Backend(File dbHome, int isbnOfPrdidCacheSize) |
| 22 | |
throws FileNotFoundException, DatabaseException { |
| 23 | 0 | super(dbHome, "bob_isbnAndImageOfPrdid.db", isbnOfPrdidCacheSize, url); |
| 24 | 0 | } |
| 25 | |
|
| 26 | |
public byte[] productPage_nonaffil(BookStocking stocking) |
| 27 | |
throws IOException { |
| 28 | 0 | return Session.content(url + stocking.getDetailurl_unsafe(), 16384, 100000); |
| 29 | |
} |
| 30 | |
|
| 31 | |
protected BookPageBase bookPage(byte[] text) { |
| 32 | 0 | return new BookPage(text); |
| 33 | |
} |
| 34 | |
|
| 35 | |
public String notifiedOfferedLinkHTML(BookStocking stocking) { |
| 36 | 0 | return ""; |
| 37 | |
} |
| 38 | |
|
| 39 | |
public String productURL(BookStocking stocking) { |
| 40 | 0 | return Session.urlInCurrentSession(url + stocking.getDetailurl_unsafe()); |
| 41 | |
} |
| 42 | |
|
| 43 | |
public static String searchURL( |
| 44 | |
String title, |
| 45 | |
String author, |
| 46 | |
String publisher, |
| 47 | |
String keyword) { |
| 48 | 0 | return url |
| 49 | |
+ "/cgi-bin/BOB2" |
| 50 | |
+ "?BV_ServiceName=BOB" |
| 51 | |
+ "&form%25destination=%2Fbob%2Fbob_searchresults.html.tmpl" |
| 52 | |
+ "&form%25destination_type=template" |
| 53 | |
+ "&consumer_submit00000%25destination=%2Fbob%2Fbob_searchresults.html.tmpl" |
| 54 | |
+ "&consumer_submit00000%25destination_type=template" |
| 55 | |
+ "&consumer_submit00000%25save_options=0" |
| 56 | |
+ "&consumer_submit00000%25clear_cat_name=0" |
| 57 | |
+ "&consumer_submit00000%25check_data=1" |
| 58 | |
+ "&form%25title=" |
| 59 | |
+ UTF8URLEncoder.encode(title) |
| 60 | |
+ "&form%25titleOp=AND" |
| 61 | |
+ "&form%25author=" |
| 62 | |
+ UTF8URLEncoder.encode(author) |
| 63 | |
+ "&form%25authorOp=AND" |
| 64 | |
+ "&form%25publisher=" |
| 65 | |
+ UTF8URLEncoder.encode(publisher) |
| 66 | |
+ "&form%25keywords=" |
| 67 | |
+ UTF8URLEncoder.encode(keyword) |
| 68 | |
+ "&form%25keywordsOp=AND" |
| 69 | |
+ "&form%25keywordType=ANYWHERE" |
| 70 | |
+ "&form%25isbn=" |
| 71 | |
+ "&form%25minPrice=" |
| 72 | |
+ "&form%25maxPrice=" |
| 73 | |
+ "&form%25fromPubDate=" |
| 74 | |
+ "&form%25toPubDate=" |
| 75 | |
+ "&consumer_submit00001%25destination=%2Fbob%2Fbob_categoryselector.html.tmpl" |
| 76 | |
+ "&consumer_submit00001%25destination_type=template" |
| 77 | |
+ "&consumer_submit00001%25save_options=0" |
| 78 | |
+ "&consumer_submit00001%25clear_cat_name=1" |
| 79 | |
+ "&consumer_submit00001%25check_data=" |
| 80 | |
+ "&form%25category=" |
| 81 | |
+ "&form%25UK_TITLES=1" |
| 82 | |
+ "&form%25ALLAVAIL=1" |
| 83 | |
+ "&NO_DISPLAY_RESULTS=1" |
| 84 | |
+ "&consumer_input%25NO_DISPLAY_RESULTS=select%25integer%25NO_DISPLAY_RESULTS" |
| 85 | |
+ "&form%25SORT_OPTION1=1" |
| 86 | |
+ "&consumer_input%25IS_SORT1_DESC=checkbox%25integer%25IS_SORT1_DESC" |
| 87 | |
+ "&form%25SORT_OPTION2=0" |
| 88 | |
+ "&consumer_input%25IS_SORT2_DESC=checkbox%25integer%25IS_SORT2_DESC" |
| 89 | |
+ "&form%25SORT_OPTION3=0" |
| 90 | |
+ "&consumer_input%25IS_SORT3_DESC=checkbox%25integer%25IS_SORT3_DESC" |
| 91 | |
+ "&form%25SORT_OPTION4=0" |
| 92 | |
+ "&consumer_input%25IS_SORT4_DESC=checkbox%25integer%25IS_SORT4_DESC" |
| 93 | |
+ "&consumer_submit00002%25destination=%2Fbob%2Fbob_searchresults.html.tmpl" |
| 94 | |
+ "&consumer_submit00002%25destination_type=template" |
| 95 | |
+ "&consumer_submit00002%25save_options=0" |
| 96 | |
+ "&consumer_submit00002%25clear_cat_name=0" |
| 97 | |
+ "&consumer_submit00002%25check_data=1" |
| 98 | |
+ "&BV_Operation=BOB_ConsumerCriteriaReceive" |
| 99 | |
+ "&submit%25consumer_submit00000.x=16" |
| 100 | |
+ "&submit%25consumer_submit00000.y=16"; |
| 101 | |
} |
| 102 | |
|
| 103 | |
public Enumeration booksMatching( |
| 104 | |
BookStockingFactory stockings, |
| 105 | |
String title, |
| 106 | |
String author, |
| 107 | |
String publisher, |
| 108 | |
String keyword, |
| 109 | |
ToTidyList toTidy) |
| 110 | |
throws IOException { |
| 111 | |
|
| 112 | 0 | return new SearchResults( |
| 113 | |
Session.content( |
| 114 | |
searchURL(title, author, publisher, keyword), |
| 115 | |
65536, |
| 116 | |
100000), |
| 117 | |
stockings); |
| 118 | |
} |
| 119 | |
} |