cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco and Ruby on Rails

achung
Champ in-the-making
Champ in-the-making
Hello -

I want to use Alfresco as the CMS for http://www.mysite.com and develop a custom app with Ruby that can be accessed at http://www.mysite.com/app1.  The custom app should only be visible to users who login to Alfresco.

From what I understand so far of Alfresco, both the CMS and RoR can reside on the same server and that the scenario above is possible.  Is my interpretation correct?  If so, how difficult is it to accomplish?

Thanks very much in advance.

Regards,
Andrew
14 REPLIES 14

pmonks
Star Contributor
Star Contributor
Integrating Alfresco with other applications (regardless of the technology) is reasonably straight forward via the use of Web Scripts (http://wiki.alfresco.com/wiki/Web_Scripts).  Basically the idea is to use Web Scripts to define your own REST based API tailored to your specific use cases, and then call that API from the other application.  Alfresco ends up being little more than a repository, with the other application acting as the UI for the combined system.

In the case of Ruby on Rails specifically, you might choose to implement a REST API that "talks" ActiveResource (http://wiki.rubyonrails.org/rails/pages/ActiveResource), thereby simplifying the integration on the Rails side.  I know of at least one Alfresco implementation that has done this, and have heard of similar techniques being used with other technologies (such as Python) as well.

Cheers,
Peter

achung
Champ in-the-making
Champ in-the-making
Thanks Peter – appreciate it.

bnordgren
Champ in-the-making
Champ in-the-making
In the case of Ruby on Rails specifically, you might choose to implement a REST API that "talks" ActiveResource (http://wiki.rubyonrails.org/rails/pages/ActiveResource), thereby simplifying the integration on the Rails side.  I know of at least one Alfresco implementation that has done this, and have heard of similar techniques being used with other technologies (such as Python) as well.

I know it's been a couple of years since this last post, but I was rooting around on the forge and couldn't find any of these webscripts.  Nor could I locate any actual code with a google search. My hope was to use Alfresco (our CMS) as a backend for Redmine http://www.redmine.org (our development solution).  Is there any chance some of these REST APIs that talk ActiveResource could be shared? Smiley Happy

THanks,
Bryce

pmonks
Star Contributor
Star Contributor
The customer I worked with who did this have not (as far as I'm aware) released their Alfresco / ActiveResource infrastructure to the community, although they do monitor these forums and may be willing to do so if there's sufficient interest.

Given the age of this thread, perhaps it would be worth creating a new one?

Cheers,
Peter

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi,

First of all, it seems no other thread have been created (or I missed it !) that's why I keep on this one.

@pmonks

Any feedbacks from your customer about usability/integration/sustainability of this kind of architecture ?
I'm currently collecting infos on alternatives way of presenting data from an Alfresco repository through external frameworks, that's why I'm interested in your advices.
I've already looked at Surf deeply, Php a bit, but I do need other inputs to complete the overview, especially as I consider myself as a real RoR fan !
I planned to look also around Python, do you have any other ideas ?

Thanks

Mathieu BODIN

groberts
Champ on-the-rise
Champ on-the-rise
I am working on a Ruby on Rails project that uses Alfresco.   I started off trying to use the excellent Docasu module but quickly (alright, slowly) realised that the SQL side of my project would be better done in Rails.  (I use a fabulous framework called Netzke to do most of the GUI).

So as mentioned above,  Alfresco is just used as a repository.    Docasu provides some web scripts to do things like list files in a directory, create spaces and new files.  But I have been surprised at how few other web scripts are delivered with Alfresco to do the above tasks.

Maybe its because the emphasis is on CMIS.   Incidentally Docasu's web scripts return nice simple JSON which can be processed very easily in Javascript.  CMIS seems to involve lots of XML building and XML construction,  I wonder if the guys who wrote the standard ever tried to write a GUI that uses it.   It would be much easier if the results were optionally rendered in JSON.   Docasu's web scripts seem like proper RESTful operations,  CMIS wraps up complicated instructions inside an XML (ATOM ?) and then makes it look like a RESTful act.  (Not much about big XML documents makes me feel restful).

You can always write your own Web Scripts,  but you'll need to know Java, Java build environtments, Ant, Javascript,  Firebug.  

The other issue when calling Alfresco web services from Rails is Authentication.   You can either use a ticket or basic authentication (I think)

curl -v "http://xxxx.yyyy.org/alfresco/service/api/login?u=admin&pw=admin"

returns some XML containing

<ticket>TICKET_b7162c9dfcc2a89dac801ff0a27d22ca53a213d0</ticket>

Then use an extra parameter when calling your web scripts   &alf_ticket=TICKET_bb280d638daaac387bdc34a6c0b6b128d6b047e8

One thing I have not solved is how to just download a simple file, say a pdf, from Alfresco using another web app or curl.   I keep getting a login prompt in html even though I provide basic auth and a valid ticket.  I guess this is because the URL for the file is not a web service.  Docasu uses the same URL but it is part of Alfresco where as my app is completely different.

I suppose I will have to write a web script to provide the file,  but if so I wonder why one does not already exist.

Using Rails with Alfresco is theoretically as simple as finding the right web scripts,  but the complexity of CMIS makes it harder than it could be.

groberts
Champ on-the-rise
Champ on-the-rise
A Rails application can fetch a file from Alfresco using the docasu web script.

GET /alfresco/service/docasu/ui/node/content/{nodeId}

curl -v "http://admin:admin@xxxxx.yyyy.org/alfresco/service/docasu/ui/node/content/5b76387d-3649-46b0-aae7-22..."

I use a Ruby on Rails controller that takes the nodeid as a param and then fetches the file from Alfresco before rendering it back to the browser.  This way the credentials for Alfresco are not embedded in the HTML of the Rails app !   The files are rendered in a grid as links to the controller just mentioned with the correct nodeid.

lfridael
Champ in-the-making
Champ in-the-making
I'm not familiar with the docaso web scripts, but I do know that, for retrieving content, you can also use the standard repository REST API.

Example:
GET /alfresco/service/api/node/content/workspace/SpacesStore/<node-id>?alf_ticket=<ticket_id>

groberts
Champ on-the-rise
Champ on-the-rise
Thanks for the suggestion.  I don't think that Web Script is available in Alfresco Community 3.3.g.   I can see it in an older version,  Alfresco Community v3.2.0.

There is a Web Script in 3.3.g called

http://admin:admin@xxxx.yyyy.org/alfresco/service/api/node/workspace/SpacesStore/5b76387d-3649-46b0-...

but it produces lots of cmis XML and not the file stream.   

I guess I could spend time learning about CMIS but my client is in a rush and the docasu scripts just work.

Jeff Potts wrote a useful document "Getting started with CMIS" (55 pages) and I bought a PACT book called "Alfresco 3 Web Services".  Both remind me of the complicated Java/XML web services world that I was trying to move away from with Ruby on Rails and RESTful stuff.  I just want to download a file from Alfresco ! 

Thanks for the suggestion though.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.