cancel
Showing results for 
Search instead for 
Did you mean: 

getServiceRegistry, getRepositoryContext

tasso
Champ in-the-making
Champ in-the-making
getServiceRegistry, getRepositoryContext

I recently upgraded from to the 3.2 CE edition of alfresco. In our previous version of alfresco we used java backed webscripts and in many of our webscripts we used the get getServiceRegistry and getRepositoryContext methods as they were available through the AbstractWebScript class.  Since upgrading to version 3.2 it looks like these methods have been removed from the AbstractWebScript class. Below is an example of abstract class where we extended AbstractWebScript and called these methods

   protected AuthenticationService getAuthenticationService() {
      AuthenticationService returnAuthenticationService = this.getServiceRegistry().getAuthenticationService();
      return returnAuthenticationService;
   }
   protected AuthorityService getAuthorityService() {
      AuthorityService returnAuthorityService = this.getServiceRegistry().getAuthorityService();
      return returnAuthorityService;
   }

   protected NodeRef getCompanyHomeReference() {
      NodeRef nodeRef = this.getRepositoryContext().getCompanyHome();
      return nodeRef;
   }


Since the getServiceRegistry() and getRepositoryContext() methods are no longer available from the AbstractWebScript class, what is the best way to adapt the methods above  in order to utilize the getAuthenticationService(), getAuthorityService() and getCompanyHome() methods in 3.2? In other words how can I get access to the methods in the ServiceRegistry interface in org.alfresco.service?

Thank you
3 REPLIES 3

bramthielemans
Champ in-the-making
Champ in-the-making
You can inject the ServiceRegistry bean into your webscript bean when you have the appropriate setter in your class:

<bean id="webscript.com.example.mywebscript.get" class="com.example.MyWebScript" parent="webscript">
   <property name="serviceRegistry" ref="ServiceRegistry"/>       
</bean>

christophes
Champ in-the-making
Champ in-the-making
I'm trying to upgrade to Alfresco 3.2.0 too and I have the same problem than tasso with the method getRepositoryContext. Is there a solution to get the RepositoryContext with another method in my java backed webscripts?

Christophe

thomasg
Champ in-the-making
Champ in-the-making
Hi,
you need to inject repositoryHelper in your bean definition

<bean id="webscript.org.alfresco.demo.test.get"
    class="org.alfresco.Demo"
    parent="webscript">
           <property name="repository" ref="repositoryHelper" />
</bean>

It will provide class org.alfresco.repo.model.Repository with methods you expect.

Thomas