2
2
2
Directory
YES
select the
Client Side?
Directory Name
NO
select the
Directory Name
YES
If the
selected
name is
YES
If the NO
selected Directory will be
deleted
name is
The File may
not be Deleted
NO
Return
RNM
RENAME File
Is It the file ?
NO
YES
Is It the file ?
Enter the New Cannot be
name for File renamed
YES
Cannot be
Enter the New renamed The selected file
name for File was renamed
DELETE File
Chose the
side where u
want to delete
file
Client Side ?
NO
NO
If it is File If it is File ?
?
YES
YES Deletion Failed
Deletion Failed
Selecte
Selecte d file
d file will be
will be
Return
DWN
UP
Retur
n
4.5.3 E-cabinet Module
START
NO
Existing
User? SIGN UP
YES
LOGIN
NO
YES
E-cab
E-cab
E-Cabinet Handler
NO
YES
REQUEST TO
Server With Enter The
Filename Enter the File To
Valid Delete
rename
No
NO
If the File
Exsists YES
File DELETE
Yes Present File
Contents Of The
File Will be
Displayed
5.IMPLEMENTATION
5.1 PSEUDO CODE OF MODULES
5.1.1 Communication With WEB Server
HISTORY CLASS:
Introduction:
This module provides the basis for most of the other sub-modules
like PREVIOUS, NEXT. Basically this module is used to keep track of the URL
pages visited. Similar to Internet Explorer here also we can keep history settings
as our requirement.
Design:
Before going to actual design we need to know some information
regarding System Properties. Some of these which are used in our Project are as
Follows
System.getProperty("user.home")
This will return the directory under which the current Operating
System on which the software is being run. For example if user is currently is
working under "Windows Operating System" and “OS” was loaded in drive D,
then this function will return "D:"
Ex: D:\Windows
In Order to retrieve the offline pages efficiently they are temporarily
stored in an user defined directory. For this Module we have created an
user defined file "UCOfflineDir" to serve as a temporary storage
System.getProperty ("file.separator")
This function will return the character that is used as a file separator.
By default in “Windows Operating System” the file separator is “\”. This
represents an Hierarchical way representation for the files stored in the system.
This property is used in “History Module” to create the temporary files needed to
store the visited “Offline Pages”
The user defined functions that are required for designing HISTORY
class are described below
Then the current file is being downloaded into the offline page
whose path is already set. Here for downloading this function will call a
Download function
which uses the URL class along with BufferedInputStream for reading and
FileOutputStream for writing.
con = myURL.openConnection();
This function will also map files to respective URL by calling a function
which uses FileWriter class as shown below
public DefaultMutableTreeNode
addChildNodesFor(DefaultMutableTreeNode parent)
This function will add the Childs to their parent in a hierarchical
fashion, which is being called for obtaining a tree like hierarchical structure.
TREEVIEWOFFLINE CLASS:
INTRODUCTION:
This class is basically responsible for obtaining tree like structure of
the history that is being maintained. This will assume "HISTORY" as the root
directory and then adds child nodes to it hierarchically.
DESIGN:
Public
TreeViewOfflineFiles(Historyhistory, DefaultMutableTreeNode
root,DefaultTreeModel treeModel)
This function will declare a tree and made it follow a default tree model as
Tree = new JTree (treeModel);
public DefaultMutableTreeNode getOfflineFiles() throws
Exception
This function will declare the root node as
DefaultMutableTreeNode rootNode = new
DefaultMutableTreeNode("History");
Then this will retreive the offline pages and adds them as childs
to their respective parents as shown below
DefaultMutableTreeNode child = new DefaultMutableTreeNode (v.elementAt(i));
child = history.addChildNodesFor(child);
rootNode.add(child);
CODEVIEWER CLASS:
Introduction:
This class is basically designed using SWING, IO,
AWT, and NET packages in JAVA. Its purpose is to provide the user the
source code of the html file he is currently viewing.
Design:
The codeviewer is an internal frame developed using
the JInternalFrame class.a desktop pane is used as a container to all the
objects in the codeviewer frame. An editor pane is used to display the
source code of the html file and a scroll pane is used to provide the scroll
bars needed for the editor pane.
JInternalFrame codeView;
JEditorPane codePane;
JScrollPane scrollCode;
codePane = new JEditorPane();
scrollCode = new JScrollPane(codePane);
codeView = new JInternalFrame("Code Viewer",false,true,true,true);
To provide the link between the client and the html
file the URL class and URLConnection class present in the net package are
used. URL class creates an object for the URL address specified in the
address bar. URLConnection provides a stream for reading from and
writing to the URL.
URL myURL;
URLConnection con;
A buffered input stream is created for reading the
contents of the html file specified in the address bar.
bis = new BufferedInputStream(con.getInputStream( ));
JInternalFrame mail;
JScrollPane consolePane;
JDesktopPane parent;
BufferedReader in = newBufferedReader
(newInputStreamReader (sendSocket.getInputStream ()));
Upon clicking the CANCEL the internal frame should be closed and
disabling the desktop pane visibility does this.
mail.setVisible(false);
1. Here's a representative sample of what you see when you call printDialog:
2.Rendering Graphics on the Printer
however, you only have a single page. So you return PAGE_EXISTS for
index 0, NO_SUCH_PAGE otherwise.
The second step is to start drawing. In general, you can do any sort of
drawing you want. In the specific case of printing Swing components,
however, your drawing should just be a high-resolution version of what the
component looks like on the screen. So you cast the Graphics object to
Graphics2D, scale the resolution to the printer, and call the component's
paint method with this scaled Graphics2D.
Graphics2D graphics2D;
graphics2D = (Graphics2D) graphics;
graphics2D.translate(graphics2D.getClipBounds().getX(),
graphics2D.getClipBounds().getY());
if (printView(graphics2D,allocation,rootView))
{
return Printable.PAGE_EXISTS;
}
else
{
pageStartY = 0;
pageEndY = 0;
currentPage = -1;
return Printable.NO_SUCH_PAGE;
}
}
HTTPHandler Class :
This class is the main class that is responsible for all the under
going operation in this “Browser”. All the classes that are mentioned above are
imported in this class. Also all the preceding classes communicate with this class.
This class is also responsible for handling of many events’ that are occurred with
the HTTPHandler.Any command the user will give must be first recognized by
this class. Then using the sub modules like “HISTORY”,”PRINT”,”MAIL
HANDLER” it will execute the requested command. For example if the user want
to see the “Previous Page” then this module will retrieve the required page from
“HISTORY” module
Connection-Establishment:
For example:
myConnect.setHostName (txtHostName.getText())
myConnect.setPortNum(Integer.parseInt(txtPortNum.getText()))
myConnect.setUserName(txtUserID.getText())
myConnect.setPathName(txtPathName.getText())
myConnect.setPassWord(new String(txtPassword.getPassword()))
The user identification is that does require the server for access to its file
system. This command will normally be the first command transmitted by the
user after the control connections are made (some servers may require this).
Additional identification information in the form of a password and/or an
account command may also be required by some servers. Servers may allow
a new USER command to be entered at any point in order to change the
access control and/or accounting information. This has the effect of flushing
any user, password, and account information already supplied and beginning
the login sequence again. All transfer parameters are unchanged and any file
transfer in progress is completed under the old access control parameters
PASS - password.
Now we can easily connect to the FTP server using the method provided for
“Ftp” instance called “connect” ,as follows
ftp.connect(myConnect)
this method will return Boolean value “true” if the connection was
successfully made otherwise it returns “false”
Disconnection:
ftp.disconnect();
this function will disconnect the server and closes the
control connections
Returns:
Current working directory.
Once we have connected to the FTP server we can get the list of files
present in the current working directory on the right side table of the FTP
internal frame. Now we can make the operations on either Local / Server side.
The side on which we wish to perform the operation is specified by selecting
the file tables present on each side
Making Directory:
Ex: myFtp.mkdir(dirName)
This command causes the directory specified in the pathname to be
created as a directory (if the pathname is absolute) or as a subdirectory of
the current working directory (if the pathname is relative).
This function will return “true” if the operation was success otherwise it
returns “false”. The case in which the “mkdir()” will return false is
In either case the directory creation was failed and simple message box
will be displayed indicating the reason for the failure of creation.
Deleting Directory:
Similar to above case we can also make it possible to delete directory both
at server side and at client side. To delete file at the client side we first create an
instance of “File” with the specified file name. Then we call the “delete()” method
with the corresponding file object
command the “delete” function will return a Boolean “false” When the specified
directory was deleted the entire files present in the directory was deleted.
ftp.rmdir(java.lang.String directory)
Parameters:
directory - Name of directory to be removed.
Returns:
True on success.
Deleting File:
It can also possible to delete a single file. This can be made both at the
Client side and at the Server side. For Client side the normal method that was
used to delete a directory can also be used to delete a single file.
Ex: myFile.delete() where “myFile” is object associated with the
file to be deleted
DELE - delete.
Parameters:
filename - Name of file to be deleted.
Returns:
True on success.
If the requested file was removed “true” will be return otherwise “false” will be
return
Renaming a File:
To rename at the Server side we can simply use the method called “mv”
provided in the Ftp calss.
Ex: myFtp.mv(oldfilename,newfilename)
Parameters:
oldfilename - Old name of file.
newfilename - New name of file.
This method will return the Boolean value “true” if the respective
file is successfully renamed otherwise it returns “false”.
Uploading is the process of loading the desired client file into the server
address space. To write the data into the associated FTP server we need to get
an object which refers the Outputstream. To open the Outputstream object we
need to instantiate an “FtpOutputStream” object as follows
The above statement opens the file for writing in the Server side. Once the file
object stream is obtained we need opened the file to be written in Inputstream
mode for reading the contents of the file.
in = new FileInputStream(file.getAbsolutePath());
out = new FtpOutputStream(newFtpFile(dir,file.getName(),myFtp))
Herer uSpeed specifies the speed with which the data is to be transferred
out.write(b,0,bytes)}
Downloading is the process of loading the file from the FTP server. In
order to perform the downloading operation we used the InputStream class
associated for the Ftp server, called as FtpInputStream.
Ex:FtpInputStream(FtpFile file)
This method will opens the retrieve inputstream for the FtpFile .
Once the InputStream file was opened we need to write the data into the desired
output file. To write the data we need to open the open the file in using
Outputstream. To write the data we need first to store it in temporary buffer, later
the contents of the buffer are written into the desired file.
FileOutputStream out=null;
in = new FtpInputStream(ftpFile);
FtpFile ftpFile;
out.write (b,0,bytes)}
The main problem is how to communicate between the client and the
server. This has been achieved in the software using a unique data
structure known as the ‘Vector’. The Vector is analogous to the array except
that it can have elements of various data types. This is of course exactly
what we need, because our information between the server and client
consist of many types of fields.
A flag which will tell the server what action has been requested by the
client. One or more fields specific to the operation desired to be performed
by the user.As the server has to be always in a state of alert as to listen to
information sent from the client, an inputstream as well as an output stream
is associated with the Server socket. The server sets up a connection with
the socket of the client machine at the local port of the client machine. Thus,
a two way information channel is set up between the server and the
instance of the client thread.
As mentioned above, the client sends requests regarding actions to be
performed using flags. These flags are essentially strings. The flags used in
this software are mentioned below
Adduser – This flag is sent by a client whenever there is a new user who wants
to sign up to the service and thereby creates his own login on the server. This is
sent as the 3rd element of a Vector of size 3. In addition the Vector contains the
user’s chosen login name as well as his password.
Defile – This flag is sent by a client whenever the user wants to delete a file from
the login. This is sent as the 3rd element of a vector of size 3. The Vector also
contains the user’s loginname as well as the filename that has to be deleted.
Getlist – This flag is used to inform the server to send all the filenames of the
files present in a use’s login. In case the login is empty a message must be
displayed which says that the login is currently empty. The flag is the 3rd element
of the Vector which also contains the loginname as well as the password of the
user.
Renamefile – This flag is sent by the client instance whenever the user wants to
rename a file in his login to a new name. Here the flag is the 4th field in the vector
and also contains the login, the name of the file, and the new name of the file.
Savefile – This flag is sent by the client whenever the user wants to store a file
on her machine onto her login. This involves transport of the file object across the
network using a vector. The flag is the 3rd element of the vector of size 4, also
containing the loginname, source file object and the target file object.
• Signing up
The client sends the login password and the flag ‘adduser’. The server
then searches the local directory c:\Database and checks whether the
directory already exists. If it does not exist the server returns a value 1 and
a message is displayed at the client that the required directory has been
created. In case the value 0 is returned the client is asked to give a new
login name.
• Signing in
The client sends the login and the password to the server for verification. If there
does exist such a combination then the confirmation is sent back to the client
and the buttons ‘Read File’ and ‘Save File’ are activated.
• Read File
The client sends the login, password and the flag ‘getlist’. When the server
receives this from the client it checks for the directory, matches the password and
gets all the filenames in the directory and sends them in a vector back to the
client. This list is then displayed in a frame as the list of files in the login. Three
buttons are provided to ask the user what he intends to do Delete, Rename or
Open a file.
• Open file
The client sends the login, file wanted and the flag ‘fileget’. When the server
receives this, it searches for the file in the login and sends the contents of
the file as a string to the client. The client then displays the file in a frame.
• Rename File
The client sends the login, file to be renamed, new file name and the flag
‘renamefile’. When the server receives this, it enters the directory c:\database\
loginname_login and renames the file. If it could be done the integer 1 is returned
to the client and the appropriate message flashed at the client. If the renaming
was unsuccessful, 0 is returned and the message is flashed that renaming could
not be done
• Delete File
The client sends the login, file to be deleted, and the flag ‘delfile’. When the
server receives this, it enters the directory c:\database\ loginname_login and
deletes the file. If it could be done the integer 1 is returned to the client and
the appropriate message flashed at the client. If the renaming was
unsuccessful, 0 is returned and the message is flashed that deletion could
not be performed.
• Save File
The client opens a FileDialog box and the user is prompted to select a file to be
saved from the client hard disc onto the login. The client sends the File object,
login, flag ‘savefile’, and the new name of the file. The object is then stored in the
login directory.
Function of The Client
The Client is essentially an applet so that it can be easily
downloaded on the Internet. The main focus in designing the client is on the
Graphical User Interface. When the Client is first initialized, the control passes to
init(). The init function sets the size of the applet, background color, font color,
layout pattern as well as the Buttons used throughout the applet. ActionListener
() and WindowAdapter () are used extensively so that the applet is sensitive to
mouse movements and actions.
accessed. The methods written in the client are given below with a brief
description about each function.
int getVerified(Object)
This Function sends the login and the password for verification to the server
and returns a value 1 if the login exists and 0 if it does not.
Vector sendReqForList(Vector)
This function sends the request to the server to send the list of files present in
one’s login. The function returns a vector which contains the list of filenames.
String sendFileName(Object)
This function sends the request to the server to send the file while the file name
is typecast to Object and passed as a parameter. The function returns a string
from the server which is the contents of the file. This is valid only for text files.
int sendNewUserInfo(Object)
This function is used to send information regarding a user who wants to sign up
and create a new account. The function returns an integer 0 or 1 which tells if the
creation of a new account was a success or not.
int saveSentFile(Object)
This function asks the server to save the file from the client hard disk onto the
login in the server hard disk. The function takes file object to be saved as an
argument and returns 0 or 1 depending on success of the operation.
int sendFileForDeletion(Object)
This function is used to ask the server to delete the file in userspace. The
filename is sent as the object argument. This too returns 1 or 0 as an argument
depending on success of deletion.
int sendFileForRenaming(Object)
This function is used to ask the server to rename the file in userspace. The
filename is sent as the object argument. This too returns 1 or 0 as an argument
depending on success of renaming.
void sendToServer(Object)
This function is used to send a message to the server that the applet has been
destroyed and that all open streams be closed and sockets closed.
6.SYSTEM TESTING
Testing
1. Unit testing:
Unit testing begins at the vertex of the spiral and concentrates
on each unit of the software as implemented in source code. Initially test
focus on each module individually, assuring that it functions properly as a
unit. Hence the name Unit Testing. Unit testing makes heavy use of white
box testing techniques, exercising specific paths in a module’s control
structure complete coverage and maximum error detection. Unit testing
focuses on verification effort of the smallest unit of software design
module. Using the procedural design description as a guide important
control paths are tested to uncover the errors within the boundary of the
module. The relative complexity of the tests and uncovered errors are
limited by the constrained scope established for unit testing.
2. Integration Testing:
Integration testing is a systematic technique for constructing
the program structure while conducting tests to uncover errors associated
with interfacing. The objective is to take unit tested modules and build a
program structure that has been dictated by design. There is often
tendency to attempt non-incremental integration, that is, to construct the
program using “big bang” approach. All modules are combined in advance.
The entire program is tested as a whole. A sets of errors are encountered.
Correction is difficult because isolation of causes is complicated by the
vast expanse of the entire program.
3. System Testing:
System testing is actually a series of different tests whose primary
purpose is to fully exercise the computer-based system. Although each test has a
different purpose, all work to verify that all system elements have been properly
integrated and perform allocated functions.
Test Cases:
Test case – I:
In HTTP module suppose if u give an invalid URL in the URL address then
we may get an error message indicating that the specified URL is not an valid
one. Similarly if the system is not connected to internet or if net is currently
disconnected then , similar to “Internet Explorer” we may get an Unknown Host
Exception.
Test Case ii:
Similarly suppose if u attempt to send a mail from Source address to
Destination address without connected to Internet U may failed to deliver the
message.
Test Case iii:
The Browser needs the user to specify the server name he wants to
Communicate. For example supposes if the user want to connects to a WEB
server he needs to specify the HTTP protocol . Otherwise we may get a
MalformedURLException
Test Case iv:
Main screen opened when the user runs the Universal Browser. By default it is the
HTTP Handler that processes the requests for web pages.
Screen opened when the user want to view the History
2.when the user want to specify the URL address he must also use the
protocol that the URL need. It means that when ever the user wants to open any web
site he have to give the protocol “http” preceding the URL address in the address bar
of the browser.
11. REFERENCES
This project is developed by
referring to most of the books that cover the SWING ,NET,UTIL,IO packages
extensively.. Some of those books that might help the users of this software are
listed below.
BOOKS
• SUN.COM/JAVATUTORIAL
• JSCAPE.COM
• RFC.COM
• SECUREFTP.COM