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) boolean
Whether the student's clear name should be found out while logging in.private boolean
Whether the student's e-mail address should be found out while logging in.private boolean
Whether the task has been prematurelyterminated
by 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 Boolean
Whether the login was executed successfully.static final int
The amount of steps to complete this task. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Prematurely terminates the action.private void
Notifies allsubscribers
that the login process was terminated prematurely by outside intervention.private void
Uses theParser
tofind out
the student'sclear name
from the given HTML document retrieved from Friedolin.private void
failed()
Notifies allsubscribers
that the login process finished unsuccessfully.void
registerListener
(@NonNull Task.TaskListener<Boolean> listener) Adds a subscriber that is interested in status updates of the action's progress.boolean
removeListener
(@NonNull Task.TaskListener<Boolean> listener) Removes a subscriber that was previously added to receive status updates of the action's progress.void
run()
Logs in to Friedolin using the student's credentials specified in theConfiguration
previously set viaFriedolinClient.setConfiguration(Configuration)
(or the constructor).void
setFetchPersonalData
(boolean fetchClearname, boolean fetchEmailAddress) Updates the setting whether the student'sclear name
andemail address
should be fetched from the University of Jena's Friedolin system along with the login.private void
started()
Notifies allsubscribers
that the login process has begun.private void
Notifies allsubscribers
that the login process was successful.private void
updateProgress
(int current, int total) Notifies allsubscribers
about 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.null
until the task has finished. -
isCancelled
private boolean isCancelledWhether the task has been prematurelyterminated
by 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:
registerListener
in 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:
removeListener
in 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:
true
if the subscriber was removed,false
if it hadn't been registered in the first place.- See Also:
-
updateProgress
private void updateProgress(int current, int total) Notifies allsubscribers
about 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 allsubscribers
that the login process has begun. -
failed
private void failed()Notifies allsubscribers
that the login process finished unsuccessfully. -
cancelled
private void cancelled()Notifies allsubscribers
that the login process was terminated prematurely by outside intervention. -
succeeded
private void succeeded()Notifies allsubscribers
that the login process was successful. -
cancel
-
getResult
- Specified by:
getResult
in 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 name
andemail address
should 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
configuration
asConfiguration.getClearname()
andConfiguration.getEmail()
.- Specified by:
setFetchPersonalData
in 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 theParser
tofind out
the student'sclear name
from 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 theConfiguration
previously set viaFriedolinClient.setConfiguration(Configuration)
(or the constructor).
-