Hi,
It started out with me trying to get the example of the google docs example to work in my environment, and now I'm doing a deep dive into the latest features of Java Objects in Oscript. I'm doing this in CS 10.0 U 13, BTW (will duplicate in 10.5 once I have it working here).
I decided to do a very simple example where I fetch a DAPI node and then call its various features and write them back to a Map object. Obviously in the real world, you'd never do this (why complicate your life calling Oscript methods from Java when you can more easily call them from Oscript, but I digress...), but since this was a block of code in the Google Docs example that wasn't working, I wanted to explore why.
Here is the function I'm calling. When it runs, the server hangs when trying to call DAPI.GetNodeByID(). There are no errors returned. I'm able to validate where it's failing by calling the Oscript echo() method from within my java function. Any place I should be checking for errors?
Thanks
-Hugh
public static Map<String, String> getDocInfo(OScriptObject prgCtx, int docId) { boolean ok = true; Map<String, String> result = new HashMap<String, String>(); csLog("getDocInfo() BEGIN"); // this is just a call to echo()...it works try { csLog("Fetching DSession..."); OScriptObject session = (OScriptObject) prgCtx.invokeScript("DSession"); if(session == null || session.isUndefined() || session.isError()) { throw new IOException("Could not access DSession"); } csLog("Fetching fSession..."); ODAPISession fSession = (ODAPISession) session.getFeature("fSession"); if(fSession == null || fSession.isUndefined() || fSession.isError()) { throw new IOException("Could not access DAPISession"); } csLog("Fetching DAPINODE..."); ODAPINode dapiNode = (ODAPINode) OScriptObject.runScript("DAPI.GetNodeById", fSession, docId); if(dapiNode == null || dapiNode.isUndefined() || dapiNode.isError()) { throw new IOException("Could not retrieve node " + docId); } csLog("Have DAPI Node..."); result.put("parentID", dapiNode.pPARENTID().toString()); result.put("volumeID", dapiNode.pVOLUMEID().toString()); result.put("name", dapiNode.pNAME().toString()); csLog("We're done!!"); } catch (Exception e) { System.err.println(e.getMessage()); ok = false; csLog(e.getMessage());result.put(ERROR_MESSAGE_KEY, e.toString()); } finally { result.put("STATUS_KEY", ok ? "true" : "false"); } return result;}