After constructing a new Friedolyn object with the student's credentials, the grades can be fetched with the
fetchGrades()
method. The student's clear name can be retrieved with the fetchStudentClearname()
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
A callback that is to be called as soon as the currently logged-in user has been identified as banned from using Friedolyn.static enum
The various types of requests that can be sent via thecontact form
.class
Fetches the student's grades from the University of Jena's Friedolin system by calling thefetchGrades()
.static interface
Subscribes to status changes of the periodicgrades fetching
on the respectiveFriedolyn
object.static class
Various folders in theinvalid reference
Friedolyn directory
static enum
Whether thefetchGradesTask
is currentlyrunning
or not and what this means for calling various methods. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull ReentrantLock
Facilitates mutual exclusion when updating thebanLevels
.The application's features that the user is disallowed from using.static final @NonNull URL
The base URL to access the Friedolin server.private @NonNull FriedolinClient
TheFriedolinClient
to use for interacting with the Friedolin system.private @NonNull Configuration
Various options that modify Friedolyn's behaviour.private @NonNull Countdown
The time left until the next execution of thefetchGradesTask
.static final @NonNull KnownDegree
The default degrees to search for in the grades.static final @NonNull Duration
The default amount of time between two grade fetches from the Friedolin server: SeeDEFAULT_INTERVAL_MINUTES
.static final int
The default amount of hours between two grade fetches from the Friedolin server: 5 minutes.static final @NonNull Path
The default Friedolyn directory where all application data is stored.static final @NonNull String
The hostname of the Friedolin server.private int
The total number of allfetches
that have been executed so far, including both successful and unsuccessful ones.private @NonNull Friedolyn.FetchGradesTask
Fetches the student's grades from the University of Jena's Friedolin system by calling thefetchGrades()
.static final @NonNull Duration
Default amount of time to wait before retrying to fetch the grades from the Friedolin server after a failure: 10 seconds.static final @NonNull Duration
Default amount of time to wait before retrying to fetch the grades from the Friedolin server after a failure: 5 seconds.private final @NonNull Set
<Friedolyn.FriedolynListener> Subscribers that are interested in thestatus
changes of the periodicgrades fetching
.private final @NonNull ReentrantLock
Facilitates mutual exclusion whenrunning
thefetchGradesTask
.static final String
The default name of the log file which the Friedolyn application's Log4J logs are written to.static final @NonNull Duration
The maximum amount of time between two grade fetches from the Friedolin server: 7 days.static final int
The maximum amount of days between two grade fetches from the Friedolin server: 7 days.private PolledMetadata
Stores information about the application, fetched from the Codeberg repository, most notably theURL to a user poll
and alist of banned users
.static final @NonNull Duration
The minimum amount of time between two grade fetches from the Friedolin server: 5 minutes.static final int
The minimum amount of minutes between two grade fetches from the Friedolin server: 1 minutes.static final @NonNull String
The name of this application.private static final @NonNull Preferences
static final @NonNull String
The path to the Friedolin server's request handler.static final @NonNull URL
The full URL to access Friedolin's request handler.static final int
Number of attempt waves to fetch the grades from the Friedolin server before giving up: 3.private Friedolyn.Status
Indicates whether thefetchGradesTask
is currentlyrunning
, paused etc.static final @NonNull String
The name of the file where thesystem information
should be stored when invokinggetSystemInfoFile()
.private final @NonNull UserAgentManager
Stores various user agents of Friedolyn and real web browsers.static final @NonNull com.fasterxml.jackson.core.Version
The version of this application. -
Constructor Summary
ConstructorsConstructorDescriptionFriedolyn
(@NonNull Configuration configuration) Creates a new Friedolyn object with a deep copy of the given configuration. -
Method Summary
Modifier and TypeMethodDescription@NonNull jakarta.mail.internet.InternetAddress
Fetches the student's email address from the University of Jena's Friedolin system and updates theconfiguration
accordingly.boolean
Fetches the student's grades from the University of Jena's Friedolin system (once).@NonNull String
void
finish()
Explicitly frees the resources of theclient
.@NonNull Configuration
@NonNull Configuration
static String
static @NonNull File
Writes thesystem information
to a file in the system's temporary directory.void
void
Adds anotherCountdown.CountdownListener
to the set of objects interested in when the nextgrades fetching run
will be executed.void
registerListener
(@NonNull Friedolyn.FriedolynListener listener) Registers a newFriedolyn.FriedolynListener
to the set of objects interested in the status changes of the periodicgrades fetching
.boolean
Deletes an alreadyregistered
Countdown.CountdownListener
from the set of objects interested in when the nextgrades fetching run
will be executed.boolean
removeListener
(@NonNull Friedolyn.FriedolynListener listener) Deletes an alreadyregistered
Friedolyn.FriedolynListener
from the set of objects interested in the status changes of the periodicgrades fetching
.void
Continues the periodic fetching of the student's grades from the University of Jena's Friedolin system at the point where it was paused previously by calling thepausePeriodicGradesFetch()
method.void
setConfiguration
(@NonNull Configuration configuration) Updates the currentconfiguration
with the deep copy of a new one (not the actual reference of it, for security reasons).void
Starts fetching the student's grades from the University of Jena's Friedolin system periodically according to theinvalid reference
interval
configuration
.private void
startPeriodicGradesFetch
(@NonNull Duration delay) Starts fetching the student's grades from the University of Jena's Friedolin system periodically according to theinvalid reference
interval
configuration
and with a certain delay.boolean
Cancels thetask
that fetches the student's grades from the University of Jena's Friedolin system periodically.
-
Field Details
-
NAME
-
VERSION
@NonNull public static final @NonNull com.fasterxml.jackson.core.Version VERSIONThe version of this application. -
PREFERENCES
-
DOMAIN
-
BASE_URL
The base URL to access the Friedolin server. -
REQUEST_PATH
The path to the Friedolin server's request handler.- See Also:
-
REQUEST_URL
The full URL to access Friedolin's request handler. -
DEFAULT_DEGREE
The default degrees to search for in the grades. -
DEFAULT_ROOT
The default Friedolyn directory where all application data is stored. -
MINIMUM_INTERVAL_MINUTES
public static final int MINIMUM_INTERVAL_MINUTESThe minimum amount of minutes between two grade fetches from the Friedolin server: 1 minutes.- See Also:
-
MINIMUM_INTERVAL
The minimum amount of time between two grade fetches from the Friedolin server: 5 minutes. -
MAXIMUM_INTERVAL_DAYS
public static final int MAXIMUM_INTERVAL_DAYSThe maximum amount of days between two grade fetches from the Friedolin server: 7 days.- See Also:
-
MAXIMUM_INTERVAL
The maximum amount of time between two grade fetches from the Friedolin server: 7 days. -
DEFAULT_INTERVAL_MINUTES
public static final int DEFAULT_INTERVAL_MINUTESThe default amount of hours between two grade fetches from the Friedolin server: 5 minutes.- See Also:
-
DEFAULT_INTERVAL
The default amount of time between two grade fetches from the Friedolin server: SeeDEFAULT_INTERVAL_MINUTES
. -
INTER_WAVE_RETRY_DELAY
Default amount of time to wait before retrying to fetch the grades from the Friedolin server after a failure: 10 seconds. -
RETRY_ATTEMPTS
public static final int RETRY_ATTEMPTSNumber of attempt waves to fetch the grades from the Friedolin server before giving up: 3. (Each wave consists of two attempts with a delay of 5 seconds between each attempt.)- See Also:
-
INTRA_WAVE_DELAY
Default amount of time to wait before retrying to fetch the grades from the Friedolin server after a failure: 5 seconds. -
SYSTEM_INFO_FILE_NAME
The name of the file where thesystem information
should be stored when invokinggetSystemInfoFile()
.- See Also:
-
LOG_FILE_NAME
-
configuration
Various options that modify Friedolyn's behaviour. -
client
TheFriedolinClient
to use for interacting with the Friedolin system. -
USERAGENT_MANAGER
Stores various user agents of Friedolyn and real web browsers. The user agents are intended to be used by theclient
to identify itself to the Friedolin server. -
metadata
Stores information about the application, fetched from the Codeberg repository, most notably theURL to a user poll
and alist of banned users
. -
fetchGradesTask
Fetches the student's grades from the University of Jena's Friedolin system by calling thefetchGrades()
. This task can be scheduled to updateCountdown periodically by calling thestartPeriodicGradesFetch()
. Cancel periodic execution by callingstopPeriodicGradesFetch()
. -
LISTENERS
Subscribers that are interested in thestatus
changes of the periodicgrades fetching
.- See Also:
-
countdown
The time left until the next execution of thefetchGradesTask
. -
LOCK
Facilitates mutual exclusion whenrunning
thefetchGradesTask
. -
fetchCount
private int fetchCountThe total number of allfetches
that have been executed so far, including both successful and unsuccessful ones. -
status
Indicates whether thefetchGradesTask
is currentlyrunning
, paused etc. -
banLevels
-
BAN_LEVEL_LOCK
Facilitates mutual exclusion when updating thebanLevels
.
-
-
Constructor Details
-
Friedolyn
Creates a new Friedolyn object with a deep copy of the given configuration.It is strongly recommended to execute the construction in a separate thread when invoking this constructor from a graphical user interface (GUI), because the construction may take a while, especially if a
HeadlessBrowser
is used as the client.Downloads the
user agents
and thePolledMetadata.download()
metadata if the last download was more than a day ago.Checks for bans
of the currently logged-in user.- Parameters:
configuration
- The configuration to use for this Friedolyn object.- Implementation Note:
- Downloading the
user agents
and themetadata
happens in two separate threads in order to speed up the construction of the Friedolyn object, considering that neither of these resources are immediately required for the application to function properly. Especially with the metadata, multi-threading is viable, because both decrypting thepoll URL
(called bythe download method
) andchecking for bans
is very computationally expensive due to the nature of the cryptographic algorithms employed.
-
-
Method Details
-
getSystemInfo
- Returns:
- A string containing various system information:
- name, version and architecture of the operating system
- version, vendor, home directory, library path and temporary directory of the Java runtime
- home directory of the user
- current working directory
-
getSystemInfoFile
Writes thesystem information
to a file in the system's temporary directory.- Returns:
- A temporary file containing the system information.
- Throws:
IOException
- If the system's temporary directory could not be found or could not be written to.
-
registerListener
Registers a newFriedolyn.FriedolynListener
to the set of objects interested in the status changes of the periodicgrades fetching
.- Parameters:
listener
- The object that will be notified about theFriedolyn
object's status changes.
-
removeListener
Deletes an alreadyregistered
Friedolyn.FriedolynListener
from the set of objects interested in the status changes of the periodicgrades fetching
.- Parameters:
listener
- The object that will no longer be notified about theFriedolyn
object's status changes. Must be the exact same reference that was passed toregisterListener(FriedolynListener)
previously.- Returns:
true
if the listener was removed,false
if the listener could not be found.
-
registerCountdownListener
Adds anotherCountdown.CountdownListener
to the set of objects interested in when the nextgrades fetching run
will be executed.- Parameters:
listener
- The object that will be notified about the countdown's progress.
-
removeCountdownListener
Deletes an alreadyregistered
Countdown.CountdownListener
from the set of objects interested in when the nextgrades fetching run
will be executed.- Parameters:
listener
- The object that will no longer be notified about the countdown's progress. Must be the exact same reference that was passed toregisterCountdownListener(Countdown.CountdownListener)
previously.- Returns:
true
if the listener was removed,false
if the listener could not be found.
-
finish
public void finish()Explicitly frees the resources of theclient
. This method should be called if the currentFriedolyn
object is still needed, but the client is not, because in that scenario, the Java garbage collector would not free theclient
. Notifies allFriedolyn.FriedolynListener
s that theFriedolyn
object has been stopped, by callingFriedolyn.FriedolynListener.onStopped()
on each of them. -
setConfiguration
Updates the currentconfiguration
with the deep copy of a new one (not the actual reference of it, for security reasons).- Parameters:
configuration
- New preferences for the current Friedolyn object.
-
getConfiguration
- Returns:
- A deep copy of the current configuration (not the actual reference of it, for security reasons).
Use
getReferenceToConfiguration()
if you need the actual reference. - See Also:
-
getReferenceToConfiguration
- Returns:
- The actual object reference of the
configuration
field. Only use this method if you are sure that you actually need the reference. If you only need to read the data in it, usegetConfiguration()
instead. - See Also:
-
startPeriodicGradesFetch
Starts fetching the student's grades from the University of Jena's Friedolin system periodically according to theinvalid reference
interval
configuration
. This process will run until thestopPeriodicGradesFetch()
method is called. (Of course, external factors like the computer being shut down or the application being closed will also stop the process.)- Throws:
IllegalStateException
- If thefetchGradesTask
has already been scheduled.- See Also:
-
startPeriodicGradesFetch
private void startPeriodicGradesFetch(@NonNull @NonNull Duration delay) throws IllegalStateException Starts fetching the student's grades from the University of Jena's Friedolin system periodically according to theinvalid reference
interval
configuration
and with a certain delay.- Parameters:
delay
- Amount of time to wait before the first execution of thefetchGradesTask
.- Throws:
IllegalStateException
- If thefetchGradesTask
has already been scheduled.- See Also:
- Implementation Note:
- Since we do not care about the absolute point in time of each execution (we only care about the
relative time between two executions), we can use the
Timer.schedule(TimerTask, long, long)
method instead ofTimer.scheduleAtFixedRate(TimerTask, long, long)
.Sets the
status
toscheduled
but does not notify theLISTENERS
, because this method cannot distinguish betweenstarting
andresuming
.
-
pausePeriodicGradesFetch
public void pausePeriodicGradesFetch()Stops thetask
that fetches the student's grades from the University of Jena's Friedolin system periodically, but does not reset thecountdown
. UseresumePeriodicGradesFetch()
to later continue the periodic fetching at the point where it was paused. -
resumePeriodicGradesFetch
Continues the periodic fetching of the student's grades from the University of Jena's Friedolin system at the point where it was paused previously by calling thepausePeriodicGradesFetch()
method.- Throws:
IllegalStateException
- If thefetchGradesTask
is already scheduled.- Implementation Note:
Notifies
allLISTENERS
that the periodic fetching has been resumed.
-
stopPeriodicGradesFetch
public boolean stopPeriodicGradesFetch()Cancels thetask
that fetches the student's grades from the University of Jena's Friedolin system periodically.- If the task has been scheduled, it will not be executed again.
- If the task is currently running, it will finish its current execution and then stop.
- If the task has not been scheduled yet, nothing will happen.
-
fetchGrades
public boolean fetchGrades()Fetches the student's grades from the University of Jena's Friedolin system (once).- Returns:
true
if the grades were fetched successfully,false
otherwise.- See Also:
-
fetchStudentClearname
@NonNull public @NonNull String fetchStudentClearname() throws org.openqa.selenium.NotFoundException- Returns:
- The student's clear name as indicated in the University of Jena's Friedolin system.
- Throws:
org.openqa.selenium.NotFoundException
- If the student's clear name could not be found.
-
fetchEmailAddress
@NonNull public @NonNull jakarta.mail.internet.InternetAddress fetchEmailAddress() throws org.openqa.selenium.NotFoundExceptionFetches the student's email address from the University of Jena's Friedolin system and updates theconfiguration
accordingly.- Returns:
- The student's email address as indicated in the University of Jena's Friedolin system.
- Throws:
org.openqa.selenium.NotFoundException
- If the student's email address could not be determined.
-