[[BackLinksMenu]] [[TicketQuery(summary=SCRIPTING_ACTIONS_API_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|)]] = Analysis = == Overview == The goal of this task is to expose the Sophie book's model and Sophie's logic in a user-friendly way to the user. Generally, there are two use-cases for scripting, which imply some differences in the requirements: * Scripts used for automation * The result of their execution should be undoable, as each other change to the model * Scripts as link targets * They have limited scope - for example, user cannot create a new book with them * There's no need to be undoable == Task requirements == ^(List the necessary requirements that the task must fulfill.)^ * Security * Some scripts can crash the application. * Some other scripts can allow crackers to execute malicious code. * Solution: Not all Java classes have to be exposed to Sophie scripts. == Task result == * Source code == Implementation idea == * To filter the access to some Java classes: {{{ context.setClassShutter(new ClassShutter() { @Override public boolean visibleToScripts(String fullClassName) { return fullClassName.startsWith("org.mozilla.javascript"); } }); }}} * The following lines add a global variable {{{out}}} that is a JavaScript reflection of the {{{System.out}}} variable: {{{ Object wrappedOut = Context.javaToJS(System.out, scope); ScriptableObject.putProperty(scope, "out", wrappedOut); }}} == Related == ^(Add links to related tasks that could be useful or helpful.)^ == How to demo == ^(Provide instructions for demonstration of the task.)^ = Design = ^(Describe your design here.)^ = Implementation = ^(Describe and link the implementation results here (from the wiki or the repository).)^ = Testing = ^(Place the testing results here.)^ = Comments = ^(Write comments for this or later revisions here.)