Acquire Alfresco Ticket via JavaScript Session in Alfresco 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2015 04:12 PM
We are currently upgrading a client from Alfresco 4.1.1.3 to Alfresco 5.0.0.3. One of the webscripts we are migrating gets the current user's session ticket off of the JavaScript Session object,<a href="https://forums.alfresco.com/comment/80253#comment-80253"> discussed here by jpotts</a>
However, the method
I noticed that the API for the JavaScript Session root object has changed from 4.x. Is it still possible to retrieve the current session's ticket this way? If not, what is the best alternative?
Thank you.
However, the method
session.getTicket()
now fails with the following stacktrace:{ "status" : { "code" : 500, "name" : "Internal Error", "description" : "An error inside the HTTP server which prevented it from fulfilling the request." }, "message" : "02030011 Wrapped Exception (with status template): 02030032 Failed to execute script 'classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js': 02030031 TypeError: Cannot find function getTicket in object org.springframework.extensions.webscripts.AbstractRuntime$RuntimeSession@2d5053a2. (classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js#2)", "exception" : "org.springframework.extensions.webscripts.WebScriptException - 02030011 Wrapped Exception (with status template): 02030032 Failed to execute script 'classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js': 02030031 TypeError: Cannot find function getTicket in object org.springframework.extensions.webscripts.AbstractRuntime$RuntimeSession@2d5053a2. (classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js#2)", "callstack" : [ "" ,"org.mozilla.javascript.EcmaError: TypeError: Cannot find function getTicket in object org.springframework.extensions.webscripts.AbstractRuntime$RuntimeSession@2d5053a2. (classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js#2)" ,"org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3687)" ,"org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3665)" ,"org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3693)" ,"org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3712)" ,"org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3783)" ,"org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2269)" ,"org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2251)" ,"org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:83)" ,"org.mozilla.javascript.gen.classpath__alfresco_extension_templates_webscripts_com_test_getTicket_get_js_34._c_main_1(classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js:2)" ,"org.mozilla.javascript.gen.classpath__alfresco_extension_templates_webscripts_com_test_getTicket_get_js_34.call(classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js)" ,"org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:74)" ,"org.mozilla.javascript.gen.classpath__alfresco_extension_templates_webscripts_com_test_getTicket_get_js_34._c_script_0(classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js:5)" ,"org.mozilla.javascript.gen.classpath__alfresco_extension_templates_webscripts_com_test_getTicket_get_js_34.call(classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js)" ,"org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)" ,"org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)" ,"org.mozilla.javascript.gen.classpath__alfresco_extension_templates_webscripts_com_test_getTicket_get_js_34.call(classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js)" ,"org.mozilla.javascript.gen.classpath__alfresco_extension_templates_webscripts_com_test_getTicket_get_js_34.exec(classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js)" ,"org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:502)" ,"org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:200)" ,"org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:212)" ,"org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:174)" ,"org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)" ,"org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1364)" ,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)" ,"org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:470)" ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:454)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:532)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:600)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:380)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:261)" ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)" ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)" ,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)" ,"javax.servlet.http.HttpServlet.service(HttpServlet.java:727)" ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)" ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)" ,"org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)" ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)" ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)" ,"org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)" ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)" ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)" ,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)" ,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)" ,"org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)" ,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)" ,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)" ,"org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)" ,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)" ,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)" ,"org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)" ,"org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)" ,"org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)" ,"org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)" ,"java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)" ,"java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)" ,"java.lang.Thread.run(Unknown Source)" ,"org.alfresco.error.AlfrescoRuntimeException: 02030031 TypeError: Cannot find function getTicket in object org.springframework.extensions.webscripts.AbstractRuntime$RuntimeSession@2d5053a2. (classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js#2)" ,"org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:526)" ,"org.alfresco.scripts.ScriptException: 02030032 Failed to execute script 'classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js': 02030031 TypeError: Cannot find function getTicket in object org.springframework.extensions.webscripts.AbstractRuntime$RuntimeSession@2d5053a2. (classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js#2)" ,"org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:204)" ,"org.springframework.extensions.webscripts.WebScriptException: 02030011 Wrapped Exception (with status template): 02030032 Failed to execute script 'classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js': 02030031 TypeError: Cannot find function getTicket in object org.springframework.extensions.webscripts.AbstractRuntime$RuntimeSession@2d5053a2. (classpath*:alfresco\/extension\/templates\/webscripts\/com\/test\/getTicket.get.js#2)" ,"org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1126)" ], "server" : "Enterprise v5.0.0 (.3 r92668-b9) schema 8,009", "time" : "Mar 3, 2015 3:03:58 PM"}
I noticed that the API for the JavaScript Session root object has changed from 4.x. Is it still possible to retrieve the current session's ticket this way? If not, what is the best alternative?
Thank you.
Labels:
- Labels:
-
Archive
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2015 05:13 AM
Root level object "session" is changed to "sessionticket"
Try with sessionticket.getTicket()
Hope it helps!
Try with sessionticket.getTicket()
Hope it helps!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2015 12:15 PM
It works! Thank you Niketa!
I just double checked Alfresco's 5.0 documentation page for the <a href="http://docs.alfresco.com/5.0/references/API-JS-rootscoped.html">JavaScipt API Root objects</a> and I don't see sessionticket mentioned anywhere, only session. Why do the only have it listed on the <a href="http://docs.alfresco.com/5.0/references/API-JS-Scripting-API.html">Scripting API page</a> and not the Root Objects page?
I just double checked Alfresco's 5.0 documentation page for the <a href="http://docs.alfresco.com/5.0/references/API-JS-rootscoped.html">JavaScipt API Root objects</a> and I don't see sessionticket mentioned anywhere, only session. Why do the only have it listed on the <a href="http://docs.alfresco.com/5.0/references/API-JS-Scripting-API.html">Scripting API page</a> and not the Root Objects page?
