/** The METHOD_FETCH_MODS_FROM_COPY description : used to return info. @returns : mvr class OSRF Object. Fields of interest : title, author */
public static String METHOD_FETCH_MODS_FROM_COPY = "open-ils.search.biblio.mods_from_copy";
+ public static String METHOD_ORG_TREE_RETRIEVE = "open-ils.actor.org_tree.retrieve";
+
/** The METHOD_FETCH_COPY description : used to return info for a PRE_CATALOGED object. @returns : acp class OSRF Object. Fields of interest : dummy_title, dummy_author */
public static String METHOD_FETCH_COPY = "open-ils.search.asset.copy.retrieve";
}
}
-// public void getOrgHiddentDepth() {
-//
-// // logic can be found in the opac_utils.js file in web/opac/common/js
-//
-// for (int i = 0; i < organisations.size(); i++) {
-// AccountAccess ac = AccountAccess.getAccountAccess();
-// try {
-// Object obj = ac.fetchOrgSettings(organisations.get(i).id,
-// "opac.org_unit_hiding.depth");
-// } catch (SessionNotFoundException e) {
-// }
-//
-// }
-//
-// }
-
// ------------------------Checked Out Items Section
// -------------------------//
if (id.equals("-1"))
return "";
- OSRFObject resp = (OSRFObject) Utils.doRequestSimple(conn(), PCRUD_SERVICE,
- PCRUD_METHOD_RETRIEVE_MRA, new Object[] { "ANONYMOUS", id });
+ OSRFObject resp;
+ try {
+ resp = (OSRFObject) Utils.doRequest(conn(), PCRUD_SERVICE,
+ PCRUD_METHOD_RETRIEVE_MRA, authToken, new Object[]{
+ authToken, id});
+ } catch (SessionNotFoundException e) {
+ return "";
+ }
// This is not beautiful. This MRA record comes back with an 'attrs' field that
// appears to have been serialized by perl Data::Dumper, e.g.
}
- // ------------------------Holds Section
+ // ------------------------orgs Section
// --------------------------------------//
+ public OSRFObject fetchOrgs() {
+ OSRFObject response = (OSRFObject) Utils.doRequest(conn(), SERVICE_ACTOR,
+ METHOD_ORG_TREE_RETRIEVE, new Object[]{});
+ try {
+ //List<OSRFObject> l = (List<OSRFObject>) response;
+ Log.d(TAG, "response="+response);
+ } catch (Exception e) {
+ Log.d(TAG, "caught exception", e);
+ }
+ return response;
+ }
+
/**
* Fetch org settings.
*
* @return the object
* @throws SessionNotFoundException the session not found exception
*/
- public Object fetchOrgSettings(Integer org_id, String setting)
- throws SessionNotFoundException {
+// public OSRFObject fetchOrgSettings(Integer org_id, String setting)
+// throws SessionNotFoundException {
+//
+// OSRFObject response = (OSRFObject) Utils.doRequest(conn(), SERVICE_ACTOR,
+// METHOD_FETCH_ORG_SETTINGS, new Object[]{
+// org_id, setting});
+// return response;
+// }
- OSRFObject response = (OSRFObject) Utils.doRequest(conn(), SERVICE_ACTOR,
- METHOD_FETCH_ORG_SETTINGS, new Object[] {
- org_id, setting });
- return response;
+// public void getOrgHiddentDepth() {
+//
+// // logic can be found in the opac_utils.js file in web/opac/common/js
+//
+// for (int i = 0; i < organisations.size(); i++) {
+// AccountAccess ac = AccountAccess.getAccountAccess();
+// try {
+// Object obj = ac.fetchOrgSettings(organisations.get(i).id,
+// "opac.org_unit_hiding.depth");
+// } catch (SessionNotFoundException e) {
+// }
+//
+// }
+//
+// }
- }
+ // ------------------------Holds Section
+ // --------------------------------------//
/**
* Gets the holds.
return textcode;
}
+ private static void handleNPE(NullPointerException e, String service, String methodName) {
+ // I know it's bad form to catch NPE. But until I implement some kind of on-demand IDL parsing,
+ // this is what happens when the JSONReader tries to parse a response of an unregistered class.
+ // Crash if debugMode, fail if not.
+ Log.d(TAG, "NPE...unregistered type from service "+service+" method "+methodName, e);
+ if (GlobalConfigs.isDebugMode()) {
+ throw(e);
+ }
+ }
+
public static Object doRequest(HttpConnection conn, String service,
String methodName, String authToken,
Object[] params) throws SessionNotFoundException {
try {
resp = req.recv();
} catch (NullPointerException e) {
- // I know it's bad form to catch NPE. But until I implement some kind of on-demand IDL parsing,
- // this is what happens when the JSONReader tries to parse a response of an unregistered class.
- // Crash if debugMode, fail if not.
- Log.d(TAG, "NPE...unregistered type?", e);
- if (GlobalConfigs.isDebugMode()) {
- throw(e);
- }
+ handleNPE(e, service, methodName);
}
if (resp != null) {
Log.d(TAG, "Sync Response: " + resp);
HttpRequest req = new GatewayRequest(conn, service, method).send();
Object resp;
- while ((resp = req.recv()) != null) {
- Log.d(TAG, "Sync Response: " + resp);
- Object response = (Object) resp;
-
- return response;
+ try {
+ while ((resp = req.recv()) != null) {
+ Log.d(TAG, "Sync Response: " + resp);
+ Object response = (Object) resp;
+ return response;
+ }
+ } catch (NullPointerException e) {
+ handleNPE(e, service, methodName);
}
return null;
}
import android.os.Bundle;
import android.util.Log;
import org.evergreen_ils.searchCatalog.Library;
+import org.opensrf.util.OSRFObject;
/** This is basically the same as an AsyncTask<String,String,String>, except that it uses
* a Thread. Starting with HONEYCOMB, tasks are executed on a single thread and the 2nd
publishProgress("Loading resources");
GlobalConfigs.getGlobalConfigs(mCallingActivity, library.url);
- Log.d(TAG, tag+"Starting session");
- publishProgress("Starting session");
AccountAccess ac = AccountAccess.getAccountAccess();
+ /* way to fetch org tree using OSRF rather than parsing JS
+ try {
+ OSRFObject o = ac.fetchOrgs();
+ } catch (Exception e) {
+ Log.d(TAG, tag+"caught exception", e);
+ }
+ */
+
// auth token zen: try once and if it fails, invalidate the token and try again
+ Log.d(TAG, tag+"Starting session");
+ publishProgress("Starting session");
boolean haveSession = false;
try {
haveSession = ac.retrieveSession(auth_token);