Class TasksResource
TaskManager tasks within the viewer, such as
PDF pre-rendering.- Author:
- Florian Alpers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTask(TaskParameter desc) Creates a task for the givenTaskParameter.getType()and starts it asynchronously.Returns a single task or message-queue job by id, provided the request is authorized to access it.getTasks()Returns the tasks held in memory by the viewer's task manager that the current request is authorized to see.booleanisAuthorized(ITaskType type, Optional<String> jobSessionId, HttpServletRequest request)
-
Constructor Details
-
TasksResource
-
-
Method Details
-
addTask
@POST @Consumes("application/json") @Produces("application/json") public Response addTask(TaskParameter desc) throws WebApplicationException Creates a task for the givenTaskParameter.getType()and starts it asynchronously.If the internal message queue broker is enabled in the configuration, which is the default, only the three task types that carry a dedicated
TaskParametersubtype are queued as aViewerMessageand processed by the message queue consumer (sitemap update, data repository name update, PDF pre-rendering); any other type is accepted but creates no task. With the broker disabled, the task runs as an in-memoryTaskon a fixed pool of five worker threads. The task type also determines, viaTask.getAccessibility(ITaskType), the authorization required to create it (token, admin or session, depending on the type).- Parameters:
desc- parameters describing the task to create, including its type- Returns:
- the created
TaskorViewerMessage - Throws:
WebApplicationException- if no task type is given, the caller is not authorized to create it, or the message queue rejects the task
-
getTask
@GET @Path("/{id}") @Produces("application/json") public Response getTask(@PathParam("id") String id) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException Returns a single task or message-queue job by id, provided the request is authorized to access it.A purely numeric id is looked up among the tasks held in memory by the viewer's task manager; any other id is treated as a message queue job id and looked up first via the message broker, then, if not found there, in the database. Authorization depends on the
Task.Accessibilityof the underlying task type: token tasks require the same authorization header as other protected endpoints, admin tasks require an active admin session, and session tasks are only visible to the session that created them.- Parameters:
id- the id of the task- Returns:
- the
TaskorViewerMessagewith the given id - Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException- if no task or job is found for the given id, or the request is not authorized to access it
-
getTasks
Returns the tasks held in memory by the viewer's task manager that the current request is authorized to see.Unlike
getTask(String), this only lists locally tracked tasks, not asynchronous message queue jobs. Visibility of each task depends on its accessibility: token tasks require the same authorization token as other protected endpoints, admin tasks require an active admin session, and session tasks are included only for the session that created them.- Returns:
- the list of tasks visible to the current request
-
isAuthorized
public boolean isAuthorized(ITaskType type, Optional<String> jobSessionId, HttpServletRequest request)
-