View Javadoc

1   package fr.in2p3.jsaga.impl.namespace;
2   
3   import fr.in2p3.jsaga.engine.factories.DataAdaptorFactory;
4   import fr.in2p3.jsaga.impl.AbstractSagaObjectImpl;
5   import org.ogf.saga.SagaObject;
6   import org.ogf.saga.error.*;
7   import org.ogf.saga.namespace.*;
8   import org.ogf.saga.session.Session;
9   import org.ogf.saga.task.Task;
10  import org.ogf.saga.task.TaskMode;
11  import org.ogf.saga.url.URL;
12  
13  /* ***************************************************
14  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
15  * ***             http://cc.in2p3.fr/             ***
16  * ***************************************************
17  * File:   NSFactoryImpl
18  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
19  * Date:   17 sept. 2007
20  * ***************************************************
21  * Description:                                      */
22  /**
23   *
24   */
25  public class NSFactoryImpl extends AbstractAsyncNSFactoryImpl {
26      public NSFactoryImpl(DataAdaptorFactory adaptorFactory) {
27          super(adaptorFactory);
28      }
29  
30      ////////////////////////////////////////// interface NSFactory //////////////////////////////////////////
31  
32      protected NSEntry doCreateNSEntry(Session session, URL name, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, AlreadyExistsException, TimeoutException, NoSuccessException {
33          float timeout = this.getTimeout("createNSEntry", name);
34          if (timeout == SagaObject.WAIT_FOREVER) {
35              return super.doCreateNSEntrySync(session, name, flags);
36          } else {
37              try {
38                  return (NSEntry) this.getResult(createNSEntry(JSAGA_FACTORY, TaskMode.ASYNC, session, name, flags), timeout);
39              }
40              catch (IncorrectStateException e) {throw new NoSuccessException(e);}
41              catch (SagaIOException e) {throw new NoSuccessException(e);}
42          }
43      }
44  
45      protected NSDirectory doCreateNSDirectory(Session session, URL name, int flags) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, AlreadyExistsException, TimeoutException, NoSuccessException {
46          float timeout = this.getTimeout("createNSDirectory", name);
47          if (timeout == SagaObject.WAIT_FOREVER) {
48              return super.doCreateNSDirectorySync(session, name, flags);
49          } else {
50              try {
51                  return (NSDirectory) this.getResult(createNSDirectory(JSAGA_FACTORY, TaskMode.ASYNC, session, name, flags), timeout);
52              }
53              catch (IncorrectStateException e) {throw new NoSuccessException(e);}
54              catch (SagaIOException e) {throw new NoSuccessException(e);}
55          }
56      }
57  
58      ////////////////////////////////////////// private methods //////////////////////////////////////////
59  
60      private float getTimeout(String methodName, URL url) throws NoSuccessException {
61          return AbstractSagaObjectImpl.getTimeout(NSFactory.class, methodName, url.getScheme());
62      }
63  
64      private Object getResult(Task task, float timeout)
65              throws NotImplementedException, IncorrectURLException,
66              AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException,
67              BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException,
68              TimeoutException, NoSuccessException, SagaIOException
69      {
70          return AbstractSagaObjectImpl.getResult(task, timeout);
71      }
72  }