"Blackboard never used" check introduced
This commit is contained in:
@@ -79,7 +79,14 @@ public class UserLoginTask extends AsyncTask<Void, Void, String> {
|
||||
mBBLogin.testLoginToken(success, success1 -> {
|
||||
login.set(success1.toJsonString());
|
||||
latch.countDown();
|
||||
}, errorFunc);
|
||||
}, error -> {
|
||||
if (error.getCode() == 100270) {
|
||||
// Blackboard never used
|
||||
success.setNotAvailable();
|
||||
login.set(success.toJsonString());
|
||||
}
|
||||
errorFunc.onError(error);
|
||||
});
|
||||
}, errorFunc);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ModulesAnnouncements extends PartModules<ArrayList<Announcement>> {
|
||||
|
||||
@Override
|
||||
protected void upgradeKVV(final String ID, final NetworkCallback<ArrayList<Announcement>> callback, final NetworkErrorCallback errorCallback) {
|
||||
if (!mLogin.isInOnlineMode() || mLogin.getLoginTokenKVV() == null) {
|
||||
if (!mLogin.isInOnlineMode() || mLogin.getLoginTokenKVV() == null || !mLogin.getLoginTokenKVV().isAvailable()) {
|
||||
errorCallback.onError(new NetworkError(101204, 500, "Currently running in offline mode!"));
|
||||
return;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class ModulesAnnouncements extends PartModules<ArrayList<Announcement>> {
|
||||
|
||||
@Override
|
||||
protected void upgradeBB(String ID, NetworkCallback<ArrayList<Announcement>> callback, NetworkErrorCallback errorCallback) {
|
||||
if (!mLogin.isInOnlineMode() || mLogin.getLoginTokenBB() == null) {
|
||||
if (!mLogin.isInOnlineMode() || mLogin.getLoginTokenBB() == null || !mLogin.getLoginTokenBB().isAvailable()) {
|
||||
errorCallback.onError(new NetworkError(101214, 500, "Currently running in offline mode!"));
|
||||
return;
|
||||
}
|
||||
@@ -122,14 +122,7 @@ public class ModulesAnnouncements extends PartModules<ArrayList<Announcement>> {
|
||||
text = String.valueOf(fromHtml(text));
|
||||
String createdBy = "";//site.getString("createdByDisplayName");
|
||||
long createdOn = UtilsDate.stringToMillis(site.getString("startDateRestriction"), "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
//long createdOn = 0;//site.getLong("createdOn");
|
||||
|
||||
// Extract attachment links
|
||||
//JSONArray attachments = site.getJSONArray("attachments");
|
||||
ArrayList<String> urls = new ArrayList<>();
|
||||
/*for (int j = 0; j < attachments.length(); j++) {
|
||||
urls.add(attachments.getJSONObject(j).optString("url", null));
|
||||
}*/
|
||||
|
||||
announcements.add(new Announcement(id, title, text, createdBy, createdOn, urls));
|
||||
} catch (JSONException e) {
|
||||
|
||||
@@ -9,10 +9,8 @@ import org.json.JSONObject;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.regex.MatchResult;
|
||||
|
||||
import de.sebse.fuplanner.services.kvv.types.Lecturer;
|
||||
@@ -164,6 +162,10 @@ public class ModulesList extends HTTPService {
|
||||
errorCallback.onError(new NetworkError(101110, 500, "Currently running in offline mode!"));
|
||||
return;
|
||||
}
|
||||
if (!mLogin.getLoginTokenKVV().isAvailable()) {
|
||||
callback.onResponse(new Modules(mLogin.getLoginTokenKVV().getUsername()));
|
||||
return;
|
||||
}
|
||||
get("https://kvv.imp.fu-berlin.de/direct/site.json", mLogin.getLoginTokenKVV().getCookies(), response -> {
|
||||
String body = response.getParsed();
|
||||
if (body == null) {
|
||||
@@ -227,6 +229,10 @@ public class ModulesList extends HTTPService {
|
||||
errorCallback.onError(new NetworkError(101120, 500, "Currently running in offline mode!"));
|
||||
return;
|
||||
}
|
||||
if (!mLogin.getLoginTokenBB().isAvailable()) {
|
||||
callback.onResponse(modulesKVV);
|
||||
return;
|
||||
}
|
||||
get(String.format("https://lms.fu-berlin.de/learn/api/public/v1/users/%s/courses", mLogin.getLoginTokenBB().getId()), mLogin.getLoginTokenBB().getCookies(), response -> {
|
||||
String body = response.getParsed();
|
||||
if (body == null) {
|
||||
|
||||
@@ -18,6 +18,7 @@ public class LoginTokenBB {
|
||||
private final String s_session_id;
|
||||
private final String session_id;
|
||||
private final String username;
|
||||
private boolean isAvailable = true;
|
||||
@Nullable private String id;
|
||||
@Nullable private String studentId;
|
||||
|
||||
@@ -48,6 +49,17 @@ public class LoginTokenBB {
|
||||
public void setAdditionals(String id, String studentId) {
|
||||
this.id = id;
|
||||
this.studentId = studentId;
|
||||
this.isAvailable = true;
|
||||
}
|
||||
|
||||
public void setNotAvailable() {
|
||||
this.id = null;
|
||||
this.studentId = null;
|
||||
this.isAvailable = false;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return isAvailable;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
@@ -102,6 +114,7 @@ public class LoginTokenBB {
|
||||
json.put("username", username);
|
||||
json.put("id", id);
|
||||
json.put("studentId", studentId);
|
||||
json.put("isAvailable", isAvailable);
|
||||
} catch (JSONException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -120,6 +133,9 @@ public class LoginTokenBB {
|
||||
json.getString("id"),
|
||||
json.getString("studentId")
|
||||
);
|
||||
if (!json.optBoolean("isAvailable", true)) {
|
||||
token.setNotAvailable();
|
||||
}
|
||||
return token;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -17,6 +17,7 @@ import de.sebse.fuplanner.tools.CustomAccountManager;
|
||||
public class LoginTokenKVV {
|
||||
private final String username;
|
||||
private final String JSESSIONID;
|
||||
private boolean isAvailable = true;
|
||||
@Nullable private String fullName;
|
||||
@Nullable private String email;
|
||||
|
||||
@@ -46,6 +47,17 @@ public class LoginTokenKVV {
|
||||
public void setAdditionals(String fullName, String email) {
|
||||
this.fullName = fullName;
|
||||
this.email = email;
|
||||
this.isAvailable = true;
|
||||
}
|
||||
|
||||
public void setNotAvailable() {
|
||||
this.fullName = null;
|
||||
this.email = null;
|
||||
this.isAvailable = false;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return isAvailable;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
@@ -95,6 +107,7 @@ public class LoginTokenKVV {
|
||||
json.put("JSESSIONID", JSESSIONID);
|
||||
json.put("fullName", fullName);
|
||||
json.put("email", email);
|
||||
json.put("isAvailable", isAvailable);
|
||||
} catch (JSONException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -112,6 +125,9 @@ public class LoginTokenKVV {
|
||||
json.getString("fullName"),
|
||||
json.getString("email")
|
||||
);
|
||||
if (!json.optBoolean("isAvailable", true)) {
|
||||
token.setNotAvailable();
|
||||
}
|
||||
return token;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -14,7 +14,7 @@ https://lms.fu-berlin.de/learn/api/public/v1/users/_203980_1/courses
|
||||
|
||||
## Course details
|
||||
|
||||
https://lms.fu-berlin.de/learn/api/v1/courses/_122802_1
|
||||
https://lms.fu-berlin.de/learn/api/public/v1/courses/_122802_1
|
||||
|
||||
The field "courseId" in Blackboard can be matched to "props/kvv_lvnumbers" in "http://kvv.imp.fu-berlin.de/direct/site/<SITE_ID>"
|
||||
|
||||
@@ -25,7 +25,7 @@ The field "courseId" in Blackboard can be matched to "props/kvv_lvnumbers" in "h
|
||||
+ lvNumber
|
||||
* parse "courseId"
|
||||
+ title
|
||||
* "displayName"
|
||||
* "name"
|
||||
+ lecturer
|
||||
* https://lms.fu-berlin.de/learn/api/public/v1/courses/_127131_1/users
|
||||
* Find Instructor
|
||||
@@ -33,7 +33,7 @@ The field "courseId" in Blackboard can be matched to "props/kvv_lvnumbers" in "h
|
||||
+ type
|
||||
* parse "courseId" ('Vorlesung'/'Seminar'/...?)
|
||||
+ description
|
||||
* description
|
||||
* ""
|
||||
+ ID
|
||||
* id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user