AnsweredAssumed Answered

Alfresco Share Document List custom javascript failing to execute for non-admin users

Question asked by chandra.shekhar on Apr 3, 2013
Hi,
I am working with share community version 4.0.e hosted on linux. My need is to change the Edit Offline behavior such that the download copy bears the name original-doc-name_version-no.file-extension. The default behavior is that downloaded copy gets the name original-doc-name (Working Copy).file-extension. The share application has a javascript surf-doclist.lib.js that truncates the label (Working Copy) from the browse view in document listing. I modified this file to truncate my version no from the document name in the browse view.

I successfully made the changes by modifying the following files and placing them under web-extension folder as mentioned below:

/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js

/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.lib.js

/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/templates/org/alfresco/import/alfresco-util.js

tomcat/shared/classes/alfresco/extension/custom-services-context.xml (Extended core-services-context.xml config file)

org.alfresco.repo.coci.CheckOutCheckInServiceImpl (Extended this class and placed the implementation jar under /tomcat/webapps/alfresco/WEB-INF/lib)

The desired functionality works perfectly fine when logged in as admin user. But then I create a new user in alfresco and when I log in as that user, the document list itself does not load and throws the below error in catalina.out and also shows a red label with that error, This issue is related to non-admin users not able to execute the scripts from the /tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension folder. If I made changes to directly to the original files under /tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts and /templates then it works for all users:

########################################################################################
2013-04-03 01:10:01,417  ERROR [extensions.webscripts.AbstractRuntime] [http-8050-11] Exception from executeScript - redirecting to status template error: 03030009 Failed to execute script 'classpath*:alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js': 03030008 TypeError: Cannot read property "Write" from undefined (file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js#146)
org.springframework.extensions.webscripts.WebScriptException: 03030009 Failed to execute script 'classpath*:alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js': 03030008 TypeError: Cannot read property "Write" from undefined (file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js#146)
   at org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:200)
   at org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1285)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
   at org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:70)
   at org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:240)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
   at org.springframework.extensions.webscripts.servlet.mvc.WebScriptView.renderMergedOutputModel(WebScriptView.java:104)
   at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
   at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
   at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
   at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
   at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
   at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
   at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
   at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
   at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
   at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
   at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.extensions.webscripts.WebScriptException: 03030008 TypeError: Cannot read property "Write" from undefined (file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js#146)
   at org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScriptImpl(JSScriptProcessor.java:328)
   at org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:192)
   … 39 more
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "Write" from undefined (file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js#146)
   at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
   at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
   at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3356)
   at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3375)
   at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3388)
   at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1324)
   at org.mozilla.javascript.gen.c22._c4(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js:146)
   at org.mozilla.javascript.gen.c22.call(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js)
   at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
   at org.mozilla.javascript.gen.c22._c2(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js:323)
   at org.mozilla.javascript.gen.c22.call(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js)
   at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
   at org.mozilla.javascript.gen.c22._c20(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js:843)
   at org.mozilla.javascript.gen.c22.call(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js)
   at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
   at org.mozilla.javascript.gen.c22._c0(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js:859)
   at org.mozilla.javascript.gen.c22.call(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
   at org.mozilla.javascript.gen.c22.call(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js)
   at org.mozilla.javascript.gen.c22.exec(file:/opt/alfresco-4.0.2/tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js)
   at org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScriptImpl(JSScriptProcessor.java:318)
   … 40 more
########################################################################################

I know it has something to do with permissions but not sure how it can be resolved. This is troubling me for some time so suggestions would be highly appreciated.

Thanks
Chandra

Outcomes