My best albums 2012…

2012 is already far away… but 2 famous albums for this year :

1. Muse – the 2nd law – the guys are growing up and they’re becoming very good 

2. The Killers – Battles born – nice job but not they’re best album

I’m looking for some new fresh rock for 2013…

Greetings

Summer early morning

20120808-054252.jpg

Premier col de l’année

20120616-120524.jpg

Ce matin en route pour le col de la forclaz au dessus de Martigny.

Lotus Traveler and iPhone agenda mark private

One of my manager dislikes the switch from blackberry to iphone because he couldn’t set his calendar entries as private.

Of course you should care about the issues of you VIP.

To manage this, I have done the following :

1. Add a view to his database which display the caldendar entries with a “#” in the subject.

2. Create an agent in a second database which monitor a list of mail databases every 5 minutes.

3. The agent process all the entries in the view and remove then from the view. Each document is mark as private…

The VIP has only to put a “#” in the description of the caldendar entry.

Simple but not perfect, there is a window of 5 minutes in which the document is not private… I haven’t found a better handler to manage it…

I could give you the database if you are interested.

Greetings

Check if a OOO agent is activated on lotus notes databases…

This week I was asked to get all the activated out of office agent. I have activated the ooo agent on the server, so getting the info from the profile is not a solution.

If you launch your administrator client you could see that there is a column which indicates if the ooo is activated. This means that the property is set on the database file attribute.

 

 

Reading the web I found this post :

http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllFlatWeb/37db9f50dc3f5515852576110067fb03?OpenDocument

So you can write this in a simple function :

Public Function isOOO(db as notesdatabase) As Integer
                On Error Goto errorHandler        
                If app.se.NotesBuildVersion < 379 Then
                        Call app.logError(“too old version 8.5x”)
                        Exit Function
                End If
                
                ‘ *** DBOPT_OUTOFOFFICEENABLED passed as a number to compile in R7 client
                If db.GetOption( 74 ) Then
                        isOOO = True
                Else
                        isOOO = False
                End If
                Exit Function
errorHandler:
                Dim sMsg As String
                sMsg =   Typename(Me) + “-” + Error + “-” +Cstr(Err()) & ” at line number ” & Erl() &  ” ” & Lsi_info(12) & ” ” & Lsi_info(2)
                Call app.logErrorExt(sMsg, Nothing)        
End Function

Happy new year 2012

New year, new objectives…

Last year I have migrated my site to a wordpress database. This year a have rebuild my old site with the amazing Bootstrap from twitter (http://twitter.github.com/bootstrap/ ). Why this comeback ?

1. WordPress is time consuming to manage. When you have installed wordpress on your server, it will be time consuming to keep it up to date. This is not my priority to do some sys admin so I just prefer to have static page with a link on my blog on wordpress.com.

2. Less well indexed… it’s seem to me that the whole stuff is less well indexed. We will see this year.

3. Harder to maintain static pages…

4. With bootstrap I can do my site very fast and I get more control on it.

And you what are your experience with wordpress ?

Greetings and happy new year.

xPages or not xPages

Are xPages a leading technologie ?

Obviously not. Of course Lotus has done a big effort to improve the gap between lotus notes and the today’s technologies, but they fail. The web has grown and they have choose the heavy choice of java and dojo.

What do you think ?

Coming next… dynamic class loading in lotusscript.,. stay tune !

Agent to create a backup of you names.nsf weekly

As an administrator, I often need to put me back in time to check something on the domino infrastructure. My Domino Domain is very small so I can afford to make a backup of my names.nsf every week.

This class, creat a copy of each documents of the names.nsf, zip it and attach it to a document… enjoy !


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import lotus.domino.*;
import java.io.*;
import java.util.zip.*;

/* -----------------------------------------------------------------------------------------------------------------------
* Class : JavaAgent
* Date : 12.01.2011
* Author : Pierre Koerber
* Desc. : Permet de faire un backup du PAB et de le zipper.
*/

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {

Session session = getSession();
AgentContext agentContext = session.getAgentContext();

// get the curr db
Database curDb ;
curDb = agentContext.getCurrentDatabase() ;

// (Your code goes here)
Database db ;
db = session.getDatabase(curDb.getServer(), "names.nsf") ;

DateTime timenow = session.createDateTime("Today");
timenow.setNow();

String sName = new String("") ;
String sZipName = new String("") ;
sName = db.getFilePath() ;

System.out.println("OS current temporary directory is " + System.getProperty("java.io.tmpdir"));

sName = System.getProperty("java.io.tmpdir") ;
sName = sName + "names_backup_" + timenow.getDateOnly().replace('.', '_') + ".nsf";

sZipName = System.getProperty("java.io.tmpdir") ;
sZipName = sZipName + "names_backup_" + timenow.getDateOnly().replace('.', '_') + ".zip";

// copy the database
System.out.println("Create a copy of the names.nsf =" + db.getServer() + "-" + db.getFilePath()) ;

this.deleteIfExist(sName) ;
Database newDb ;
newDb = db.createCopy("", sName) ;

// copy all the documents
DocumentCollection dc ;
Document d ;

dc = db.getAllDocuments() ;
d = dc.getFirstDocument() ;

while(d != null){

// No deletion stubs...
if (d.isDeleted() == false){
d.copyToDatabase(newDb) ;
}
d = dc.getNextDocument() ;
}

// Compress the stuff
System.out.println("Compressing file from " + sName + " to " + sZipName) ;

// delete the files if exist
this.deleteIfExist(sZipName) ;

// compress the database
this.doZipExt(sName,sZipName) ;

// create a document and attach the backup
System.out.println("Attach everything to the archive document") ;
Document doc ;
doc = curDb.createDocument() ;

doc.replaceItemValue("backupName", "Sauvegarde names.nsf of " + db.getServer() + " - " + timenow.getDateOnly()) ;
doc.replaceItemValue("Subject", doc.getItemValueString("backupName")) ;
doc.replaceItemValue("backupDate", timenow) ;
doc.replaceItemValue("agentName", agentContext.getCurrentAgent().getName()) ;
doc.replaceItemValue("Form", "backup") ;

lotus.domino.RichTextItem rt = doc.createRichTextItem("Body") ;
rt.embedObject(EmbeddedObject.EMBED_ATTACHMENT,null, sZipName, "archive") ;

// Save the document
doc.save(true, true);

// delete the database
this.deleteIfExist(sName) ;
this.deleteIfExist(sZipName) ;
System.out.println("Done");

} catch(Exception e) {
e.printStackTrace();
}
}

public void deleteIfExist(String sName){
File f = new File(sName) ;
if (f.exists()) {
System.out.println("File : " + sName + " deleted");
f.delete() ;
}

}

public void doZipExt(String sFileName, String sZipFileName) throws IOException{
System.out.println("Creating zip file :" + sZipFileName) ;

File sourceFile = new File(sFileName) ;

// Create our zip file
ZipOutputStream zipfile = new ZipOutputStream(new FileOutputStream(sZipFileName));
FileInputStream filetozip = new FileInputStream(sFileName);
zipfile.putNextEntry(new ZipEntry(sourceFile.getName()));

// Loop through the contents writing it to the zip file output stream.
int len;
byte[] buffer = new byte[1024];

while ((len = filetozip.read(buffer)) > 0) {
zipfile.write(buffer,0,len);
}

// Close the entry and the current file.
zipfile.closeEntry();
filetozip.close();
// When done, close the zip file.
zipfile.close();
}

}

Generating an excelsheet with POI…

It’s very easy for an lotusscript developer to generate an excel sheet with some OLE… but when the code should be run on the server it’s getting bad.

My last entry was about to pass a vector to the java API from lotusscript. Here some background to create the excel sheet with POI.

Of course you should customize this code to fit your solution. If it run on the server with a lot of instances, remember to do some stress tests to avoid some servers issues.

Greetings…

First get – POI Export with poi 3.2

http://www.criverapr.com/2008/10/using-poi-to-export-lotus-notes-data-to.html

Second – ls2j and dynamic array
http://www-10.lotus.com/ldd/nd6forum.nsf/c21908baf7e06eb085256a39006eae9f/45bc5292d67167508525706500525a52?OpenDocument

Dynamic arrays in lotusscript with ls2j

Last week, I was facing a tricky issue. I wanted to use some java to create an excel sheet. The POI java API requires a java vector. I created a dynamic array in lotusscript (to adjust the numbers of rows of my excel sheet) but when I called the POI API I’ve got an ugly error. The trick is to declare a variant, then affect the dynamic array to the variant and pass it to the JAVA API. So easy !

http://www-10.lotus.com/ldd/nd6forum.nsf/c21908baf7e06eb085256a39006eae9f/45bc5292d67167508525706500525a52?OpenDocument