import lotus.domino.*; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); Document doc = agentContext.getDocumentContext(); String agentName = agentContext.getCurrentAgent().getName(); Document cache = agentContext.getCurrentDatabase().getProfileDocument( agentName, agentName ); //get list of modified-dates for relevant documents String dates = (String) session.evaluate( "@Implode(@Text(@DbColumn( '' : 'nocache' ; '' ; '(lupTests)' ; 1 )))" ).get(0); //get body/apply style RichTextItem body = (RichTextItem) doc.getFirstItem( "body" ); RichTextStyle style = session.createRichTextStyle(); style.setPassThruHTML( RichTextStyle.YES ); body.appendStyle( style ); if( cache.getItemValueString( "dates" ).equals(dates) ){ //debug - test that caching works doc.replaceItemValue( "status", "Got content from cache" ); //replace body with body from cache doc.removeItem( "body" ); body = (RichTextItem) cache.getFirstItem( "body" ).copyItemToDocument( doc, "body" ); } else { //debug - test that caching works doc.replaceItemValue( "status", "New content. Recreated html." ); //add html body.appendText( (String) session.evaluate( "@Implode(@DbColumn( '' : 'nocache' ; '' ; '(lupTests)' ; 2 ) ; '
')" ).get(0) ); //cache new HTML if( cache.hasItem( "body" ) ){ cache.removeItem( "body" ); } doc.getFirstItem( "body" ).copyItemToDocument( cache, "body" ); cache.replaceItemValue( "dates", dates ); cache.save( false, false ); } } catch(Exception e) { e.printStackTrace(); } } }