Commit 30933142 authored by Sherry Mathews's avatar Sherry Mathews


parent 0f1a3092
#### This project contains all the components required to create custom REST endpoints in APS
### Use-Case / Requirement
The workflows can have custom requirements to get certain data from the APS engine or its database. This can be a implemented as a custom REST API and deployed.
### Prerequisites to run this demo end-2-end
* Alfresco Process Services (powered by Activiti) (Version 1.9 and above) - If you don't have it already, you can download a 30 day trial from [Alfresco Process Services (APS)]( & help available at [Activiti Docs](, [Alfresco BPM Community](
### Activiti Setup and Process Deployment
1. Setup Alfresco Activiti if you don't have one already. Instructions & help available at [Activiti Docs](, [Alfresco BPM Community](
2. Before starting with your REST API implementation make sure to ![set up a proper Activiti Extension project](
3. Sample custom API code to greet.
package com.activiti.extension.api;
import com.activiti.extension.api.GreetingMessage;
import com.codahale.metrics.annotation.Timed;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
public class CustomRestEndpoint {
@RequestMapping(value = "/CustomRestEndpoint", method= RequestMethod.GET)
public GreetingMessage sayHello(@RequestParam(value="name", required=false,
defaultValue="World") String name) {
GreetingMessage msg = new GreetingMessage(name, "Hello " + name + "!");
return msg;
@RequestMapping(value = "/CustomRestEndpoint/{name}", method= RequestMethod.GET)
public GreetingMessage sayHelloAgain(@PathVariable String name) {
GreetingMessage msg = new GreetingMessage(name, "Hello " + name + "!");
return msg;
public static void main(String[] argv) {
System.out.println("-------- Custom Endpoint Successfully called ------");
4. Another example of custom REST endpoint to get task count of a user.
import com.activiti.domain.idm.User;
import org.activiti.engine.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/rest/custom-rest-endpoint") //http://localhost:8080/activiti-app/app/rest/custom-rest-endpoint
public class CustomRESTEndpoint {
private TaskService taskService;
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
public CustomRestEndpointResponse sampleImplementation() {
//Obtain the Task Count for the Current User
final User currentUser = SecurityUtils.getCurrentUserObject();
final long taskCount = taskService.createTaskQuery().taskAssignee(String.valueOf(currentUser.getId())).count();
//Construct the Response
final CustomRestEndpointResponse myRestEndpointResponse = new CustomRestEndpointResponse();
return myRestEndpointResponse;
private static final class CustomRestEndpointResponse {
private String fullName;
private long taskCount;
public String getFullName() {
return fullName;
public long getTaskCount() {
return taskCount;
public void setFullName(final String fullName) {
this.fullName = fullName;
public void setTaskCount(final long taskCount) {
this.taskCount = taskCount;
5. Build the extension project
mvn clean install
6. Deploy the jar file to the activiti-app webapp's WEB-INF/lib folder.
eg: /usr/local/tomcat/webapps/activiti-app/WEB-INF/lib.
### Run the DEMO
### References
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment