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 TypeClassDescriptionclassA callback that is to be called as soon as the currently logged-in user has been identified as banned from using Friedolyn.static enumThe various types of requests that can be sent via thecontact form.classFetches the student's grades from the University of Jena's Friedolin system by calling thefetchGrades().static interfaceSubscribes to status changes of the periodicgrades fetchingon the respectiveFriedolynobject.static classVarious folders in thethat are used to store different kinds of data relevant to the application.invalid reference
Friedolyn directorystatic enumWhether thefetchGradesTaskis currentlyrunningor not and what this means for calling various methods. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull ReentrantLockFacilitates mutual exclusion when updating thebanLevels.The application's features that the user is disallowed from using.static final @NonNull URLThe base URL to access the Friedolin server.private @NonNull FriedolinClientTheFriedolinClientto use for interacting with the Friedolin system.private @NonNull ConfigurationVarious options that modify Friedolyn's behaviour.private @NonNull CountdownThe time left until the next execution of thefetchGradesTask.static final @NonNull KnownDegreeThe default degrees to search for in the grades.static final @NonNull DurationThe default amount of time between two grade fetches from the Friedolin server: SeeDEFAULT_INTERVAL_MINUTES.static final intThe default amount of hours between two grade fetches from the Friedolin server: 5 minutes.static final @NonNull PathThe default Friedolyn directory where all application data is stored.static final @NonNull StringThe hostname of the Friedolin server.private intThe total number of allfetchesthat have been executed so far, including both successful and unsuccessful ones.private @NonNull Friedolyn.FetchGradesTaskFetches the student's grades from the University of Jena's Friedolin system by calling thefetchGrades().static final @NonNull DurationDefault amount of time to wait before retrying to fetch the grades from the Friedolin server after a failure: 10 seconds.static final @NonNull DurationDefault 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 thestatuschanges of the periodicgrades fetching.private final @NonNull ReentrantLockFacilitates mutual exclusion whenrunningthefetchGradesTask.static final StringThe default name of the log file which the Friedolyn application's Log4J logs are written to.static final @NonNull DurationThe maximum amount of time between two grade fetches from the Friedolin server: 7 days.static final intThe maximum amount of days between two grade fetches from the Friedolin server: 7 days.private PolledMetadataStores information about the application, fetched from the Codeberg repository, most notably theURL to a user polland alist of banned users.static final @NonNull DurationThe minimum amount of time between two grade fetches from the Friedolin server: 5 minutes.static final intThe minimum amount of minutes between two grade fetches from the Friedolin server: 1 minutes.static final @NonNull StringThe name of this application.private static final @NonNull Preferencesstatic final @NonNull StringThe path to the Friedolin server's request handler.static final @NonNull URLThe full URL to access Friedolin's request handler.static final intNumber of attempt waves to fetch the grades from the Friedolin server before giving up: 3.private Friedolyn.StatusIndicates whether thefetchGradesTaskis currentlyrunning, paused etc.static final @NonNull StringThe name of the file where thesystem informationshould be stored when invokinggetSystemInfoFile().private final @NonNull UserAgentManagerStores various user agents of Friedolyn and real web browsers.static final @NonNull com.fasterxml.jackson.core.VersionThe 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.InternetAddressFetches the student's email address from the University of Jena's Friedolin system and updates theconfigurationaccordingly.booleanFetches the student's grades from the University of Jena's Friedolin system (once).@NonNull Stringvoidfinish()Explicitly frees the resources of theclient.@NonNull Configuration@NonNull Configurationstatic Stringstatic @NonNull FileWrites thesystem informationto a file in the system's temporary directory.voidvoidAdds anotherCountdown.CountdownListenerto the set of objects interested in when the nextgrades fetching runwill be executed.voidregisterListener(@NonNull Friedolyn.FriedolynListener listener) Registers a newFriedolyn.FriedolynListenerto the set of objects interested in the status changes of the periodicgrades fetching.booleanDeletes an alreadyregisteredCountdown.CountdownListenerfrom the set of objects interested in when the nextgrades fetching runwill be executed.booleanremoveListener(@NonNull Friedolyn.FriedolynListener listener) Deletes an alreadyregisteredFriedolyn.FriedolynListenerfrom the set of objects interested in the status changes of the periodicgrades fetching.voidContinues 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.voidsetConfiguration(@NonNull Configuration configuration) Updates the currentconfigurationwith the deep copy of a new one (not the actual reference of it, for security reasons).voidStarts fetching the student's grades from the University of Jena's Friedolin system periodically according to thespecified in theinvalid reference
intervalconfiguration.private voidstartPeriodicGradesFetch(@NonNull Duration delay) Starts fetching the student's grades from the University of Jena's Friedolin system periodically according to thespecified in theinvalid reference
intervalconfigurationand with a certain delay.booleanCancels thetaskthat 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 informationshould be stored when invokinggetSystemInfoFile().- See Also:
-
LOG_FILE_NAME
-
configuration
Various options that modify Friedolyn's behaviour. -
client
TheFriedolinClientto 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 theclientto identify itself to the Friedolin server. -
metadata
Stores information about the application, fetched from the Codeberg repository, most notably theURL to a user polland 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 thestatuschanges of the periodicgrades fetching.- See Also:
-
countdown
The time left until the next execution of thefetchGradesTask. -
LOCK
Facilitates mutual exclusion whenrunningthefetchGradesTask. -
fetchCount
private int fetchCountThe total number of allfetchesthat have been executed so far, including both successful and unsuccessful ones. -
status
Indicates whether thefetchGradesTaskis 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
HeadlessBrowseris used as the client.Downloads the
user agentsand thePolledMetadata.download()metadata if the last download was more than a day ago.Checks for bansof the currently logged-in user.- Parameters:
configuration- The configuration to use for this Friedolyn object.- Implementation Note:
- Downloading the
user agentsand themetadatahappens 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 bansis 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 informationto 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.FriedolynListenerto the set of objects interested in the status changes of the periodicgrades fetching.- Parameters:
listener- The object that will be notified about theFriedolynobject's status changes.
-
removeListener
Deletes an alreadyregisteredFriedolyn.FriedolynListenerfrom the set of objects interested in the status changes of the periodicgrades fetching.- Parameters:
listener- The object that will no longer be notified about theFriedolynobject's status changes. Must be the exact same reference that was passed toregisterListener(FriedolynListener)previously.- Returns:
trueif the listener was removed,falseif the listener could not be found.
-
registerCountdownListener
Adds anotherCountdown.CountdownListenerto the set of objects interested in when the nextgrades fetching runwill be executed.- Parameters:
listener- The object that will be notified about the countdown's progress.
-
removeCountdownListener
Deletes an alreadyregisteredCountdown.CountdownListenerfrom the set of objects interested in when the nextgrades fetching runwill 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:
trueif the listener was removed,falseif the listener could not be found.
-
finish
public void finish()Explicitly frees the resources of theclient. This method should be called if the currentFriedolynobject is still needed, but the client is not, because in that scenario, the Java garbage collector would not free theclient. Notifies allFriedolyn.FriedolynListeners that theFriedolynobject has been stopped, by callingFriedolyn.FriedolynListener.onStopped()on each of them. -
setConfiguration
Updates the currentconfigurationwith 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
configurationfield. 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 thespecified in theinvalid reference
intervalconfiguration. 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 thefetchGradesTaskhas 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 thespecified in theinvalid reference
intervalconfigurationand with a certain delay.- Parameters:
delay- Amount of time to wait before the first execution of thefetchGradesTask.- Throws:
IllegalStateException- If thefetchGradesTaskhas 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
statustoscheduledbut does not notify theLISTENERS, because this method cannot distinguish betweenstartingandresuming.
-
pausePeriodicGradesFetch
public void pausePeriodicGradesFetch()Stops thetaskthat 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 thefetchGradesTaskis already scheduled.- Implementation Note:
NotifiesallLISTENERSthat the periodic fetching has been resumed.
-
stopPeriodicGradesFetch
public boolean stopPeriodicGradesFetch()Cancels thetaskthat 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:
trueif the grades were fetched successfully,falseotherwise.- 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 theconfigurationaccordingly.- 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.
-