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