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

Quick Search    Search Deep

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


1   /*
2    * AssetPathGateway.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.exceptions.ejb.NotFoundException;
16  import com.flexstor.common.gateway.debug.GatewayDebugOutput;
17  import com.flexstor.common.gateway.exceptions.TransactionFailedException;
18  import com.flexstor.ejb.EjbObject;
19  import com.flexstor.ejb.importrecord.assetpath.AssetPath;
20  import com.flexstor.ejb.importrecord.assetpath.AssetPathHome;
21  
22  /**
23   * Get a list of asset paths and check to see if they exist in the database
24   * @author David Cardozo
25   * @version 3.0
26   */
27  public class AssetPathGateway
28  extends Gateway
29  {
30     // MKS macro expander
31     public final static String IDENTIFIER = "$Id: AssetPathGateway.java,v 1.3 2003/08/11 02:22:29 aleric Exp $";
32  
33     private AssetPath assetPath = null;
34  
35     protected String getHomeName ( )
36     {
37        return ASSET_PATH_HOME;
38     }
39  
40     protected EjbObject getBeanObject ( )
41     {
42        return assetPath;
43     }
44  
45     /**
46      * Sends the request for the assetPath data to the server.
47      * @throws TransactionFailedException Throws if this transaction fails.
48      */
49     public void connect ()
50        throws TransactionFailedException
51     {
52        try
53        {
54           if ( canLoadObject() )
55              return;
56  
57           AssetPathHome home = (AssetPathHome) getHome ( );
58  
59           GatewayDebugOutput.println ( 3, "Getting AssetPath object" );
60           assetPath = home.create();
61        }
62        catch ( NotFoundException e )
63        {
64           throw new TransactionFailedException ( e );
65        }
66        catch ( Throwable e )
67        {
68           throw buildException(e, "Connecting to AssetPath", IDENTIFIER );
69        }
70     }
71  
72     /**
73      * Check to see if asset paths exist on database
74      * @throws TransactionFailedException Throws if this transaction fails.
75      */
76     public Vector assetList( Vector assetPaths )
77        throws TransactionFailedException
78     {
79        try
80        {
81           GatewayDebugOutput.println ( 3, "Checking for asset paths in the database" );
82  
83           if ( canLoadObject() )
84              return (Vector) retrieveObject( "AssetPath_assetList" );
85  
86           Vector data = assetPath.assetList( assetPaths );
87  
88           if ( canSaveObject() )
89              storeObject( "AssetPath_assetList", data );
90  
91           return data;
92        }
93        catch ( Throwable e )
94        {
95           throw buildException(e, "Getting Asset List", IDENTIFIER );
96        }
97     }
98  }