use of com.enonic.xp.task.TaskNotFoundException in project xp by enonic.
the class NamedTaskScriptFactoryImpl method doCreate.
private NamedTaskScript doCreate(final TaskDescriptor descriptor, final PropertyTree data) {
final ResourceKey scriptResourceKey = ResourceKey.from(descriptor.getApplicationKey(), TASKS_PATH_PREFIX + descriptor.getName() + "/" + descriptor.getName() + ".js");
final ScriptExports exports;
try {
exports = this.scriptService.execute(scriptResourceKey);
} catch (ResourceNotFoundException e) {
throw new TaskNotFoundException(descriptor.getKey(), "Missing task script");
}
final boolean exists = exports.hasMethod(NamedTaskScript.SCRIPT_METHOD_NAME);
if (!exists) {
throw new TaskNotFoundException(descriptor.getKey(), "Missing exported function '" + NamedTaskScript.SCRIPT_METHOD_NAME + "' in task script");
}
return new NamedTaskScript(exports, descriptor, data);
}
Aggregations