gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.lib / org.gvsig.vcsgis.lib.impl / src / main / java / org / gvsig / vcsgis / lib / repository / localdb / requests / UsersRequestLocaldb.java @ 3573
History | View | Annotate | Download (3.19 KB)
1 |
/*
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2020 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
18 |
*
|
19 |
* For any additional information, do not hesitate to contact us
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
21 |
*/
|
22 |
|
23 |
package org.gvsig.vcsgis.lib.repository.localdb.requests; |
24 |
|
25 |
import java.util.ArrayList; |
26 |
import java.util.List; |
27 |
import org.gvsig.fmap.dal.feature.Feature; |
28 |
import org.gvsig.fmap.dal.feature.FeatureSet.DisposableFeatureSetIterable; |
29 |
import org.gvsig.tools.dispose.DisposeUtils; |
30 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_CANT_RETRIEVE_USERS; |
31 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_NO_ERROR; |
32 |
import org.gvsig.vcsgis.lib.VCSGisUser; |
33 |
import org.gvsig.vcsgis.lib.VCSGisUserImpl; |
34 |
import org.gvsig.vcsgis.lib.repository.localdb.VCSGisRepositoryLocaldb; |
35 |
import org.gvsig.vcsgis.lib.repository.localdb.tables.UsersRepoTable; |
36 |
import org.gvsig.vcsgis.lib.repository.localdb.tables.UsersRepoTable.UserRepoRow; |
37 |
import org.gvsig.vcsgis.lib.repository.requests.VCSGisUsersRequest; |
38 |
import org.gvsig.vcsgis.lib.requests.UsersRequestHelper; |
39 |
|
40 |
/**
|
41 |
*
|
42 |
* @author gvSIG Team
|
43 |
*/
|
44 |
public class UsersRequestLocaldb extends AbstractRequestLocaldb implements VCSGisUsersRequest { |
45 |
|
46 |
public UsersRequestLocaldb(VCSGisRepositoryLocaldb repository) {
|
47 |
super(new UsersRequestHelper(repository)); |
48 |
} |
49 |
|
50 |
@Override
|
51 |
public UsersRequestHelper helper() {
|
52 |
return (UsersRequestHelper) super.helper(); |
53 |
} |
54 |
|
55 |
@Override
|
56 |
public List<VCSGisUser> getUsers() { |
57 |
return helper().getUsers();
|
58 |
} |
59 |
|
60 |
@Override
|
61 |
public int execute() { |
62 |
if( !this.isAuthorized() ) { |
63 |
return this.getLastErrorCode(); |
64 |
} |
65 |
DisposableFeatureSetIterable usersTable_it=null;
|
66 |
try {
|
67 |
UsersRepoTable usersTable = new UsersRepoTable();
|
68 |
|
69 |
List<VCSGisUser> list = new ArrayList<>(); |
70 |
usersTable_it = usersTable.getAll(this.getRepository());
|
71 |
for (Feature fUser : usersTable_it) {
|
72 |
VCSGisUser user = new VCSGisUserImpl();
|
73 |
user.copyFrom(new UserRepoRow(this.getRepository(), fUser)); |
74 |
list.add(user); |
75 |
} |
76 |
helper().users = list; |
77 |
return error(ERR_NO_ERROR);
|
78 |
|
79 |
} catch (Exception ex) { |
80 |
LOGGER.warn("Can't retrieve topology plans from '"+getRepository().getLabel()+"'.",ex); |
81 |
return error(ERR_CANT_RETRIEVE_USERS, "Can't retrieve topology plans from '"+getRepository().getLabel()+"'."); |
82 |
} finally {
|
83 |
DisposeUtils.disposeQuietly(usersTable_it); |
84 |
} |
85 |
} |
86 |
|
87 |
} |