1 package fr.in2p3.jsaga.impl.namespace;
2
3 import fr.in2p3.jsaga.adaptor.data.DataAdaptor;
4 import org.ogf.saga.error.*;
5 import org.ogf.saga.namespace.NSEntry;
6 import org.ogf.saga.session.Session;
7 import org.ogf.saga.task.TaskMode;
8 import org.ogf.saga.url.URL;
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public abstract class AbstractNSEntryImpl extends AbstractAsyncNSEntryImpl implements NSEntry {
23
24 protected AbstractNSEntryImpl(Session session, URL url, DataAdaptor adaptor, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, TimeoutException, NoSuccessException {
25 super(session, url, adaptor, flags);
26 }
27
28
29 protected AbstractNSEntryImpl(AbstractNSDirectoryImpl dir, URL relativeUrl, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, TimeoutException, NoSuccessException {
30 super(dir, relativeUrl, flags);
31 }
32
33
34 protected AbstractNSEntryImpl(AbstractNSEntryImpl entry, String absolutePath, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, TimeoutException, NoSuccessException {
35 super(entry, absolutePath, flags);
36 }
37
38
39
40 public URL getURL() throws NotImplementedException, IncorrectStateException, TimeoutException, NoSuccessException {
41 float timeout = this.getTimeout("getURL");
42 if (timeout == WAIT_FOREVER) {
43 return super.getURLSync();
44 } else {
45 try {
46 return (URL) getResult(super.getURL(TaskMode.ASYNC), timeout);
47 }
48 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
49 catch (AuthenticationFailedException e) {throw new NoSuccessException(e);}
50 catch (AuthorizationFailedException e) {throw new NoSuccessException(e);}
51 catch (PermissionDeniedException e) {throw new NoSuccessException(e);}
52 catch (BadParameterException e) {throw new NoSuccessException(e);}
53 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
54 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
55 catch (SagaIOException e) {throw new NoSuccessException(e);}
56 }
57 }
58
59 public URL getCWD() throws NotImplementedException, IncorrectStateException, TimeoutException, NoSuccessException {
60 float timeout = this.getTimeout("getCWD");
61 if (timeout == WAIT_FOREVER) {
62 return super.getCWDSync();
63 } else {
64 try {
65 return (URL) getResult(super.getCWD(TaskMode.ASYNC), timeout);
66 }
67 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
68 catch (AuthenticationFailedException e) {throw new NoSuccessException(e);}
69 catch (AuthorizationFailedException e) {throw new NoSuccessException(e);}
70 catch (PermissionDeniedException e) {throw new NoSuccessException(e);}
71 catch (BadParameterException e) {throw new NoSuccessException(e);}
72 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
73 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
74 catch (SagaIOException e) {throw new NoSuccessException(e);}
75 }
76 }
77
78 public URL getName() throws NotImplementedException, IncorrectStateException, TimeoutException, NoSuccessException {
79 float timeout = this.getTimeout("getName");
80 if (timeout == WAIT_FOREVER) {
81 return super.getNameSync();
82 } else {
83 try {
84 return (URL) getResult(super.getName(TaskMode.ASYNC), timeout);
85 }
86 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
87 catch (AuthenticationFailedException e) {throw new NoSuccessException(e);}
88 catch (AuthorizationFailedException e) {throw new NoSuccessException(e);}
89 catch (PermissionDeniedException e) {throw new NoSuccessException(e);}
90 catch (BadParameterException e) {throw new NoSuccessException(e);}
91 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
92 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
93 catch (SagaIOException e) {throw new NoSuccessException(e);}
94 }
95 }
96
97 public boolean isDir() throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, IncorrectStateException, TimeoutException, NoSuccessException {
98 float timeout = this.getTimeout("isDir");
99 if (timeout == WAIT_FOREVER) {
100 return super.isDirSync();
101 } else {
102 try {
103 return (Boolean) getResult(super.isDir(TaskMode.ASYNC), timeout);
104 }
105 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
106 catch (BadParameterException e) {throw new NoSuccessException(e);}
107 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
108 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
109 catch (SagaIOException e) {throw new NoSuccessException(e);}
110 }
111 }
112
113 public boolean isEntry() throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, IncorrectStateException, TimeoutException, NoSuccessException {
114 float timeout = this.getTimeout("isEntry");
115 if (timeout == WAIT_FOREVER) {
116 return super.isEntrySync();
117 } else {
118 try {
119 return (Boolean) getResult(super.isEntry(TaskMode.ASYNC), timeout);
120 }
121 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
122 catch (BadParameterException e) {throw new NoSuccessException(e);}
123 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
124 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
125 catch (SagaIOException e) {throw new NoSuccessException(e);}
126 }
127 }
128
129 public boolean isLink() throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, IncorrectStateException, TimeoutException, NoSuccessException {
130 float timeout = this.getTimeout("isLink");
131 if (timeout == WAIT_FOREVER) {
132 return super.isLinkSync();
133 } else {
134 try {
135 return (Boolean) getResult(super.isLink(TaskMode.ASYNC), timeout);
136 }
137 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
138 catch (BadParameterException e) {throw new NoSuccessException(e);}
139 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
140 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
141 catch (SagaIOException e) {throw new NoSuccessException(e);}
142 }
143 }
144
145 public URL readLink() throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, IncorrectStateException, TimeoutException, NoSuccessException {
146 float timeout = this.getTimeout("readLink");
147 if (timeout == WAIT_FOREVER) {
148 return super.readLinkSync();
149 } else {
150 try {
151 return (URL) getResult(super.readLink(TaskMode.ASYNC), timeout);
152 }
153 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
154 catch (BadParameterException e) {throw new NoSuccessException(e);}
155 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
156 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
157 catch (SagaIOException e) {throw new NoSuccessException(e);}
158 }
159 }
160
161 public long getMTime() throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, IncorrectStateException, TimeoutException, NoSuccessException {
162 float timeout = this.getTimeout("getMTime");
163 if (timeout == WAIT_FOREVER) {
164 return super.getMTimeSync();
165 } else {
166 try {
167 return (Long) getResult(super.getMTime(TaskMode.ASYNC), timeout);
168 }
169 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
170 catch (BadParameterException e) {throw new NoSuccessException(e);}
171 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
172 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
173 catch (SagaIOException e) {throw new NoSuccessException(e);}
174 }
175 }
176
177 public void copy(URL target, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException, IncorrectURLException {
178 float timeout = this.getTimeout("copy");
179 if (timeout == WAIT_FOREVER) {
180
181 this.copySync(target, flags);
182 } else {
183 try {
184 getResult(super.copy(TaskMode.ASYNC, target, flags), timeout);
185 }
186 catch (SagaIOException e) {throw new NoSuccessException(e);}
187 }
188 }
189
190 public void copy(URL target) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException, IncorrectURLException {
191 float timeout = this.getTimeout("copy");
192 if (timeout == WAIT_FOREVER) {
193 super.copySync(target);
194 } else {
195 try {
196 getResult(super.copy(TaskMode.ASYNC, target), timeout);
197 }
198 catch (SagaIOException e) {throw new NoSuccessException(e);}
199 }
200 }
201
202 public void copyFrom(URL source, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException, IncorrectURLException {
203 float timeout = this.getTimeout("copyFrom");
204 if (timeout == WAIT_FOREVER) {
205
206 this.copyFromSync(source, flags);
207 } else {
208 try {
209 getResult(super.copyFrom(TaskMode.ASYNC, source, flags), timeout);
210 }
211 catch (SagaIOException e) {throw new NoSuccessException(e);}
212 }
213 }
214
215 public void copyFrom(URL source) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException, IncorrectURLException {
216 float timeout = this.getTimeout("copyFrom");
217 if (timeout == WAIT_FOREVER) {
218 super.copyFromSync(source);
219 } else {
220 try {
221 getResult(super.copyFrom(TaskMode.ASYNC, source), timeout);
222 }
223 catch (SagaIOException e) {throw new NoSuccessException(e);}
224 }
225 }
226
227 public void link(URL target, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException, IncorrectURLException {
228 float timeout = this.getTimeout("link");
229 if (timeout == WAIT_FOREVER) {
230 super.linkSync(target, flags);
231 } else {
232 try {
233 getResult(super.link(TaskMode.ASYNC, target, flags), timeout);
234 }
235 catch (SagaIOException e) {throw new NoSuccessException(e);}
236 }
237 }
238
239 public void link(URL target) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException, IncorrectURLException {
240 float timeout = this.getTimeout("link");
241 if (timeout == WAIT_FOREVER) {
242 super.linkSync(target);
243 } else {
244 try {
245 getResult(super.link(TaskMode.ASYNC, target), timeout);
246 }
247 catch (SagaIOException e) {throw new NoSuccessException(e);}
248 }
249 }
250
251 public void move(URL target, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException, IncorrectURLException {
252 float timeout = this.getTimeout("move");
253 if (timeout == WAIT_FOREVER) {
254 super.moveSync(target, flags);
255 } else {
256 try {
257 getResult(super.move(TaskMode.ASYNC, target, flags), timeout);
258 }
259 catch (SagaIOException e) {throw new NoSuccessException(e);}
260 }
261 }
262
263 public void move(URL target) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException, IncorrectURLException {
264 float timeout = this.getTimeout("move");
265 if (timeout == WAIT_FOREVER) {
266 super.moveSync(target);
267 } else {
268 try {
269 getResult(super.move(TaskMode.ASYNC, target), timeout);
270 }
271 catch (SagaIOException e) {throw new NoSuccessException(e);}
272 }
273 }
274
275 public void remove(int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, TimeoutException, NoSuccessException {
276 float timeout = this.getTimeout("remove");
277 if (timeout == WAIT_FOREVER) {
278 super.removeSync(flags);
279 } else {
280 try {
281 getResult(super.remove(TaskMode.ASYNC, flags), timeout);
282 }
283 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
284 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
285 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
286 catch (SagaIOException e) {throw new NoSuccessException(e);}
287 }
288 }
289
290 public void remove() throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, TimeoutException, NoSuccessException {
291 float timeout = this.getTimeout("remove");
292 if (timeout == WAIT_FOREVER) {
293 super.removeSync();
294 } else {
295 try {
296 getResult(super.remove(TaskMode.ASYNC), timeout);
297 }
298 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
299 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
300 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
301 catch (SagaIOException e) {throw new NoSuccessException(e);}
302 }
303 }
304
305 public void close() throws NotImplementedException, NoSuccessException {
306 if (this.getTimeout("close") != WAIT_FOREVER) {
307 throw new NotImplementedException("Configuring user timeout is not supported for method: close");
308 }
309
310 super.close();
311 }
312
313 public void close(float timeoutInSeconds) throws NotImplementedException, NoSuccessException {
314 if (this.getTimeout("close") != WAIT_FOREVER) {
315 throw new NotImplementedException("Configuring user timeout is not supported for method: close");
316 }
317
318 if (timeoutInSeconds == WAIT_FOREVER) {
319 super.close();
320 } else if (timeoutInSeconds == NO_WAIT) {
321 super.close(TaskMode.ASYNC);
322 } else {
323 try {
324 getResult(super.close(TaskMode.ASYNC), timeoutInSeconds);
325 }
326 catch (TimeoutException e) {throw new NoSuccessException(e);}
327 catch (BadParameterException e) {throw new NoSuccessException(e);}
328 catch (SagaIOException e) {throw new NoSuccessException(e);}
329 catch (AuthorizationFailedException e) {throw new NoSuccessException(e);}
330 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
331 catch (PermissionDeniedException e) {throw new NoSuccessException(e);}
332 catch (IncorrectStateException e) {throw new NoSuccessException(e);}
333 catch (AuthenticationFailedException e) {throw new NoSuccessException(e);}
334 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
335 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
336 }
337 }
338
339 public void permissionsAllow(String id, int permissions, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, IncorrectStateException, BadParameterException, TimeoutException, NoSuccessException {
340 float timeout = this.getTimeout("permissionsAllow");
341 if (timeout == WAIT_FOREVER) {
342 super.permissionsAllowSync(id, permissions, flags);
343 } else {
344 try {
345 getResult(super.permissionsAllow(TaskMode.ASYNC, id, permissions, flags), timeout);
346 }
347 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
348 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
349 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
350 catch (SagaIOException e) {throw new NoSuccessException(e);}
351 }
352 }
353
354 public void permissionsDeny(String id, int permissions, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, IncorrectStateException, PermissionDeniedException, BadParameterException, TimeoutException, NoSuccessException {
355 float timeout = this.getTimeout("permissionsDeny");
356 if (timeout == WAIT_FOREVER) {
357 super.permissionsDenySync(id, permissions, flags);
358 } else {
359 try {
360 getResult(super.permissionsDeny(TaskMode.ASYNC, id, permissions, flags), timeout);
361 }
362 catch (IncorrectURLException e) {throw new NoSuccessException(e);}
363 catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
364 catch (DoesNotExistException e) {throw new NoSuccessException(e);}
365 catch (SagaIOException e) {throw new NoSuccessException(e);}
366 }
367 }
368
369
370
371 private float getTimeout(String methodName) throws NoSuccessException {
372 return getTimeout(NSEntry.class, methodName, m_url.getScheme());
373 }
374 }