Source code: jreceiver/common/rpc/xmlrpc/DeviceBindingsImpl.java
1 /* $Header: /cvsroot/jreceiver/jreceiver/src/jreceiver/common/rpc/xmlrpc/DeviceBindingsImpl.java,v 1.3 2002/07/31 11:29:42 reedesau Exp $ */
2
3 package jreceiver.common.rpc.xmlrpc;
4
5 import java.util.Vector;
6 import java.util.Hashtable;
7 import java.net.URL;
8
9 //import org.apache.commons.logging.*;
10
11 import jreceiver.common.rec.Key;
12 import jreceiver.common.rec.Rec;
13 import jreceiver.common.rec.RecException;
14 import jreceiver.common.rec.driver.*;
15 import jreceiver.common.rec.security.User;
16 import jreceiver.common.rpc.DeviceBindings;
17 import jreceiver.common.rpc.RpcException;
18
19 /**
20 * DeviceBinding-definition queries and updates via XML-RPC
21 * <p>
22 *
23 * @author Reed Esau
24 * @version $Revision: 1.3 $ $Date: 2002/07/31 11:29:42 $
25 */
26 public class DeviceBindingsImpl extends ServerTableImpl implements DeviceBindings {
27
28 /**
29 * ctor for this implementation
30 */
31 public DeviceBindingsImpl(URL remote_host, User user)
32 throws RpcException {
33 super(HANDLER_NAME, remote_host, user);
34 }
35
36
37 /**
38 * restore a rec object from hashtable form
39 */
40 public Rec reconstituteRec(Hashtable hash) throws RecException {
41 return new DeviceBindingRec(hash);
42 }
43
44 /**
45 * restore a key object from hashtable form
46 */
47 public Key reconstituteKey(Hashtable hash) {
48 return new DeviceBindingKey(hash);
49 }
50
51
52 /**
53 * Obtain a total count of devbind keys for a driverbind
54 * <p>
55 * Recommended when traversing large lists.
56 */
57 public int getKeyCountForDriverBinding(DriverBindingKey drvbind_key) throws RpcException {
58 Vector params = new Vector();
59 params.add( drvbind_key.toHash() );
60 Integer ii = (Integer)execute(GET_KEY_COUNT_FOR_DRIVER_BINDING, params);
61 return ii.intValue();
62 }
63
64
65 /**
66 * Obtain an ordered range of keys for the specified driverbind.
67 * <p>
68 * Recommended when traversing large lists where a complex filter
69 * is used.
70 */
71 public Vector getKeysForDriverBinding(DriverBindingKey drvbind_key, String order_by, int rec_offset, int rec_count) throws RpcException {
72 if (log.isDebugEnabled())
73 log.debug("getKeysForDriverBinding");
74 Vector params = new Vector();
75 params.add( drvbind_key.toHash() );
76 params.add( order_by != null ? order_by : "");
77 params.add( new Integer(rec_offset) );
78 params.add( new Integer(rec_count) );
79 Vector keys = (Vector)execute(GET_KEYS_FOR_DRIVER_BINDING, params);
80 if (keys.size() > 0 && keys.get(0) instanceof Hashtable) {
81 reconstituteKeys(keys);
82 }
83 return keys;
84 }
85
86
87 /**
88 * logging sink
89 */
90 //protected static Log log = LogFactory.getLog(DeviceBindings.class);
91 }
92 /*
93 JRECEIVER MODIFIED BSD LICENSE
94
95 Copyright (c) 2002, Reed Esau (reed.esau@pobox.com) All rights reserved.
96
97 Redistribution and use in source and binary forms, with or without
98 modification, are permitted provided that the following conditions are
99 met:
100
101 Redistributions of source code must retain the above copyright notice,
102 this list of conditions and the following disclaimer.
103
104 Redistributions in binary form must reproduce the above copyright notice,
105 this list of conditions and the following disclaimer in the documentation
106 and/or other materials provided with the distribution.
107
108 Neither the name of the JReceiver Project
109 (http://jreceiver.sourceforge.net) nor the names of its contributors may
110 be used to endorse or promote products derived from this software without
111 specific prior written permission.
112
113 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
114 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
115 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
116 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
117 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
118 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
119 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
120 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
121 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
122 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
123 POSSIBILITY OF SUCH DAMAGE.
124 */
125