-#ignore class objects
*.class
*.dex
+.idea/workspace.xml
+.idea/tasks.xml
bin/
gen/
.settings
--- /dev/null
+EvergreenApp
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="CompilerConfiguration">
+ <option name="DEFAULT_COMPILER" value="Javac" />
+ <resourceExtensions />
+ <wildcardResourcePatterns>
+ <entry name="!?*.java" />
+ <entry name="!?*.form" />
+ <entry name="!?*.class" />
+ <entry name="!?*.groovy" />
+ <entry name="!?*.scala" />
+ <entry name="!?*.flex" />
+ <entry name="!?*.kt" />
+ <entry name="!?*.clj" />
+ </wildcardResourcePatterns>
+ <annotationProcessing>
+ <profile default="true" name="Default" enabled="false">
+ <processorPath useClasspath="true" />
+ </profile>
+ </annotationProcessing>
+ </component>
+</project>
+
--- /dev/null
+<component name="CopyrightManager">
+ <settings default="">
+ <module2copyright />
+ </settings>
+</component>
\ No newline at end of file
--- /dev/null
+<component name="ProjectDictionaryState">
+ <dictionary name="kenstir">
+ <words>
+ <w>textcode</w>
+ </words>
+ </dictionary>
+</component>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+</project>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="EntryPointsManager">
+ <entry_points version="2.0" />
+ </component>
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
+ <output url="file://$PROJECT_DIR$/classes" />
+ </component>
+</project>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/EvergreenApp.iml" filepath="$PROJECT_DIR$/EvergreenApp.iml" />
+ </modules>
+ </component>
+</project>
+
--- /dev/null
+<component name="DependencyValidationManager">
+ <state>
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+ </state>
+</component>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="Palette2">
+ <group name="Swing">
+ <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+ </item>
+ <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+ </item>
+ <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+ <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+ <initial-values>
+ <property name="text" value="Button" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="RadioButton" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="CheckBox" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="Label" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+ <preferred-size width="200" height="200" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+ <preferred-size width="200" height="200" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+ </item>
+ <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+ <preferred-size width="-1" height="20" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+ </item>
+ <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+ </item>
+ </group>
+ </component>
+</project>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="" vcs="" />
+ <mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
+ </component>
+</project>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="EclipseModuleManager" forced_jdk="true">
+ <libelement value="jar://$MODULE_DIR$/libs/android-support-v4.jar!/" />
+ <libelement value="jar://$MODULE_DIR$/libs/org.opensrf2_serialized_reg.jar!/" />
+ <libelement value="jar://$MODULE_DIR$/libs/zxing_barcode.jar!/" />
+ <libelement value="jar://$MODULE_DIR$/libs/androwrapee-1.1.0.jar!/" />
+ <conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
+ <src_description expected_position="5">
+ <src_folder value="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" expected_position="0" />
+ <src_folder value="com.android.ide.eclipse.adt.LIBRARIES" expected_position="1" />
+ <src_folder value="file://$MODULE_DIR$/src" expected_position="6" />
+ <src_folder value="file://$MODULE_DIR$/gen" expected_position="7" />
+ </src_description>
+ </component>
+ <component name="FacetManager">
+ <facet type="android" name="Android">
+ <configuration />
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/bin/classes" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
+ </content>
+ <orderEntry type="jdk" jdkName="Android 4.4 Platform" jdkType="Android SDK" />
+ <orderEntry type="module-library">
+ <library name="android-support-v4.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/libs/android-support-v4.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="file://E:/tools/adt-bundle-windows-x86_64-20130917/sdk/extras/android/support/v4/docs" />
+ </JAVADOC>
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library name="org.opensrf2_serialized_reg.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/libs/org.opensrf2_serialized_reg.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library name="zxing_barcode.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/libs/zxing_barcode.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library name="androwrapee-1.1.0.jar">
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/libs/androwrapee-1.1.0.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module>
+
*/
package org.evergreen.android.accountAccess;
+import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
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
* Instantiates a new authenticate user.
*
* @param httpAddress the http address
- * @param cm the cm
*/
private AccountAccess(String httpAddress) {
* Gets the account access.
*
* @param httpAddress the http address
- * @param cm the cm
* @return the account access
*/
public static AccountAccess getAccountAccess(String httpAddress) {
}
/**
- * 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");
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
* @throws NoAccessToServer the no access to server
*/
public ArrayList<CircRecord> getItemsCheckedOut()
- throws SessionNotFoundException, NoNetworkAccessException,
- NoAccessToServer {
+ throws SessionNotFoundException {
ArrayList<CircRecord> circRecords = new ArrayList<CircRecord>();
/*
List<String> 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<String>) ((Map<String, ?>) resp)
* @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;
}
* @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;
*
* @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,
*
* @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 });
* @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<String, Integer> complexParam = new HashMap<String, Integer>();
complexParam.put("patron", this.userID);
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<String, String> resp = (Map<String, String>) a_lot;
* @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,
*
* @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<HoldRecord> getHolds() throws SessionNotFoundException,
- NoNetworkAccessException, NoAccessToServer {
+ public List<HoldRecord> getHolds() throws SessionNotFoundException {
ArrayList<HoldRecord> holds = new ArrayList<HoldRecord>();
List<OSRFObject> 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;
* @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");
* @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");
System.err.println("Can't get types of resurce type"
+ e.getMessage());
}
- ;
}
return copyObject;
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,
System.err.println("Can't get types of resurce type"
+ e.getMessage());
}
- ;
}
return null;
* @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<String, Integer> map = (Map<String, Integer>)resp;
* @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
* @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);
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;
* @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);
// 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];
resp[1] = ((Map<String, String>) map).get("textcode");
resp[2] = ((Map<String, String>) map).get("desc");
}
- ;
System.out.println("Result " + resp[1] + " " + resp[2]);
* @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<String, Integer> mapAsk = getHoldPreCreateInfo(recordID,
pickup_lib);
// "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;
* @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<String, Integer> getHoldPreCreateInfo(Integer recordID,
- Integer pickup_lib) throws NoNetworkAccessException,
- NoAccessToServer {
+ Integer pickup_lib) {
HashMap<String, Integer> param = new HashMap<String, Integer>();
*
* @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];
*
* @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<FinesRecord> getTransactions()
- throws SessionNotFoundException, NoNetworkAccessException,
- NoAccessToServer {
+ throws SessionNotFoundException {
ArrayList<FinesRecord> finesRecords = new ArrayList<FinesRecord>();
Object transactions = Utils.doRequest(conn, SERVICE_ACTOR,
- METHOD_FETCH_TRANSACTIONS, authToken, cm, new Object[] {
+ METHOD_FETCH_TRANSACTIONS, authToken, new Object[] {
authToken, userID });
// get Array
*
* @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<OSRFObject> bookbags = (List<OSRFObject>) response;
* @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<String, ?> map = (Map<String, ?>) Utils.doRequest(conn,
- SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, authToken, cm,
+ SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, authToken,
new Object[] { authToken, "biblio", bookbagID });
List<OSRFObject> items = new ArrayList<OSRFObject>();
*
* @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);
*
* @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");
*
* @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 });
}
* @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);
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 });
}
* @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 });
}
* @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 });
}
}
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;
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;
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() {
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() {
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;
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;
bookBags = accountAccess.getBookbags();
} catch (NoNetworkAccessException e) {
- Utils.showNetworkNotAvailableDialog(context);
+ Utils.showSessionNotAvailableDialog(context);
} catch (NoAccessToServer e) {
Utils.showServerNotAvailableDialog(context);
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;
try {
circRecords = accountAccess.getItemsCheckedOut();
} catch (NoNetworkAccessException e) {
- Utils.showNetworkNotAvailableDialog(context);
+ Utils.showSessionNotAvailableDialog(context);
} catch (NoAccessToServer e) {
Utils.showServerNotAvailableDialog(context);
.println("Exception in reAuth");
}
} catch (NoNetworkAccessException e1) {
- Utils.showNetworkNotAvailableDialog(context);
+ Utils.showSessionNotAvailableDialog(context);
} catch (NoAccessToServer e1) {
Utils.showServerNotAvailableDialog(context);
}
circRecords = accountAccess
.getItemsCheckedOut();
} catch (NoNetworkAccessException e) {
- Utils.showNetworkNotAvailableDialog(context);
+ Utils.showSessionNotAvailableDialog(context);
} catch (NoAccessToServer e) {
Utils.showServerNotAvailableDialog(context);
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;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
-import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
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<FinesRecord> 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<FinesRecord> finesRecords = frecords;
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;
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;
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) {
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,
*/
package org.evergreen.android.accountAccess.holds;
-import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
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;
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;
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);
}
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;
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;
.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(),
thaw_date_s);
} catch (Exception e1) {
}
-
- } catch (NoNetworkAccessException e) {
- Utils.showNetworkNotAvailableDialog(context);
- } catch (NoAccessToServer e) {
- Utils.showServerNotAvailableDialog(context);
}
final String[] holdPlaced = stringResponse;
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) {
}
}
+++ /dev/null
-/*
- * 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;
-
-}
+++ /dev/null
-/*
- * 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;
-
-}
+++ /dev/null
-/*
- * 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
--- /dev/null
+/*
+ * 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
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;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
import android.util.Log;
import android.widget.ImageView;
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.
}
- 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<String, String>) 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+":");
Log.d(TAG, "Sync Response: " + resp);
Object response = (Object) resp;
- String textcode = null;
- try {
- textcode = ((Map<String, String>) 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;
// 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);
// 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++) {
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);
}
}
}
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);
*/
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 {
// 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
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;
records.size());
} catch (NoNetworkAccessException e) {
runOnUiThread(Utils
- .showNetworkNotAvailableDialog(context));
+ .showSessionNotAvailableDialog(context));
} catch (NoAccessToServer e) {
runOnUiThread(Utils
.showServerNotAvailableDialog(context));
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;
/**
* Instantiates a new search catalog.
- *
- * @param httpAddress
- * the http address
- * @param locale
- * the locale
*/
private SearchCatalog(ConnectivityManager cm) {
super();
* @return the search results
*/
public ArrayList<RecordInfo> getSearchResults(String searchWords,
- Integer offset) throws NoNetworkAccessException, NoAccessToServer {
+ Integer offset) {
searchText = searchWords;
* 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 });
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;
}
});
- 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() {
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() {
.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() {
} 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() {
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;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.net.ConnectivityManager;
import android.preference.PreferenceManager;
import android.util.Log;
boolean auth = true;
try {
accountAccess.authenticate();
- } catch (NoNetworkAccessException e) {
- auth = false;
- e.printStackTrace();
- } catch (NoAccessToServer e) {
+ } catch (Exception e) {
auth = false;
e.printStackTrace();
}
// 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
}
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;
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;
} 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() {
// 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
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;
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
AccountAccess account = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
if (routeToAddress) {
-
try {
if (account.authenticate()) {
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;
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) {
*/
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<String,String,String>, except that it uses
* a Thread. Starting with HONEYCOMB, tasks are executed on a single thread and the 2nd
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;
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";