Search in sources :

Example 1 with WorkflowServiceImpl

use of org.opencastproject.workflow.impl.WorkflowServiceImpl in project opencast by opencast.

the class WorkflowRestService method getOperationHandlers.

@GET
@Path("handlers.json")
@SuppressWarnings("unchecked")
@RestQuery(name = "handlers", description = "List all registered workflow operation handlers (implementations).", returnDescription = "A JSON representation of the registered workflow operation handlers.", reponses = { @RestResponse(responseCode = SC_OK, description = "A JSON representation of the registered workflow operation handlers") })
public Response getOperationHandlers() {
    JSONArray jsonArray = new JSONArray();
    for (HandlerRegistration reg : ((WorkflowServiceImpl) service).getRegisteredHandlers()) {
        WorkflowOperationHandler handler = reg.getHandler();
        JSONObject jsonHandler = new JSONObject();
        jsonHandler.put("id", handler.getId());
        jsonHandler.put("description", handler.getDescription());
        JSONObject jsonConfigOptions = new JSONObject();
        for (Entry<String, String> configEntry : handler.getConfigurationOptions().entrySet()) {
            jsonConfigOptions.put(configEntry.getKey(), configEntry.getValue());
        }
        jsonHandler.put("options", jsonConfigOptions);
        jsonArray.add(jsonHandler);
    }
    return Response.ok(jsonArray.toJSONString()).header("Content-Type", MediaType.APPLICATION_JSON).build();
}
Also used : HandlerRegistration(org.opencastproject.workflow.impl.WorkflowServiceImpl.HandlerRegistration) JSONObject(org.json.simple.JSONObject) WorkflowOperationHandler(org.opencastproject.workflow.api.WorkflowOperationHandler) JSONArray(org.json.simple.JSONArray) WorkflowServiceImpl(org.opencastproject.workflow.impl.WorkflowServiceImpl) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) RestQuery(org.opencastproject.util.doc.rest.RestQuery)

Aggregations

GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 JSONArray (org.json.simple.JSONArray)1 JSONObject (org.json.simple.JSONObject)1 RestQuery (org.opencastproject.util.doc.rest.RestQuery)1 WorkflowOperationHandler (org.opencastproject.workflow.api.WorkflowOperationHandler)1 WorkflowServiceImpl (org.opencastproject.workflow.impl.WorkflowServiceImpl)1 HandlerRegistration (org.opencastproject.workflow.impl.WorkflowServiceImpl.HandlerRegistration)1