Hello world java backed webscript
What is
webscript?
A Web Script is a service bound
to a URL which responds to HTTP methods like GET, POST, PUT and DELETE.
Webscript
consists of three files.
Webscript descriptor file: XML
file
Controller file: Either it can be
a server-side Javascript or Java backed.
Presentation file: Free Marker
Template file.
In this
blog, I’ll show you, how to create a simple java backed webscript for Alfresco
Repository.
Step 1: Create
a new Java project with the following structure.
Step 3: Override the executeImpl method. In this method create a new HashMap object, add a greeting message and return it. Refer the below image.
Step 4: Now, we need to create a webscript descriptor xml
file (helloWorld.get.desc.xml) in the
config/alfresco/extension/templates/webscripts/com/murali/webscripts path
Step 5: Now we need to create a simple FreeMarker Template
file (helloWorld.get.json.ftl) to render
the output.
Step 6: Register the webscript bean like,
Step 7: Create module.properties file in config/alfresco path.
Step 8: Create the alfresco amp by using below build.xml
file.
Step 9: Install the amp, delete the exploded directory of
alfresco.
Step 10: Restart the tomcat.
Step 11: Navigate to http://localhost:<portNumber>/alfresco/service/index/all
Step 12: Search for your /com/murali/webscripts package
and click GET /alfresco/service/com/murali/webscripts/helloWorld/ url to invoke
the webscript.
Step 13: Webscript output
Hope this helps someone !
No comments:
Post a Comment