View Javadoc

1   package fr.in2p3.jsaga.impl.file;
2   
3   import fr.in2p3.jsaga.adaptor.data.DataAdaptor;
4   import fr.in2p3.jsaga.impl.namespace.AbstractNSDirectoryImpl;
5   import fr.in2p3.jsaga.impl.namespace.AbstractNSEntryImpl;
6   import fr.in2p3.jsaga.impl.task.AbstractThreadedTask;
7   import org.ogf.saga.buffer.Buffer;
8   import org.ogf.saga.error.*;
9   import org.ogf.saga.file.*;
10  import org.ogf.saga.session.Session;
11  import org.ogf.saga.task.Task;
12  import org.ogf.saga.task.TaskMode;
13  import org.ogf.saga.url.URL;
14  
15  import java.util.List;
16  
17  /* ***************************************************
18  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
19  * ***             http://cc.in2p3.fr/             ***
20  * ***************************************************
21  * File:   AbstractAsyncFileImpl
22  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
23  * Date:   18 sept. 2007
24  * ***************************************************
25  * Description:                                      */
26  /**
27   *
28   */
29  public abstract class AbstractAsyncFileImpl extends AbstractSyncFileImpl implements File {
30      /** constructor for factory */
31      protected AbstractAsyncFileImpl(Session session, URL url, DataAdaptor adaptor, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
32          super(session, url, adaptor, flags);
33      }
34  
35      /** constructor for NSDirectory.open() */
36      protected AbstractAsyncFileImpl(AbstractNSDirectoryImpl dir, URL relativeUrl, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
37          super(dir, relativeUrl, flags);
38      }
39  
40      /** constructor for NSEntry.openAbsolute() */
41      protected AbstractAsyncFileImpl(AbstractNSEntryImpl entry, String absolutePath, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
42          super(entry, absolutePath, flags);
43      }
44  
45      //////////////////////////////////////////// interface File ////////////////////////////////////////////
46  
47      public Task<File, Long> getSize(TaskMode mode) throws NotImplementedException {
48          return new AbstractThreadedTask<File,Long>(mode) {
49              public Long invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
50                  return AbstractAsyncFileImpl.super.getSizeSync();
51              }
52          };
53      }
54  
55      public Task<File, Integer> read(TaskMode mode, final Buffer buffer, final int offset, final int len) throws NotImplementedException {
56          return new AbstractThreadedTask<File,Integer>(mode) {
57              public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
58                  try {
59                      return AbstractAsyncFileImpl.super.readSync(buffer, offset, len);
60                  } catch (SagaIOException e) {
61                      throw new NoSuccessException(e);
62                  }
63              }
64          };
65      }
66      public Task<File, Integer> read(TaskMode mode, final Buffer buffer, final int len) throws NotImplementedException {
67          return new AbstractThreadedTask<File,Integer>(mode) {
68              public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
69                  try {
70                      return AbstractAsyncFileImpl.super.readSync(buffer, len);
71                  } catch (SagaIOException e) {
72                      throw new NoSuccessException(e);
73                  }
74              }
75          };
76      }
77      public Task<File, Integer> read(TaskMode mode, final Buffer buffer) throws NotImplementedException {
78          return new AbstractThreadedTask<File,Integer>(mode) {
79              public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
80                  try {
81                      return AbstractAsyncFileImpl.super.readSync(buffer);
82                  } catch (SagaIOException e) {
83                      throw new NoSuccessException(e);
84                  }
85              }
86          };
87      }
88  
89      public Task<File, Integer> write(TaskMode mode, final Buffer buffer, final int offset, final int len) throws NotImplementedException {
90          return new AbstractThreadedTask<File,Integer>(mode) {
91              public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
92                  try {
93                      return AbstractAsyncFileImpl.super.writeSync(buffer, offset, len);
94                  } catch (SagaIOException e) {
95                      throw new NoSuccessException(e);
96                  }
97              }
98          };
99      }
100     public Task<File, Integer> write(TaskMode mode, final Buffer buffer, final int len) throws NotImplementedException {
101         return new AbstractThreadedTask<File,Integer>(mode) {
102             public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
103                 try {
104                     return AbstractAsyncFileImpl.super.writeSync(buffer, len);
105                 } catch (SagaIOException e) {
106                     throw new NoSuccessException(e);
107                 }
108             }
109         };
110     }
111     public Task<File, Integer> write(TaskMode mode, final Buffer buffer) throws NotImplementedException {
112         return new AbstractThreadedTask<File,Integer>(mode) {
113             public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
114                 try {
115                     return AbstractAsyncFileImpl.super.writeSync(buffer);
116                 } catch (SagaIOException e) {
117                     throw new NoSuccessException(e);
118                 }
119             }
120         };
121     }
122 
123     public Task<File, Long> seek(TaskMode mode, final long offset, final SeekMode whence) throws NotImplementedException {
124         return new AbstractThreadedTask<File,Long>(mode) {
125             public Long invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
126                 try {
127                     return AbstractAsyncFileImpl.super.seekSync(offset, whence);
128                 } catch (SagaIOException e) {
129                     throw new NoSuccessException(e);
130                 }
131             }
132         };
133     }
134 
135     public Task<File, Void> readV(TaskMode mode, final IOVec[] iovecs) throws NotImplementedException {
136         return new AbstractThreadedTask<File,Void>(mode) {
137             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
138                 try {
139                     AbstractAsyncFileImpl.super.readVSync(iovecs);
140                     return null;
141                 } catch (SagaIOException e) {
142                     throw new NoSuccessException(e);
143                 }
144             }
145         };
146     }
147 
148     public Task<File, Void> writeV(TaskMode mode, final IOVec[] iovecs) throws NotImplementedException {
149         return new AbstractThreadedTask<File,Void>(mode) {
150             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
151                 try {
152                     AbstractAsyncFileImpl.super.writeVSync(iovecs);
153                     return null;
154                 } catch (SagaIOException e) {
155                     throw new NoSuccessException(e);
156                 }
157             }
158         };
159     }
160 
161     public Task<File, Integer> sizeP(TaskMode mode, final String pattern) throws NotImplementedException {
162         return new AbstractThreadedTask<File,Integer>(mode) {
163             public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
164                 return AbstractAsyncFileImpl.super.sizePSync(pattern);
165             }
166         };
167     }
168 
169     public Task<File, Integer> readP(TaskMode mode, final String pattern, final Buffer buffer) throws NotImplementedException {
170         return new AbstractThreadedTask<File,Integer>(mode) {
171             public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
172                 try {
173                     return AbstractAsyncFileImpl.super.readPSync(pattern, buffer);
174                 } catch (SagaIOException e) {
175                     throw new NoSuccessException(e);
176                 }
177             }
178         };
179     }
180 
181     public Task<File, Integer> writeP(TaskMode mode, final String pattern, final Buffer buffer) throws NotImplementedException {
182         return new AbstractThreadedTask<File,Integer>(mode) {
183             public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
184                 try {
185                     return AbstractAsyncFileImpl.super.writePSync(pattern, buffer);
186                 } catch (SagaIOException e) {
187                     throw new NoSuccessException(e);
188                 }
189             }
190         };
191     }
192 
193     public Task<File, List<String>> modesE(TaskMode mode) throws NotImplementedException {
194         return new AbstractThreadedTask<File,List<String>>(mode) {
195             public List<String> invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
196                 return AbstractAsyncFileImpl.super.modesESync();
197             }
198         };
199     }
200 
201     public Task<File, Integer> sizeE(TaskMode mode, final String emode, final String spec) throws NotImplementedException {
202         return new AbstractThreadedTask<File,Integer>(mode) {
203             public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
204                 return AbstractAsyncFileImpl.super.sizeESync(emode, spec);
205             }
206         };
207     }
208 
209     public Task<File, Integer> readE(TaskMode mode, final String emode, final String spec, final Buffer buffer) throws NotImplementedException {
210         return new AbstractThreadedTask<File,Integer>(mode) {
211             public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
212                 try {
213                     return AbstractAsyncFileImpl.super.readESync(emode, spec, buffer);
214                 } catch (SagaIOException e) {
215                     throw new NoSuccessException(e);
216                 }
217             }
218         };
219     }
220 
221     public Task<File, Integer> writeE(TaskMode mode, final String emode, final String spec, final Buffer buffer) throws NotImplementedException {
222         return new AbstractThreadedTask<File,Integer>(mode) {
223             public Integer invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
224                 try {
225                     return AbstractAsyncFileImpl.super.writeESync(emode, spec, buffer);
226                 } catch (SagaIOException e) {
227                     throw new NoSuccessException(e);
228                 }
229             }
230         };
231     }
232 }