01: /*
02: * Copyright 2004 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.outerj.daisy.doctaskrunner.serverimpl;
17:
18: import org.outerj.daisy.doctaskrunner.*;
19: import org.outerj.daisy.doctaskrunner.commonimpl.TaskSpecificationImpl;
20: import org.outerj.daisy.doctaskrunner.commonimpl.QueryDocumentSelection;
21: import org.outerj.daisy.doctaskrunner.commonimpl.EnumerationDocumentSelection;
22: import org.outerj.daisy.doctaskrunner.commonimpl.SimpleActionsTaskSpecificationImpl;
23: import org.outerj.daisy.repository.Repository;
24: import org.outerj.daisy.repository.VariantKey;
25: import org.outerj.daisy.repository.user.Role;
26:
27: public class DocumentTaskManagerImpl implements DocumentTaskManager {
28: private final CommonDocumentTaskManager delegate;
29: private final Repository repository;
30:
31: public DocumentTaskManagerImpl(CommonDocumentTaskManager delegate,
32: Repository repository) {
33: this .delegate = delegate;
34: this .repository = repository;
35: }
36:
37: public long runTask(DocumentSelection documentSelection,
38: TaskSpecification taskSpecification) throws TaskException {
39: if (!(taskSpecification instanceof SimpleActionsTaskSpecificationImpl)
40: && !repository.isInRole(Role.ADMINISTRATOR))
41: throw new TaskException(
42: "Non-\"simple actions\" scripts can only be executed by Administrators.");
43:
44: return delegate.runTask(documentSelection, taskSpecification,
45: repository);
46: }
47:
48: public Task getTask(long id) throws TaskException {
49: return delegate.getTask(id, repository);
50: }
51:
52: public Tasks getTasks() throws TaskException {
53: return delegate.getTasks(repository);
54: }
55:
56: public void deleteTask(long id) throws TaskException {
57: delegate.deleteTask(id, repository);
58: }
59:
60: public void interruptTask(long id) throws TaskException {
61: delegate.interruptTask(id, repository);
62: }
63:
64: public TaskDocDetails getTaskDocDetails(long taskId)
65: throws TaskException {
66: return delegate.getTaskDocDetails(taskId, repository);
67: }
68:
69: public TaskSpecification createTaskSpecification(
70: String description, String script, String scriptLanguage,
71: boolean stopOnFirstError) {
72: return new TaskSpecificationImpl(description, script,
73: scriptLanguage, stopOnFirstError);
74: }
75:
76: public SimpleActionsTaskSpecification createSimpleActionsTaskSpecification(
77: String description, boolean stopOnFirstError) {
78: return new SimpleActionsTaskSpecificationImpl(description,
79: stopOnFirstError, repository);
80: }
81:
82: public DocumentSelection createQueryDocumentSelection(String query) {
83: return new QueryDocumentSelection(query);
84: }
85:
86: public DocumentSelection createEnumerationDocumentSelection(
87: VariantKey[] variantKeys) {
88: return new EnumerationDocumentSelection(variantKeys);
89: }
90: }
|