{"id":16866,"date":"2021-11-25T18:38:28","date_gmt":"2021-11-25T17:38:28","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/"},"modified":"2021-11-25T18:38:28","modified_gmt":"2021-11-25T17:38:28","slug":"alfresco-custom-share-action-not-working-after-disabling-webdav-servlet","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/","title":{"rendered":"Alfresco &#8211; Custom Share action not working after disabling WebDAV servlet"},"content":{"rendered":"<p>On an Alfresco upgrade project I was working on recently, I faced an interesting issue where post upgrade, one of my custom Share action wasn&#8217;t working anymore. This action was used to create folder links for use on an external interface. When applied on a document, it would create a link to the parent folder for example and when applied on a folder, it would link to itself. Generated link could then be used from outside of Alfresco.<\/p>\n<p>I created this custom action when I started working with Alfresco almost 10 years ago and I didn&#8217;t touch the source code since then, it always worked. Therefore, I was a little bit surprised when the action didn&#8217;t work anymore (the link would always redirect to the root of the Repository [\/Company Home]) after the latest upgrade. The action is a simple JavaScript piece of code deployed as an AMP on the Share war file:<\/p>\n<pre class=\"brush: javascript; gutter: true; first-line: 1\">$ cat $ALF_HOME\/tomcat\/webapps\/share\/components\/documentlibrary\/folderlink.js\n(function() {\n  YAHOO.Bubbling.fire(\"registerAction\", {\n    actionName: \"onActionFolderLink\",\n    fn: function dbiservices_onActionFolderLink(record) {\n      var viewID = record.actionGroupId;\n      var path = record.webdavUrl.replace('\/webdav', '');\n      ...<\/pre>\n<p>&nbsp;<\/p>\n<p>On this code, the &#8220;<strong>viewID<\/strong>&#8221; is used to know on which page and on which element is this action triggered. Possible values can be &#8220;<strong>folder-browse<\/strong>&#8221; (applied on a folder when you browse the repository), &#8220;<strong>document-browse<\/strong>&#8221; (applied on a document when you browse the repository) or &#8220;<strong>document-details<\/strong>&#8221; (applied on a document when viewing the details\/preview of this document) for example. The second JavaScript variable &#8220;<strong>path<\/strong>&#8221; is supposed to be the path of the Alfresco Node. I used this &#8220;<strong>webdavUrl<\/strong>&#8221; when I created this method because I found that to be a simple way to retrieve the path, since you can use &#8220;<strong>record.displayName<\/strong>&#8221; to retrieve the name of the Node but you cannot use &#8220;<strong>record.displayPath<\/strong>&#8221; to retrieve its path (look at the end of this post for alternatives).<\/p>\n<p>When trying to debug the issue, I used the JavaScript Console on the Share UI but my piece of code was working and giving me the correct outcome (using &#8220;<strong>document<\/strong>&#8221; instead of &#8220;<strong>record<\/strong>&#8220;). While looking further into the code, the issue was really that &#8220;<strong>record.webdavUrl<\/strong>&#8221; didn&#8217;t return anything when executed as part of the custom action while it was working properly on the JavaScript Console.<\/p>\n<p>I couldn&#8217;t find anything on Alfresco side that would explain a different behavior between the two versions of Alfresco so I looked into the configuration instead (alfresco-global.properties) and saw that on the new server, the WebDAV was disabled. This was most probably done as part of a best practice, to disable whatever isn&#8217;t used. So, I tried to re-enable the WebDAV:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1; highlight: [2,3,4]\">$ grep webdav $ALF_HOME\/tomcat\/shared\/classes\/alfresco-global.properties\nwebdav.enabled=true\nsystem.webdav.servlet.enabled=true\nsystem.webdav.activities.enabled=true\nsystem.webdav.rootPath=${protocols.rootPath}<\/pre>\n<p>&nbsp;<\/p>\n<p>After a restart of Alfresco, the action suddenly worked without any problem. To do some more testing, I tried to enable only the &#8220;<strong>webdav.enabled=true<\/strong>&#8221; parameter but it stopped working again. So my next test was to enable only the servlet instead (&#8220;<strong>system.webdav.servlet.enabled=true<\/strong>&#8220;) and that was indeed sufficient.<\/p>\n<p>Therefore, if you are using &#8220;<strong>webdavUrl<\/strong>&#8221; in any of your JavaScript code, make sure that you enable at least the servlet as follow:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1; highlight: [3]\">$ grep webdav $ALF_HOME\/tomcat\/shared\/classes\/alfresco-global.properties\nwebdav.enabled=false\nsystem.webdav.servlet.enabled=true\nsystem.webdav.activities.enabled=false\nsystem.webdav.rootPath=${protocols.rootPath}<\/pre>\n<p>&nbsp;<\/p>\n<p>There are other ways to retrieve the path of the working node on JavaScript inside a custom action so instead of enabling the WebDAV servlet, it is also possible (and probably better) to use another alternative. Here are the 4 different ways I know of, with an example value returned when executed on a Document:<\/p>\n<ul>\n<li>record.webdavUrl -&gt; &#8216;\/webdav\/dbi%20services\/A%20Folder\/My%20Document.docx&#8217;<\/li>\n<li>record.location.path -&gt; &#8216;\/dbi services\/A Folder&#8217;<\/li>\n<li>record.location.repoPath -&gt; &#8216;\/dbi services\/A Folder&#8217;<\/li>\n<li>this.currentPath -&gt; &#8216;\/dbi services\/A Folder&#8217;<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>As you can see, the values are rather similar, except for the node name (which can be retrieve with &#8220;<strong>record.displayName<\/strong>&#8220;) which is only present for the &#8220;<strong>webdavUrl<\/strong>&#8221; one. All the three other alternatives display the path up to the parent only. Therefore, if applied to a folder or document, you might also need the node name to be concatenated. In conclusion, if you do specifically need the &#8220;<strong>webdavUrl<\/strong>&#8220;, make sure that the &#8220;<strong>system.webdav.servlet.enabled<\/strong>&#8221; is set to true otherwise it won&#8217;t work.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On an Alfresco upgrade project I was working on recently, I faced an interesting issue where post upgrade, one of my custom Share action wasn&#8217;t working anymore. This action was used to create folder links for use on an external interface. When applied on a document, it would create a link to the parent folder [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197,525],"tags":[3169,1170,1233,2422],"type_dbi":[],"class_list":["post-16866","post","type-post","status-publish","format-standard","hentry","category-application-integration-middleware","category-enterprise-content-management","tag-alfresco","tag-share","tag-webdav","tag-webdavurl"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Alfresco - Custom Share action not working after disabling WebDAV servlet - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Alfresco - Custom Share action not working after disabling WebDAV servlet\" \/>\n<meta property=\"og:description\" content=\"On an Alfresco upgrade project I was working on recently, I faced an interesting issue where post upgrade, one of my custom Share action wasn&#8217;t working anymore. This action was used to create folder links for use on an external interface. When applied on a document, it would create a link to the parent folder [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-25T17:38:28+00:00\" \/>\n<meta name=\"author\" content=\"Morgan Patou\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@MorganPatou\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Morgan Patou\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/\"},\"author\":{\"name\":\"Morgan Patou\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c4d05b25843a9bc2ab20415dae6bd2d8\"},\"headline\":\"Alfresco &#8211; Custom Share action not working after disabling WebDAV servlet\",\"datePublished\":\"2021-11-25T17:38:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/\"},\"wordCount\":685,\"commentCount\":0,\"keywords\":[\"Alfresco\",\"Share\",\"WebDAV\",\"webdavUrl\"],\"articleSection\":[\"Application integration &amp; Middleware\",\"Enterprise content management\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/\",\"name\":\"Alfresco - Custom Share action not working after disabling WebDAV servlet - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2021-11-25T17:38:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c4d05b25843a9bc2ab20415dae6bd2d8\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Alfresco &#8211; Custom Share action not working after disabling WebDAV servlet\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c4d05b25843a9bc2ab20415dae6bd2d8\",\"name\":\"Morgan Patou\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/5d7f5bec8b597db68a09107a6f5309e3870d6296ef94fb10ead4b09454ca67e5?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5d7f5bec8b597db68a09107a6f5309e3870d6296ef94fb10ead4b09454ca67e5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5d7f5bec8b597db68a09107a6f5309e3870d6296ef94fb10ead4b09454ca67e5?s=96&d=mm&r=g\",\"caption\":\"Morgan Patou\"},\"description\":\"Morgan Patou has over 12 years of experience in Enterprise Content Management (ECM) systems, with a strong focus in recent years on platforms such as Alfresco, Documentum, and M-Files. He specializes in the architecture, setup, customization, and maintenance of ECM infrastructures in complex &amp; critical environments. Morgan is well-versed in both engineering and operations aspects, including high availability design, system integration, and lifecycle management. He also has a solid foundation in open-source and proprietary technologies - ranging from Apache, OpenLDAP or Kerberos to enterprise-grade systems like WebLogic. Morgan Patou holds an Engineering Degree in Computer Science from ENSISA (\u00c9cole Nationale Sup\u00e9rieure d'Ing\u00e9nieurs Sud Alsace) in Mulhouse, France. He is Alfresco Content Services Certified Administrator (ACSCA), Alfresco Content Services Certified Engineer (ACSCE) as well as OpenText Documentum Certified Administrator. His industry experience spans the Public Sector, IT Services, Financial Services\/Banking, and the Pharmaceutical industry.\",\"sameAs\":[\"https:\/\/blog.dbi-services.com\/author\/morgan-patou\/\",\"https:\/\/x.com\/MorganPatou\"],\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/morgan-patou\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Alfresco - Custom Share action not working after disabling WebDAV servlet - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/","og_locale":"en_US","og_type":"article","og_title":"Alfresco - Custom Share action not working after disabling WebDAV servlet","og_description":"On an Alfresco upgrade project I was working on recently, I faced an interesting issue where post upgrade, one of my custom Share action wasn&#8217;t working anymore. This action was used to create folder links for use on an external interface. When applied on a document, it would create a link to the parent folder [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/","og_site_name":"dbi Blog","article_published_time":"2021-11-25T17:38:28+00:00","author":"Morgan Patou","twitter_card":"summary_large_image","twitter_creator":"@MorganPatou","twitter_misc":{"Written by":"Morgan Patou","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/"},"author":{"name":"Morgan Patou","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c4d05b25843a9bc2ab20415dae6bd2d8"},"headline":"Alfresco &#8211; Custom Share action not working after disabling WebDAV servlet","datePublished":"2021-11-25T17:38:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/"},"wordCount":685,"commentCount":0,"keywords":["Alfresco","Share","WebDAV","webdavUrl"],"articleSection":["Application integration &amp; Middleware","Enterprise content management"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/","url":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/","name":"Alfresco - Custom Share action not working after disabling WebDAV servlet - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2021-11-25T17:38:28+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c4d05b25843a9bc2ab20415dae6bd2d8"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/alfresco-custom-share-action-not-working-after-disabling-webdav-servlet\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Alfresco &#8211; Custom Share action not working after disabling WebDAV servlet"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c4d05b25843a9bc2ab20415dae6bd2d8","name":"Morgan Patou","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5d7f5bec8b597db68a09107a6f5309e3870d6296ef94fb10ead4b09454ca67e5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5d7f5bec8b597db68a09107a6f5309e3870d6296ef94fb10ead4b09454ca67e5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5d7f5bec8b597db68a09107a6f5309e3870d6296ef94fb10ead4b09454ca67e5?s=96&d=mm&r=g","caption":"Morgan Patou"},"description":"Morgan Patou has over 12 years of experience in Enterprise Content Management (ECM) systems, with a strong focus in recent years on platforms such as Alfresco, Documentum, and M-Files. He specializes in the architecture, setup, customization, and maintenance of ECM infrastructures in complex &amp; critical environments. Morgan is well-versed in both engineering and operations aspects, including high availability design, system integration, and lifecycle management. He also has a solid foundation in open-source and proprietary technologies - ranging from Apache, OpenLDAP or Kerberos to enterprise-grade systems like WebLogic. Morgan Patou holds an Engineering Degree in Computer Science from ENSISA (\u00c9cole Nationale Sup\u00e9rieure d'Ing\u00e9nieurs Sud Alsace) in Mulhouse, France. He is Alfresco Content Services Certified Administrator (ACSCA), Alfresco Content Services Certified Engineer (ACSCE) as well as OpenText Documentum Certified Administrator. His industry experience spans the Public Sector, IT Services, Financial Services\/Banking, and the Pharmaceutical industry.","sameAs":["https:\/\/blog.dbi-services.com\/author\/morgan-patou\/","https:\/\/x.com\/MorganPatou"],"url":"https:\/\/www.dbi-services.com\/blog\/author\/morgan-patou\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/16866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=16866"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/16866\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=16866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=16866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=16866"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=16866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}