bug fix renew item on hold by another user
authordrizea <danielrizea27@gmail.com>
Wed, 15 Aug 2012 10:26:03 +0000 (13:26 +0300)
committerdrizea <danielrizea27@gmail.com>
Wed, 15 Aug 2012 10:26:03 +0000 (13:26 +0300)
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/ServerErrorMessage.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/checkout/ItemsCheckOutListView.java

index 439df8b..895233a 100644 (file)
@@ -611,7 +611,7 @@ public class AccountAccess {
        /* Method used to renew a circulation record based on target_copy_id
         * Returns many objects, don't think they are needed
         */
-       public void renewCirc(Integer target_copy) throws MaxRenewalsException, SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{ 
+       public void renewCirc(Integer target_copy) throws MaxRenewalsException,ServerErrorMessage, SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{ 
                
                HashMap<String,Integer> complexParam = new HashMap<String, Integer>();
                complexParam.put("patron", this.userID);                
@@ -625,6 +625,7 @@ public class AccountAccess {
                if(resp.get("textcode") != null){
                        if(resp.get("textcode").equals("MAX_RENEWALS_REACHED"))
                                throw new MaxRenewalsException();
+                       throw new ServerErrorMessage(resp.get("desc").toString());
                }
                
                
@@ -681,9 +682,7 @@ public class AccountAccess {
                String holdType = (String)holdArhObject.get("hold_type");
                
                String method = null;
-               
-               
-               
+
                Object response;
                OSRFObject holdInfo = null;
                if(holdType.equals("T") || holdType.equals("M")){
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/ServerErrorMessage.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/ServerErrorMessage.java
new file mode 100644 (file)
index 0000000..0da01bb
--- /dev/null
@@ -0,0 +1,16 @@
+package org.evergreen.android.accountAccess;
+
+public class ServerErrorMessage extends Exception{
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 3341617529835568018L;
+
+       public String message;
+       
+       public ServerErrorMessage(String message){
+               this.message = message;
+       }
+       
+}
index 1de0964..bfb8e6c 100644 (file)
@@ -9,6 +9,7 @@ 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;
@@ -304,12 +305,25 @@ public class ItemsCheckOutListView extends Activity {
                                                                                        progressDialog.dismiss();
                                                                                        Toast.makeText(context,
                                                                                                        "Max renewals reached",
-                                                                                                       Toast.LENGTH_SHORT).show();
+                                                                                                       Toast.LENGTH_LONG).show();
                                                                                }
                                                                        });
 
                                                                        refresh = false;
-                                                               } catch (SessionNotFoundException e1) {
+                                                               }catch (ServerErrorMessage error) {
+                                                                       
+                                                                       final String errorMessage = error.message; 
+                                                                       runOnUiThread(new Runnable() {
+
+                                                                               @Override
+                                                                               public void run() {
+                                                                                       progressDialog.dismiss();
+                                                                                       Toast.makeText(context,
+                                                                                                       errorMessage,
+                                                                                                       Toast.LENGTH_LONG).show();
+                                                                               }
+                                                                       });
+                                                               }catch (SessionNotFoundException e1) {
                                                                        try {
                                                                                if (accountAccess.authenticate())
                                                                                        ac.renewCirc(record.getTargetCopy());