How to use Alfresco 'Edit Online' functionality from Spring MVC application

99封情书 提交于 2020-04-10 04:33:05

问题


I am currently investigating Alfresco's Sharepoint functionality. I installed Alfresco 3.4 and followed the Web Quick Start Installation.

I then uploaded a word document to Alfresco and can navigate to it in a browser. My URL is http://localhost:8080/share/page/site/webqs/document-details?nodeRef=workspace://SpacesStore/f7f5881e-320e-4d73-85e4-b62752fef1b8

Using Internet Explorer there is an 'Edit Online' button under the 'Document Actions' section. Sadly this button is not available with firefox or google chrome. The HTML source for the button doesn't help me much as I can see a URL:

<div class="onActionEditOnline">
  <a rel="edit,online-edit" href="" class="action-link" title="Edit Online">
    <span>Edit Online</span>
  </a>
</div>

While researching thing at the alfresco site people recommended learning Spring Surf as the Alfresco /share application was written using it. The Spring Surf tutorial uses Roo, this in turn has a Spring Surf addin, which I could not get running, reported by someone else here.

Back to the 'Edit Online' button itself; when I click it the word document is opened in Word on my client machine, I can edit it and click save in Word, using the Sharepoint protocol the document is correctly saved back to Alfresco.

My question is how can I access this 'Edit Online' functionality from my own Spring MVC application? I would like to have this 'Edit Online' button visible on one of my JSPs but I don't know how to interact with Alfresco. Has anyone done this? Any help appreciated!


回答1:


The Sharepoint integration in Alfresco makes use of an embedded Jetty server running the Sharepoint server. If you look at the URL that the "Edit Online", it will show a different port number than all Alfresco web pages (7070 by default).

I never ran any deep investigation on the subject, but since Sharepoint is a WebDAV-like extension of HTTP, possibly using some special headers or built in browser plugin/feature, in order to create an "Edit online" functionality in your site you just have to offer the same URLs Alfresco creates for online editing, and make sure the user is running IE. This will direct the user to the VTI server, thus almost completely leaving SpringMVC out of the picture (you just have to generate proper URLs).


EDIT: how alfresco generates VTI URLs

Have a look at actions.js, which is actually generating the URLs underlying the Edit Online links in Share. The _launchOnlineEditor method is what handles clicks to those empty links you saw, and it also provides the logic that creates the url:

        // Ensure we have the record's onlineEditUrl populated
        if (!Alfresco.util.isValueSet(record.onlineEditUrl))
        {
           var onlineEditUrl = this.doclistMetadata.custom.vtiServer.host + ":" +
                 this.doclistMetadata.custom.vtiServer.port + "/" +
                 $combine("alfresco", loc.site.name, loc.container.name, loc.path, loc.file);

           if (!(/^(http|https):\/\//).test(onlineEditUrl))
           {
              // VTI server now supports HTTPS directly http://issues.alfresco.com/jira/browse/DOC-227
              onlineEditUrl = window.location.protocol + "//" + onlineEditUrl;
           }
           record.onlineEditUrl = onlineEditUrl;
        }

if we had e.g.:

loc.site.name == mySite
loc.container.name == documentLibrary
loc.path == /images
loc.file == logo.png

with default values for the VTI server it would produce the following URL:

http://localhost:7070/alfresco/mySite/documentLibrary/images/logo.png

If you also continue reading that method, it turns out that I was totally wrong: it's not just simple MS magic that associate Office applications to specific URLs, but rather an ActiveX control being created on your browser that results in the proper invocation:

var controlProgID = "SharePoint.OpenDocuments",
//...
activeXControl = new ActiveXObject(controlProgID + ".3");
return activeXControl.EditDocument3(window, record.onlineEditUrl, true, appProgID);

This should complete the picture of how to create Sharepoint links from your custom applications, pointing to the right location in the Alfresco repository.



来源:https://stackoverflow.com/questions/7160494/how-to-use-alfresco-edit-online-functionality-from-spring-mvc-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!