From: <ha...@us...> - 2011-12-22 21:07:38
|
Revision: 16629 http://jmol.svn.sourceforge.net/jmol/?rev=16629&view=rev Author: hansonr Date: 2011-12-22 21:07:32 +0000 (Thu, 22 Dec 2011) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/openscience/jmol/app/jsonkiosk/JsonNioService.java Modified: trunk/Jmol/src/org/openscience/jmol/app/jsonkiosk/JsonNioService.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/jsonkiosk/JsonNioService.java 2011-12-22 19:55:43 UTC (rev 16628) +++ trunk/Jmol/src/org/openscience/jmol/app/jsonkiosk/JsonNioService.java 2011-12-22 21:07:32 UTC (rev 16629) @@ -36,6 +36,7 @@ import org.jmol.util.Logger; import org.jmol.util.TextFormat; +import com.json.JSONArray; import com.json.JSONException; import com.json.JSONObject; import com.json.JSONTokener; @@ -523,20 +524,21 @@ path = "."; JSONObject contentJSON = new JSONObject(new JSONTokener(jsonFile)); - /* - * //Find startup script - String startupScript = null; + String script = null; + if (json.has("scripts")) { JSONArray scripts = contentJSON.getJSONArray("scripts"); - for(int i = 0; i < scripts.length(); i++) { + for(int i = scripts.length(); --i >= 0; ) { JSONObject scriptInfo = scripts.getJSONObject(i); if(scriptInfo.getString("startup").equals("yes")) { - startupScript = scriptInfo.getString("filename"); + script = scriptInfo.getString("filename"); break; } } - - */ - String script = contentJSON.getString("startup_script"); + if (script == null) + throw new JSONException("scripts startup:yes not found"); + } else { + script = contentJSON.getString("startup_script"); + } Logger.info("JsonNiosService startup_script=" + script); setBanner("", false); sendScript("exit"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |