KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > exchange > items > common > manager > ItemManager


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.exchange.items.common.manager;
20
21 import java.io.IOException JavaDoc;
22
23 import sync4j.exchange.items.common.dao.ItemDAO;
24 import sync4j.exchange.items.common.model.Item;
25 import sync4j.exchange.DataAccessException;
26
27 /*
28  * This class defines methods to access commons items data
29  * in database source and exchange datastore
30  *
31  * @author Fabio Maggi @ Funambol
32  * @version $Id: ItemManager.java,v 1.7 2005/06/20 14:03:21 fabius Exp $
33  *
34  **/

35 public class ItemManager {
36
37     //------------------------------------------------------------- Constants
38

39     //------------------------------------------------------------- Private Data
40

41     //------------------------------------------------------------- Private Data
42

43     ItemDAO id = null ;
44
45     //------------------------------------------------------------- Costructor
46

47     public ItemManager ()
48         throws DataAccessException {
49
50         this.id = new ItemDAO ();
51
52     }
53
54     public ItemManager (String JavaDoc host ,
55                         int port )
56     throws DataAccessException {
57
58         this.id = new ItemDAO (host, port);
59     }
60
61     //------------------------------------------------------------- Public methods
62

63     /**
64      * delete local items
65      *
66      * @param sourceURI
67      * @param principal
68      *
69      * @throws sync4j.exchange.util.DataAccessException
70      **/

71     public void deleteLocalItems(String JavaDoc sourceURI, String JavaDoc principal)
72     throws DataAccessException {
73
74          id.deleteLocalItems(sourceURI, principal);
75
76     }
77
78     /**
79      * get all local items
80      *
81      * @param sourceURI
82      * @param principal
83      *
84      * @return array of find items
85      *
86      * @throws sync4j.exchange.util.DataAccessException
87      **/

88     public Item[] getLocalItems (String JavaDoc sourceURI, String JavaDoc principal)
89     throws DataAccessException {
90
91          return id.getLocalItems (sourceURI, principal);
92
93     }
94
95     /**
96      * add local items
97      *
98      * @param localItems
99      * @param sourceURI
100      * @param principal
101      *
102      * @return array of find items
103      *
104      * @throws sync4j.exchange.util.DataAccessException
105      **/

106     public void addLocalItems (Item[] localItems ,
107                                String JavaDoc sourceURI ,
108                                String JavaDoc principal )
109     throws DataAccessException {
110
111          id.addLocalItems (localItems, sourceURI, principal);
112
113     }
114
115     /**
116      * update local items
117      *
118      * @param localItems
119      * @param sourceURI
120      * @param principal
121      *
122      * @throws sync4j.exchange.util.DataAccessException
123      **/

124     public void updateLocalItems(Item[] localItems ,
125                                  String JavaDoc sourceURI ,
126                                  String JavaDoc principal )
127     throws DataAccessException {
128
129          this.deleteLocalItems (sourceURI, principal);
130          this.addLocalItems (localItems, sourceURI, principal);
131
132     }
133
134     /**
135      * get all Exchange Server items
136      *
137      * @param username
138      * @param credentials
139      * @param exchangeFolder
140      *
141      * @return array of find items
142      *
143      * @throws sync4j.exchange.util.DataAccessException
144      **/

145     public Item[] getExchangeItems(String JavaDoc username ,
146                                    String JavaDoc credentials ,
147                                    String JavaDoc exchangeFolder )
148     throws DataAccessException {
149
150         return id.getAllExchangeItems(username ,
151                                       credentials ,
152                                       exchangeFolder);
153     }
154
155
156     /**
157      * get Exchange Access Status
158      *
159      * @param exchangeServerName
160      * @param userName
161      * @param credentials
162      *
163      * @return array of find items
164      *
165      * @throws sync4j.exchange.util.DataAccessException
166      **/

167     public int getExchangeAccessStatus(String JavaDoc exchangeServerName ,
168                                        String JavaDoc userName ,
169                                        String JavaDoc credentials )
170     throws DataAccessException {
171
172         return id.getExchangeAccessStatus(exchangeServerName ,
173                                           userName ,
174                                           credentials );
175     }
176
177
178 }
Popular Tags