Commit a358be79 authored by Brian Long's avatar Brian Long
Browse files

Merge branch 'develop' into stable

parents 8d2b2078 dc69d342
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
/*
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
package com.inteligr8.activiti;

import com.inteligr8.activiti.api.ManagementApi;

/**
 * This interface consolidates the JAX-RS APIs available in the open-source
 * Activiti Public ReST API.
 * 
 * @author brian@inteligr8.com
 */
public interface ActivitiPublicRestApi {
	
	<T> T getApi(Class<T> apiClass);
	
	default ManagementApi getManagementApi() {
		return this.getApi(ManagementApi.class);
	}
    
}
+173 −0
Original line number Diff line number Diff line
/*
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
package com.inteligr8.activiti.api;

import java.io.File;
import java.time.LocalDate;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.inteligr8.activiti.model.Engine;
import com.inteligr8.activiti.model.EngineProperties;
import com.inteligr8.activiti.model.ExecuteAction;
import com.inteligr8.activiti.model.ExecuteAction.Action;
import com.inteligr8.activiti.model.Job;
import com.inteligr8.activiti.model.ResultList;

@Path("/api/management")
public interface ManagementApi {
    
    public enum JobType {
        @JsonProperty("jobs")
        Job,
        @JsonProperty("deadletter-jobs")
        DeadletterJob
    }

    @GET
    @Path("engine")
    @Produces({ "application/json" })
    public Engine getEngine();

    @GET
    @Path("properties")
    @Produces({ "application/json" })
    public EngineProperties getEngineProperties();
    
    @GET
    @Path("{jobType}/{jobId}")
    @Produces({ "application/json" })
    public Job getJob(
            @PathParam("jobType") JobType jobType,
            @PathParam("jobId") String jobId);
    
    @DELETE
    @Path("{jobType}/{jobId}")
    public void deleteJob(
            @PathParam("jobType") JobType jobType,
            @PathParam("jobId") String jobId);
    
    @POST
    @Path("{jobType}/{jobId}")
    @Consumes({ "application/json" })
    public void executeJob(
            @PathParam("jobType") JobType jobType,
            @PathParam("jobId") String jobId,
            ExecuteAction execute);
    
    default void executeJob(
            JobType jobType,
            String jobId,
            Action action) {
        this.executeJob(jobType, jobId, new ExecuteAction(action));
    }
    
    default void executeJob(
            JobType jobType,
            String jobId) {
        this.executeJob(jobType, jobId, new ExecuteAction(Action.Execute));
    }
    
    @GET
    @Path("{jobType}/{jobId}/execution-stacktrace")
    @Produces({ "application/octet-stream" })
    public File getJobStacktrace(
            @PathParam("jobType") JobType jobType,
            @PathParam("jobId") String jobId);
    
    @GET
    @Path("{jobType}")
    @Produces({ "application/json" })
    public ResultList<Job> queryJobs(
            @PathParam("jobType") JobType jobType,
            @QueryParam("id") String jobId,
            @QueryParam("processInstanceId") String processInstanceId,
            @QueryParam("executionId") String executionId,
            @QueryParam("processDefinitionId") String processDefinitionId,
            @QueryParam("withRetriesLeft") Boolean withRetriesLeft,
            @QueryParam("executable") Boolean executable,
            @QueryParam("timersOnly") Boolean timersOnly,
            @QueryParam("messagesOnly") Boolean messagesOnly,
            @QueryParam("withException") Boolean withException,
            @QueryParam("dueBefore") LocalDate dueBefore,
            @QueryParam("dueAfter") LocalDate dueAfter,
            @QueryParam("exceptionMessage") String exceptionMessage,
            @QueryParam("withoutTenantId") Boolean withoutTenatId,
            @QueryParam("sort") String sort);
    
    @GET
    @Path("{jobType}")
    @Produces({ "application/json" })
    public ResultList<Job> queryJobs(
            @PathParam("jobType") JobType jobType,
            @QueryParam("id") String jobId,
            @QueryParam("processInstanceId") String processInstanceId,
            @QueryParam("executionId") String executionId,
            @QueryParam("processDefinitionId") String processDefinitionId,
            @QueryParam("withRetriesLeft") Boolean withRetriesLeft,
            @QueryParam("executable") Boolean executable,
            @QueryParam("timersOnly") Boolean timersOnly,
            @QueryParam("messagesOnly") Boolean messagesOnly,
            @QueryParam("withException") Boolean withException,
            @QueryParam("dueBefore") LocalDate dueBefore,
            @QueryParam("dueAfter") LocalDate dueAfter,
            @QueryParam("exceptionMessage") String exceptionMessage,
            @QueryParam("tenantId") String tenantId,
            @QueryParam("tenantIdLike") String tenantIdLike,
            @QueryParam("sort") String sort);

    default ResultList<Job> queryTimerJobs(
            JobType jobType,
            @QueryParam("id") String jobId,
            @QueryParam("processInstanceId") String processInstanceId,
            @QueryParam("executionId") String executionId,
            @QueryParam("processDefinitionId") String processDefinitionId,
            @QueryParam("withRetriesLeft") Boolean withRetriesLeft,
            @QueryParam("executable") Boolean executable,
            @QueryParam("withException") Boolean withException,
            @QueryParam("dueBefore") LocalDate dueBefore,
            @QueryParam("dueAfter") LocalDate dueAfter,
            @QueryParam("exceptionMessage") String exceptionMessage,
            @QueryParam("withoutTenantId") Boolean withoutTenantId,
            @QueryParam("sort") String sort) {
        return this.queryJobs(jobType, jobId, processInstanceId, executionId, processDefinitionId, withRetriesLeft, executable, true, false, withException, dueBefore, dueAfter, exceptionMessage, withoutTenantId, sort);
    }
    
    default ResultList<Job> queryMessagesJobs(
            JobType jobType,
            @QueryParam("id") String jobId,
            @QueryParam("processInstanceId") String processInstanceId,
            @QueryParam("executionId") String executionId,
            @QueryParam("processDefinitionId") String processDefinitionId,
            @QueryParam("withRetriesLeft") Boolean withRetriesLeft,
            @QueryParam("executable") Boolean executable,
            @QueryParam("withException") Boolean withException,
            @QueryParam("dueBefore") LocalDate dueBefore,
            @QueryParam("dueAfter") LocalDate dueAfter,
            @QueryParam("exceptionMessage") String exceptionMessage,
            @QueryParam("withoutTenantId") Boolean withoutTenantId,
            @QueryParam("sort") String sort) {
        return this.queryJobs(jobType, jobId, processInstanceId, executionId, processDefinitionId, withRetriesLeft, executable, false, true, withException, dueBefore, dueAfter, exceptionMessage, withoutTenantId, sort);
    }

}
+2 −5
Original line number Diff line number Diff line

package com.inteligr8.alfresco.activiti.model;
package com.inteligr8.activiti.model;

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({

})
public class Datum {

    @JsonIgnore
+76 −0
Original line number Diff line number Diff line
package com.inteligr8.activiti.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class Engine {

    @JsonProperty("name")
    private String name;
    @JsonProperty("version")
    private String version;
    @JsonProperty("resourceUrl")
    private String resourceUrl;
    @JsonProperty("exception")
    private String exception;

    /**
     * No args constructor for use in serialization
     */
    public Engine() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

	public Engine withName(String name) {
        this.name = name;
        return this;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

	public Engine withVersion(String version) {
        this.version = version;
        return this;
    }

    public String getResourceUrl() {
        return resourceUrl;
    }

    public void setResourceUrl(String resourceUrl) {
        this.resourceUrl = resourceUrl;
    }

	public Engine withResourceUrl(String resourceUrl) {
        this.resourceUrl = resourceUrl;
        return this;
    }

    public String getException() {
        return exception;
    }

    public void setException(String exception) {
        this.exception = exception;
    }

	public Engine withException(String exception) {
        this.exception = exception;
        return this;
    }

}
+61 −0
Original line number Diff line number Diff line
package com.inteligr8.activiti.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class EngineProperties {

    @JsonProperty("next.dbid")
    private String nextDbid;
    @JsonProperty("schema.history")
    private String schemaHistory;
    @JsonProperty("schema.version")
    private String schemaVersion;

    /**
     * No args constructor for use in serialization
     */
    public EngineProperties() {
    }

    public String getNextDbid() {
        return nextDbid;
    }

    public void setNextDbid(String nextDbid) {
        this.nextDbid = nextDbid;
    }

	public EngineProperties withNextDbid(String nextDbid) {
        this.nextDbid = nextDbid;
        return this;
    }

    public String getSchemaHistory() {
        return schemaHistory;
    }

    public void setSchemaHistory(String schemaHistory) {
        this.schemaHistory = schemaHistory;
    }

	public EngineProperties withSchemaHistory(String schemaHistory) {
        this.schemaHistory = schemaHistory;
        return this;
    }

    public String getSchemaVersion() {
        return schemaVersion;
    }

    public void setSchemaVersion(String schemaVersion) {
        this.schemaVersion = schemaVersion;
    }

	public EngineProperties withSchemaVersion(String schemaVersion) {
        this.schemaVersion = schemaVersion;
        return this;
    }

}
Loading