package org.jenkinsci.plugins.p4.groovy;

import hudson.FilePath.FileCallable;
import hudson.model.TaskListener;
import hudson.remoting.VirtualChannel;
import jenkins.security.Roles;
import org.jenkinsci.plugins.p4.workspace.Workspace;
import org.jenkinsci.remoting.RoleChecker;
import org.jenkinsci.remoting.RoleSensitive;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;

public class GetP4Task implements FileCallable<P4Groovy>, Serializable {

	private static final long serialVersionUID = 1L;

	private final String credential;
	private final Workspace workspace;

	private final TaskListener listener;

	public GetP4Task(String credential, Workspace workspace, TaskListener listener) {
		this.credential = credential;
		this.workspace = workspace;
		this.listener = listener;
	}

	@Override
	public P4Groovy invoke(File buildWorkspace, VirtualChannel channel) throws IOException, InterruptedException {
		P4Groovy p4Groovy = new P4Groovy(credential, listener, workspace);
		return p4Groovy;
	}

	@Override
	public void checkRoles(RoleChecker checker) throws SecurityException {
		checker.check((RoleSensitive) this, Roles.SLAVE);
	}
}

@@ -53,325 +53,128 @@
 son.
-FilePath.FileCallable;%0Aimport hudson.model.TaskListener;%0Aimport hudson.remoting.VirtualChannel;%0Aimport jenkins.security.Roles;%0Aimport org.jenkinsci.plugins.p4.workspace.Workspace;%0Aimport org.jenkinsci.remoting.RoleChecker;%0Aimport org.jenkinsci.remoting.RoleSensitive;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;
+model.TaskListener;%0Aimport jenkins.security.MasterToSlaveCallable;%0Aimport org.jenkinsci.plugins.p4.workspace.Workspace;%0A
 %0Aimp
@@ -227,22 +227,28 @@
 ask 
-implements Fil
+extends MasterToSlav
 eCal
@@ -265,10 +265,42 @@
 oovy
-%3E
 ,
+ InterruptedException%3E implements
  Ser
@@ -682,79 +682,21 @@
 ovy 
-invoke(File buildWorkspace, VirtualChannel channel) throws IOException,
+call() throws
  Int
@@ -809,146 +809,7 @@
 ;%0A%09%7D
-%0A%0A%09@Override%0A%09public void checkRoles(RoleChecker checker) throws SecurityException %7B%0A%09%09checker.check((RoleSensitive) this, Roles.SLAVE);%0A%09%7D
 %0A%7D%0A

Replace FileCallable and checkRoles with MasterToSlaveCallable.