Compare commits

..

1 commit

5 changed files with 2 additions and 66 deletions

View file

@ -78,19 +78,11 @@ public class UntisClient {
public void logout() throws APIRequestException {
try {
client.invoke("logout", new Object[0], Object.class);
auth = null;
} catch (Throwable e) {
throw new APIRequestException(e);
}
}
@Override
protected void finalize() throws Throwable {
if (auth != null) {
logout();
}
}
/**
* Get list of subjects
* @return an ArrayList of subjects

View file

@ -10,9 +10,7 @@ public class KlasseResponse extends ArrayList<KlasseResponse.Klasse> {
public String longName;
public String backColor;
public String longColor;
public boolean active;
public String teacher1;
public String teacher2;
}

View file

@ -31,11 +31,6 @@ public class TimetableResponse extends ArrayList<TimetableResponse.Period> {
public String name;
public String longname;
public String externalkey;
public int orgid;
public String orgname;
public String orglongname;
public String orgexternalkey;
}
}

View file

@ -1,51 +1,16 @@
package ley.untis.exception;
import org.omg.CORBA.UNKNOWN;
public class APIRequestException extends Exception {
Throwable source;
String message;
EnumError errorType;
public APIRequestException(Throwable error) {
source = error;
message = source.getMessage();
if (message == null) {
errorType = EnumError.UNKNOWN;
} else if (message.contains("no such element")) {
errorType = EnumError.ELEMENTNOTFOUND;
} else if (message.contains("no right")) {
errorType = EnumError.NOPERMISSION;
} else if (message.contains("webuntis.com")) {
errorType = EnumError.NOCONNECTION;
}else {
switch (message) {
case "bad credentials":
errorType = EnumError.BADCREDENTIALS;
break;
case "0":
errorType = EnumError.SCHOOLNOTFOUND;
break;
case "too many results":
errorType = EnumError.TOOMANYSCHOOLS;
break;
case "no allowed date":
errorType = EnumError.DATENOTALLOWED;
default:
errorType = EnumError.UNKNOWN;
break;
}
}
}
public EnumError getError() {
return errorType;
}
@Override
public String getMessage() {
return message;
return source.getMessage();
}
@Override

View file

@ -1,14 +0,0 @@
package ley.untis.exception;
public enum EnumError {
UNKNOWN,
BADCREDENTIALS,
SCHOOLNOTFOUND,
TOOMANYSCHOOLS,
NOCONNECTION,
NOPERMISSION,
ELEMENTNOTFOUND,
DATENOTALLOWED
}