Skip to content
Browse files

rephrased

  • Loading branch information...
1 parent 9669de8 commit 6021fa142c3331546e79052ce20b89e9c769faba @blairc committed May 7, 2012
View
4 service/src/main/java/org/projectbamboo/philologic/service/PhilologicService.java
@@ -13,7 +13,7 @@
* Get bibliography of documents within Philologic collection.
*
* @param name of <i>Philologic</i> collection.
- * @throws IllegalStateException if no ProxyService available.
+ * @throws IllegalStateException if no collection available.
* @throws PhilologicException if request cannot be completed
* @return Bibliography of available documents.
*/
@@ -24,7 +24,7 @@
*
* XXX Return <i>Collection</i>?
*
- * @throws IllegalStateException if no ProxyService available.
+ * @throws IllegalStateException if no collections available.
* @return Map<String, String> - Name and source URL of collection.
*/
public abstract Map<String, String> getCollections();
View
18 service/src/main/java/org/projectbamboo/philologic/service/PhilologicServiceImpl.java
@@ -19,12 +19,12 @@
* Get bibliography of documents within Philologic collection.
*
* @param name of <i>Philologic</i> collection.
- * @throws IllegalStateException if no ProxyService available.
+ * @throws IllegalStateException if no collection available.
* @throws PhilologicException if request cannot be completed
* @return Bibliography of available documents.
*/
public Bibliography getBibliography(String name) throws PhilologicException {
- _validateState();
+ _validateState(name);
try {
return new BibliographyImpl( new ProxyClient().get( endpoints.get(name), "?title=" ) );
}
@@ -36,7 +36,7 @@ public Bibliography getBibliography(String name) throws PhilologicException {
/**
* Get map of Philologic collections.
*
- * @throws IllegalStateException if no ProxyService available.
+ * @throws IllegalStateException if no collections available.
* @return Map<String, String> - Name and source URL of collection.
*/
public Map<String, String> getCollections() {
@@ -60,9 +60,17 @@ public void setEndpoints( Map<String, String> endpoints ) {
this.endpoints = endpoints;
}
+
private void _validateState() throws IllegalStateException {
- if ( null == endpoints ) {
- throw new IllegalStateException("null endpoints");
+ if ( null == endpoints || endpoints.isEmpty() ) {
+ throw new IllegalStateException("no collections");
+ }
+ }
+
+ private void _validateState(String name) throws IllegalStateException {
+ _validateState();
+ if ( null == name || !endpoints.containsKey(name) ) {
+ throw new IllegalStateException("collection not available");
}
}

0 comments on commit 6021fa1

Please sign in to comment.
Something went wrong with that request. Please try again.