import lotus.domino.*;
import paypal.payflow.*;
import java.io.PrintWriter;
import java.lang.*;
import java.io.*;
public class JavaAgent extends AgentBase {
//-------------THIS IS USED TO REPLACE "\" WITH "/" FOR URL STRINGS-----------
public static String replaceSubString(
String s,
String search,
String replace) {
int p = 0;
while (p < s.length() && (p = s.indexOf(search, p)) >= 0) {
s = s.substring(0, p) + replace +
s.substring(p + search.length(), s.length());
p += replace.length();
}
return s;
}
//----------------------------------------------------------------------------------------------------------
public void NotesMain() {
try {
Session session = getSession();
AgentContext agtc = session.getAgentContext();
Database db = agtc.getCurrentDatabase();
lotus.domino.Document doc = agtc.getDocumentContext();
//HAVE TO EXPLICITLY STATE THE ROOT CLASS FOR THE DOCUMENT TO AVOID CONFLICT WITH PAYPAL DUPLICATE CLASS
//============= START OF SPECIFIC CODE ============
PrintWriter out = getAgentOutput();
// out.println("Content-Type: text/text");
// out.println("szip=zipcode and sweight=weight");
//if everything has been processed successfully, redirect the browser to the review page
String filepath = db.getFilePath();
String thisdbpath = replaceSubString(filepath,"\\", "/");
out.println("[/" + thisdbpath + "/formname?openform]");
//============= END OF SPECIFIC CODE ============
//CLEANUP
doc.recycle();
db.recycle();
agtc.recycle();
session.recycle();
} catch(Exception e) {
e.printStackTrace();
}
}
}