Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
e5cb8e7517 | |||
e6de135012 | |||
94f3de6386 | |||
41f74eddc9 | |||
a258ccf045 | |||
a3ab8a5c08 | |||
5399a77993 | |||
78f006849f | |||
3d0cb56680 | |||
d34d95ae42 | |||
e791bdb1fa | |||
6dbb73fa17 | |||
7c0dfe919e | |||
8c31f098d4 | |||
baf2e0ebb6 | |||
b388ffb9ed | |||
e2b6ed6177 | |||
8f1300b097 | |||
fe41dbef76 | |||
4fe407de0f | |||
4fb9724d07 |
59
pom.xml
59
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.inteligr8.alfresco</groupId>
|
<groupId>com.inteligr8.alfresco</groupId>
|
||||||
<artifactId>aps-public-rest-api</artifactId>
|
<artifactId>aps-public-rest-api</artifactId>
|
||||||
<version>1.0.0-v1</version>
|
<version>1.1.1</version>
|
||||||
<name>Alfresco Process Services ReST API Client for Java</name>
|
<name>Alfresco Process Services ReST API Client for Java</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -18,25 +18,27 @@
|
|||||||
|
|
||||||
<junit.version>5.7.2</junit.version>
|
<junit.version>5.7.2</junit.version>
|
||||||
<spring.version>5.2.14.RELEASE</spring.version>
|
<spring.version>5.2.14.RELEASE</spring.version>
|
||||||
<spring-boot.version>2.3.10.RELEASE</spring-boot.version>
|
|
||||||
<jersey.version>2.34</jersey.version>
|
<jersey.version>2.34</jersey.version>
|
||||||
|
<cxf.version>3.3.2</cxf.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>com.inteligr8</groupId>
|
||||||
<artifactId>spring-context</artifactId>
|
<artifactId>common-rest-api</artifactId>
|
||||||
<version>${spring.version}</version>
|
<version>1.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>org.glassfish.jersey.ext</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jersey-proxy-client</artifactId>
|
||||||
<version>2.12.2</version>
|
<version>${jersey.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.ws.rs</groupId>
|
<groupId>org.apache.cxf</groupId>
|
||||||
<artifactId>jakarta.ws.rs-api</artifactId>
|
<artifactId>cxf-rt-rs-client</artifactId>
|
||||||
<version>2.1.6</version>
|
<version>${cxf.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.core</groupId>
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
@@ -68,6 +70,12 @@
|
|||||||
<version>${spring.version}</version>
|
<version>${spring.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>4.5.9</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -94,18 +102,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>io.repaint.maven</groupId>
|
|
||||||
<artifactId>tiles-maven-plugin</artifactId>
|
|
||||||
<version>2.21</version>
|
|
||||||
<extensions>true</extensions>
|
|
||||||
<configuration>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
<tiles>
|
|
||||||
<tile>com.inteligr8:maven-public-deploy-tile:[1.0.0,2.0.0)</tile>
|
|
||||||
</tiles>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@@ -263,8 +259,19 @@
|
|||||||
<url>https://repository.mulesoft.org/releases</url>
|
<url>https://repository.mulesoft.org/releases</url>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>inteligr8-releases</id>
|
<id>inteligr8-public</id>
|
||||||
<url>http://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
</project>
|
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>inteligr8-releases</id>
|
||||||
|
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>inteligr8-snapshots</id>
|
||||||
|
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-snapshots</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
|
</project>
|
||||||
|
@@ -1,20 +0,0 @@
|
|||||||
package com.inteligr8.alfresco.activiti;
|
|
||||||
|
|
||||||
import javax.ws.rs.client.ClientRequestContext;
|
|
||||||
import javax.ws.rs.client.ClientRequestFilter;
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
|
||||||
|
|
||||||
public class AccessTokenRequestFilter implements ClientRequestFilter {
|
|
||||||
|
|
||||||
private final String token;
|
|
||||||
|
|
||||||
public AccessTokenRequestFilter(String token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void filter(ClientRequestContext requestContext) {
|
|
||||||
requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, "Bearer " + this.token);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,35 +0,0 @@
|
|||||||
package com.inteligr8.alfresco.activiti;
|
|
||||||
|
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.api.EnterpriseAPI;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Afresco Process Services Spring Client
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class ApsClient {
|
|
||||||
|
|
||||||
private static final ApsClient INSTANCE = new ApsClient();
|
|
||||||
|
|
||||||
public static ApsClient getInstance() {
|
|
||||||
return ApsClient.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApsClientConfiguration config;
|
|
||||||
|
|
||||||
public EnterpriseAPI getEnterpriseAPI() {
|
|
||||||
javax.ws.rs.client.Client client = ClientBuilder
|
|
||||||
.newClient();
|
|
||||||
|
|
||||||
this.config.authorize(client);
|
|
||||||
return new EnterpriseAPI(this.config.getBaseUrl() + "/api", client);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,37 +1,105 @@
|
|||||||
package com.inteligr8.alfresco.activiti;
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import com.inteligr8.rs.ClientCxfConfiguration;
|
||||||
|
import com.inteligr8.rs.ClientJerseyConfiguration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
public class ApsClientConfiguration {
|
public class ApsClientConfiguration implements ClientCxfConfiguration, ClientJerseyConfiguration {
|
||||||
|
|
||||||
@Value("${process.service.baseUrl}")
|
@Value("${process.service.baseUrl:http://localhost:8080/activiti-app}")
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
|
|
||||||
@Value("${process.service.security.basicAuth.username}")
|
@Value("${process.service.security.basicAuth.username:admin@app.activiti.com}")
|
||||||
private String basicAuthUsername;
|
private String basicAuthUsername;
|
||||||
|
|
||||||
@Value("${process.service.security.basicAuth.password}")
|
@Value("${process.service.security.basicAuth.password:admin}")
|
||||||
private String basicAuthPassword;
|
private String basicAuthPassword;
|
||||||
|
|
||||||
@Value("${process.service.security.accessToken}")
|
@Value("${process.service.security.accessToken:#{null}}")
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
|
|
||||||
|
@Value("${process.service.security.oauth.tokenUrl:#{null}}")
|
||||||
|
private String oAuthTokenUrl;
|
||||||
|
|
||||||
|
@Value("${process.service.security.oauth.clientId:#{null}}")
|
||||||
|
private String oAuthClientId;
|
||||||
|
|
||||||
|
@Value("${process.service.security.oauth.clientSecret:#{null}}")
|
||||||
|
private String oAuthClientSecret;
|
||||||
|
|
||||||
|
@Value("${process.service.security.oauth.authCode:#{null}}")
|
||||||
|
private String oAuthAuthCode;
|
||||||
|
|
||||||
|
@Value("${process.service.security.oauth.authRedirectUri:#{null}}")
|
||||||
|
private String oAuthAuthRedirectUri;
|
||||||
|
|
||||||
|
@Value("${process.service.security.oauth.grantUsername:#{null}}")
|
||||||
|
private String oAuthUsername;
|
||||||
|
|
||||||
|
@Value("${process.service.security.oauth.grantPassword:#{null}}")
|
||||||
|
private String oAuthPassword;
|
||||||
|
|
||||||
|
@Value("${process.service.cxf.defaultBusEnabled:true}")
|
||||||
|
private boolean defaultBusEnabled;
|
||||||
|
|
||||||
|
@Value("${process.service.jersey.putBodyRequired:true}")
|
||||||
|
private boolean putBodyRequired;
|
||||||
|
|
||||||
public String getBaseUrl() {
|
public String getBaseUrl() {
|
||||||
return this.baseUrl;
|
return this.baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void authorize(Client client) {
|
public String getBasicAuthUsername() {
|
||||||
if (this.basicAuthUsername != null) {
|
return this.basicAuthUsername;
|
||||||
client.register(new BasicAuthRequestFilter(this.basicAuthUsername, this.basicAuthPassword));
|
}
|
||||||
} else if (this.accessToken != null) {
|
|
||||||
client.register(new AccessTokenRequestFilter(this.accessToken));
|
public String getBasicAuthPassword() {
|
||||||
}
|
return this.basicAuthPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessToken() {
|
||||||
|
return this.accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOAuthTokenUrl() {
|
||||||
|
return this.oAuthTokenUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOAuthClientId() {
|
||||||
|
return this.oAuthClientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOAuthClientSecret() {
|
||||||
|
return this.oAuthClientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOAuthAuthCode() {
|
||||||
|
return this.oAuthAuthCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOAuthAuthRedirectUri() {
|
||||||
|
return this.oAuthAuthRedirectUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOAuthUsername() {
|
||||||
|
return this.oAuthUsername;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOAuthPassword() {
|
||||||
|
return this.oAuthPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDefaultBusEnabled() {
|
||||||
|
return this.defaultBusEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPutBodyRequired() {
|
||||||
|
return this.putBodyRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.inteligr8.rs.ClientCxfConfiguration;
|
||||||
|
import com.inteligr8.rs.ClientCxfImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configured JAX-RS Client & WebTarget for APS & CXF
|
||||||
|
*/
|
||||||
|
@Component("aps.client.cxf")
|
||||||
|
@Lazy
|
||||||
|
public class ApsClientCxfImpl extends ClientCxfImpl {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApsClientConfiguration config;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ClientCxfConfiguration getConfig() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.inteligr8.rs.ClientJerseyConfiguration;
|
||||||
|
import com.inteligr8.rs.ClientJerseyImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configured JAX-RS Client & WebTarget for APS & Jersey
|
||||||
|
*/
|
||||||
|
@Component("aps.client.jersey")
|
||||||
|
@Lazy
|
||||||
|
public class ApsClientJerseyImpl extends ClientJerseyImpl {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApsClientConfiguration config;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ClientJerseyConfiguration getConfig() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,39 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.activiti.api.AdminApi;
|
||||||
|
import com.inteligr8.alfresco.activiti.api.AppVersionApi;
|
||||||
|
import com.inteligr8.alfresco.activiti.api.ProcessInstancesApi;
|
||||||
|
import com.inteligr8.alfresco.activiti.api.ProfileApi;
|
||||||
|
import com.inteligr8.alfresco.activiti.api.TasksApi;
|
||||||
|
import com.inteligr8.rs.ClientConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alfresco Process Services Spring-ready API
|
||||||
|
*/
|
||||||
|
public abstract class ApsPublicRestApi {
|
||||||
|
|
||||||
|
protected abstract ClientConfiguration getConfig();
|
||||||
|
|
||||||
|
protected abstract <T> T getApi(Class<T> apiClass);
|
||||||
|
|
||||||
|
public AdminApi getAdminApi() {
|
||||||
|
return this.getApi(AdminApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppVersionApi getAppVersionApi() {
|
||||||
|
return this.getApi(AppVersionApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProcessInstancesApi getProcessInstancesApi() {
|
||||||
|
return this.getApi(ProcessInstancesApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProfileApi getProfileApi() {
|
||||||
|
return this.getApi(ProfileApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TasksApi getTasksApi() {
|
||||||
|
return this.getApi(TasksApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,29 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.inteligr8.rs.ClientConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alfresco Process Services Spring-ready API for CXF
|
||||||
|
*/
|
||||||
|
@Component("aps.api.cxf")
|
||||||
|
@Lazy
|
||||||
|
public class ApsPublicRestApiCxfImpl extends ApsPublicRestApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApsClientCxfImpl client;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ClientConfiguration getConfig() {
|
||||||
|
return this.client.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <T> T getApi(Class<T> apiClass) {
|
||||||
|
return this.client.getApi(apiClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,29 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.inteligr8.rs.ClientConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alfresco Process Services Spring-ready API for Jersey
|
||||||
|
*/
|
||||||
|
@Component("aps.api.jersey")
|
||||||
|
@Lazy
|
||||||
|
public class ApsPublicRestApiJerseyImpl extends ApsPublicRestApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApsClientJerseyImpl client;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ClientConfiguration getConfig() {
|
||||||
|
return this.client.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <T> T getApi(Class<T> apiClass) {
|
||||||
|
return this.client.getApi(apiClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,28 +0,0 @@
|
|||||||
package com.inteligr8.alfresco.activiti;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
import javax.ws.rs.client.ClientRequestContext;
|
|
||||||
import javax.ws.rs.client.ClientRequestFilter;
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
|
||||||
|
|
||||||
public class BasicAuthRequestFilter implements ClientRequestFilter {
|
|
||||||
|
|
||||||
private final String username;
|
|
||||||
private final String password;
|
|
||||||
|
|
||||||
public BasicAuthRequestFilter(String username, String password) {
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void filter(ClientRequestContext requestContext) throws UnsupportedEncodingException {
|
|
||||||
String userAndPass = this.username + ":" + this.password;
|
|
||||||
String userAndPassEncoded = Base64.getEncoder().encodeToString(userAndPass.getBytes("utf-8"));
|
|
||||||
|
|
||||||
requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, "Basic " + userAndPassEncoded);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,32 +0,0 @@
|
|||||||
package com.inteligr8.alfresco.activiti;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
||||||
|
|
||||||
public class ExtendedResponse {
|
|
||||||
|
|
||||||
private final Response response;
|
|
||||||
|
|
||||||
public ExtendedResponse(Response response) {
|
|
||||||
this.response = response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <T> List<T> readArrayEntity(Class<T> genericType) {
|
|
||||||
ArrayNode nodes = this.response.readEntity(ArrayNode.class);
|
|
||||||
|
|
||||||
ObjectMapper om = new ObjectMapper();
|
|
||||||
try {
|
|
||||||
return (List<T>)om.readerForListOf(genericType).readValue(nodes);
|
|
||||||
} catch (IOException ie) {
|
|
||||||
throw new WebApplicationException(ie);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,32 +0,0 @@
|
|||||||
|
|
||||||
package com.inteligr8.alfresco.activiti.api;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.core.Response.Status.Family;
|
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.ExtendedResponse;
|
|
||||||
import com.inteligr8.alfresco.activiti.model.Tenant;
|
|
||||||
|
|
||||||
public class AdminAPI extends PathElement {
|
|
||||||
|
|
||||||
private final Client client;
|
|
||||||
|
|
||||||
public AdminAPI(EnterpriseAPI api) {
|
|
||||||
super(api, "admin");
|
|
||||||
this.client = api.getClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Tenant> getTenants() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/tenants")
|
|
||||||
.request()
|
|
||||||
.get();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return new ExtendedResponse(response).readArrayEntity(Tenant.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
package com.inteligr8.alfresco.activiti.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.activiti.model.Tenant;
|
||||||
|
|
||||||
|
@Path("/api/enterprise/admin")
|
||||||
|
public interface AdminApi {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/tenants")
|
||||||
|
@Consumes({ "application/json" })
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
public List<Tenant> getTenants();
|
||||||
|
|
||||||
|
}
|
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
package com.inteligr8.alfresco.activiti.api;
|
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.core.Response.Status.Family;
|
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.model.AppVersion;
|
|
||||||
|
|
||||||
public class AppVersionAPI extends PathElement {
|
|
||||||
|
|
||||||
private final Client client;
|
|
||||||
|
|
||||||
public AppVersionAPI(EnterpriseAPI api) {
|
|
||||||
super(api, "app-version");
|
|
||||||
this.client = api.getClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AppVersion get() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl())
|
|
||||||
.request()
|
|
||||||
.get();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(AppVersion.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
package com.inteligr8.alfresco.activiti.api;
|
||||||
|
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.activiti.model.AppVersion;
|
||||||
|
|
||||||
|
@Path("/api/enterprise/app-version")
|
||||||
|
public interface AppVersionApi {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
public AppVersion get();
|
||||||
|
|
||||||
|
}
|
@@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
package com.inteligr8.alfresco.activiti.api;
|
|
||||||
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
|
|
||||||
public class EnterpriseAPI extends PathElement {
|
|
||||||
|
|
||||||
private final Client client;
|
|
||||||
|
|
||||||
public EnterpriseAPI(String baseUrl, Client client) {
|
|
||||||
super(baseUrl, "enterprise");
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnterpriseAPI(PathElement parent, Client client) {
|
|
||||||
super(parent, "enterprise");
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Client getClient() {
|
|
||||||
return this.client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminAPI getAdminAPI() {
|
|
||||||
return new AdminAPI(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AppVersionAPI getAppVersionAPI() {
|
|
||||||
return new AppVersionAPI(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProcessInstancesAPI getProcessInstanceAPI() {
|
|
||||||
return new ProcessInstancesAPI(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileAPI getProfileAPI() {
|
|
||||||
return new ProfileAPI(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TasksAPI getTasksAPI() {
|
|
||||||
return new TasksAPI(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,25 +0,0 @@
|
|||||||
package com.inteligr8.alfresco.activiti.api;
|
|
||||||
|
|
||||||
public abstract class PathElement {
|
|
||||||
|
|
||||||
private final String baseUrl;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public PathElement(String baseUrl, String name) {
|
|
||||||
this.baseUrl = baseUrl + "/" + name;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PathElement(PathElement pelement, String name) {
|
|
||||||
this(pelement.getBaseUrl(), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getBaseUrl() {
|
|
||||||
return this.baseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,110 +0,0 @@
|
|||||||
|
|
||||||
package com.inteligr8.alfresco.activiti.api;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
import javax.ws.rs.client.Entity;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.core.Response.Status.Family;
|
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.ExtendedResponse;
|
|
||||||
import com.inteligr8.alfresco.activiti.model.ProcessInstance;
|
|
||||||
import com.inteligr8.alfresco.activiti.model.Variable;
|
|
||||||
|
|
||||||
public class ProcessInstanceAPI extends PathElement {
|
|
||||||
|
|
||||||
private final Client client;
|
|
||||||
|
|
||||||
public ProcessInstanceAPI(ProcessInstancesAPI api, String processInstanceId) throws UnsupportedEncodingException {
|
|
||||||
super(api, URLEncoder.encode(processInstanceId, "utf-8"));
|
|
||||||
this.client = api.getClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Client getClient() {
|
|
||||||
return this.client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProcessInstance get() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl())
|
|
||||||
.request()
|
|
||||||
.get();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(ProcessInstance.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl())
|
|
||||||
.request()
|
|
||||||
.delete();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProcessInstance activate() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/activate")
|
|
||||||
.request()
|
|
||||||
.put(null);
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(ProcessInstance.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProcessInstance suspend() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/suspend")
|
|
||||||
.request()
|
|
||||||
.put(null);
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(ProcessInstance.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Variable> getVariables() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables")
|
|
||||||
.request()
|
|
||||||
.get();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return new ExtendedResponse(response).readArrayEntity(Variable.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Variable> setVariables(List<Variable> variables) {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables")
|
|
||||||
.request()
|
|
||||||
.put(Entity.json(variables));
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return new ExtendedResponse(response).readArrayEntity(Variable.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Variable getVariable(String variableName) throws UnsupportedEncodingException {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables/" + URLEncoder.encode(variableName, "utf-8"))
|
|
||||||
.request()
|
|
||||||
.get();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(Variable.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Variable setVariable(String variableName, Variable variable) throws UnsupportedEncodingException {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables/" + URLEncoder.encode(variableName, "utf-8"))
|
|
||||||
.request()
|
|
||||||
.put(Entity.json(variable));
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(Variable.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteVariable(String variableName) throws UnsupportedEncodingException {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables/" + URLEncoder.encode(variableName, "utf-8"))
|
|
||||||
.request()
|
|
||||||
.delete();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
package com.inteligr8.alfresco.activiti.api;
|
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
import javax.ws.rs.client.Entity;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.core.Response.Status.Family;
|
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.model.CreateProcessInstance;
|
|
||||||
import com.inteligr8.alfresco.activiti.model.ProcessInstance;
|
|
||||||
|
|
||||||
public class ProcessInstancesAPI extends PathElement {
|
|
||||||
|
|
||||||
private final Client client;
|
|
||||||
|
|
||||||
public ProcessInstancesAPI(EnterpriseAPI api) {
|
|
||||||
super(api, "process-instances");
|
|
||||||
this.client = api.getClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Client getClient() {
|
|
||||||
return this.client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProcessInstance create(CreateProcessInstance processInstance) {
|
|
||||||
Response response = this.client.target(this.getBaseUrl())
|
|
||||||
.request()
|
|
||||||
.post(Entity.json(processInstance));
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(ProcessInstance.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -0,0 +1,72 @@
|
|||||||
|
|
||||||
|
package com.inteligr8.alfresco.activiti.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.activiti.model.CreateProcessInstance;
|
||||||
|
import com.inteligr8.alfresco.activiti.model.ProcessInstance;
|
||||||
|
import com.inteligr8.alfresco.activiti.model.Variable;
|
||||||
|
|
||||||
|
@Path("/api/enterprise/process-instances")
|
||||||
|
public interface ProcessInstancesApi {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes({ "application/json" })
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
ProcessInstance create(CreateProcessInstance processInstance);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{processInstanceId}")
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
ProcessInstance get(@PathParam("processInstanceId") String processInstanceId);
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("{processInstanceId}")
|
||||||
|
void delete(@PathParam("processInstanceId") String processInstanceId);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{processInstanceId}/activate")
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
ProcessInstance activate(@PathParam("processInstanceId") String processInstanceId);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{processInstanceId}/suspend")
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
ProcessInstance suspend(@PathParam("processInstanceId") String processInstanceId);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{processInstanceId}/variables")
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
List<Variable> getVariables(@PathParam("processInstanceId") String processInstanceId);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{processInstanceId}/variables")
|
||||||
|
@Consumes({ "application/json" })
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
List<Variable> setVariables(@PathParam("processInstanceId") String processInstanceId, List<Variable> variables);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{processInstanceId}/variables/{variableName}")
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
Variable getVariable(@PathParam("processInstanceId") String processInstanceId, @PathParam("variableName") String variableName);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{processInstanceId}/variables/{variableName}")
|
||||||
|
@Consumes({ "application/json" })
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
Variable setVariable(@PathParam("processInstanceId") String processInstanceId, @PathParam("variableName") String variableName, Variable variable);
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("{processInstanceId}/variables/{variableName}")
|
||||||
|
void deleteVariable(@PathParam("processInstanceId") String processInstanceId, @PathParam("variableName") String variableName);
|
||||||
|
|
||||||
|
}
|
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
package com.inteligr8.alfresco.activiti.api;
|
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.core.Response.Status.Family;
|
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.model.User;
|
|
||||||
|
|
||||||
public class ProfileAPI extends PathElement {
|
|
||||||
|
|
||||||
private final Client client;
|
|
||||||
|
|
||||||
public ProfileAPI(EnterpriseAPI api) {
|
|
||||||
super(api, "profile");
|
|
||||||
this.client = api.getClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public User get() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl())
|
|
||||||
.request()
|
|
||||||
.get();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(User.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
package com.inteligr8.alfresco.activiti.api;
|
||||||
|
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.activiti.model.User;
|
||||||
|
|
||||||
|
@Path("/api/enterprise/profile")
|
||||||
|
public interface ProfileApi {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
User get();
|
||||||
|
|
||||||
|
}
|
@@ -1,120 +0,0 @@
|
|||||||
|
|
||||||
package com.inteligr8.alfresco.activiti.api;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
import javax.ws.rs.client.Entity;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.core.Response.Status.Family;
|
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.ExtendedResponse;
|
|
||||||
import com.inteligr8.alfresco.activiti.model.Task;
|
|
||||||
import com.inteligr8.alfresco.activiti.model.TaskUpdate;
|
|
||||||
import com.inteligr8.alfresco.activiti.model.Variable;
|
|
||||||
|
|
||||||
public class TaskAPI extends PathElement {
|
|
||||||
|
|
||||||
private final Client client;
|
|
||||||
|
|
||||||
public TaskAPI(TasksAPI api, String taskId) throws UnsupportedEncodingException {
|
|
||||||
super(api, URLEncoder.encode(taskId, "utf-8"));
|
|
||||||
this.client = api.getClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Client getClient() {
|
|
||||||
return this.client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task update(TaskUpdate taskUpdate) {
|
|
||||||
Response response = this.client.target(this.getBaseUrl())
|
|
||||||
.request()
|
|
||||||
.put(Entity.json(taskUpdate));
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(Task.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Variable> getVariables(String scope) {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables")
|
|
||||||
.queryParam("scope", scope)
|
|
||||||
.request()
|
|
||||||
.get();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return new ExtendedResponse(response).readArrayEntity(Variable.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Variable> setVariables(List<Variable> variables) {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables")
|
|
||||||
.request()
|
|
||||||
.post(Entity.json(variables));
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return new ExtendedResponse(response).readArrayEntity(Variable.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteVariable(String variableName, String scope) throws UnsupportedEncodingException {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables/" + URLEncoder.encode(variableName, "utf-8"))
|
|
||||||
.queryParam("scope", scope)
|
|
||||||
.request()
|
|
||||||
.delete();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Variable getVariable(String variableName, String scope) throws UnsupportedEncodingException {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables/" + URLEncoder.encode(variableName, "utf-8"))
|
|
||||||
.queryParam("scope", scope)
|
|
||||||
.request()
|
|
||||||
.get();
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(Variable.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Variable setVariable(String variableName, Variable variable) throws UnsupportedEncodingException {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/variables/" + URLEncoder.encode(variableName, "utf-8"))
|
|
||||||
.request()
|
|
||||||
.put(Entity.json(variable));
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
return response.readEntity(Variable.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void claim() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/action/claim")
|
|
||||||
.request()
|
|
||||||
.put(null);
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unclaim() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/action/unclaim")
|
|
||||||
.request()
|
|
||||||
.put(null);
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void complete() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/action/complete")
|
|
||||||
.request()
|
|
||||||
.put(null);
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resolve() {
|
|
||||||
Response response = this.client.target(this.getBaseUrl() + "/action/resolve")
|
|
||||||
.request()
|
|
||||||
.put(null);
|
|
||||||
if (!Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily()))
|
|
||||||
throw new WebApplicationException(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
package com.inteligr8.alfresco.activiti.api;
|
|
||||||
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
|
|
||||||
public class TasksAPI extends PathElement {
|
|
||||||
|
|
||||||
private final Client client;
|
|
||||||
|
|
||||||
public TasksAPI(EnterpriseAPI api) {
|
|
||||||
super(api, "tasks");
|
|
||||||
this.client = api.getClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Client getClient() {
|
|
||||||
return this.client;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
package com.inteligr8.alfresco.activiti.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.activiti.model.Task;
|
||||||
|
import com.inteligr8.alfresco.activiti.model.TaskUpdate;
|
||||||
|
import com.inteligr8.alfresco.activiti.model.Variable;
|
||||||
|
|
||||||
|
@Path("/api/enterprise/tasks")
|
||||||
|
public interface TasksApi {
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{taskId}")
|
||||||
|
@Consumes({ "application/json" })
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
public Task update(@PathParam("taskId") String taskId, TaskUpdate taskUpdate);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{taskId}/variables")
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
List<Variable> getVariables(@PathParam("taskId") String taskId, @QueryParam("scope") String scope);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{taskId}/variables")
|
||||||
|
@Consumes({ "application/json" })
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
List<Variable> setVariables(@PathParam("taskId") String taskId, List<Variable> variables);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{taskId}/variables/{variableName}")
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
Variable getVariable(@PathParam("taskId") String taskId, @PathParam("variableName") String variableName, @QueryParam("scope") String scope);
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{taskId}/variables/{variableName}")
|
||||||
|
@Consumes({ "application/json" })
|
||||||
|
@Produces({ "application/json" })
|
||||||
|
Variable setVariable(@PathParam("taskId") String taskId, @PathParam("variableName") String variableName, Variable variable);
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("{taskId}/variables/{variableName}")
|
||||||
|
void deleteVariable(@PathParam("taskId") String taskId, @PathParam("variableName") String variableName, @QueryParam("scope") String scope);
|
||||||
|
|
||||||
|
}
|
@@ -1,60 +1,37 @@
|
|||||||
package com.inteligr8.alfresco.activiti;
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.http.HttpClient;
|
|
||||||
import java.net.http.HttpClient.Redirect;
|
|
||||||
import java.net.http.HttpRequest;
|
|
||||||
import java.net.http.HttpResponse;
|
|
||||||
import java.net.http.HttpResponse.BodyHandlers;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.EnabledIf;
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.test.context.TestPropertySource;
|
import org.springframework.test.context.TestPropertySource;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.model.Tenant;
|
import com.inteligr8.alfresco.activiti.model.Tenant;
|
||||||
|
import com.inteligr8.rs.ClientConfiguration;
|
||||||
|
|
||||||
@TestPropertySource(locations = {"/local.properties"})
|
@TestPropertySource(locations = {"/local.properties"})
|
||||||
@SpringJUnitConfig(classes = {ApsClientConfiguration.class, ApsClient.class})
|
@SpringJUnitConfig(classes = {ApsClientConfiguration.class, ApsPublicRestApiJerseyImpl.class, ApsClientJerseyImpl.class})
|
||||||
public class ArrayResponseUnitTest {
|
public class ArrayResponseUnitTest extends ConditionalIT {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApsClient client;
|
@Qualifier("aps.api.jersey")
|
||||||
|
private ApsPublicRestApi client;
|
||||||
|
|
||||||
@Autowired
|
@Override
|
||||||
private ApsClientConfiguration config;
|
public ClientConfiguration getConfiguration() {
|
||||||
|
return this.client.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnabledIf("hostExists")
|
@EnabledIf("hostExists")
|
||||||
public void testTenants() {
|
public void testTenants() {
|
||||||
List<Tenant> objs = this.client
|
List<Tenant> objs = this.client.getAdminApi().getTenants();
|
||||||
.getEnterpriseAPI()
|
|
||||||
.getAdminAPI()
|
|
||||||
.getTenants();
|
|
||||||
|
|
||||||
Assertions.assertNotNull(objs);
|
Assertions.assertNotNull(objs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hostExists() {
|
|
||||||
String baseUrl = this.config.getBaseUrl();
|
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.newBuilder(URI.create(baseUrl))
|
|
||||||
.GET()
|
|
||||||
.build();
|
|
||||||
|
|
||||||
HttpClient client = HttpClient.newBuilder()
|
|
||||||
.followRedirects(Redirect.ALWAYS)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
try {
|
|
||||||
HttpResponse<?> response = client.send(request, BodyHandlers.discarding());
|
|
||||||
return response.statusCode() < 300;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
|
import org.apache.http.client.methods.HttpUriRequest;
|
||||||
|
import org.apache.http.client.methods.RequestBuilder;
|
||||||
|
import org.apache.http.impl.client.DefaultRedirectStrategy;
|
||||||
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
|
||||||
|
import com.inteligr8.rs.ClientConfiguration;
|
||||||
|
|
||||||
|
public abstract class ConditionalIT {
|
||||||
|
|
||||||
|
public abstract ClientConfiguration getConfiguration();
|
||||||
|
|
||||||
|
public boolean hostExists() {
|
||||||
|
String uri = this.getConfiguration().getBaseUrl();
|
||||||
|
|
||||||
|
HttpUriRequest request = RequestBuilder.get()
|
||||||
|
.setUri(uri)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpClient client = HttpClientBuilder.create()
|
||||||
|
.setRedirectStrategy(DefaultRedirectStrategy.INSTANCE)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpResponse response = client.execute(request);
|
||||||
|
return response.getStatusLine().getStatusCode() < 300;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,54 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.activiti.model.AppVersion;
|
||||||
|
import com.inteligr8.alfresco.activiti.model.CreateProcessInstance;
|
||||||
|
import com.inteligr8.alfresco.activiti.model.ProcessInstance;
|
||||||
|
import com.inteligr8.alfresco.activiti.model.User;
|
||||||
|
import com.inteligr8.alfresco.activiti.model.Variable;
|
||||||
|
|
||||||
|
public abstract class ConnectionClientIT extends ConditionalIT {
|
||||||
|
|
||||||
|
public abstract ApsPublicRestApi getClient();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnabledIf("hostExists")
|
||||||
|
public void testAppVersion() {
|
||||||
|
AppVersion obj = this.getClient().getAppVersionApi().get();
|
||||||
|
|
||||||
|
Assertions.assertNotNull(obj);
|
||||||
|
Assertions.assertEquals("1", obj.getMajorVersion());
|
||||||
|
Assertions.assertEquals("bpmSuite", obj.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnabledIf("hostExists")
|
||||||
|
public void testProfile() {
|
||||||
|
User obj = this.getClient().getProfileApi().get();
|
||||||
|
|
||||||
|
Assertions.assertNotNull(obj);
|
||||||
|
Assertions.assertEquals("admin@app.activiti.com", obj.getEmail());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnabledIf("hostExists")
|
||||||
|
public void testStartProcess() {
|
||||||
|
CreateProcessInstance request = new CreateProcessInstance();
|
||||||
|
request.setProcessDefinitionKey("qcDocument");
|
||||||
|
request.setVariables(Arrays.asList(new Variable("acsNodeId", null, null, UUID.randomUUID().toString())));
|
||||||
|
|
||||||
|
ProcessInstance response = this.getClient().getProcessInstancesApi().create(request);
|
||||||
|
|
||||||
|
Assertions.assertNotNull(response);
|
||||||
|
Assertions.assertNotNull(response.getId());
|
||||||
|
Assertions.assertNotNull(response.getId().length() > 0);
|
||||||
|
Assertions.assertEquals("qcDocument", response.getProcessDefinitionKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,74 +0,0 @@
|
|||||||
package com.inteligr8.alfresco.activiti;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.http.HttpClient;
|
|
||||||
import java.net.http.HttpClient.Redirect;
|
|
||||||
import java.net.http.HttpRequest;
|
|
||||||
import java.net.http.HttpResponse;
|
|
||||||
import java.net.http.HttpResponse.BodyHandlers;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.condition.EnabledIf;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.test.context.TestPropertySource;
|
|
||||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.model.AppVersion;
|
|
||||||
import com.inteligr8.alfresco.activiti.model.User;
|
|
||||||
|
|
||||||
@TestPropertySource(locations = {"/local.properties"})
|
|
||||||
@SpringJUnitConfig(classes = {ApsClientConfiguration.class, ApsClient.class})
|
|
||||||
public class ConnectionClientUnitTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApsClient client;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApsClientConfiguration config;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@EnabledIf("hostExists")
|
|
||||||
public void testAppVersion() {
|
|
||||||
AppVersion obj = this.client
|
|
||||||
.getEnterpriseAPI()
|
|
||||||
.getAppVersionAPI()
|
|
||||||
.get();
|
|
||||||
|
|
||||||
Assertions.assertNotNull(obj);
|
|
||||||
Assertions.assertEquals("1", obj.getMajorVersion());
|
|
||||||
Assertions.assertEquals("bpmSuite", obj.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@EnabledIf("hostExists")
|
|
||||||
public void testProfile() {
|
|
||||||
User obj = this.client
|
|
||||||
.getEnterpriseAPI()
|
|
||||||
.getProfileAPI()
|
|
||||||
.get();
|
|
||||||
|
|
||||||
Assertions.assertNotNull(obj);
|
|
||||||
Assertions.assertEquals("admin@app.activiti.com", obj.getEmail());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hostExists() {
|
|
||||||
String baseUrl = this.config.getBaseUrl();
|
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.newBuilder(URI.create(baseUrl))
|
|
||||||
.GET()
|
|
||||||
.build();
|
|
||||||
|
|
||||||
HttpClient client = HttpClient.newBuilder()
|
|
||||||
.followRedirects(Redirect.ALWAYS)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
try {
|
|
||||||
HttpResponse<?> response = client.send(request, BodyHandlers.discarding());
|
|
||||||
return response.statusCode() < 300;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -0,0 +1,28 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.test.context.TestPropertySource;
|
||||||
|
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||||
|
|
||||||
|
import com.inteligr8.rs.ClientConfiguration;
|
||||||
|
|
||||||
|
@TestPropertySource(locations = {"/local.properties"})
|
||||||
|
@SpringJUnitConfig(classes = {ApsClientConfiguration.class, ApsPublicRestApiCxfImpl.class, ApsClientCxfImpl.class})
|
||||||
|
public class ConnectionCxfClientIT extends ConnectionClientIT {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("aps.api.cxf")
|
||||||
|
private ApsPublicRestApi client;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApsPublicRestApi getClient() {
|
||||||
|
return this.client;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientConfiguration getConfiguration() {
|
||||||
|
return this.client.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,27 @@
|
|||||||
|
package com.inteligr8.alfresco.activiti;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.test.context.TestPropertySource;
|
||||||
|
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||||
|
|
||||||
|
import com.inteligr8.rs.ClientConfiguration;
|
||||||
|
|
||||||
|
@TestPropertySource(locations = {"/local.properties"})
|
||||||
|
@SpringJUnitConfig(classes = {ApsClientConfiguration.class, ApsPublicRestApiCxfImpl.class, ApsClientJerseyImpl.class})
|
||||||
|
public class ConnectionJerseyClientIT extends ConnectionClientIT {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("aps.api.jersey")
|
||||||
|
private ApsPublicRestApi client;
|
||||||
|
|
||||||
|
public ApsPublicRestApi getClient() {
|
||||||
|
return this.client;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientConfiguration getConfiguration() {
|
||||||
|
return this.client.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
5
src/test/resources/local-oauth.properties
Normal file
5
src/test/resources/local-oauth.properties
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
process.service.baseUrl=http://localhost:8080/activiti-app
|
||||||
|
process.service.security.oauth.tokenUrl=http://auth.example.org:8080/auth/realms/alfresco/protocol/openid-connect/token
|
||||||
|
process.service.security.oauth.clientId=alfresco
|
||||||
|
process.service.security.oauth.grantUsername=admin
|
||||||
|
process.service.security.oauth.grantPassword=admin
|
Reference in New Issue
Block a user