cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get access to the Repository?

alexeyg
Champ in-the-making
Champ in-the-making
Is there a way to access the Repository without using the Web Client?

Can I get it from JNDI somehow? 

I tried this but it did not work: http://www.alfresco.org/mediawiki/index.php/Alfresco_Content_Management_Java_API
7 REPLIES 7

alexeyg
Champ in-the-making
Champ in-the-making
I am trying to build a custom bridge between Alfresco JCR and a Web App.  Administrators will use Web Client to work with the repository, but most of the time another web app would need to get stuff from it.  I am having some major problems discerning Presentation and Business layers of Alfresco.  Is there a nice clean way to get access to the JCR programmatically?

davidc
Star Contributor
Star Contributor
The article http://www.alfresco.org/mediawiki/index.php/Introducing_the_Alfresco_Java_Content_Repository_API provides details on how to access the Alfresco JCR interface from within the same process as the client.  The JCR Repository interface (the entry point) is accessed via a Spring configured Bean.

You may also access remotely via a JCR "remoting" bridge such as the one provided in Jackrabbit.  Others have tried this approach e.g. http://www.alfresco.org/forums/viewtopic.php?t=488.  I haven't personally attempted this yet, but it's something we'd like to incorporate in future builds.

The Repository API's focus solely on providing services (no UI or UI dependencies).

alexeyg
Champ in-the-making
Champ in-the-making
Even though the Repository API is aimed at providing services, it seems very tighly coupled with the Web Client.

If alfresco.war is deployed in Tomcat - can Repository API be accessed from another context? 

If yes, how?  If no, does that mean I have to drop my app into exploded Alfresco.war and hook into it in web.xml?  Sounds like quite a hassle.



As for repository access,:
http://www.alfresco.org/mediawiki/index.php/Introducing_the_Alfresco_Java_Content_Repository_API

does not work - it seems awfully outdated.  It says to get Repository via:

ApplicationContext context = new ClassPathXmlApplicationContext("classpathSmiley Surprisedrg/alfresco/jcr-context.xml");
Repository repository = (Repository)context.getBean("JCR.Repository");

this does not work.  jcr-context.xml no longer gets packaged with alfresco.war.  The "org" part was removed from the classpath.

An updated version of getting Repository appeared here "http://www.alfresco.org/mediawiki/index.php/Alfresco_Content_Management_Java_API" end of January '06:

ApplicationContext appContext = new ClassPathXmlApplicationContext("alfresco/application-context.xml");


  ServiceRegistry registry = (ServiceRegistry)appContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
  if (registry.isServiceProvided(ServiceRegistry.NODE_SERVICE)
  {
    NodeService nodeService = registry.getNodeService();

I haven't tried this yet, about to do so.  Still, the main problem is deploying Alfresco as purely a service layer.  We do need the web client, but only for Administrative users.  Most other access would be done from our web app.

paulhh
Champ in-the-making
Champ in-the-making
Hi

We're going to look at getting another bundle built that is more the pure repo and not the web client.

Cheers
Paul.

davidc
Star Contributor
Star Contributor
I just want to clear up some confusion here with regards to the different xxx-context.xml files.

There are two Alfresco public Java APIs:

1) Alfresco's own service API
2) Alfresco's implementation of the JCR API (JCR is a standard Content Repository API as specified in JSR-170)

The "alfresco/application-context.xml" provides access to Alfresco's own service API which includes the ServiceRegistry and interfaces accessible from it.  This level of API is currently bundled into alfresco.war - simply because the Web Client uses it.

The "alfresco/jcr-context.xml" provides access to Alfresco's implementation of the JCR (JSR-170) API.  It's implemented as a facade on top of Alfresco's own API.  This is not bundled in alfresco.war.

When we provide the "developer" bundle as mentioned by Paul, all of the above jars (as well as the Web Service client jar etc) will be available pre-built.  Otherwise, they can be built from the source bundle.

hsp
Champ in-the-making
Champ in-the-making
Which API provides all services found in Alfresco UI (or almost, like categorization, forum, versioning, aspects). If I am building my web client with struts, I'll need to place what tree of API into it, what files of Alfresco API depends and are needed to be placed into my application too?

alexeyg
Champ in-the-making
Champ in-the-making
After some figuring out I got Alfresco Web Client and myApp working with the same repository from different Tomcat contexts.  Here is info if  you need it:

http://www.alfresco.org/forums/viewtopic.php?p=3826#3826