KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > controllers > kernel > impl > simple > AvailableServiceBindingDeliveryController


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.deliver.controllers.kernel.impl.simple;
25
26 import org.apache.log4j.Logger;
27 import org.exolab.castor.jdo.Database;
28 import org.exolab.castor.jdo.OQLQuery;
29 import org.exolab.castor.jdo.QueryResults;
30 import org.infoglue.cms.entities.management.AvailableServiceBinding;
31 import org.infoglue.cms.entities.management.AvailableServiceBindingVO;
32 import org.infoglue.cms.exception.SystemException;
33 import org.infoglue.deliver.applications.actions.UpdateCacheAction;
34 import org.infoglue.deliver.util.CacheController;
35
36
37 public class AvailableServiceBindingDeliveryController extends BaseDeliveryController
38 {
39     private final static Logger logger = Logger.getLogger(AvailableServiceBindingDeliveryController.class.getName());
40
41     /**
42      * Private constructor to enforce factory-use
43      */

44     
45     private AvailableServiceBindingDeliveryController()
46     {
47     }
48     
49     /**
50      * Factory method
51      */

52     
53     public static AvailableServiceBindingDeliveryController getAvailableServiceBindingDeliveryController()
54     {
55         return new AvailableServiceBindingDeliveryController();
56     }
57     
58
59     /**
60      * This method returns the available service binding with a specific name.
61      */

62     
63     public AvailableServiceBindingVO getAvailableServiceBindingVO(String JavaDoc availableServiceBindingName, Database db) throws SystemException, Exception JavaDoc
64     {
65         String JavaDoc key = "" + availableServiceBindingName;
66         logger.info("key:" + key);
67         AvailableServiceBindingVO availableServiceBindingVO = (AvailableServiceBindingVO)CacheController.getCachedObject("availableServiceBindingCache", key);
68         if(availableServiceBindingVO != null)
69         {
70             logger.info("There was an cached availableServiceBindingVO:" + availableServiceBindingVO);
71         }
72         else
73         {
74             logger.info("Going to look for availableServiceBindingName " + availableServiceBindingName);
75             
76             //OQLQuery oql = db.getOQLQuery( "SELECT asb FROM org.infoglue.cms.entities.management.impl.simple.AvailableServiceBindingImpl asb WHERE asb.name = $1");
77
OQLQuery oql = db.getOQLQuery( "SELECT asb FROM org.infoglue.cms.entities.management.impl.simple.SmallAvailableServiceBindingImpl asb WHERE asb.name = $1");
78             //OQLQuery oql = db.getOQLQuery( "CALL SQL SELECT availableServiceBindingId, name, description, visualizationAction, isMandatory, isUserEditable, isInheritable FROM cmAvailableServiceBinding WHERE (name = $1) AS org.infoglue.cms.entities.management.impl.simple.AvailableServiceBindingImpl");
79
oql.bind(availableServiceBindingName);
80             
81             QueryResults results = oql.execute(Database.ReadOnly);
82             if (results.hasMore())
83             {
84                 AvailableServiceBinding availableServiceBinding = (AvailableServiceBinding)results.next();
85                 availableServiceBindingVO = availableServiceBinding.getValueObject();
86                 logger.info("Found availableServiceBinding:" + availableServiceBindingVO.getName());
87             }
88             else
89             {
90                 logger.info("Found no AvailableServiceBindingVO with name " + availableServiceBindingName);
91             }
92             
93             results.close();
94             oql.close();
95         
96             //try{ throw new Exception("Hepp1"); }catch(Exception e){e.printStackTrace();}
97

98             CacheController.cacheObject("availableServiceBindingCache", key, availableServiceBindingVO);
99         }
100         
101         return availableServiceBindingVO;
102     }
103     
104     /**
105      * This method returns the available service binding with a specific name.
106      */

107     
108     public AvailableServiceBinding getAvailableServiceBinding(String JavaDoc availableServiceBindingName, Database db) throws SystemException, Exception JavaDoc
109     {
110         AvailableServiceBinding availableServiceBinding = null;
111         
112         OQLQuery oql = db.getOQLQuery( "SELECT asb FROM org.infoglue.cms.entities.management.impl.simple.AvailableServiceBindingImpl asb WHERE asb.name = $1");
113         oql.bind(availableServiceBindingName);
114         
115         QueryResults results = oql.execute(Database.ReadOnly);
116         if (results.hasMore())
117         {
118             availableServiceBinding = (AvailableServiceBinding)results.next();
119             logger.info("Found availableServiceBinding:" + availableServiceBinding.getName());
120         }
121          
122         results.close();
123         oql.close();
124
125         return availableServiceBinding;
126     }
127     
128 }
Popular Tags