From: kenstir Date: Wed, 4 Dec 2013 02:12:45 +0000 (-0500) Subject: Important milestone: session timeout handled gracefully. Activity runnables now... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6dd4f5a8de7e4e69a2c3d493c0bb8022ab2c14d3;p=working%2FEvergreen.git Important milestone: session timeout handled gracefully. Activity runnables now reauthenticate if the stored auth_token has expired. This fixes the single most common crash problem. Code follows this model: getHoldsRunnable = new Runnable() { public void run() { try { holdRecords = accountAccess.getHolds(); } catch (SessionNotFoundException e) { try { if (accountAccess.reauthenticate(HoldsListView.this)) holdRecords = accountAccess.getHolds(); } catch (Exception eauth) { System.out.println("Exception in reauth"); } } } } At the same time, * removed obsolete exceptions * added support for Intellij IDE --- diff --git a/Open-ILS/src/Android/.gitignore b/Open-ILS/src/Android/.gitignore index a284b9211d..9d93ab6e4d 100644 --- a/Open-ILS/src/Android/.gitignore +++ b/Open-ILS/src/Android/.gitignore @@ -1,6 +1,7 @@ -#ignore class objects *.class *.dex +.idea/workspace.xml +.idea/tasks.xml bin/ gen/ .settings diff --git a/Open-ILS/src/Android/.idea/.name b/Open-ILS/src/Android/.idea/.name new file mode 100644 index 0000000000..a4eaec3374 --- /dev/null +++ b/Open-ILS/src/Android/.idea/.name @@ -0,0 +1 @@ +EvergreenApp \ No newline at end of file diff --git a/Open-ILS/src/Android/.idea/compiler.xml b/Open-ILS/src/Android/.idea/compiler.xml new file mode 100644 index 0000000000..217af471a9 --- /dev/null +++ b/Open-ILS/src/Android/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/Open-ILS/src/Android/.idea/copyright/profiles_settings.xml b/Open-ILS/src/Android/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000000..3572571ad8 --- /dev/null +++ b/Open-ILS/src/Android/.idea/copyright/profiles_settings.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/.idea/dictionaries/kenstir.xml b/Open-ILS/src/Android/.idea/dictionaries/kenstir.xml new file mode 100644 index 0000000000..3ada50e95d --- /dev/null +++ b/Open-ILS/src/Android/.idea/dictionaries/kenstir.xml @@ -0,0 +1,7 @@ + + + + textcode + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/.idea/encodings.xml b/Open-ILS/src/Android/.idea/encodings.xml new file mode 100644 index 0000000000..e206d70d85 --- /dev/null +++ b/Open-ILS/src/Android/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Open-ILS/src/Android/.idea/misc.xml b/Open-ILS/src/Android/.idea/misc.xml new file mode 100644 index 0000000000..591776d713 --- /dev/null +++ b/Open-ILS/src/Android/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Open-ILS/src/Android/.idea/modules.xml b/Open-ILS/src/Android/.idea/modules.xml new file mode 100644 index 0000000000..dbe6f3a39b --- /dev/null +++ b/Open-ILS/src/Android/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Open-ILS/src/Android/.idea/scopes/scope_settings.xml b/Open-ILS/src/Android/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000000..922003b843 --- /dev/null +++ b/Open-ILS/src/Android/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/.idea/uiDesigner.xml b/Open-ILS/src/Android/.idea/uiDesigner.xml new file mode 100644 index 0000000000..3b00020308 --- /dev/null +++ b/Open-ILS/src/Android/.idea/uiDesigner.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/Android/.idea/vcs.xml b/Open-ILS/src/Android/.idea/vcs.xml new file mode 100644 index 0000000000..808ed2a9a6 --- /dev/null +++ b/Open-ILS/src/Android/.idea/vcs.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Open-ILS/src/Android/EvergreenApp.iml b/Open-ILS/src/Android/EvergreenApp.iml new file mode 100644 index 0000000000..0d4bb02eec --- /dev/null +++ b/Open-ILS/src/Android/EvergreenApp.iml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java index 5af29a952d..f5ab55ac4c 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java @@ -19,6 +19,7 @@ */ package org.evergreen.android.accountAccess; +import java.io.IOException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; @@ -26,23 +27,23 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import android.accounts.*; +import android.app.Activity; +import android.os.Bundle; +import android.os.Looper; +import android.text.TextUtils; import org.evergreen.android.accountAccess.bookbags.BookBag; import org.evergreen.android.accountAccess.bookbags.BookBagItem; import org.evergreen.android.accountAccess.checkout.CircRecord; import org.evergreen.android.accountAccess.fines.FinesRecord; import org.evergreen.android.accountAccess.holds.HoldRecord; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.evergreen.android.searchCatalog.RecordInfo; -import org.opensrf.Method; -import org.opensrf.net.http.GatewayRequest; +import org.evergreen_ils.auth.Const; import org.opensrf.net.http.HttpConnection; -import org.opensrf.net.http.HttpRequest; import org.opensrf.util.OSRFObject; import android.net.ConnectivityManager; -import android.util.Log; /** * The Class AuthenticateUser. Singleton class @@ -193,7 +194,6 @@ public class AccountAccess { * Instantiates a new authenticate user. * * @param httpAddress the http address - * @param cm the cm */ private AccountAccess(String httpAddress) { @@ -230,7 +230,6 @@ public class AccountAccess { * Gets the account access. * * @param httpAddress the http address - * @param cm the cm * @return the account access */ public static AccountAccess getAccountAccess(String httpAddress) { @@ -323,33 +322,17 @@ public class AccountAccess { } /** - * Authenticate. - * - * @return true, if successful - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server - */ - public boolean authenticate() throws NoNetworkAccessException, - NoAccessToServer { - - //TODO this is a giant hack - return true; - } - - /** * Retrieve session. - * @throws NoAccessToServer - * @throws NoNetworkAccessException - * @throws SessionNotFoundException + * @throws SessionNotFoundException */ - public boolean initSession(String auth_token) throws NoNetworkAccessException, NoAccessToServer, SessionNotFoundException { + public boolean retrieveSession(String auth_token) throws SessionNotFoundException { if (this.haveSession && this.authToken.equals(auth_token)) return true; this.haveSession = false; this.authToken = auth_token; - Object resp = Utils.doRequest(conn, SERVICE_AUTH, METHOD_AUTH_SESSION_RETRV, authToken, null, new Object[] {authToken}); + Object resp = Utils.doRequest(conn, SERVICE_AUTH, METHOD_AUTH_SESSION_RETRV, authToken, new Object[] {authToken}); if (resp != null) { OSRFObject au = (OSRFObject) resp; userID = au.getInt("id"); @@ -359,28 +342,31 @@ public class AccountAccess { this.haveSession = true; } return this.haveSession; - /* - Method method = new Method(METHOD_AUTH_SESSION_RETRV); - - method.addParam(authToken); - - // sync request - HttpRequest req = new GatewayRequest(conn, SERVICE_AUTH, method).send(); - Object resp; - - while ((resp = req.recv()) != null) { - System.out.println("Sync Response: " + resp); - OSRFObject au = (OSRFObject) resp; - userID = au.getInt("id"); - homeLibraryID = au.getInt("home_ou"); - String s = au.getString("usrname"); + } - System.out.println("User Id " + userID); + public static boolean runningOnUIThread() { + return (Looper.myLooper() == Looper.getMainLooper()); + } - this.haveSession = true; - } - return this.haveSession; - */ + /** invalidate current auth token and get a new one + * + * @param activity + * @return true if auth successful + */ + public boolean reauthenticate(Activity activity) throws SessionNotFoundException, AuthenticatorException, OperationCanceledException, IOException { + boolean ok = false; + final AccountManager am = AccountManager.get(activity); + final Account account = new Account(userName, Const.ACCOUNT_TYPE); + am.invalidateAuthToken(Const.ACCOUNT_TYPE, authToken); + haveSession = false; + authToken = null; + if (runningOnUIThread()) + return false; + Bundle b = am.getAuthToken(account, Const.AUTHTOKEN_TYPE, null, activity, null, null).getResult(); + final String new_authToken = b.getString(AccountManager.KEY_AUTHTOKEN); + if (TextUtils.isEmpty(new_authToken)) + return false; + return retrieveSession(new_authToken); } // ------------------------Checked Out Items Section @@ -395,8 +381,7 @@ public class AccountAccess { * @throws NoAccessToServer the no access to server */ public ArrayList getItemsCheckedOut() - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { ArrayList circRecords = new ArrayList(); /* @@ -415,7 +400,7 @@ public class AccountAccess { List out_id; Object resp = Utils.doRequest(conn, SERVICE_ACTOR, - METHOD_FETCH_CHECKED_OUT_SUM, authToken, cm, new Object[] { + METHOD_FETCH_CHECKED_OUT_SUM, authToken, new Object[] { authToken, userID }); long_overdue_id = (List) ((Map) resp) @@ -481,15 +466,12 @@ public class AccountAccess { * @param id the id * @return the oSRF object * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ private OSRFObject retrieveCircRecord(String id) - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { OSRFObject circ = (OSRFObject) Utils.doRequest(conn, SERVICE_CIRC, - METHOD_FETCH_CIRC_BY_ID, authToken, cm, new Object[] { + METHOD_FETCH_CIRC_BY_ID, authToken, new Object[] { authToken, id }); return circ; } @@ -506,12 +488,9 @@ public class AccountAccess { * @param target_copy the target_copy * @param circRecord the circ record * @return the oSRF object - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ private OSRFObject fetchInfoForCheckedOutItem(Integer target_copy, - CircRecord circRecord) throws NoNetworkAccessException, - NoAccessToServer { + CircRecord circRecord) { if (target_copy == null) return null; @@ -543,11 +522,8 @@ public class AccountAccess { * * @param target_copy the target_copy * @return the oSRF object - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - private OSRFObject fetchModsFromCopy(Integer target_copy) - throws NoNetworkAccessException, NoAccessToServer { + private OSRFObject fetchModsFromCopy(Integer target_copy) { // sync request OSRFObject mvr = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH, @@ -561,11 +537,8 @@ public class AccountAccess { * * @param target_copy the target_copy * @return the oSRF object - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - private OSRFObject fetchAssetCopy(Integer target_copy) - throws NoNetworkAccessException, NoAccessToServer { + private OSRFObject fetchAssetCopy(Integer target_copy) { OSRFObject acp = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH, METHOD_FETCH_COPY, cm, new Object[] { target_copy }); @@ -584,12 +557,9 @@ public class AccountAccess { * @throws MaxRenewalsException the max renewals exception * @throws ServerErrorMessage the server error message * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ public void renewCirc(Integer target_copy) throws MaxRenewalsException, - ServerErrorMessage, SessionNotFoundException, - NoNetworkAccessException, NoAccessToServer { + ServerErrorMessage, SessionNotFoundException { HashMap complexParam = new HashMap(); complexParam.put("patron", this.userID); @@ -597,7 +567,7 @@ public class AccountAccess { complexParam.put("opac_renewal", 1); Object a_lot = (Object) Utils.doRequest(conn, SERVICE_CIRC, - METHOD_RENEW_CIRC, authToken, cm, new Object[] { authToken, + METHOD_RENEW_CIRC, authToken, new Object[] { authToken, complexParam }); Map resp = (Map) a_lot; @@ -620,12 +590,9 @@ public class AccountAccess { * @param setting the setting * @return the object * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ public Object fetchOrgSettings(Integer org_id, String setting) - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { OSRFObject response = (OSRFObject) Utils .doRequest(conn, SERVICE_ACTOR, METHOD_FETCH_ORG_SETTINGS, cm, @@ -639,11 +606,8 @@ public class AccountAccess { * * @return the holds * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - public List getHolds() throws SessionNotFoundException, - NoNetworkAccessException, NoAccessToServer { + public List getHolds() throws SessionNotFoundException { ArrayList holds = new ArrayList(); @@ -651,7 +615,7 @@ public class AccountAccess { List listHoldsAhr = null; Object resp = Utils.doRequest(conn, SERVICE_CIRC, METHOD_FETCH_HOLDS, - authToken, cm, new Object[] { authToken, userID }); + authToken, new Object[] { authToken, userID }); if (resp == null) { System.out.println("Result: null"); return holds; @@ -684,11 +648,8 @@ public class AccountAccess { * @param holdArhObject the hold arh object * @param hold the hold * @return the object - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - private Object fetchHoldTitleInfo(OSRFObject holdArhObject, HoldRecord hold) - throws NoNetworkAccessException, NoAccessToServer { + private Object fetchHoldTitleInfo(OSRFObject holdArhObject, HoldRecord hold) { String holdType = (String) holdArhObject.get("hold_type"); @@ -732,11 +693,8 @@ public class AccountAccess { * @param hold the hold * @param holdObj the hold obj * @return the oSRF object - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - private OSRFObject holdFetchObjects(OSRFObject hold, HoldRecord holdObj) - throws NoNetworkAccessException, NoAccessToServer { + private OSRFObject holdFetchObjects(OSRFObject hold, HoldRecord holdObj) { String type = (String) hold.get("hold_type"); @@ -779,7 +737,6 @@ public class AccountAccess { System.err.println("Can't get types of resurce type" + e.getMessage()); } - ; } return copyObject; @@ -813,7 +770,6 @@ public class AccountAccess { System.err.println("Can't get types of resurce type" + e.getMessage()); } - ; } else if (type.equals("I")) { OSRFObject issuance = (OSRFObject) Utils.doRequest(conn, SERVICE_SERIAL, METHOD_FETCH_ISSUANCE, cm, @@ -861,7 +817,6 @@ public class AccountAccess { System.err.println("Can't get types of resurce type" + e.getMessage()); } - ; } return null; @@ -873,18 +828,15 @@ public class AccountAccess { * @param hold the hold * @param holdObj the hold obj * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ public void fetchHoldStatus(OSRFObject hold, HoldRecord holdObj) - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { Integer hold_id = hold.getInt("id"); // MAP : potential_copies, status, total_holds, queue_position, // estimated_wait Object resp = Utils.doRequest(conn, SERVICE_CIRC, - METHOD_FETCH_HOLD_STATUS, authToken, cm, new Object[] { + METHOD_FETCH_HOLD_STATUS, authToken, new Object[] { authToken, hold_id }); Map map = (Map)resp; @@ -901,16 +853,13 @@ public class AccountAccess { * @param hold the hold * @return true, if successful * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - public boolean cancelHold(OSRFObject hold) throws SessionNotFoundException, - NoNetworkAccessException, NoAccessToServer { + public boolean cancelHold(OSRFObject hold) throws SessionNotFoundException { Integer hold_id = hold.getInt("id"); Object response = Utils.doRequest(conn, SERVICE_CIRC, - METHOD_CANCEL_HOLD, authToken, cm, new Object[] { authToken, + METHOD_CANCEL_HOLD, authToken, new Object[] { authToken, hold_id }); // delete successful @@ -931,13 +880,10 @@ public class AccountAccess { * @param thaw_date the thaw_date * @return the object * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ public Object updateHold(OSRFObject ahr, Integer pickup_lib, boolean suspendHold, String expire_time, String thaw_date) - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { // TODO verify that object is correct passed to the server ahr.put("pickup_lib", pickup_lib); @@ -948,7 +894,7 @@ public class AccountAccess { ahr.put("thaw_date", thaw_date); Object response = Utils.doRequest(conn, SERVICE_CIRC, - METHOD_UPDATE_HOLD, authToken, cm, new Object[] { authToken, + METHOD_UPDATE_HOLD, authToken, new Object[] { authToken, ahr }); return response; @@ -967,14 +913,11 @@ public class AccountAccess { * @param thaw_date the thaw_date * @return the string[] * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ public String[] createHold(Integer recordID, Integer pickup_lib, boolean email_notify, boolean phone_notify, String phone, boolean suspendHold, String expire_time, String thaw_date) - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { OSRFObject ahr = new OSRFObject("ahr"); ahr.put("target", recordID); @@ -996,7 +939,7 @@ public class AccountAccess { // extra parameters (not mandatory for hold creation) Object response = Utils.doRequest(conn, SERVICE_CIRC, - METHOD_CREATE_HOLD, authToken, cm, new Object[] { authToken, + METHOD_CREATE_HOLD, authToken, new Object[] { authToken, ahr }); String[] resp = new String[3]; @@ -1017,7 +960,6 @@ public class AccountAccess { resp[1] = ((Map) map).get("textcode"); resp[2] = ((Map) map).get("desc"); } - ; System.out.println("Result " + resp[1] + " " + resp[2]); @@ -1033,12 +975,9 @@ public class AccountAccess { * @param recordID the record id * @return the object * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ public Object isHoldPossible(Integer pickup_lib, Integer recordID) - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { HashMap mapAsk = getHoldPreCreateInfo(recordID, pickup_lib); @@ -1055,7 +994,7 @@ public class AccountAccess { // "patronid":2,"depth":0,"pickup_lib":"8","partid":null} Object response = Utils.doRequest(conn, SERVICE_CIRC, - METHOD_VERIFY_HOLD_POSSIBLE, authToken, cm, new Object[] { + METHOD_VERIFY_HOLD_POSSIBLE, authToken, new Object[] { authToken, mapAsk }); return response; @@ -1068,12 +1007,9 @@ public class AccountAccess { * @param recordID the record id * @param pickup_lib the pickup_lib * @return the hold pre create info - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ public HashMap getHoldPreCreateInfo(Integer recordID, - Integer pickup_lib) throws NoNetworkAccessException, - NoAccessToServer { + Integer pickup_lib) { HashMap param = new HashMap(); @@ -1110,15 +1046,12 @@ public class AccountAccess { * * @return the fines summary * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - public float[] getFinesSummary() throws SessionNotFoundException, - NoNetworkAccessException, NoAccessToServer { + public float[] getFinesSummary() throws SessionNotFoundException { // mous object OSRFObject finesSummary = (OSRFObject) Utils.doRequest(conn, - SERVICE_ACTOR, METHOD_FETCH_FINES_SUMMARY, authToken, cm, + SERVICE_ACTOR, METHOD_FETCH_FINES_SUMMARY, authToken, new Object[] { authToken, userID }); float fines[] = new float[3]; @@ -1138,17 +1071,14 @@ public class AccountAccess { * * @return the transactions * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ public ArrayList getTransactions() - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { ArrayList finesRecords = new ArrayList(); Object transactions = Utils.doRequest(conn, SERVICE_ACTOR, - METHOD_FETCH_TRANSACTIONS, authToken, cm, new Object[] { + METHOD_FETCH_TRANSACTIONS, authToken, new Object[] { authToken, userID }); // get Array @@ -1175,14 +1105,11 @@ public class AccountAccess { * * @return the bookbags * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - public boolean retrieveBookbags() throws SessionNotFoundException, - NoNetworkAccessException, NoAccessToServer { + public boolean retrieveBookbags() throws SessionNotFoundException { Object response = Utils.doRequest(conn, SERVICE_ACTOR, - METHOD_FLESH_CONTAINERS, authToken, cm, new Object[] { + METHOD_FLESH_CONTAINERS, authToken, new Object[] { authToken, userID, "biblio", "bookbag" }); List bookbags = (List) response; @@ -1215,15 +1142,12 @@ public class AccountAccess { * @param bookbagID the bookbag id * @return the bookbag content * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ private Object getBookbagContent(BookBag bag, Integer bookbagID) - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { Map map = (Map) Utils.doRequest(conn, - SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, authToken, cm, + SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, authToken, new Object[] { authToken, "biblio", bookbagID }); List items = new ArrayList(); @@ -1248,11 +1172,8 @@ public class AccountAccess { * * @param id the id * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - public void removeBookbagItem(Integer id) throws SessionNotFoundException, - NoNetworkAccessException, NoAccessToServer { + public void removeBookbagItem(Integer id) throws SessionNotFoundException { removeContainer("biblio", id); @@ -1263,11 +1184,8 @@ public class AccountAccess { * * @param name the name * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - public void createBookbag(String name) throws SessionNotFoundException, - NoNetworkAccessException, NoAccessToServer { + public void createBookbag(String name) throws SessionNotFoundException { OSRFObject cbreb = new OSRFObject("cbreb"); cbreb.put("btype", "bookbag"); @@ -1283,14 +1201,11 @@ public class AccountAccess { * * @param id the id * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ - public void deleteBookBag(Integer id) throws SessionNotFoundException, - NoNetworkAccessException, NoAccessToServer { + public void deleteBookBag(Integer id) throws SessionNotFoundException { Object response = Utils.doRequest(conn, SERVICE_ACTOR, - METHOD_CONTAINER_FULL_DELETE, authToken, cm, new Object[] { + METHOD_CONTAINER_FULL_DELETE, authToken, new Object[] { authToken, "biblio", id }); } @@ -1300,12 +1215,9 @@ public class AccountAccess { * @param record_id the record_id * @param bookbag_id the bookbag_id * @throws SessionNotFoundException the session not found exception - * @throws NoAccessToServer the no access to server - * @throws NoNetworkAccessException the no network access exception */ public void addRecordToBookBag(Integer record_id, Integer bookbag_id) - throws SessionNotFoundException, NoAccessToServer, - NoNetworkAccessException { + throws SessionNotFoundException { OSRFObject cbrebi = new OSRFObject("cbrebi"); cbrebi.put("bucket", bookbag_id); @@ -1313,7 +1225,7 @@ public class AccountAccess { cbrebi.put("id", null); Object response = Utils.doRequest(conn, SERVICE_ACTOR, - METHOD_CONTAINER_ITEM_CREATE, authToken, cm, new Object[] { + METHOD_CONTAINER_ITEM_CREATE, authToken, new Object[] { authToken, "biblio", cbrebi }); } @@ -1323,15 +1235,12 @@ public class AccountAccess { * @param container the container * @param id the id * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ private void removeContainer(String container, Integer id) - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { Object response = Utils.doRequest(conn, SERVICE_ACTOR, - METHOD_CONTAINER_DELETE, authToken, cm, new Object[] { + METHOD_CONTAINER_DELETE, authToken, new Object[] { authToken, container, id }); } @@ -1341,15 +1250,12 @@ public class AccountAccess { * @param container the container * @param parameter the parameter * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ private void createContainer(String container, Object parameter) - throws SessionNotFoundException, NoNetworkAccessException, - NoAccessToServer { + throws SessionNotFoundException { Object response = Utils.doRequest(conn, SERVICE_ACTOR, - METHOD_CONTAINER_CREATE, authToken, cm, new Object[] { + METHOD_CONTAINER_CREATE, authToken, new Object[] { authToken, container, parameter }); } } diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBagDetails.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBagDetails.java index 81377f3ee0..c6b96d1d32 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBagDetails.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBagDetails.java @@ -25,8 +25,6 @@ import java.util.List; import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.accountAccess.SessionNotFoundException; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.searchCatalog.RecordInfo; import org.evergreen.android.searchCatalog.SearchCatalog; import org.evergreen.android.searchCatalog.SearchCatalogListView; @@ -52,7 +50,6 @@ import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; -import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; @@ -146,13 +143,6 @@ public class BookBagDetails extends Activity { try { accountAccess.deleteBookBag(bookBag.id); } catch (SessionNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoNetworkAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoAccessToServer e) { - // TODO Auto-generated catch block e.printStackTrace(); } runOnUiThread(new Runnable() { @@ -333,22 +323,11 @@ public class BookBagDetails extends Activity { try { accountAccess.removeBookbagItem(record.id); } catch (SessionNotFoundException e) { - try { - if (accountAccess.authenticate()) - accountAccess - .removeBookbagItem(record.id); + if (accountAccess.reauthenticate(BookBagDetails.this)) + accountAccess.removeBookbagItem(record.id); } catch (Exception e1) { } - ; - - e.printStackTrace(); - } catch (NoNetworkAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoAccessToServer e) { - // TODO Auto-generated catch block - e.printStackTrace(); } runOnUiThread(new Runnable() { diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.java index d5067ccdaf..fe8ddee3ce 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.java @@ -25,8 +25,6 @@ import java.util.List; import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.accountAccess.SessionNotFoundException; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.evergreen.android.searchCatalog.SearchCatalogListView; import org.evergreen.android.views.AccountScreenDashboard; @@ -48,7 +46,6 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; -import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; @@ -210,7 +207,7 @@ public class BookbagsListView extends Activity { bookBags = accountAccess.getBookbags(); } catch (NoNetworkAccessException e) { - Utils.showNetworkNotAvailableDialog(context); + Utils.showSessionNotAvailableDialog(context); } catch (NoAccessToServer e) { Utils.showServerNotAvailableDialog(context); diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/checkout/ItemsCheckOutListView.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/checkout/ItemsCheckOutListView.java index 34565508c7..645d50ac03 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/checkout/ItemsCheckOutListView.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/checkout/ItemsCheckOutListView.java @@ -20,27 +20,20 @@ package org.evergreen.android.accountAccess.checkout; import java.util.ArrayList; -import java.util.Calendar; import java.util.Date; import java.util.List; -import org.androwrapee.db.DefaultDAO; import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.accountAccess.MaxRenewalsException; import org.evergreen.android.accountAccess.ServerErrorMessage; import org.evergreen.android.accountAccess.SessionNotFoundException; -import org.evergreen.android.database.DatabaseManager; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.evergreen.android.searchCatalog.SearchCatalogListView; import org.evergreen.android.views.AccountScreenDashboard; import org.evergreen.android.views.splashscreen.SplashActivity; import android.app.Activity; -import android.app.AlarmManager; -import android.app.PendingIntent; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; @@ -146,7 +139,7 @@ public class ItemsCheckOutListView extends Activity { try { circRecords = accountAccess.getItemsCheckedOut(); } catch (NoNetworkAccessException e) { - Utils.showNetworkNotAvailableDialog(context); + Utils.showSessionNotAvailableDialog(context); } catch (NoAccessToServer e) { Utils.showServerNotAvailableDialog(context); @@ -344,7 +337,7 @@ public class ItemsCheckOutListView extends Activity { .println("Exception in reAuth"); } } catch (NoNetworkAccessException e1) { - Utils.showNetworkNotAvailableDialog(context); + Utils.showSessionNotAvailableDialog(context); } catch (NoAccessToServer e1) { Utils.showServerNotAvailableDialog(context); } @@ -355,7 +348,7 @@ public class ItemsCheckOutListView extends Activity { circRecords = accountAccess .getItemsCheckedOut(); } catch (NoNetworkAccessException e) { - Utils.showNetworkNotAvailableDialog(context); + Utils.showSessionNotAvailableDialog(context); } catch (NoAccessToServer e) { Utils.showServerNotAvailableDialog(context); diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java index c6d7248587..0e9c1713fd 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java @@ -26,8 +26,6 @@ import java.util.List; import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.accountAccess.SessionNotFoundException; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.evergreen.android.searchCatalog.SearchCatalogListView; import org.evergreen.android.views.AccountScreenDashboard; @@ -46,7 +44,6 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; -import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; @@ -139,31 +136,21 @@ public class FinesActivity extends Activity { finesR = ac.getFinesSummary(); } catch (SessionNotFoundException e) { try { - if (ac.authenticate()) + if (ac.reauthenticate(FinesActivity.this)) finesR = ac.getFinesSummary(); } catch (Exception e1) { } - } catch (NoNetworkAccessException e) { - Utils.showNetworkNotAvailableDialog(context); - } catch (NoAccessToServer e) { - Utils.showServerNotAvailableDialog(context); } ArrayList frecords = null; try { frecords = ac.getTransactions(); } catch (SessionNotFoundException e) { - try { - if (ac.authenticate()) + if (ac.reauthenticate(FinesActivity.this)) frecords = ac.getTransactions(); } catch (Exception e1) { } - - } catch (NoNetworkAccessException e) { - Utils.showNetworkNotAvailableDialog(context); - } catch (NoAccessToServer e) { - Utils.showServerNotAvailableDialog(context); } final ArrayList finesRecords = frecords; diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldDetails.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldDetails.java index 35b8407113..6457b1d0a4 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldDetails.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldDetails.java @@ -27,8 +27,6 @@ import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.accountAccess.SessionNotFoundException; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.evergreen.android.searchCatalog.SearchCatalogListView; import org.evergreen.android.views.AccountScreenDashboard; @@ -56,7 +54,6 @@ import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.DatePicker; import android.widget.EditText; -import android.widget.ImageButton; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -239,16 +236,9 @@ public class HoldDetails extends Activity { try { accountAccess .cancelHold(record.ahr); - } catch (NoNetworkAccessException e) { - Utils.showNetworkNotAvailableDialog(context); - } catch (NoAccessToServer e) { - Utils.showServerNotAvailableDialog(context); - } catch (SessionNotFoundException e) { - // TODO other way? try { - if (accountAccess - .authenticate()) + if (accountAccess.reauthenticate(HoldDetails.this)) accountAccess .cancelHold(record.ahr); } catch (Exception eauth) { @@ -293,15 +283,9 @@ public class HoldDetails extends Activity { accountAccess.updateHold(record.ahr, selectedOrgPos, suspendHold.isChecked(), expire_date_s, thaw_date_s); - } catch (NoNetworkAccessException e) { - Utils.showNetworkNotAvailableDialog(context); - } catch (NoAccessToServer e) { - Utils.showServerNotAvailableDialog(context); - } catch (SessionNotFoundException e) { - // TODO other way? try { - if (accountAccess.authenticate()) + if (accountAccess.reauthenticate(HoldDetails.this)) accountAccess.updateHold(record.ahr, selectedOrgPos, suspendHold.isChecked(), expire_date_s, diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldsListView.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldsListView.java index ffb6bb09e6..414903e415 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldsListView.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldsListView.java @@ -19,7 +19,6 @@ */ package org.evergreen.android.accountAccess.holds; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; @@ -27,8 +26,6 @@ import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.accountAccess.SessionNotFoundException; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.evergreen.android.searchCatalog.ImageDownloader; import org.evergreen.android.searchCatalog.SearchCatalogListView; @@ -49,7 +46,6 @@ import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.Button; -import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -138,16 +134,14 @@ public class HoldsListView extends Activity { try { holdRecords = accountAccess.getHolds(); } catch (SessionNotFoundException e) { - System.out.println("no session!"); - // TODO other way? try { - if (accountAccess.authenticate()) + if (accountAccess.reauthenticate(HoldsListView.this)) holdRecords = accountAccess.getHolds(); } catch (Exception eauth) { - System.out.println("Exception in reAuth"); + System.out.println("Exception in reauth"); } } catch (NoNetworkAccessException e) { - Utils.showNetworkNotAvailableDialog(context); + Utils.showSessionNotAvailableDialog(context); } catch (NoAccessToServer e) { Utils.showServerNotAvailableDialog(context); } diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/PlaceHold.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/PlaceHold.java index 616550e805..7ffb7c6bd3 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/PlaceHold.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/PlaceHold.java @@ -27,8 +27,6 @@ import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.accountAccess.SessionNotFoundException; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.evergreen.android.searchCatalog.RecordInfo; import org.evergreen.android.searchCatalog.SearchCatalogListView; @@ -54,7 +52,6 @@ import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.DatePicker; import android.widget.EditText; -import android.widget.ImageButton; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -228,9 +225,8 @@ public class PlaceHold extends Activity { .getText().toString(), suspendHold .isChecked(), expire_date_s, thaw_date_s); } catch (SessionNotFoundException e) { - try { - if (accountAccess.authenticate()) + if (accountAccess.reauthenticate(PlaceHold.this)) stringResponse = accountAccess.createHold( record_id, selectedOrgID, email_notification.isChecked(), @@ -240,11 +236,6 @@ public class PlaceHold extends Activity { thaw_date_s); } catch (Exception e1) { } - - } catch (NoNetworkAccessException e) { - Utils.showNetworkNotAvailableDialog(context); - } catch (NoAccessToServer e) { - Utils.showServerNotAvailableDialog(context); } final String[] holdPlaced = stringResponse; diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java index 8198f736bc..0a4508bd6a 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java @@ -250,9 +250,7 @@ public class GlobalConfigs { try { Object obj = ac.fetchOrgSettings(organisations.get(i).id, "opac.org_unit_hiding.depth"); - } catch (NoNetworkAccessException e) { - } catch (NoAccessToServer e) { - } catch (SessionNotFoundException e) {// not used here + } catch (SessionNotFoundException e) { } } diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/NoAccessToServer.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/NoAccessToServer.java deleted file mode 100644 index 080649106d..0000000000 --- a/Open-ILS/src/Android/src/org/evergreen/android/globals/NoAccessToServer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2012 Evergreen Open-ILS - * @author Daniel-Octavian Rizea - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * or the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be usefull, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - */ -package org.evergreen.android.globals; - -public class NoAccessToServer extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - -} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/NoNetworkAccessException.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/NoNetworkAccessException.java deleted file mode 100644 index 9ca9c73e01..0000000000 --- a/Open-ILS/src/Android/src/org/evergreen/android/globals/NoNetworkAccessException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2012 Evergreen Open-ILS - * @author Daniel-Octavian Rizea - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * or the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be usefull, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - */ -package org.evergreen.android.globals; - -public class NoNetworkAccessException extends Exception { - /** - */ - private static final long serialVersionUID = 1L; - -} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowNetworkNotAvailableRunnable.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowNetworkNotAvailableRunnable.java deleted file mode 100644 index cc4aec1475..0000000000 --- a/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowNetworkNotAvailableRunnable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2012 Evergreen Open-ILS - * @author Daniel-Octavian Rizea - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * or the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be usefull, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - */ -package org.evergreen.android.globals; - -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; - -class ShowNetworkNotAvailableRunnable implements Runnable { - - public Context context; - - public ShowNetworkNotAvailableRunnable(Context context) { - this.context = context; - } - - @Override - public void run() { - // TODO Auto-generated method stub - AlertDialog alertDialog = new AlertDialog.Builder(context).create(); - alertDialog.setTitle("Error"); - alertDialog.setMessage("You need to have an internet connection"); - alertDialog.setButton("OK", new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); - } - }); - - alertDialog.show(); - } - -} \ No newline at end of file diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowSessionNotAvailableRunnable.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowSessionNotAvailableRunnable.java new file mode 100644 index 0000000000..9b73f1cc43 --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowSessionNotAvailableRunnable.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 Evergreen Open-ILS + * @author Daniel-Octavian Rizea + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * or the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be usefull, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + */ +package org.evergreen.android.globals; + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; + +class ShowSessionNotAvailableRunnable implements Runnable { + + public Context context; + + public ShowSessionNotAvailableRunnable(Context context) { + this.context = context; + } + + @Override + public void run() { + AlertDialog alertDialog = new AlertDialog.Builder(context).create(); + alertDialog.setTitle("Error"); + alertDialog.setMessage("No session"); + alertDialog.setButton("OK", new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + } + }); + + alertDialog.show(); + } + +} \ No newline at end of file diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java index 6604fbdfad..c2fe416c37 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java @@ -29,6 +29,8 @@ import java.net.URL; import java.net.URLConnection; import java.util.Map; +import android.os.Looper; +import android.text.TextUtils; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; @@ -43,7 +45,6 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.ConnectivityManager; -import android.net.NetworkInfo; import android.util.Log; import android.widget.ImageView; @@ -118,8 +119,7 @@ public class Utils { return in; } - public static boolean checkIfNetAddressIsReachable(String url) - throws NoAccessToServer { + public static boolean checkIfNetAddressIsReachable(String url) { // The old method of fetching the URL to see if the net is "reachable" was not good; // it wasted bandwidth and time. For now just check if the url is empty. @@ -193,15 +193,19 @@ public class Utils { } - public static Object doRequest(HttpConnection conn, String service, - String methodName, String authToken, ConnectivityManager cm, - Object[] params) throws SessionNotFoundException, - NoNetworkAccessException, NoAccessToServer { + public static String getResponseTextcode(Object response) { + String textcode = null; + try { + textcode = ((Map) response).get("textcode"); + } catch (Exception e) { + } + return textcode; + } - // check to see if EG http server is reachable - checkIfNetAddressIsReachable(GlobalConfigs.httpAddress); + public static Object doRequest(HttpConnection conn, String service, + String methodName, String authToken, + Object[] params) throws SessionNotFoundException { - // TODO check params and throw errors Method method = new Method(methodName); Log.d(TAG, "doRequest Method :" + methodName + ": token :"+authToken+":"); @@ -229,21 +233,13 @@ public class Utils { Log.d(TAG, "Sync Response: " + resp); Object response = (Object) resp; - String textcode = null; - try { - textcode = ((Map) response).get("textcode"); - } catch (Exception e) { - //System.err.println(e.getMessage()); - } - if (textcode != null) { - if (textcode.equals("NO_SESSION")) { - Log.d(TAG, textcode); - throw new SessionNotFoundException(); - } + String textcode = getResponseTextcode(resp); + if (TextUtils.equals(textcode, "NO_SESSION")) { + Log.d(TAG, textcode); + throw new SessionNotFoundException(); } return response; - } return null; @@ -251,11 +247,7 @@ public class Utils { // does not require authToken public static Object doRequest(HttpConnection conn, String service, - String methodName, ConnectivityManager cm, Object[] params) - throws NoNetworkAccessException, NoAccessToServer { - - // check to see if EG http server is reachable - checkIfNetAddressIsReachable(GlobalConfigs.httpAddress); + String methodName, ConnectivityManager cm, Object[] params) { Method method = new Method(methodName); @@ -284,6 +276,12 @@ public class Utils { // is fast than with checks for multiple method invocations like in search public static Object doRequestSimple(HttpConnection conn, String service, String methodName, Object[] params) { + + if (Looper.myLooper() == Looper.getMainLooper()) { + // running on UI thread! + throw new NullPointerException(); + } + Method method = new Method(methodName); System.out.println("doRequestSimple Method :" + methodName); for (int i = 0; i < params.length; i++) { @@ -305,16 +303,10 @@ public class Utils { return null; } - public static ShowServerNotAvailableRunnable showServerNotAvailableDialog( - Context context) { - - return new ShowServerNotAvailableRunnable(context); - } - - public static ShowNetworkNotAvailableRunnable showNetworkNotAvailableDialog( + public static ShowSessionNotAvailableRunnable showSessionNotAvailableDialog( Context context) { - return new ShowNetworkNotAvailableRunnable(context); + return new ShowSessionNotAvailableRunnable(context); } } diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java index 93641c0767..052ff3625b 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java @@ -155,7 +155,7 @@ public class AdvancedSearchActivity extends Activity { } TextView text = new TextView(context); - text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, + text.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); text.setText(searchText); layout.addView(text); diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/MoreCopyInformation.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/MoreCopyInformation.java index 5ca240b9e9..5f2f95c5fd 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/MoreCopyInformation.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/MoreCopyInformation.java @@ -19,40 +19,26 @@ */ package org.evergreen.android.searchCatalog; -import java.util.ArrayList; import java.util.Iterator; -import java.util.List; import java.util.Set; import java.util.Map.Entry; import org.evergreen.android.R; -import org.evergreen.android.accountAccess.AccountAccess; -import org.evergreen.android.accountAccess.SessionNotFoundException; -import org.evergreen.android.accountAccess.fines.FinesRecord; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; -import org.evergreen.android.globals.Utils; import org.evergreen.android.views.AccountScreenDashboard; import org.evergreen.android.views.splashscreen.SplashActivity; import android.app.Activity; -import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; -import android.graphics.Color; import android.os.Bundle; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup; -import android.widget.ArrayAdapter; import android.widget.Button; -import android.widget.ImageButton; import android.widget.LinearLayout; -import android.widget.ListView; import android.widget.TextView; public class MoreCopyInformation extends Activity { @@ -140,7 +126,7 @@ public class MoreCopyInformation extends Activity { // insert into main view insertPoint.addView(copy_info_view, new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); LinearLayout copy_statuses = (LinearLayout) copy_info_view diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SampleUnderlinesNoFade.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SampleUnderlinesNoFade.java index 27659587dc..1da70602f1 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SampleUnderlinesNoFade.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SampleUnderlinesNoFade.java @@ -20,11 +20,8 @@ package org.evergreen.android.searchCatalog; import java.util.ArrayList; -import java.util.List; import org.evergreen.android.R; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.evergreen.android.utils.ui.BaseSampleActivity; import org.evergreen.android.utils.ui.BasicDetailsFragment; @@ -144,7 +141,7 @@ public class SampleUnderlinesNoFade extends BaseSampleActivity { records.size()); } catch (NoNetworkAccessException e) { runOnUiThread(Utils - .showNetworkNotAvailableDialog(context)); + .showSessionNotAvailableDialog(context)); } catch (NoAccessToServer e) { runOnUiThread(Utils .showServerNotAvailableDialog(context)); diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java index e65eff1a78..25dc918b90 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java @@ -26,8 +26,6 @@ import java.util.List; import java.util.Map; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.opensrf.Method; import org.opensrf.net.http.GatewayRequest; @@ -135,11 +133,6 @@ public class SearchCatalog { /** * Instantiates a new search catalog. - * - * @param httpAddress - * the http address - * @param locale - * the locale */ private SearchCatalog(ConnectivityManager cm) { super(); @@ -168,7 +161,7 @@ public class SearchCatalog { * @return the search results */ public ArrayList getSearchResults(String searchWords, - Integer offset) throws NoNetworkAccessException, NoAccessToServer { + Integer offset) { searchText = searchWords; @@ -290,8 +283,7 @@ public class SearchCatalog { * the search words * @return the object */ - public Object searchCatalog(String searchWords) - throws NoNetworkAccessException, NoAccessToServer { + public Object searchCatalog(String searchWords) { Object response = Utils.doRequest(conn, SERVICE, METHOD_SLIM_RETRIVE, cm, new Object[] { "keyword", searchWords }); diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java index 641f20e8af..cefe6ef4d9 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java @@ -30,8 +30,6 @@ import org.evergreen.android.accountAccess.bookbags.BookBag; import org.evergreen.android.accountAccess.holds.PlaceHold; import org.evergreen.android.barcodescan.CaptureActivity; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.evergreen.android.views.AccountScreenDashboard; import org.evergreen.android.views.ApplicationPreferences; @@ -267,17 +265,7 @@ public class SearchCatalogListView extends Activity { } }); - try { - searchResults = search.getSearchResults(text, 0); - } catch (NoNetworkAccessException e) { - System.out.println("no network access in search"); - SearchCatalogListView.this.runOnUiThread(Utils - .showNetworkNotAvailableDialog(context)); - - } catch (NoAccessToServer e) { - SearchCatalogListView.this.runOnUiThread(Utils - .showServerNotAvailableDialog(context)); - } + searchResults = search.getSearchResults(text, 0); runOnUiThread(new Runnable() { @@ -334,16 +322,8 @@ public class SearchCatalogListView extends Activity { searchResults.clear(); - try { - searchResults = search.getSearchResults(text, - recordList.size()); - } catch (NoNetworkAccessException e) { - runOnUiThread(Utils - .showNetworkNotAvailableDialog(context)); - } catch (NoAccessToServer e) { - runOnUiThread(Utils - .showServerNotAvailableDialog(context)); - } + searchResults = search.getSearchResults(text, + recordList.size()); runOnUiThread(new Runnable() { @@ -447,17 +427,9 @@ public class SearchCatalogListView extends Activity { .toString(); searchResults.clear(); - try { - searchResults = search - .getSearchResults(text, - adapter.getCount()); - } catch (NoNetworkAccessException e) { - runOnUiThread(Utils - .showNetworkNotAvailableDialog(context)); - } catch (NoAccessToServer e) { - runOnUiThread(Utils - .showServerNotAvailableDialog(context)); - } + searchResults = search + .getSearchResults(text, + adapter.getCount()); runOnUiThread(new Runnable() { @@ -666,12 +638,6 @@ public class SearchCatalogListView extends Activity { } catch (SessionNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (NoAccessToServer e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoNetworkAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } runOnUiThread(new Runnable() { diff --git a/Open-ILS/src/Android/src/org/evergreen/android/services/ScheduledIntentService.java b/Open-ILS/src/Android/src/org/evergreen/android/services/ScheduledIntentService.java index 953566c0b4..f40db468b2 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/services/ScheduledIntentService.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/services/ScheduledIntentService.java @@ -31,8 +31,6 @@ import org.evergreen.android.accountAccess.SessionNotFoundException; import org.evergreen.android.accountAccess.checkout.CircRecord; import org.evergreen.android.database.DatabaseManager; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.globals.Utils; import org.open_ils.idl.IDLParser; @@ -41,7 +39,6 @@ import android.app.IntentService; import android.app.PendingIntent; import android.content.Intent; import android.content.SharedPreferences; -import android.net.ConnectivityManager; import android.preference.PreferenceManager; import android.util.Log; @@ -97,10 +94,7 @@ public class ScheduledIntentService extends IntentService { boolean auth = true; try { accountAccess.authenticate(); - } catch (NoNetworkAccessException e) { - auth = false; - e.printStackTrace(); - } catch (NoAccessToServer e) { + } catch (Exception e) { auth = false; e.printStackTrace(); } @@ -120,10 +114,6 @@ public class ScheduledIntentService extends IntentService { // get the circ records try { circRecords = accountAccess.getItemsCheckedOut(); - } catch (NoNetworkAccessException e) { - // not suppose to happen - } catch (NoAccessToServer e) { - // not suppose to happen } catch (SessionNotFoundException e) { // auth just earlier realized, not supose to happen } diff --git a/Open-ILS/src/Android/src/org/evergreen/android/utils/ui/BasicDetailsFragment.java b/Open-ILS/src/Android/src/org/evergreen/android/utils/ui/BasicDetailsFragment.java index 036914b2ea..d73d51742f 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/utils/ui/BasicDetailsFragment.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/utils/ui/BasicDetailsFragment.java @@ -30,8 +30,6 @@ import org.evergreen.android.accountAccess.SessionNotFoundException; import org.evergreen.android.accountAccess.bookbags.BookBag; import org.evergreen.android.accountAccess.holds.PlaceHold; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen.android.searchCatalog.CopyInformation; import org.evergreen.android.searchCatalog.ImageDownloader; import org.evergreen.android.searchCatalog.MoreCopyInformation; @@ -40,9 +38,7 @@ import org.evergreen.android.searchCatalog.SearchCatalog; import android.app.Dialog; import android.app.ProgressDialog; -import android.content.Context; import android.content.Intent; -import android.graphics.Bitmap; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; @@ -224,12 +220,6 @@ public class BasicDetailsFragment extends Fragment { } catch (SessionNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (NoAccessToServer e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoNetworkAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } getActivity().runOnUiThread(new Runnable() { @@ -370,7 +360,7 @@ public class BasicDetailsFragment extends Fragment { // insert into main view insertPoint.addView(copy_info_view, new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); LinearLayout copy_statuses = (LinearLayout) copy_info_view diff --git a/Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java b/Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java index 1c67a61caf..f2d53b7a94 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java @@ -24,16 +24,11 @@ import java.util.Calendar; import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; -import org.evergreen.android.globals.Utils; import org.evergreen.android.services.NotificationAlert; -import org.evergreen.android.services.NotificationReceiver; import org.evergreen.android.services.PeriodicServiceBroadcastReceiver; import org.evergreen.android.services.ScheduledIntentService; import android.app.AlarmManager; -import android.app.AlertDialog; import android.app.PendingIntent; import android.app.ProgressDialog; import android.content.Context; @@ -46,7 +41,6 @@ import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.provider.Settings; -import android.util.Log; import android.widget.Toast; public class ApplicationPreferences extends PreferenceActivity implements @@ -119,7 +113,6 @@ public class ApplicationPreferences extends PreferenceActivity implements AccountAccess account = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress); if (routeToAddress) { - try { if (account.authenticate()) { diff --git a/Open-ILS/src/Android/src/org/evergreen/android/views/ConfigureApplicationActivity.java b/Open-ILS/src/Android/src/org/evergreen/android/views/ConfigureApplicationActivity.java index b723fd9c97..f37f1274fa 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/views/ConfigureApplicationActivity.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/views/ConfigureApplicationActivity.java @@ -22,15 +22,12 @@ package org.evergreen.android.views; import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; import org.evergreen.android.globals.Utils; import android.app.Activity; import android.app.ProgressDialog; -import android.app.Service; import android.content.Context; import android.content.SharedPreferences; -import android.net.ConnectivityManager; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; @@ -87,13 +84,9 @@ public class ConfigureApplicationActivity extends Activity { boolean server_address = false; boolean auth = false; - try { - server_address = Utils - .checkIfNetAddressIsReachable(server_http - .getText().toString()); - } catch (NoAccessToServer e) { - server_address = false; - } + server_address = Utils + .checkIfNetAddressIsReachable(server_http + .getText().toString()); if (server_address == true) { diff --git a/Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/LoadingTask.java b/Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/LoadingTask.java index 771bb3ede5..13242db721 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/LoadingTask.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/LoadingTask.java @@ -19,26 +19,17 @@ */ package org.evergreen.android.views.splashscreen; -import java.security.PublicKey; - import org.evergreen.android.accountAccess.AccountAccess; import org.evergreen.android.accountAccess.SessionNotFoundException; import org.evergreen.android.globals.GlobalConfigs; -import org.evergreen.android.globals.NoAccessToServer; -import org.evergreen.android.globals.NoNetworkAccessException; import org.evergreen_ils.auth.Const; import android.accounts.Account; import android.accounts.AccountManager; -import android.accounts.AccountManagerCallback; import android.accounts.AccountManagerFuture; import android.app.Activity; -import android.net.ConnectivityManager; -import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; -import android.widget.ProgressBar; -import android.widget.TextView; /** This is basically the same as an AsyncTask, except that it uses * a Thread. Starting with HONEYCOMB, tasks are executed on a single thread and the 2nd @@ -123,7 +114,7 @@ public class LoadingTask { boolean haveSession = false; boolean retry = false; try { - haveSession = ac.initSession(auth_token); + haveSession = ac.retrieveSession(auth_token); } catch (SessionNotFoundException e) { mAccountManager.invalidateAuthToken(Const.ACCOUNT_TYPE, auth_token); retry = true; @@ -138,7 +129,7 @@ public class LoadingTask { Log.d(TAG, tag+"account_name="+account_name+" token="+auth_token); if (account_name == null) return "no account"; - haveSession = ac.initSession(auth_token); + haveSession = ac.retrieveSession(auth_token); } if (!haveSession) return "no session";