public abstract class BaseApi extends java.lang.Object implements OpacApi
OpacApi.CancelResult, OpacApi.MultiStepResult, OpacApi.OpacErrorException, OpacApi.ProlongAllResult, OpacApi.ProlongResult, OpacApi.ReservationResult
Modifier and Type | Field and Description |
---|---|
protected org.apache.http.client.HttpClient |
http_client |
protected boolean |
httpLoggingEnabled |
protected boolean |
initialised |
protected static java.lang.String |
KEY_SEARCH_QUERY_AUDIENCE
Some libraries support a special "audience" field with specified values.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_AUTHOR
Author name to search for.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_AVAILABLE
Restrict search to available media.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_BARCODE
Unique item identifier.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_BRANCH
Library branch to search in.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_CATEGORY
Item category (like "book" or "CD").
|
protected static java.lang.String |
KEY_SEARCH_QUERY_DIGITAL
Restrict search to digital media.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_FREE
Keywords to do a free search.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_HOME_BRANCH
"Home" library branch.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_ISBN
An ISBN / EAN code to search for.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_KEYWORDA
"Keyword A".
|
protected static java.lang.String |
KEY_SEARCH_QUERY_KEYWORDB
"Keyword B".
|
protected static java.lang.String |
KEY_SEARCH_QUERY_LOCATION
Item location in library.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_ORDER
Sort search results in a specific order
This is only used internally to construct search fields.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_PUBLISHER
The "publisher" search field
This is only used internally to construct search fields.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_SYSTEM
Systematic identification, used in some libraries.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_TITLE
Item title to search for.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_YEAR
Year of publication.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_YEAR_RANGE_END
Start of range, if year of publication can be specified as a range.
|
protected static java.lang.String |
KEY_SEARCH_QUERY_YEAR_RANGE_START
End of range, if year of publication can be specified as a range.
|
protected Library |
library |
protected StringProvider |
stringProvider |
protected java.util.Set<java.lang.String> |
supportedLanguages |
SUPPORT_FLAG_ACCOUNT_PROLONG_ALL, SUPPORT_FLAG_CHANGE_ACCOUNT, SUPPORT_FLAG_ENDLESS_SCROLLING, SUPPORT_FLAG_QUICKLINKS, SUPPORT_FLAG_WARN_PROLONG_FEES, SUPPORT_FLAG_WARN_RESERVATION_FEES
Constructor and Description |
---|
BaseApi() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
buildHttpGetParams(java.util.List<org.apache.http.NameValuePair> params) |
static java.lang.String |
cleanUrl(java.lang.String myURL)
Cleans the parameters of a URL by parsing it manually and reformatting it using
URLEncodedUtils.format(java.util.List, String) |
protected static java.lang.String |
convertStreamToString(java.io.InputStream is)
Reads content from an InputStream into a string, using the default
ISO-8859-1
encoding |
protected static java.lang.String |
convertStreamToString(java.io.InputStream is,
java.lang.String encoding)
Reads content from an InputStream into a string
|
void |
downloadCover(CoverHolder item)
Downloads a cover to a CoverHolder.
|
protected java.lang.String |
getDefaultEncoding() |
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getQueryParams(java.lang.String url) |
static java.util.Map<java.lang.String,java.lang.String> |
getQueryParamsFirst(java.lang.String url) |
java.util.List<SearchField> |
getSearchFields()
Returns a list of search criteria which are supported by this OPAC and should be visible in
the search activity.
|
java.lang.String |
httpGet(java.lang.String url)
Deprecated.
|
java.lang.String |
httpGet(java.lang.String url,
java.lang.String encoding) |
java.lang.String |
httpGet(java.lang.String url,
java.lang.String encoding,
boolean ignore_errors) |
java.lang.String |
httpGet(java.lang.String url,
java.lang.String encoding,
boolean ignore_errors,
org.apache.http.client.CookieStore cookieStore)
Perform a HTTP GET request to a given URL
|
java.lang.String |
httpPost(java.lang.String url,
org.apache.http.HttpEntity data)
Deprecated.
|
java.lang.String |
httpPost(java.lang.String url,
org.apache.http.HttpEntity data,
java.lang.String encoding) |
java.lang.String |
httpPost(java.lang.String url,
org.apache.http.HttpEntity data,
java.lang.String encoding,
boolean ignore_errors) |
java.lang.String |
httpPost(java.lang.String url,
org.apache.http.HttpEntity data,
java.lang.String encoding,
boolean ignore_errors,
org.apache.http.client.CookieStore cookieStore)
Perform a HTTP POST request to a given URL
|
void |
init(Library library,
HttpClientFactory http_client_factory)
Initializes HTTP client and String Provider
|
protected void |
logHttpError(java.lang.Throwable e) |
abstract java.util.List<SearchField> |
parseSearchFields() |
protected static java.util.Map<java.lang.String,java.lang.String> |
searchQueryListToMap(java.util.List<SearchQuery> queryList)
|
void |
setHttpLoggingEnabled(boolean httpLoggingEnabled) |
void |
setStringProvider(StringProvider stringProvider)
Sets the StringProvider to use for error messages etc.
|
protected boolean |
shouldUseMeaningDetector() |
void |
start()
May be called on application startup and you are free to call it in our
OpacApi.search(java.util.List<de.geeksfactory.opacclient.searchfields.SearchQuery>)
implementation or similar positions. |
SearchRequestResult |
volumeSearch(java.util.Map<java.lang.String,java.lang.String> query)
Performs a catalogue search for volumes of an item.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
account, cancel, checkAccountData, filterResults, getResult, getResultById, getShareUrl, getSupportedLanguages, getSupportFlags, prolong, prolongAll, reservation, search, searchGetPage, setLanguage
protected org.apache.http.client.HttpClient http_client
protected Library library
protected StringProvider stringProvider
protected java.util.Set<java.lang.String> supportedLanguages
protected boolean initialised
protected boolean httpLoggingEnabled
protected static final java.lang.String KEY_SEARCH_QUERY_FREE
protected static final java.lang.String KEY_SEARCH_QUERY_TITLE
protected static final java.lang.String KEY_SEARCH_QUERY_AUTHOR
protected static final java.lang.String KEY_SEARCH_QUERY_KEYWORDA
protected static final java.lang.String KEY_SEARCH_QUERY_KEYWORDB
KEY_SEARCH_QUERY_KEYWORDA
is set as well.
This is only used internally to construct search fields.protected static final java.lang.String KEY_SEARCH_QUERY_BRANCH
init(Library,
HttpClientFactory)
.
This is only used internally to construct search fields.protected static final java.lang.String KEY_SEARCH_QUERY_HOME_BRANCH
KEY_SEARCH_QUERY_BRANCH
.
This is only used internally to construct search fields.protected static final java.lang.String KEY_SEARCH_QUERY_ISBN
OpacApi.search(List)
implementation.
This is only used internally to construct search fields.protected static final java.lang.String KEY_SEARCH_QUERY_YEAR
KEY_SEARCH_QUERY_YEAR_RANGE_*
fields (or none of them).
This is only used internally to construct search fields.protected static final java.lang.String KEY_SEARCH_QUERY_YEAR_RANGE_START
KEY_SEARCH_QUERY_YEAR
but has to be combined with
KEY_SEARCH_QUERY_YEAR_RANGE_END
.
This is only used internally to construct search fields.protected static final java.lang.String KEY_SEARCH_QUERY_YEAR_RANGE_END
KEY_SEARCH_QUERY_YEAR
but has to be combined with
KEY_SEARCH_QUERY_YEAR_RANGE_START
.
This is only used internally to construct search fields.protected static final java.lang.String KEY_SEARCH_QUERY_SYSTEM
protected static final java.lang.String KEY_SEARCH_QUERY_AUDIENCE
protected static final java.lang.String KEY_SEARCH_QUERY_PUBLISHER
protected static final java.lang.String KEY_SEARCH_QUERY_CATEGORY
init(Library,
HttpClientFactory)
.
This is only used internally to construct search fields.protected static final java.lang.String KEY_SEARCH_QUERY_BARCODE
protected static final java.lang.String KEY_SEARCH_QUERY_LOCATION
protected static final java.lang.String KEY_SEARCH_QUERY_DIGITAL
protected static final java.lang.String KEY_SEARCH_QUERY_AVAILABLE
protected static final java.lang.String KEY_SEARCH_QUERY_ORDER
public static java.lang.String cleanUrl(java.lang.String myURL)
URLEncodedUtils.format(java.util.List, String)
myURL
- the URL to cleanprotected static java.lang.String convertStreamToString(java.io.InputStream is, java.lang.String encoding) throws java.io.IOException
is
- InputStream to read fromencoding
- the encoding to usejava.io.IOException
protected static java.lang.String convertStreamToString(java.io.InputStream is) throws java.io.IOException
ISO-8859-1
encodingis
- InputStream to read fromjava.io.IOException
protected static java.util.Map<java.lang.String,java.lang.String> searchQueryListToMap(java.util.List<SearchQuery> queryList)
List
of SearchQuery
s to Map
of their keys and values. Can
be used to convert old implementations using search(Map<String, String>)
to the new
SearchField APIqueryList
- List of search queriespublic static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getQueryParams(java.lang.String url)
public static java.util.Map<java.lang.String,java.lang.String> getQueryParamsFirst(java.lang.String url)
public void init(Library library, HttpClientFactory http_client_factory)
public void start() throws java.io.IOException
OpacApi
OpacApi.search(java.util.List<de.geeksfactory.opacclient.searchfields.SearchQuery>)
implementation or similar positions. It is commonly used to initialize a session. You MUST
NOT rely on it being called and should check by yourself, whether it was already called (if
your following calls require it to be called before). You SHOULD use this function to
populate the MetaDataSource e.g. with information on your library's branches.
This function is always called from a background thread, you can use blocking network
operations in it.start
in interface OpacApi
java.io.IOException
- if network connection failedNotReachableException
- may throw this if the library couldn't be reachedpublic java.lang.String httpGet(java.lang.String url, java.lang.String encoding, boolean ignore_errors, org.apache.http.client.CookieStore cookieStore) throws java.io.IOException
url
- URL to fetchencoding
- Expected encoding of the response bodyignore_errors
- If true, status codes above 400 do not raise an exceptioncookieStore
- If set, the given cookieStore is used instead of the built-in one.NotReachableException
- Thrown when server returns a HTTP status code greater or equal
than 400.java.io.IOException
public java.lang.String httpGet(java.lang.String url, java.lang.String encoding, boolean ignore_errors) throws java.io.IOException
java.io.IOException
public java.lang.String httpGet(java.lang.String url, java.lang.String encoding) throws java.io.IOException
java.io.IOException
@Deprecated public java.lang.String httpGet(java.lang.String url) throws java.io.IOException
java.io.IOException
public void downloadCover(CoverHolder item)
item
- CoverHolder to download the cover forpublic java.lang.String httpPost(java.lang.String url, org.apache.http.HttpEntity data, java.lang.String encoding, boolean ignore_errors, org.apache.http.client.CookieStore cookieStore) throws java.io.IOException
url
- URL to fetchdata
- POST data to sendencoding
- Expected encoding of the response bodyignore_errors
- If true, status codes above 400 do not raise an exceptioncookieStore
- If set, the given cookieStore is used instead of the built-in one.NotReachableException
- Thrown when server returns a HTTP status code greater or equal
than 400.java.io.IOException
protected void logHttpError(java.lang.Throwable e)
public java.lang.String httpPost(java.lang.String url, org.apache.http.HttpEntity data, java.lang.String encoding, boolean ignore_errors) throws java.io.IOException
java.io.IOException
public java.lang.String httpPost(java.lang.String url, org.apache.http.HttpEntity data, java.lang.String encoding) throws java.io.IOException
java.io.IOException
@Deprecated public java.lang.String httpPost(java.lang.String url, org.apache.http.HttpEntity data) throws java.io.IOException
java.io.IOException
protected java.lang.String getDefaultEncoding()
protected boolean shouldUseMeaningDetector()
public SearchRequestResult volumeSearch(java.util.Map<java.lang.String,java.lang.String> query) throws java.io.IOException, OpacApi.OpacErrorException
OpacApi
DetailledItem.getVolumesearch()
.
This function is always called from a background thread, you can use blocking network
operations in it. See documentation on DetailledItem for details.volumeSearch
in interface OpacApi
query
- see abovejava.io.IOException
OpacApi.OpacErrorException
SearchResult
public void setStringProvider(StringProvider stringProvider)
OpacApi
setStringProvider
in interface OpacApi
stringProvider
- the StringProvider to usepublic java.util.List<SearchField> getSearchFields() throws org.json.JSONException, OpacApi.OpacErrorException, java.io.IOException
OpacApi
getSearchFields
in interface OpacApi
org.json.JSONException
OpacApi.OpacErrorException
java.io.IOException
OpacApi.search(java.util.List<de.geeksfactory.opacclient.searchfields.SearchQuery>)
public abstract java.util.List<SearchField> parseSearchFields() throws java.io.IOException, OpacApi.OpacErrorException, org.json.JSONException
java.io.IOException
OpacApi.OpacErrorException
org.json.JSONException
public static java.lang.String buildHttpGetParams(java.util.List<org.apache.http.NameValuePair> params) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public void setHttpLoggingEnabled(boolean httpLoggingEnabled)