1 package fr.in2p3.jsaga.impl.job.streaming;
2
3 import java.io.FileInputStream;
4 import java.io.FileNotFoundException;
5 import java.io.FileOutputStream;
6 import java.io.InputStream;
7 import java.io.OutputStream;
8
9 import org.ogf.saga.error.NoSuccessException;
10 import org.ogf.saga.error.PermissionDeniedException;
11 import org.ogf.saga.error.TimeoutException;
12
13 import fr.in2p3.jsaga.adaptor.job.control.interactive.JobIOGetterInteractive;
14
15
16
17
18
19
20
21
22
23
24
25
26 public class GenericJobIOHandler implements JobIOGetterInteractive {
27
28 private String m_jobId;
29 private String m_uniqId;
30
31 public GenericJobIOHandler(String jobId, String uniqId) {
32 m_jobId = jobId;
33 m_uniqId = uniqId;
34 }
35
36 public String getJobId() {
37 return m_jobId;
38 }
39
40 public InputStream getStdout() throws PermissionDeniedException,
41 TimeoutException, NoSuccessException {
42 try {
43 return new FileInputStream(LocalFileFactory.getLocalOutputFile(m_uniqId));
44 } catch (FileNotFoundException e) {
45 throw new NoSuccessException(e);
46 }
47 }
48
49 public InputStream getStderr() throws PermissionDeniedException,
50 TimeoutException, NoSuccessException {
51 try {
52 return new FileInputStream(LocalFileFactory.getLocalErrorFile(m_uniqId));
53 } catch (FileNotFoundException e) {
54 throw new NoSuccessException(e);
55 }
56 }
57
58 public OutputStream getStdin() throws PermissionDeniedException,
59 TimeoutException, NoSuccessException {
60 try {
61 return new FileOutputStream(LocalFileFactory.getLocalInputFile(m_uniqId));
62 } catch (FileNotFoundException e) {
63 throw new NoSuccessException(e);
64 }
65 }
66
67 }