9
9
import java .io .StringWriter ;
10
10
import java .io .Writer ;
11
11
import java .nio .charset .Charset ;
12
+ import java .text .MessageFormat ;
12
13
import java .util .HashMap ;
13
14
import java .util .List ;
14
15
import java .util .Map ;
15
16
16
- import org .alfresco .repo .jscript .RhinoScriptProcessor ;
17
17
import org .alfresco .repo .jscript .ScriptNode ;
18
18
import org .alfresco .repo .jscript .ScriptUtils ;
19
19
import org .alfresco .repo .security .authentication .AuthenticationUtil ;
20
20
import org .alfresco .repo .security .permissions .AccessDeniedException ;
21
21
import org .alfresco .repo .transaction .RetryingTransactionHelper .RetryingTransactionCallback ;
22
- import org .alfresco .scripts .ScriptResourceHelper ;
23
22
import org .alfresco .service .cmr .repository .NodeRef ;
24
23
import org .alfresco .service .transaction .TransactionService ;
25
24
import org .alfresco .util .MD5 ;
26
25
import org .apache .commons .io .IOUtils ;
27
26
import org .apache .commons .lang .StringUtils ;
28
27
import org .apache .commons .logging .Log ;
29
28
import org .apache .commons .logging .LogFactory ;
29
+ import org .springframework .core .io .ClassPathResource ;
30
30
import org .springframework .core .io .Resource ;
31
31
import org .springframework .extensions .webscripts .AbstractWebScript ;
32
32
import org .springframework .extensions .webscripts .Cache ;
@@ -56,15 +56,13 @@ public class ExecuteWebscript extends AbstractWebScript {
56
56
57
57
private TransactionService transactionService ;
58
58
59
- private Resource preRollScriptResource ;
59
+ private ClassPathResource preRollScriptResource ;
60
60
61
61
private String preRollScript = "" ;
62
62
63
- private Resource postRollScriptResource ;
63
+ private ClassPathResource postRollScriptResource ;
64
64
65
65
private String postRollScript = "" ;
66
-
67
- private RhinoScriptProcessor rhinoScriptProcessor ;
68
66
69
67
@ Override
70
68
public void init (Container container , Description description ) {
@@ -89,9 +87,10 @@ public void execute(WebScriptRequest request, WebScriptResponse response) throws
89
87
90
88
JavascriptConsoleRequest jsreq = JavascriptConsoleRequest .readJson (request );
91
89
92
- String script = ScriptResourceHelper .resolveScriptImports (jsreq .script , rhinoScriptProcessor , log );
90
+ final String script = MessageFormat .format ("<import resource=\" classpath:{0}\" >" ,
91
+ this .preRollScriptResource .getPath ()) + jsreq .script ;
93
92
94
- ScriptContent scriptContent = new StringScriptContent (preRollScript + script + "\n " + postRollScript );
93
+ ScriptContent scriptContent = new StringScriptContent (script + "\n " + postRollScript );
95
94
JavascriptConsoleResult result = runScriptWithTransactionAndAuthentication (request , response , jsreq , scriptContent );
96
95
97
96
if (!result .isStatusResponseSent ()) {
@@ -315,17 +314,13 @@ public void setTransactionService(TransactionService transactionService) {
315
314
this .transactionService = transactionService ;
316
315
}
317
316
318
- public void setPostRollScriptResource (Resource postRollScriptResource ) {
317
+ public void setPostRollScriptResource (ClassPathResource postRollScriptResource ) {
319
318
this .postRollScriptResource = postRollScriptResource ;
320
319
}
321
320
322
- public void setPreRollScriptResource (Resource preRollScriptResource ) {
321
+ public void setPreRollScriptResource (ClassPathResource preRollScriptResource ) {
323
322
this .preRollScriptResource = preRollScriptResource ;
324
323
}
325
-
326
- public void setRhinoScriptProcessor (RhinoScriptProcessor rhinoScriptProcessor ) {
327
- this .rhinoScriptProcessor = rhinoScriptProcessor ;
328
- }
329
324
330
325
private static class StringScriptContent implements ScriptContent {
331
326
private final String content ;
0 commit comments