1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.exoplatform.ui.login.tasks;
20
21 import java.io.IOException;
22
23 import org.exoplatform.utils.ExoConnectionUtils;
24
25 import android.os.AsyncTask;
26 import android.util.Log;
27
28
29
30
31 public class CheckingTenantStatusTask extends AsyncTask<String, Void, Integer> {
32
33 private AsyncTaskListener mListener;
34
35 private static final String TAG = "eXo____CheckingTenantStatusTask____";
36
37 @Override
38 protected Integer doInBackground(String... params) {
39 String tenant = params[0];
40 String email = params[1];
41 Log.d(TAG, "Checking tenant status: " + tenant + " for " + email);
42
43 try {
44 int status = ExoConnectionUtils.requestTenantStatus(tenant);
45 if (status == ExoConnectionUtils.LOGIN_SERVER_RESUMING)
46 return ExoConnectionUtils.LOGIN_SERVER_RESUMING;
47
48 else if (status == ExoConnectionUtils.SIGNIN_SERVER_SUSPENDED) {
49
50 ExoConnectionUtils.makeCloudSignUpRequest(email);
51 return ExoConnectionUtils.LOGIN_SERVER_RESUMING;
52 } else if (status == ExoConnectionUtils.SIGNIN_SERVER_ONLINE)
53 return ExoConnectionUtils.TENANT_OK;
54
55 return status;
56 } catch (IOException e) {
57 Log.d(TAG, "IOException: " + e.getLocalizedMessage());
58 return ExoConnectionUtils.SIGNIN_SERVER_NAV;
59 }
60 }
61
62 public void setListener(AsyncTaskListener listener) {
63 mListener = listener;
64 }
65
66 @Override
67 protected void onPostExecute(Integer result) {
68 if (mListener != null)
69 mListener.onCheckingTenantStatusFinished(result);
70 }
71
72 public interface AsyncTaskListener {
73
74 void onCheckingTenantStatusFinished(int result);
75 }
76 }