1 package fr.in2p3.jsaga.adaptor.job;
2
3 import fr.in2p3.jsaga.Base;
4 import fr.in2p3.jsaga.adaptor.ClientAdaptor;
5 import fr.in2p3.jsaga.adaptor.base.defaults.Default;
6 import fr.in2p3.jsaga.adaptor.base.usage.Usage;
7 import fr.in2p3.jsaga.adaptor.security.SecurityCredential;
8 import org.ogf.saga.error.*;
9
10 import java.io.File;
11 import java.util.Map;
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public abstract class EmulatorJobAdaptorAbstract implements ClientAdaptor {
26 private static final File STATUS_DIR = new File(Base.JSAGA_VAR, "JobEmulator");
27
28 public String getType() {
29 return "test";
30 }
31
32 public Usage getUsage() {return null;}
33 public Default[] getDefaults(Map attributes) throws IncorrectStateException {return null;}
34 public Class[] getSupportedSecurityCredentialClasses() {return null;}
35 public void setSecurityCredential(SecurityCredential credential) {}
36
37 public void connect(String userInfo, String host, int port, String basePath, Map attributes) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, BadParameterException, TimeoutException, NoSuccessException {
38 if (! STATUS_DIR.exists()) {
39 STATUS_DIR.mkdir();
40 }
41 }
42
43 public void disconnect() throws NoSuccessException {
44 if (STATUS_DIR.list().length == 0) {
45 STATUS_DIR.delete();
46 }
47 }
48
49 protected File getJob(String nativeJobId) {
50 return new File(STATUS_DIR, nativeJobId);
51 }
52 }