Customize share document list to display custom file name

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2013 08:18 AM
Alfresco Version - 4.0.e Community
I am new to Alfresco development. I want to display custom filename in the share browse view for Working Copies. For example, if the file name is sample.txt, I want to add sample_myname.txt only for Working Copies, i.e the files checked out for offline editing. While exploring customization options, I found that '/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrary/data' has surf-doclist.lib.js which processes the JSON data retrieved from repository.
I modified the function processItem(item) in the surf-doclist.lib.js where it is looking for working copy using below condition -
if (item.workingCopy){}
After making the changes, I created the folder structure 'shared/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data' and placed the following files along with the modified js file
surf-doclist.get.desc.xml (no change)
surf-doclist.get.js (no change)
surf-doclist.get.json.ftl (no change)
surf-doclist.lib.js (modified)
And then refreshed the web scripts. There was no change in the filenames of Working Copies displayed in share. I restarted the server also but no changes.
I get a feel this deployment method is flawed. Can someone guide on how can I correctly deploy these changes or if I am working on wrong set of files?
Thanks
Chandra
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2013 09:02 AM
Have you debugged it?
Just to check:
Take the copy of original surf-doclist.lib.js file.
Modify /tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.lib.js.
Refresh web script and check your custom code runs or not?
Then we'll check the deployment issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2013 01:27 AM
Thanks for your suggestion. I modified the /tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.lib.js and got the desired file name in the documentlist browse view. So, this confirms that surf-doclist.lib.js is the correct file to be extended/modified.
Thanks
Chandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2013 04:48 AM
Now place the modified "surf-doclist.lib.js" file into the extension directory.
Webscripts extension directory :
/tomcat/webapps/share/WEB-INF/classes/alfresco/<strong>web-extension</strong>/site-webscripts/org/alfresco/components/documentlibrary/data/
Revert back the original surf-doclist.lib.js file into /tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrary/data/ directory.
Refresh the webscripts using http://<localhost>:<8080>/share/service/index URL.
Finally check your modified javascript is running or not.
If it not worked, try to restart your tomcat and check.
Kindly keep me posted to help you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2013 08:11 AM
This is the approach I started with earlier but it did not work. I had refreshed the web-scripts, follwed by server restarts, but no results.
Looking into creating extension module, found some article on web. Not sure if that would work but will update the forum on final outcome.
Thanks
Chandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2013 08:31 AM
Are you planning to create AMP module?
For Share webscript extensions , you need to place the extension webscripts into share/WEB-INF/classes/alfresco/web-extension/site-webscripts folder.
For Alfresco webscripts extension, you need to place the extension webscripts into
alfresco/WEB-INF/classes/alfresco/extension/templates/webscripts folder.
I'm also using quite a lot of share extension webscripts, by placing them into web-extension/site-webscripts folder structure.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2013 08:47 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2013 11:51 PM
I attempted something similar to what you suggested - placed the surf-doclist.get.js and surf-doclist.lib.js under "/opt/docu/edm/alfresco-nextgen/tomcat/shared/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data" and the alfresco-util.js along with its .ftl files under /opt/docu/edm/alfresco-nextgen/tomcat/shared/classes/alfresco/web-extension/templates/org/alfresco/import. Upon restarting the server and login into share, I get the following error in catalina.out, in share also I get a red bar above document listing area saying "02200001 Failed to execute script 'classpath*:alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js': null" and it does not list repository content:
Error
*******************************************************************************************
2013-03-20 12:25:17,812 ERROR [extensions.webscripts.AbstractRuntime] [http-8050-11] Exception from executeScript - redirecting to status template error: 02200000 Failed to execute script 'classpath*:alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js': null
org.springframework.extensions.webscripts.WebScriptException: 02200000 Failed to execute script 'classpath*:alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.get.js': null
at org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:200)
at org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1193)
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:239)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:372)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
at org.springframework.extensions.webscripts.servlet.mvc.WebScriptView.renderMergedOutputModel(WebScriptView.java:99)
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:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at org.springframework.extensions.webscripts.processor.JSScriptProcessor.loadScriptResource(JSScriptProcessor.java:222)
at org.springframework.extensions.surf.core.scripts.ScriptResourceHelper.recurseScriptImports(ScriptResourceHelper.java:144)
at org.springframework.extensions.surf.core.scripts.ScriptResourceHelper.resolveScriptImports(ScriptResourceHelper.java:60)
at org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:167)
… 39 more
*******************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2013 01:18 AM
No.
You can create a new folder called web-extension under tomcat\webapps\share\WEB-INF\classes\alfresco\.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2013 08:45 AM
surf-doclist.get.js file is importing surf-doclist.lib.js from the classpath, and it is not referring the extension path.
Importing class path : <import resource="classpath:/alfresco/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.lib.js">
So make the following changes,
In surf-doclist.get.js file, change the importing resource path.
<import resource="classpath:/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.lib.js">
Place <strong>surf-doclist.get.js </strong> into the web-extension path.
C:\Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\web-extension/site-webscripts\org\alfresco\components\documentlibrary\data\surf-doclist.get.js
Place <strong>surf-doclist.lib.js </strong> also in the web-extension path.
C:\Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\web-extension\site-webscripts\org\alfresco\components\documentlibrary\data\surf-doclist.lib.js
<strong>alfresco-util.js </strong>file also referred the surf-doclist.lib.js.
So change "alfresco-util.js" file also and place it in the extension directory.
C:\Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\web-extension\templates\org\alfresco\import\alfresco-util.js
<import resource="classpath:/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/data/surf-doclist.lib.js">
Now, either refresh or restart your server and the share app will pickup the surf-doclist.lib.js from the extension directory.
Hope this helps you.
