All Packages Class Hierarchy This Package Previous Next Index
Class distans.CreateCourseDataLoader
java.lang.Object
|
+----distans.CreateCourseDataLoader
- public class CreateCourseDataLoader
- extends Object
The CreateCourseDataLoader acts as the interface between the CreateCourseApplet and the scripts on the Server.
-
addCourseAccess
-
-
deleteStudents
-
-
doCourseInfo
-
-
father
- A reference to the CreateCourseApplet used for displaying messages and getting parameters from the HTML containing the Applet
-
getStudents
-
-
local
- If this is true the Applet will search information on the local harddisk this is used for debuging
-
mkCourse
-
-
proxy
- Wheather the user is on a LAN with Java socket restrictions or no (that have to go a proxy that does not permit it).
-
registerStudents
-
-
removeCourseAccess
-
-
rmCourse
-
-
studentVector
- A vector which the students are loaded into when calling the getStudents from server.
-
subject
- The name of the actual course (course is the same as subject).
-
CreateCourseDataLoader(Applet, String)
- Constructor, sets the course/subject, the father and the local parameter.
-
addNewUserAccess(String)
- Calls the addCourseAccess script on server to grant access to subject for the user newUser.
-
appendVariable(String, String, StringBuffer)
- This is used to append a variable name and data on a String that is going to be sent to the CGI script
This is the syntax of cgi strings &variableName=variableData&variableName=variableData etc.
-
checkStudentSyntax(String)
- Returns the first argument in studData if
the studData is correct written.
-
createCourse()
- Calls the mkCourse script on server with the name of the course and the user creating it.
-
deleteCourse()
- 1.
-
getCourseInfo()
- Calls the doCourseInfo with mode set to getInfo, to retrieve information about the course, such as creation date and users access.
-
getProxy()
-
-
getStream(String)
- Contacts the server with the URL cgiString.
-
getStudentsII()
- Contacts the server and retreives the students registered to the course "subject".
-
getStudentsInfo()
- Returns the students loaded into the studentVector.
-
getUsersAccess()
- Calls the doCourseInfo with the mode getAccess to get the users with access to subject.
-
postToScript(String, String)
- Creates a connection to the server using the POST method.
-
registerStudents(String)
- Calls sortStudentLines and uses the response to put it together into the body/URL (depends on proxy) that is sent to the server.
-
removeThisUserAccess()
- Calls the removeCourseAccess script on the server, which removes the users access from subject.
-
sendToScript(String, String)
- Connects to a server using the GET method and going through getStream.
-
setProxy(boolean)
-
-
sortStudentLines(String)
- Called by registerStudents.
-
sortVec(Vector, int)
- Sorts the string components of vec in the orden of increasing cedula number.
-
updateStudentOnDisk(String, boolean)
- Calls either the registerStudents script or the deleteStudents script on server depending on the parameter register.
registerStudents
private static final String registerStudents
getStudents
private static final String getStudents
deleteStudents
private static final String deleteStudents
removeCourseAccess
private static final String removeCourseAccess
doCourseInfo
private static final String doCourseInfo
addCourseAccess
private static final String addCourseAccess
mkCourse
private static final String mkCourse
rmCourse
private static final String rmCourse
subject
protected String subject
- The name of the actual course (course is the same as subject).
local
private boolean local
- If this is true the Applet will search information on the local harddisk this is used for debuging
proxy
private boolean proxy
- Wheather the user is on a LAN with Java socket restrictions or no (that have to go a proxy that does not permit it).
studentVector
private Vector studentVector
- A vector which the students are loaded into when calling the getStudents from server.
father
private Applet father
- A reference to the CreateCourseApplet used for displaying messages and getting parameters from the HTML containing the Applet
CreateCourseDataLoader
public CreateCourseDataLoader(Applet father,
String subject)
- Constructor, sets the course/subject, the father and the local parameter.
- Parameters:
- father - the CreateCourseApplet reference.
getStudentsInfo
public Enumeration getStudentsInfo()
- Returns the students loaded into the studentVector.
getStudentsII
public void getStudentsII()
- Contacts the server and retreives the students registered to the course "subject".
Checks that the data for each student has a correct syntax, and if not, the erorred line is not loaded.
Puts the students loaded into the studentVector.
checkStudentSyntax
public String checkStudentSyntax(String studData) throws NumberFormatException
- Returns the first argument in studData if
the studData is correct written. If not, an empty
String is returned. If the cedula is not a number, then
a NumberFormatException is thrown.
Arguments are either separated with ";"s or with " "s.
- Parameters:
- studData - the student data to be checked.
- Returns:
- the cedula number as a String.
sortStudentLines
private Vector sortStudentLines(String studentLines) throws CreateCourseException
- Called by registerStudents.
Checks the syntax of the studenLines given to it (with the help of checkStudentSyntax).
All the studentLine that are correct in the syntax is then passed to sortVec to be sorted in an orden of increasing cedula number.
- Parameters:
- studentLines - a string with data for students with each students data separated with a new line.
- Returns:
- the answer from sortVec.
sortVec
private Vector sortVec(Vector vec,
int size)
- Sorts the string components of vec in the orden of increasing cedula number.
- Parameters:
- vec - a vector containing unsorted students data.
- Returns:
- a vector with the string components sorted.
registerStudents
protected Vector registerStudents(String studentLines)
- Calls sortStudentLines and uses the response to put it together into the body/URL (depends on proxy) that is sent to the server.
- Parameters:
- studentLines - a string with data for students with each students data separated with a new line.
- Returns:
- the vector with the sorted studentLines.
updateStudentOnDisk
protected boolean updateStudentOnDisk(String student,
boolean register)
- Calls either the registerStudents script or the deleteStudents script on server depending on the parameter register.
- Parameters:
- the - data for the student to update.
- register - is an indicator if the student will be removed or registered.
- Returns:
- either true or false to indicate success/failure of the update.
createCourse
protected boolean createCourse() throws CreateCourseException
- Calls the mkCourse script on server with the name of the course and the user creating it.
The mkCourse script then creates the directories and files that a course contain.
Then calls the addCourseAccess script on server to update the users accesses.
- Returns:
- either true or false to indicate success/failure of creation.
deleteCourse
protected boolean deleteCourse() throws CreateCourseException
- 1. Gets the users with access to the course to be deleted.
2. Calls the rmCourse script on server with the name of the course.
The mkCourse script then deletes the directories and files that a course contain.
3. Calls the removeCourseAccess script on server to remove the access to the
now deleted course from the users which had access to the course before.
- Returns:
- either true or false, indicating success/failure of deletion.
getUsersAccess
private String getUsersAccess() throws CreateCourseException
- Calls the doCourseInfo with the mode getAccess to get the users with access to subject.
- Returns:
- the answer from the script.
addNewUserAccess
protected String addNewUserAccess(String newUser) throws CreateCourseException
- Calls the addCourseAccess script on server to grant access to subject for the user newUser.
- Parameters:
- the - user name of the new access for which to grant access.
- Returns:
- the answer from the script (more or less success or failure).
removeThisUserAccess
protected String removeThisUserAccess() throws CreateCourseException
- Calls the removeCourseAccess script on the server, which removes the users access from subject.
A user can only remove its own access from a course and not any others, if not deleting the course.
- Returns:
- the answer from the script (more or less success or failure).
getCourseInfo
protected String getCourseInfo() throws CreateCourseException
- Calls the doCourseInfo with mode set to getInfo, to retrieve information about the course, such as creation date and users access.
- Returns:
- the answer from the script.
appendVariable
private void appendVariable(String variableName,
String variableData,
StringBuffer appendToThis)
- This is used to append a variable name and data on a String that is going to be sent to the CGI script
This is the syntax of cgi strings &variableName=variableData&variableName=variableData etc. etc.
- Parameters:
- variableName - the name of the variable e.g. subject
- variableData - the data for the variable e.g. TEST
- appendToThis - a StringBuffer with the send string so far
postToScript
private String postToScript(String data,
String scriptName) throws CreateCourseException
- Creates a connection to the server using the POST method.
Contacts the script scriptName with the parameters that are contained in data.
Waits for an answer line either beginning with a "0" or an "1".
- Parameters:
- data - contains the parameters that the contacted script takes as in arguments.
- scriptName - URL to the script to contact.
- Returns:
- the lines read from the connection until a "0" or an "1" occured.
sendToScript
private String sendToScript(String data,
String scriptName) throws CreateCourseException
- Connects to a server using the GET method and going through getStream.
Uses the DataInputStream passed from getStream to read the answer lines that is returned from the connection.
- Parameters:
- data - contains the parameters that the contacted script takes as in arguments.
- scriptName - URL to the script to contact.
- Returns:
- the lines read from the connection until a "0" or an "1" occured.
getStream
private DataInputStream getStream(String cgiString) throws IOException
- Contacts the server with the URL cgiString. Uses the GET method.
- Parameters:
- cgiString - the URL to contact.
- Returns:
- a DataInputStream that can be used to read the answer returned from the URL contacted.
setProxy
protected void setProxy(boolean state)
getProxy
protected boolean getProxy()
All Packages Class Hierarchy This Package Previous Next Index