Source code: jreceiver/common/rpc/xmlrpc/FoldersImpl.java
1 /* $Header: /cvsroot/jreceiver/jreceiver/src/jreceiver/common/rpc/xmlrpc/FoldersImpl.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.util.Set;
8 import java.net.URL;
9
10 //import org.apache.commons.logging.*;
11
12 import jreceiver.common.rec.Rec;
13 import jreceiver.common.rec.RecException;
14 import jreceiver.common.rec.security.User;
15 import jreceiver.common.rpc.Folders;
16 import jreceiver.common.rpc.RpcException;
17 import jreceiver.common.rec.site.FolderRec;
18
19 /**
20 * Folder-related queries to a remote server via XML-RPC.
21 * <p>
22 *
23 * @author Reed Esau
24 * @version $Revision: 1.5 $ $Date: 2002/07/31 11:29:42 $
25 */
26 public class FoldersImpl extends ServerTableImpl implements Folders {
27
28 /**
29 * ctor for this implementation
30 */
31 public FoldersImpl(URL remote_host, User user)
32 throws RpcException {
33 super(HANDLER_NAME, remote_host, user);
34 }
35
36 /**
37 * restore a rec object from hashtable form
38 */
39 public Rec reconstituteRec(Hashtable hash) throws RecException {
40 return new FolderRec(hash);
41 }
42
43 //
44 // public methods
45 //
46
47 /**
48 * Obtain a list of folder_ids which represent the children
49 * of the folder associated with parent_id.
50 */
51 public Vector getChildKeys(int parent_id, String order_by,
52 boolean recurse,
53 int rec_offset, int rec_count) throws RpcException {
54 if (parent_id < 1)
55 throw new IllegalArgumentException();
56
57 Vector params = new Vector();
58 params.addElement( new Integer(parent_id) );
59 params.addElement( order_by != null ? order_by : "" );
60 params.addElement( new Boolean(recurse) );
61 params.addElement( new Integer(rec_offset) );
62 params.addElement( new Integer(rec_count) );
63 return(Vector)execute(GET_CHILD_KEYS, params);
64 }
65
66 /**
67 * Obtain a list of folder_ids which represent the root folders
68 */
69 public Vector getRootKeys(String order_by, int rec_offset, int rec_count) throws RpcException {
70 Vector params = new Vector();
71 params.addElement( order_by != null ? order_by : "" );
72 params.addElement( new Integer(rec_offset) );
73 params.addElement( new Integer(rec_count) );
74 return(Vector)execute(GET_ROOT_KEYS, params);
75 }
76
77
78 /**
79 * see interface for description and behavior
80 */
81 public int findParent(int folder_id, Set folders) throws RpcException {
82 if (folder_id < 1 || folders == null)
83 throw new IllegalArgumentException();
84
85 Vector params = new Vector();
86 params.addElement( new Integer(folder_id) );
87 params.addElement( new Vector(folders) );
88 Integer parent_id = (Integer)execute(FIND_PARENT, params);
89 return parent_id.intValue();
90 }
91
92
93 /**
94 * logging sink
95 */
96 //protected static Log log = LogFactory.getLog(Folders.class);
97 }
98 /*
99 JRECEIVER MODIFIED BSD LICENSE
100
101 Copyright (c) 2001-2002, Reed Esau (reed.esau@pobox.com) All rights reserved.
102
103 Redistribution and use in source and binary forms, with or without
104 modification, are permitted provided that the following conditions are
105 met:
106
107 Redistributions of source code must retain the above copyright notice,
108 this list of conditions and the following disclaimer.
109
110 Redistributions in binary form must reproduce the above copyright notice,
111 this list of conditions and the following disclaimer in the documentation
112 and/or other materials provided with the distribution.
113
114 Neither the name of the JReceiver Project
115 (http://jreceiver.sourceforge.net) nor the names of its contributors may
116 be used to endorse or promote products derived from this software without
117 specific prior written permission.
118
119 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
120 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
121 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
122 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
123 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
124 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
125 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
126 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
127 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
128 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
129 POSSIBILITY OF SUCH DAMAGE.
130 */
131