Reputation: 1299
I'm uploading a file using an XPage with the standard file upload control. On the datasource I have a WebQuerySave agent.
WQS-agent is in LotusScript.
The user is uploading an XML file and we've got an existing helper library to help parse the XML being uploaded - that's why the WQS is in LotusScript.
Since I cant detach the uploaded file to the server, I'm calling a Java agent to just read the XML to a string and store that in the document.
I'm calling the Java agent using a param document, all basic stuff.
In the param doc I include the UniversalID of the document that contains the attachment and here's my problem!
The Java agent claims that the UniversalID is invalid:
"HTTP JVM: 4091 Invalid universal id"
But if I try to locate the document in the LotusScript agent, before calling the Java agent the document is found using the same UNID: Set tempDoc = db.Getdocumentbyunid(unid)
The Java code:
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import lotus.domino.Agent;
import lotus.domino.AgentBase;
import lotus.domino.AgentContext;
import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.NotesException;
import lotus.domino.Session;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
Agent agent = agentContext.getCurrentAgent();
// Get document used for passing data
System.out.println(agent.getParameterDocID());
Document paramDoc = db.getDocumentByID(agent.getParameterDocID());
String UniversalID = paramDoc.getItemValueString("unid");
System.out.println(UniversalID);
Document doc = db.getDocumentByUNID(UniversalID);
When I run the Java agent I won't get anything from the print commands, but maybe that's expected...(?)
If I run everything manually on an existing document it works. But not on a document submitted thru the browsers.
To me it feels like the document containing the attachment isn't ready yet to Java.
Domino 8.5.3
Any help very much appreciated!
/J
P.S. I'm a Java newbie, so U know.. ;-)
Upvotes: 0
Views: 1282
Reputation: 1299
The only way I could solve it was to copy all items from the documentContext into a new document I created in the database.
Upvotes: 0
Reputation: 14628
I seem to remember that the context document has a temporary UNID that is changed to its permanent value when you call the save() method. So my best guess is that your LotusScript code is reading the universalId property of the context document before you save it.
So if I'm right, just move your call to get universalId property in the LotusScript agent until after you save the context document, and pass that value into your Java agent.
Upvotes: 1
Reputation: 2932
Remember to save paramDoc
in LotusScript agent before passing it to Java agent.
Upvotes: 0
Reputation: 15739
Are you able to use the Extension Library with the extlibx packages? If so, there's an XML parser already inbuilt, sbt.XmlNavigator. See chapter 13 of XPages Extension Library book. It may be worth looking at to avoid calling a LotusScript agent that calls a Java agent. You can use those packages from Java, but you can also use SSJS. It may be easier to rip the bandaid off and use that (or another Java-based XML parser, I'm sure there are a few). It may be a bit of work now, but will be more useful for the future.
Upvotes: 1