java.lang.Object
page.codeberg.friedolyn.util.Task<Boolean>
page.codeberg.friedolyn.client.FriedolinClient.Login
page.codeberg.friedolyn.client.Client.Login
- All Implemented Interfaces:
Runnable
- Enclosing class:
Client
A
Task that can be executed in a different Thread to log in to
Friedolin using the student's credentials specified in the Configuration previously set via
FriedolinClient.setConfiguration(Configuration) (or the constructor).- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class page.codeberg.friedolyn.util.Task
Task.CancelListener, Task.FailureListener<ResultType>, Task.ProgressListener, Task.SuccessListener<ResultType>, Task.TaskListener<ResultType> -
Field Summary
FieldsModifier and TypeFieldDescription(package private) booleanWhether the student's clear name should be found out while logging in.private booleanWhether the student's e-mail address should be found out while logging in.private booleanWhether the task has been prematurelyterminatedby outside intervention.private final @NonNull HashSet<Task.TaskListener<Boolean>> The subscribers that will be notified about any status changes and progress updates of this task.private BooleanWhether the login was executed successfully.static final intThe amount of steps to complete this task. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Prematurely terminates the action.private voidNotifies allsubscribersthat the login process was terminated prematurely by outside intervention.private voidUses theParsertofind outthe student'sclear namefrom the given HTML document retrieved from Friedolin.private voidfailed()Notifies allsubscribersthat the login process finished unsuccessfully.voidregisterListener(@NonNull Task.TaskListener<Boolean> listener) Adds a subscriber that is interested in status updates of the action's progress.booleanremoveListener(@NonNull Task.TaskListener<Boolean> listener) Removes a subscriber that was previously added to receive status updates of the action's progress.voidrun()Logs in to Friedolin using the student's credentials specified in theConfigurationpreviously set viaFriedolinClient.setConfiguration(Configuration)(or the constructor).voidsetFetchPersonalData(boolean fetchClearname, boolean fetchEmailAddress) Updates the setting whether the student'sclear nameandemail addressshould be fetched from the University of Jena's Friedolin system along with the login.private voidstarted()Notifies allsubscribersthat the login process has begun.private voidNotifies allsubscribersthat the login process was successful.private voidupdateProgress(int current, int total) Notifies allsubscribersabout the amount of work that has already been done and the total amount of work that needs to be done to finish logging in.Methods inherited from class page.codeberg.friedolyn.util.Task
setOnCancelled, setOnFailed, setOnProgressUpdate, setOnSucceeded
-
Field Details
-
TOTAL_WORK
public static final int TOTAL_WORKThe amount of steps to complete this task.- See Also:
-
LISTENERS
The subscribers that will be notified about any status changes and progress updates of this task. -
fetchClearname
boolean fetchClearnameWhether the student's clear name should be found out while logging in. -
fetchEmailAddress
private boolean fetchEmailAddressWhether the student's e-mail address should be found out while logging in. -
success
Whether the login was executed successfully.nulluntil the task has finished. -
isCancelled
private boolean isCancelledWhether the task has been prematurelyterminatedby outside intervention.
-
-
Constructor Details
-
Login
public Login()
-
-
Method Details
-
registerListener
Adds a subscriber that is interested in status updates of the action's progress. Does NOT remove or replace any existing listeners.- Specified by:
registerListenerin classTask<Boolean>- Parameters:
listener- The subscriber that wants to be informed about the progress of the action.- See Also:
-
removeListener
Removes a subscriber that was previously added to receive status updates of the action's progress.- Specified by:
removeListenerin classTask<Boolean>- Parameters:
listener- The subscriber that no longer wants to be informed about the progress of the action. Must be the exact same reference that was previously registered.- Returns:
trueif the subscriber was removed,falseif it hadn't been registered in the first place.- See Also:
-
updateProgress
private void updateProgress(int current, int total) Notifies allsubscribersabout the amount of work that has already been done and the total amount of work that needs to be done to finish logging in. -
started
private void started()Notifies allsubscribersthat the login process has begun. -
failed
private void failed()Notifies allsubscribersthat the login process finished unsuccessfully. -
cancelled
private void cancelled()Notifies allsubscribersthat the login process was terminated prematurely by outside intervention. -
succeeded
private void succeeded()Notifies allsubscribersthat the login process was successful. -
cancel
-
getResult
- Specified by:
getResultin classTask<Boolean>- Returns:
- The end product generated by the action. Empty if the action has not finished yet.
The presence of
Result.getResult()does NOT indicate success. OnlyResult.getSuccess()can be used to determine success or failure.
-
setFetchPersonalData
public void setFetchPersonalData(boolean fetchClearname, boolean fetchEmailAddress) Updates the setting whether the student'sclear nameandemail addressshould be fetched from the University of Jena's Friedolin system along with the login. May require additional network requests, slowing down the login process.The results of the fetches will be stored in the
configurationasConfiguration.getClearname()andConfiguration.getEmail().- Specified by:
setFetchPersonalDatain classFriedolinClient.Login- Parameters:
fetchClearname- Whether the student's clear name should be found out. True by default.fetchEmailAddress- Whether the student's email address should be found out. False by default.
-
extractStudentClearname
Uses theParsertofind outthe student'sclear namefrom the given HTML document retrieved from Friedolin.- Parameters:
html- The body of the response to the HTTP request to Friedolin.- Throws:
IllegalArgumentException- If the student's clear name could not be extracted from the HTML document.
-
run
Logs in to Friedolin using the student's credentials specified in theConfigurationpreviously set viaFriedolinClient.setConfiguration(Configuration)(or the constructor).
-