cancel
Showing results for 
Search instead for 
Did you mean: 

Java Backed Web Scripts

yvinodh
Champ in-the-making
Champ in-the-making
Hi all,

i am trying to execute the example in Java Backed Webscripts which is given in the below link..

http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples#RandomSelectWebScript.java

In this example they have extended the AbstractRepositoryWebScript class. where is this class be available ? Do i want to include any jars files to execute this script..?

When i am trying to compile this java file.. i am getting the errors like this..

RandomSelectWebScript.java:23: cannot find symbol
symbol: class AbstractRepositoryWebScript
public class RandomSelectWebScript extends AbstractRepositoryWebScript
                                           ^
RandomSelectWebScript.java:42: cannot find symbol
symbol  : variable services
location: class org.alfresco.demoscripts.RandomSelectWebScript
        List<FileInfo> files = this.services.getFileFolderService().listFiles(rootNodeRef);
                               ^
RandomSelectWebScript.java:88: cannot find symbol
symbol  : variable repository
location: class org.alfresco.demoscripts.RandomSelectWebScript
                NodeRef companyHomeRef = this.repository.getCompanyHome();
                                         ^
RandomSelectWebScript.java:89: cannot find symbol
symbol  : method getFileFolderService()
location: class org.alfresco.demoscripts.RandomSelectWebScript
                nodeRef = getFileFolderService().resolveNamePath(companyHomeRef, pathElements).getNodeRef();
                          ^
RandomSelectWebScript.java:105: cannot find symbol
symbol  : variable services
location: class org.alfresco.demoscripts.RandomSelectWebScript
        ContentReader reader = this.services.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT);
                               ^
5 errors

What should i wanna do to execute this java file and run this script successfully…?


Thanks in Advance,
Vinodh
13 REPLIES 13

max12
Champ in-the-making
Champ in-the-making
Hi

I also tried one of the examples in > 3.3.
There you need to extend your Webscript from DeclarativeWebScript.

But I do have another Problem:
Once I deployed my webscript, it seems that it never gets updated, even when I recompile (with changes) and redeploy.
I also found out that in the Bean definition (once deployes) it doesnt matter what class it referes to. I can change this without getting any errors etc. when restarting tomcat.
I can even delete the Bean definition and tomcat still doesnt complain when starting…

So I am not quite sure if the Java Web Script is called at all.
I am deploying the .class directly into the alfresco webapp -> WEB-INF/classes, so I dont have to build the AMP all the time while developing.

Is there something I am missing?

premium93
Champ in-the-making
Champ in-the-making
You want to pack the .class files into a JAR using jar.exe cf <class files>.

Then you can move the jar file to the WEB-INF/lib folder with the deployment and use those libraries.

koolalfdev
Champ in-the-making
Champ in-the-making
Hi Everyone -

I could not find AbstractRepositoryWebScript.java which contains utility methods to access the service layer. I am using the Alfresco Version 3.3.4. Please let me know if anybody has any luck?

Thanks.

premium93
Champ in-the-making
Champ in-the-making
Here's a great Tutorial to follow to move to the Spring Framework: http://wiki.alfresco.com/wiki/IngresTutorial_Alfresco_Web_Service_API_for_Java

Along with this, there are many other Objects that have to be swapped out and converted to Spring. It's not so bad, just use common Java sense and work with the right documentation.