2 * WebConfig - a web administration interface for the Funambol DS Server.
3 * Copyright (C) 2008 Mathew McBride
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package net
.bionicmessage
.funambol
.configuration
;
21 import com
.funambol
.framework
.filter
.WhereClause
;
22 import com
.funambol
.framework
.server
.Sync4jSource
;
23 import com
.funambol
.framework
.server
.store
.PersistentStore
;
24 import com
.funambol
.framework
.server
.store
.PersistentStoreException
;
25 import com
.funambol
.server
.config
.Configuration
;
31 public class SyncSourceUtils
{
32 public static Sync4jSource
getSourceByURI(String uri
) throws PersistentStoreException
{
33 String
[] values
= {uri
};
34 WhereClause wc
= new WhereClause("uri",values
, WhereClause
.OPT_EQ
, false);
35 Configuration c
= Configuration
.getConfiguration();
36 PersistentStore ps
= c
.getStore();
37 Sync4jSource
[] results
= (Sync4jSource
[]) ps
.read(new Sync4jSource(), wc
);
38 if (results
.length
== 1)
42 public static void deleteSyncSourceByURI(String uri
) throws PersistentStoreException
{
43 Sync4jSource existingSource
= getSourceByURI(uri
);
44 if (existingSource
!= null) {
45 Configuration c
= Configuration
.getConfiguration();
46 PersistentStore ps
= c
.getStore();
47 ps
.delete(existingSource
);