View Javadoc

1   package fr.in2p3.jsaga.impl.namespace;
2   
3   import fr.in2p3.jsaga.adaptor.data.DataAdaptor;
4   import fr.in2p3.jsaga.impl.file.AbstractSyncDirectoryImpl;
5   import fr.in2p3.jsaga.impl.file.AbstractSyncFileImpl;
6   import fr.in2p3.jsaga.impl.file.copy.AbstractCopyFromTask;
7   import fr.in2p3.jsaga.impl.file.copy.AbstractCopyTask;
8   import fr.in2p3.jsaga.impl.task.AbstractThreadedTask;
9   import org.ogf.saga.error.*;
10  import org.ogf.saga.namespace.Flags;
11  import org.ogf.saga.namespace.NSEntry;
12  import org.ogf.saga.session.Session;
13  import org.ogf.saga.task.Task;
14  import org.ogf.saga.task.TaskMode;
15  import org.ogf.saga.url.URL;
16  
17  /* ***************************************************
18  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
19  * ***             http://cc.in2p3.fr/             ***
20  * ***************************************************
21  * File:   AbstractAsyncNSEntryImpl
22  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
23  * Date:   17 sept. 2007
24  * ***************************************************
25  * Description:                                      */
26  /**
27   *
28   */
29  public abstract class AbstractAsyncNSEntryImpl extends AbstractSyncNSEntryImpl implements NSEntry {
30      /** constructor for factory */
31      protected AbstractAsyncNSEntryImpl(Session session, URL url, DataAdaptor adaptor, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, TimeoutException, NoSuccessException {
32          super(session, url, adaptor, flags);
33      }
34  
35      /** constructor for NSDirectory.open() */
36      protected AbstractAsyncNSEntryImpl(AbstractNSDirectoryImpl dir, URL relativeUrl, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, TimeoutException, NoSuccessException {
37          super(dir, relativeUrl, flags);
38      }
39  
40      /** constructor for NSEntry.openAbsolute() */
41      protected AbstractAsyncNSEntryImpl(AbstractNSEntryImpl entry, String absolutePath, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, TimeoutException, NoSuccessException {
42          super(entry, absolutePath, flags);
43      }
44  
45      //////////////////////////////////////////// interface NSEntry ////////////////////////////////////////////
46  
47      public Task<NSEntry, URL> getURL(TaskMode mode) throws NotImplementedException {
48          return new AbstractThreadedTask<NSEntry,URL>(mode) {
49              public URL invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
50                  return AbstractAsyncNSEntryImpl.super.getURLSync();
51              }
52          };
53      }
54  
55      public Task<NSEntry, URL> getCWD(TaskMode mode) throws NotImplementedException {
56          return new AbstractThreadedTask<NSEntry,URL>(mode) {
57              public URL invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
58                  return AbstractAsyncNSEntryImpl.super.getCWDSync();
59              }
60          };
61      }
62  
63      public Task<NSEntry, URL> getName(TaskMode mode) throws NotImplementedException {
64          return new AbstractThreadedTask<NSEntry,URL>(mode) {
65              public URL invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
66                  return AbstractAsyncNSEntryImpl.super.getNameSync();
67              }
68          };
69      }
70  
71      public Task<NSEntry, Long> getMTime(TaskMode mode) throws NotImplementedException {
72          return new AbstractThreadedTask<NSEntry,Long>(mode) {
73              public Long invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
74                  return AbstractAsyncNSEntryImpl.super.getMTimeSync();
75              }
76          };
77      }
78  
79      public Task<NSEntry, Boolean> isDir(TaskMode mode) throws NotImplementedException {
80          return new AbstractThreadedTask<NSEntry,Boolean>(mode) {
81              public Boolean invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
82                  return AbstractAsyncNSEntryImpl.super.isDirSync();
83              }
84          };
85      }
86  
87      public Task<NSEntry, Boolean> isEntry(TaskMode mode) throws NotImplementedException {
88          return new AbstractThreadedTask<NSEntry,Boolean>(mode) {
89              public Boolean invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
90                  return AbstractAsyncNSEntryImpl.super.isEntrySync();
91              }
92          };
93      }
94  
95      public Task<NSEntry, Boolean> isLink(TaskMode mode) throws NotImplementedException {
96          return new AbstractThreadedTask<NSEntry,Boolean>(mode) {
97              public Boolean invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
98                  return AbstractAsyncNSEntryImpl.super.isLinkSync();
99              }
100         };
101     }
102 
103     public Task<NSEntry, URL> readLink(TaskMode mode) throws NotImplementedException {
104         return new AbstractThreadedTask<NSEntry,URL>(mode) {
105             public URL invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
106                 return AbstractAsyncNSEntryImpl.super.readLinkSync();
107             }
108         };
109     }
110 
111     public Task<NSEntry, Void> copy(TaskMode mode, final URL target, final int flags) throws NotImplementedException {
112         if (this instanceof AbstractSyncFileImpl) {
113             final AbstractSyncFileImpl source = (AbstractSyncFileImpl) this;
114             return new AbstractCopyTask<NSEntry,Void>(mode, m_session, target, flags) {
115                 public void doCopy(URL target, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, DoesNotExistException, AlreadyExistsException, TimeoutException, NoSuccessException, IncorrectURLException {
116                     source._copyAndMonitor(target, flags, this);
117                 }
118             };
119         } else {
120             return new AbstractThreadedTask<NSEntry,Void>(mode) {
121                 public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
122                     AbstractAsyncNSEntryImpl.this.copySync(target, flags);
123                     return null;
124                 }
125             };
126         }
127     }
128     public Task<NSEntry, Void> copy(TaskMode mode, final URL target) throws NotImplementedException {
129         return this.copy(mode, target, Flags.NONE.getValue());
130     }
131 
132     public Task<NSEntry, Void> copyFrom(TaskMode mode, final URL source, final int flags) throws NotImplementedException {
133         if (this instanceof AbstractSyncFileImpl) {
134             final AbstractSyncFileImpl target = (AbstractSyncFileImpl) this;
135             return new AbstractCopyFromTask<NSEntry,Void>(mode, m_session, source, flags) {
136                 public void doCopyFrom(URL source, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, DoesNotExistException, AlreadyExistsException, TimeoutException, NoSuccessException, IncorrectURLException {
137                     target._copyFromAndMonitor(source, flags, this);
138                 }
139             };
140         } else if (this instanceof AbstractSyncDirectoryImpl) {
141             final AbstractSyncDirectoryImpl target = (AbstractSyncDirectoryImpl) this;
142             return new AbstractCopyFromTask<NSEntry,Void>(mode, m_session, source, flags) {
143                 public void doCopyFrom(URL source, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, DoesNotExistException, AlreadyExistsException, TimeoutException, NoSuccessException, IncorrectURLException {
144                     target.copyFromSync(source, flags);
145                 }
146             };
147         } else {
148             return new AbstractThreadedTask<NSEntry,Void>(mode) {
149                 public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
150                     AbstractAsyncNSEntryImpl.this.copyFromSync(source, flags);
151                     return null;
152                 }
153             };
154         }
155     }
156     public Task<NSEntry, Void> copyFrom(TaskMode mode, final URL source) throws NotImplementedException {
157         return this.copyFrom(mode, source, Flags.NONE.getValue());
158     }
159 
160     public Task<NSEntry, Void> link(TaskMode mode, final URL target, final int flags) throws NotImplementedException {
161         return new AbstractThreadedTask<NSEntry,Void>(mode) {
162             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
163                 AbstractAsyncNSEntryImpl.super.linkSync(target, flags);
164                 return null;
165             }
166         };
167     }
168     public Task<NSEntry, Void> link(TaskMode mode, final URL target) throws NotImplementedException {
169         return new AbstractThreadedTask<NSEntry,Void>(mode) {
170             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
171                 AbstractAsyncNSEntryImpl.super.linkSync(target);
172                 return null;
173             }
174         };
175     }
176 
177     public Task<NSEntry, Void> move(TaskMode mode, final URL target, final int flags) throws NotImplementedException {
178         if (this instanceof AbstractSyncFileImpl) {
179             final AbstractSyncFileImpl source = (AbstractSyncFileImpl) this;
180             return new AbstractCopyTask<NSEntry,Void>(mode, m_session, target, flags) {
181                 public void doCopy(URL target, int flags) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, DoesNotExistException, AlreadyExistsException, TimeoutException, NoSuccessException, IncorrectURLException {
182                     source._copyAndMonitor(target, flags, this);
183                     // For remove, ignore all flags except DEREFERENCE
184                     if (Flags.DEREFERENCE.isSet(flags)) {
185                         source.removeSync(Flags.DEREFERENCE.getValue());
186                     } else {
187                         source.removeSync();
188                     }
189                 }
190             };
191         } else {
192             return new AbstractThreadedTask<NSEntry,Void>(mode) {
193                 public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
194                     AbstractAsyncNSEntryImpl.this.moveSync(target, flags);
195                     return null;
196                 }
197             };
198         }
199     }
200     public Task<NSEntry, Void> move(TaskMode mode, final URL target) throws NotImplementedException {
201         return this.move(mode, target, Flags.NONE.getValue());
202     }
203 
204     public Task<NSEntry, Void> remove(TaskMode mode, final int flags) throws NotImplementedException {
205         return new AbstractThreadedTask<NSEntry,Void>(mode) {
206             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
207                 AbstractAsyncNSEntryImpl.super.removeSync(flags);
208                 return null;
209             }
210         };
211     }
212     public Task<NSEntry, Void> remove(TaskMode mode) throws NotImplementedException {
213         return new AbstractThreadedTask<NSEntry,Void>(mode) {
214             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
215                 AbstractAsyncNSEntryImpl.super.removeSync();
216                 return null;
217             }
218         };
219     }
220 
221     public Task<NSEntry, Void> close(TaskMode mode) throws NotImplementedException {
222         return new AbstractThreadedTask<NSEntry,Void>(mode) {
223             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
224                 AbstractAsyncNSEntryImpl.super.close();
225                 return null;
226             }
227         };
228     }
229 
230     public Task<NSEntry, Void> close(TaskMode mode, final float timeoutInSeconds) throws NotImplementedException {
231         throw new NotImplementedException("Not supported");
232     }
233 
234     public Task<NSEntry, Void> permissionsAllow(TaskMode mode, final String id, final int permissions, final int flags) throws NotImplementedException {
235         return new AbstractThreadedTask<NSEntry,Void>(mode) {
236             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
237                 AbstractAsyncNSEntryImpl.super.permissionsAllowSync(id, permissions, flags);
238                 return null;
239             }
240         };
241     }
242 
243     public Task<NSEntry, Void> permissionsDeny(TaskMode mode, final String id, final int permissions, final int flags) throws NotImplementedException {
244         return new AbstractThreadedTask<NSEntry,Void>(mode) {
245             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
246                 AbstractAsyncNSEntryImpl.super.permissionsDenySync(id, permissions, flags);
247                 return null;
248             }
249         };
250     }
251 }