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.


Variable Index

 o addCourseAccess
 o deleteStudents
 o doCourseInfo
 o father
A reference to the CreateCourseApplet used for displaying messages and getting parameters from the HTML containing the Applet
 o getStudents
 o local
If this is true the Applet will search information on the local harddisk this is used for debuging
 o mkCourse
 o 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).
 o registerStudents
 o removeCourseAccess
 o rmCourse
 o studentVector
A vector which the students are loaded into when calling the getStudents from server.
 o subject
The name of the actual course (course is the same as subject).

Constructor Index

 o CreateCourseDataLoader(Applet, String)
Constructor, sets the course/subject, the father and the local parameter.

Method Index

 o addNewUserAccess(String)
Calls the addCourseAccess script on server to grant access to subject for the user newUser.
 o 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.
 o checkStudentSyntax(String)
Returns the first argument in studData if the studData is correct written.
 o createCourse()
Calls the mkCourse script on server with the name of the course and the user creating it.
 o deleteCourse()
1.
 o getCourseInfo()
Calls the doCourseInfo with mode set to getInfo, to retrieve information about the course, such as creation date and users access.
 o getProxy()
 o getStream(String)
Contacts the server with the URL cgiString.
 o getStudentsII()
Contacts the server and retreives the students registered to the course "subject".
 o getStudentsInfo()
Returns the students loaded into the studentVector.
 o getUsersAccess()
Calls the doCourseInfo with the mode getAccess to get the users with access to subject.
 o postToScript(String, String)
Creates a connection to the server using the POST method.
 o 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.
 o removeThisUserAccess()
Calls the removeCourseAccess script on the server, which removes the users access from subject.
 o sendToScript(String, String)
Connects to a server using the GET method and going through getStream.
 o setProxy(boolean)
 o sortStudentLines(String)
Called by registerStudents.
 o sortVec(Vector, int)
Sorts the string components of vec in the orden of increasing cedula number.
 o updateStudentOnDisk(String, boolean)
Calls either the registerStudents script or the deleteStudents script on server depending on the parameter register.

Variables

 o registerStudents
 private static final String registerStudents
 o getStudents
 private static final String getStudents
 o deleteStudents
 private static final String deleteStudents
 o removeCourseAccess
 private static final String removeCourseAccess
 o doCourseInfo
 private static final String doCourseInfo
 o addCourseAccess
 private static final String addCourseAccess
 o mkCourse
 private static final String mkCourse
 o rmCourse
 private static final String rmCourse
 o subject
 protected String subject
The name of the actual course (course is the same as subject).

 o local
 private boolean local
If this is true the Applet will search information on the local harddisk this is used for debuging

 o 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).

 o studentVector
 private Vector studentVector
A vector which the students are loaded into when calling the getStudents from server.

 o father
 private Applet father
A reference to the CreateCourseApplet used for displaying messages and getting parameters from the HTML containing the Applet

Constructors

 o CreateCourseDataLoader
 public CreateCourseDataLoader(Applet father,
                               String subject)
Constructor, sets the course/subject, the father and the local parameter.

Parameters:
father - the CreateCourseApplet reference.

Methods

 o getStudentsInfo
 public Enumeration getStudentsInfo()
Returns the students loaded into the studentVector.

 o 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.

 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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).
 o 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).
 o 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.
 o 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
 o 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.
 o 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.
 o 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.
 o setProxy
 protected void setProxy(boolean state)
 o getProxy
 protected boolean getProxy()

All Packages  Class Hierarchy  This Package  Previous  Next  Index