cancel
Showing results for 
Search instead for 
Did you mean: 

Access web scripts in alfresco.war through code

yogesh
Champ in-the-making
Champ in-the-making
Hi

I am working on code written by some other team and they designed some web scripts to access Alfresco using functions like ServiceRegistry, SearchService and other such functions for connecting to database. Then this is used to create an .amp file which is applied to make changes in alfresco.war and now tomcat/webapps/alfresco.war contains those corresponding classes in a jar file inside alfresco/WEB-INF/lib folder. I need to add more functionality using these classes but I don't know how to access those classes directly in my code from those packages or war files. Can anyone please help.

Regards
3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator
I think we need to break this down a bit to validate my understanding of what you are trying to do…
I am working on code written by some other team and they designed some web scripts to access Alfresco using functions like ServiceRegistry, SearchService and other such functions for connecting to database.
Okay, this sounds like they have written some Java-backed web scripts and they are using some of Alfresco's services to work with content in the repository.
Then this is used to create an .amp file which is applied to make changes in alfresco.war and now tomcat/webapps/alfresco.war contains those corresponding classes in a jar file inside alfresco/WEB-INF/lib folder
The code, such as the custom web scripts, includes a build script which creates an AMP. The AMP has been applied to the alfresco.war. This is one way to get customizations merged with the Alfresco web application. Those Java classes were placed in a JAR and that JAR goes in WEB-INF/lib.
I need to add more functionality using these classes but I don't know how to access those classes directly in my code from those packages or war files.
You'll need the source Java code. And you'll probably want their build script. The part that is tripping me up is that you are asking "how to access those classes directly in my code from those packages or WAR files". If you are adding functionality to the Java classes, you can either edit the source of the custom code the other team wrote, then compile and deploy it as an AMP, just like they did, or you can write new Java classes that extend the code the other team wrote.

I may still not be understanding what you are asking for, so please provide additional details and what you've tried so far if you need further help.

Jeff

yogesh
Champ in-the-making
Champ in-the-making
I think we need to break this down a bit to validate my understanding of what you are trying to do…

You'll need the source Java code. And you'll probably want their build script. The part that is tripping me up is that you are asking "how to access those classes directly in my code from those packages or WAR files". If you are adding functionality to the Java classes, you can either edit the source of the custom code the other team wrote, then compile and deploy it as an AMP, just like they did, or you can write new Java classes that extend the code the other team wrote.

I may still not be understanding what you are asking for, so please provide additional details and what you've tried so far if you need further help.

Jeff

Thank you for your reply. I am sorry, I am novice in Alfresco and not conversant with standard Alfresco terminology. They have created some web scripts to put or get user/records in Alfresco and I can see a .jar file for the same in alfresco.war after applying .amp package. What I want to know is how can I call those custom functions from my Java code. Is there a way I can create a URL which will call local alfresco with parameters and get the results.

jpotts
World-Class Innovator
World-Class Innovator
No problem at all, happy to help.

It sounds like they have written some Java-backed web scripts. If you would also like to write some Java-backed web scripts and they have some services they have created, you can inject those services into your web scripts through Spring configuration. Or, if they have a Java-backed web script that you would like to extend, you can use standard Java techniques to extend their class and then override their methods.

It really depends on what they've written, how they've written it, and what exactly you are trying to do.

The tools you have to work with are:
- The Java code the other team has written.
- The Alfresco Foundation API, which is written in Java. Your Java-backed web script can leverage this API. You can deploy new web scripts alongside the other team's web scripts, either in their Jar or in a new Jar.
- The web scripts the other team has written. You can invoke these over HTTP from Java if you'd like.

Jeff