public RTaskResult call()

in src/main/java/com/revo/deployr/client/broker/worker/BackgroundTaskWorker.java [50:132]


    public RTaskResult call() throws RClientException,
            RSecurityException,
            RDataException {


        RTaskResult taskResult = null;
        RJob rJob = null;

        long timeOnCall = 0L;
        long timeOnServer = 0L;

        try {

            long startTime = System.currentTimeMillis();


            JobExecutionOptions options =
                    ROptionsTranslator.translate(task.options,
                            isPriorityTask);

            if (task.code != null) {
                rJob = rUser.submitJobCode(task.name,
                        task.description,
                        task.code,
                        options);
            } else if (task.external != null) {
                rJob = rUser.submitJobExternal(task.external,
                        task.description,
                        task.code,
                        options);
            } else {

                rJob = rUser.submitJobScript(task.name,
                        task.description,
                        task.filename,
                        task.directory,
                        task.author,
                        task.version,
                        options);
            }

            timeOnCall = System.currentTimeMillis() - startTime;

            taskResult = new RTaskResultImpl(rJob.about().id,
                    RTaskType.BACKGROUND,
                    true,
                    0L,
                    0L,
                    timeOnCall,
                    null);

        } catch (Exception ex) {

            if (ex.getCause() instanceof InterruptedException) {
                try {
                    /*
                     * If RTaskToken.cancel() call raises InterruptedException
                     * then ensure any corresponding scheduled RJob is
                     * also cancelled.
                     */
                    rJob.cancel();
                } catch (Exception iex) {
                }
            }

            taskResult = new RTaskResultImpl(null,
                    RTaskType.BACKGROUND,
                    false,
                    0L,
                    0L,
                    0L,
                    ex);
        } finally {

            /*
             * Callback to PooledTaskBroker to release
             * RProject back into pool for other tasks.
             */
            rBroker.callback(task, taskResult);
        }

        return taskResult;
    }