Domino Références : Site francophone de ressources pour les développeurs Lotus Notes / Domino Domino Références
Site francophone de ressources pour les développeurs Notes/Domino
Annuaire Articles Forums Contact
Recherche
 
Mot exact résultats
Au Sommaire ...
Annuaire commenté des sites traitant de Lotus Notes/Domino
Articles d'actualité
Les forums de discussion
Une remarque, une critique, un encouragement. N'hésitez pas à me contacter.
The Team that meets in Forum.
Newsletter
email:   
s'abonner se désabonner 
Statistiques
 Stats du site

 

Broken Links Retrieval: 4 - Adaptation to Domino Web Sites
par Lionel

Part 4 - Adaptation to Domino Web Sites


In this final article, we will browse a Notes database and collect links information from a text field.

1. The context
Each document in our database has a field (called "LinkFull") that contains an URL. Our first objective is to check this URL. Then we want to collect this page's links and to verify them also.

To achieve this objective, we need to browse the database. The file DominoBasic.java contains the code for doing a loop that analyzes every documents in a given view.

We obtained this file by adding the following code to the Checker.java file that we introduced in previous page:

// ********************************************
// JAVA PROGRAM -- Start
// ********************************************


String url;

/* 1 - Initialize */
Database DB = S.getDatabase ("", "tools\\wweasel.nsf");
View V = DB.getView ("alllinks");

Document D = V.getFirstDocument();
Document DelDoc = null;

/* 2 - Loop The View */
while (D != null) {
    //
CODE FOR CHECKING THE URL GOES HERE ...
    url= D.getItemValueString("LinkFull");
    System.out.println (url);
    //
EDN OF CODE FOR CHECKING THE URL
    DelDoc = V.getNextDocument(D);
    D.recycle();
    D = DelDoc;
}
/* end while D != null */

// ********************************************
// JAVA PROGRAM -- End
// ********************************************

This is a typical code for processing documents in a view. You can use it for any type of purpose. In this case, we only retrieve the value from a text field and display it on the default output.

 

2. Adding the verification code
We mixed the codes from the above paragraph and the previous page into a file called CheckerBasic.java.

You can make it more complex by logging information into a text file or into a Notes database.

 

4. Adapting the Program to your environment
To adapt the code, you need first to specify your own Intranet server, proxy information and account information. You do this in the instruction that declares the LCClient.

The other possible adaptation resides in the login procedure. This procedure is tighly dependent on you authentication form; let's have a look at the code. The Login method is located in the class LCClient:

private boolean Login () {

    boolean passed = true;

    WebConversation wc = new WebConversation();
    wc.clearContents();

    ClientProperties cp;
    cp = wc.getClientProperties();
    cp.setUserAgent ("Mozilla/4.0");
    cp.setPlatform ("Windows NT 5.0");
    cp.setApplicationCodeName ("MSIE 6.0");

    WebRequest request = new GetMethodWebRequest (this.Server + "/names.nsf?login");

    try {
        WebResponse httpResponse = wc.getResponse (request);
        WebForm Login = httpResponse.getForms()[0];
        Login.setParameter ("Username", this.UName);
        Login.setParameter ("Password", this.Pwd);
       
 try {
            Login.submit();
            passed = true;
       
 } catch (java.io.IOException e) {
        }
 
   } catch (MalformedURLException e1) {
    } catch (AuthorizationRequiredException e0) {
    } catch (IOException e2) {
    } catch (org.xml.sax.SAXException e3) {
    } catch (RuntimeException e5) {
    }
    return (passed);
}

 

The program opens the page "/names?login" on the server you defined. This is the page that we need for authentication. Then it identifies the login form. It is managed by the WebForm object called Login.

We modify the content of two fields: "Username" and "Password". This is what you have to change if you use different fields. Simply replace the field names with yours.

Then the program submits the authentication form. It returns the boolean variable "passed".


At the end of this article, we learned how to develop our own links checker in Java. The small program we discussed is very simple; but you can extend its features by adding your own code. This is potentially very powerful.

Mise à jour: 18/09/2003
Conception: Lionel, 2001-2002