Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/common/gateway/SendSettingGateway.java


1   /*
2    * SendSettingGateway.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:29 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.common.gateway;
12  
13  import java.util.Vector;
14  
15  import com.flexstor.common.data.ejb.setting.SendSettingData;
16  import com.flexstor.common.gateway.debug.GatewayDebugOutput;
17  import com.flexstor.common.gateway.exceptions.TransactionFailedException;
18  import com.flexstor.common.keys.ejb.RoleKey;
19  import com.flexstor.common.keys.ejb.SendSettingCollectionKey;
20  import com.flexstor.common.keys.ejb.SendSettingKey;
21  import com.flexstor.ejb.EjbObject;
22  import com.flexstor.ejb.setting.persist.SendSettingPersist;
23  import com.flexstor.ejb.setting.persist.SendSettingPersistHome;
24  
25  /**
26   * Gateway class to perform operations on send setting related information.
27   * 
28   * @author Praveen Jani
29   * @since 3.0
30   * @see com.flexstor.common.gateway.Gateway
31   */
32  
33  
34  public class SendSettingGateway 
35     extends Gateway
36  {
37     // MKS macro expander
38     public final static String IDENTIFIER = "$Id: SendSettingGateway.java,v 1.3 2003/08/11 02:22:29 aleric Exp $";
39    
40     /**
41      * Instance of SendSettingPersist remote interface.
42      * 
43      * @since 3.0
44      * @see com.flexstor.ejb.setting.persist.SendSettingPersist
45      */
46  
47     private SendSettingPersist sendSetting;
48  
49  
50     /**
51      * Returns the home name of the bean to be accessed.
52      * 
53      * @return String - the published context name for the home interface of the bean
54      * @since 3.0
55      * @see com.flexstor.common.constants.EjbHomeInterfacesI
56      */
57  
58     protected String getHomeName ( )
59     {
60        return SEND_SETTING_HOME;
61     }
62  
63     /**
64      * Returns the bean object (EjbObject)
65      * 
66      * @return EjbObject - Remote Object
67      * @since 3.0
68      * @see com.flexstor.ejb.EjbObject
69      */
70  
71     protected EjbObject getBeanObject ( )
72     {
73        return (EjbObject)sendSetting;
74     }
75     
76     /**
77      * Connects to the Send Setting Persist EJB.
78      * 
79      * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
80      * @since 3.0
81      */
82  
83     public void connect ()
84        throws TransactionFailedException
85     {
86        try
87        {
88           if ( canLoadObject() )
89              return;
90           
91           SendSettingPersistHome home = (SendSettingPersistHome)getHome();
92           GatewayDebugOutput.println ( 3, "Getting SendSettingPersist object" );
93           sendSetting = home.create();
94        }
95        catch ( Throwable e )
96        {
97           throw buildException(e, "Connecting to SendSettingPersist", IDENTIFIER );
98        }
99     }
100    
101    /**
102     * Retrieves a list of all available send settings contained by FLEXSTOR.db.
103     * 
104     * @return vector of SendSettingData objects.
105     * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
106     * @since 3.0
107     * @see com.flexstor.ejb.address.persist.SendSettingPersist
108     * @see com.flexstor.common.data.ejb.settings.SendSettingData
109     */  
110    public Vector getSendSettingList ( )
111       throws TransactionFailedException
112    {
113       try
114       {
115          if ( canLoadObject() )
116             return (Vector)retrieveObject ( "SendSettingPersist_getSendSettingList" );
117 
118          GatewayDebugOutput.println ( 3, "Getting Send Setting list" );
119          Vector  vector = sendSetting.getAllSendSettings();
120                
121          if ( canSaveObject() )
122             storeObject ( "SendSettingPersist_getSendSettingList", vector );
123                
124          return vector;
125       }
126       catch ( Throwable e )
127       {
128          throw buildException(e, "Getting Send Setting List", IDENTIFIER );
129       }
130    }   
131    
132    /**
133     * Retrieves a list of all send settings contained by FLEXSTOR.db provided a list of send
134     * setting keys.
135     * 
136     * @param keyCollection - Vector of send setting keys.
137     * @return Vector of SendSettingData objects.
138     * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
139     * @since 3.0
140     * @see com.flexstor.ejb.address.setting.persist.SendSettingPersist
141     */  
142    public Vector getSendSettings (Vector keyCollection)
143       throws TransactionFailedException
144    {
145       try
146       {
147          if ( canLoadObject() )
148             return (Vector)retrieveObject ( "SendSettingPersist_getSendSettings(Vector)" );
149 
150          GatewayDebugOutput.println ( 3, "Getting Send Setting list for keyCollection (vector)" );
151          Vector  addresses = sendSetting.getSendSetting( keyCollection );
152                
153          if ( canSaveObject() )
154             storeObject ( "SendSettingPersist_getSendSettings(Vector)", addresses );
155                
156          return addresses;
157       }
158       catch ( Throwable e )
159       {
160          throw buildException(e, "Getting Send Settings", IDENTIFIER );
161       }
162    }   
163    /**
164     * Retrieves a list of all send settings contained by FLEXSTOR.db provided 
165     * a send setting collection key.
166     * 
167     * @param collectionKey Instance of SendSettingCollectionKey, The key represents a collection of 
168     * SendSettingData Objects.
169     * @return Vector of SendSettingData objects.
170     * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
171     * @since 3.0
172     * @see com.flexstor.ejb.address.setting.persist.SendSettingPersist
173     */  
174    public Vector getSendSettings (SendSettingCollectionKey collectionKey)
175       throws TransactionFailedException
176    {
177       try
178       {
179          if ( canLoadObject() )
180             return (Vector)retrieveObject ( "SendSettingPersist_getSendSettings(collectionKey)" );
181 
182          GatewayDebugOutput.println ( 3, "Getting Send Setting list" );
183          Vector  settings = sendSetting.getSendSetting ( collectionKey );
184                
185          if ( canSaveObject() )
186             storeObject ( "SendSettingPersist_getSendSettings(collectionKey)", settings );
187                
188          return settings;
189       }
190       catch ( Throwable e )
191       {
192          throw buildException(e, "Getting Send Settings", IDENTIFIER );
193       }
194    }   
195    
196    /**
197     * Retrieves a send setting contained by FLEXSTOR.db provided a send setting name.
198     * 
199     * @param name Name of the send setting.
200     * @return SendSettingData object.
201     * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
202     * @since 3.0
203     * @see com.flexstor.ejb.address.setting.persist.SendSettingPersist
204     */  
205    public SendSettingData getSendSetting ( String name )
206       throws TransactionFailedException
207    {
208       try
209       {
210          if ( canLoadObject() )
211             return (SendSettingData)retrieveObject ( "SendSettingPersist_getSendSetting(name)" );
212 
213          GatewayDebugOutput.println ( 3, "Getting a Send Setting" );
214          SendSettingData  iSetting = sendSetting.getSendSetting ( name );
215                
216          if ( canSaveObject() )
217             storeObject ( "SendSettingPersist_getSendSetting(name)", iSetting);
218                
219          return iSetting;
220       }
221       catch ( Throwable e )
222       {
223          throw buildException(e, "Getting Send Setting", IDENTIFIER );
224       }
225    }   
226    
227    
228 
229    /**
230     * Retrieves a Send Setting contained by FLEXSTOR.db provided a send
231     * setting key.
232     * 
233     * @param key - Send Setting Key.
234     * @return SendSettingData object.
235     * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
236     * @since 3.0
237     * @see com.flexstor.ejb.address.persist.SendSettingPersist
238     * @see com.flexstor.common.address.persist.SendSettingData
239     */  
240    public SendSettingData getSendSetting(SendSettingKey key)
241       throws TransactionFailedException
242    {
243       try
244       {
245          if ( canLoadObject() )
246             return (SendSettingData)retrieveObject ( "SendSettingPersist_getSendSetting(key)" );
247 
248          GatewayDebugOutput.println ( 3, "Getting Send Setting list" );
249          SendSettingData  sSetting = sendSetting.getSendSetting(key);
250                
251          if ( canSaveObject() )
252             storeObject ( "SendSettingPersist_getSendSetting(key)", sSetting );
253                
254          return sSetting;
255       }
256       catch ( Throwable e )
257       {
258          throw buildException(e, "Getting Send Setting", IDENTIFIER );
259       }
260    }   
261    
262    /**
263     * Inserts a Send Setting to the FLEXSTOR.db Send Setting database.
264     * 
265     * @param sendSettingData Instance of SendSettingData Object.
266     * @return SendSettingData.
267     * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
268     * @since 3.0
269     * @see com.flexstor.ejb.address.persist.SendSettingPersist
270     * @see com.flexstor.common.address.persist.SendSettingData
271     */  
272 
273 
274    public SendSettingData insert( SendSettingData sendSettingData ) 
275       throws TransactionFailedException   
276    {
277       try
278       {
279          if ( canLoadObject() )
280             return (SendSettingData)retrieveObject( "SendSettingPersist_insert" );
281 
282          GatewayDebugOutput.println ( 3, "Inserting Send Setting." );
283          SendSettingData sData = sendSetting.insert( sendSettingData );
284 
285          if ( canSaveObject() )
286             storeObject( "SendSettingPersist_insert", sData );
287                
288          return sData;
289       }
290       catch ( Throwable e )
291       {
292          throw buildException( e, "Inserting", IDENTIFIER );
293       }
294    }
295    
296    /**
297     * Adds a Send Setting to a role.
298     * 
299     * @param sendSettingData - Instance of SendSettingData - the data Object
300     * @param key - The RoleKey instance, - represents the role, this send setting object is 
301     * assigned to.
302     * @return - SendSettingData send setting data object.
303     * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
304     * @since 3.0
305     * @see com.flexstor.ejb.address.persist.SendSettingPersist
306     * @see com.flexstor.common.address.persist.SendSettingData
307     */  
308 
309 
310    public SendSettingData insert( SendSettingData sendSettingData, RoleKey key ) 
311       throws TransactionFailedException   
312    {
313       try
314       {
315          if ( canLoadObject() )
316             return (SendSettingData)retrieveObject( "SendSettingPersist_insert" );
317 
318          GatewayDebugOutput.println ( 3, "Inserting Send Setting." );
319          SendSettingData sSetting = sendSetting.insert( sendSettingData, key );
320 
321          if ( canSaveObject() )
322             storeObject( "SendSettingPersist_insert", sSetting );
323                
324          return sSetting;
325       }
326       catch ( Throwable e )
327       {
328          throw buildException( e, "Inserting", IDENTIFIER );
329       }
330    }
331    
332    
333    /**
334     * Deletes ( removes ) a Send Setting from the FLEXSTOR.db Send Setting database.
335     * 
336     * @param sendSettingKey - The send setting key.
337     * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
338     * @since 3.0
339     * @see com.flexstor.ejb.address.persist.SendSettingPersist
340     * @see com.flexstor.common.address.persist.SendSettingData
341     * @see com.flexstor.common.address.persist.SendSettingKey
342     */  
343 
344 
345    public void remove( SendSettingKey sendSettingKey ) 
346       throws TransactionFailedException   
347    {
348       try
349       {
350          if ( canLoadObject() )
351             return;         
352          GatewayDebugOutput.println ( 3, "Removing Send Setting." );        
353          sendSetting.remove( sendSettingKey );
354       }
355       catch ( Throwable e )
356       {
357          throw buildException( e, "Removing", IDENTIFIER );
358       }
359    }
360    
361    /**
362     * Updates Send Setting to the FLEXSTOR.db Send Setting database.
363     *
364     * @param sendSettingData - Send Setting Data Object.
365     * @return SendSettingData - the updated data object.
366     * @exception com.flexstor.common.gateway.exceptions.TransactionFailedException Thrown whenever the transaction fails.
367     * @since 3.0
368     * @see com.flexstor.ejb.address.persist.SendSettingPersist
369     * @see com.flexstor.common.address.persist.SendSettingData
370     * @see com.flexstor.common.address.persist.SendSettingKey
371     */
372 
373 
374    public SendSettingData update( SendSettingData sendSettingData )
375       throws TransactionFailedException
376    {
377       try
378       {
379          if ( canLoadObject() )
380             return (SendSettingData)retrieveObject( "SendSettingPersist_update" );
381 
382          GatewayDebugOutput.println ( 3, "Updating Send Setting." );
383          SendSettingData sSetting = sendSetting.update( sendSettingData );
384 
385          if ( canSaveObject() )
386             storeObject( "SendSettingPersist_update", sSetting );
387 
388           return sSetting;
389 
390       }
391       catch ( Throwable e )
392       {
393          throw buildException( e, "Updating", IDENTIFIER );
394       }
395    }
396    
397 
398 }