View Javadoc

1   package fr.in2p3.jsaga.impl.attributes;
2   
3   import fr.in2p3.jsaga.impl.task.AbstractThreadedTask;
4   import org.ogf.saga.attributes.AsyncAttributes;
5   import org.ogf.saga.attributes.Attributes;
6   import org.ogf.saga.error.*;
7   import org.ogf.saga.session.Session;
8   import org.ogf.saga.task.Task;
9   import org.ogf.saga.task.TaskMode;
10  
11  /* ***************************************************
12  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
13  * ***             http://cc.in2p3.fr/             ***
14  * ***************************************************
15  * File:   AbstractAsyncAttributesImpl
16  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
17  * Date:   30 oct. 2007
18  * ***************************************************
19  * Description:                                      */
20  /**
21   *
22   */
23  public abstract class AbstractAsyncAttributesImpl<T extends Attributes> extends AbstractAttributesImpl implements AsyncAttributes<T> {
24      private T m_object;
25  
26      public AbstractAsyncAttributesImpl(Session session, T object) {
27          super(session);
28          m_object = object;
29      }
30  
31      public Task<T, Void> setAttribute(TaskMode mode, final String key, final String value) throws NotImplementedException {
32          return new AbstractThreadedTask<T,Void>(mode){
33              public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
34                  m_object.setAttribute(key, value);
35                  return null;
36              }
37          };
38      }
39  
40      public Task<T, String> getAttribute(TaskMode mode, final String key) throws NotImplementedException {
41          return new AbstractThreadedTask<T,String>(mode) {
42              public String invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
43                  return m_object.getAttribute(key);
44              }
45          };
46      }
47  
48      public Task<T, Void> setVectorAttribute(TaskMode mode, final String key, final String[] values) throws NotImplementedException {
49          return new AbstractThreadedTask<T,Void>(mode) {
50              public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
51                  m_object.setVectorAttribute(key, values);
52                  return null;
53              }
54          };
55      }
56  
57      public Task<T, String[]> getVectorAttribute(TaskMode mode, final String key) throws NotImplementedException {
58          return new AbstractThreadedTask<T,String[]>(mode) {
59              public String[] invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
60                  return m_object.getVectorAttribute(key);
61              }
62          };
63      }
64  
65      public Task<T, Void> removeAttribute(TaskMode mode, final String key) throws NotImplementedException {
66          return new AbstractThreadedTask<T,Void>(mode) {
67              public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
68                  m_object.removeAttribute(key);
69                  return null;
70              }
71          };
72      }
73  
74      public Task<T, String[]> listAttributes(TaskMode mode) throws NotImplementedException {
75          return new AbstractThreadedTask<T,String[]>(mode) {
76              public String[] invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
77                  return m_object.listAttributes();
78              }
79          };
80      }
81  
82      public Task<T, String[]> findAttributes(TaskMode mode, final String... patterns) throws NotImplementedException {
83          return new AbstractThreadedTask<T,String[]>(mode) {
84              public String[] invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
85                  return m_object.findAttributes(patterns);
86              }
87          };
88      }
89  
90      public Task<T, Boolean> existsAttribute(TaskMode mode, final String key) throws NotImplementedException {
91          return new AbstractThreadedTask<T,Boolean>(mode) {
92              public Boolean invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
93                  return m_object.existsAttribute(key);
94              }
95          };
96      }
97  
98      public Task<T, Boolean> isReadOnlyAttribute(TaskMode mode, final String key) throws NotImplementedException {
99          return new AbstractThreadedTask<T,Boolean>(mode) {
100             public Boolean invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
101                 return m_object.isReadOnlyAttribute(key);
102             }
103         };
104     }
105 
106     public Task<T, Boolean> isWritableAttribute(TaskMode mode, final String key) throws NotImplementedException {
107         return new AbstractThreadedTask<T,Boolean>(mode) {
108             public Boolean invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
109                 return m_object.isWritableAttribute(key);
110             }
111         };
112     }
113 
114     public Task<T, Boolean> isRemovableAttribute(TaskMode mode, final String key) throws NotImplementedException {
115         return new AbstractThreadedTask<T,Boolean>(mode) {
116             public Boolean invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
117                 return m_object.isRemovableAttribute(key);
118             }
119         };
120     }
121 
122     public Task<T, Boolean> isVectorAttribute(TaskMode mode, final String key) throws NotImplementedException {
123         return new AbstractThreadedTask<T,Boolean>(mode) {
124             public Boolean invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
125                 return m_object.isVectorAttribute(key);
126             }
127         };
128     }
129 }